Skip to content

Commit

Permalink
VS Code: Reload window on first activation event (#4989)
Browse files Browse the repository at this point in the history
CLOSE
https://linear.app/sourcegraph/issue/CODY-3007/new-sidebar-ui-does-not-get-picked-up-on-extension-reload

Add a condition to check if `newSidebarChatUI_isReloaded` has been set
before or not.

If not, reload the window to ensure the new webview is registered before
the extension host is activated.

After discussing with @kalanchan and @vovakulikov , we think this is a
better approach than showing the CTA to ask users to reload without
knowing if the user has reloaded or not.

## Test plan

<!-- Required. See
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles.
-->

Green CI - The extension should not be affected by this change and work
as expected.

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
  • Loading branch information
abeatrix authored Jul 24, 2024
1 parent 0e5a6e5 commit 29ccc37
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions vscode/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ export async function start(
context: vscode.ExtensionContext,
platform: PlatformContext
): Promise<vscode.Disposable> {
// NOTE: Hack to ensure the window is reloaded when extension is restarted after upgrade
// to get the updated sidebar chat UI. Can be removed after the next release (1.28).
if (
!context.globalState.get('newSidebarChatUI_isReloaded', false) &&
process.env.CODY_TESTING !== 'true'
) {
// First activation, set the flag and then reload the window
await context.globalState.update('newSidebarChatUI_isReloaded', true)
await vscode.commands.executeCommand('workbench.action.reloadWindow')
}

const isExtensionModeDevOrTest =
context.extensionMode === vscode.ExtensionMode.Development ||
context.extensionMode === vscode.ExtensionMode.Test
Expand Down

0 comments on commit 29ccc37

Please sign in to comment.