Repository navigation
sessions: focus the main window and moved chat after Move to Main Window - #348025
Open
Sandeep Somavarapu (sandy081) wants to merge 8 commits into
Open
Sandeep Somavarapu (sandy081) wants to merge 8 commits into
Sandeep Somavarapu (sandy081) wants to merge 8 commits into
Conversation
Fixes #347102 Co-authored-by: Copilot <[email protected]>
…e main window Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change restoring chat focus after moving to the main window.
No open issues 🎉
What changed in this PR
Fixes #347102 by restoring focus after Move to Main Window in the Agents window, so users can continue typing in the moved chat.
Changes:
- Focuses the main window and active session after opening moved chats and editors.
- Reactivates the first moved chat when several chats move together.
- Updates tests to verify focus ordering and confirm that focus stays unchanged when no chat moves.
No actionable findings remain. Reported live validation does not cover real OS window raising, drag moves, or same-session multi-chat moves.
| File | Description |
|---|---|
src/vs/sessions/contrib/chatWindow/test/browser/sessionsChatWindowProvider.test.ts |
Records focus calls and tests successful and no-op moves. |
src/vs/sessions/contrib/chatWindow/browser/sessionsChatWindowProvider.ts |
Adds main-window and session focus, preserves first-chat selection, and extracts moved-editor opening. |
Review effort: Balanced
Dmitriy Vasyura (dmitrivMS)
previously approved these changes
Nov 12, 2026
Sandeep Somavarapu (sandy081)
marked this pull request as draft
November 12, 2026 23:41
The chat group replaces its content view when the chat settles (for example a moved chat resolving), which detached the focused input and dropped focus to the body. Move focus to the new view when the old one held it. Co-authored-by: Copilot <[email protected]>
A document keeps its last active element while another window is focused, so a background view swap could steal focus. Also require the group's window to have focus. Co-authored-by: Copilot <[email protected]>
The retained check compared getFocusedSessionView(), which follows DOM focus and was only equal by both being unfocused. Focus now follows a swapped view, so assert the surviving pane through the active pane state instead. Co-authored-by: Copilot <[email protected]>
The detach test guards that re-detaching the chat of a detached pane keeps that pane. Assert the pane's element identity and attachment instead of the focused view. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
…ctive pane Co-authored-by: Copilot <[email protected]>
Sandeep Somavarapu (sandy081)
marked this pull request as ready for review
November 13, 2026 08:30
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Ladislau Szomoru (@lszomoru)Matched files:
|
Alexandru Dima (alexdima)
approved these changes
Nov 13, 2026
Benjamin Christopher Simmonds (benibenj)
approved these changes
Nov 13, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #347102
After Move to Main Window, the moved chat was not focused. Two things were wrong:
SessionsChatWindowProvider.moveToMainWindownow, after opening the moved chats and editors, focuses the main window and then the active session. With several chats moved together, the first moved chat is re-opened (without focus) so it is the active one, matchingopenMovedChatsorder. Only user-initiated move paths reach this method; close, quit and restore paths are guarded and unchanged.setContextautorun inChatGroupViewswaps the content view when the pane's kind changes (for example new session to chat). That detached the focused input, so focus fell toBODY.ChatGroupViewnow remembers whether focus was inside the old view and, once the new view is installed, focuses it. This only happens when the old view's own document is the one that has window focus (an injectable_hasWindowFocuspredicate, the same patternChatGroupsViewalready uses), so a background or other-window chat never claims focus. Focus elsewhere in the same window, such as another group, the sidebar or the editor, is left untouched.How to test: open a chat in a new window, use Move to Main Window in the chat window header; the main window comes to front with the moved chat shown and its input focused. Also move two chats of the same session together; the first should be focused.
Tests:
ChatGroupViewtests with a real DOM: focus inside the old view is restored in the new view after a swap; focus elsewhere in the same document is left alone; a staleactiveElementin a document that does not have window focus is not restored.sessionsManagementService.test.ts"detaching a chat without dragging creates a pane that survives closing its parent": itsretainedcheck usedgetFocusedSessionView(), which follows DOM focus and only passed by accident (nothing was focused). It now captures the two pane elements before the parent closes and asserts exactly one stays connected and is the sole remaining pane. It no longer depends on focus or on which pane is active, which differs between the Electron and browser runners.Validation:
sessionsManagementService.test.ts: 445 passingnode test/unit/browser/index.js --run src/vs/sessions/services/sessions/test/browser/sessionsManagementService.test.ts --browser chromium: 444 passing./scripts/test.sh --runonsessionsChatWindowProvider.test.ts,chatGroupsView.test.ts: 203 passing (on the fix commits, before the test-only follow-ups)pnpm run typecheck-clientandpnpm run oxlinton the changed files: exit 0document.hasFocus()true,activeElementin the moved chat's input, stable when sampled every 300 ms for 3 s) and for a normal session switch while typing in main (no unexpected focus jump; weak check). Before the fixactiveElementwasBODY.ChatGroupViewtests and a reviewer trace), and the drag-out path.