Skip to content

fix(dashboard): preserve previous reply when regenerate ends empty - #23769

Merged
iamwhatever merged 1 commit into
mainfrom
fix/14632-regenerate-preserve-reply-samerepo
Oct 29, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/14632-regenerate-preserve-reply-samerepo

Conversation

@RohanK6

@RohanK6 RohanK6 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #14632
Fixes #24039

Problem / Motivation

Goal: A Regenerate that produces no new reply leaves the previous reply in place instead of destroying it.

Bug fix: pressing Regenerate and then having the new turn end before it produces any content permanently deletes the previous assistant reply. The old reply the user was trying to improve on is gone from the transcript and from disk, with no way to recover it. One concrete trigger is a Regenerate pressed while gateway memory preparation is still running (the turn is refused before it produces a reply), but any early exit from the turn before its first message hits the same path.

Why it matters

This is silent, user-visible data loss on a common action. A user reaches for Regenerate because they value the current answer and want a variation; the failure mode throws that answer away exactly when the retry fails to replace it. There is no undo and no copy left anywhere, so the content cannot be recovered.

Not a goal

  • Not changing normal Regenerate behavior: once the new reply exists it still replaces the old one, which is retained as a variant.
  • Not adding a new recovery UI, undo affordance, or variant-management surface.
  • Not touching the streaming hot path or introducing a parallel persistence mechanism.

What changed (motivation → approach → change)

Replaces #15417.

Symptom. A Regenerate turn ending with no reply (refused, stopped, failed) lost the old reply from screen and disk.

Cause. The endpoint deleted the old reply before the new turn ran.

Change. Nothing is deleted before a new reply exists.

regenerate endpoint: keep the old reply; arm a RegenerateTarget
                     (old rows + transcript key + slot name + turn generation);
                     dispatch the turn. No write.
