Skip to content

fix(thread-startup): recover creation after reconnect - #1764

Merged
chuks-qua merged 4 commits into
mainfrom
codex/fix-reconnect-thread-creation
Sep 24, 2026
Merged

chuks-qua merged 4 commits into
mainfrom
codex/fix-reconnect-thread-creation

Conversation

@chuks-qua

@chuks-qua chuks-qua commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What

  • Count queued push bytes separately from RPC replies, so a large creation reply does not evict its own WebSocket.
  • Replay agent.createAndSend with the original startup ID after reconnect. The server binds that ID to one task and rejects a changed request.
  • Reconcile the preparing UI with the durable task, retain the submitted draft on a real failure, and add a repeatable lost-response worktree journey.

Why

Production logs showed the push guard closing sockets with 18–35 MiB buffered during task creation. A lost reply then made the UI report failure; Retry could start a second task with a fresh startup ID.

Evidence

  • A controlled Electron run suppressed the first creation reply and closed the app socket. Before this patch, the UI briefly showed Failed to create thread and retained a separate Draft. After the patch, the app sent two RPCs on different sockets with the same startup ID, showed no false failure or extra Draft, and displayed one task and its fixture answer after reload.
  • The public runtime worktree-setup --confirm-cleanup journey verified one startup, task, managed worktree, queued first turn, and persisted prompt after a lost reply. It cancelled Setup before any provider call and cleaned the owned fixture.
  • The seven-task fixture completed 7/7 turns and delivered 3,458 ordered events without gaps or duplicates. This is a functional workload check, not a performance comparison.

UI Changes

The screenshots use only the repository fixture project. The first shows the extra Draft in the controlled pre-fix run. The second shows one task and its answer after reconnect and reload.

Before: a recovered task plus an extra Draft

After: one task and its persisted answer

Review Notes

  • Migration 0064 adds a nullable request fingerprint to startup records. Existing records remain readable.
  • A process crash in the narrow managed-worktree interval between task insertion and startup binding can still leave an unbound task; the client asks for workspace inspection instead of silently creating another.
  • Focused checks passed: 187 web tests, 77 server tests, 10 verification-script tests, both typechecks, targeted lint, and diff checks. No configuration change.

@chuks-qua
chuks-qua merged commit 15590ea into main Sep 24, 2026
9 checks passed
@chuks-qua
chuks-qua deleted the codex/fix-reconnect-thread-creation branch September 24, 2026 16:54
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.

1 participant