[codex] fix Codex JSON parsing and convert chip hooks#52
Conversation
|
Hey @alannewlife — heads-up for review scoping: this overlaps with a few open fixes already in flight.
This PR is the focused two-file version that covers both slices, so reviewers can compare whether to land the narrow fix here or one of the broader compatibility PRs. I routed @nettee for pool review. |
|
Heads-up: PR #27 is already open for the narrower Codex This PR also includes the |
|
Hey @alannewlife, quick lifecycle update: both concrete slices in this draft have now landed on That makes this draft superseded as written. If you intended a remaining change beyond those two fixes, please update the PR description/diff so reviewers can re-scope it; otherwise it is safe to close this one to keep the queue tidy. |
What changed
codex exec --jsonevents where assistant output arrives asitem.type: "agent_message"instead of the olderitem_type: "assistant_message"shape.turn.completedevent.ConvertChip's split-layout early return below its hooks so React hook ordering remains stable when layout state changes.Why
Newer Codex CLI versions can complete successfully while HTML Anything still shows a 0 KB output because the parser ignores the updated event shape. Separately, switching layouts can trigger React's “Rendered fewer hooks than expected” error because
ConvertChipreturned before later hooks ran.Validation
codex exec --json --skip-git-repo-check --sandbox workspace-write -c sandbox_workspace_write.network_access=true 'Reply with exactly: CODEX_OK'returnedCODEX_OK./api/convertwithagent: "codex"returned a complete<!DOCTYPE html>...document.pnpm buildpassed. Turbopack still reports the existing NFT tracing warning fromnext.config.ts -> src/lib/agents/invoke.ts -> src/app/api/draft/route.ts.