turn runs as usual; each reply row it writes is recorded on the target
turn end (_end_turn_tail, before the queue hands off):
  ├─ a reply was recorded → one pinned rewrite: old rows out, old reply kept as a variant
  └─ no reply             → drop the target; old reply untouched
  • chat_turn/regenerate_swap.py (new owner): RegenerateTarget, settle_regenerate, note_regenerate_reply, rows_before_regenerate_target. chat_runner re-exports RegenerateTarget for chat_regenerate.py.
  • chat_regenerate.py: the up-front del, truncating save and 409 are gone; the endpoint arms the target and passes the request row (_current_message). release_regenerate_on_done drops a target no turn end settled.
  • queue_cycle._end_turn_tail: calls settle_regenerate before _hand_off_queue in whichever frame runs the tail (/prompts get re-entry included), so a queued successor never sees the target.
  • file_changes._note_reply_row (model segments, partial replies) segment_flush._append_command_reply and the slash gate's direct answers (slash_commands) record the reply on the target.
  • save_transaction (forwards expected_disk_older_count) / slot_persistence/transcript_merge.py: retired_rows names the rows a rewrite removes; any other window-region line the snapshot lacks is kept, and the cached fast path drops a kept line once the window carries it (_drop_carried_foreign).
  • slot_persistence/write_guards.py, save_transaction: a swap-won guard. The committed swap bumps a slot epoch inside the transcript lock (publish_swap). A save whose window copy predates it, or falls before memory applies it, re-takes it under the lock with the pre-copy swap record applied; a caller's own snapshot is refused.
  • turn_admission._turn_admit: the crew-log ordinal counts rows_before_regenerate_target, so a regenerate stays a retry (turn_dispatch_gates.py).
  • state_parts/chat_slot.py, slot_turns.py, slot_transcript.py: the slot carries _regenerate_target; the front trim waits during a swap (_swap_in_flight).
  • stream_chunks, segment_flush, turn_reply_seams: a notice-only row (Compacting...) gets no variants, the continuation takes the target (Regenerate replaces the previous answer when its only output is a control notice #24039), and both save seams tag it a notice so the next Regenerate skips it.
  • turn_ledgers._queue_recovery, queue_drain: a recovery queued before any reply takes the target; the replay turn re-arms it.
  • prompt_assembly, context.py, context_assembly/replay.py: a cold-start replay and the interrupted-turn preamble leave out the reply being replaced (regenerate_replaced_rows).
  • docs/system-specs/modules/history.md, learn-cron-dashboard.md: document all of the above.
  • turnActions.ts / ChatPage.tsx: the optimistic truncateAfterIndex and its rollback are removed, and with them the hook's dispatch option. The settle step's chat_variant_switch names the retired rows; useWebSocket.ts drops them (retireSwappedRows) before refetching, so the refresh cannot re-seat a retired permission or elicitation card.
  • turnActions.ts / transcriptRendering.tsx: on press, the hook records the ids of the rows after the regenerated user row (replacingMids), as the server arms them. They render dimmed under "Previous version. Kept if no new reply arrives. Stopping now keeps it."; once the "New version" starts below, it reads "Previous version. New reply started: this one moves to the version arrows. Stopping keeps both." Strings: every catalog in website/src/i18n/locales/.

The replace write is pinned (expected_history_key, expected_slot_name, _disk_older_count, best_effort=False). A rebind, a recreate, or a previous reply partly trimmed into the frozen prefix refuses it, and both replies stay.

Tests from #23388 change. They expected Regenerate to remove the old reply on press. It now stays until the new one lands, so five assert that and the rows marked for replacement: three in test/test_regenerate_taken_back_steer.py, two in website/src/test/transcriptRowCallbacksStable.test.tsx.

Invariants

The swap contract, checked over boundary inputs: the window cap +/-1, a concurrent and a cancelled Regenerate, and a reload mid-swap. They are in test/test_regenerate_invariants.py.

# Invariant Inputs covered Tests
I1 At the window cap, no retired row is credited to the frozen prefix, and each row reaches disk once. window at cap -1/0/+1 x 0/1/2 rows landing during the replace write test_i1_no_retired_row_is_credited_at_the_window_cap (9 cases)
I2 A Regenerate during an in-flight swap is refused as busy (409); one after it works on the swapped reply. concurrent Regenerate, real endpoint and runner test_i2_a_regenerate_during_the_swap_is_refused_and_after_it_works
I3 A Regenerate with no reply leaves the previous reply and its versions as they were; a reload mid-swap reads one whole transcript; a reply that is only a backend control notice is no reply. cancelled turn, write failing before commit, gateway gone after commit, a Compacting...-only turn that ends normally, dies or is stopped, then regenerated again test_i3_a_cancelled_regenerate_leaves_the_reply_and_its_versions, test_i3_reload_mid_swap_reads_one_whole_transcript, test_a_regenerate_after_a_notice_only_one_re_runs_the_kept_reply

The version cap and dedupe stay as on main (_cap_keeping_shown, content-only dedupe).

Why a plain swap

At turn end the dimmed previous version and the new reply collapse into one reply carrying the version switcher, with no exit animation or closing notice. That reads as a move, not a loss:

  • The label says what a Stop leaves behind: "Previous version. Kept if no new reply arrives. Stopping now keeps it." until new text arrives, then "Previous version. New reply started: this one moves to the version arrows. Stopping keeps both." One term, "version", is used throughout, the word the switcher uses.
  • The switcher appears in the same spot the moment the swap lands, showing 2/2, with the previous version one step back (the settled screenshot below).
  • Nothing is lost: the previous version is on disk and one click away, and a turn that ends empty keeps it as the reply.

A closing notice or an animation into the switcher would be new version-management UI, which the Goal rules out: "Not adding a new recovery UI, undo affordance, or variant-management surface." An earlier head added a "kept as version N of M" notice, and First Principles blocked it on that line, so it was removed.

Backwards compatibility

Compatible: a Regenerate that produces a reply ends with the same window and variants as before; an empty turn keeps the reply.

Visible during a Regenerate: the previous reply stays on screen, dimmed under "Previous version. Kept if no new reply arrives. Stopping now keeps it.", which turns into "Previous version. New reply started: this one moves to the version arrows. Stopping keeps both." once the new reply appears below it under "New version" until the turn ends. Then the two collapse into one reply with the version switcher, the previous version one step back in it (see "Why a plain swap"). A refused press drops the label at once, and a turn that ends empty drops it when the turn ends; the old reply is then the answer again, unmarked.

Accepted outcome: if the gateway stops mid-turn after the turn's own save, the transcript keeps user, old, new with no variant link. Nothing is lost, and both rows render as ordinary assistant rows.

Reader: website/src/pages/chat/page/turnActions.ts:handleRegenerate -- chat -- the 409 regenerate_save_refused code had no reader (git grep on origin/main finds only the endpoint and its test); other refusals still reach showRefusedPress.
Reader: src/kiro_crew/dashboard/chat_turn/segment_flush.py:_flush_segment -- chat -- outside a Regenerate turn it still adopts _pending_variants on the first segment (test_pending_variants_are_attached_and_broadcast); during one it leaves them for the committed swap (test_a_declined_write_after_a_real_flush_saves_no_variants, test_a_reply_trimmed_into_the_prefix_after_a_real_flush_saves_no_variants).

Tests

Proof: PROVEN test_regenerate_swap.py::test_a_refused_regenerate_turn_keeps_the_previous_reply, test_regenerate_swap.py::test_a_stale_window_save_after_the_swap_does_not_restore_the_old_reply, test_regenerate_swap.py::test_a_window_copied_before_a_long_swap_is_retaken_under_the_lock, test_regenerate_swap.py::test_a_callers_snapshot_from_before_a_swap_is_refused, test_regenerate_swap.py::test_a_swap_that_finishes_during_the_retake_still_corrects_it, test_regenerate_swap.py::test_a_previous_reply_partly_trimmed_into_the_prefix_is_kept, test_regenerate_swap.py::test_appends_at_the_cap_during_the_swap_do_not_credit_retired_rows, test_regenerate_swap.py::test_the_swap_frame_names_the_rows_it_retired, test_regenerate_swap.py::test_a_notice_only_regenerate_through_the_runner_waits_for_the_continuation, test_regenerate_swap.py::test_a_notice_only_reply_that_dies_keeps_the_previous_reply, test_regenerate_swap.py::test_a_notice_only_regenerate_stopped_mid_compaction_saves_a_notice_row, test_dashboard_chat_regenerate.py::TestRegenerateAndVariants::test_a_regenerate_after_a_notice_only_one_re_runs_the_kept_reply, test_regenerate_swap.py::test_a_cold_start_regenerate_replays_history_without_the_reply_it_replaces, test_regenerate_swap.py::test_a_row_kept_as_foreign_is_written_once_when_the_window_carries_it, test_regenerate_swap.py::test_a_recovery_replay_of_the_regenerate_settles_the_previous_reply, test_regenerate_swap.py::test_regenerating_a_command_answered_directly_replaces_its_reply, test_regenerate_swap.py::test_regenerating_a_prompt_get_settles_in_its_nested_turn, test_dashboard_chat_regenerate.py::TestRegenerateAndVariants::test_regenerate_empty_turn_keeps_the_previous_reply, test_dashboard_chat_regenerate.py::TestRegenerateAndVariants::test_regenerate_replaces_the_reply_once_a_new_one_exists (head 0510fc5)

prove.py over all hunks was inconclusive (reverting every hunk deletes regenerate_swap.py, so the new test file fails at collection). The line above is from reverting only chat_regenerate.py to origin/main and re-running those tests: all three fail ([] == ['old'], ['hi'] == ['hi', 'old'], KeyError: 'variants').

File What it pins
test/test_regenerate_swap.py (new) empty, refused and stopped turns keep the reply; a reply swaps once; rows written during the swap survive; stale saves and old snapshots cannot restore the old reply; the window cap; notice-only rows; recovery replays; slash-command replies; the swap frame names retired rows
test/test_regenerate_invariants.py (new) the swap contract over boundary inputs: window cap, a Regenerate during a swap, an empty end
test/test_dashboard_chat_regenerate.py empty turn keeps the reply; a new reply replaces it
test/test_chat_regenerate_cov80.py, test/test_regenerate_taken_back_steer.py the endpoint writes nothing and arms a pinned target, past a taken-back steer too
website/src/test/ChatPageMoreCoverage.test.tsx, transcriptRowCallbacksStable.test.tsx, chatSlice.retireSwappedRows.test.ts the reply stays on screen, the two labels, a refused or empty turn drops the label, rows marked for replacement, retired rows dropped before refetch

The rest follow the new owner: test_slot_ownership_checkpoint_post_await.py, test_no_config_dir_in_async.py, test_state_parts_facade.py, test_redaction_blocked_links.py, test_chat_runner_base_surface.py, the two composition-contract tests, chatSlice.publicSurface.test.ts, ChatPage.transcriptRendering.test.tsx.

On this head: the regenerate, slot, redaction and composition suites, 1366 passed; flake-pattern ratchet 64 passed; Vitest over the related frontend set, 12087 passed; tsc, eslint, i18n:check, i18n:render, mypy, flake8, isort, black, docs-lint, semgrep clean. Determinism: the regenerate test files passed 3 repeats; the label Vitest suites passed 3 shuffled runs. The capture harness asserts every state before each screenshot.

Manual verification

Rendered the real ChatPage in a browser through the capture entry website/capture/regenerate-preserve-reply.html, driven by website/scripts/capture-14632-regenerate-preserve-reply.mjs (scripted Playwright, its own loopback vite server). The script presses the real Regenerate button, then plays the server's side through the store paths the live socket uses: chunk frames for the new reply, setSlotRunning for the turn's start and end, and the refreshSlot refetch that chat_variant_switch triggers. Before each frame it asserts the state: in flight, the old reply is marked and the new one streams below it; at turn end the mark is gone, the old reply is folded into the variants and the switcher is visible; after an empty turn the old reply is kept, unmarked, with no switcher. All 33 checks pass on this head, including both previous-version labels and the "New version" label in flight. The empty-turn checks are what found the 30 s label linger fixed here.

Screenshots / video

Just pressed, nothing new yet: the old reply is dimmed under "Previous version. Kept if no new reply arrives. Stopping now keeps it."

regenerate pressed, nothing new yet, dark

In flight: the previous version stays on screen, dimmed under "Previous version. New reply started: this one moves to the version arrows. Stopping keeps both.", and the new reply streams in below it under "New version".

regenerate in flight, dark

Turn end: the two collapse into one reply. The previous reply is one step back in the switcher (2/2).

regenerate settled into the variant switcher, dark

Empty turn: the new turn produced nothing, so the old reply is kept as the answer, unmarked and with no switcher. This is the #14632 outcome; before this fix the reply was gone.

regenerate that came back empty keeps the reply, dark

A full Regenerate, from the press to the turn-end collapse (recording, WebM):

regenerate.webm

Light theme

regenerate pressed, nothing new yet, light

regenerate in flight, light

regenerate settled, light

regenerate empty turn, light

## Related Issues

Fixes #14632
Fixes #24039

Supersedes #15417.

Sibling sweep

Swept: git grep -nE "del slot.messages[" -- src/ and git grep -n "truncateAfterIndex" -- website/src
Sibling: website/src/pages/chat/page/messageActions.ts:109 -- not affected -- edit-resend replaces the user's own prompt, so the reply it drops answers a prompt the user rewrote
Sibling: src/kiro_crew/dashboard/chat_turn/regenerate_swap.py:162 -- changed here

Pattern harvest

Rule candidate: review-prompt
Pattern: a replace operation deletes or truncates live state before its replacement exists.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 71fe3ffe437d826fc75211bc22de782154cf3b24 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing to check.

What this change ships

Inventory (10 items) — 10 justified

Intent: a user who presses Regenerate and gets no new reply keeps the reply they already had. This is a FIX (#14632, #24039).

  1. A Regenerate that ends empty (refused, stopped, failed) keeps the previous reply on screen and on disk — justified
  2. Pressing Regenerate no longer returns 409 regenerate_save_refused; a refused replace keeps both replies instead — justified
  3. While a Regenerate runs, the previous reply stays on screen dimmed, labelled "Previous version…", and a "New version" divider sits above the new reply — justified
  4. A committed swap names the rows it retired, and the client drops them before it refetches — justified
  5. The history the model is given during a Regenerate leaves out the reply being replaced — justified
  6. The crew log still records a Regenerate as a retry of the same turn — justified
  7. A reply that is only a Compacting... notice does not count as the new reply and is tagged as a notice — justified
  8. A recovery replay queued by the Regenerate turn takes over the replace step — justified
  9. A save that copied the window before the swap committed re-takes it, and the replace write keeps rows another writer appended — justified
  10. The window's front trim waits while a swap is in flight — justified

[FIRST-PRINCIPLES-REVIEWED] 71fe3ff

Description read

[DESCRIPTION-READ] 4c71dcd2021df47e5d0268781b57ad2b0f4769103cca918d198d20d497954f4a

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 71fe3ffe437d826fc75211bc22de782154cf3b24 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the fix removes the cause, an irreversible delete made before the new reply existed. Rendered evidence for this revision is committed (8 images, 1 recording).

Notes

  • The fix had to touch the persistence layer: a slot epoch, a swap-won save guard, and retired_rows passed through transcript_merge. That makes the general save path more complex for every turn, not just Regenerate. The simpler-looking alternative (cut on press, put the old rows back if the turn ends empty) still loses the reply if the process dies mid-turn, so this design is the right one. The concurrency risk sits in save_transaction/write_guards, so line-level review should look hardest there.
  • The ## Backwards compatibility section falls past the description's truncation point, so I could not check it against the code. The one reply-path removal I found is the regenerate_save_refused 409. Nothing in the tree reads it, and the truncateAfterIndex reducer still exists for messageActions.ts.

[DESIGN-REVIEWED] 71fe3ff

Description read

[DESCRIPTION-READ] fbf55937dc532d1cb1fad7c9a68170a6b015e7f231df2fc0941f838b68c617e1

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 71fe3ffe437d826fc75211bc22de782154cf3b24 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing blocks. The blind reader read both notes and the "New version" divider correctly, and said they would dare to press Stop. The swap at turn end is explained in the PR and shown in regenerate.webm.

Notes

  • regenerate_previous_reply "Kept if no new reply arrives" made the blind reader wonder whether the old answer is "deleted if a new reply does arrive". Suggested replacement: "Previous version. Stopping before a new reply keeps it."
  • regenerate_previous_reply_kept_as_version refers to "the version arrows", which are not on screen yet. The reader said: "I don't know what 'the version arrows' are, because I can't see any arrows on this screen." Suggested replacement: "Previous version. Once the new reply finishes, switch back with ‹ 2/2 ›. Stopping keeps both."

[UX-REVIEWED] 71fe3ff

Description read

[DESCRIPTION-READ] b8160a3133a1684a82decaea903048b36a8e3168e5f84c42ffa6f42dce0d90e2

That sha256 names everything this verdict read: the PR description, plus the 11 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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 71fe3ffe437d826fc75211bc22de782154cf3b24 — this comment is updated in place on each push.

Review details

No findings. None of the five candidates holds up against the code at this commit.

[OPUS-REVIEWED] 71fe3ff

Verdict parsed from the review's SHA-scoped output markers for commit 71fe3ffe437d826fc75211bc22de782154cf3b24.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 71fe3ffe437d826fc75211bc22de782154cf3b24 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 71fe3ffe437d826fc75211bc22de782154cf3b24 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 71fe3ff

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 71fe3ffe437d826fc75211bc22de782154cf3b24 false-positive: <reason, 20 to 500 characters>

@RohanK6 RohanK6 closed this Oct 24, 2026
@RohanK6 RohanK6 reopened this Oct 24, 2026
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 24, 2026
@RohanK6
RohanK6 force-pushed the fix/14632-regenerate-preserve-reply-samerepo branch from 40d3a79 to fbbb5db Compare October 24, 2026 22:35
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 24, 2026
@RohanK6
RohanK6 force-pushed the fix/14632-regenerate-preserve-reply-samerepo branch 6 times, most recently from 9907e40 to fc5fbe0 Compare October 25, 2026 02:42
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 25, 2026
@RohanK6 RohanK6 closed this Oct 25, 2026
@RohanK6 RohanK6 reopened this Oct 25, 2026
@RohanK6
RohanK6 force-pushed the fix/14632-regenerate-preserve-reply-samerepo branch from fc5fbe0 to 2eadca7 Compare October 25, 2026 03:14
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 25, 2026
@RohanK6
RohanK6 force-pushed the fix/14632-regenerate-preserve-reply-samerepo branch 2 times, most recently from 9624460 to dc68556 Compare October 25, 2026 04:30
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 27, 2026
@RohanK6
RohanK6 force-pushed the fix/14632-regenerate-preserve-reply-samerepo branch from 266a378 to b386733 Compare October 27, 2026 07:36
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 27, 2026
@RohanK6
RohanK6 force-pushed the fix/14632-regenerate-preserve-reply-samerepo branch from b386733 to 8391d64 Compare October 27, 2026 20:36
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Oct 27, 2026
@RohanK6

RohanK6 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/dashboard/state_parts/chat_slot.py, docs/system-specs/modules/history.md, docs/system-specs/modules/learn-cron-dashboard.md and website/src/i18n/locales/*.json since this head went green (c55d16f -> 2afa15f); CI re-running.

@RohanK6

RohanK6 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author
  • span=b03dc3886093 Previous reply vanishes, "2/2" appears elsewhere

fixed in 54ace4f: the in-flight label now names where the previous reply goes, the fix this finding offered as its second option: "Previous version. Stays here if you stop or no new reply comes. Otherwise it moves to the ‹ › switcher." (all 14 catalogs).
The animation option stays out: the Goal rules out new variant-management surface, and First Principles blocked an added swap notice on that line.
Screenshots and the recording are re-captured with the new label.

@RohanK6

RohanK6 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author
  • span=11e1cff7d095 The copy says nothing about Stop, the PR's main case

fixed in 54ace4f: the label covers both outcomes, as the finding asked: "Previous version. Stays here if you stop or no new reply comes. Otherwise it moves to the ‹ › switcher."
A user can now read, before pressing Stop, that stopping keeps the old answer.

@RohanK6

RohanK6 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=b512bc657c01 The "Previous version" label promised Stop keeps the old answer

fixed in e72e615: the label now promises only what every path does, the wording fix this finding offered: "Previous version. Kept as the answer if no new text arrives; otherwise moved to the ‹ › switcher." (all catalogs).
A Stop before any text keeps the old reply; a Stop after text keeps the partial, which is "new text arrived", so the label holds in both cases.

@RohanK6

RohanK6 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author
  • span=3e2b3e3ba2ef In-flight history reads can undo row retirement

Rebutted: disproportionate remedy, as Opus adjudication ruled on this head. The race needs a reconnect refetch still in flight when chat_variant_switch arrives, and landing before the swap's own refetch.
Its outcome is display-only: decided permission or elicitation cards drawn again beside the new reply. Disk, variants and decisions are untouched; a reload reads the swapped transcript.
The fix is a new per-slot retirement fence across three fulfillment reducers (slotRefresh refreshSlot and warmSlotCache, slotSwitch switchSlot): new state and an ordering contract for one rare race, beyond this PR's Goal.

@RohanK6

RohanK6 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author
  • span=236590924119 The old reply is hard-swapped out when the new reply settles

Rebutted: the motion is left out on purpose, and the PR description says why, the clear-condition this finding names. See "## Why a plain swap": an animation into the switcher is version-management UI the frozen Goal rules out ("Not adding a new recovery UI, undo affordance, or variant-management surface").
The label the user reads for the whole turn names where the reply goes before it moves: "otherwise moved to the ‹ › switcher", and the switcher shows 2/2 the moment the swap lands.
This is the class of span=cb21ceec3d31 (rebutted on c2beb12) and span=b03dc3886093 (fixed in copy on 805bf6d); a motion change stays a human decision on the Goal.

@RohanK6

RohanK6 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author
  • span=911e4ea04614 The note hedges about something the code already knows

fixed in bdf98d8: the note now changes when new text starts, the fix this finding gave. Before: "Previous version. Kept if Regenerate produces nothing." After: "Previous version. Stays available in the version arrows under the new reply." (every catalog).
transcriptRendering.tsx computes newReplyStarted from the transcript; ChatPageMoreCoverage pins the flip, and the capture harness asserts both strings.

@RohanK6

RohanK6 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author
  • span=92f0eedc0511 The old reply disappears instead of visibly becoming version 1

Rebutted: the motion is left out on purpose, and "## Why a plain swap" in the description gives the reason: an animation or a saved-as notice into the switcher is version-management UI the frozen Goal rules out, and First Principles blocked such a notice on an earlier head.
The label now tells the user, before the swap, where the reply goes: "Stays available in the version arrows under the new reply."
Same class as span=236590924119, span=b03dc3886093 and span=cb21ceec3d31. Adding motion is a change to the Goal, which only a person can make.

@iamwhatever

Copy link
Copy Markdown
Contributor

Holding for human review.

This PR changes what the regenerate path deletes from persisted chat history. The up-front delete is removed, and a deferred rewrite removes retired_rows from the on-disk transcript at turn end (transcript_merge.py#L777-L830), with a new swap-won save guard (write_guards.py#L483-L512). Data-deleting paths are reserved for a maintainer. I found no definite defect in the hunks I read, and CI plus the GPT and Opus lanes are green.

Also open on this head:

  • UX notes have no reply: 'Previous version' is also the accessible name of the version-switch button, the armed-state label has no screenshot, and the settled switcher is hard to see.
  • The author asks a human to rule on the UX-vs-Goal conflict (animating the old reply into the switcher).
  • Edit-resend still truncates and persists before its turn (chat_regenerate.py#L428). That deferral needs a linked issue.

To clear: a maintainer review of the persistence change and the UX ruling, replies to the UX notes, and an issue for edit-resend.

Reviewed head: bdf98d8ef80f5c9f0ff3901dd86289714951e831.

— crew-pr-reviewer (r131)

@RohanK6

RohanK6 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author
  • span=46ad2f230dd2 A cold-start Regenerate can replay the question it re-asks

fixed in fd5b9d4: the endpoint passes the request row to the turn, the fix this finding gave: _run_chat(..., _current_message=msgs[u_idx]). The turn no longer guesses its current message by scanning back from the newest row, which a later steer, inject or subagent row could win.
Only Regenerate has this shape: edit-resend and rewind cut the rows after the request before they dispatch.
test_regenerate_taken_back_steer.py asserts the request row reaches the turn, past a taken-back steer and as a read steer; both checks fail with the line removed.

@RohanK6

RohanK6 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author
  • span=4cd75210712c The previous reply vanishes when the turn ends instead of visibly turning into the version arrows

Rebutted: the hard cut is deliberate, and the description says why under "## Why a plain swap", the second fix this finding offers. An animation into the switcher is version-management UI the frozen Goal rules out.
The evidence gap is closed in fd5b9d4: empty-inflight-dark.png and empty-inflight-light.png show the just-pressed state under "Previous version. Kept if Regenerate produces nothing."
Same class as span=92f0eedc0511, span=236590924119, span=b03dc3886093 and span=cb21ceec3d31; adding motion is a Goal change for a person to make.

@RohanK6

RohanK6 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author
  • The dimmed previous reply disappears at settle with no exit motion; add a fade or collapse into the version arrows

Rebutted: same class as span=4cd75210712c, span=92f0eedc0511, span=236590924119, span=b03dc3886093 and span=cb21ceec3d31. The hard cut is deliberate and the description says why under "## Why a plain swap".
Animating the old reply into the switcher is version-management UI the frozen Goal rules out. Adding motion is a Goal change for a maintainer to rule on, not a defect in this head.

@RohanK6

RohanK6 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Re r131 (crew-pr-reviewer) on edit-resend, chat_regenerate.py#L428:

Not a deferral, so no issue: the description records it as a sibling that is not affected (website/src/pages/chat/page/messageActions.ts:109).
Edit-resend replaces the user prompt itself. The reply it drops answers a prompt the user rewrote, so keeping it would show an answer to a question nobody is asking any more. Regenerate keeps the same prompt, which is why only Regenerate needs the keep-on-empty path.
The UX notes from r131 at bdf98d8 were answered at 858ef11 (span=4cd75210712c) and the screenshot gap is closed in fd5b9d4c5f (empty-inflight-dark.png, empty-inflight-light.png).

@RohanK6

RohanK6 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

resolution: removed

  • Item 4: the version-cap rewrite rides along (same_version, cap_variants_keeping)

fixed in 315e5e8: both removed; the endpoint keeps main's content-only dedupe and variants[-_MAX_VARIANTS:] tail slice, as the subtraction asked.
Nothing in the deferred swap uses them: settle and flush adopt _pending_variants as stashed. The #20487 order-mark check lived inside same_version, so it goes with it; main never had it.
Their tests (I1/I2 in test_regenerate_invariants.py, seven cap tests in test_dashboard_chat_regenerate.py) and the history.md paragraph go too. The cap eviction stays a separate fix for its own PR.

@RohanK6

RohanK6 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author
  • Notes: the two "Previous version." labels read alike, and the in-flight note does not say what Stop keeps

fixed in 315e5e8: the second label starts with what changed and both say what Stop does. Before new text: "Previous version. Kept if no new reply arrives. Stopping now keeps it." After: "Previous version. New reply started: this one moves to the version arrows. Stopping keeps both." Every catalog, informal or impersonal; screenshots re-captured.
The settle fade stays out, as "## Why a plain swap" says: motion into the switcher is version UI the frozen Goal rules out.

@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD at d889515b3d52db39664a4d9ebc1100c81866de20: the branch conflicts with main, and the persistence change still needs a maintainer.

  1. Conflict. A merge with current main conflicts in website/src/pages/chat/page/transcriptRendering.tsx. Rebase, resolve it, and let CI and the review lanes run on the new head.
  2. Maintainer review. Regenerate now removes retired_rows from the on-disk transcript at turn end (transcript_merge.py#L777, regenerate_swap.py#L312). What gets deleted from persisted chat history is reserved for a human maintainer.

The r131 items are answered. The edit-resend reply (the edit replaces the prompt, so the dropped reply answers a question nobody is asking) is reasonable and needs no issue. The UX notes and the screenshot gap were handled in 858ef11 and fd5b9d4. All AI lanes pass and CI is green. A rebased head needs a fresh review.

— crew-pr-reviewer (r133)

@RohanK6

RohanK6 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Frontend Lint & Type Check (and the Coverage Gate that waits on it) is red on main, not this PR: website/src/components/RedactionCards.tsx:1102 (from #19843) portals to document.body, which the no-restricted-syntax rule refuses. This PR does not touch that file. #25429 fixes it; this PR rebases once it lands.

@RohanK6

RohanK6 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author
  • span=374515aed8cf The first segment flush of a Regenerate reply copies the previous reply onto the new row as a variant

fixed in 9908085: _flush_segment no longer adopts _pending_variants while the turn owns a Regenerate target (owned_regenerate_target(slot) is None), the first fix this finding gave. The reply gets its variants only in the swapped row the pinned write commits; outside a Regenerate the flush is unchanged (test_pending_variants_are_attached_and_broadcast).
New decline tests go through the real _flush_segment: a refused or raising write, and a reply trimmed into the frozen prefix. Both assert no variants/variant_idx on the new row in memory and on disk, and both fail with the change reverted. history.md records when variants attach.

Regenerate used to remove the previous assistant reply before the new
turn ran, both on the server (history rewrite) and in the browser
(optimistic truncation). A re-run that produced no reply left the turn
with no answer at all, and the old one was gone.

The previous reply now stays in place until the turn ends. At the end,
settle_regenerate (chat_turn/regenerate_swap.py) removes it and keeps it
as a variant only when the turn produced a reply, through one write
pinned to the transcript and slot the Regenerate was authorized against.
An empty turn leaves it untouched.

The replace write names the rows it retires (retired_rows). The rewrite
keeps its foreign-append scan, so a row another writer persisted after
the snapshot, such as a workflow result landing during the write's
await, survives the swap instead of being rewritten away.

A committed swap also bumps a slot epoch inside the transcript lock
(write_guards.publish_swap). A save whose window copy predates the
commit, or was taken before memory applied it, re-takes the copy under
the lock with the swap applied, variants included; a caller's own
snapshot is refused. So an in-flight flush or a tag save cannot write
the old reply back, however many rows the swap retired.
The guard applies the swap record it read before re-copying the window,
since the event loop may apply the swap and clear the record meanwhile.
A swap whose previous reply was partly trimmed off the window into the
frozen prefix is refused: a rewrite cannot retire those rows, so both
replies stay.
While a swap is in flight the window's front trim waits, so an append at
the window cap cannot credit a retired row to the frozen prefix after the
write removed it from disk; the next append trims the excess.

A recovery the Regenerate turn queues before it has a reply (a
session-not-found replay, a refusal fallback, a continuation) is the
same Regenerate's next attempt: _queue_recovery hands it the target and
the drain re-arms it on the replay turn, so the replay's reply replaces
the previous one instead of landing after it.

Command replies the slash gate writes directly (an empty /prompts, a
blocked command, unsupported compaction) are recorded on the target like
every other reply, and the settle step runs in whichever frame runs the
turn's tail, so a /prompts get re-entry (depth 1) settles too.

test/test_regenerate_invariants.py checks the swap contract (the window
cap, a Regenerate during a swap, and one that ends with no reply) over
boundary inputs.

The streaming reply is labelled "New version". The previous one reads
"Previous version. Kept if no new reply arrives. Stopping now keeps
it." until new text starts, then "Previous version. New reply started:
this one moves to the version arrows. Stopping keeps both.", using the
word the version switcher already uses.

While the turn runs, the browser draws the previous reply dimmed under
a "Previous version" label, so the collapse into one reply with a variant
switcher at turn end reads as expected rather than as a lost answer.

A turn that ends without streaming also clears the pending press, so
the label leaves the kept reply as soon as the empty turn ends instead
of at the 30 s pending-press safety timeout.

The committed swap's chat_variant_switch frame names the rows it
retired (mids and approval ids), and the client drops them
(retireSwappedRows) before the refetch: that refetch re-seats decided
rows (permissions, elicitations) from the client's own copies, so a
decided card of the replaced turn would otherwise come back beside the
new reply. An empty or failed swap sends no frame, so its rows stay.

A row made of nothing but backend control notices (the Claude adapter's
"Compacting...") is not a reply: the target records each notice chunk,
and such a row is neither recorded as the reply nor given the stashed
variants. A notice-only turn that dies keeps the previous reply; one that
ends normally hands the target to the compaction continuation it queues,
whose real reply replaces the previous one.

The crew-log turn ordinal skips the kept reply
(rows_before_regenerate_target) so the re-run still draws the ordinal of
the turn it repeats and the emitter's attempt increments.

Fixes #14632
Fixes #24039
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants