fix(client): remove reverted prompts from live history - #9857
juliusmarminge wants to merge 2 commits into
Conversation
Carry forward the focused retention correction from #6044. Co-authored-by: Amit Ray <51674969+amitray007@users.noreply.github.com>
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a focused client-runtime correction that removes turnless prompts beyond a retained checkpoint after a revert while preserving valid prior history. The implementation is confined to the reducer and includes targeted coverage for pagination, missing checkpoints, and steering-message cases. No code changes detected at You can add or adjust custom eligibility rules. Learn more. |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
Note: GPT-6 on behalf of shivam (@shivamhwp). Current main already removes the ordinary second prompt through #5362, but the loaded-pagination case still needs a fix. Rebasing this retention rule must preserve main's imported-history exception: at checkpoint zero it currently removes both imported prompts and imported answers, while the persisted server history keeps them. Retain The completion-time fallback also needs The existing history-policy hold still applies. There is also a current fallback disagreement when no checkpoint survives in the loaded client state and turnCount is positive: this candidate drops all turnless rows, while main retains fallback messages. Resolve that alongside the steering/commentary policy before treating live and persisted history as consistent. |
After a successful revert, the live client keeps user prompts without a turn ID even when the server has removed them. Reloading the thread produces different history.
Human-held: the ordinary two-turn case is fixed, but additional receipt tests confirm a pre-existing server/client disagreement for steering messages and turnless assistant commentary. This candidate preserves those earlier rows in the live client while the server drops them. Choosing preservation versus matching the server's removal needs a maintainer decision; this PR is not ready for automatic merge.
Bound those prompts by the latest retained checkpoint's assistant message, falling back to its completion time when that message is outside the loaded window. Preserve messages bound to retained turns and system messages. This carries forward only Amit Ray's retention correction and regression tests from closed #6044, with an additional no-surviving-checkpoint control. The author invited reuse, and maintainer edits on that closed branch are unavailable.
Addresses the live-history portion of #5685. Restoring prompts, images or existing drafts into the composer is not included; the issue remains open for those recovery choices.
Before and after
A disposable SQLite orchestration engine generated two turns and checkpoint records at 82f64cd8. After its committed revert-completion receipt:
The receipt fixture waits on engine receipts and worker drains, without sleeps. This verifies post-revert history projection, not a Git/provider rewind or browser interaction. No UI component, provider behavior, schema, dependency or stored-data migration changes.
Additional receipt-derived controls use real persisted snapshots, not reducer-only expected arrays:
The last two are unresolved history-policy limits, not claims of complete parity. Server retention and contracts remain unchanged.
Checks
The earlier CI attempt was infrastructure-blocked by Ubuntu HTTP mirror timeouts. This branch is now refreshed onto ce4712d5, which includes the upstream HTTPS mirror repair. All 49 focused tests, client-runtime typecheck and targeted lint pass again. A new current-head CI cycle is running. No extra workflow change or check bypass was made. The human history-policy hold above remains in place.
Original correction by Amit Ray. Prepared and verified with GPT 6 Astra via Codex in T3 Code.
Note
Medium Risk
Changes shared revert projection logic used by web/desktop/mobile; wrong bounds could drop or keep the wrong messages in chat history, though scope is limited to
thread.revertedhandling and is heavily regression-tested.Overview
Fixes live thread history after a
thread.revertedevent so reverted user prompts (and related rows) disappear without a full reload.retainMessagesAfterRevertno longer keeps every message with a nullturnId. Turn-bound messages still follow retained checkpoints; system messages stay. Turnless user/assistant rows are kept only through the latest retained checkpoint—by index through that checkpoint’sassistantMessageIdwhen it’s in the loaded window, otherwise bycreatedAtvs the checkpoint’scompletedAt.The existing two-turn revert test is updated (explicit second prompt + assistant id), with new reducer tests for paginated windows, no surviving checkpoint, and pre-checkpoint steering/commentary retention.
Reviewed by Cursor Bugbot for commit 576461e. Bugbot is set up for automated code reviews on this repo. Configure here.