Skip to content

agentHost: make archived chat workspace tests wait for queued updates - #341882

Merged
Sandeep Somavarapu (sandy081) merged 1 commit into
mainfrom
sandy081/fix-windows-archive-worktree-test
Oct 15, 2026
Merged

Sandeep Somavarapu (sandy081) merged 1 commit into
mainfrom
sandy081/fix-windows-archive-worktree-test

Conversation

@sandy081

Copy link
Copy Markdown
Member

Problem

AgentService (node dispatcher) › additional chat working directories › archiving a peer chat in its own worktree detaches the worktree without deleting it fails intermittently on Windows / Electron-Unit across unrelated PRs (for example #341843 and #341869).

The test (added in #341782) checks state after a fixed await timeout(10). Archiving a chat queues the worktree update on a per-session sequencer: the archive task detaches the worktree right away, then awaits the persistence of the session's working directories, which goes through SQLite. The unarchive task waits behind it. On slower Windows disk I/O, 10 ms isn't enough, so the assertion runs before the unarchive has re-attached the worktree. The CI diff shows afterUnarchive with the same arrays as afterArchive.

The product ordering is correct. This is a test-only fix.

Change

  • agentServiceTestUtils.ts: add whenArchivedChatWorkspaceUpdatesSettled(svc, session). It queues a no-op update behind the per-session sequencer, so it resolves only after every queued archive/unarchive update and its persistence.
  • agentService.test.ts: both archive tests (folder and worktree) await that barrier instead of timeout(10). The worktree test also holds the catalog persistence on purpose, dispatches unarchive while the archive is still persisting, then releases it, so the slow-I/O ordering is checked deterministically.

Validation

  • Before the fix, a 20 ms delay injected into _persistSessionWorkingDirectories reproduced the exact CI diff locally.
  • After the fix:
    • 20 ms and 200 ms injected latency: passed.
    • 50 runs in a loop: 50/50 passed.
    • 50 runs with 20 ms latency: 50/50 passed.
  • Mutations: unarchive never re-attaches → both tests fail; a barrier that doesn't wait → both tests fail.
  • ./scripts/test.sh --runGlob "**/agentHost/test/node/**/*.test.js": passed, 11197 passing / 75 pending / 0 failing.
  • npm run typecheck-client: passed. npm run eslint -- <changed files>: passed. Hygiene: passed.

Archiving or unarchiving a peer chat updates the session workspace
asynchronously, one update at a time per session, and each update persists the
session's folders before the next starts. The tests from #341782 slept 10ms
instead of waiting for these updates, so when persisting the detached worktree
took longer, as on Windows CI, the unarchive had not attached it back yet.

Wait for the queued updates instead, and hold the archive's persistence while
unarchiving so the worktree test covers the slow case deterministically.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sandy081 Sandeep Somavarapu (sandy081) added this to the 1.143.0 milestone Oct 15, 2026
Copilot AI balanced review requested due to automatic review settings October 15, 2026 22:11

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

The focused test-only changes preserve existing assertions and address timing sensitivity, with no actionable issues identified.

0 open findings

What changed in this PR

Makes Agent Host archive/unarchive workspace tests deterministic without changing production behavior.

Changes:

  • Replaces fixed delays with a per-session queue barrier.
  • Simulates slow persistence to verify queued unarchive ordering.
File Description
src/​vs/​platform/​agentHost/​test/​node/​agentServiceTestUtils.ts Adds a helper that waits for queued workspace updates.
src/​vs/​platform/​agentHost/​test/​node/​agentService.test.ts Uses the barrier and adds controlled persistence blocking.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

3 participants