Skip to content

Commit

Permalink
Enable moving the chat from editor back into the sidebar (#4730)
Browse files Browse the repository at this point in the history
  • Loading branch information
beyang authored Jul 1, 2024
1 parent 6ebe1f1 commit f0c2444
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 46 deletions.
45 changes: 23 additions & 22 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -452,18 +452,26 @@
{
"command": "cody.chat.panel.sidebar.new",
"category": "Cody",
"title": "New Chat",
"title": "New Chat in Sidebar",
"enablement": "cody.activated",
"group": "Cody",
"icon": "$(new-comment-icon)"
},
{
"command": "cody.chat.panel.moveFromSideBarToEditor",
"command": "cody.chat.panel.moveFromSidebarToEditor",
"category": "Cody",
"title": "Move chat to an editor panel",
"title": "Move Chat to Editor Panel",
"enablement": "cody.activated",
"group": "Cody",
"icon": "$(editor-layout)"
"icon": "$(layout-sidebar-left-off)"
},
{
"command": "cody.chat.panel.moveFromEditorToSidebar",
"category": "Cody",
"title": "Move Chat to Sidebar",
"enablement": "cody.activated",
"group": "Cody",
"icon": "$(layout-sidebar-left)"
},
{
"command": "cody.minion.panel.new",
Expand Down Expand Up @@ -551,14 +559,6 @@
"icon": "$(mention)",
"enablement": "cody.activated && resourceSet && cody.hasChatPanelsOpened"
},
{
"command": "cody.chat.panel.reset",
"category": "Cody",
"title": "New Chat Session",
"group": "Cody",
"icon": "$(clear-all)",
"enablement": "cody.activated && cody.hasChatHistory"
},
{
"command": "cody.embeddings.resolveIssue",
"title": "Cody Embeddings",
Expand Down Expand Up @@ -780,11 +780,6 @@
"command": "cody.chat.view.popOut",
"when": "false",
"_comment": "Hidden because it is only a wrapper around the workspace pop out command and would place any editor tab (not just Cody chat) in a new window."
},
{
"command": "cody.chat.panel.reset",
"when": "false",
"_comment": "Hidden because it only needs to be usable in the chat toolbar."
}
],
"editor/context": [
Expand Down Expand Up @@ -874,7 +869,7 @@
"group": "navigation@1"
},
{
"command": "cody.chat.panel.moveFromSideBarToEditor",
"command": "cody.chat.panel.moveFromSidebarToEditor",
"when": "view == cody.chat && cody.activated",
"group": "navigation@2"
},
Expand Down Expand Up @@ -912,27 +907,33 @@
"visibility": "visible"
},
{
"command": "cody.chat.panel.new",
"command": "cody.chat.panel.moveFromEditorToSidebar",
"when": "activeWebviewPanelId == cody.chatPanel && cody.activated",
"group": "navigation@1",
"visibility": "visible"
},
{
"command": "cody.chat.history.panel",
"command": "cody.chat.panel.new",
"when": "activeWebviewPanelId == cody.chatPanel && cody.activated",
"group": "navigation@2",
"visibility": "visible"
},
{
"command": "cody.chat.history.panel",
"when": "activeWebviewPanelId == cody.chatPanel && cody.activated",
"group": "navigation@3",
"visibility": "visible"
},
{
"command": "cody.chat.view.popOut",
"when": "activeWebviewPanelId == cody.chatPanel && cody.activated && !isAuxiliaryEditorPart",
"group": "navigation@3",
"group": "navigation@4",
"visibility": "visible"
},
{
"command": "cody.settings.extension.chat",
"when": "activeWebviewPanelId == cody.chatPanel && cody.activated",
"group": "navigation@4",
"group": "navigation@5",
"visibility": "visible"
}
],
Expand Down
9 changes: 5 additions & 4 deletions vscode/src/chat/chat-view/ChatManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@ export class ChatManager implements vscode.Disposable {
this.disposables.push(
vscode.commands.registerCommand('cody.action.chat', args => this.executeChat(args)),
vscode.commands.registerCommand(
'cody.chat.panel.moveFromSideBarToEditor',
'cody.chat.panel.moveFromSidebarToEditor',
async () => await this.chatPanelsManager.moveSidebarChatToEditor()
),
vscode.commands.registerCommand(
'cody.chat.panel.moveFromEditorToSidebar',
async () => await this.chatPanelsManager.moveEditorChatToSidebar()
),
vscode.commands.registerCommand(
'cody.chat.panel.sidebar.new',
async () => await this.chatPanelsManager.resetSidebar()
Expand All @@ -87,9 +91,6 @@ export class ChatManager implements vscode.Disposable {
vscode.commands.registerCommand('cody.chat.panel.restore', (id, chat) =>
this.restorePanel(id, chat)
),
vscode.commands.registerCommand('cody.chat.panel.reset', () =>
this.chatPanelsManager.resetPanel()
),
vscode.commands.registerCommand(CODY_PASSTHROUGH_VSCODE_OPEN_COMMAND_ID, (...args) =>
this.passthroughVsCodeOpen(...args)
),
Expand Down
28 changes: 9 additions & 19 deletions vscode/src/chat/chat-view/ChatPanelsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ import {
ModelsService,
featureFlagProvider,
} from '@sourcegraph/cody-shared'

import { telemetryRecorder } from '@sourcegraph/cody-shared'
import type { LocalEmbeddingsController } from '../../local-context/local-embeddings'
import type { SymfRunner } from '../../local-context/symf'
import { logDebug } from '../../log'
// biome-ignore lint/nursery/noRestrictedImports: Deprecated v1 telemetry used temporarily to support existing analytics.
import { telemetryService } from '../../services/telemetry'
import { TreeViewProvider } from '../../services/tree-views/TreeViewProvider'
import type { MessageProviderOptions } from '../MessageProvider'
import type { ExtensionMessage } from '../protocol'
Expand Down Expand Up @@ -294,22 +290,16 @@ export class ChatPanelsManager implements vscode.Disposable {
await Promise.all([this.createWebviewPanel(sessionID), this.resetSidebar()])
}

/**
* Clear the current chat view and start a new chat session in the active panel
*/
public async resetPanel(): Promise<void> {
logDebug('ChatPanelsManager', 'resetPanel')
telemetryService.log(
'CodyVSCodeExtension:chatTitleButton:clicked',
{ name: 'clear' },
{ hasV2Event: true }
)
telemetryRecorder.recordEvent('cody.interactive.clear', 'clicked', {
privateMetadata: { name: 'clear' },
})
if (this.activePanelProvider) {
return this.activePanelProvider.clearAndRestartSession()
public async moveEditorChatToSidebar(): Promise<void> {
const sessionID = this.activePanelProvider?.sessionID
if (!sessionID) {
return
}
await Promise.all([
this.sidebarProvider.restoreSession(sessionID),
vscode.commands.executeCommand('workbench.action.closeActiveEditor'),
])
await vscode.commands.executeCommand('cody.chat.focus')
}

public async restorePanel(
Expand Down
3 changes: 2 additions & 1 deletion vscode/test/e2e/update-notice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ test('new installs should not show the update toast', async ({ page, sidebar })
).toMatch(/\d+\.\d+/)
})

test('existing installs should show the update toast when the last dismissed version is different', async ({
// TODO(beyang): fix flaky
test.skip('existing installs should show the update toast when the last dismissed version is different', async ({
page,
sidebar,
}) => {
Expand Down

0 comments on commit f0c2444

Please sign in to comment.