Repository navigation
fix(dashboard): bound the large-file window diff and never invent a failed write's diff - #20441
Conversation
UX Review (Opus 5.5) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS The same "File only" tag now means both "this write failed" and "this file was too big", so only the red colour and the icon tell them apart. Watch
Suggestions
[UX-REVIEWED] af4aa79 Description read[DESCRIPTION-READ] 2a722202be54e4c1d0fff784374e7a8d72daada41a71bc31ba9b73e340f5a146 That sha256 names everything this verdict read: the PR description, plus the 6 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that a successful write after a failed one should replace the failed call's entry: the card then shows only the later diff and hides any torn bytes from the failed write. [DESIGN-REVIEWED] af4aa79 Description read[DESCRIPTION-READ] edeadb6bdf254060eb8972185b67d13582fbec3c0ee224c490258085ea04d919 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS Re-reading the file on a failed Not justified as shipped
What this change shipsInventory (9 items) — 7 justifiedIntent: the file-change card should finish fast on large files, never show an edit that didn't happen, and never lose a one-file turn's diff. FIX.
[FIRST-PRINCIPLES-REVIEWED] af4aa79 Description read[DESCRIPTION-READ] 73f73d194efeb7ba735bd22cfc024ab65843f8944c3ab2bca45e6af092e3c4b2 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
6ee2fec to
00e225b
Compare
|
self-added: yes
|
|
self-added: yes
|
00e225b to
7085ff9
Compare
|
self-added: yes
|
|
self-added: yes
|
7085ff9 to
db1d12e
Compare
fc3e85f to
b806238
Compare
|
self-added: yes
|
|
self-added: yes
|
|
self-added: yes
|
|
|
|
/ai-review override first-principles 9a3f0eb: agent: false positive, the runner's import difflib is read by owner functions through chat_turn.compose (which binds no module objects), and deleting it makes _excerpt_pair raise NameError (7 TestExcerptDiffWork failures on a clean archive of this head; rebuttals issuecomment-6203869120 and issuecomment-6203869904). |
Human judgment recorded@iamwhatever marked the first-principles AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
9a3f0eb to
a4ee966
Compare
a4ee966 to
29c7973
Compare
|
self-added: yes
|
|
self-added: yes
|
cruisercohen
left a comment
There was a problem hiding this comment.
Requesting one change on 29c7973.
Both changes since a4ee966 check out. The refinement re-mark now skips a collapsed id, and an entry without pre_call_digest is marked unverified_write before the off-loop settlement read. But an earlier await in the same result branch still runs before that marking, and it reopens the invented-diff case from #20419.
Blocking: a cancel during the repeat-loop steer persists an invented hunk. In chat_runner.py, await _steer_repeat_loop_notice(...) at line 11276 runs before the failed/refused block at lines 11319-11332. The third identical failed result sends that notice, which waits up to STEER_NOTICE_BOUND_SECS (5 s) on a backend that supports refusal steers. If the turn is cancelled during that wait, the _failed_write_calls entry and the unverified_write mark are both skipped, and the teardown flush stores the reverse substitution as the before. GPT 6.1's finding on this head is correct.
I reproduced it locally on this head with the turn harness. The setup: three identical strReplace calls (value = 1 to value = 2) against a file that already holds value = 2, each with a failed result, and a provider whose steer raises CancelledError. The persisted entry has before head\nvalue = 1\ntail\n, after head\nvalue = 2\ntail\n and no omitted_reason, while the file never changed. Without the cancel, the same three calls store the path-only unverified_write entry.
Fix: move the two _loop_notice lines below the failed-write block. Alternatively, run the synchronous _failed_write_calls.add and the unverified_write marking before any await in this branch, and keep the digest-backed settlement off the loop. Moving the steer below the block turned the probe green locally, and all 21 TestFailedWriteRecordsNoChange tests still pass. A test like the probe (a steer that raises CancelledError on the third repeat) would pin it.
…ailed write's diff
29c7973 to
af4aa79
Compare
|
self-added: yes
|
|
|
|
|
|
|
|
|
@cruisercohen, on your review of
|
|
Rebased onto main ( Conflicts resolved:
Fixes (each with a turn-loop test and a spec clause):
Rebase audit: main added no locale catalog, no new reader of Interdiff: force-push compare. That view also shows main's commits, so the patch-only range-diff is below.
|
cruisercohen
left a comment
There was a problem hiding this comment.
Approving af4aa79. The blocking point from my review on 29c7973 is met.
- A
failedorrefusedresult now marks the call's own entriesunverified_writesynchronously, right after_tool_terminaland before the result branch's first await. Only_settle_failed_write's completed content read changes that: an unchanged file removes the entry, and a changed one clears the mark so the real diff shows. test_cancelled_failed_write_keeps_unproven_paths_onlycovers a cancel at each await between the result and the flush, the repeat-loop steer included.- Locally on this head, my probe from the last review (three identical failed
strReplacecalls, with a steer that raisesCancelledError) now stores the path-only entry, andTestFailedWriteRecordsNoChangepasses. A failedcreatethat changed the file before failing still shows its real before and after.
Every check on this head passes, and GPT 6.1 has no blocking findings.
Non-blocking: a failed create of a new file that never reached disk reads back as gone, so it stays path-only with the "earlier file is unknown" notice. Its earlier state was known (no file), so "no change" would be accurate there. Path-only claims nothing false, so I would not hold the PR on it.
Problem / Motivation
Goal: Storing a small change in a large file finishes quickly, a failed write never shows a change, and a one-file turn never loses its only diff to the 400K turn notice.
Three faults remain on main after #19977 in the dashboard file-change card:
-old/+newhunk.Why it matters
The window diff runs before the turn saves, so a slow diff delays every turn that edits a log, CSV or fixture file. A card that shows an edit that never ran, or hides the one edit that did, misleads the person reviewing the agent's work.
Not a goal
oldStr-inside-newStrstrReplace (still keeps the top cut; a pre-write snapshot would lift it).unverified_write, is added.What changed (motivation → approach → change)
SequenceMatcherran over both whole sides; on repeated rows its match walk is lines times repeats_EXCERPT_DIFF_BUDGET(about half a second); sides whose lengths differ by more than_MAX_SNAPSHOTare not diffedfailedcan also follow bytes that reached diskfailedorrefusedcall recorded alone isunverified_writefrom its result on, set before any await. With a whole pre-call snapshot (create's content block) the file is re-read off the loop: equal, no entry; different, the mark is cleared and the real diff shows. Otherwise, or when that read is cancelled or fails, the write keeps only the path asomitted_reason: "unverified_write"(neither word proves the file was left alone): no hunk, no "no changes", no WakaTime linesThe card states the new reason once, through the shared error surface (
ErrorNotice, with the agent hand-off): "Diff unavailable: the write failed, and the file before it is unknown." It sits beside the turn-budget sentence when both apply, and the failed row's own File only tag takes the same red and warning icon, so the notice points at its file. The keydiff_unavailable_unverified_writeis in every catalog underwebsite/src/i18n/locales/(theen-XApseudolocale regenerated).Measured, one
_excerpt_paircall:The spec (
learn-cron-dashboard.md) states the bound, the failed-write rule and the protection rule.Backwards compatibility
Compatible:
omitted_reason: "unverified_write"is a new value on the existing path-only shape (content_omitted); an older dashboard reads it as a path-only row with the turn-budget sentence, and old transcripts carry no such value.Reader: src/kiro_crew/dashboard/chat_turn/file_changes.py:_flush_file_changes -- chat -- a call's entry is gone before the flush only when content proves the call changed nothing (test_a_failed_create_is_judged_by_its_content_block, test_a_refused_reissue_shows_no_invented_hunk)
Reader: src/kiro_crew/dashboard/chat_turn/file_changes.py:_turn_after_reads -- chat -- reads the same list at turn end; a dropped entry is never read (test_a_retry_after_a_proven_no_change_failure_keeps_its_own_before)
Reader: src/kiro_crew/dashboard/chat_turn/file_changes.py:_turn_line_changes (WakaTime) -- chat -- counts no lines for a dropped or unverified entry (test_a_failed_write_counts_no_lines)
Reader: src/kiro_crew/dashboard/slot_persistence/transcript_merge.py:_without_file_change_copies -- chat -- rewrites only entries that still hold a copy, so an unverified entry keeps its reason
Reader: website/src/components/FileChangeChips.tsx:noticeEntries -- chat -- one sentence per reason (FileChangeChips.unverifiedWrite.test.tsx, FileChangeChips.olderTurn.test.tsx)
Tests
TestExcerptDiffWork: countsfind_longest_matchline visits (no wall clock). A small edit, insert, delete or append in 1.3 MB of repeated rows visits under 10,000 lines (main: over 50 M, stopped); 1-in-50 spread edits stop at the budget; two far edits in distinct lines still window; a length gap past the cap skips the diff; an over-budget edit keeps the top cut and stays protected.TestOneFileTurnKeepsItsEntry: equal top cuts on a truncated entry are protected; an inline (cancel/error) flush and a file past the whole-read bound keep their entry with no turn notice.TestFailedWriteRecordsNoChange: failed create, no bytes changed: no entry; failed create, torn bytes: the actual before/after; failed strReplace with a fragment or reverse-substitution before, a torn read, or a later disk change: path only asunverified_write, no hunk; refused re-issue: path only, no hunk; an unverified write never takes the protected slot and counts no lines; a completed edit keeps its diff; a refusal on a path another call wrote, or under a collapsed call id, drops nothing; a snapshot a failed or refused call records after its result (the refinement that can follow it in one frame, whether or not the call's first event carried rawInput) still keeps only the path, while a different call's later write shows its own diff; a call id that collapsed onto another call's leaves that call's diff alone; a cancel at each await between a failed result and the flush (the repeat-loop steer, the settlement read, the MCP app render, the PostToolUse hook, the compaction notice, the next stream event, the turn-end reads) stores only path-onlyunverified_writeentries, never a hunk.FileChangeChips.unverifiedWrite.test.tsx: the dedicated sentence on the card, the row tag and the pill row; beside the turn-budget sentence as two reasons; never "too large" or "No changes".-n0, 10 at-n 4 --dist loadgroupbeside two sibling files, one shuffled order (seed 176); the post-result refinement test (4 cases) 20 runs at-n0, 10 at-n 4beside two sibling files, and the whole file shuffled (seed 8823); the collapsed-id test and the 7-point cancel test (8 cases) the same, and the whole file shuffled (seed 4242); frontend files 10 shuffled runs; all green.Manual verification
The card rendered from the built SPA with an
unverified_writerow beside a normal diff row (screenshot below).Screenshots / video
Two notices, each said once: a failed write beside a turn-budget row; the open hint ends only the last.
The minimal pill style: the filename, the File only marker and the sentence once under the pills.
Committed rather than attached: the local
gh(2.96) has no--attach.Related Issues
Closes #20419
Pattern harvest
Rule candidate: review-prompt
Pattern: an unbounded
difflib.SequenceMatcherover whole files on a request path; trim shared ends and bound the work.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)