fix(web): clicked workspace areas no longer show the focus ring after a stray key#33525
Problem
Click an empty part of the conversation or home area. Then press any bare key, such as Shift or Meta. A 2px focus ring appears around the whole area. A window switch can send that key for you (Hyprland focus-follows-mouse, a Super-key window switch), so the ring shows up with no keyboard navigation at all.
The cause is [data-workspace-area]:focus-visible. Chromium turns :focus-visible on for the element that already has focus when a key arrives. The same selector made the window-return check treat a clicked area as "reached from the keyboard", so the caret did not go back to the composer.
Change
The workspace focus controller now marks an area with data-workspace-keyboard-focus only when keyboard focus arrives on it: F6, a focus request, or focus that returns from a dialog. A pointer press, focus moving elsewhere, and dispose clear the mark. Window activation refocuses the same element, so it does not count as an arrival.
The ring in index.css and shouldRefocusComposerOnWindowFocus read the mark instead of :focus-visible.
This replaces #28191 by @juliusmarminge, which was 1160 commits behind main and had a conflict. The five original commits are kept with their authorship. The one conflict was in ChatView.logic.ts: main renamed the sidebar selector to [data-sidebar-row]:focus-visible, and this branch keeps that name.
Scope and approval
Fixes pingdotgg/t3code#28166
Verification
Web app from vp run dev, T3 Code browser panel, 1280x800. Steps: click the empty conversation area, then press Shift.
Before (main 2da1b7431d) | After |
|---|---|
| Ring around the clicked conversation area | No ring around the clicked conversation area |
outline: solid 2px | outline: none |
F6 still shows the ring, and a click removes it again:
Ring on the conversation area after Shift+F6
vp test run --project browser src/lib/workspaceFocus.browser.test.ts src/components/ChatView.logic.browser.test.ts(apps/web): 21 passed.vp run check:changed: format, lint, knip, typecheck, tests, and React compiler pass.- The original PR also records an Electron run with real window activation between two windows.
Not checked:
- Hyprland or another Wayland session. The key press here was synthetic.
- Desktop (Electron) on this rebased branch.
- If a focused control is removed after a stray key, focus recovery can still mark the area and show the ring.
Original work: Claude Opus 5.5 and GPT-6.1 Sol in T3 Code. Rebase, conflict fix, and verification: Claude Fable 5 in Claude Code.
🤖 Generated with Claude Code
Checks
Added 5 commits
- fix(web): F6 onto the only, already focused area shows its ring2c706af
- fix(web): clicked workspace areas no longer ring after a bare key press36b0d0d
- test(web): reproduce #28166, clicked workspace area rings after a bare key press3732af5
- fix(web): keep the area ring when keyboard focus returns to an areabdaa27e
- test(web): name the ring-clearing assertion for what it checkse439158
Approvability
Verdict: Approved at 2c706af
Macroscope's review found this PR approvable — Workspace focus rings and window-return focus now use an explicit keyboard-focus marker, avoiding stray rings after pointer interaction. The change is limited to transient UI focus behavior and preserves existing input and popup protections.
You can add or adjust custom eligibility rules. Learn more.
No actionable comments were generated in the recent review.
Walkthrough
-
Workspace focus handling now marks areas reached by keyboard navigation. The focus-ring styling and composer-refocus eligibility use this marker instead of relying on
:focus-visiblefor workspace areas.Changes: Workspace focus behavior
Layer / File(s) Summary Track keyboard focus on workspace areas
apps/web/src/lib/workspaceFocus.ts,apps/web/src/lib/workspaceFocus.browser.test.tsThe controller sets and clears a keyboard-focus marker during focus changes and pointer interaction. Browser tests cover focus-ring behavior for clicked and keyboard-reached areas. Use the marker for focus display and refocus
apps/web/src/index.css,apps/web/src/components/ChatView.logic.ts,apps/web/src/components/ChatView.logic.browser.test.tsWorkspace-area focus styling and composer-refocus eligibility use the marker. A browser test checks window-return eligibility around F6 navigation. Estimated code review effort: 2 (Simple) | ~12 minutes
Change: Bug fix · Severity of issue fixed: Low
Possibly related PRs
- pingdotgg/t3code#28191: Implements the same clicked-workspace focus-ring fix and shares marker, CSS, composer-refocus, and regression-test changes.
- pingdotgg/t3code#19669: Establishes the workspace-area focus controller and F6 navigation used by this change.
- pingdotgg/t3code#26457: Updates window-return eligibility for keyboard-focused timeline messages, a behavior also changed here for workspace areas.
Suggested reviewers:
yash-singh1,nibarahmed,macroscopeapp
Merge Risk: External image Minimal · up to 2c706
-
The focus-ring change has no identified issue that needs resolution before merge; proceed with normal checks.
Pre-merge checks: Passed 4
-
Check name Status Explanation Title check Passed The title clearly describes the main change: clicked workspace areas no longer show a focus ring after a stray key. Description check Passed The description covers the problem, change, linked issue, scope, verification results, screenshots, and known limitations. It follows the required sections and provides specific test details. Linked Issues check Passed Issue [ #28166] requires no ring after non-keyboard focus and a ring for F6 navigation.workspaceFocus.tsmarks an area only on keyboard-visible focus arrival and clears the mark on pointer input or …Out of Scope Changes check Passed All changes support [ #28166]. The controller and CSS implement the focus-ring behavior. The browser tests verify the behavior, and theChatView.logic.tschange keeps window-return focus handling con…Full details: Linked Issues check
-
Explanation
Issue [
#28166] requires no ring after non-keyboard focus and a ring for F6 navigation.workspaceFocus.tsmarks an area only on keyboard-visible focus arrival and clears the mark on pointer input or other focus.index.cssdraws the ring only for the marked focused area. Browser tests cover a click followed by bare Shift, simulated refocus, F6 navigation, and pointer clearing.ChatView.logic.tsuses the same mark for window-return composer refocus.
Full details: Out of Scope Changes check
-
Explanation
All changes support [
#28166]. The controller and CSS implement the focus-ring behavior. The browser tests verify the behavior, and theChatView.logic.tschange keeps window-return focus handling consistent with the new keyboard-focus marker. No unrelated changes appear in the pull request diff.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
External image Recent review info
-
External image Run configuration
-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: fix/workspace-area-focus-ring
- File: .coderabbit.config.ts
- Commit: 2c706af
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
78c2aa95-74b3-4558-84ef-fc2588822ad6
External image Commits
-
Reviewing files that changed from the base of the PR and between 2da1b7431d07abeefe69c3cda4ae38d7f7c3df30 and 2c706af82964983a61defe1dbbce66499524b70e.
External image Files selected for processing: 5
-
apps/web/src/components/ChatView.logic.browser.test.tsapps/web/src/components/ChatView.logic.tsapps/web/src/index.cssapps/web/src/lib/workspaceFocus.browser.test.tsapps/web/src/lib/workspaceFocus.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
External image Recent review info
-
External image Run configuration
-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: fix/workspace-area-focus-ring
- File: .coderabbit.config.ts
- Commit: 2c706af
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
78c2aa95-74b3-4558-84ef-fc2588822ad6
External image Commits
-
Reviewing files that changed from the base of the PR and between 2da1b7431d07abeefe69c3cda4ae38d7f7c3df30 and 2c706af82964983a61defe1dbbce66499524b70e.
External image Files selected for processing: 5
-
apps/web/src/components/ChatView.logic.browser.test.tsapps/web/src/components/ChatView.logic.tsapps/web/src/index.cssapps/web/src/lib/workspaceFocus.browser.test.tsapps/web/src/lib/workspaceFocus.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
-
fixes annoying "feature" that happens a lot to me.