Skip to content

Summarize turn file changes and preserve resolved prompt receipts - #19229

Merged
brennanb2025 merged 9 commits into
mainfrom
brennanb2025/nc-turn-rollup
Sep 9, 2026
Merged

brennanb2025 merged 9 commits into
mainfrom
brennanb2025/nc-turn-rollup

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​598 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​597
Prod 16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​701 $\color{#cf222e}{\Huge{\mathbf{−}}}$​213 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​488

What this does, in plain terms

Two things, both about reading a finished turn rather than watching a live one.

1. What did this turn actually change? A turn that edits seven files gives you seven separate diff cards and no total. You had to add it up yourself. Now there's one header — "7 changed files +123 −45" — that expands to the list.

2. What did I approve, again? When you answer an approval or a question, the record of it collapsed to a flat line of text that restated the prompt but not your answer. Now it's a proper receipt showing which option was chosen.

Before → After

Before After
Turn edited 7 files 7 diff cards, no total One rollup header, expandable
Same file edited twice Ambiguous Counted once — the header counts files, not edits
You approved something "title / detail / resolved" Which option you picked, and where
Live approval prompts — Unchanged; those still work exactly as before

Settled receipts are deliberately quiet — they're history, and shouldn't compete with a prompt that actually needs your attention.


Technical detail

ELI5

Each native-chat turn summarizes its recorded changed files, and answered approvals and questions keep a readable receipt of the answer, resolver, and time.

What Changed

  • Add a collapsible unique-file rollup with recorded additions/deletions and links that reveal existing diff cards. Repeated edits and rename chains combine under the final path; truncated patches remain marked.
  • Derive rollups from the exact post-fold message array and turn keys used by the status row. Reuse the existing patch parser for lightweight counts; detailed diff rows remain deferred until the activity opens. Preserve unchanged journal projection identities so settled summaries are reused across streaming updates.
  • Render receipts from existing resolution metadata, including grouped questions with empty flat options, free text, cancellation, and resolver identity. Use stable question IDs for receipt rows and synchronize diff reveal controls before painting.
  • Reuse the identical NativeChatMessageTimestamp component and tests from Show native chat message timestamps on hover #19218 for locale-aware absolute receipt time and a full accessible date label. This deliberately replaces English-only relative ages; no new timer or second date-formatting mechanism is introduced.

Rollups summarize recorded journal Diff envelopes. They do not infer file changes from arbitrary generic tool output or count-only records that contain no usable path. No journal item kind, schema, wire payload, host execution, or persisted data changes.

Why

Per-edit cards made a turn's overall changes hard to scan. Flattened prompt history lost the selected answer and resolver even though both were persisted. The review also removed full diff parsing from collapsed history and kept unchanged rows cached during streaming.

Linked Issue

Coordinator-dispatched native-chat presentation task; no issue link supplied.

Visual Proof

Initial implementation evidence, before the review refinements below: the same journal fixture rendered in a hidden Electron window on macOS, legacy presentation before, enriched presentation after. Clicking a file row was also verified to open its existing diff card. This checks renderer behavior, not a live provider round trip.

Before After
Before After

Refreshed hidden Electron validation is owned by the coordinator's separate QA lane.

Testing

  • 1,204 tests passed across 114 native-chat, shared edit-normalizer/projection/fold, and structured journal archive suites after merging the overlapping main changes.
  • 36 final focused tests passed for reveal/collapse, tool runs, and streaming render performance.
  • Deterministic structured-diff test: one summary scan and zero detailed parses across 20 journal updates; one detailed parse after revealing the file. Summary/card parity covers hunks, renames, truncation, and row caps.
  • Localized timestamp/receipt tests cover live locale changes, invalid dates, grouped answers, and semantic date metadata.
  • Changed-code, type-aware, and React Doctor checks report zero findings; localization catalog/runtime catalog checks and git diff --check pass. Commit hooks pass.
  • No local full typecheck or desktop UI launch was run in this review lane. Latest pushed-head CI is running; Windows, Linux, live SSH/provider and paired-mobile flows were not exercised locally.

Review

Merged main at 2ccf35b with a verified two-parent merge commit before reviewing. Same-model and effort subagent review returned CLEAN after fixes. START readiness review completed with two candidates (eager detailed parsing and English receipt ages); END readiness review PASS with both resolved and zero remaining candidates across all eight sections. The unavailable mobile compatibility skill and unexercised platform/UI matrix are recorded in the coordinator reports; direct compatibility inspection found no wire or persisted-data change.

Agent skill upstream boundary

  • Not applicable; no skill implementation changes.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

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
📝 Walkthrough

Walkthrough

The native chat session now exposes structured journal items to the message list. The UI renders turn-local diff rollups and can reveal and scroll to a selected diff card. Resolved approval and question items render receipts with decoded answers, status, device, and timestamps. Shared edit parsing supports cached summaries and rename-aware totals. Tests cover diff aggregation, reveal behavior, receipts, performance, and legacy message lists.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to db056

Aggregated diff payloads perform avoidable parsing before being discarded. This does not affect displayed results, but moving the guard avoids needless work on that path.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the changes, motivation, testing, visual behavior, and scope. However, it does not provide the required linked issue, and it omits the template's Notes, Checklist, and AI Disc… Add a valid issue reference after "Fixes #". Complete the Notes and Checklist sections, and add the AI Disclosure section or state the applicable exception.
Docstring Coverage ⚠️ Warning Docstring coverage is 28.13% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 32 functions across 20 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies both primary changes: turn file summaries and preserved resolved prompt receipts.
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.
Full details: Description check

Explanation

The description explains the changes, motivation, testing, visual behavior, and scope. However, it does not provide the required linked issue, and it omits the template's Notes, Checklist, and AI Disclosure sections.

Full details: Docstring Coverage

Explanation

Docstring coverage is 28.13% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 32 functions across 20 files. (1 skipped: 1 unsupported.)

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

Important

The turn-diff rollup re-parses every diff in the transcript on each streaming frame — worth confirming against a diff-heavy long session before merge. Details below.

Reviewed changes

  • Turn diff rollups — new nativeChatTurnDiffs collapses a turn's Diff items into unique files (folding rename chains to the destination path) and renders a collapsible summary whose rows reveal the existing per-file diff card and scroll it into view.
  • Resolution receipts — resolved approvals/questions render a passive receipt (selected answer, resolver identity, timestamp, cancellation) instead of the flattened system message, decoding grouped/free-text answers from existing journal resolution metadata.
  • Edit-card reuse — buildEditCards moves to native-chat-edit-cards.ts and shares a WeakMap cache so the rollup and card consumers don't normalize the same tool pair twice.
  • Projection memoization — useStructuredAgentSession memoizes the message projection and exposes journalItems; NativeChatMessageList memoizes receipts/turnDiffs.

⚠️ Rollup diff parsing runs over the whole transcript on every streaming frame

The turn-diff summary recomputes whenever journalItems, messages, or turnKeys change identity — and all three change on every frame of a streaming turn (state.items grows → projection re-runs → new message/block objects). nativeChatTurnDiffs then walks every message and calls editFilesFromToolPair for each Diff block, i.e. the same "most expensive work" the diff card deliberately defers until a run is open. The normalizedEdits WeakMap does not help across frames: it is keyed on block object identity, which projectStructuredItemsToNativeChat recreates on every projection, so it only dedupes the rollup↔card path within a single render.

Net effect: a long structured session re-does patch splitting + LCS for its entire diff history on every stream event, synchronously in render. The existing NativeChatMessageList.stream-render.perf.test.tsx does not catch this — it passes no journalItems and uses text-only messages, so nativeChatTurnDiffs returns an empty map there.

Technical details
# Turn-diff rollup re-parses all diffs every frame

## Affected sites
- src/renderer/src/components/native-chat/NativeChatMessageList.tsx:132 — `turnDiffs` memo keyed on `[journalItems, messages, turnKeys]`, all new-identity every frame.
- src/renderer/src/components/native-chat/native-chat-turn-diffs.ts:38 — `buildEditCards(message.blocks, true)` runs `editFilesFromToolPair` for every `Diff` block in history.
- src/renderer/src/components/native-chat/native-chat-edit-cards.ts:9 — `WeakMap` cache keyed on block identity, defeated across frames by re-projection.
- src/shared/structured-agent-session-projection.ts:111 — projection creates fresh block objects each call.

## Required outcome
- Re-parsing a settled diff must be a no-op across streaming frames (cache hit), so per-frame cost is bounded by the new/changed items, not the whole transcript.

## Suggested approach
- Stabilize block identity: memoize `projectStructuredItemsToNativeChat` per unchanged `AgentJournalRenderItem` (e.g. by `revision`) so `normalizedEdits` also hits across frames.
- Or key the cache on content (item `revision` / `patch.digest`) rather than object identity, and/or skip turns that are not the current turn while `isWorking`.

## Open questions for the human
- Is the live/partial rollup on the active turn intentional (see nitpick), and does that constrain which turns must be recomputed while streaming?

ℹ️ Nitpicks

  • The rollup has no isWorking/isCurrentTurn guard, so a partial "N changed files" appears at the tail of a streaming turn and, because it renders inside the turn's last-message fragment, its collapse state resets as each new message lands. If the summary is meant to describe completed turns only, gate it on turn completion.

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

const [expanded, setExpanded] = useState(initiallyExpanded)
const cardRef = useRef<HTMLDivElement>(null)
useLayoutEffect(() => {
if (revealSignal && cardRef.current) {

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.

revealedDiff is never reset, so the last revealed card stays the target. Collapsing and re-expanding the turn remounts the card, which re-runs this effect on mount and scrolls the viewport back to the same card. Consider clearing the reveal target once consumed (e.g. reset revealedDiff after onReveal) so a plain re-expand doesn't yank the scroll.

@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 prior performance concern is now addressed.

Reviewed changes

  • Deferred turn-diff detail parsing — buildDiffSummaries + summarizeUnifiedPatch now read only lightweight counts from the journal's path-only Diff envelope; full line models are built only when the tool run opens.
  • Stabilized projection identity — projectStructuredItemToNativeChat memoizes via a projectedItems WeakMap, and the reducer's mergeItems preserves identity for unchanged items, so settled diffs hit the summary cache across streaming frames.
  • Added structured perf coverage — the stream-render perf test now drives structured Diff items and asserts one summary scan and zero detailed parses across 20 journal updates.
  • Localized resolution times — new NativeChatMessageTimestamp replaces English-only relative ages with locale-aware absolute time plus an accessible full-date label.
  • Stabilized receipt rows — receipt answer rows are keyed by stable question id rather than array index.
  • Reworked reveal/open sync — NativeChatToolRun uses a render-phase controls snapshot so a revealedDiff change opens the run without clobbering the expand-override state.

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Manual UI validation — Electron, real app, CDP screenshots

Driven in an isolated Orca dev instance built from this branch (brennanb2025/nc-turn-rollup @ 24869b7d05), fresh ORCA_DEV_USER_DATA_PATH, hidden renderer, CDP-only. Real structured Codex and Claude sessions against a scratch folder workspace — no fixtures, no component harness. Verdict: all five criteria pass.

1. A turn that edits several files shows one rollup header with a file count and total added/removed

Codex turn 1 made three apply_patch edits (alpha.txt, beta.txt, gamma.txt); turn 2 made three patches across two files. Each turn gets its own header, anchored to that turn.

collapsed rollup headers, dark
Dark: two turns, each closed by its own rollup — 3 changed files +3 −1 and 2 changed files +4.

collapsed rollup headers, light
Light: same two headers; counts and the +/− pair read correctly on the light surface.

2. A file edited twice in one turn is counted once

Turn 2 was two separate patches to alpha.txt plus one to beta.txt. The header says 2 changed files, and the expanded list shows alpha.txt once with its two patches summed to +3.

expanded rollup showing per-file list, dark
Dark, expanded: "Totals from recorded edits in this turn" over /tmp/ncr-ws/alpha.txt +3 (two patches, one row) and /tmp/ncr-ws/beta.txt +1.

expanded rollup showing per-file list, light
Light, expanded: same de-duplicated per-file list; each row stays clickable to reveal its diff.

3a. A resolved question renders as a quiet receipt showing which option was chosen

Claude called AskUserQuestion; I picked "Two spaces" and submitted.

resolved question receipt, dark
Dark: the answered prompt collapses to a muted, left-ruled receipt — chosen option "Two spaces", Resolved · Answered on desktop-renderer · 12:15 PM.

resolved question receipt, light
Light: same receipt, still visually subordinate to the surrounding assistant prose.

3b. A resolved approval renders the same way

Claude asked to run wc -l …; I chose "Allow for this session".

resolved approval receipt, dark
Dark: Allow Bash? receipt naming the exact option chosen — "Allow for this session" — plus resolver and time, with the tool output following underneath.

resolved approval receipt, light
Light: same approval receipt; the command detail stays readable without competing with the transcript.

4. Pending approval and question cards at the composer are unchanged and still work

Both pending cards render at the composer exactly as before and both actually resolved through the real mutation path (the receipts above are the proof).

pending question card, dark
Dark: pending question card — numbered options, descriptions, free-text field and Skip, all intact.

pending question card, light
Light: same pending question card, unchanged.

pending approval card, dark
Dark: pending approval card — Allow / Allow for this session / Deny / Stop, all intact.

pending approval card, light
Light: same pending approval card, unchanged.

5. Light and dark

Every state above was captured in both themes; nothing loses contrast or structure in either.


Two small things worth a look (not blockers)

  1. The question receipt prints its title twice. NativeChatResolutionReceipt renders body.question as the title and answer.question per answer. For a single-question prompt those are the same string, so "Which indent style should the sample files use?" appears on two consecutive lines. Suppressing answer.question when it equals the title would fix it.
  2. The rollup is Codex-only in practice. buildDiffSummaries only counts tool blocks named Diff, which come from journal kind: 'diff' items — and those are produced solely by the Codex translation path. A Claude turn that edits three files via the Edit tool renders no rollup at all (confirmed live: files changed on disk, no header). That may well be intended for this PR, but the surface is silently absent for Claude sessions rather than degraded.

Scope of this run

Local execution host, macOS, folder workspace. Not covered: SSH/remote hosts, mobile, truncated (Partial diff) rollups, and the rename-collapse branch in nativeChatTurnDiffs.

@brennanb2025

brennanb2025 commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor Author

Status: ready for review

Plan review

Reviewed before any code was written. APPROVE WITH AMENDMENTS, all applied. Three were substantive:

  • The correlation had no key. The plan proposed mapping journal diff items to their projected blocks, but a projected diff block carries only { path } — no itemId — and block references are stable only within one render pass. Redirected to derive from the same post-fold array in the same memo chain as turnKeys, which also guarantees the rollup's turn grouping can never disagree with the status row's.
  • A latent performance regression. Diff parsing is deliberately deferred until a run is expanded; an always-visible rollup header would have forced it for every turn, collapsed or not. Now memoized per journal update.
  • Grouped questions read the wrong field. The flat options array is empty for grouped Claude questions, so receipts would have rendered "unknown option" for every grouped answer. Now sourced from body.questions.

Code review loop

Same-model subagent review returned clean. readiness-checklist at start and end; the closing run resolved both opening candidates with zero remaining findings. 1204 broad tests plus 36 focused tests pass.

Verification

  • Central typecheck: exit 0.
  • Merged with origin/main, two parents verified.

Manual UI validation

Real Orca dev build, hidden renderer over CDP, driving real structured Codex and Claude sessions against a scratch folder workspace. 12 screenshots attached above. All five criteria pass, including the one most likely to be wrong: a file patched twice in one turn appears exactly once with its counts summed (header 2 changed files +4; list showed alpha.txt +3 once plus beta.txt +1). Pending approval and question cards are unchanged and still work.

Process deviations, stated plainly

  • The review loop's $orchestration arm was not used. Nested worker depth is 1 in this install, so a dispatched worker cannot dispatch its own workers (nested_worker_depth_exceeded). The UI validation lane was run directly by the coordinator at depth 0. The substance of the loop — subagent review to clean, readiness bookends, independent UI validation with visual evidence — was carried out in full.
  • readiness-checklist's severity-counsel step was unavailable for the same depth reason, and is recorded as unavailable rather than reported as a verdict.
  • Validation ran on Claude, not the originally-planned agent, which ran out of quota mid-programme.

Known-red, not caused by this PR

structured-agent-session-adoption-replay.test.ts:188 fails on a clean detached origin/main checkout — reproduced independently by two lanes, byte-identical failure. It is a pre-existing break on main and was deliberately not touched.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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: Team

Run ID: 67be9a3b-206f-43e6-af4f-d63054f57a46

📥 Commits

Reviewing files that changed from the base of the PR and between d0506bf and c81420a.

📒 Files selected for processing (21)
  • src/renderer/src/components/native-chat/NativeChatDiffCard.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/NativeChatMessageList.turn-history.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageRow.tsx
  • src/renderer/src/components/native-chat/NativeChatResolutionReceipt.test.tsx
  • src/renderer/src/components/native-chat/NativeChatResolutionReceipt.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx
  • src/renderer/src/components/native-chat/NativeChatToolRun.tsx
  • src/renderer/src/components/native-chat/NativeChatTurnDiffRollup.tsx
  • src/renderer/src/components/native-chat/native-chat-edit-cards.ts
  • src/renderer/src/components/native-chat/native-chat-resolution-receipt.ts
  • src/renderer/src/components/native-chat/native-chat-turn-diffs.test.ts
  • src/renderer/src/components/native-chat/native-chat-turn-diffs.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session.ts
  • src/renderer/src/i18n/locales/en.json
  • src/shared/native-chat-edit-normalize.ts
  • src/shared/native-chat-edit-patch-files.ts
  • src/shared/native-chat-unified-patch.ts
  • src/shared/structured-agent-session-projection.test.ts
  • src/shared/structured-agent-session-projection.ts
🚧 Files skipped from review as they are similar to previous changes (13)
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/components/native-chat/NativeChatTurnDiffRollup.tsx
  • src/renderer/src/components/native-chat/NativeChatDiffCard.tsx
  • src/renderer/src/components/native-chat/use-structured-agent-session.ts
  • src/renderer/src/components/native-chat/NativeChatMessageList.turn-history.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageRow.tsx
  • src/renderer/src/components/native-chat/NativeChatResolutionReceipt.tsx
  • src/renderer/src/components/native-chat/NativeChatToolRun.tsx
  • src/renderer/src/components/native-chat/native-chat-turn-diffs.ts
  • src/renderer/src/components/native-chat/native-chat-resolution-receipt.ts
  • src/renderer/src/components/native-chat/NativeChatMessageList.tsx
  • src/renderer/src/components/native-chat/NativeChatResolutionReceipt.test.tsx

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

Comment on lines +81 to +131
const diffSummaries = new WeakMap<
NativeChatBlock,
{
result: NativeChatBlock | undefined
files: NativeChatEditFileSummary[] | null
}
>()

// Only the journal's path-only Diff envelope has counts that can be read without tool normalization.
export function buildDiffSummaries(blocks: NativeChatBlock[]): Map<
NativeChatBlock,
{
files: NativeChatEditFileSummary[]
key: string
}
> {
const summaries = new Map<NativeChatBlock, { files: NativeChatEditFileSummary[]; key: string }>()
for (const [index, pair] of pairToolBlocks(blocks).entries()) {
const { call, result } = pair
if (
!call ||
call.name !== 'Diff' ||
call.state === 'running' ||
call.state === 'failed' ||
result?.isError ||
result?.editPatch ||
!result?.output
) {
continue
}
const input = call.input
if (
!input ||
typeof input !== 'object' ||
!('path' in input) ||
typeof input.path !== 'string' ||
Object.keys(input).some((key) => key !== 'path')
) {
continue
}
const cached = diffSummaries.get(call)
let files = cached?.result === result ? cached.files : undefined
if (files === undefined) {
files = editFilesFromPatchText(result.output, input.path, true)
diffSummaries.set(call, { result, files })
}
if (files?.length) {
summaries.set(call, { files, key: `${call.name}:${index}` })
}
}
return summaries

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

Include normalized successful edit pairs in turn-diff aggregation

When a structured Claude Edit tool call completes, the session projects it into a tool pair that buildEditCards already normalizes. buildDiffSummaries only accepts Diff, so nativeChatTurnDiffs omits that edit and renders no changed-file rollup for the turn. Reuse the normalized edit-pair path at the shared summary boundary and map its counts to NativeChatEditFileSummary.

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

Important

One prior finding remains open and this delta does not address it — the stale reveal at NativeChatDiffCard.tsx:126.

Reviewed changes

  • Merged origin/main — this delta is a single merge commit (c81420a43e) folding in #19218 (timestamps) and #19226 (tool row identity/annotations).
  • Deduplicated NativeChatMessageTimestamp — this PR's copy is dropped; main now owns an identical one, and NativeChatResolutionReceipt/NativeChatTranscriptChrome import it unchanged.
  • Integrated tool annotations — NativeChatToolRun threads onLinkClick and renders NativeChatCommandMetadata/NativeChatSearchResults/mcpIdentity, coexisting cleanly with the revealedDiff/buildEditCards rework.

⚠️ Stale reveal target is never reset

revealedDiff in NativeChatMessageList only increments requestId on a new reveal and is never cleared. Collapsing and re-expanding a turn remounts the revealed NativeChatDiffCard, whose useLayoutEffect re-fires on mount because revealSignal is still truthy, yanking the viewport back to the previously revealed card. This is a pre-existing open thread and is unchanged by this merge.

Technical details
# Stale reveal target is never cleared

## Affected sites
- src/renderer/src/components/native-chat/NativeChatMessageList.tsx:67-70 — `revealDiff` increments `requestId`; `revealedDiff` never resets to `null`.
- src/renderer/src/components/native-chat/NativeChatDiffCard.tsx:125-130 — `useLayoutEffect` fires on `revealSignal` on every mount, not just its edge.

## Required outcome
- A plain collapse → re-expand must not re-scroll to the previously revealed card.

## Suggested approach
- Clear `revealedDiff` once consumed (after `onReveal`), or track the consumed `requestId` so a remount without a new `requestId` is a no-op.

## Open questions for the human
- Is a re-reveal on re-expand ever desirable, e.g. returning to a card the user explicitly reopened?

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Fresh rollup layout evidence for e34cbeb67f. These screenshots supersede the earlier rollup screenshots in this PR.

The summary now comes first, with the non-shrinking chevron pushed to the right by the flex layout. The explanation and file list are indented using pl-4 (1rem / 16px); the existing open-state rotation and reduced-motion guard are preserved.

Captured through Playwright CDP in this worktree’s hidden Orca Electron renderer, launched with ORCA_BACKGROUND_LAUNCH=1. A temporary journal fixture rendered the real message-list and rollup components inside the app; it was removed after capture. This is focused layout evidence, not a new live-provider run.

Dark — collapsed, chevron at the right edge.

dark-collapsed.png

Dark — expanded, explanation and file list nested below the header.

dark-expanded.png

Light — collapsed, same summary and trailing chevron.

light-collapsed.png

Light — expanded, 16px body padding and unchanged +4 total / +3 and +1 file counts.

light-expanded.png

Validation: 28 tests passed across the turn-diffs, turn-history, stream-render, and resolution-receipt suites; changed-file oxlint and commit hooks passed. No typecheck was run in this lane. Only the rollup component is committed.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/renderer/src/components/native-chat/NativeChatMessageRow.tsx (2)

97-97: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Handle empty structured notices before the empty-row guard.

AgentJournalItemBodySchema accepts empty status.text, and projectStructuredItemToNativeChat forwards it with presentation: 'compaction'. For this message, NativeChatMessageRow returns null before NativeChatNoticeRow can render the separator. Move notice handling before the guard and add a regression test for an empty compaction notice.


101-107: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Do not drop sibling blocks from system messages.

AgentJournalItemBodySchema allows multiple blocks, and legacy import preserves their metadata and order. If a system message contains a metadata-bearing text block and another block, MessageRow renders only the first block and returns. Render all system-message blocks or enforce a single-block invariant in the message contract.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 87ddbf13-5da1-4731-ae00-03b92a0395b8

📥 Commits

Reviewing files that changed from the base of the PR and between e34cbeb and f2c20ee.

📒 Files selected for processing (4)
  • src/renderer/src/components/native-chat/NativeChatMessageRow.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/shared/structured-agent-session-projection.test.ts
  • src/shared/structured-agent-session-projection.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/i18n/locales/en.json

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

@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 — an origin/main merge that integrates cleanly.

Reviewed changes

  • Merged origin/main — the single delta commit f2c20eee folds in #19228 (compaction notices, plan documents, and images) and #19366 (mobile max-lines cleanup) onto the feature branch.
  • Integrated notice rendering alongside this PR — NativeChatMessageRow now early-returns a NativeChatNoticeRow for system text blocks carrying presentation/tone, and structured-agent-session-projection propagates those fields; both coexist intact with this PR's revealedDiff/onRevealDiff wiring and its turnDiff/receipt i18n keys.

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

UI validation (real dev build, hidden renderer over CDP, real components + real turn-diff computation):

Turn rollup collapsed in dark theme: one header reading 2 changed files +9 −3
Collapsed rollup in dark theme: one header per turn with file count and total +9/−3.

Turn rollup expanded in dark theme: per-file rows for src/a.ts +4 −3 and src/b.ts +5
Expanded rollup in dark theme: per-file rows; src/a.ts was edited twice in the turn yet appears once (+4/−3 summed), with quiet resolved approval/question receipts below and unchanged live pending cards (question card shown mid-answer with selection + Submit).

Same expanded rollup, receipts, and pending cards in light theme
Same surfaces in light theme: rollup totals, quiet receipts, and unchanged live approval/question cards all read correctly.

Checks: header counts unique files not edits (3 edits across 2 files → “2 changed files”); resolved prompts render as quiet border-l receipts with chosen option + resolver + time, no buttons; pending approval/question cards untouched and still interactive (option select verified); unit suites green (turn-diffs, resolution-receipt, turn-history: 26 passed). No surrounding-surface regression observed.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

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

🧹 Nitpick comments (1)
src/shared/native-chat-edit-patch-files.ts (1)

54-60: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Move the FILE_COUNT_PATH guard above the section split.

unifiedPatchSections(moved.body) parses the whole patch at Line 54. The guard at Line 55 then discards that result and returns null. Run the guard first to skip the parse for aggregated multi-file payloads.

♻️ Proposed reordering
-  const split = unifiedPatchSections(moved.body)
   if (callerPath !== null && FILE_COUNT_PATH.test(callerPath)) {
     // The producer joined several files' patches and kept a count in place of a
     // path, so nothing here can name a file. Naming the card after the count
     // would assert a file that does not exist.
     return null
   }
+  // One card per file the patch touches: run together, the later files' rows
+  // and gutter numbers sit under the first file's name.
+  const split = unifiedPatchSections(moved.body)

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: f88944b9-d4ee-4b2d-aad9-9d1c5127d303

📥 Commits

Reviewing files that changed from the base of the PR and between 4f0e380 and db05643.

📒 Files selected for processing (21)
  • src/renderer/src/components/native-chat/NativeChatDiffCard.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/NativeChatMessageList.turn-history.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageRow.tsx
  • src/renderer/src/components/native-chat/NativeChatResolutionReceipt.test.tsx
  • src/renderer/src/components/native-chat/NativeChatResolutionReceipt.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx
  • src/renderer/src/components/native-chat/NativeChatToolRun.tsx
  • src/renderer/src/components/native-chat/NativeChatTurnDiffRollup.tsx
  • src/renderer/src/components/native-chat/native-chat-edit-cards.ts
  • src/renderer/src/components/native-chat/native-chat-resolution-receipt.ts
  • src/renderer/src/components/native-chat/native-chat-turn-diffs.test.ts
  • src/renderer/src/components/native-chat/native-chat-turn-diffs.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session.ts
  • src/renderer/src/i18n/locales/en.json
  • src/shared/native-chat-edit-normalize.ts
  • src/shared/native-chat-edit-patch-files.ts
  • src/shared/native-chat-unified-patch.ts
  • src/shared/structured-agent-session-projection.test.ts
  • src/shared/structured-agent-session-projection.ts
🚧 Files skipped from review as they are similar to previous changes (18)
  • src/renderer/src/components/native-chat/NativeChatMessageList.stream-render.perf.test.tsx
  • src/shared/native-chat-unified-patch.ts
  • src/renderer/src/components/native-chat/native-chat-resolution-receipt.ts
  • src/renderer/src/components/native-chat/NativeChatMessageList.tsx
  • src/renderer/src/components/native-chat/native-chat-edit-cards.ts
  • src/renderer/src/components/native-chat/native-chat-turn-diffs.test.ts
  • src/shared/native-chat-edit-normalize.ts
  • src/renderer/src/components/native-chat/NativeChatResolutionReceipt.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageRow.tsx
  • src/shared/structured-agent-session-projection.test.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/components/native-chat/NativeChatMessageList.turn-history.test.tsx
  • src/renderer/src/components/native-chat/NativeChatToolRun.tsx
  • src/shared/structured-agent-session-projection.ts
  • src/renderer/src/components/native-chat/NativeChatResolutionReceipt.test.tsx
  • src/renderer/src/components/native-chat/NativeChatDiffCard.tsx
  • src/renderer/src/components/native-chat/native-chat-turn-diffs.ts

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

@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 — an origin/main merge that integrates cleanly.

Reviewed changes

  • Merged origin/main — the single delta commit db0564351c folds recent main work (orchestration ownership, terminal contrast floor, activity-menu reorg, dependency bumps) onto the feature branch with no conflicts.
  • Adopted useStructuredAgentSessionMessages — the PR's useMemo message projection is replaced by main's new weak-keyed memoization hook, which keeps settled message and block identity stable across frames and so preserves the earlier rollup perf fix.
  • Reconciled NativeChatToolRun — main's Fragment import addition coexists with this PR's useEffect removal; the revealedDiff/onRevealDiff/buildEditCards wiring is unchanged.

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

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