Skip to content

fix(native-chat): show every user message on the message rail, not just loaded ones - #22558

Merged
brennanb2025 merged 18 commits into
mainfrom
brennanb2025/native-chat-rail-outline
Sep 24, 2026
Merged

brennanb2025 merged 18 commits into
mainfrom
brennanb2025/native-chat-rail-outline

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 24 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1903 $\color{#cf222e}{\Huge{\mathbf{−}}}$​23 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1880
Prod 32 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​942 $\color{#cf222e}{\Huge{\mathbf{−}}}$​166 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​776

ELI5

The strip of little ticks on the right edge of a chat has one tick per message you sent, plus a preview list on hover. It only knew about the messages the app had loaded so far, so in a long chat your older messages were simply missing. Now the host sends a short list of every message you sent, and the strip always covers the whole conversation. Clicking an older message that isn't loaded yet loads history until it's there, then scrolls to it.

What Changed

Before: the message rail was built only from the transcript rows loaded in the window. History loads in pages, so anything above the loaded window had no tick. The rail could also lose ticks during a long live turn, when the structured lane trims its oldest retained rows. And with only a couple of messages loaded, the rail didn't render at all, because it needs 3.

After (structured chat lane):

  • Host outline read. A new agentSession.conversationOutline method returns every user message the transcript would draw. Each entry has the id, journal sequence, a preview cut to 200 characters, and an image count. The reply also carries the journal cursor it is current through. The outline is derived from the host's existing journal snapshot on each request, never stored. It runs the same projection the transcript runs: order, fold tool results into their turn, then strip harness-injected turns. That projection moved into src/shared/native-chat-transcript-projection.ts, and the renderer's list projection and the host both call it. So an outline tick exists exactly when the transcript would draw a row for that message.
  • Size bound. The reply fits the same byte budget as a history page. If it would not, previews shrink to 60 characters, then to empty. Only after that are the oldest entries dropped, reported as omittedEntries.
  • Merge. The loaded window is trusted for everything it covers. The outline only contributes messages older than the oldest loaded row, and loaded rows follow in transcript order. The outline counts as stale if the session epoch changed or if its cursor falls short of the loaded window, which would leave a gap no source covers. While it's stale, the rail shows loaded messages only.
  • When it fetches. Only while the pane is visible and older history is actually unloaded, so fully loaded sessions never ask. It refetches only when a gap opens, never per streamed batch. A failed read is retried up to 3 times with backoff. Nothing blocks the transcript: without an outline, the rail maps the loaded messages.
  • Older-page loading reports a result. loadEarlier now returns whether a page was applied, history ran out, or the load failed or was superseded. A second request while a page is loading joins that page instead of being refused. This applies to both chat lanes, and the scroll-to-top trigger and "Load earlier" button behave as before.
  • Jump to an unloaded message. One abortable loop loads older pages until the message has a row, then runs the existing rail jump. It is capped at 1000 pages and stops when history runs out or a page doesn't apply. The latest pick wins. Any other navigation cancels a pending jump, so the reader is never pulled away later. That includes picking a loaded message, a diff reveal, "Jump to latest", the reader's own wheel, touch, scroll keys or scrollbar drag, and a wheel over the rail. Switching sessions or unmounting cancels it too.
  • Visible progress. While a picked message loads in, the hover list stays open with that item pulsing. It closes when the jump lands or is cancelled, and it doesn't scroll under the pointer while waiting.

Two scroll fixes turned up while testing the jump in the app. Both code paths are unchanged from main, but this PR makes them easy to hit:

  • A rail jump that starts from the very bottom cancelled itself. A smooth scroll only marks its landing as the app's own scroll, and its first frames still sit within 4px of the end. That re-armed "follow the bottom", and the next frame snapped back. Re-arming follow now requires the distance to the end not to grow. A scroll moving away from the end no longer re-arms, while a reader clamped onto the end by content shrinking still does.
  • Clicks on older items in the hover list were lost once the list overflowed. Pressing an item switched the popover from hover to interactive, which re-ran "scroll the current item into view" and moved the list under the pointer. That reveal now runs when the list opens, not on the mode switch, and focus stays on the pressed item.

Old hosts: the method is advertised as the runtime capability agent-session.conversation-outline.v1. The client checks it through the existing runtime capability cache before calling. A host without it is never called, and the rail stays on loaded messages with no error. The prompt-cancel capability check now shares the same helper.

Not covered: the terminal-transcript chat lane. Its host read works backward from the end of the transcript file and reads only the requested window. Listing every user message there would need a new indexed read on the host, which this PR doesn't build. That lane keeps showing loaded messages only; it adopts only the new older-page result contract.

Why

The rail's job is to be a map of the whole conversation. A map that silently leaves out the older part is wrong, not just incomplete. Paging has to stay: the transcript list only limits what is drawn, and a whole long history can't cross an SSH or paired-host connection in one message. So the rail needs its own small, complete source instead of borrowing the paged window.

Alternatives considered:

  • Growing the history page until the rail is complete: this defeats paging, and preventing that is what the byte budget is for.
  • Storing a precomputed list on the host: we derive it from the journal on request instead. The journal is already in memory, so a stored copy would just be something that could disagree with it. The per-request cost for a 20,000-item journal was measured at about 13 ms warm and 84 ms cold. It only runs when the outline is stale, never per batch.
  • A separate, user-rows-only projection for the outline: an earlier revision did this. It drew a tick for an imported message the transcript folds away, so the outline now shares the transcript's projection.
  • Keeping outline entries even for messages the loaded window covers: the loaded window wins for everything it covers. That keeps loaded ticks in transcript order and correctly drops messages that were removed or don't render.
  • Stepping the jump from a React effect across commits: an earlier revision did this, and it produced a class of races. A click was dropped while a page was already loading, a finished jump yanked the reader after a later pick, and a stale write lost a queued pick. One awaited loop with an abort signal, plus the lane joining the page in flight, removes those at the source.

Linked Issue

None. Reported directly while using the native chat.

Visual Proof

Structured Claude chat with 8 sent messages. For the test, the history page size and the initial read size were both temporarily set to 6 (that edit is not in this PR). After a reload, only turns 7–8 are loaded.

Before (main): with only turns 7–8 loaded there is no rail at all, because two loaded messages is below its minimum of 3. After two "Load earlier" clicks, the list shows only the loaded turns 3–8.
main, newest page only, no rail
main hover list is only the loaded turns

After: with only turns 7–8 in the transcript, the rail has 8 ticks and the list shows all 8 messages with their exact text.
hover list of all 8

After: clicking unloaded turn 1 from the bottom keeps the list open with turn 1 busy while older pages load (captured 56 ms after the click)...
list open, turn 1 busy

...then lands turn 1 flush with the top (row top equals scroller top, delta 0).
turn 1 at the top

Testing

  • In-app on macOS, in a hidden dev window, using the structured Claude chat lane at 7c86186615. The history page size and initial read size were temporarily set to 6, so an 8-turn chat reloads with only turns 7–8 loaded. Results:

    • The rail showed 8 of 8 ticks, and the list showed all 8 texts, while only 4 transcript rows were loaded.
    • Jumping to unloaded turn 1 from the exact bottom kept the list open with the item busy. The older pages then loaded and turn 1 settled at delta 0.
    • A reader wheel during the history read aborted the jump: the target never loaded and the view stayed put.
    • Picking a loaded message while an unloaded jump was paging cancelled the older jump.
    • "Load earlier" paged 4 → 8 → 12 → 16 rows. After that, each of the 8 prompts appeared once, in order.
    • Following the bottom still works. The view stayed put while scrolled up during a long streamed reply, and stayed pinned after scrolling back to the end.
    • Main, same setup: no rail with 2 loaded messages, and only the loaded turns after paging. Main also shows the "jump from the bottom cancels itself" behavior this PR fixes: the view stayed 6px from the end.
  • Automated tests:

    • the shared transcript projection and outline parity with the renderer, including an imported tool-result/harness row and an out-of-order timestamp
    • byte bound and degradation
    • the RPC handler
    • merge and staleness, including a trimmed window sliding without rebuilding
    • fetch gating and bounded retry
    • both lanes joining an in-flight older page
    • the jump loop: latest pick wins, and each abort path (loaded pick, diff reveal, jump to latest, wheel/touch/keys/scrollbar, wheel over the rail, session change)
    • a failing page stops after one call
    • the follow re-arm rule, including content shrink
    • the held-open busy list
    • capability-gated client
    • cross-version wire
  • Tests fail without the fixes: each fix was checked by deleting it and confirming its test goes red for the stated reason.

  • Checks: pnpm tc, check:code-quality:changed, check:react-doctor:changed, oxlint and the max-lines ratchet all pass. CI is green, including Mobile Checks, which scans src/shared for engine compatibility.

  • Console: paging logs React flushSync was called from inside a lifecycle method from the list virtualizer measuring rows during commit. Main logs the same during "Load earlier"; this PR's longer jumps log it more times.

  • Not tested: SSH or paired remote hosts end to end (covered by the capability check and the cross-version suite), Linux, Windows, and real 200-item pages.

  • I manually tested these changes locally

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

AI Disclosure

Review

Known and left alone:

  • Jumps can land a few pixels low. If rows above the target measure differently from their estimated height mid-scroll, a jump lands that far below the top (seen as 8–12px). The jump aims at a fixed pixel offset, and the list doesn't correct for rows above changing size during a smooth scroll. Aiming at the row index would fix it, but that path is shared with the diff reveal, so it's left for a separate change. Jumps to loaded messages behave the same way on main.
  • omittedEntries isn't shown in the UI. Past roughly 20,000 user messages, the oldest ticks are dropped with no marker. The newest entries are kept.
  • Jumping to the first message of a very long chat loads its whole history into the window. This is the same as scrolling there by hand.
  • Overlap with fix(native-chat): load older messages automatically before the reader reaches the top #22541 (automatic older-history loading): both PRs touch the transcript scroll hook and the older-history load signature. Whichever merges second needs a small rebase.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: the new method sits behind the same gate as agentSession.history and returns a subset of what history already returns.
  • Cross-platform: no platform-specific code.
  • Remote SSH / paired hosts: the new method is capability-negotiated. An older host is never called, and an older client never calls it.
  • Mobile: the mobile allowlist is unchanged, so mobile doesn't use the method.
  • Backwards compatibility: additive only.
  • Performance: one outline read per window gap, bounded by the page byte budget. There is no per-batch work, and fully loaded sessions never fetch. The shared transcript projection does the same work per batch as before.

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)

…st loaded ones

The message rail was built only from transcript rows the renderer had
loaded, so any prompt above the loaded page had no tick, and the rail lost
ticks when a long live session trimmed its retained window.

The host now answers `agentSession.conversationOutline`: every user message
in a structured session's journal (item id, creation sequence, a preview
cut to 200 characters, image count) plus the journal position it is current
through. It is derived from the reduced journal on each request with the
same projection the transcript runs, so an entry's id and preview are what
the loaded row shows. The reply is bounded like a history page: previews
shorten, then drop, and only then do the oldest entries go.

