Skip to content

Read daemon-owned rollouts for hand-typed Codex - #840

Merged
onevcat merged 1 commit into
mainfrom
fix/codex-daemon-log-detection
Sep 29, 2026
Merged

onevcat merged 1 commit into
mainfrom
fix/codex-daemon-log-detection

Conversation

@onevcat

@onevcat onevcat commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Stacked on #839. Review and merge #839 first; this PR's diff is only the detection change.

Problem

CodexLogProvider finds Codex rollouts through the open files of the pane's TUI process. A Codex 0.157+ TUI typed by hand attaches to the shared app-server daemon, which owns every rollout, so the TUI holds none. The state machine reported screen.noLiveTurn and relied on the screen alone. That is how the original symptom surfaced: a 0.158 footer change hid the Working row (#838), and nothing else knew the turn was open.

Change

  • When the TUI's open-file inventory is complete and holds no rollout, the provider asks CodexDaemonThreadMapper (from Resolve CLI callers under Codex's shared daemon #839) for the pane's binding: the root thread of the pane's newest indexed submit plus every descendant the daemon holds open. It feeds those rollouts into the existing incremental decoder, so lineage, subagent work, and suspension rules are unchanged.
  • The session log must belong to the current TUI process (header within 120 s after the process start), so a log left by an earlier TUI cannot bind.
  • A newly bound rollout starts at the live task_started that precedes the bound submit, not at the file end. Binding happens only after the turn's user item lands, which is after task_started; starting at the end would miss the open turn of a resumed, older rollout.
  • The rollout index honors the live boundary of forked rollouts. Measured on 0.158: /fork writes only the fork's own items, and a forked subagent copies task_started but not user items before its thread_settings_applied.
  • The daemon is found through daemon.pid under the TUI's own CODEX_HOME, and the pid must still be the managed daemon.
  • Embedded Codex (Profile launches, --no-daemon) is unchanged: its TUI owns its rollouts and is read directly.
  • Docs: docs/components/agent-detection.md and docs-ai/073-codex-daemon-caller-identity/002-daemon-log-detection.md.

Verification

  • New tests: binding family and live offsets, pending submit keeps the previous binding, index turn offsets, forked live boundary, stale session log rejection, provider live-offset start, provider daemon fallback wiring, and daemon.pid validation.
  • make check, make test (3599 passed, 0 failed in supacode-tests), and make build-app pass.
  • Live acceptance in a Debug instance on a dedicated socket, isolated CODEX_HOME daemon, two hand-typed Codex panes in one cwd (prowl agents --json, sampled every 2 s):
Scenario detection_reason
Before the first submit screen.noLiveTurn (unbound, as before)
Concurrent sleep 40 / sleep 15 turns each log.openWork, then log.turnEnded at its own end
Subagent running sleep 20 while the parent waits log.openWork throughout
/new, then a new turn log.openWork on the new thread
Steered message during a turn log.openWork throughout
Restart with codex resume of a thread created before the provider, then a turn log.openWork
Esc interrupt log.turnEnded

A Codex 0.157+ TUI attached to the shared daemon holds no rollout, so
the log provider found nothing and detection relied on the screen alone.

- When the TUI's open files are complete and hold no rollout, read the
  rollouts the pane drives through the daemon: the root thread of the
  pane's newest indexed submit and its descendants. The session log
  must belong to the current TUI process.
- Start a newly bound rollout at the live task_started of that submit.
  Binding happens after the user item lands, which is after the turn
  started, so starting at the file end would miss the open turn.
- Honor the live boundary of forked rollouts in the thread index.
- Record the change in docs-ai 073.002.
Base automatically changed from fix/codex-daemon-caller-identity to main September 29, 2026 10:57
@onevcat
onevcat merged commit 1ec2ce9 into main Sep 29, 2026
1 check passed
@onevcat
onevcat deleted the fix/codex-daemon-log-detection branch September 29, 2026 10:58
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