fix: keep watch dispatch from stealing the visible workspace - #802
Merged
Merged
Conversation
Watch and Fix follow-up injects write to the agent PTY without calling selectWorkspace or selectWorkspaceTab. User-initiated send still focuses the agent tab only while that workspace is already visible.
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Background Watch/Fix injects no longer call selectWorkspaceTab, so they cannot switch the visible workspace, tab, or panel.
- Activate gate -
agentTaskDispatchShouldActivaterequires bothactivateand a matchingactiveWorkspaceId, so a user-initiated send still focuses the agent tab only while that workspace is already visible. - Workbench persist-without-select -
openPersistedWorkspaceTab(activate: false)still adds the tab and skipsselectWorkspaceTab;addTabToGroupkeeps the current active tab and group. - Watch follow-ups - timer/
onPanelState_dispatchpassesactivate: false; new profile tabs persist in the background. Prompt delivery stays on the PTY/launchAgentpath, not UI focus. - Tests and policy - service and layout tests cover the gate;
AGENTS.mdrecords the no-navigation rule. Mobile comment send remains opt-in Open.
Grok | 𝕏
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.

Summary
Watch and Fix follow-up injects were calling
selectWorkspaceTab, which switched the visible workspace whenever the watched workspace was not already selected.Background dispatch now writes the prompt to the agent PTY without changing
activeWorkspaceId, the active tab, or the panel. User-initiated send (first Watch start, Fix Failed Checks, Restack, file comments) can still focus the agent tab if that workspace is already visible, and does not switch workspaces if the user has navigated away. Opening a new profile tab from a background watch persists the tab without selecting it. Toasts are unchanged.Mobile comment send still does not auto-navigate. The SnackBar Open action remains opt-in.
Validation
flutter test test/unit/agent_task_dispatch_test.dart test/unit/agent_task_dispatch_focus_test.dart test/unit/pull_request_agent_watch_test.dart test/unit/workbench_layout_test.dartflutter test test/workspace_agent_comments_test.dartfrommobile/dart analyzeon the edited desktop dispatch, watch, and workbench filesRisks