The renderer asks only while the pane is visible and older history is
unloaded, uses outline entries only for messages older than its loaded
window (the window is authoritative for the rest), and falls back to loaded
messages while the outline is stale (epoch change, or the window trimmed
past what it covers). Selecting a tick with no row pages older history in
until the row exists, then uses the existing rail jump.

The method is negotiated with `agent-session.conversation-outline.v1`; a
client never calls a host that does not advertise it, and any failure
leaves the rail on loaded messages.
…low and cancelling itself

A rail jump started by a reader following the end stopped a few pixels
above the bottom instead of reaching the message. Paging older history in
for a jump always leaves the reader following at the very end, so jumps to
unloaded messages hit it every time; a jump to a loaded message from the
end did too.

The jump scrolls smoothly, and only its landing is marked as the
application's own scroll. Its first frames move a pixel or two, still
inside the band where a reader event re-arms follow, so the list read the
jump leaving the end as the reader arriving at it. The next frame, just
outside the band, then read as the reader taking over and rebased the view
with an instant write, which cancels the smooth scroll.

Re-arming follow now needs the reader to be arriving at the end: an
unmarked event that moved the view up never reattaches a detached reader.
…lects an item

With the whole conversation in the rail, its hover list overflows and opens
scrolled to the message being read. Clicking an older item did nothing:
pressing it focuses it, which turns the hover preview interactive, and that
switch re-ran the effect that scrolls the lit row into view and focuses it.
The list moved under the pointer between press and release, so the click
landed on the list instead of the item, and focus jumped to the lit row.

