Skip to content

fix(codex): bundle codex-code-mode-host next to the codex binary#3603

Merged
trunk-io[bot] merged 4 commits into
mainfrom
posthog-code/bundle-codex-code-mode-host
Jul 21, 2026
Merged

fix(codex): bundle codex-code-mode-host next to the codex binary#3603
trunk-io[bot] merged 4 commits into
mainfrom
posthog-code/bundle-codex-code-mode-host

Conversation

@adboio

@adboio adboio commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Problem

Two users reported that after updating to v0.57.237, Codex sessions can chat but cannot run any terminal commands or edit files — the agent reports a missing binary at .../app.asar.unpacked/.vite/build/codex-acp/codex-code-mode-host.

Why: the codex 0.140.0 → 0.144.0 bump in #3567 introduced a new runtime dependency. In codex 0.144, the gpt-5.6 model family advertises tool_mode: code_mode_only in codex's bundled model metadata (which overrides features.* config), so all command execution routes through code-mode cells. With the code_mode_host feature stable/default-on, those cells run in a standalone codex-code-mode-host process that codex resolves as a sibling of its own executable. We only ship codex and rg into .vite/build/codex-acp/, so every exec fails while chat keeps working.

Changes

  • download-binaries.mjs: fetch codex-code-mode-host from the same openai/codex release as codex (shared version const so they can't drift), and deduplicate the identical getTarget/URL logic.
  • vite-main-plugins.mts: stage the host next to codex in .vite/build/codex-acp/ (also removes a stray duplicate codex entry left over from the codex-acp removal in feat(codex)!: remove the codex-acp harness, app-server is the only codex adapter #3198). It ships via the existing asarUnpack glob and gets ad-hoc signed on macOS like its siblings; the inherit entitlements already allow JIT, which the host's embedded V8 needs.
  • code-release.yml: the packaged-app verification now fails the release if any codex sibling binary is missing, so this class of regression can't ship again.

How did you test this?

  • Ran node apps/code/scripts/download-binaries.mjs on linux-x64: all three binaries download, the host extracts and renames from its target-suffixed archive name, and executes (exit 0).
  • vitest run apps/code/scripts/download-binaries.test.mjs: 6/6 pass.
  • Biome check clean on both changed source files.
  • Verified upstream: resolve_host_program() in codex 0.144's code-mode/src/remote_session.rs joins codex-code-mode-host onto current_exe().parent(), matching the exact path in the user reports.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code

The codex 0.140.0 -> 0.144.0 bump (#3567) introduced a new runtime
dependency: codex resolves codex-code-mode-host as a sibling of its own
executable and routes all command execution through it for code-mode
models (gpt-5.6 family advertises tool_mode: code_mode_only). We only
shipped codex and rg into .vite/build/codex-acp, so Codex sessions could
chat but every command/edit failed with the host binary missing.

Download the host from the same codex release, stage it next to codex,
and make the packaged-app verification fail the release when any codex
sibling binary is missing.

Generated-By: PostHog Code
Task-Id: 541351db-2923-49df-8b67-45e277f5dce8
@trunk-io

trunk-io Bot commented Jul 20, 2026

Copy link
Copy Markdown

😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details.

@adboio adboio added the Create Release This will trigger a new release label Jul 20, 2026
@adboio
adboio requested a review from a team July 20, 2026 20:15
@adboio
adboio marked this pull request as ready for review July 20, 2026 20:15
@adboio adboio added the Stamphog This will request an autostamp by stamphog on small changes label Jul 20, 2026

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR modifies a GitHub Actions release workflow, which is blocked by the CI/infra deny-list gate. Changes to release workflows require human review before merging.

@stamphog stamphog Bot removed the Stamphog This will request an autostamp by stamphog on small changes label Jul 20, 2026
@greptile-apps

greptile-apps Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
.github/workflows/code-release.yml:205
**Linux And Windows Packages Stay Unchecked**

This required-binary check only runs in the macOS release job. If staging skips a missing platform-specific source on Linux or Windows, packaging still succeeds and those artifacts can ship without `codex-code-mode-host`, leaving code-mode sessions unable to run commands.

### Issue 2 of 2
apps/code/scripts/download-binaries.mjs:49-52
**Windows Archive Name Is Assumed**

The new Windows host download assumes the ZIP member is named `codex-code-mode-host-${target}.exe`. If the release archive contains the target-suffixed host without `.exe`, extraction succeeds but the rename is skipped and `downloadBinary` throws `Binary not found after extraction`, blocking Windows setup and release builds. The current tests cover HTTP retries but not this Windows archive contract.

Reviews (1): Last reviewed commit: "fix(codex): bundle codex-code-mode-host ..." | Re-trigger Greptile

# codex resolves codex-code-mode-host and rg as siblings of its own
# executable; shipping codex without them breaks command execution
# at runtime (code-mode models route all commands through the host).
for f in codex codex-code-mode-host rg; do

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Linux And Windows Packages Stay Unchecked

This required-binary check only runs in the macOS release job. If staging skips a missing platform-specific source on Linux or Windows, packaging still succeeds and those artifacts can ship without codex-code-mode-host, leaving code-mode sessions unable to run commands.

Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/code-release.yml
Line: 205

Comment:
**Linux And Windows Packages Stay Unchecked**

This required-binary check only runs in the macOS release job. If staging skips a missing platform-specific source on Linux or Windows, packaging still succeeds and those artifacts can ship without `codex-code-mode-host`, leaving code-mode sessions unable to run commands.

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b51839c: added Verify package steps to the publish-windows and publish-linux jobs, checking codex, codex-code-mode-host, and rg in the unpacked electron-builder output (win-unpacked, linux-unpacked / linux-arm64-unpacked) before artifacts upload.

Comment on lines +49 to +52
const codexArchiveBinaryName = (binary) => (target) =>
process.platform === "win32"
? `${binary}-${target}.exe`
: `${binary}-${target}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Windows Archive Name Is Assumed

The new Windows host download assumes the ZIP member is named codex-code-mode-host-${target}.exe. If the release archive contains the target-suffixed host without .exe, extraction succeeds but the rename is skipped and downloadBinary throws Binary not found after extraction, blocking Windows setup and release builds. The current tests cover HTTP retries but not this Windows archive contract.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/scripts/download-binaries.mjs
Line: 49-52

Comment:
**Windows Archive Name Is Assumed**

The new Windows host download assumes the ZIP member is named `codex-code-mode-host-${target}.exe`. If the release archive contains the target-suffixed host without `.exe`, extraction succeeds but the rename is skipped and `downloadBinary` throws `Binary not found after extraction`, blocking Windows setup and release builds. The current tests cover HTTP retries but not this Windows archive contract.

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against the actual rust-v0.144.0 release asset: codex-code-mode-host-x86_64-pc-windows-msvc.exe.zip contains exactly one member, codex-code-mode-host-x86_64-pc-windows-msvc.exe, matching archiveBinaryName (same target-suffixed convention as the codex zip we already ship from). If upstream ever changes the member name, downloadBinary throws Binary not found after extraction at postinstall/CI time — a loud failure at build time, not a broken package at runtime — so no defensive handling added.

The packaged-app binary check only ran in the macOS release job, so a
windows or linux package missing codex-code-mode-host (or codex/rg)
would still ship. Check the unpacked electron-builder output on all
three platforms.

Generated-By: PostHog Code
Task-Id: 541351db-2923-49df-8b67-45e277f5dce8

@richardsolomou richardsolomou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be worth adding pre-merge coverage for the new host staging path. rn the release checks only run on v* tags and download-binaries.test.mjs only covers HTTP retries, so a typo here wouldnt show up until release packaging.

tatoalo added 2 commits July 21, 2026 08:40
Generated-By: PostHog Code
Task-Id: f00e3e6c-6f38-4baa-8df1-ddb7547129a1
Generated-By: PostHog Code
Task-Id: f00e3e6c-6f38-4baa-8df1-ddb7547129a1
@tatoalo
tatoalo enabled auto-merge (squash) July 21, 2026 08:45
@trunk-io
trunk-io Bot merged commit 5f0f3d0 into main Jul 21, 2026
28 of 29 checks passed
@trunk-io
trunk-io Bot deleted the posthog-code/bundle-codex-code-mode-host branch July 21, 2026 08:55
@github-actions

Copy link
Copy Markdown

Could not verify team-posthog-code membership (GitHub API error). Auto-release is limited to Team PostHog Code members, so this will ship with the next scheduled release instead.

@posthog

posthog Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

👋 Visual changes detected for this PR.

Review and approve in PostHog Visual Review

If these changes are unexpected, they may be caused by a flaky test or a broken snapshot on master. Don't approve — rerun the job or wait for a fix.

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

Labels

Create Release This will trigger a new release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants