From e454459858d9dd60f0cbc3e91062746719de2b5a Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Tue, 3 Nov 2026 15:43:44 -0500 Subject: [PATCH] smoke: wait for the local chat before sending to it smoketest.openLocalChat keeps running after the command palette closes, and first waits for the command that opens a local chat. The tests only waited for the chat view, so when that command registered late they sent their message to the view's default Agent Host Copilot session, which never answered, and Chat Model Configuration failed its warm-up. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- test/automation/src/chat.ts | 18 ++++++++++++++++++ .../src/areas/browserView/browserView.test.ts | 3 ++- .../src/areas/chat/chatModelConfig.test.ts | 3 ++- test/smoke/src/areas/chat/chatSandbox.test.ts | 3 ++- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/test/automation/src/chat.ts b/test/automation/src/chat.ts index b48305924a6506..f5a4ff5bde9905 100644 --- a/test/automation/src/chat.ts +++ b/test/automation/src/chat.ts @@ -10,6 +10,8 @@ const CHAT_VIEW = 'div[id="workbench.panel.chat"]'; // The chat view sets `data-bound-chat-resource` once its widget is bound to a // chat session and clears it while it rebinds to another one. const CHAT_VIEW_BOUND_SESSION = `${CHAT_VIEW} .chat-viewpane[data-bound-chat-resource]`; +// The resource of a local chat session (`LocalChatSessionUri`). +const LOCAL_CHAT_SESSION_RESOURCE_PREFIX = 'vscode-chat-session://local/'; const CHAT_EDITOR = '.editor-instance .interactive-session'; const CHAT_INPUT_EDITOR = `${CHAT_VIEW} .interactive-input-part .monaco-editor[role="code"]`; const CHAT_INPUT_EDITOR_FOCUSED = `${CHAT_VIEW} .interactive-input-part .monaco-editor.focused[role="code"]`; @@ -78,6 +80,22 @@ export class Chat { await this.code.waitForElement(CHAT_VIEW_BOUND_SESSION, element => !!element && element.attributes['data-bound-chat-resource'] !== previousSessionResource, retryCount); } + /** + * Waits until the chat view is bound to a local chat session other than + * `previousSessionResource`, such as the one `smoketest.openLocalChat` + * opens. That command keeps running after the command palette closes, and + * first waits for the command that opens a local chat to be registered: a + * message sent before then goes to the session the view had, such as the + * Agent Host Copilot session that is its default, and never gets the + * response the test expects. + */ + async waitForNewLocalChatViewSession(previousSessionResource: string | undefined, retryCount?: number): Promise { + await this.code.waitForElement(CHAT_VIEW_BOUND_SESSION, element => { + const sessionResource = element?.attributes['data-bound-chat-resource']; + return !!sessionResource && sessionResource !== previousSessionResource && sessionResource.startsWith(LOCAL_CHAT_SESSION_RESOURCE_PREFIX); + }, retryCount); + } + async waitForChatEditor(retryCount?: number): Promise { await this.code.waitForElement(CHAT_EDITOR, undefined, retryCount); } diff --git a/test/smoke/src/areas/browserView/browserView.test.ts b/test/smoke/src/areas/browserView/browserView.test.ts index 063e463be7aa67..98f938abc1c0d4 100644 --- a/test/smoke/src/areas/browserView/browserView.test.ts +++ b/test/smoke/src/areas/browserView/browserView.test.ts @@ -317,8 +317,9 @@ export function setup(logger: Logger): void { await workbenchPage.locator('.tab', { hasText: 'Browser Smoke Sharing' }).click(); await unshareButton.waitFor(); + const previousSessionResource = await app.workbench.chat.getChatViewSessionResource(); await app.workbench.quickaccess.runCommand('smoketest.openLocalChat'); - await app.workbench.chat.waitForChatView(); + await app.workbench.chat.waitForNewLocalChatViewSession(previousSessionResource, 600); await app.workbench.chat.sendMessage('[scenario:browser-sharing-click-success]'); const successToolResult = await waitForScenarioToolResult(mockServer, 'browser-sharing-click-success'); assert.doesNotMatch(successToolResult, /not found/i); diff --git a/test/smoke/src/areas/chat/chatModelConfig.test.ts b/test/smoke/src/areas/chat/chatModelConfig.test.ts index b45e8838fd560b..2c5524624644fc 100644 --- a/test/smoke/src/areas/chat/chatModelConfig.test.ts +++ b/test/smoke/src/areas/chat/chatModelConfig.test.ts @@ -226,8 +226,9 @@ export function setup(logger: Logger) { // override is applied on the agent request path). Select the local // harness explicitly since the panel default is Agent Host Copilot // when the agent host is enabled. + const previousSessionResource = await chat.getChatViewSessionResource(); await app.workbench.quickaccess.runCommand('smoketest.openLocalChat'); - await chat.waitForChatView(); + await chat.waitForNewLocalChatViewSession(previousSessionResource, 600); // Retry the warm-up send until the model actually replies, which // confirms copilot-chat is active and the panel is usable. diff --git a/test/smoke/src/areas/chat/chatSandbox.test.ts b/test/smoke/src/areas/chat/chatSandbox.test.ts index b9ccfb7b2af68b..c58b957b2c503d 100644 --- a/test/smoke/src/areas/chat/chatSandbox.test.ts +++ b/test/smoke/src/areas/chat/chatSandbox.test.ts @@ -212,8 +212,9 @@ export function setup(logger: Logger): void { before(async function () { const app = this.app as Application; + const previousSessionResource = await app.workbench.chat.getChatViewSessionResource(); await app.workbench.quickaccess.runCommand('smoketest.openLocalChat'); - await app.workbench.chat.waitForChatView(); + await app.workbench.chat.waitForNewLocalChatViewSession(previousSessionResource, 600); await warmUpChat(app.workbench.chat, mockServer, logger); });