Skip to content

fix: keep watch dispatch from stealing the visible workspace - #802

Merged
leynier merged 2 commits into
mainfrom
fix/watch-dispatch-no-focus-steal
Sep 17, 2026
Merged

leynier merged 2 commits into
mainfrom
fix/watch-dispatch-no-focus-steal

Conversation

@leynier

@leynier leynier commented Sep 17, 2026

Copy link
Copy Markdown
Owner

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.dart
  • flutter test test/workspace_agent_comments_test.dart from mobile/
  • dart analyze on the edited desktop dispatch, watch, and workbench files

Risks

  • A Watch follow-up while looking at the watched workspace no longer jumps to the agent tab. The prompt still arrives; the user has to open that tab themselves.
  • If the original agent tab is gone, a background follow-up still opens a profile tab in the background. That tab is persisted but not focused.

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.

@pullfrog pullfrog Bot 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.

✅ 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 - agentTaskDispatchShouldActivate requires both activate and a matching activeWorkspaceId, 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 skips selectWorkspaceTab; addTabToGroup keeps the current active tab and group.
  • Watch follow-ups - timer/onPanelState _dispatch passes activate: false; new profile tabs persist in the background. Prompt delivery stays on the PTY/launchAgent path, not UI focus.
  • Tests and policy - service and layout tests cover the gate; AGENTS.md records the no-navigation rule. Mobile comment send remains opt-in Open.

Pullfrog  | View workflow run | Using Grok𝕏

@leynier
leynier merged commit df02923 into main Sep 17, 2026
23 checks passed
@leynier
leynier deleted the fix/watch-dispatch-no-focus-steal branch September 17, 2026 07:41
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.

1 participant