Revealing the lit row now follows the list opening (and its rows shifting),
not the switch between hover and interactive. Entering interactive moves
focus into the list only when focus is not already on one of its items.
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 7055e045-4c17-4f43-81e6-54071865d1fe

📥 Commits

Reviewing files that changed from the base of the PR and between 26c278e and 7c86186.

📒 Files selected for processing (4)
  • src/renderer/src/components/native-chat/NativeChatMessageList.rail-history-jump.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageRail.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageRail.tsx
  • src/shared/native-chat-transcript-projection.ts

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


📝 Walkthrough

Walkthrough

The change adds a structured agent-session conversation-outline RPC. The host projects and bounds user-message entries, and the renderer checks outline freshness before merging entries into the native-chat rail. Selecting an unloaded rail entry can page older history before jumping to its loaded row. The change also updates transcript follow-state handling to use distance from the end.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 7c861

The message rail can show a few prompts out of transcript order at a history-page boundary. Navigation remains available, so this is mergeable with owner awareness.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 34.78% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 69 functions across 55 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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 identifies the primary change: showing all user messages on the native-chat message rail, including unloaded messages.
Description check ✅ Passed The description is detailed and covers the user impact, implementation, rationale, testing, visual proof, compatibility, and known limitations. The required Linked Issue is missing and is listed as No…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 35bb3690-61e9-4e14-a8c2-ae936bfe08d7

