Skip to content

fix(client): prevent stale reads from restoring deleted sessions - #57222

Open
Kyle-j-bush wants to merge 4 commits into
anomalyco:devfrom
Kyle-j-bush:session-deletion
Open

Kyle-j-bush wants to merge 4 commits into
anomalyco:devfrom
Kyle-j-bush:session-deletion

Conversation

@Kyle-j-bush

@Kyle-j-bush Kyle-j-bush commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #56736

Type of change

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

What does this PR do?

Ignore sessions deleted while metadata or family reads are in flight. Deletions are tracked only until each read settles, preventing stale responses from restoring deleted records or marking them synchronized.

How did you verify your code works?

  • Both regression cases fail before the fix and pass afterward.
  • Client: 231 tests pass; the regression file passes 10 randomized runs.
  • TUI data: 50 tests pass.
  • bun run check passes, with existing lint warnings.

Screenshots / recordings

No visual layout change.

Checklist

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

Added by the opencode bot (AI-generated).

Related: #57139

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

I reproduced both sequences from #56736 on the base with the bot's script, and both pass with this change: the deleted session stays out of info and family membership, and a later sync of the deleted child fetches again. The client tests (231) and typecheck pass in packages/client.

I checked how the per-read deletion set behaves with createSync. A call that joins an in-flight read never registers its own set, and the shared read keeps the first caller's set until it settles. A restart after invalidation gets a fresh set, and finally cleans up on failure, so nothing leaks and no deletion is missed while a request is pending. I have no blocking concerns.

Public API: unchanged. This is an internal change to createData, with no new or changed exports, events or endpoints.

Note: #57184 adds a similar per-read tracker for session.moved in the same session.sync function. Whichever lands second will need a rebase, and the two trackers could reasonably share one mechanism.

Related: #57139

@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 new commit only merges dev; the fix and its tests are unchanged. I re-ran the #56736 reproduction on the merged head and both cases still pass. The client tests (235) and typecheck pass in packages/client. The dev changes merged into data.ts don't interact with session.sync or removeSession. Public API: unchanged. No new concerns.

@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 new commit only merges dev; the fix and its tests are unchanged. I re-ran the #56736 reproduction on the new head and both cases still pass. The client tests (235) and tsc --noEmit in packages/client pass. The dev changes merged into data.ts don't affect session.sync or removeSession. Public API: unchanged. No new concerns.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

client: delayed metadata and family reads resurrect deleted sessions in the client cache

1 participant