Repository navigation
fix(native-chat): reveal message chrome on keyboard focus, not any focus - #19426
Conversation
`:focus-within` cannot tell a mouse click from a keyboard tab, so clicking any control inside a message row — a tool run's disclosure, most visibly — parked focus there and left the row's copy, scroll, and timestamp chrome showing after the pointer had moved away. The row read as permanently hovered. `:focus-visible` is the distinction the browser already computes, and it is the keyboard focus this reveal was written for in #19218. Measured in the running app: after a real click on a run header, `document.activeElement` is that button and `:focus-visible` is false, while `:focus-within` is true.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughNative chat timestamps and agent controls now apply hidden-state classes only on hover-capable devices. They remain visible and interactive on touch devices. Keyboard focus reveals the controls through Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Chat message controls now reveal for keyboard-visible focus and hover while remaining visible on touch devices. No current merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description provides detailed cause, changes, testing, performance, and scope information. However, it omits required template items, including a Linked Issue, Visual Proof or an explicit N/A explanation, the checklist, and the required testing checklist details. Resolution Add the required template sections and information. Include a linked issue after “Fixes #”, attach before-and-after visual proof or write exactly “N/A” with a reason, complete the Testing and Checklist items, and address the remaining template headings or explicitly mark them as not applicable.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 critical issues — one minor consistency suggestion inline, plus a touch-input note below.
Reviewed changes
- Message chrome reveal narrowed to keyboard focus —
NativeChatMessageRowswapsgroup-focus-within:forgroup-[&:has(:focus-visible)]:on the assistant control cluster (line 215) and the user-bubble timestamp (line 156), so a mouse click on a control no longer leaves the copy/scroll/timestamp chrome revealed once the pointer moves away. Hover reveal is untouched. - Test assertions updated in lockstep —
NativeChatMessageRow.test.tsxnow asserts the new variant class strings, so a revert tofocus-withinfails the suite.
The change is correct: :has(:focus-visible) is exactly the "keyboard focus" distinction #19218 wanted, the arbitrary variant compiles in this Tailwind v4 setup (and the in-app A/B in the PR description confirms it), and none of the focusable descendants in a message row are text-entry elements, so no click path still matches :focus-visible.
ℹ️ Touch input no longer reveals the chrome
[:focus-visible] matches keyboard focus, not touch taps, so on a touch-only device the copy/scroll/timestamp chrome loses its only reveal path — :focus-within used to fire on tap, and hover does not exist there. This is non-blocking: the row already reveals on bare group-hover with no can-hover:/[@media(hover:none)] fallback, and NativeChatMessageRow.tsx is not in HOVER_REVEAL_FILES in hover-reveal-touch-action-visibility.test.ts. Worth a conscious decision on whether native chat needs a touch affordance, but not a merge blocker.
Technical details
# Touch reveal path for native-chat chrome
## Affected sites
- src/renderer/src/components/native-chat/NativeChatMessageRow.tsx:156 — user-bubble timestamp reveal
- src/renderer/src/components/native-chat/NativeChatMessageRow.tsx:215 — assistant control cluster reveal
## Required outcome
- Decide whether touch-only users need a way to reveal the copy/scroll/timestamp chrome. If so, add a `can-hover:`/`[@media(hover:none)]` fallback consistent with the `hover-reveal-touch-action-visibility.test.ts` convention (and add this file to `HOVER_REVEAL_FILES`). If not, no change required.DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…-class has variant Swaps the hand-rolled arbitrary variant `group-[&:has(:focus-visible)]:` for Tailwind's `group-has-[:focus-visible]:`. Every other `has-` variant in the renderer is already spelled in the bracket form, including the same hover-plus-keyboard-focus reveal on the project header actions. Measured in the running app: both spellings compile to an equivalent selector and are identical in every state (idle, mouse click on a control inside the row with the pointer moved away, and each keyboard tab stop). Also asserts the pointer-events half of both reveals, which governs whether the copy button is clickable and had no coverage.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Arbitrary
hasvariant swapped for the first-class form — the twogroup-[&:has(:focus-visible)]:strings on the assistant control cluster (line 215) and user-bubble timestamp (line 156) becomegroup-has-[:focus-visible]:, matching the existinghas-[:focus-visible]:usage inProjectHeaderActions.tsx:15. Semantically identical, consistency/readability only. - Test assertions strengthened — both
toHaveClassblocks now also assertgroup-hover:pointer-events-autoandgroup-has-[:focus-visible]:pointer-events-auto, so the pointer-events half of the reveal is pinned alongside the opacity half.
This resolves the prior inline suggestion (arbitrary group-[&:has(...)] → first-class group-has-*). The touch-input note from the prior review still stands and remains non-blocking.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Merge-gate review — approve, with one measured consequence to decide onReviewed at The fix is correct, and I re-derived the evidence independentlyBoth class strings and both spellings were rendered side by side in one DOM in a running Electron dev instance, using the app's own compiled stylesheet, driven by real mouse and keyboard input through CDP:
So the keyboard reveal #19218 added is fully preserved, including focus landing anywhere in the row — not just on the chrome's own controls. The diagnosis holds up: What I changed and pushed
Spelling. There were no Test hardening. Both assertions checked only the PrecedentThis matches established practice rather than inventing something. In-repo, Performance
The mechanism is real — roughly a 6.5x multiplier on style recalc, and it does scale with transcript length. The magnitude is not: even at 3200 rows it is ~64 µs of extra style recalc per DOM mutation, in a measurement that forces a synchronous recalc after every single mutation, which real streaming does not. Not a merge concern. Anchoring The one thing to decide: touch surfaces lose the chrome entirelyThis is measured, not theoretical, and it is the only finding I would not merge without a conscious decision. Tailwind wraps This matters because I deliberately did not fix this here. The repo's house rule is to gate the hide with Two related notes, both report-only, neither touched:
Checks
Not verifiedThe behavioural evidence is from an isolated DOM using the app's real compiled CSS and real input, not from a seeded live transcript — the unit tests are what tie the class strings to the right elements. The touch result is Chromium under emulated |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Touch reveal path restored — the hard-hide tokens
opacity-0/pointer-events-noneon both chrome strings becamecan-hover:opacity-0/can-hover:pointer-events-none, so on touch devices (hover: none) the copy/scroll/timestamp controls stay visible instead of losing their only reveal path once the:focus-within→:has(:focus-visible)swap removed the tap trigger. Desktop hover/keyboard reveal is untouched. - Touch-visibility ratchet extended —
NativeChatMessageRow.tsxwas added toHOVER_REVEAL_FILES, and bothNativeChatMessageRow.test.tsxsuites now assert thecan-hover:hide variants plusnot.toHaveClass('opacity-0', 'pointer-events-none'), so a revert to a bare hover-only hide fails the suite.
This closes the touch-input gap flagged in the two prior reviews. One housekeeping note: the PR description's "Known gaps" section still says touch "has no reveal path" and the can-hover: fix is "being decided separately", which now contradicts the implemented fix — worth a quick rewrite before merge.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Review status: land after fixesThe focused review found and fixed one in-scope regression: changing Validation:
Architecture review found the CSS-owned mechanism appropriate; browser focus classification and hover-capability media queries match the required lifecycle without adding React state or event listeners. The final readiness review found no P0/P1/P2 issues. The current static-analysis check is red because newer main has an inherited localization catalog mismatch (identical failing catalog blobs in main and the PR merge); changed-code lint itself passes. Grok Electron QA was unavailable due to its weekly usage limit, so Codex performed the requested equivalent CDP validation. |
…hat-hover-chrome-focus-visible
|
Review status: ready to land.
|
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
…ole subtrees
Tailwind compiles group-has-* to `.x:is(:where(.group\/g):has(...) *)`: a
non-subject :has() whose subject is `*`. Together with any attribute :has()
in the sheet (e.g. card.tsx has-data-[slot=card-action]) and a non-subject
:has() on a large ancestor, Blink restyles the whole subtree under the
anchor on every mutation, so Mermaid label measurement, streaming code
blocks and rich-editor edits paid for thousands of elements per forced
style read.
(a) SshTargetCard and NativeChatReasoningChevron use the scoped
[[class~='group/x']:has(:focus-visible)_&] shape from #23725, keeping
the keyboard-only reveal (#19426). This is the whole measured win.
(b) rich-markdown-editor.css drops a redundant :has(): .markdown-toc-header
only renders inside .markdown-toc-panel. Defence in depth; measured
close to neutral once (a) lands.
Guard: check-has-restyle-scope.mjs compiles the renderer's Tailwind CSS
with Tailwind's own API, adds the plain renderer stylesheets, lowers
nesting with lightningcss and walks its selector AST. It flags any
non-subject :has() (outside sibling-only arguments) whose subject compound
has no class, id or attribute, carrying context through :is/:where/:not.
Reading compiled output covers the Tailwind spellings, @apply and nested
CSS forms tested so far. It runs in pnpm lint, check:changed and PR CI.
Hidden Electron 43.8.1, real compiled Tailwind, ~8.3k-node DOM, per
iteration, all from (a): rich editor with TOC 19.4 -> 1.6 ms; native-chat
code block append 12.5 -> 3.6 ms (3,184 -> 3 elements restyled); large
group row 8.0 -> 2.4 ms (2,003 -> 2).
Fixes #34312
Co-authored-by: Naufaldi <[email protected]>




Clicking anything inside a native-chat message row left the row's copy, scroll-to-top and timestamp controls showing after the pointer had moved away — the row read as permanently hovered. Most visible on a tool run: expanding one parks focus on its disclosure button, and the controls below the message stay up.
Fixing that exposed a second, older problem on touch, so this PR covers all three input modes.
Cause
The reveal keyed on
group-focus-within, which cannot tell a mouse click from a keyboard tab — so any click on a control inside the row satisfied it. Introduced on the assistant-controls line by #18744; #19218 added the second occurrence and made it easy to hit. Neither is at fault for the choice::focus-withinwas simply the closest available spelling for "keyboard focus" at the time.Measured on
main, after a real click on a tool-run header:Separately, the controls hid with a bare
opacity-0andpointer-events-none. Tailwind media-gateshover:to(hover: hover), so on a device with no hover they were invisible and inert — measuredopacity 0 / pointer-events none. That surface is real:web-index.htmlboots the full renderer and ships as the "Open in browser" URL and aswebClientUrlin the mobile pairing offer.Change
Two class strings in
NativeChatMessageRow.tsx— the assistant control cluster and the user-bubble timestamp:group-focus-within:→group-has-[:focus-visible]:opacity-0,pointer-events-none) moves behindcan-hover:Both spellings are the established in-repo idiom rather than new inventions.
sidebar/ProjectHeaderActions.tsx:15is the same hover-plus-keyboard-focus reveal and already useshas-[:focus-visible]:with acan-hover:-gated hide;main.cssdeclares thecan-hovervariant for exactly this reason, and 32 files use it.Proof
All three modes measured in the running app, real compiled Tailwind, real mouse and keyboard, both the shipping and pre-PR class strings side by side in one DOM:
opacity 0opacity 0opacity 0opacity 1← the bugopacity 1opacity 1hover: none,pointer: coarse)opacity 1 / pointer-events autoopacity 0 / pointer-events noneRunning the old spelling alongside is what makes it conclusive: had either variant silently failed to compile, its row would read wrong rather than the feature quietly dying. The keyboard and mouse rows were also independently re-derived by review in a separate instance, across every tab stop inside the row.
Regression protection
NativeChatMessageRow.tsxis now listed inhover-reveal-touch-action-visibility.test.ts, the existing ratchet for this rule — it was never in that list, which is how the file drifted. Ablation: reverting thecan-hover:gate makes the ratchet fail and name both offending lines by file and line number. The two unit assertions cover thepointer-eventshalf as well asopacity, and assert the ungatedopacity-0/pointer-events-noneare absent, so a partial revert fails too.Performance
:has()is worth measuring rather than assuming. Isolated single-rule stylesheets, real element insertion and removal, in the app's own Chromium::has()The multiplier is real and scales with transcript length; the magnitude is ~64 µs per mutation at 3200 rows under a worst-case forced-sync measurement.
Verification
pnpm test src/renderer/src/components/native-chat/+ the ratchet — 114 files, 1190 tests passingpnpm tc,oxfmt --check,oxlint, React Doctor, changed-code quality gate — cleanScope and known gaps
group-focus-withinreveals share the original defect. Most are not a mechanical swap, because their group carrier is itself focusable and:has()only matches descendants. Reported, not touched.group-has-[:focus-visible]spelling on its own; these lines are still covered via theirgroup-hovertoken and via thecan-hover:gate, but a future file using only the new spelling would escape it.hover: none/pointer: coarsein Chromium, not on a physical device or in Safari.Found while reviewing #19372; not caused by it, and reproduces on
main.