Skip to content

fix(client): reconcile session.sync results into the store - #57093

Open
qretsar wants to merge 2 commits into
anomalyco:devfrom
qretsar:fix/client-session-sync-reconcile
Open

qretsar wants to merge 2 commits into
anomalyco:devfrom
qretsar:fix/client-session-sync-reconcile

Conversation

@qretsar

@qretsar qretsar commented Oct 19, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #57092

Related #56253 (touches the same lines in session.sync; whichever lands second needs a small rebase).

Type of change

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

What does this PR do?

session.sync stored each fetched session with draft[session.id] = session, so an unchanged session still got a new object. That re-sorted the session list and re-ran every consumer of session.list() on each sync. This switches to a per-entry reconcile(session), the pattern session.remember already uses. Unchanged data keeps its identity. Omitted optional fields are still removed, changed fields still notify, children: true still never deletes children, and session.deleted is untouched.

The new reactivity test needs the browser build of solid-js, because the server build has no effects. It is skipped in the default stage, so package.json now runs test:unit and then a focused test:reactivity stage (one test, selected by name). Without that the test would never run in CI.

architecture: existing reconcile precedent in the same store, no new infrastructure.

How did you verify your code works?

In packages/client with bun 1.4.2:

  • bun run test passes: 230 pass, 1 skip, 0 fail in the unit stage, then 1 pass, 0 skip in the reactivity stage.
  • On current dev the reactivity test fails (4 effect runs vs 1, 3 sorts vs 0) and passes with the change. A second test checks that omitted fields are dropped and children are never deleted.
  • bun run typecheck is clean. Pre-push bun run check passed.
  • A separate scratch test (1000 sessions, 5 unchanged syncs) gave 5 sorts and 4995 comparisons before, 0 after. It is not part of this PR; the PR test uses 50 sessions.

I did not measure how often real clients trigger an unchanged sync.

Screenshots / recordings

N/A, no UI 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: #55948

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

Looks good. I ran the reproduction from #57092 under browser conditions. On the base, three unchanged syncs re-ran the session.list() effect 3 times, sorted the list 3 times, and replaced the session object. With this change there are no re-runs and no sorts, and the same object is kept. The new reactivity test fails on the base source and passes with the change. bun run test passes in both stages and bun run typecheck is clean in packages/client. CI runs each package's test script through turbo, so the new test:reactivity stage will run there.

Public API: unchanged; only the package's test scripts are new.

No blocking concerns. Writing each session with reconcile, as session.remember already does, still adds new sessions, removes omitted optional fields and leaves children in place. Heads-up: #56253 rewrites these same lines, so whichever lands second should keep the reconcile write.

Related: #55948

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: session.sync replaces unchanged sessions, re-sorting the list and notifying all consumers

1 participant