📥 Commits

Reviewing files that changed from the base of the PR and between f1eb191 and 0284293.

⛔ Files ignored due to path filters (1)
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing (43)
  • src/main/native-chat/agent-session-wire/agent-session-conversation-outline.test.ts
  • src/main/native-chat/agent-session-wire/agent-session-conversation-outline.ts
  • src/main/runtime/rpc/methods/structured-agent-session-conversation-outline.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-conversation-outline.ts
  • src/main/runtime/rpc/methods/structured-agent-session-gate-classification.test-fixture.ts
  • src/main/runtime/rpc/methods/structured-agent-session-rpc.test-fixture.ts
  • src/main/runtime/rpc/methods/structured-agent-session.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session.ts
  • src/renderer/src/components/native-chat/NativeChatBackgroundTaskRun.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageList.rail-history-jump.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageList.stream-render.perf.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageList.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageRail.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageRail.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageRow.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx
  • src/renderer/src/components/native-chat/native-chat-autoscroll.test.ts
  • src/renderer/src/components/native-chat/native-chat-autoscroll.ts
  • src/renderer/src/components/native-chat/native-chat-message-rail-items.test.ts
  • src/renderer/src/components/native-chat/native-chat-message-rail-items.ts
  • src/renderer/src/components/native-chat/native-chat-rail-outline-parity.test.ts
  • src/renderer/src/components/native-chat/native-chat-row-height-estimate.ts
  • src/renderer/src/components/native-chat/native-chat-transcript-slots.ts
  • src/renderer/src/components/native-chat/structured-agent-session-rail-outline.test.ts
  • src/renderer/src/components/native-chat/structured-agent-session-rail-outline.ts
  • src/renderer/src/components/native-chat/use-native-chat-live-session.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-history-jump.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-rail-history-jump.ts
  • src/renderer/src/components/native-chat/use-native-chat-transcript-scroll.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session-rail-outline.test.tsx
  • src/renderer/src/components/native-chat/use-structured-agent-session-rail-outline.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session.ts
  • src/renderer/src/runtime/structured-agent-session-client.test.ts
  • src/renderer/src/runtime/structured-agent-session-client.ts
  • src/shared/agent-session-conversation-outline.ts
  • src/shared/native-chat-prose.ts
  • src/shared/native-chat-row-content.ts
  • src/shared/protocol-version.ts
  • tests/e2e/cross-version-wire/cross-version-agent-session-wire.unit.test.ts
  • tests/e2e/cross-version-wire/structured-agent-session-host-fixture.ts
  • tests/e2e/cross-version-wire/structured-agent-session-surface-manifest.ts

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

…mmed window slides

A long live session holds a head-trimmed window, so every new row moved the
oldest-loaded edge and rebuilt the outline view even when no user message
crossed it. The rail then re-merged, re-rendered and re-read the scroll
geometry on each new row. The view is now reused while the set of entries
older than the edge is unchanged.
Scrolling to the top of the loaded window asks for the next older page. A rail
jump made while that page was in flight asked again, got the lane's immediate
no-op return, read it as a page with no progress, and dropped the click. The
jump now waits for the in-flight page to land before deciding.
…der onto the end

The rule that stops a smooth scroll leaving the end from re-arming follow
compared offsets, so it also refused a reader whose offset dropped because
settled content folded away beneath them and the browser clamped them onto
the end. They sat at the bottom without following, and the next reply grew
out of view. Re-arming now requires closing on the end rather than moving
down, which still rejects a scroll leaving it.
Both hooks wrote a ref while rendering, which React may replay or discard.
The rail's structural-sharing baseline is now recorded after commit, and the
history jump calls the lane's page loader from its effect instead of through
a render-updated ref.
A jump to an unloaded message keeps paging older history until it lands. A
pick made meanwhile lost to it: a loaded message scrolled into view, then the
earlier jump finished and pulled the reader away; another unloaded message was
ignored. Picking a loaded message now cancels the paging jump, and picking an
unloaded one retargets it without asking for a second page.

