Repository navigation
fix(cli): Codex 0.160 sessions reach the chat view again - #640
Merged
Merged
Conversation
Codex 0.160 moved the TUI behind a machine-wide app-server daemon that holds every rollout open, so the terminal's own process tree holds none and the daemon never found the session: no thread id, no transcript, no backfill. It also replaced the user_message / agent_message / agent_reasoning events with one item_completed per thread item, which the parser skipped. A Codex holding no rollout is now matched by what the rollouts say: the session in the terminal's dir that started with its codex process (ps etime vs session_meta.timestamp), else the one written to since (a resume), never one another terminal follows; the match sticks to the process. The parser reads UserMessage / AgentMessage / Reasoning items, and unwraps the JSON output framing 0.160 puts on code-mode commands. Live-checked on an isolated daemon: a spawned Codex reports its thread id within seconds and both turns of a conversation stream into the transcript.
…o Codex A Codex terminal stayed "working" after it finished: its TUI keeps repainting (clock, footer), so the silence heuristic never fired, and the chat composer showed "your message will queue" against an idle agent. The rollout marks every turn, so the transcript poll now reports task_started / task_complete / turn_aborted and attention takes them with a hook's authority (working / needs_you, reason stop) — Codex's equivalent of Claude Code's UserPromptSubmit / Stop. A message sent from the chat view never submitted to Codex: the text and its Enter arrived in one write, Codex's paste-burst detection read the burst as a paste and the Enter within 120 ms of it as a newline. The input route now writes the message and the Enter 250 ms apart. Live-checked on an isolated daemon: needs_you within seconds of each turn's end, a chat-style `text\r` starts the next turn, both turns in the transcript.
The conversation view rendered an agent's reply as markdown, which folds single newlines into a paragraph: a haiku, list-like lines, and short answers written for a terminal came out on one line. The assistant rows now render with remark-breaks (`breaks` on LogMarkdown); the log viewer's rendering is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Local Codex sessions showed an empty chat view since Codex 0.160: no thread id, no transcript, no backfill. Two independent breakages, both in the daemon:
lsof//proclookup found nothing. A Codex holding no rollout is now matched by what the rollouts say about themselves: the session in the terminal's dir that started with itscodexprocess (ps etimevssession_meta.timestamp), else the one written to since (a resume), never one another terminal already follows; the match sticks to the process so a later session in the same dir doesn't steal it.user_message/agent_message/agent_reasoningevents with oneitem_completedper thread item. The parser readsUserMessage/AgentMessage/Reasoningitems (tool items are skipped: their response items carry the call and output) and unwraps the JSON output framing 0.160 puts on code-mode commands.Pre-0.160 rollouts and the in-tree lookup keep working.
Verification
pnpm --filter @optio/cli test(210): new cases for the 0.160 item shape built from real rollout lines,etimeparsing, the dir+time match, and a two-terminal finder scenario under an app-server daemon.test-daemon.sh) against a private test API: a spawned Codex 0.160 reported its thread id within seconds; both turns of a conversation streamed intoGET /api/local/terminals/:id/transcript.Rebuild the CLI and restart
optio local upto pick it up.Also: attention and chat for Codex
workingafter it finished because its TUI keeps repainting (clock, footer), so the silence heuristic never fired and the chat view said "The agent is working — your message will queue". The rollout marks every turn, so the transcript poll now reportstask_started/task_complete/turn_abortedand attention takes them with a hook's authority (working/needs_you, reasonstop): Codex's equivalent of Claude Code'sUserPromptSubmit/Stop.POST /api/local/terminals/:id/inputnow writes the message and the Enter 250 ms apart (a bare Enter or text without one is unchanged). The iOS and Android composers go through the same route.Live-checked on the isolated daemon:
needs_youwithin seconds of each turn's end, a chat-styletext\rstarts the next turn, both turns in the transcript. API image rebuilt and rolled out on the local cluster.Also: chat replies keep their line breaks
The conversation view rendered an agent's reply as markdown, which folds single newlines into a paragraph (a haiku came out on one line). Assistant rows now render with
remark-breaks(breaksonLogMarkdown); the log viewer is unchanged.