Skip to content

fix(native-chat): open the message rail panel on the current message - #21143

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/popover-scroll-to-current
Sep 17, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/popover-scroll-to-current

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​255 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​249
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​73 $\color{#cf222e}{\Huge{\mathbf{−}}}$​40 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​33

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 with preventScroll only 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:

  • A callback ref on the current row misses changes that keep the same keyed row, such as inserting or reordering earlier prompts, and does not own focus on a retained reopen.
  • A parent effect can run before the popover has mounted its list descendants.
  • Computing scrollTop by hand would couple the behavior to row height and panel layout.
  • Remounting the panel with a key would disrupt its animation and focus lifecycle.

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

Hover preserves composer focus Hover to click focuses the current prompt
Hover preview showing the current prompt Interactive panel focusing the current prompt
Keyboard open focuses the current prompt Immediate reopen restores current-prompt focus
Keyboard-opened panel focusing the current prompt Retained popover reopened on the current prompt

The original before state was supplied with the direct report; no separate main-branch capture was recorded during final validation.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

Local checks:

  • pnpm test src/renderer/src/components/native-chat/NativeChatMessageRail.test.tsx — 13/13 passed
  • pnpm tc — passed
  • pnpm run check:code-quality:changed — passed
  • git diff --check — passed

Electron 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

  • Not applicable.

Notes

The native-chat fixture emits an existing flushSync mount 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

  • 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)
  • Before/after screenshots or videos attached for UI changes — final-state interaction proof is attached; no new main-branch before capture is available
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (N/A beyond standard DOM behavior)
  • Lint/static analysis, typecheck, test, and package checks pass

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.
@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 72f08beb-7271-454f-be56-1ae1aebeb8f7

📥 Commits

Reviewing files that changed from the base of the PR and between 751426d and 1f8df46.

📒 Files selected for processing (2)
  • src/renderer/src/components/native-chat/NativeChatMessageRail.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageRail.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

NativeChatMessageRail now resolves the active message button for focus when the panel opens. It scrolls the active button into view with scrollIntoView({ block: 'nearest' }). If no message is active, it focuses the first button and does not scroll. Tests cover keyboard opening, hover opening, and scrolling behavior.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 1f8df

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning 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… Add the issue reference in the required Fixes #<issue-number> format. Attach a before visual alongside the existing after-state proof, or provide the required before/after comparison in an accepted format.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the primary change: opening the native chat message rail on the current message.
Full details: Description check

Explanation

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.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Minor suggestions only. One observation inline.

Reviewed changes

  • Rail panel opens on the current message — NativeChatMessageRail.tsx adds a stable useCallback ref callback (revealCurrentItem) that calls scrollIntoView({ block: 'nearest' }), attached only to the row where item.id === rail.activeId. Because Radix unmounts the content on close, ref attach is the open edge, and it re-fires when activeId changes under an open panel.
  • Tests pin the scroll target — NativeChatMessageRail.test.tsx adds an opening position describe that spies on Element.prototype.scrollIntoView, asserting the active row (exactly) is scrolled with { block: 'nearest' }, plus a negative case for activeId: 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Activation now keeps the current row focused — the follow-up commit adds currentItemRef and resolveInteractiveItem, and routes both the trigger onClick and onOpenAutoFocus through it, so the interactive picker starts on the lit row instead of the first row. This directly resolves the earlier observation about focus() scrolling the panel back to the top.
  • onOpenAutoFocus now always calls event.preventDefault() and explicitly focuses only when mode === '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: null that 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron visual proof — message rail popover opens on the current message

Hidden CDP session against this worktree (window.api.app.getIdentity(): blenny @ brennanb2025/popover-scroll-to-current, repo root /Users/brennanbenson/orca/workspaces/orca/blenny). Native chat pane width 1097px (≥512px so the rail is shown). Seeded a 30-user-message Claude transcript, scrolled to the bottom so the current prompt is Question 29 (below the picker’s first fold), then opened the rail through the real hover/click surface.

After — first open

The picker is a max-h-64 scroller (256px). It lists all 30 prompts (scrollHeight 1350px) and opens already scrolled to the highlighted current row, not to Question 0.

