Skip to content

[codex] fix Codex JSON parsing and convert chip hooks#52

Draft
alannewlife wants to merge 1 commit into
nexu-io:mainfrom
alannewlife:codex/fix-codex-output-and-hooks
Draft

[codex] fix Codex JSON parsing and convert chip hooks#52
alannewlife wants to merge 1 commit into
nexu-io:mainfrom
alannewlife:codex/fix-codex-output-and-hooks

Conversation

@alannewlife

Copy link
Copy Markdown

What changed

  • Fix Codex JSON parsing for newer codex exec --json events where assistant output arrives as item.type: "agent_message" instead of the older item_type: "assistant_message" shape.
  • Preserve Codex usage parsing for the newer turn.completed event.
  • Move 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 ConvertChip returned 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' returned CODEX_OK.
  • /api/convert with agent: "codex" returned a complete <!DOCTYPE html>... document.
  • Browser UI generation with OpenAI Codex completed and produced a 7.0 KB preview.
  • pnpm build passed. Turbopack still reports the existing NFT tracing warning from next.config.ts -> src/lib/agents/invoke.ts -> src/app/api/draft/route.ts.

@lefarcen lefarcen requested a review from nettee May 17, 2026 05:45
@lefarcen lefarcen added size/XS Extra-small change (<20 lines) risk/medium Medium risk change type/bugfix Bug fix labels May 17, 2026
@lefarcen

Copy link
Copy Markdown

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.

@lefarcen

Copy link
Copy Markdown

Heads-up: PR #27 is already open for the narrower Codex agent_message / turn.completed parser compatibility slice in src/lib/agents/argv.ts.

This PR also includes the ConvertChip hook-order fix, so it is broader than #27. Sharing the overlap so the authors and reviewer can compare scope before the maintainer team picks which path lands.

@lefarcen

Copy link
Copy Markdown

Hey @alannewlife, quick lifecycle update: both concrete slices in this draft have now landed on main through focused PRs — #27 covers the Codex agent_message / turn.completed parser drift, and #28 covers the ConvertChip hook-order crash. Issue #26 has also been verified and closed after those fixes.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk/medium Medium risk change size/XS Extra-small change (<20 lines) type/bugfix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants