Repository navigation
feat: add Linux x64 support - #12
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ce4b664376
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| #[cfg(target_os = "linux")] | ||
| let root = env::var_os("HOME") | ||
| .map(PathBuf::from) | ||
| .ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, "HOME is unavailable"))?; |
There was a problem hiding this comment.
Keep Linux runtime state under the updater root
When running a Linux npm update with the default state directory, the updater writes status under $HOME/.codexhost/updates and then wait_for_relaunch derives the new descriptor path as $HOME/.codexhost/desktop-runtime-v1.json; this Linux branch makes the relaunched Launcher publish desktop-runtime-v1.json under $HOME/codexhost instead. The update can successfully reinstall and relaunch but still time out as failed because it polls the wrong descriptor path, so use the same Linux state root for the Launcher descriptor/guard and the update manager.
AGENTS.md reference: AGENTS.md:L66-L66
Useful? React with 👍 / 👎.
|
Linux 现在会把通过 当兼容性状态为 warning 或 degraded 时,交互终端会显示 Desktop 与 CodexHost 版本、兼容性状态、能力、原因和观察到的 identity。用户可以选择继续一次、继续并记住、打开最新 CodexHost release、启动原生 ChatGPT 或取消。非交互运行、EOF 和无效输入都会取消。只有“继续并记住”会保存确认记录。 runtime descriptor 优先放在 测试覆盖独立 root、PID reuse、wrapper 本地检查:
GitHub Actions 仍在等待维护者批准 fork PR 的 workflow,因此当前 run 为 Linux now tracks the launcher started through For warning or degraded compatibility states, an interactive terminal shows the Desktop and CodexHost versions, the compatibility state, capability, reason, and observed identity. The choices are continue once, continue and remember, open the latest CodexHost release, launch stock ChatGPT, or cancel. Non-interactive runs, EOF, and invalid input cancel. Only "continue and remember" saves an acknowledgement. The runtime descriptor prefers Tests cover independent roots, PID reuse, wrapper Local checks:
GitHub Actions is waiting for maintainer approval before it can run jobs for this fork PR. The current run has |
There was a problem hiding this comment.
Pull request overview
This PR adds first-party Linux x64 support across the native Rust launch/supervision layer, Gate A evidence tooling, npm packaging/release automation, and update-manager semantics (Linux supported via npm distribution but not via installers).
Changes:
- Add Linux desktop discovery + managed launch/supervision (PID/start-time/exe identity via
/proc,pidfdsignaling, compatibility warning UI, and secure on-disk state/runtime storage). - Extend Gate A to run on Linux, including probe capture parsing/sanitization and Linux fixtures/contracts.
- Add
linux-x64to release targets and CI workflows, plus a Linux npm-package smoke test path (without installer packaging).
Reviewed changes
Copilot reviewed 50 out of 51 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/gate-a/run.mjs | Enable Gate A on Linux and add capture-based shim invocation evidence handling. |
| tools/gate-a/native/src/capture.rs | Extend probe capture platform fields for Unix/Linux. |
| tools/gate-a/native/src/bin/codexhost-probe.rs | Add Linux probe flow and shutdown-after-capture option. |
| tools/gate-a/differential.test.mjs | Add differential temp-parent safety test coverage. |
| tools/gate-a/contracts.mjs | Extend Gate A contracts with Linux variants and scenarios. |
| tools/gate-a/capture.test.mjs | Add Linux capture sanitization test coverage. |
| tools/gate-a/capture.mjs | Support sanitizing/parsing Linux raw captures. |
| tests/release/targets.test.mjs | Expand target matrix to include linux-x64 and no-installer expectations. |
| tests/release/packagers.test.mjs | Validate workflow steps for Linux npm build/smoke and installer skipping. |
| tests/release/npm-publish.test.mjs | Include Linux tarball + platform package in npm publish plan. |
| tests/release/npm-package.test.mjs | Add Linux npm target mapping and expected launcher source content. |
| tests/release/distribution-metadata.test.mjs | Allow Linux npm distribution metadata. |
| tests/fixtures/gate-a/linux/desktop-shim-invocation.fixture.json | Add Linux Gate A shim invocation fixture. |
| tests/fixtures/gate-a/linux/desktop-interactive.fixture.json | Add Linux Gate A interactive evidence fixture. |
| tests/differential/codex-transparent-proxy.mjs | Allow differential runs to place temp dirs under an explicit parent. |
| scripts/release/targets.mjs | Add linux-x64 release target and split installer vs npm target sets. |
| scripts/release/smoke-npm-package.mjs | New script: build + install + verify Linux npm platform + meta packages. |
| scripts/release/prepare-npm.mjs | Add Linux platform package mapping and linux cpu/os handling. |
| scripts/release/prepare-npm-meta.mjs | Update meta-package README text to include Linux. |
| scripts/release/distribution-metadata.mjs | Extend target validation regex to include linux-x64. |
| README.md | Document npm Linux support and clarify installer availability scope. |
| packages/update-manager/test/distribution.test.ts | Ensure Linux npm installations resolve without enabling installer updates. |
| packages/update-manager/src/github-release.ts | Add ReleaseTarget union including Linux (installer targets remain separate). |
| packages/update-manager/src/distribution.ts | Allow Linux targets in distribution metadata + expected-host mapping. |
| packages/host-runtime/src/update-coordinator.ts | Disable installer-update flows for Linux targets while allowing npm installs. |
| docs/README.en.md | Mention Linux npm support and clarify installers are macOS/Windows only. |
| docs/linux.zh-CN.md | New: Chinese Linux support documentation and constraints. |
| docs/linux.md | New: English Linux support documentation and constraints. |
| crates/updater/src/install.rs | Gate installer-specific codepaths/tests to macOS/Windows only. |
| crates/shim/tests/proxy.rs | Add streaming behavior test ensuring response can arrive before stdin EOF. |
| crates/shim/tests/fixtures/fake-codex-cli.rs | Add fake streaming response mode for shim tests; broaden unix cfg. |
| crates/shim/src/lib.rs | Change stream copy loop to flush per chunk and handle EINTR explicitly. |
| crates/shim/Cargo.toml | Enable nix/signal-hook deps for Linux as well as macOS. |
| crates/platform/src/process.rs | Add Linux /proc snapshots, identity checks, pidfd signaling, and root selection logic. |
| crates/platform/src/process_supervision.rs | Extend supervised process group signaling/cleanup behavior to Linux. |
| crates/platform/src/linux_ui.rs | New: Linux compatibility warning TTY prompt UI. |
| crates/platform/src/linux_installation.rs | New: validate official Linux package layout + ELF identity/resources. |
| crates/platform/src/lib.rs | Wire Linux modules/exports and add Linux identity + error variants. |
| crates/platform/src/installation.rs | Refactor shared unix helpers for Linux usage (sha256 + executable validation). |
| crates/platform/src/desktop_launch.rs | Linux managed launch via launcher wrapper + /proc lineage + cleanup. |
| crates/platform/src/background.rs | Extend background detachment support to Linux and tighten unsupported-OS behavior. |
| crates/platform/Cargo.toml | Add Linux deps (rustix/serde/serde_json) and share nix for macOS+Linux. |
| crates/launcher/src/secure_storage.rs | New: Linux secure runtime/state directory + file ops (no symlink, owned perms). |
| crates/launcher/src/runtime_instance.rs | Use secure storage primitives on Linux for runtime descriptor/guard handling. |
| crates/launcher/src/main.rs | Add Linux launch path, Linux compatibility prompt flow, and linux ownership checks. |
| crates/launcher/src/desktop_attachment.rs | Pass installation into ownership acquisition; use per-installation root discovery. |
| crates/launcher/src/compatibility.rs | Persist acknowledgements securely on Linux; include Linux identity in keying. |
| crates/launcher/Cargo.toml | Add Linux-only nix/rustix deps for secure storage. |
| Cargo.lock | Add/update lock entries for new Linux dependencies (rustix, linux-raw-sys, etc.). |
| .github/workflows/release-packages.yml | Add linux-x64 matrix target; skip installer on Linux; add Linux npm smoke step. |
| .github/workflows/ci.yml | New CI workflow running checks on Ubuntu/macOS/Windows + Linux npm smoke test. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| let metadata_path = install_root.join("resources/linux-package-metadata.json"); | ||
| let metadata_file = File::open(&metadata_path).map_err(|error| { | ||
| PlatformError::NotFound(format!( | ||
| "ChatGPT Linux package metadata '{}' is unavailable: {error}", | ||
| metadata_path.display() | ||
| )) | ||
| })?; | ||
| if !metadata_file.metadata()?.is_file() { | ||
| return Err(PlatformError::Invalid(format!( | ||
| "ChatGPT Linux package metadata '{}' is not a regular package file", | ||
| metadata_path.display() | ||
| ))); | ||
| } |
| let process_group_id = codexhost_platform::process_snapshot(process_id) | ||
| .map_or(0, |process| process.process_group_id); | ||
| .expect("capture process must remain inspectable") | ||
| .process_group_id; |
| @@ -0,0 +1,35 @@ | |||
| # Linux support | |||
|
|
|||
| CodexHost supports x64 Linux through the npm package. Install the official ChatGPT App first, then install CodexHost: | |||
| @@ -0,0 +1,35 @@ | |||
| # Linux 支持 | |||
|
|
|||
| CodexHost 通过 npm 包支持 x64 Linux。请先安装官方 ChatGPT App,再安装 CodexHost: | |||
| Err(error) | ||
| if interactive_running_desktop | ||
| && error.downcast_ref::<UnmanagedDesktopConflict>().is_some() => | ||
| && (error.downcast_ref::<UnmanagedDesktopConflict>().is_some() | ||
| || error.to_string() == UNMANAGED_DESKTOP_MESSAGE) => | ||
| { | ||
| continue; | ||
| return Err(error); | ||
| } |
|
我已把 #12 rebase 到最新 使用仓库锁定的 Node 24.13.1、npm 11.8.0 和 Rust 1.97.1, #12 现已转为 Ready。如果方便,烦请维护者批准来自 fork 的 CI workflow;它会在 Ubuntu、macOS 和 Windows 上运行 I rebased #12 onto the latest With the repository-pinned Node 24.13.1, npm 11.8.0, and Rust 1.97.1, #12 is now ready for review. When convenient, could a maintainer approve the workflow from this fork? It will run |
|
抱歉。我在使用 Agent 辅助调试 #12 时,没有正确限制验证环境,错误地把上游 PR Actions 用作了迭代测试,因此产生了多条不必要的 workflow runs。这是我的流程判断失误。 后续验证已转到我 fork 的 staging 分支,并已在那里通过完整矩阵。现在我已向 #12 推送一次清理后的提交序列:去除了 staging 专用触发器、诊断提交和重复历史,只保留实际修复与可重复验证所需的测试。上游的这一次 PR check 已在 Ubuntu、macOS 和 Windows 通过,#12 已转为 Ready for review。若还需后续定位,只会在 fork staging 中进行,再提交一次干净更新。 我没有权限删除上游 runs;如希望清理,拥有写权限的维护者可以在 Actions 页面删除。给你添麻烦了。 Sorry. While using an agent to help debug #12, I failed to constrain the validation environment correctly and mistakenly used upstream PR Actions for iterative testing. That created several unnecessary workflow runs, and it was a process mistake on my side. Validation then moved to a staging branch in my fork, where the full matrix passed. I have pushed one cleaned commit series to #12: staging-only triggers, diagnostic commits, and duplicate history were removed, while the actual fixes and reproducible verification coverage remain. This one upstream PR check has now passed on Ubuntu, macOS, and Windows, and #12 is ready for review. If anything needs further investigation, it will stay in fork staging until one clean follow-up is ready. I do not have permission to remove runs from the upstream repository. If you would like them removed, a maintainer with write access can delete them from the Actions page. Sorry for the extra noise. |
Keep Linux-gated launcher imports and Desktop session wiring from the PR, and take current main's update-notes and Host Runtime changes.
BytePioneer-AI
left a comment
There was a problem hiding this comment.
Summary
This is a substantial, carefully structured Linux x64 bring-up: official .deb/.rpm layout checks, /proc identity (PID + start time + executable), pidfd signaling without a PID-only fallback, takeover refusal, XDG-private runtime/state files, npm/CI/release wiring, and Gate A fixtures. Process ownership and launch supervision look intentionally conservative and are covered by focused tests. The dominant risk is the half-wired npm update path: Linux now advertises npm updates, but the launcher derives its update-state directory from the new XDG runtime descriptor location, so it never observes waiting-for-exit. Secondary review pressure is comment volume and a macOS force_stop_desktop refactor that now keys supervision off tree[0] after a PID sort.
Issue counts by severity
- bugs: 1
- suggestions: 2
- nits: 1
| release: CodexhostLatestRelease, | ||
| ): Promise<boolean> { | ||
| if (context.metadata.distribution === "npm") return true; | ||
| if (context.installation.kind === "npm") return true; |
There was a problem hiding this comment.
[bug] Linux npm updates are treated as installable (installation.kind === "npm" returns true; the following linux-x64 guard is dead for real Linux installs). The updater still writes waiting-for-exit under defaultUpdateStateDirectory() ($HOME/.codexhost/updates). The Linux launcher now publishes its runtime descriptor under XDG_RUNTIME_DIR/codexhost (or ~/.local/state/codexhost) and update_state_directory() is derived as that parent plus updates, so should_stop_desktop_for_update() in the new Linux supervise loop never sees the updater status. The helper is also never started on Linux (helper_started = false). Result: the Desktop stays up, the updater waits 180s for the launcher PID, then fails. The new CODEXHOST_RUNTIME_DESCRIPTOR_PATH would make post-relaunch probing work only after the launcher actually exits.
Suggestion: Either disable Linux npm updates until the path is finished (installable() false / start() error, matching the stated out-of-scope self-update), or point launcher update_state_directory() and defaultUpdateStateDirectory("linux") at one durable directory (prefer XDG_STATE_HOME/codexhost/updates, never the ephemeral XDG runtime dir) and cover the waiting-for-exit handshake with a Linux test.
| } | ||
| signal_processes_checked(&members, nix::sys::signal::Signal::SIGTERM)?; | ||
| let mut survivors = members; | ||
| let mut observed = ObservedProcessTree::new(tree[0].clone()); |
There was a problem hiding this comment.
[suggestion] macOS force_stop_desktop now builds ObservedProcessTree from tree[0] after desktop_process_tree sorts by PID. The first SIGTERM still covers every member, but the wait/SIGKILL loop only observes that one root. If tree[0] is a descendant (PID wrap / helper started with a lower PID) or one of several independent roots, survivors outside that subtree can be treated as gone and never receive SIGKILL. Previously the function waited on the full identity-checked member list.
Suggestion: Seed the observed tree from a real Desktop root (desktop_root_snapshots_for_installation / the group leader), or keep one observed tree per root, and wait/kill the original member set rather than tree[0] after a PID sort.
| .cloned() | ||
| .collect::<Vec<_>>() | ||
| }); | ||
| // The Linux managed-launch group is private when it is created, but a |
There was a problem hiding this comment.
[suggestion] This block (and the similar launch-loop comment in desktop_launch.rs) restates the PGID-versus-lineage design and architecture history. Comments in this change set often narrate WHY at essay length instead of naming the invariant.
Suggestion: Collapse to a one-line invariant, e.g. “same-PGID is not ownership; only the root instance and known descendants may be signaled.”
| ## Diagnosis | ||
|
|
||
| ```bash | ||
| codexhost inspect |
There was a problem hiding this comment.
[nit] The doc says shutdown signals are sent only after PID, start time, and executable identity are revalidated. signal_processes now checks same_process_instance (PID + start time) and explicitly does not require the executable to match, so descendants can exec. The Desktop root executable is checked in observe(), not at signal delivery.
Suggestion: Say signals revalidate PID + start time via pidfd, and that only the Desktop root’s executable is re-checked during observation.
Merge pull request #12 from XWIlluDelu/feat/linux-x64-solid
Route only external multi-select groups to an isolated card while preserving native single-choice and approval surfaces. Validate ownership, lifecycle and answers through the existing Host pending-question flow. Adapt the card, styles and polling foundation from karlorz/codex-host BytePioneer-AI#12 under LGPL-3.0-only, omitting Grok-specific timer and activity features. Co-authored-by: karlorz <[email protected]>
中文
这个 PR 为 CodexHost 增加 Linux x64 支持。我使用 Debian GNU/Linux 和官方 ChatGPT
.deb包完成了开发与实机测试。实机截图
下图是官方 ChatGPT App 在 Linux x64 上通过 CodexHost 使用 Pi 的实际界面。
截图只用于展示 GUI。同一请求也出现在 Pi 的 session 记录中,确认它确实路由到了 Pi。Gate A 另行验证了协议转发和进程生命周期。
支持范围
当前支持:
/usr/lib/chatgpt的官方 ChatGPT.deb或.rpm包/usr/bin/chatgpt启动器@codexhost/cli-linux-x64这个 PR 暂不包含 CodexHost 自己的 Linux installer 和 installer 自更新,也不支持 ARM64、Snap、Flatpak、AppImage、其他 ChatGPT 安装路径或没有
/proc的容器。实现
/proc中的 PID、启动时间和可执行文件确认进程身份pidfd发送信号,不在旧内核上退回到可能命中复用 PID 的做法如果发现一个独立运行的 ChatGPT App,CodexHost 会拒绝接管并提示用户先退出它。
测试
npm run checkcodexhost --version和codexhost inspect谢谢
感谢作者做出 CodexHost。让 Pi 和其他 Agent 直接复用 Codex GUI 这个想法真的很酷。
我自己在写 Pi 的 Web GUI,所以很喜欢 CodexHost 选择的这条不同路线。很高兴能贡献这次 Linux 支持。🤝
English
This PR adds Linux x64 support to CodexHost. I developed and tested it on Debian GNU/Linux with the official ChatGPT
.debpackage.Screenshot
The screenshot above shows the official ChatGPT App using Pi through CodexHost on Linux x64.
The screenshot is only a visual record of the GUI. The same request appears in the Pi session log, confirming that it was routed to Pi. Gate A separately validates protocol forwarding and process lifecycle behavior.
Supported setup
.debor.rpmpackage installed at/usr/lib/chatgpt/usr/bin/chatgptlauncher@codexhost/cli-linux-x64npm packageThis PR does not include a CodexHost Linux installer or installer self-update. ARM64, Snap, Flatpak, AppImage, alternate ChatGPT layouts, and containers without
/procare also outside its scope.Implementation
/procpidfdwithout falling back to a PID-only path on older kernelsCodexHost refuses to take over an independently running ChatGPT App and asks the user to quit it first.
Tests
npm run checkwith Node 24 and npm 11codexhost --version, andcodexhost inspectThanks
Thanks to the author for building CodexHost. Letting Pi and other agents reuse the Codex GUI is a really cool idea.
I am working on a Web GUI for Pi, so I enjoyed seeing CodexHost take a different route. I am glad to contribute the Linux support here. 🤝