Skip to content

smoke: wait for smoketest.openLocalChat to finish before using the Chat view - #350133

Merged
Ladislau Szomoru (lszomoru) merged 1 commit into
mainfrom
lszomoru/agents/fix-flaky-electron-chat-test
Nov 24, 2026
Merged

Ladislau Szomoru (lszomoru) merged 1 commit into
mainfrom
lszomoru/agents/fix-flaky-electron-chat-test

Conversation

@lszomoru

Copy link
Copy Markdown
Member

TL;DR: Chat Sessions › Test Local session could send its prompt to the Chat view's own startup session before smoketest.openLocalChat had run. That session is a local chat when the Agent Host is not available yet. When the command ran a few seconds later, New Local Chat opened a new chat and moved the running one to the sessions list, so the reply never showed in the view. The command now signals when it has finished, and the tests wait for that signal.

CI failure

Root cause

From the failing job's logs, Playwright trace and screencast (UTC):

Time What happened
11:42:37.662 [driver] Workbench contributions created, and the test starts
11:42:37.668 The test reads the view's bound session. There is none yet, so previousSessionResource is undefined
11:42:37.830 The Agent Host connection fails, and the client reconnects
11:42:37.873 The Chat view has bound its startup session. With no Agent Host Copilot agent, ChatViewPane.acquireDefaultNewSession falls back to a local chat: vscode-chat-session://local/YWUz…
11:42:38.014 The test runs smoketest.openLocalChat from the command palette, which closes right away
11:42:38.256 waitForNewLocalChatViewSession(undefined) sees local/YWUz… and returns
11:42:38.608 The test sends its prompt to that session
11:42:41.074 The extension host activates the smoke test extension (activationEvent: 'onCommand:smoketest.openLocalChat'). Until then it was still activating the eager extensions
11:42:41.94–42.06 The command's New Local Chat replaces the view's chat with a new, empty one. The running chat shows as "Working…" in the sessions list
11:42:42.363 The reply is produced (panel/editAgent succeeds) in the background chat

The view works as designed: New Local Chat opens a new chat and leaves a running one in the sessions list. The test raced its own command.

A passing shard 2 run from the same day (https://github.com/microsoft/vscode/actions/runs/45387330297) shows the same late activation. There, the view's startup session was an Agent Host Copilot session (agent-host-copilotcli:/untitled-…), which the wait skips, so the test waited for the command's local chat. The flake needs both conditions: a local startup session because the Agent Host is not available yet, and the test reading the view before that session is bound.

Earlier fixes narrowed the same race:

Neither can tell the command's local chat from a local startup session.

Fix

  • smoketest.openLocalChat writes a marker file to os.tmpdir() once workbench.action.chat.newLocalChat has resolved. That action awaits ChatViewPane.startNewLocalSession(), so the view is bound to the new chat by then. The same extension already signals the extension host restart tests through files in os.tmpdir().
  • A new openLocalChatInChatView(app) helper in test/smoke/src/utils.ts removes the marker, runs the command, and waits for the marker. It then checks that the view shows a new local chat.
  • All four callers of the command use the helper: Chat Sessions, Chat Sandbox, Chat Model Configuration and Integrated Browser. They all had the same race; the others mostly survived it through warm-up retries.
  • The doc of Chat.waitForNewLocalChatViewSession now says that the wait alone does not identify which command bound the session.

There is no product change, since the switch is the expected New Local Chat behavior.

Validation

To reproduce the CI ordering deterministically on macOS arm64 (from source), I made these temporary edits, which are not part of this PR:

  • Delayed smoketest.openLocalChat by 8s before New Local Chat.
  • Set chat.defaultToCopilotHarness: false and chat.editor.preferCopilotHarness: false, so the view's startup session is local.
  • Delayed the first Local reply by 15s.
  • Added a REPRO_BASELINE=1 switch that selects the previous openSession.

With those edits:

  • REPRO_BASELINE=1 pnpm run smoketest-no-compile -g 'Chat Sessions Test Local session$' --tracing (previous wait): failed with the CI error. The failure screenshot matches CI: the sessions list with the session, and an empty new chat input.
  • pnpm run smoketest-no-compile -g 'Chat Sessions Test Local session$' --tracing (this PR): passed. The test waited for the delayed command, then got the reply.

Without the repro edits:

  • pnpm run smoketest -g "Chat Sessions" --tracing, 4 runs: passed every time (3 passing: Local, Local run in terminal, Agent Host Copilot).
  • pnpm run smoketest-no-compile -g "Chat Sandbox|Chat Model Configuration|allows agents to use shared pages" --tracing: passed (10 passing).
  • cd test/smoke && pnpm run compile (tsc for test/automation and test/smoke): passed.
  • pnpm run oxlint on the 7 changed files: passed. Pre-commit hygiene: passed.
  • No unit tests or pnpm run typecheck-client, because nothing under src/ changed.

…at view

In a fresh window, `smoketest.openLocalChat` can run seconds after the
command palette closes: the extension host activates the smoke test
extension on that command only once it has activated the eager
extensions. Meanwhile the Chat view binds its own startup session, which
is a local chat when the Agent Host is not available yet. When the test
read the view before that binding, `waitForNewLocalChatViewSession`
accepted the startup session, the prompt went to it, and the late New
Local Chat then moved it to the sessions list, so its reply never showed
in the view.

The command now writes a marker file once New Local Chat has finished,
and the new `openLocalChatInChatView` helper waits for it before checking
the view's session. All four callers of the command use the helper.

🤖 Authored with GitHub Copilot on behalf of @lszomoru.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 12:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the smoke-test synchronization change.

No open issues 🎉

What changed in this PR

Fixes a smoke-test race where prompts could reach the Chat view’s startup session before smoketest.openLocalChat finished. The change strengthens test synchronization without changing product behavior.

Changes:

  • Signals completion with a temporary marker file after New Local Chat resolves.
  • Adds a shared helper that waits for command completion and verifies a new local session, then adopts it in four smoke-test suites.
  • Clarifies that the existing session-binding wait alone cannot identify which command opened a session.
File Description
test/​smoke/​src/​utils.ts Adds the shared command-completion and session-verification helper.
test/​smoke/​src/​areas/​chat/​chatSessions.test.ts Uses the helper when opening local chats in the view.
test/​smoke/​src/​areas/​chat/​chatSandbox.test.ts Waits for command completion before chat warm-up.
test/​smoke/​src/​areas/​chat/​chatModelConfig.test.ts Uses the helper before model-configuration warm-up.
test/​smoke/​src/​areas/​browserView/​browserView.test.ts Uses the helper before sending browser-sharing prompts.
test/​smoke/​extensions/​vscode-smoketest-ext-host/​extension.js Writes the completion marker after New Local Chat resolves.
test/​automation/​src/​chat.ts Updates documentation to explain the session wait’s limitations; no behavior change.

Review effort: Balanced

@lszomoru
Ladislau Szomoru (lszomoru) marked this pull request as ready for review November 24, 2026 12:47
@lszomoru
Ladislau Szomoru (lszomoru) added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit ce6a39e Nov 24, 2026
37 checks passed
@lszomoru
Ladislau Szomoru (lszomoru) deleted the lszomoru/agents/fix-flaky-electron-chat-test branch November 24, 2026 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants