Repository navigation
Summarize turn file changes and preserve resolved prompt receipts - #19229
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe 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 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)
✅ Passed checks (3 passed)
Full details: Description checkExplanation 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 CoverageExplanation 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.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
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
nativeChatTurnDiffscollapses a turn'sDiffitems 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 —
buildEditCardsmoves tonative-chat-edit-cards.tsand shares aWeakMapcache so the rollup and card consumers don't normalize the same tool pair twice. - Projection memoization —
useStructuredAgentSessionmemoizes the message projection and exposesjournalItems;NativeChatMessageListmemoizesreceipts/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/isCurrentTurnguard, 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.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| const [expanded, setExpanded] = useState(initiallyExpanded) | ||
| const cardRef = useRef<HTMLDivElement>(null) | ||
| useLayoutEffect(() => { | ||
| if (revealSignal && cardRef.current) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
ℹ️ No new issues in this delta — the prior performance concern is now addressed.
Reviewed changes
- Deferred turn-diff detail parsing —
buildDiffSummaries+summarizeUnifiedPatchnow read only lightweight counts from the journal's path-onlyDiffenvelope; full line models are built only when the tool run opens. - Stabilized projection identity —
projectStructuredItemToNativeChatmemoizes via aprojectedItemsWeakMap, and the reducer'smergeItemspreserves 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
Diffitems and asserts one summary scan and zero detailed parses across 20 journal updates. - Localized resolution times — new
NativeChatMessageTimestampreplaces 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
idrather than array index. - Reworked reveal/open sync —
NativeChatToolRunuses a render-phasecontrolssnapshot so arevealedDiffchange opens the run without clobbering the expand-override state.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Status: ready for reviewPlan reviewReviewed before any code was written. APPROVE WITH AMENDMENTS, all applied. Three were substantive:
Code review loopSame-model subagent review returned clean. Verification
Manual UI validationReal 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 Process deviations, stated plainly
Known-red, not caused by this PR
|
|
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. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 67be9a3b-206f-43e6-af4f-d63054f57a46
📒 Files selected for processing (21)
src/renderer/src/components/native-chat/NativeChatDiffCard.tsxsrc/renderer/src/components/native-chat/NativeChatMessageList.stream-render.perf.test.tsxsrc/renderer/src/components/native-chat/NativeChatMessageList.tsxsrc/renderer/src/components/native-chat/NativeChatMessageList.turn-history.test.tsxsrc/renderer/src/components/native-chat/NativeChatMessageRow.tsxsrc/renderer/src/components/native-chat/NativeChatResolutionReceipt.test.tsxsrc/renderer/src/components/native-chat/NativeChatResolutionReceipt.tsxsrc/renderer/src/components/native-chat/NativeChatStructuredSession.tsxsrc/renderer/src/components/native-chat/NativeChatToolRun.tsxsrc/renderer/src/components/native-chat/NativeChatTurnDiffRollup.tsxsrc/renderer/src/components/native-chat/native-chat-edit-cards.tssrc/renderer/src/components/native-chat/native-chat-resolution-receipt.tssrc/renderer/src/components/native-chat/native-chat-turn-diffs.test.tssrc/renderer/src/components/native-chat/native-chat-turn-diffs.tssrc/renderer/src/components/native-chat/use-structured-agent-session.tssrc/renderer/src/i18n/locales/en.jsonsrc/shared/native-chat-edit-normalize.tssrc/shared/native-chat-edit-patch-files.tssrc/shared/native-chat-unified-patch.tssrc/shared/structured-agent-session-projection.test.tssrc/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.
| 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 |
There was a problem hiding this comment.
🎯 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.
There was a problem hiding this comment.
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;mainnow owns an identical one, andNativeChatResolutionReceipt/NativeChatTranscriptChromeimport it unchanged. - Integrated tool annotations —
NativeChatToolRunthreadsonLinkClickand rendersNativeChatCommandMetadata/NativeChatSearchResults/mcpIdentity, coexisting cleanly with therevealedDiff/buildEditCardsrework.
⚠️ 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?DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Fresh rollup layout evidence for 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 Captured through Playwright CDP in this worktree’s hidden Orca Electron renderer, launched with Dark — collapsed, chevron at the right edge. Dark — expanded, explanation and file list nested below the header. Light — collapsed, same summary and trailing chevron. Light — expanded, 16px body padding and unchanged +4 total / +3 and +1 file counts. 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. |
There was a problem hiding this comment.
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 winHandle empty structured notices before the empty-row guard.
AgentJournalItemBodySchemaaccepts emptystatus.text, andprojectStructuredItemToNativeChatforwards it withpresentation: 'compaction'. For this message,NativeChatMessageRowreturnsnullbeforeNativeChatNoticeRowcan 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 winDo not drop sibling blocks from system messages.
AgentJournalItemBodySchemaallows multiple blocks, and legacy import preserves their metadata and order. If a system message contains a metadata-bearing text block and another block,MessageRowrenders 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
📒 Files selected for processing (4)
src/renderer/src/components/native-chat/NativeChatMessageRow.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/shared/structured-agent-session-projection.test.tssrc/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.
There was a problem hiding this comment.
ℹ️ No new issues in this delta — an
origin/mainmerge that integrates cleanly.
Reviewed changes
- Merged
origin/main— the single delta commitf2c20eeefolds in #19228 (compaction notices, plan documents, and images) and #19366 (mobilemax-linescleanup) onto the feature branch. - Integrated notice rendering alongside this PR —
NativeChatMessageRownow early-returns aNativeChatNoticeRowfor system text blocks carryingpresentation/tone, andstructured-agent-session-projectionpropagates those fields; both coexist intact with this PR'srevealedDiff/onRevealDiffwiring and itsturnDiff/receipti18n keys.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
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. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/shared/native-chat-edit-patch-files.ts (1)
54-60: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueMove the
FILE_COUNT_PATHguard above the section split.
unifiedPatchSections(moved.body)parses the whole patch at Line 54. The guard at Line 55 then discards that result and returnsnull. 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
📒 Files selected for processing (21)
src/renderer/src/components/native-chat/NativeChatDiffCard.tsxsrc/renderer/src/components/native-chat/NativeChatMessageList.stream-render.perf.test.tsxsrc/renderer/src/components/native-chat/NativeChatMessageList.tsxsrc/renderer/src/components/native-chat/NativeChatMessageList.turn-history.test.tsxsrc/renderer/src/components/native-chat/NativeChatMessageRow.tsxsrc/renderer/src/components/native-chat/NativeChatResolutionReceipt.test.tsxsrc/renderer/src/components/native-chat/NativeChatResolutionReceipt.tsxsrc/renderer/src/components/native-chat/NativeChatStructuredSession.tsxsrc/renderer/src/components/native-chat/NativeChatToolRun.tsxsrc/renderer/src/components/native-chat/NativeChatTurnDiffRollup.tsxsrc/renderer/src/components/native-chat/native-chat-edit-cards.tssrc/renderer/src/components/native-chat/native-chat-resolution-receipt.tssrc/renderer/src/components/native-chat/native-chat-turn-diffs.test.tssrc/renderer/src/components/native-chat/native-chat-turn-diffs.tssrc/renderer/src/components/native-chat/use-structured-agent-session.tssrc/renderer/src/i18n/locales/en.jsonsrc/shared/native-chat-edit-normalize.tssrc/shared/native-chat-edit-patch-files.tssrc/shared/native-chat-unified-patch.tssrc/shared/structured-agent-session-projection.test.tssrc/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.
There was a problem hiding this comment.
ℹ️ No new issues in this delta — an
origin/mainmerge that integrates cleanly.
Reviewed changes
- Merged
origin/main— the single delta commitdb0564351cfolds recent main work (orchestration ownership, terminal contrast floor, activity-menu reorg, dependency bumps) onto the feature branch with no conflicts. - Adopted
useStructuredAgentSessionMessages— the PR'suseMemomessage 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'sFragmentimport addition coexists with this PR'suseEffectremoval; therevealedDiff/onRevealDiff/buildEditCardswiring is unchanged.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏




















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
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
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.
Refreshed hidden Electron validation is owned by the coordinator's separate QA lane.
Testing
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