@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 suggestion only — the feature works and I found no blocking issue.

Reviewed changes

  • Host outline read. readAgentSessionConversationOutline derives every user message the transcript would draw from the journal snapshot per request, degrading previews (200 → 60 → '') before dropping oldest entries, bounded by the history-page byte budget.
  • RPC + capability. New agentSession.conversationOutline (same requireStructuredHost gate as history, OptionsParams), advertised as agent-session.conversation-outline.v1; client probes it through the shared capability helper before calling. Cross-version manifest and fixtures updated; STRUCTURED_AGENT_SESSION_METHODS 28 → 29.
  • Shared preview parity. nativeChatUserMessagePreview and projectAgentSessionConversationOutline moved to src/shared/, so a loaded row and an outline entry for the same message preview identically. I checked the projection against native-chat-turn-fold (user rows never fold) and hasImages === imageCount > 0 — no parity gap on those paths.
  • Rail merge. mergeNativeChatRailOutline places unloaded outline entries before loaded items, lets a loaded item replace its entry, and allows slotIndex: null. The loaded window wins for everything it covers.
  • Jump through history. use-native-chat-rail-history-jump pages older history until the target has a slot, then runs the existing jump (one at a time, 1000-page cap, stops on no progress). The real structured lane's loadOlder is () => Promise<void> resolving after the page applies, so the commit-driven loop works.
  • Scroll fixes. nextFollowingEnd now requires motion toward the end before re-arming follow. I verified programmatic writes bypass it, previousScrollTopRef ordering is correct, and prepend/measurement writes are marked — no regression found.
  • Hover-list press. The reveal now runs on open rather than on the hover→interactive transition, with a focus guard, so pressing an overflow item no longer slides the list.
Technical details
# A stale-after-arrival outline is never re-read for the rest of the epoch

## Affected sites
- `src/renderer/src/components/native-chat/use-structured-agent-session-rail-outline.ts:37` — `const requestKey = enabled && view.kind === 'stale' ? state.epoch : null`
- `src/renderer/src/components/native-chat/use-structured-agent-session-rail-outline.ts:52` — effect deps `[requestKey, sessionId, target]`
- `src/renderer/src/components/native-chat/structured-agent-session-rail-outline.ts:42-48` — staleness is `outline.cursor.sequence < oldestLoadedSequence - 1`

## Required outcome
If a successful read lands but the view is still stale (the loaded-window edge advanced
past `outline.cursor.sequence` while the read was in flight), the hook should schedule
exactly one more read for that epoch. Today `requestKey` is the same `state.epoch` string
before and after `setOutline`, so React does not re-run the effect and the rail falls back
to loaded messages until the epoch changes or the pane is re-enabled. Reachability is
narrow — per `src/shared/structured-agent-session-reducer.ts` the front edge only advances
once the retained-item floor (~1024) is hit, so it needs >1024 items applied during one
round trip, or a same-epoch window replacement landing mid-flight — which is why I've
filed it as minor rather than blocking.

## Suggested approach
Include the window edge in the trigger while stale (e.g. `state.epoch` + `oldestLoadedSequence`),
guarded by a ref recording the edge the in-flight/last read was issued for, so a read that
lands fresh still costs nothing and a moved edge that leaves the view stale issues one
follow-up rather than a fetch per streamed batch.

## Open questions for the human
Is the "one read per gap" comment in the file header intended to tolerate a read that
returns already-stale, or should that case self-heal?

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

oldestLoadedSequence: state.items[0]?.sequence ?? null,
hasOlder: state.hasOlder
})
const requestKey = enabled && view.kind === 'stale' ? state.epoch : null

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.

The read is keyed on the epoch, so a read that lands already-stale — the loaded-window edge advanced past outline.cursor.sequence while it was in flight — leaves requestKey unchanged and schedules no follow-up read for that epoch; the rail then falls back to loaded messages until the epoch changes or the pane is re-enabled. It is narrow (needs the front edge to move ~1024+ items during one round trip, or a same-epoch window replacement landing mid-flight), hence a minor note rather than a blocker.

Technical details
# A stale-after-arrival outline is never re-read for the rest of the epoch

