Skip to content

fix(codex): ChatGPT 桌面版的 Codex 对话只显示一张卡 (#370) - #371

Merged
wxtsky merged 1 commit into
wxtsky:mainfrom
Junyu06:fix/codex-desktop-hook-bundle
Oct 11, 2026
Merged

wxtsky merged 1 commit into
wxtsky:mainfrom
Junyu06:fix/codex-desktop-hook-bundle

Conversation

@Junyu06

@Junyu06 Junyu06 commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #370

改了什么

  • bridge:Codex 的 hook 没带 bundle id 时,如果最近的 Codex 进程在跑 app-server,而且它的父进程是 com.openai.codex,就补上 _term_bundle = com.openai.codex,hook 事件于是落到桌面版那张卡上。判断写成纯函数 CLIProcessResolver.codexDesktopTermBundle(ancestry:)。
  • HookServer:所有桌面版对话共用同一个 app-server 进程,所以 codexNativeSubsessionParentId 对桌面版的 hook 不再按进程号找父对话。不然在合并模式下,父对话自己的 hook 会被当成它的子任务吞掉。

验证

  • 新增 6 个测试:5 个测判断规则,1 个测合并模式下父对话的 hook 不被吞。桌面版那几种情况和合并模式那一个,改之前都失败。全量 swift test 0 失败。
  • 开着 ChatGPT 桌面版新开一个 Codex 对话:1.0.35 上是两张卡,这个分支上是一张。

已知影响

合并模式下,子任务的 hook 如果比它的对话记录先到,就不再按进程号并到父对话下面,会先单独显示一张卡,等扫描到了再合并。这期间如果它有待审批的请求,现有的移除逻辑会把请求拒掉。以前带 bundle id 的桌面版 hook 本来就是这样。

🤖 Generated with Claude Code

ChatGPT starts Codex Desktop's app-server from
ChatGPT.app/Contents/Resources/codex-cli/CodexCLI.app without
__CFBundleIdentifier in its environment. The bridge learned the host
only from that variable, so Desktop hooks reached HookEvent without
_term_bundle and stayed under the raw thread id, while the state-DB
scan keyed the same thread as codexapp:<id>: two cards for one thread.

When neither the payload nor the environment names a bundle, check the
nearest Codex process in the hook's ancestry: if it runs the app-server
subcommand (after nothing but -c overrides, as Desktop starts it) and
its direct parent belongs to the com.openai.codex app, stamp that
bundle. The binary alone cannot decide this. Codex CLI started through
ChatGPT's codex-cli/bin/codex launcher and the app-server Claude Code's
Codex plugin starts run the same binary, and exec codex in ChatGPT's
own terminal also leaves ChatGPT as the parent. Everything else keeps
its current keying.

With Desktop hooks on their codexapp: card, the same-PID parent
fallback for native subagents must skip them: every Desktop thread
shares the one app-server, so under Merge a thread's own hook could
take its card (which a child hook left that PID on) for its parent and
fold into itself. Desktop children already find their parent from
rollout metadata.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@wxtsky
wxtsky merged commit cd39ddd into wxtsky:main Oct 11, 2026
@wxtsky

wxtsky commented Oct 11, 2026

Copy link
Copy Markdown
Owner

感谢 @Junyu06!已合入 main(cd39ddd),和 #369 一起随 v1.0.37 发布。本机 ChatGPT 26.1007 的 app-server 启动参数(-c features.code_mode_host=true app-server)和 CodexCLI.app 的位置都与 PR 里的判断一致。

vxiaofengs pushed a commit to vxiaofengs/CodeIsland that referenced this pull request Oct 12, 2026
Five upstream commits across v1.0.37 and v1.0.38, all Codex: finding the
binary newer ChatGPT builds bundle, keying Desktop app-server hooks
without a bundle id (wxtsky#371), and keeping other app-server clients' threads
out of Desktop discovery (wxtsky#369). No conflicts; none of it touches the
panel, approval or jump code this branch carries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
RooobinYe added a commit to RooobinYe/CodeIsland that referenced this pull request Oct 14, 2026
* fix(codex): keep other app-server clients' threads out of Desktop discovery (wxtsky#369)

Fixes wxtsky#368

(cherry picked from commit 5394c2e)

* fix(codex): key Desktop app-server hooks as Desktop without a bundle id (wxtsky#371)

Fixes wxtsky#370

(cherry picked from commit cd39ddd)

* fix(codex): find the Codex binary newer ChatGPT builds bundle

ChatGPT moved Codex from Contents/Resources/codex to
Contents/Resources/codex-cli/CodexCLI.app/Contents/MacOS/codex. The
process scan never found Desktop's app-server there, so Desktop threads
were never read from state_5.sqlite, and the app-server client could not
start at all.

The same binary also runs Codex CLI, ChatGPT's cloud exec-server and
CodeIsland's own app-server client, so the process is classified by argv
and parent: the app-server ChatGPT starts is the Desktop host, helpers
and our own child are skipped, anything else is a CLI session process.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 9905070)

---------

Co-authored-by: Terry Li <[email protected]>
Co-authored-by: wxtsky <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ChatGPT 桌面版里的 Codex 对话,刘海上显示两张卡

2 participants