Skip to content

fix: keep forked Codex threads subscribed - #37

Merged
Leeeon233 merged 1 commit into
LodyAI:mainfrom
ladydd:fix/keep-fork-child-subscribed
Sep 9, 2026
Merged

Leeeon233 merged 1 commit into
LodyAI:mainfrom
ladydd:fix/keep-fork-child-subscribed

Conversation

@ladydd

@ladydd ladydd commented Sep 9, 2026

Copy link
Copy Markdown

Closes LodyAI/Lody#543

Problem / pressure

thread/fork returns a live child thread. The adapter then called threadUnsubscribe on that child. runTurn waits for turn/completed notifications, so the first prompt on a Fork session never finishes. Codex can complete the turn on the server; the adapter never sees it. Stop reports no active turn to interrupt. The next prompt is A Codex prompt is already active. The parent session still works.

onSubscribed is only a lifecycle callback. It does not subscribe. This is not Codex thread/fork failing.

Summary

Keep the child subscribed when fork install succeeds. Unsubscribe only if assignProject fails before the session is returned. closeSession still unsubscribes.

Visual explanation

sequenceDiagram
  participant Host
  participant Adapter
  participant Codex
  Host->>Adapter: session/fork
  Adapter->>Codex: thread/fork
  Codex-->>Adapter: child id (subscribed)
  Note over Adapter: before: threadUnsubscribe(child)
  Host->>Adapter: session/prompt
  Adapter->>Codex: turn/start
  Codex-->>Adapter: turn/start ok
  Codex-->>Adapter: turn/completed (needs subscription)
  Note over Adapter: after: stay subscribed so completed arrives
Loading

Before / after

Before After
Fork tab hangs on first prompt; stop then already active Child stays subscribed; first prompt can complete
Parent still answers Unchanged

Test plan

  • vitest run src/__tests__/CodexACPAgent/session-fork.test.ts --no-file-parallelism --retry=0 — 3 passed (successful fork does not unsubscribe; install failure still unsubscribes).
  • vitest run src/__tests__/CodexACPAgent/CodexAcpClient.test.ts -t 'forks an ACP session through thread/fork' — passed.
  • Independent app-server check (Codex 0.153.4, synthetic model): suppressing that unsubscribe let the child finish two turns with turn/completed. This PR is that change plus failure-path cleanup. Live Electron E2E forks a session and continues was not re-run here (RUN_E2E_TESTS + API key).

Context

Authored with an AI coding agent. Reviewers should challenge: leaving the child subscribed vs any reason the old tests required unsubscribe; whether assignProject failure is the only install-fail path that must unsubscribe.

Lody still needs a submodule bump after this merge.

thread/fork leaves the child subscribed. runTurn waits on
turn/completed notifications, so unsubscribing the live child
leaves the first prompt hanging. Unsubscribe only if install
fails before the session is returned; closeSession still
unsubscribes.
@Leeeon233

Copy link
Copy Markdown
Collaborator

thanks

@Leeeon233
Leeeon233 merged commit e472d56 into LodyAI:main Sep 9, 2026
Leeeon233 added a commit to LodyAI/Lody that referenced this pull request Sep 9, 2026
* fix: keep forked Codex sessions subscribed

Pin acp-extension-codex to fc91dce (LodyAI/acp-extension-codex#37) so
thread/fork children stay subscribed for turn/completed. Pin
acp-extension-core 0.1.2 because that adapter already depends on it.

This does not take Lody#534 host worktree identity changes. Adapter #35
is already on Codex main and comes along with #37.

Closes #543

* docs: record Codex fork subscription pin

Agent Note for pinning acp-extension-codex fc91dce and Core 0.1.2
without taking Lody #534 host identity changes.

Model: grok-4.6

* fix: pin DSH main with awaited smoke tests

Use merged acp-extension-dsh #14 to fix the no-floating-promises CI error without weakening lint checks.

Model: gpt-6

---------

Co-authored-by: Leon Zhao <leeeon233@gmail.com>
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.

[Bug] Forked Codex session hangs forever on the first prompt

2 participants