Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change: reuse empty "New Chat" panel #2087

Merged
merged 4 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This is a log of all notable changes to Cody for VS Code. [Unreleased] changes a
### Changed

- Enhanced Context used to turn off automatically after the first chat. Now it stays enabled until you disable it. [pull/2069](https://github.com/sourcegraph/cody/pull/2069)
- Chat: Reuse existing New Chat panel to prevent having multiple new chats open at once. [pull/2087](https://github.com/sourcegraph/cody/pull/2087)
- Chat: Close the Enhanced Context popover on chat input focus. [pull/2091](https://github.com/sourcegraph/cody/pull/2091)
- Chat: Show onboarding glowy dot guide until first time opening Enhanced Context. [pull/2097](https://github.com/sourcegraph/cody/pull/2097)

Expand Down
1 change: 0 additions & 1 deletion vscode/src/chat/chat-view/ChatPanelProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ export class ChatPanelProvider extends MessageProvider {
}
// selection is available to pro only at Dec GA
const isCodyProFeatureFlagEnabled = await this.featureFlagProvider?.evaluateFeatureFlag(FeatureFlag.CodyPro)
console.log(isCodyProFeatureFlagEnabled, 'isCodyProFeatureFlagEnabled')
const models = ChatModelProvider.get(authStatus.endpoint, this.chatModel)?.map(model => {
return {
...model,
Expand Down
12 changes: 12 additions & 0 deletions vscode/src/chat/chat-view/ChatPanelsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,18 @@ export class ChatPanelsManager implements vscode.Disposable {
}
}

// Reuse existing "New Chat" panel if there is an empty one
const emptyNewChatProvider = Array.from(this.panelProvidersMap.values()).find(
p => p.webviewPanel?.title === 'New Chat'
)
if (!chatID && !panel && this.panelProvidersMap.size && emptyNewChatProvider) {
emptyNewChatProvider.webviewPanel?.reveal()
this.activePanelProvider = emptyNewChatProvider
this.options.contextProvider.webview = emptyNewChatProvider.webview
void this.selectTreeItem(emptyNewChatProvider.sessionID)
return emptyNewChatProvider
}

logDebug('ChatPanelsManager:createWebviewPanel', this.panelProvidersMap.size.toString())

// Get the view column of the current active chat panel so that we can open a new one on top of it
Expand Down
Loading