Metric Value
aria-current row Question 29 (index 29 / 30)
List viewport 256px client / 1350px content / scrollTop 1094
Row vs list top 530, bottom 575, list 319–575 → in view
Transcript scrollTop 18043 / scrollHeight 18864, width 1097px

01-popover-open-current-below-fold.png

Reopen

Closed the hover preview, opened again. Same current row, same scrollTop 1094, still in view.

02-popover-reopen.png

Active row change while open

With 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 (scrollTop 1094 → 45). Question 1 sat at the top of the list viewport (319–364 inside 319–575).

04-active-row-changed-while-open.png

Logs / gaps

  • Renderer console: repeated flushSync was called from inside a lifecycle method around native-chat mount and later virtualizer updates. Not specific to this picker screenshot; called out, not triaged here.
  • App log: no rail/native-chat errors. Vite HMR did reload NativeChatMessageRail.tsx during the session (uncommitted local edits were present in the worktree and were not authored by this validation).
  • Wheel-on-rail while the hover preview was open closed the panel (pointer left the trigger). The while-open case above was done with the panel in interactive (clicked) mode.
  • No before screenshot from main; happy-dom still cannot prove pixel offset. These captures are the after state on a real overflowing picker.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 scrolls currentItemRef.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, and open are 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, so currentItemRef.current is 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron visual proof on a43adb15 — current row in view and focused

This supersedes the earlier comment, which was taken against an intermediate revision. Hidden CDP session on this worktree (window.api.app.getIdentity(): blenny @ brennanb2025/popover-scroll-to-current). Native chat pane 1097px wide. 30 user messages; transcript scrolled to the bottom so the current prompt is Question 29, below the picker’s first fold (max-h-64 = 256px, list scrollHeight 1350px).

Shared list metrics on every successful open: 30 rows, scrollTop 1094, aria-current = Question 29 (index 29), row 529–574 inside list 318–574 → in view.

Hover preview

Opens on Question 29. Focus stays in the composer (Send a message…), not the picker.

final-01-hover.png

Hover → click (interactive)

Same row stays in view and receives focus.

final-02-hover-to-click.png

Direct keyboard open

Rail focused, Enter. Question 29 in view and focused.

final-03-keyboard.png

Retained reopen

Escape left the popover content in the DOM with data-state="closed" (Presence still mounted). Immediate click reopened it: Question 29 still in view and focused.

final-04-retained-reopen.png

Logs / gaps

  • Renderer: flushSync was called from inside a lifecycle method around native-chat mount (virtualizer). Unrelated tooltip controlled/uncontrolled warnings. No rail-specific errors in the app log.
  • Wheel-on-rail while a hover preview is open still closes the panel if the pointer leaves the trigger; not re-tested on this HEAD.
  • No main before screenshot.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 owns listRef, currentItemRef, and a previousMode marker, putting scroll and focus on one lifecycle.
  • Reveal and focus moved to a useLayoutEffect — keyed on activeId, items, and mode; it scrolls the current row whenever the panel is open and focuses it only on the transition into interactive (previousMode.current !== 'interactive'), so a mid-open current-row change does not steal focus.
  • onOpenAutoFocus now always preventDefault()s — the child effect is the sole focus owner, which also covers a reopen where the retained content's onOpenAutoFocus no longer re-fires.
  • Tests pin the retained-portal and focus-preservation paths — a getComputedStyle proxy 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: clean and ready to merge

Final reviewed head: a43adb155f93b6a492a93dceeab9df9db41781ca

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:

  • activating a hover preview could focus the first row and move the panel back to the top;
  • inserting or reordering prompts could leave the same keyed current row out of view;
  • reopening during the popover's retained exit state could reveal the current row without restoring focus to it.

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:

  • targeted Vitest: 13/13 passed;
  • pnpm tc passed;
  • changed-code quality and git diff --check passed;
  • all required CI checks passed, including all eight test shards, static analysis, package, and Windows package;
  • hidden Electron validation passed for hover, hover-to-click, keyboard open, and immediate close/reopen with retained popover content.

Electron screenshots and measurements

Remaining evidence limits: no separate main-branch before screenshot was recorded. The native-chat fixture emitted an existing flushSync setup warning unrelated to this path. Wheel forwarding during hover is unchanged and remains covered by its delta-mode tests.

@brennanb2025
brennanb2025 merged commit 28a2b62 into main Sep 17, 2026
28 checks passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant