Repository navigation
fix(native-chat): open the message rail panel on the current message - #21143
Conversation
The rail's hover panel mounts fresh at scrollTop 0 every time it opens, so
in a long thread it showed the top of the conversation instead of where the
reader actually is. It already knew which row was current — activeId drives
the highlight — it just never scrolled to it.
Attach a ref to the current row that calls scrollIntoView({ block: 'nearest' }).
Radix unmounts popover content on close, so ref attachment is the open edge;
it also re-fires when a different row goes active under an open panel.
|
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 (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The rail reveals the current message when opened, including hover opening, with no actionable merge-blocking issue identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description explains the user impact, implementation, rationale, testing, and compatibility considerations. However, it does not provide the required linked issue, and it lacks a before visual for this UI behavior change.
✨ Finishing Touches📝 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.
ℹ️ Minor suggestions only. One observation inline.
Reviewed changes
- Rail panel opens on the current message —
NativeChatMessageRail.tsxadds a stableuseCallbackref callback (revealCurrentItem) that callsscrollIntoView({ block: 'nearest' }), attached only to the row whereitem.id === rail.activeId. Because Radix unmounts the content on close, ref attach is the open edge, and it re-fires whenactiveIdchanges under an open panel. - Tests pin the scroll target —
NativeChatMessageRail.test.tsxadds anopening positiondescribe that spies onElement.prototype.scrollIntoView, asserting the active row (exactly) is scrolled with{ block: 'nearest' }, plus a negative case foractiveId: null.
Verified in this run: the test file passes (7 tests) and pnpm run check:code-quality:changed reports 0 findings across 2 files. I also ablated the change myself — removing the ref line makes the positive test fail (scrolled becomes []), so it genuinely pins this behavior rather than passing against main.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Activation now keeps the current row focused — the follow-up commit adds
currentItemRefandresolveInteractiveItem, and routes both the triggeronClickandonOpenAutoFocusthrough it, so the interactive picker starts on the lit row instead of the first row. This directly resolves the earlier observation aboutfocus()scrolling the panel back to the top. onOpenAutoFocusnow always callsevent.preventDefault()and explicitly focuses only whenmode === 'interactive', preserving focus in the transcript for the hover path.- Tests cover both focus paths — a hover→interactive case that fails against the prior code (first row focused) and a direct-open case with
activeId: nullthat pins the first-row fallback. Both pass; the file is 9/9.
I verified the delta against the full PR: NativeChatMessageRail.test.tsx runs 9/9 under config/vitest.config.ts and pnpm run check:code-quality:changed reports 0 new findings across the 2 changed files. The remaining open question from the prior review was retired.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Electron visual proof — message rail popover opens on the current messageHidden CDP session against this worktree ( After — first openThe picker is a
ReopenClosed the hover preview, opened again. Same current row, same Active row change while openWith the panel kept open, the transcript was scrolled to an earlier turn. The highlighted row moved from Question 29 to Question 1 and the list followed ( Logs / gaps
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the delta since the prior Pullfrog review at 1f8df46: the panel now re-syncs when the transcript's message set changes.
- Reveal moved from the row to the list — the ref callback now lives on the
<ul>and scrollscurrentItemRef.current, so the panel re-checks the current row when the list changes instead of only when that specific row's ref attaches. - Dependency-driven re-fire —
activeId,itemCount, andopenare dependencies of the callback, so it fires on open, on a new current row, and when earlier messages load. React attaches the button ref before the parent list ref in the same commit, socurrentItemRef.currentis set when the callback runs. - Regression test — a new test prepends a message before the current one and asserts the panel still scrolls to the active row.
Verified in this run: the file passes 10/10, and setting the callback's dependency array to [] makes both opening-position tests fail (the closure captures open: false), so the tests pin this behavior rather than passing regardless. pnpm run check:code-quality:changed reports 0 new findings across 2 files.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Electron visual proof on
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the delta since the prior Pullfrog review at e935a5b: the rail now owns focus across popover opens, including a portal Radix retains through the exit animation.
- Row list extracted into
NativeChatMessageRailItems— the list moved into a child component that ownslistRef,currentItemRef, and apreviousModemarker, putting scroll and focus on one lifecycle. - Reveal and focus moved to a
useLayoutEffect— keyed onactiveId,items, andmode; it scrolls the current row whenever the panel is open and focuses it only on the transition intointeractive(previousMode.current !== 'interactive'), so a mid-open current-row change does not steal focus. onOpenAutoFocusnow alwayspreventDefault()s — the child effect is the sole focus owner, which also covers a reopen where the retained content'sonOpenAutoFocusno longer re-fires.- Tests pin the retained-portal and focus-preservation paths — a
getComputedStyleproxy keeps closing content mounted to exercise reopen focus, a case asserts focus stays put when the current prompt changes, and a same-count reorder asserts the reveal re-fires.
Verified in this run: NativeChatMessageRail.test.tsx passes 13/13 and the full native-chat suite passes 1604/1604 (pnpm test src/renderer/src/components/native-chat/); pnpm run check:code-quality:changed reports 0 new findings across the 2 changed files. I also confirmed the test proxy matches @radix-ui/[email protected], which reads getComputedStyle(...).animationName to decide the retained ANIMATION_OUT state — so the new focus test genuinely exercises the reopen path rather than passing regardless.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Review status: clean and ready to mergeFinal reviewed head: The review ran through three implementation loops plus an independent architecture challenge. The final design puts scroll and focus synchronization in the mounted list that owns the DOM. That resolved the meaningful issues found during review:
The final pass and closing readiness review found no remaining correctness, architecture, performance, security, cross-platform, mobile, SSH, wire, or persistence issue. The change stays within the existing renderer component and adds no polling, listener, retry loop, or stored synchronization state. Validation:
Electron screenshots and measurements Remaining evidence limits: no separate main-branch before screenshot was recorded. The native-chat fixture emitted an existing |
…tablyai#21143) * fix(native-chat): open the message rail panel on the current message The rail's hover panel mounts fresh at scrollTop 0 every time it opens, so in a long thread it showed the top of the conversation instead of where the reader actually is. It already knew which row was current — activeId drives the highlight — it just never scrolled to it. Attach a ref to the current row that calls scrollIntoView({ block: 'nearest' }). Radix unmounts popover content on close, so ref attachment is the open edge; it also re-fires when a different row goes active under an open panel. * fix(native-chat): keep current rail item focused * fix(native-chat): resync rail after list changes * fix(native-chat): own focus across retained rail opens








ELI5
The message rail is a map of the prompts in a chat. In a long conversation, its panel used to open at the beginning even when the reader was near the end. It now opens with the current prompt visible and ready to use.
What Changed
Before: the current prompt could be below the visible part of the panel. Activating a hover preview could also focus the first row and move the panel back to the top. A rapid close and reopen could leave focus on the trigger because the popover content was still mounted for its exit animation.
After: hover shows the current prompt without taking focus from the composer. Clicking the rail or opening it from the keyboard focuses the current prompt, falling back to the first prompt when no prompt is current. The same behavior holds when the panel reopens before its closing animation has unmounted it.
Mechanism: the mounted list owns its row and list refs. A layout effect reacts to the panel mode, current prompt, and semantic item list. It reveals the current row with
scrollIntoView({ block: 'nearest' }), and focuses the current-or-first row withpreventScrollonly when the panel enters interactive mode. Radix's default open autofocus is suppressed so it cannot move focus back to the first row.Why
The component already derives the current prompt from transcript state, so this keeps no separate scroll position or synchronization flag. Putting the effect beside the mounted list also follows the popover's real lifecycle, including content retained during its closing animation.
Alternatives considered:
scrollTopby hand would couple the behavior to row height and panel layout.Linked Issue
None — the problem was reported directly with a screenshot of a long thread whose panel opened at the top.
Visual Proof
Final Electron validation with hover, click, keyboard, and retained-reopen screenshots
The original before state was supplied with the direct report; no separate main-branch capture was recorded during final validation.
Testing
Local checks:
pnpm test src/renderer/src/components/native-chat/NativeChatMessageRail.test.tsx— 13/13 passedpnpm tc— passedpnpm run check:code-quality:changed— passedgit diff --check— passedElectron validation on macOS used a real native chat with 30 prompts and a 256 px-high overflowing list. It verified hover, hover-to-click, keyboard open, and Escape followed by immediate reopen while the popover content remained mounted. In every case the current prompt was visible; interactive opens focused it, while hover retained composer focus.
All required CI checks pass, including static analysis, typecheck, all eight test shards, package, and Windows package.
Review
This is renderer-only and keeps the component interface unchanged. It changes no IPC, wire format, persistence, paths, shortcuts, mobile code, remote execution, or SSH behavior. It uses standard DOM focus and scrolling APIs across supported desktop platforms.
The reveal effect runs only when the panel mode, current prompt, or stable semantic item list changes. Focus runs only when entering interactive mode. There is no polling, render loop, new listener, or retained resource.
Agent skill upstream boundary
Notes
The native-chat fixture emits an existing
flushSyncmount warning during setup; it is unrelated to the message-rail path. Wheel forwarding during hover is unchanged and remains covered by its existing delta-mode tests.Checklist