## Affected sites
- `use-structured-agent-session-rail-outline.ts:37` — `requestKey = enabled && view.kind === 'stale' ? state.epoch : null`
- `use-structured-agent-session-rail-outline.ts:52` — deps `[requestKey, sessionId, target]`
- `structured-agent-session-rail-outline.ts:42-48` — stale when `outline.cursor.sequence < oldestLoadedSequence - 1`

## Required outcome
After a read lands with the view still stale, schedule exactly one more read for that epoch;
a read that lands fresh must still cost nothing.

## Suggested approach
Include the window edge in the trigger while stale (e.g. `state.epoch` + `oldestLoadedSequence`),
guarded by a ref recording the edge the last read was issued for, so a moved edge issues one
follow-up rather than one fetch per streamed batch.

## Open questions for the human
Does the file header's "one fetch per stale edge" intend to tolerate a read that returns already-stale?

The step that requests the next page wrote the pending jump from the value
its effect closed over, so a pick or cancel queued since that commit would
be overwritten.

@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 critical issues — one minor suggestion inline.

Reviewed changes

Reviewed the six commits pushed since the prior pullfrog review (d980bf5796…a8ffe1abd2) — follow-up fixes to the rail jump and follow-rearm logic, one outline-cache optimization, and their tests.

  • Rail outline cache keyed on the covered count. selectStructuredRailOutline reuses the previous view when the number of entries older than the loaded edge is unchanged, so a live window that head-trims past no user message no longer produces a new entries array.
  • History jump waits out an in-flight page. The hook takes loadingEarlier and holds its step until an older page already loading (e.g. from scrolling to the top) lands, instead of reading the lane's ignored request as "no progress".
  • Latest pick wins; jump is cancellable. A pick while paging retargets the pending message id and the page step is a functional update; selecting a loaded tick cancels the in-flight jump in NativeChatMessageList.
  • Follow rearm measured from the end. nextFollowingEnd compares distance-from-bottom, so content shrinking under a detached reader and clamping them onto the end reattaches follow; the transcript hook tracks previousDistanceFromEnd.
  • Ref writes moved out of render. previousItemsRef and the jump hook's loadEarlierRef are no longer written during render.

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

count += 1
}
}
// "Older than the edge" only grows or shrinks with it, so an equal count is the same set.

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.

The count shortcut is correct only because outline.entries is sequence-ascending (journal order, and the host only drops entries from the front), which makes "older than the edge" a prefix of the list. That ordering is not encoded in AgentSessionConversationOutlineEntry, so a future reorder would let equal counts return a different set while the cache reports a hit. Spelling it out keeps the assumption visible.

Suggested change
// "Older than the edge" only grows or shrinks with it, so an equal count is the same set.
// Entries are sequence-ascending, so "older than the edge" is a prefix of the list and
// an equal count is the same set.

…ed loop

The jump through unloaded history was an effect-driven state machine that
guessed "no progress" from the message list's identity and could not be
cancelled by anything but another rail pick. A diff reveal, "Jump to latest"
or the reader scrolling left it paging, and when its page landed it pulled
the reader away; a history read that kept failing during a live turn could
repeat back to back.

Loading an older page now reports how it ended, and a second request while
a page is in flight joins it instead of being refused. The jump is an
awaited loop that reads the rail from a commit after each page, stops on
anything but a page that moved the window, and is aborted by any other
navigation, reader input (wheel, touch, scroll keys, scrollbar), a session
switch or unmount. The latest pick wins.
…rojection

The host built the outline from user items alone, while the transcript
orders every message by when it was observed, folds tool results into the
turn above and then drops harness turns. An imported user row carrying a
tool result beside harness text therefore got a rail tick previewing the
harness text, and clicking it paged history for a row that never draws.

The transcript's order-fold-strip projection now lives in one shared
function. The renderer's list projection wraps it with its own tail-row
order, and the host runs it over the whole journal and keeps the user rows
that draw content, so the outline lists the same messages in the same order.
A failed outline read left the rail on loaded messages until a new gap
opened, the pane was shown again or the epoch changed. The client now
rejects a failed read (a host without the outline still resolves to
nothing, without being called), and the rail retries up to three times
with doubling backoff.
…paging

The rail forwards its wheel to the transcript, so a reader scrolling there is
scrolling the transcript. That wheel never reached the scroller's reader-input
handlers, so the jump kept paging and later pulled the reader to its target.

@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 critical issues — one minor suggestion inline.

