Skip to content

fix(client): preserve surviving input through committed reverts - #55403

Closed
CasualDeveloper wants to merge 1 commit into
anomalyco:devfrom
CasualDeveloper:revert-projection
Closed

CasualDeveloper wants to merge 1 commit into
anomalyco:devfrom
CasualDeveloper:revert-projection

Conversation

@CasualDeveloper

@CasualDeveloper CasualDeveloper commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Fixes #44357
Split out of #55315; the original issue is closed, but its disappearing-replacement symptom is reproduced by the Client regressions.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

A committed revert could remove a replacement still waiting for acknowledgement. I keep those optimistic rows, clip the transcript by boundary position instead of ID order, and reload pending survivors from the server.

An off-page or page-edge boundary also needs fresh history and a valid cursor. Superseded transcript/pending/page reads cannot republish deleted rows. Unviewed transcripts stay unloaded; clipped pending rows clear immediately while surviving input keeps delivery-event bookkeeping, even without cached session info.

Two Client files only. No prompt API, send-chain, App/TUI, or cancellation changes; #54163 remains separate. The refresh preserves upstream cache-eviction guards, tool-file restoration and first-token handling.

How did you verify your code works?

  • Independently rebased this PR onto dev at 0354362b857beae78166d4305f06c0b2f47c251e.
  • 101 Client tests pass across solid-data, inbox-race, compaction, eviction, refresh and pending-status; official Client TypeScript checking passes.
  • The focused revert selection has 11 failures and one pass with BASE's data implementation; all 12 pass with this fix restored.
  • Root bun run check passes. These checks ran on this focused branch, without the other feature branches.
  • Reviewed the original-to-refreshed range-diff; one commit, two files, original authorship retained. No generated API changes.

Screenshots / recordings

Data projection only; no visual styling changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Process: human-directed, with agentic assistance from openai/gpt-6-astra.


Added by the opencode bot (AI-generated).

Related: #54150

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

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

The approach looks sound. I couldn't reproduce the race live in the TUI. The 8 new regression tests fail on the base and pass with this change. All 38 tests in solid-data.test.ts pass, and the client typecheck passes. Clipping by transcript position matches what the server's revert projection does: it deletes messages and pending items by their position (seq >= boundary), not by ID order. Keeping only rows that are still waiting for acknowledgement is also safe, because events arrive in order: anything the server queued before the revert has already been acknowledged by the time the revert is handled.

Public API: unchanged. createSync's run callback gains an optional parameter, but it is internal to data.ts.

Concerns:

  • A session can have its info loaded but not its transcript. For those, the boundary is never found and the session gets a full transcript and pending fetch (see the inline comment).
  • When the session's info isn't loaded, nothing removes pending rows any more; the old code removed them. When it is loaded, the deleted rows stay visible until the pending reload finishes. That gap is probably acceptable, but it is a change from before.
  • The reformatting of the existing "counts every subagent page" test is unrelated and can be dropped.

Related: #54150

Comment thread packages/client/src/solid/data.ts Resolved
@CasualDeveloper

Copy link
Copy Markdown
Contributor Author

I rebased onto dev at 22e771f589 and addressed the unloaded-transcript request: session-list info alone no longer triggers history or inbox loads. Clipped pending rows now clear immediately even without cached session info; surviving inputs retain the bookkeeping needed by delivery events during revalidation. I added regressions for both paths and the delivery overlap, and dropped the unrelated test formatting. All 48 focused Client cases pass, including 480/480 repeated runs; Client typecheck and the root gate pass.

Project the loaded boundary by transcript position and retain unacknowledged replacements. Revalidate authoritative pending state and surviving history when the boundary or cursor falls outside the retained window.

Reject superseded message and pending snapshots and older-page responses from deleted cursors before store publication.
@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

@CasualDeveloper

Copy link
Copy Markdown
Contributor Author

Please reopen this PR. It was closed by the November 14 age/reaction cleanup, and I’m still maintaining the fix. This is the focused Client-only split requested in #55315. I addressed the earlier review’s unloaded-transcript, immediate pending-cleanup and unrelated-formatting concerns before cleanup closed it.

On November 16 I refreshed the maintained copy onto dev at 0354362b85. The survivor-projection checkpoint retains chronological clipping, optimistic replacement preservation and stale-read rejection alongside upstream’s new tool-file restoration and first-token handling. The combined source passed 164 Client tests, official Client typechecking, and the root checks.

Those fresh results are from the maintained combined source. This PR still points at da4198cd2e and needs its own refresh before merge. I’d like to keep its scope to the two projection/test files, with prompt APIs and TUI Undo handled separately.

@CasualDeveloper

Copy link
Copy Markdown
Contributor Author

I’ve now refreshed this PR’s own branch onto dev at 0354362b85: 2fd5b58ea4. It remains one commit touching only Client projection and its tests. All 101 focused Client tests, official Client typechecking and the root checks pass independently. Eleven selected revert regressions fail with the base implementation; all twelve selected cases pass with the fix. The earlier unloaded-transcript and pending-cleanup corrections are preserved. I updated the description; please consider reopening it for review.

The fork branch is verified at the linked commit. GitHub's closed PR record still reports the older head SHA, so the link above identifies the refreshed revision.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doing /undo and then quickly sending next matches glitches and hides our new chat instruction under a 'reverted' label

1 participant