sessions: Preserve focus during background session replacement #336720

Merged
chrmarti opened 2:00am on September 18, 2026 wanted to merge 268 Ξ” into microsoft/vscode main from
chrmarti/preserve-session-replacement-focus
Diff Delta:
268
About 52 Diff Delta/hour
Classified as:  Feature Improvement

chrmarti's Description of Work

Summary

Fix the focus race behind intermittent WSL Dev Container smoke timeouts, with follow-up diagnostics and cancellation-safe Windows CI log publication.


  • Sample focus ownership before replacing a session: restore composer focus only when the replaced session view owned it. Otherwise preserve focus in Quick Input or another surface.

  • Publish the replacement's focus intent atomically with the active session. Preserve normal explicit navigation.

  • Add regression coverage for external focus, focused-composer replacement, explicit navigation, and atomic focus intent.

  • Print bounded, redacted WSL picker/focus/notification and renderer/shared-process diagnostics to smoke task output while preserving the original failure.

  • Publish Windows diagnostic logs and stop lingering test processes even on cancellation. Allow ten minutes for cancellation cleanup/publication; normal job and picker timeouts are unchanged.

Reproduction

Investigating Azure build 474825, a normal local repetition reproduced the picker timeout. Temporary focus instrumentation then captured background draft recreation calling focusSession while Connect via WSL was visible, dismissing the picker on blur before any WSL host connection started.

The original Azure attempt also hit its job timeout during post-test scanning, which skipped log publication and lost its screenshot/trace. The cancellation changes address that separate diagnostics gap.

Validation


  • Regression test failed before the fix and passes afterward.

  • Focused session suites after rebase: 229 passing, 2 pending.


  • npm run typecheck-client, client transpilation, smoke/automation compilation, scoped hygiene, and whitespace checks passed.

  • Real WSL Dev Container UI smoke: three consecutive passes before rebase, plus another pass after rebasing onto origin/main.

  • Injected WSL startup failure verified diagnostic output, token redaction, and preservation of the original timeout; temporary instrumentation removed.

  • Azure YAML parsed locally. Cancellation-time artifact publication has not yet been exercised in CI.

Follow-up to #336573. This branch contains one new commit on top of origin/main.

11 total changed files
(2 files ignored)
Loading changes...
Loading changes...
Review complete πŸ’ͺ
Your attention span may now revert to "default human"