Skip to content

fix(hub): keep duplicate merge consistent when a later delete is refused - #2764

Merged
tiann merged 1 commit into
tiann:mainfrom
arsalankhan786777:fix-2706-duplicate-merge-partial-progress
Dec 4, 2026
Merged

tiann merged 1 commit into
tiann:mainfrom
arsalankhan786777:fix-2706-duplicate-merge-partial-progress

Conversation

@arsalankhan786777

Copy link
Copy Markdown
Contributor

Summary

Fixes #2706

In mergeSingleDuplicateCodexSessionGroup, a source's messages were copied and its attached jobs moved before engine.deleteSession could refuse it. Events and session activity were published only after the whole loop. So a refusal on a later source left that source's messages in the canonical session, and the copies from earlier, already deleted sources were never announced.

This takes the smaller of the two directions in the issue (per-source completion, not a whole-group transaction):

  • SyncEngine: the refusal checks in deleteSession (OpenCode rewind, unconfirmed Codex resume, pending archived fork) move into assertSessionDeletable, which deleteSession still calls.
  • The merge loop calls it before touching each source. A refused source keeps its messages and jobs and nothing from it is copied, so no rollback is needed for these refusals.
  • message-received, session activity and session-updated are published after each completed source instead of once after the loop.

Limits

  • The merge still reports success: false when a source is refused, and the response still does not list the sources already removed. Earlier sources stay merged; the operator can retry once the refusal is resolved.
  • The new check does not cover the refusals inside sessionCache.deleteSession: a source that becomes active while an earlier one is being deleted is still refused after its messages were copied.
  • This is not a group transaction. An unexpected error in the middle of one source (for example a database error during a copy or delete) can still leave that source partly processed.
  • feat(web): surface blocked sessions in the session list (#1717) #2520 edits the same loop and adds applyReconciledNotifyState after it. That call is not on main, so it is not handled here; whichever lands second needs to move it into the per-source step, and engine test doubles that run a merge need assertSessionDeletable.

Testing

  • New test in codexDesktop.test.ts (real SyncEngine, three duplicates, the last one with codexResumePending). On main it fails: the canonical session has 6 messages instead of 5. With the message and job assertions removed, it also fails on main on the events (0 message-received instead of 2). With the change, the whole file passes (32/32).
  • bun test in hub: 2359 pass, 3 skip, 5 fail. The same 5 tests fail on main on my Windows machine (three AcpVerifyProbe PATH tests and two ~ expansion tests for push config).
  • bun typecheck from the repo root (cli, web, hub, relay): passes.
  • Local runs used Bun 1.4.2.
  • Not verified: a merge against a running hub with real Codex sessions, and the CLI, web, shared and relay test suites.

AI disclosure

Model: Claude Sonnet 5.5 (Claude Code).

Written with Claude Code (AI); tested locally with bun test in hub and bun typecheck from the repo root.

🤖 Generated with Claude Code

The Codex duplicate merge copied a source's messages and moved its jobs
before deleteSession could refuse it, and only published the result after
the whole loop. A refusal on a later source left its messages copied into
the canonical session and the earlier, already deleted sources unannounced.

Check for a refusal before touching each source, and publish messages and
session activity as each source completes.

Fixes tiann#2706

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@heavygee heavygee added bug Something isn't working area:hub Hub server (API, sync, store) community-pr PR from non-collaborator contributor labels Dec 3, 2026
@tiann
tiann merged commit 2ced8b8 into tiann:main Dec 4, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:hub Hub server (API, sync, store) bug Something isn't working community-pr PR from non-collaborator contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate-group merge loop in codexExtras.ts loses partial progress on a refused deletion

3 participants