Reviewed changes

Reviewed the five commits pushed since the prior pullfrog review (a8ffe1abd2…ee7b8a75d6): the rail history jump rewritten as one abortable awaited loop, the host outline re-derived from the transcript's own projection, retry-with-backoff for a failed outline read, and the older-page result contract the shared page now carries.

  • Abortable jump loop. use-native-chat-rail-history-jump is now one awaited loop per jump owning an AbortController; each step reads the rail from a commit made after the last page landed, and the loop stops on any non-applied page, a missing target, the 1000-page cap, or an abort from a later pick, any other navigation, reader input, a session switch, or unmount.
  • Outline from the transcript projection. projectAgentSessionConversationOutline now runs the shared projectNativeChatTranscriptMessages over the whole journal, so an outline entry matches the row the transcript draws (folded tool-result sidecars and observation order included) instead of a user-items-only reading; the parity test was extended with those shapes.
  • Outline read retry. readStructuredAgentSessionConversationOutline rejects instead of returning null, and the hook retries a rejected read up to three times with exponential backoff while never retrying a host that lacks the capability.
  • Older-page result contract. loadEarlier/loadOlder return NativeChatOlderPageResult, share one in-flight page between concurrent callers (scroll-to-top, the button, a rail jump), and report supersession so a jump can tell "no progress" from a page it joined.

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

[run]
)

useEffect(() => abort, [abort, sessionKey])

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.

The loop's commit waiter is resolved by a layout effect, but the session-change abandonment is installed with a passive useEffect, so on a session switch the resumed loop can read the new session's committedRef — and page/jump against it — before this cleanup aborts. The file's contract is that a session change abandons the jump; installing this as a layout effect closes the ordering gap with a one-word change.

Technical details
# Session change can be observed by the jump loop before `abort()`

## Affected sites
- `use-native-chat-rail-history-jump.ts:130` — `useEffect(() => abort, [abort, sessionKey])` (passive)
- `use-native-chat-rail-history-jump.ts:49-56` — dependency-free `useLayoutEffect` that writes `committedRef` and resolves waiters in the same commit
- `use-native-chat-rail-history-jump.ts:73-98` — `run` reads `committedRef.current.items` right after `await nextCommit(signal)`

