You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Keep overlays open when focusing the chat composer - #37403
Quick launch and other open menus or dialogs can flash closed when the chat composer takes focus.
Solution
Let open overlays keep focus when the composer becomes ready or tries to recover focus. Dismissed overlays and dialogs containing the chat can still allow the composer to receive focus.
ELI5
When you open a menu, chat waits instead of pulling your attention away and closing it.
What Changed
The chat composer checks for visible overlays before requesting or recovering focus. Tests cover menus, dialogs, queued focus recovery, dismissed menus, and chat hosted inside a dialog.
Why
Open overlays should keep control of focus until they are dismissed. Reusing the existing overlay check also handles overlays that are closing or contain the chat.
Linked Issue
None.
Visual Proof
TODO: Attach before and after video.
Testing
Automated tests were added for the focus behavior. Test execution and manual platform testing are not confirmed.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Risk
Level: Medium. Focus recovery could be skipped when an overlay is open, leaving the composer unfocused. A regression could affect chat users on any platform. Revert the change to restore the previous behavior.
AI Disclosure
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Cross-platform, SSH, mobile, compatibility, security, and performance verification remain unconfirmed.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
Overlay ownership utilities and UI components track focus scopes and dismissal. Composer focus requests use overlay ownership to coordinate focus recovery across menus, dialogs, sheets, suggestion menus, editors, and panes. The changes also add tests for delayed focus, cancellation, nested overlays, and dismissal. Quote insertion now passes selected text through a callback that closes the context menu and appends the formatted quote to the composer.
Merge Risk: Low · previous review d8102
An open attachment search can prevent automatic composer focus. Users can click the composer as a workaround; this limitation should be addressed.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 16.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title clearly describes the main change: preventing overlays from closing when the chat composer receives focus.
Description check
The description follows the required structure and explains the problem, solution, scope, testing, and risk. It is mostly complete, although the linked issue is listed as None and the required visual …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description follows the required structure and explains the problem, solution, scope, testing, and risk. It is mostly complete, although the linked issue is listed as None and the required visual proof remains TODO.
Full details: Docstring Coverage
Explanation
Docstring coverage is 16.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 37 functions across 34 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches
Generate docstrings
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
The reason will be displayed to describe this comment to others. Learn more.
Follow-up Comments
Mark the attachment result list as page content so it does not suppress composer focus.
19-23: Minor · Functional Correctness · Quick win
Mark the attachment result list as page content so it does not suppress composer focus.
The inline attachment result list in WorkspaceAttachmentSearch has no data-focus-behavior="page" marker. The list renders whenever query.trim() is nonempty, and the query persists after the search loses focus. getOverlayFocusOwners therefore counts the list as a visible overlay owner, including when it sits outside the chat root.
At the full PR base, composer focus requests were not gated on overlay owners. With this PR, a visible stale result list can cause a composer reveal or tab re-activation focus request to return early. The composer does not receive focus, and the user must click it. This regression is introduced by the new focus guard. The attachment component itself was not changed by the PR.
The correction is to mark this inline result list as page content, using the same data-focus-behavior="page" convention that the overlay ownership module already excludes. Apply the marker to the element that the overlay selector matches, which is the listbox that SmartWorkspaceSourceResultList renders. Confirm that selector before changing the marker location. The exact element and prop path were not inspected, so no code diff is proposed.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Scope recovery overlays to their own pane and let menus dismiss before
returning focus to the composer. This keeps the quick launcher open
when delayed chat actions complete.
Track focus ownership through portaled overlays so the launch prompt can
regain focus while its model list is open. Close the context menu before
inserting a quote so the caret lands after it.
* Preserve open overlays when focusing the chat composer
* Fix chat composer focus after launch menus close
* Fix chat composer focus handoff after overlays close
* Fix composer focus after custom overlays close
* Prevent chat composer from stealing overlay focus
Scope recovery overlays to their own pane and let menus dismiss before
returning focus to the composer. This keeps the quick launcher open
when delayed chat actions complete.
* Fix composer focus across nested overlays
Track focus ownership through portaled overlays so the launch prompt can
regain focus while its model list is open. Close the context menu before
inserting a quote so the caret lands after it.
* Fix overlay focus CI regressions
* Complete overlay focus ownership for inline and retained surfaces
* Declare public overlay focus hook return type
(cherry picked from commit b96d19d)
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
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.
Problem
Quick launch and other open menus or dialogs can flash closed when the chat composer takes focus.
Solution
Let open overlays keep focus when the composer becomes ready or tries to recover focus. Dismissed overlays and dialogs containing the chat can still allow the composer to receive focus.
ELI5
When you open a menu, chat waits instead of pulling your attention away and closing it.
What Changed
The chat composer checks for visible overlays before requesting or recovering focus. Tests cover menus, dialogs, queued focus recovery, dismissed menus, and chat hosted inside a dialog.
Why
Open overlays should keep control of focus until they are dismissed. Reusing the existing overlay check also handles overlays that are closing or contain the chat.
Linked Issue
None.
Visual Proof
TODO: Attach before and after video.
Testing
Automated tests were added for the focus behavior. Test execution and manual platform testing are not confirmed.
Risk
Level: Medium. Focus recovery could be skipped when an overlay is open, leaving the composer unfocused. A regression could affect chat users on any platform. Revert the change to restore the previous behavior.
AI Disclosure
Review
Agent skill upstream boundary
Notes
Cross-platform, SSH, mobile, compatibility, security, and performance verification remain unconfirmed.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)