Skip to content

fix(native-chat): message rail lights a message sent while the agent was working - #27821

Merged
brennanb2025 merged 5 commits into
mainfrom
brennanb2025/fix-chat-scroll-bottom
Oct 12, 2026
Merged

brennanb2025 merged 5 commits into
mainfrom
brennanb2025/fix-chat-scroll-bottom

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​199 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​192
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​75 $\color{#cf222e}{\Huge{\mathbf{−}}}$​29 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​46

ELI5

Down the right edge of a chat is a column of small ticks, one per message you sent: the message rail. The lit tick tells you which of your messages you are reading. A message you sent while the agent was still working never lit up, so even scrolled all the way to the bottom the rail pointed at an older message.

What Changed

The problem. The transcript groups rows into turns: one of your messages and everything the agent does in answer to it. Each row carries an id for its turn (the "turn key"), which is the id of the message that started it. A message sent while the agent is working (or one that arrives then, such as an orchestration message) does not start a new turn; it joins the running one and takes that turn's key. The rail decided which tick to light from the turn key of the row at the top of the view, so it always named the message that started the turn, never the one sent into it.

Before: send a message while the agent is mid-reply, then scroll to the bottom. The rail lights the message that started the turn, one or more ticks above the last. Scrolling through that turn, the highlight never moves onto the message sent into it.

After: at the bottom, the rail lights your latest message. Scrolling through a turn that had messages sent into it, the highlight moves onto each of them as you pass it. Clicking a tick keeps it lit, including a tick whose message cannot scroll all the way to the top because it is too near the end of the chat.

Mechanism:

  • The lit tick is now the newest loaded tick at or above the row being read (the row at the top of the view, or the last row when scrolled to the bottom). The rail already records, for each tick, which row draws its message; this reuses that, so no second rule decides what counts as a tick.
  • Rows above the first loaded message (older history known only from a summary list) fall back to that row's turn key, as before.
  • A clicked tick is held while its row stays where the jump put it on screen. When scrolling settles after a click, the rail records how far below the top of the view the clicked row landed. It keeps the clicked tick lit while that row is still on screen at that distance; any movement, whatever causes it, ends the hold. This is needed because a jump to a message near the end cannot bring it to the top: the view stops at the very bottom, in exactly the position and layout of a normal scroll to the bottom, where the rail lights the last message.

Why

  • Not a separate turn for a message sent mid-turn. Giving it its own turn key would fix the rail but change everything else that reads turns: how rows are grouped, the status line per turn, folding, and per-turn file diffs. The rail is the only reader asking "which of my messages is this row under", which is a question about position, so the fix stays in the rail.
  • Not releasing the hold on reader input. A first version held the clicked tick until the reader scrolled. That needed every way the view can move to report itself, and several do not (the scroll-to-top button on a message, inline diff reveal, re-folding a long prompt, scrolling while dragging a text selection). Each would have needed its own guard. Holding by the row's position covers them all.
  • Not a rule based only on position. After a clamped jump, the view is identical to a reader who scrolled to the bottom, where the newest message should light. No rule that looks only at the scroll position can tell those apart, so the click itself has to be remembered. Lighting the clicked item until the view moves is the common pattern for this kind of position rail.

Behaviour changes, accepted:

  • In a turn the agent started on its own (no message of yours opened it), the nearest message of yours above now lights, instead of nothing.
  • An older form of the same bug is fixed too: clicking the tick of the second-to-last turn, when the last turn is too short for it to reach the top, used to snap the highlight to the last tick.
  • When the view moves without the reader (the turn ends and its tail shrinks, or you switch back to the tab and it returns to the bottom), the hold ends and the rail goes back to tracking position.

Visual Proof

Live QA on a remote Mac with a real Claude chat, before (main) and after (this PR): #27821 (comment)

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • native-chat-active-rail-item.test.ts: a message sent into a running turn lights at the bottom and from its own row on; it stays lit past a row that belongs to no turn; the first message of the turn is lit above the first loaded tick when it is known only from older history; a turn the agent started lights the message above it.

  • use-native-chat-message-rail.test.ts: a clicked tick at a clamped bottom stays lit across settled reads, across rows above re-measuring (row and scroll move together), and across old rows being trimmed from a long session; it is released when its row moves, when the viewport shrinks it out of view, and when the reader scrolled it off screen before the jump settled. Each guard was checked by breaking it and seeing a test fail.

  • Passing locally after merging main: 11 rail and message-list test files (140 tests), pnpm tc:web, and the lint, code-quality and localization checks in orca-ci-checks. Its typecheck step fails locally before checking any code (this machine's bun has no check script); pnpm tc:web passes and CI runs the full typecheck.

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

Renderer-only highlight logic: no change for SSH, remote hosts, folder workspaces, mobile, or anything sent to a remote host. The lookup runs once per settled scroll over the loaded ticks.

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, 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)

…ssage rail

A message sent while the agent is working joins the running turn's key, and the
rail lit ticks by turn key, so that message's tick never lit: not at the bottom,
not after clicking it. Light the newest tick at or above the read row within its
turn instead.
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in 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: 323fe94b-b1a8-4774-9755-3b79fd5484fc

📥 Commits

Reviewing files that changed from the base of the PR and between a210da2 and da72873.


📒 Files selected for processing (2)
  • src/renderer/src/components/native-chat/use-native-chat-message-rail.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-message-rail.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.



📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The active rail item lookup now uses loaded prompt ticks to resolve the selected slot, with a turn-key fallback. The message rail tracks activated items while their rows remain visible at the settled position. It schedules active-item reads after scrolling becomes idle and clears pending timers on cleanup. Tests cover prompt-tick selection and activation behavior during clamped jumps, content shifts, row trimming, viewport changes, and scrolling.


Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to da728

The rail can briefly highlight a tick from the previous reply. The issue is localized, but the existing finding remains open and should be addressed or explicitly accepted before merging.

Pre-merge checks | Passed 2 | Failed 2 | Inconclusive 1

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check Warning The description explains the user impact, implementation, rationale, testing, visual proof, scope, and known local typecheck limitation. However, the required Linked Issue section is empty, and manual… Add a valid issue reference after "Fixes #" and confirm whether manual testing was performed. If manual testing was not performed, state that explicitly and explain why.
Linked Issues check Inconclusive The required issue reference is missing because the description contains an empty Fixes # entry. Add a valid linked issue, or confirm that the author is a maintainer covered by the template exception.
✅ Passed checks (2 passed)
Check name Status Explanation
Out of Scope Changes check Passed The production changes and tests stay within native-chat message-rail highlighting and viewport alignment. No unrelated changes are described.
Title check Passed The title clearly summarizes the main change: fixing the native-chat message rail highlight for messages sent while the agent is working.

Full details: Description check

Explanation

The description explains the user impact, implementation, rationale, testing, visual proof, scope, and known local typecheck limitation. However, the required Linked Issue section is empty, and manual testing is not confirmed.


  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 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.

❤️ Share

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

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 81a959cd-0ed4-430d-8f02-1db869075695
📥 Commits

Reviewing files that changed from the base of the PR and between 88a82c0 and 48c1be0.

📒 Files selected for processing (3)
  • src/renderer/src/components/native-chat/native-chat-active-rail-item.test.ts
  • src/renderer/src/components/native-chat/native-chat-active-rail-item.ts
  • src/renderer/src/components/native-chat/use-native-chat-message-rail.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

const slot = slots[index]
for (let at = index; at >= 0; at -= 1) {
const candidate = slots[at]
if (candidate?.message && tickIds.has(candidate.message.id)) {

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Check the turn boundary before accepting a preceding tick.

If a row in turn u2 has no tick and the preceding row has a tick in turn u1, railTickOf returns the u1 tick before it checks turnKey. The rail then highlights a message from the wrong turn. Check the boundary before testing tickIds for every preceding row. Keep the current row eligible when its turnKey is undefined.

… a clicked tick lit

Review round 1. The within-turn walk stopped at a row of no turn landing in the
running turn, and could return a tick from the turn above. The lit tick is now
the newest loaded rail item at or above the row at the fold, falling back to its
turn key above the first loaded one (that prompt is in the outline).

A jump that cannot bring its row to the top lands clamped at the bottom, and the
settled position report then lit the last tick instead of the clicked one. A
clicked tick now stays lit until the reader scrolls or starts another navigation
(the existing reader-input path), or the set of prompts changes.

Rail picks and the start of every navigation move into their own hook, as the
list is at its line limit.

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 307be29a-56e5-40a3-b049-dee4e5885aa5
📥 Commits

Reviewing files that changed from the base of the PR and between 48c1be0 and 40f4e04.

📒 Files selected for processing (6)
  • src/renderer/src/components/native-chat/NativeChatMessageList.tsx
  • src/renderer/src/components/native-chat/native-chat-active-rail-item.test.ts
  • src/renderer/src/components/native-chat/native-chat-active-rail-item.ts
  • src/renderer/src/components/native-chat/use-native-chat-message-rail.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-message-rail.ts
  • src/renderer/src/components/native-chat/use-native-chat-rail-selection.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

… input

Review round 2. Releasing the clicked tick on reader input needed every scroll
source to report itself, and several do not (scroll-to-top button, inline diff
reveal, prompt refold, selection-drag autoscroll); releasing it whenever the
prompts changed dropped it on every head trim of a long live session.

The hold now records where the jump settled, at the first idle read after the
click, and keeps the clicked tick lit while the view rests there. Any movement,
whatever caused it, releases it, as does the clicked message leaving the rail.
Drops the navigation wiring and the hook it was moved into.

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 08bcacc7-c871-4f15-b200-8c9e308d26f4
📥 Commits

Reviewing files that changed from the base of the PR and between 40f4e04 and a210da2.

📒 Files selected for processing (3)
  • src/renderer/src/components/native-chat/use-native-chat-message-rail.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-message-rail.ts
  • src/renderer/src/components/native-chat/use-native-chat-viewport-align.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Review round 3. Holding while scrollTop stayed put recorded the reader's spot when
they kept scrolling within the idle period of the jump, kept an off-screen row lit
after the viewport shrank, and let go when a row above re-measured late and shifted
scrollTop with the content.

The hold now records how far below the viewport top the clicked row settled, and
keeps the tick lit while the row is still on screen at that offset.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Live check on macOS: before and after

Hidden Orca app with a real Claude chat. The "before" build is main at c43ac3f, the commit this PR was last merged with. The "after" build is this PR at da72873. Ticks were read from the DOM (aria-current on the rail buttons) with the pointer off the rail. The screenshots are cropped to the chat. The rail is the set of short lines at the right edge, and the lit tick is the longer, brighter one.

1. A message sent while Claude was still working joins that turn. Scrolled to the bottom:

Before (main) After (this PR)
before: first message lit at the bottom after: second message lit at the bottom
The first tick is lit, even though the message sent mid-turn is the newest one. The second tick (the mid-turn message) is lit.

2. A short last turn where a second message was sent mid-turn. Scrolled to the bottom (4 ticks):

Before (main) After (this PR)
before: third tick lit after: fourth tick lit
The tick for the message that started the turn is lit. The tick for "Also reply with the word OK2." is lit.

3. After this PR, clicking the third tick when its turn is too short to scroll to the top: the view stays at the bottom, and the clicked tick is still lit 1.5 s and 3 s later. It does not snap to the last message. A small wheel scroll afterwards hands the rail back to the scroll position.

after: clicked third tick stays lit

Also checked on the PR build:

  • Scrolling through a turn with a mid-turn message lights the first message while the second message's bubble is below the top edge, and the second once it has scrolled past the top edge.
  • Chats with one message per turn light each message as it reaches the top edge, as before.
  • Clicking a middle tick jumps that message to the top and keeps its tick lit.

Not covered: SSH, Windows/Linux, and messages that arrive from orchestration mid-turn. Only typed messages were sent.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready for merge review

The problem. In native chat, the column of ticks on the right edge (the message rail, one tick per message you sent) lights the message you are reading. A message you send while the agent is still working joins the reply that's already running and shares that reply's id. The rail picked its tick from that id, so it always lit the message that started the reply. Even at the very bottom of the chat it pointed at an older message, and scrolling through the reply never reached the one you sent mid-reply.

What changes for you. At the bottom, your latest message is lit. Scrolling through a reply with messages sent into it, the highlight moves onto each one as you pass it. A tick you click stays lit until the view moves, including one that can't scroll all the way to the top because it's near the end of the chat.

Fixed during review (3 rounds plus a readiness pass):

  • The first version of this fix introduced a regression. Clicking the first message of a short final turn moved the highlight to the message sent mid-turn. The cause is that a jump that can't reach the top stops at the very bottom, where the rail lights the last message. A clicked tick is now held while its row stays where the jump put it on screen, and any movement ends the hold. The same fix covers the older form of this bug across turns, which was already on main.
  • The rail now lights the newest tick at or above the row you're reading, using row positions it already records. Before, it walked back through the reply. That walk stopped early at a row belonging to no turn, and it could light a tick from the turn above.
  • An earlier way of releasing the hold, triggered by your scrolling, missed several things that move the view: the scroll-to-top button on a message, the inline diff reveal, re-folding a long prompt, and scrolling while dragging a text selection. That's why the hold now follows the row's position instead.

Accepted behaviour changes:

  • In a turn the agent started on its own, your nearest message above now lights instead of nothing.
  • When the view moves without you, for example when the turn ends and the tail shrinks or you switch back to the tab, the rail goes back to lighting by position.

Deferred (not caused by this PR; same on main):

  • A message sent mid-turn that sits outside the loaded history lights the message that started its turn.
  • The check for which row is at the top has no tolerance, so a jump that lands half a pixel short can light the row above.
  • Resizing the chat without scrolling (for example when the message box grows) doesn't re-check the rail until the next scroll.

Verified:

  • Live QA on a remote Mac with a real Claude chat, comparing main with this PR (screenshots in the comment above). All 4 checks passed:
    • The message sent mid-turn lights at the bottom.
    • The highlight moves at that message while scrolling.
    • A clicked tick at a clamped bottom stays lit for over 3 s, and a small scroll resumes tracking.
    • Ordinary one-message turns behave as before.
  • Unit tests for the rail lookup and the hold: 140 tests across the rail and message-list files pass.
  • CI is fully green after merging main.
  • The readiness review found no P0 or P1 issues.

Not verified:

  • SSH, Windows and Linux were not run live. The change is renderer-only, with no host or wire changes.
  • Orchestration messages arriving mid-turn weren't tested live. They take the same path as a typed mid-turn message.
  • On main, QA could not reproduce "click the last tick, it snaps back", so I removed that claim from the description.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

cc @AmoabaKelvin

@brennanb2025
brennanb2025 merged commit a940929 into main Oct 12, 2026
30 checks passed
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