Repository navigation
fix(agent-dashboard): restore focus when dismissing the drawer - #25640
kambarakun wants to merge 1 commit into
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📥 CommitsReviewing files that changed from the base of the PR and between 8f846d4 and 7de5f242dade7fb5c3d3ce3dfe8c4fa45af024e0. 📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe drawer now records its opener and content when it opens. On close, it restores focus only when the opener remains eligible and focus has not moved elsewhere. Agent reveal, pop-out, and outside dismissal use focus handoffs. New unit and end-to-end tests cover these paths, opener eligibility, and reopening behavior. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The drawer’s focus changes are mergeable after normal checks; no actionable focus regression is established. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Drawer focus capture/restore (
AgentDashboardDrawer.tsx) — auseLayoutEffectrecords the focused opener (and the sheet-content element) on each committed open transition, and a newonCloseAutoFocushandler restores it after Escape/Close/board-close while declining stale callbacks, intentional handoffs, and unavailable openers. - Focus-handoff paths — outside dismissal, successful agent reveal, and switch-to-popout now mark the close as a handoff so restoration never steals focus from a destination the user chose;
revealDashboardAgentreturns a boolean to distinguish a successful reveal from a gone workspace. - Tests — 18 component cases against the real Sheet and outside-dismiss hook, plus three real-Electron scenarios covering Escape/Close, outside dismissal/agent reveal, and reopening during the exit animation.
I read the full diff, the surrounding drawer/sidebar/hook code, and the Radix DialogContentNonModal/FocusScope source to confirm the non-modal close still fires onUnmountAutoFocus on the content element. The changed code passes pnpm tc:web and check:code-quality:changed (0 findings), and the new and neighbouring unit suites pass. I also stubbed canReturnFocus to always return true: the hidden and css-hidden cases fail, so the helper is genuinely exercised rather than tautological.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
7de5f24 to
3fea9d1
Compare
|
Thanks so much @kambarakun for tracking down the missing focus return and for the thorough Electron validation! We've landed a slightly trimmed version of your fix in #34398 (same approach, a little less code). Your authorship is preserved on the commit. Closing this one in favor of that PR. |

ELI5
Closing the Agents drawer could leave keyboard focus on the page body. Escape and the Close button now return focus to the element that opened it. Clicking another input or opening an agent still keeps focus on the destination.
What Changed
Why
This non-modal drawer is controlled by the store and has no Radix trigger. Radix's default close handling therefore cannot restore a trigger. Unconditional restoration would steal focus from an outside click or an agent pane. The drawer now owns that distinction while retaining its existing suppression of open autofocus.
Linked Issue
Fixes #25570
Visual Proof
Same sidebar → search → Escape sequence and disposable Electron fixture on both revisions. Before: activeElement is BODY; after: the exact sidebar BUTTON regains focus. These screenshots crop the same button and use a test-only inset focus outline; the outline is not a product styling change.
Before source: d173514. Captured after source: 7de5f242dade7fb5c3d3ce3dfe8c4fa45af024e0. The automated scenario also checks Close, outside-terminal input, and agent reveal.
The current PR head is
3fea9d145c6cf5bb80bf9b0f06c14d1a00d1565e. It changes only the commit message to English; its tree, parent, and author are identical to the original tested commit7de5f242dade7fb5c3d3ce3dfe8c4fa45af024e0. The screenshots, Electron results, and local three-agent reviews below were obtained before that amendment. Targeted lint,pnpm tc, the changed-code quality gate, and the same 52 files / 430 tests were rerun successfully immediately before amending. GitHub checks and reviews on the new head are tracked separately.Testing
macOS 26.5.2 arm64; Node 24.16.0, pnpm 12.8.1, Electron 43.7.5. All automated app launches used ORCA_BACKGROUND_LAUNCH=1 and disposable profiles through the existing fixture.
AI Disclosure
OpenAI Codex implemented and tested the change. An independent Codex worker (gpt-6.1-sol), CodeRabbit CLI 0.8.2, and Claude Opus 5.5 reviewed the same original tested commit (
7de5f242dade7fb5c3d3ce3dfe8c4fa45af024e0). Codex and Claude used read-only review; neither reran tests. The author performed the three guided macOS checks above and reported their outcomes in the conversation. No real AI agent was launched for the Electron fixture; synthetic status points to a disposable shell pane.Review
Review of that original tested commit found no P0/P1/P2 issues from independent Codex or Claude; CodeRabbit completed all three changed files with zero findings. No code change was needed during this review wave. The earlier animation-coverage concern was resolved with the passing Electron scenario. Navigation to a missing or not-yet-mounted pane remains governed by the existing reveal logic; this patch does not promise to repair that separate navigation behavior.
Agent skill upstream boundary
Notes
The change is confined to renderer focus policy. It uses DOM focus handling without OS-specific shortcuts or paths. Local/SSH execution, folder-workspace routing, agent integrations, and Git providers keep their existing paths; related folder-workspace and host-routing tests pass, while live remote behavior is untested. There is no new IPC, persisted field, dependency, or global listener. Opener capture runs on open transitions and restoration on close; performance was assessed from the code, not benchmarked. UI styling is unchanged. Basic security review found no new data or privilege boundary. Native mobile UI was not exercised.
X: @kambarakun
Checklist
Validated source revision:
3fea9d145c6cf5bb80bf9b0f06c14d1a00d1565e; code tree is unchanged from the reviewed7de5f242dade7fb5c3d3ce3dfe8c4fa45af024e0; upstream baseline:d17351401d7372f3f48cc3cdb423147d8c8e61c1.