## Required outcome
When `sessionKey` changes while a jump is parked in `nextCommit`, the jump must abort before its continuation microtask reads `committedRef` (which the layout effect already repointed at the new session's rail). Otherwise the loop may call `loadEarlier`/`jumpToLoaded` for the new session. Observable only when the old target id also exists in the new session, since the loop bails when `railItemById` misses.

## Suggested approach
Use `useLayoutEffect` for the `abort` installer: it runs in the same synchronous commit as the waiter-resolving layout effect (cleanup aborts first), so the loop resumes with `signal.aborted` already true. Alternatively carry `sessionKey` in `committedRef` and bail at the top of each `run` pass when it no longer matches.

## Open questions for the human
Is the session-change path exercised anywhere while the loop is between pages? The suite covers abort/session change only while the loop awaits `loadEarlier`; `act()` flushes passive effects, so the production ordering is not reproduced.

@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

Reviewed one follow-up commit (26c278e3f3) pushed after the previous pullfrog review.

  • Rail wheel cancels a paging jump. NativeChatMessageRail already forwards a wheel over itself to the transcript scroller (the rail overlays the transcript); it now also calls the reader-scroll callback, so a wheel there aborts a history jump still paging, matching the transcript's own wheel handler. The added test holds the first older page in flight, wheels the rail, and asserts the abandoned jump neither pages further nor pulls the reader to the target.

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

…ges in

Picking a message that is not loaded yet can take several pages of older
history. The list closed on the pick, so its busy item was never seen and
the click looked ignored. The list now stays open with that item pulsing
until the jump lands or is abandoned, and stops revealing the lit row
meanwhile so the rows do not move under the pointer.

@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 in this delta. The three prior minor notes remain open and are untouched by this commit, so approval is withheld; nothing here needs a fix.

Reviewed changes

Reviewed one commit (4b90119123) pushed after the previous pullfrog review.

  • Rail list held open while a pick pages. Picking a message whose row is not loaded now keeps the hover list open with that item marked aria-busy and pulsing until the history jump lands or is abandoned, instead of the click closing the list and hiding its own busy state; a loaded pick still closes it. The list also stops scrolling the lit row into view while a pick is pending, so a landed page shifting rows cannot move an item out from under the pointer. Tests cover the held-open/busy state, Escape closing it, the abandon-settles-pick path, and paging continuing on a wheel over the open list.

Verified locally: the two changed renderer test files pass (31 tests) and oxlint is clean on the three changed files.

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

…obile

The projection moved to src/shared, which mobile's Hermes engine also loads,
and switching its sort to toSorted broke the Hermes compatibility guard.
Sort a copy made with Array.from instead, as other shared code does.

@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 in this delta — the three prior minor notes remain open and are untouched, so approval is withheld; nothing here needs a fix.

Reviewed changes

Reviewed the one commit (7c86186615) pushed since the prior pullfrog review.

  • Hermes-safe sort in the shared projection. projectNativeChatTranscriptMessages sorts a copy (Array.from(messages).sort(compare)) instead of messages.toSorted(compare). Moving the projection into src/shared put it in front of mobile's Hermes engine, and mobile's hermes-array-sorting-compat guard rejects .toSorted( under src/shared/. The copy-then-sort is equivalent, the tie-breaker on id makes engine sort stability moot, and the comment's mention of toSorted stays inert because the guard strips comments before matching.

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready for review at 7c86186615

Summary: 5 review loops plus an architecture review ran on this PR. The last loop came back clean, CI is fully green (21 passed, 11 skipped), and in-app QA confirms the feature works end to end.

What changed during review

First loop, six fixes:

  • the outline view no longer rebuilds on every new row in long live sessions
  • a jump no longer drops the click when an older page is already loading
  • follow-the-bottom re-attaches again when content shrinks under a reader
  • no ref writes during render (these were failing CI static analysis)
  • the latest rail pick wins over a jump that is still paging
  • no stale state write

Architecture review. Three of the first loop's fixes guarded the same bug class instead of removing it. The follow-up refactor changed three things:

  • Loading older history now returns a result (applied, history exhausted, unchanged, failed, or superseded). Both chat lanes join a page that is already loading instead of refusing the second request.
  • The jump to an unloaded message is now one abortable awaited loop. Any other navigation aborts it: a loaded pick, a diff reveal, "Jump to latest", reader wheel/touch/keys/scrollbar, a session switch, or unmount. It previously ran as an effect-stepped state machine.
  • The host outline runs the transcript's own shared projection (order, fold, strip). The old outline projected user rows alone, which drew a tick for an imported row that the transcript folds away.

Later loops:

  • A bounded retry for a failed outline read.
  • A wheel over the rail strip now cancels a paging jump.
  • The hover list stays open, with the picked item busy, while it loads in. The busy state existed before but was never visible.
  • The shared projection no longer uses toSorted, which the mobile engine lacks (this was failing Mobile Checks).

In-app QA (hidden dev window, structured Claude lane; page size and initial read temporarily 6)

Check Result
Rail lists all 8 messages while only turns 7–8 are loaded Pass
Click unloaded turn 1 from the bottom: list stays open, item busy, lands flush at the top (delta 0) Pass
Reader wheel during the history read aborts the jump Pass
Loaded pick while an unloaded jump pages: older jump cancelled Pass. The loaded target was the last message, so it can't sit at the top; it stayed in view.
"Load earlier" paging, no duplicate or missing rows Pass
Follow the bottom while streaming, detach, reattach Pass
Main control No rail with 2 loaded messages, and only loaded turns after paging. The "jump from the bottom cancels itself" bug reproduces on main.

Two QA observations I'm not treating as defects:

  • A wheel sent only after local paging had finished did not stop the landing scroll. It was also a downward wheel while the view was at the end, so it scrolled nothing.
  • React's flushSync ... lifecycle method console message appears while paging. It comes from the list virtualizer measuring rows during commit, and main logs it too during "Load earlier".

Screenshots are in the PR body's Visual Proof section. More from the same run:
ticks with history unloaded
full transcript after Load earlier

Open items, deliberately left out of scope

  • The terminal-transcript chat lane still shows loaded messages only. It's the default lane while structured chat is behind a setting, and it needs its own indexed host read. That lane only adopts the new older-page result contract here.
  • omittedEntries has no UI marker. It only matters past roughly 20,000 user messages.
  • Jumps can land a few pixels low when rows above re-measure mid-scroll. Main behaves the same way.

Not tested: SSH or paired hosts end to end (covered by capability negotiation and the cross-version suite), Linux, and Windows.

@brennanb2025
brennanb2025 merged commit 5e3effc into main Sep 24, 2026
58 of 60 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