Skip to content

fix(desktop-browser): keep the chat caret while the agent works and route reload/back to the browser tab - #8429

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/browser-focus-reload
Sep 29, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/browser-focus-reload

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Agent work no longer steals the keyboard from the chat composer: tab views set focusOnNavigation: false (fresh views and page-opened popups), and a hidden or not-yet-listed tab that Chromium focuses anyway (a target=_blank link opened without an opener) hands focus back to Sim
  • Focus moves into a page only on explicit user actions: omnibox Enter, opening a URL in a new tab, and foreground links the user opens; a page not yet on screen takes focus when it is first shown
  • Cmd/Ctrl+R, Cmd/Ctrl+Shift+R, F5, Shift/Ctrl+F5 typed in a page reload that page from its own keystroke instead of relying on the app menu's focus guess (which could reload all of Sim); F5 is now bound in the menu too
  • Clicking from browser chrome into the page no longer wipes the page's shortcut claim (setPanelFocused(false) keeps a claim the native page still holds)
  • Browser shortcuts (Cmd+T, reload, zoom, tab switching) work while a renderer-drawn New Tab or error page hides the native view
  • Back (Cmd+[) and new Forward (Cmd+]) move through the focused tab's history instead of navigating the Sim window
  • Cmd/middle-click and "Open Link in New Tab" open background tabs, like Chrome
  • Omnibox focus on a new blank tab is requested explicitly by the resource strip and claimed once that exact tab is on screen, so blank agent tabs never take the caret
  • Omnibox Escape backs out one step at a time (highlight, then edited text, then blur); omnibox and find bar ignore keys during IME composition
  • Error pages only move focus to their heading when the failed page held focus, never away from a field the user is typing in

Type of Change

  • Bug fix

Testing

  • New apps/desktop/e2e/browser-focus.spec.ts (Playwright _electron, writes a JSON check report to DESKTOP_BROWSER_FOCUS_REPORT_PATH): composer keeps the caret across agent open/navigate/open-tab and a target=_blank popup; omnibox navigation focuses the page; reload keys reload only the page; the page keeps its claim after chrome blur; Back/Forward move tab history; New Tab works from renderer chrome. Fails on staging at the first check, passes on this branch (3/3 repeats)
  • Real-Electron probe of the same behaviors: staging 4/13, this branch 13/13; reverting the hidden-tab focus handback turns the popup check red
  • Existing browser-tools e2e: no new failures vs staging (the viewport-screenshot test is flaky on both)
  • vitest desktop (875) and sim browser/resource suites (200), type-check both apps, bun run lint, check-block-registry, bun run check:audits, docs-manifest:check

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 29, 2026 8:28pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Browser tab focus and keyboard shortcut routing in the desktop app.

The PR appears safe to merge based on the reviewed focus and shortcut changes.

Summary

The PR keeps agent-driven browser activity from taking the chat caret and routes browser focus, reload, and history actions to the appropriate tab. Since the previous review, it adds visible-view gating for deferred focus and restores popup focus to the page the user was using.

Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Browser focus request] --> B{Explicit user action?}
  B -- No --> C[Keep current keyboard focus]
  B -- Yes --> D{Native view visible?}
  D -- Yes --> E[Focus browser page]
  D -- No --> F[Defer until view is shown]
  G[Hidden popup takes focus] --> H{Active page held focus claim?}
  H -- Yes --> I[Return focus to active page]
  H -- No --> J[Return focus to Sim]
Loading

Reviews (2) · Last reviewed commit: "fix(desktop-browser): return popup focus..."

Comment thread apps/desktop/src/main/browser-agent/session.ts Outdated
Comment thread apps/desktop/src/main/browser-agent/session.ts Outdated

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 13 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/desktop/src/main/browser-agent/session.ts Outdated
Comment thread apps/desktop/src/main/browser-agent/session.ts Outdated
Comment thread apps/desktop/src/main/browser-agent/session.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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 issues found across 14 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 113a204 into staging Sep 29, 2026
35 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/browser-focus-reload branch September 29, 2026 20:40

This branch was previously deployed

1 inactive deployment
Preview — cfed4d04 Deployed Sep 29, 2026 by vercel[bot]
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