Skip to content

fix(desktop): complete Renderer connection and external draft routing - #663

Merged
BytePioneer-AI merged 5 commits into
BytePioneer-AI:mainfrom
BeiLuoqu:fix/desktop-26.1027-renderer-harness-routing
Oct 31, 2026
Merged

BytePioneer-AI merged 5 commits into
BytePioneer-AI:mainfrom
BeiLuoqu:fix/desktop-26.1027-renderer-harness-routing

Conversation

@BeiLuoqu

@BeiLuoqu BeiLuoqu commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

补齐 #660 合入后的 Renderer 连接与外部草稿路由,覆盖三个问题:

  • 适配器持续“安装中”:旧 Renderer 注册表可能仍挂载,但没有可用 Manager。先确认旧路径确实可用,否则释放临时路由并尝试已识别的主进程 RPC;保留可用的旧版路径。
  • 外部草稿选择身份缺失:先登记选择,再写草稿模型,避免同步渲染读取空/旧选择。策略拒绝时不写入;setter 失败时把当前草稿的选择恢复为它实际携带的 carrier,不影响其他草稿。
  • 官方目录过滤外部 Model 后无法启动 Harness:沿用 fix: 适配 Desktop 26.1027 主进程 Manager(验收中) #660 按 clientThreadId 转发 carrier 的基础能力,增加 Adapter→草稿 setter→RPC 帧的组合回归;补充冲突保护,明确指定另一个外部 carrier 的创建和预热请求保持原样。

新增集成回归分别覆盖 Claude Code、Antigravity、DeepSeek Harness 和 Pi。保留输入、cwd、Thinking、原生回调和传输参数,不修改原始模式对象。同步更新官方流量归属文档。

主进程发现和目录回退的基础实现来自已合入的 #660,本 PR 不重复计为新增实现。没有加入官方应用包、本机安装脚本、账号配置或运行日志。

Related issues

Follow-up to #660。目标分支 main,基线 de7b58a(0.16.1 版本准备)。

Test plan

Windows x64 / Node.js 24.22.1,独立源码工作区:

  • npm run build:typescript、npm run typecheck、npm run lint、npm run build:renderer:通过;最后连接探测调整后重新检查修改文件 ESLint,通过。
  • 聚焦 Vitest:12 文件 / 186 项通过,覆盖 CDP 安装、RPC 路由、已加载模块、Host 路由、草稿预热策略、Adapter→RPC 集成、选择时序、原生适配器、Controller 契约、Host 预热与 protocol model routing。
  • renderer-adapter-lifecycle.spec.ts:24 项 Playwright 回归通过,使用已有 Chromium。
  • 修改文件 Prettier、git diff --check、pre-commit:通过。
  • 追加提交 8a83f17:setter 拒绝写入时恢复草稿原有选择(原实现会清空已有的外部选择),以及创建参数缺少 Model 时仍为已登记的外部草稿写入 carrier。packages/desktop-control、packages/renderer-extension 共 1170 项测试通过;两项修复去掉后对应新测试失败。
  • 前后对照:旧代码的选择时序、setter 异常清理、不可用注册表阻塞 RPC 和冲突 carrier 覆盖用例均先失败,修复后通过。

上述测试对应功能提交 63def0c。提交前合入上游 de7b58a,仅修改 Cargo/npm 版本元数据;功能代码未变,没有为此重复运行同一测试矩阵。

验证边界:组合测试执行真实 Controller 注入表达式、Adapter、草稿绑定/写入和 RPC 重写;scope store、模型过滤后的原生模式及 MessagePort 端点为离线夹具。不是最终构建产物的 Electron/登录/真实提供方实机验收。历史上本机另一兼容补丁已由用户确认回复正常,但其实现不同,不能替代本 PR 实机验收。

本轮未部署、重启或刷新用户应用。macOS/Linux、真实 SSH/Remote Control、多窗口及新版共享预热池完整隔离未实机验证;未跑全量矩阵或 Rust 检查,本次无 Rust 改动。上述未实机验证的范围如有需要,请在评审中指出。

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between de7b58a and 8a83f17.

Files selected for processing: 8
  • docs/architecture/official-traffic-ownership.md
  • packages/desktop-control/src/renderer-draft-prewarm-policy.ts
  • packages/desktop-control/src/renderer-host-rpc-routing.ts
  • packages/desktop-control/src/renderer-scoped-draft-model.ts
  • packages/desktop-control/test/renderer-host-rpc-routing.test.ts
  • packages/renderer-extension/src/versioned-renderer-adapter.ts
  • packages/renderer-extension/test/draft-selection-order.test.ts
  • packages/renderer-extension/test/renderer-main-process-draft.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.

Recent review details
CI failures not shown inline: 8

GitHub Actions: CI / 0_Check macos-14.txt: fix(desktop): complete Renderer connection and external draft routing

Conclusion: failure

View job details

##[group]Run cargo clippy --workspace --all-targets --locked --features codexhost-shim/test-utils,codexhost-gate-a-native/gate-tools -- -D warnings && npm run test:rust
 �[36;1mcargo clippy --workspace --all-targets --locked --features codexhost-shim/test-utils,codexhost-gate-a-native/gate-tools -- -D warnings && npm run test:rust�[0m
 shell: /bin/bash -e {0}
 env:
   CARGO_INCREMENTAL: 0
   CARGO_PROFILE_DEV_DEBUG: 0
   CARGO_PROFILE_TEST_DEBUG: 0
   CARGO_HOME: /Users/runner/.cargo
   CARGO_TERM_COLOR: always
   CACHE_ON_FAILURE: false
 ##[endgroup]
 �[1m�[92m    Updating�[0m crates.io index
 �[1m�[92m    Checking�[0m codexhost-platform v0.16.1 (/Users/runner/work/codex-host/codex-host/crates/platform)
 �[1m�[92m   Compiling�[0m codexhost-launcher v0.16.1 (/Users/runner/work/codex-host/codex-host/crates/launcher)
 �[1m�[92m    Checking�[0m codexhost-shim v0.16.1 (/Users/runner/work/codex-host/codex-host/crates/shim)
 �[1m�[92m    Checking�[0m codexhost-gate-a-native v0.16.1 (/Users/runner/work/codex-host/codex-host/tools/gate-a/native)
 �[1m�[92m    Checking�[0m codexhost-updater v0.16.1 (/Users/runner/work/codex-host/codex-host/crates/updater)
 �[1m�[92m    Finished�[0m `dev` profile [unoptimized] target(s) in 7.70s
 > [email protected] test:rust
 > cargo test --workspace --locked --features codexhost-shim/test-utils,codexhost-gate-a-native/gate-tools
 �[1m�[92m   Compiling�[0m codexhost-platform v0.16.1 (/Users/runner/work/codex-host/codex-host/crates/platform)
 �[1m�[92m   Compiling�[0m codexhost-launcher v0.16.1 (/Users/runner/work/codex-host/codex-host/crates/launcher)
 �[1m�[92m   Compiling�[0m codexhost-shim v0.16.1 (/Users/runner/work/codex-host/codex-host/crates/shim)
 �[1m�[92m   Compiling�[0m codexhost-gate-a-native v0.16.1 (/Users/runner/work/codex-host/codex-host/tools/gate-a/native)
 �[1m�[92m   Compiling�[0m codexhost-updater v0.16.1 (/Users/runner/work/codex-host/codex-host/crates/updater)
 �[1m�[92m    Finished�[0m `test` profile [unoptimized] t...

GitHub Actions: CI / Check macos-14: fix(desktop): complete Renderer connection and external draft routing

Conclusion: failure

View job details

##[group]Run cargo clippy --workspace --all-targets --locked --features codexhost-shim/test-utils,codexhost-gate-a-native/gate-tools -- -D warnings && npm run test:rust
 �[36;1mcargo clippy --workspace --all-targets --locked --features codexhost-shim/test-utils,codexhost-gate-a-native/gate-tools -- -D warnings && npm run test:rust�[0m
 shell: /bin/bash -e {0}
 env:
   CARGO_INCREMENTAL: 0
   CARGO_PROFILE_DEV_DEBUG: 0
   CARGO_PROFILE_TEST_DEBUG: 0
   CARGO_HOME: /Users/runner/.cargo
   CARGO_TERM_COLOR: always
   CACHE_ON_FAILURE: false
 ##[endgroup]
 �[1m�[92m    Updating�[0m crates.io index
 �[1m�[92m    Checking�[0m codexhost-platform v0.16.1 (/Users/runner/work/codex-host/codex-host/crates/platform)
 �[1m�[92m   Compiling�[0m codexhost-launcher v0.16.1 (/Users/runner/work/codex-host/codex-host/crates/launcher)
 �[1m�[92m    Checking�[0m codexhost-shim v0.16.1 (/Users/runner/work/codex-host/codex-host/crates/shim)
 �[1m�[92m    Checking�[0m codexhost-gate-a-native v0.16.1 (/Users/runner/work/codex-host/codex-host/tools/gate-a/native)
 �[1m�[92m    Checking�[0m codexhost-updater v0.16.1 (/Users/runner/work/codex-host/codex-host/crates/updater)
 �[1m�[92m    Finished�[0m `dev` profile [unoptimized] target(s) in 7.70s
 > [email protected] test:rust
 > cargo test --workspace --locked --features codexhost-shim/test-utils,codexhost-gate-a-native/gate-tools
 �[1m�[92m   Compiling�[0m codexhost-platform v0.16.1 (/Users/runner/work/codex-host/codex-host/crates/platform)
 �[1m�[92m   Compiling�[0m codexhost-launcher v0.16.1 (/Users/runner/work/codex-host/codex-host/crates/launcher)
 �[1m�[92m   Compiling�[0m codexhost-shim v0.16.1 (/Users/runner/work/codex-host/codex-host/crates/shim)
 �[1m�[92m   Compiling�[0m codexhost-gate-a-native v0.16.1 (/Users/runner/work/codex-host/codex-host/tools/gate-a/native)
 �[1m�[92m   Compiling�[0m codexhost-updater v0.16.1 (/Users/runner/work/codex-host/codex-host/crates/updater)
 �[1m�[92m    Finished�[0m `test` profile [unoptimized] t...

GitHub Actions: CI / 1_Check windows-latest.txt: fix(desktop): complete Renderer connection and external draft routing

Conclusion: failure

View job details

##[group]Run cargo clippy --workspace --all-targets --locked --features codexhost-shim/test-utils,codexhost-gate-a-native/gate-tools -- -D warnings && npm run test:rust
 �[36;1mcargo clippy --workspace --all-targets --locked --features codexhost-shim/test-utils,codexhost-gate-a-native/gate-tools -- -D warnings && npm run test:rust�[0m
 shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
 env:
   CARGO_INCREMENTAL: 0
   CARGO_PROFILE_DEV_DEBUG: 0
   CARGO_PROFILE_TEST_DEBUG: 0
   CARGO_HOME: C:\Users\runneradmin\.cargo
   CARGO_TERM_COLOR: always
   CACHE_ON_FAILURE: false
 ##[endgroup]
 �[1m�[92m    Updating�[0m crates.io index
 �[1m�[92m    Checking�[0m codexhost-platform v0.16.1 (D:\a\codex-host\codex-host\crates\platform)
 �[1m�[92m   Compiling�[0m codexhost-launcher v0.16.1 (D:\a\codex-host\codex-host\crates\launcher)
 �[1m�[92m    Checking�[0m codexhost-shim v0.16.1 (D:\a\codex-host\codex-host\crates\shim)
 �[1m�[92m    Checking�[0m codexhost-updater v0.16.1 (D:\a\codex-host\codex-host\crates\updater)
 �[1m�[92m    Checking�[0m codexhost-gate-a-native v0.16.1 (D:\a\codex-host\codex-host\tools\gate-a\native)
 �[1m�[92m    Finished�[0m `dev` profile [unoptimized] target(s) in 5.96s
 > [email protected] test:rust
 > cargo test --workspace --locked --features codexhost-shim/test-utils,codexhost-gate-a-native/gate-tools
 �[1m�[92m   Compiling�[0m codexhost-platform v0.16.1 (D:\a\codex-host\codex-host\crates\platform)
 �[1m�[92m   Compiling�[0m codexhost-launcher v0.16.1 (D:\a\codex-host\codex-host\crates\launcher)
 �[1m�[92m   Compiling�[0m codexhost-shim v0.16.1 (D:\a\codex-host\codex-host\crates\shim)
 �[1m�[92m   Compiling�[0m codexhost-gate-a-native v0.16.1 (D:\a\codex-host\codex-host\tools\gate-a\native)
 �[1m�[92m   Compiling�[0m codexhost-updater v0.16.1 (D:\a\codex-host\codex-host\crates\updater)
 �[1m�[92m    Finished�[0m `test` profile [unoptimized] target(s) in 4.28s
 �[1m�[92m     Running�[0m unittests src\lib.rs (target\debug\deps\codexho...

GitHub Actions: CI / Check windows-latest: fix(desktop): complete Renderer connection and external draft routing

Conclusion: failure

View job details

##[group]Run cargo clippy --workspace --all-targets --locked --features codexhost-shim/test-utils,codexhost-gate-a-native/gate-tools -- -D warnings && npm run test:rust
 �[36;1mcargo clippy --workspace --all-targets --locked --features codexhost-shim/test-utils,codexhost-gate-a-native/gate-tools -- -D warnings && npm run test:rust�[0m
 shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
 env:
   CARGO_INCREMENTAL: 0
   CARGO_PROFILE_DEV_DEBUG: 0
   CARGO_PROFILE_TEST_DEBUG: 0
   CARGO_HOME: C:\Users\runneradmin\.cargo
   CARGO_TERM_COLOR: always
   CACHE_ON_FAILURE: false
 ##[endgroup]
 �[1m�[92m    Updating�[0m crates.io index
 �[1m�[92m    Checking�[0m codexhost-platform v0.16.1 (D:\a\codex-host\codex-host\crates\platform)
 �[1m�[92m   Compiling�[0m codexhost-launcher v0.16.1 (D:\a\codex-host\codex-host\crates\launcher)
 �[1m�[92m    Checking�[0m codexhost-shim v0.16.1 (D:\a\codex-host\codex-host\crates\shim)
 �[1m�[92m    Checking�[0m codexhost-updater v0.16.1 (D:\a\codex-host\codex-host\crates\updater)
 �[1m�[92m    Checking�[0m codexhost-gate-a-native v0.16.1 (D:\a\codex-host\codex-host\tools\gate-a\native)
 �[1m�[92m    Finished�[0m `dev` profile [unoptimized] target(s) in 5.96s
 > [email protected] test:rust
 > cargo test --workspace --locked --features codexhost-shim/test-utils,codexhost-gate-a-native/gate-tools
 �[1m�[92m   Compiling�[0m codexhost-platform v0.16.1 (D:\a\codex-host\codex-host\crates\platform)
 �[1m�[92m   Compiling�[0m codexhost-launcher v0.16.1 (D:\a\codex-host\codex-host\crates\launcher)
 �[1m�[92m   Compiling�[0m codexhost-shim v0.16.1 (D:\a\codex-host\codex-host\crates\shim)
 �[1m�[92m   Compiling�[0m codexhost-gate-a-native v0.16.1 (D:\a\codex-host\codex-host\tools\gate-a\native)
 �[1m�[92m   Compiling�[0m codexhost-updater v0.16.1 (D:\a\codex-host\codex-host\crates\updater)
 �[1m�[92m    Finished�[0m `test` profile [unoptimized] target(s) in 4.28s
 �[1m�[92m     Running�[0m unittests src\lib.rs (target\debug\deps\codexho...

GitHub Actions: CI / 2_Check ubuntu-22.04.txt: fix(desktop): complete Renderer connection and external draft routing

Conclusion: failure

View job details

eserves the explicit codebuddy command rather than finding another local installation �[33m 606�[2mms�[22m�[39m
      �[33m�[2m✓�[22m�[39m preserves the explicit workbuddy command rather than finding another local installation �[33m 607�[2mms�[22m�[39m
      �[33m�[2m✓�[22m�[39m preserves the explicit cursor-cli command rather than finding another local installation �[33m 520�[2mms�[22m�[39m
      �[33m�[2m✓�[22m�[39m preserves the explicit hermes command rather than finding another local installation �[33m 633�[2mms�[22m�[39m
      �[33m�[2m✓�[22m�[39m preserves the explicit qoder command rather than finding another local installation �[33m 537�[2mms�[22m�[39m
      �[33m�[2m✓�[22m�[39m preserves the explicit qoder-cn command rather than finding another local installation �[33m 974�[2mms�[22m�[39m
      �[33m�[2m✓�[22m�[39m keeps managed macOS execution behind the plugin's Broker with no direct CLI fallback �[33m 588�[2mms�[22m�[39m
      �[33m�[2m✓�[22m�[39m creates independent instances for concurrent Host connections �[33m 829�[2mms�[22m�[39m
  �[32m✓�[39m tests/release/packagers.test.mjs �[2m(�[22m�[2m4 tests�[22m�[2m)�[22m�[32m 30�[2mms�[22m�[39m
  �[32m✓�[39m packages/adapters/grok/test/grok-questions.test.ts �[2m(�[22m�[2m24 tests�[22m�[2m)�[22m�[32m 26�[2mms�[22m�[39m
  �[32m✓�[39m packages/adapters/deepseek-harness/test/modern/fork-inbox.test.ts �[2m(�[22m�[2m25 tests�[22m�[2m)�[22m�[32m 30�[2mms�[22m�[39m
  �[2m�[90m↓�[39m�[22m packages/adapters/hermes/test/gateway-managed-runtime.test.ts �[2m(�[22m�[2m1 test�[22m�[2m | �[22m�[33m1 skipped�[39m�[2m)�[22m
  �[32m✓�[39m packages/adapters/copilot/test/projection.test.ts �[2m(�[22m�[2m10 tests�[22m�[2m)�[22m�[32m 29�[2mms�[22m�[39m
  �[32m✓�[39m packages/host-runtime/test/app-server-host.questions.test.ts �[2m(�[22m�[2m9 tests�[22m�[2m)�[22m�[33m 951�[2mms�[22m�[39m
      �[33m�[2m✓�[22m�[39m honors Host expiry without emitting a native server-request resolution �[33m 532�[2mms�[22m�[39m
  �[32m✓�[39m pack...

GitHub Actions: CI / Check ubuntu-22.04: fix(desktop): complete Renderer connection and external draft routing

Conclusion: failure

View job details

eserves the explicit codebuddy command rather than finding another local installation �[33m 606�[2mms�[22m�[39m
      �[33m�[2m✓�[22m�[39m preserves the explicit workbuddy command rather than finding another local installation �[33m 607�[2mms�[22m�[39m
      �[33m�[2m✓�[22m�[39m preserves the explicit cursor-cli command rather than finding another local installation �[33m 520�[2mms�[22m�[39m
      �[33m�[2m✓�[22m�[39m preserves the explicit hermes command rather than finding another local installation �[33m 633�[2mms�[22m�[39m
      �[33m�[2m✓�[22m�[39m preserves the explicit qoder command rather than finding another local installation �[33m 537�[2mms�[22m�[39m
      �[33m�[2m✓�[22m�[39m preserves the explicit qoder-cn command rather than finding another local installation �[33m 974�[2mms�[22m�[39m
      �[33m�[2m✓�[22m�[39m keeps managed macOS execution behind the plugin's Broker with no direct CLI fallback �[33m 588�[2mms�[22m�[39m
      �[33m�[2m✓�[22m�[39m creates independent instances for concurrent Host connections �[33m 829�[2mms�[22m�[39m
  �[32m✓�[39m tests/release/packagers.test.mjs �[2m(�[22m�[2m4 tests�[22m�[2m)�[22m�[32m 30�[2mms�[22m�[39m
  �[32m✓�[39m packages/adapters/grok/test/grok-questions.test.ts �[2m(�[22m�[2m24 tests�[22m�[2m)�[22m�[32m 26�[2mms�[22m�[39m
  �[32m✓�[39m packages/adapters/deepseek-harness/test/modern/fork-inbox.test.ts �[2m(�[22m�[2m25 tests�[22m�[2m)�[22m�[32m 30�[2mms�[22m�[39m
  �[2m�[90m↓�[39m�[22m packages/adapters/hermes/test/gateway-managed-runtime.test.ts �[2m(�[22m�[2m1 test�[22m�[2m | �[22m�[33m1 skipped�[39m�[2m)�[22m
  �[32m✓�[39m packages/adapters/copilot/test/projection.test.ts �[2m(�[22m�[2m10 tests�[22m�[2m)�[22m�[32m 29�[2mms�[22m�[39m
  �[32m✓�[39m packages/host-runtime/test/app-server-host.questions.test.ts �[2m(�[22m�[2m9 tests�[22m�[2m)�[22m�[33m 951�[2mms�[22m�[39m
      �[33m�[2m✓�[22m�[39m honors Host expiry without emitting a native server-request resolution �[33m 532�[2mms�[22m�[39m
  �[32m✓�[39m pack...

GitHub Actions: CI / 3_Check Linux ARM64.txt: fix(desktop): complete Renderer connection and external draft routing

Conclusion: failure

View job details

##[group]Run cargo clippy --workspace --all-targets --locked --features codexhost-shim/test-utils,codexhost-gate-a-native/gate-tools -- -D warnings && npm run test:rust
 �[36;1mcargo clippy --workspace --all-targets --locked --features codexhost-shim/test-utils,codexhost-gate-a-native/gate-tools -- -D warnings && npm run test:rust�[0m
 shell: /usr/bin/bash -e {0}
 env:
   CARGO_INCREMENTAL: 0
   CARGO_PROFILE_DEV_DEBUG: 0
   CARGO_PROFILE_TEST_DEBUG: 0
   CARGO_HOME: /home/runner/.cargo
   CARGO_TERM_COLOR: always
   CACHE_ON_FAILURE: false
 ##[endgroup]
 �[1m�[92m    Updating�[0m crates.io index
 �[1m�[92m    Checking�[0m codexhost-platform v0.16.1 (/home/runner/work/codex-host/codex-host/crates/platform)
 �[1m�[92m   Compiling�[0m codexhost-launcher v0.16.1 (/home/runner/work/codex-host/codex-host/crates/launcher)
 �[1m�[92m    Checking�[0m codexhost-shim v0.16.1 (/home/runner/work/codex-host/codex-host/crates/shim)
 �[1m�[92m    Checking�[0m codexhost-gate-a-native v0.16.1 (/home/runner/work/codex-host/codex-host/tools/gate-a/native)
 �[1m�[92m    Checking�[0m codexhost-updater v0.16.1 (/home/runner/work/codex-host/codex-host/crates/updater)
 �[1m�[92m    Finished�[0m `dev` profile [unoptimized] target(s) in 1.54s
 > [email protected] test:rust
 > cargo test --workspace --locked --features codexhost-shim/test-utils,codexhost-gate-a-native/gate-tools
 �[1m�[92m   Compiling�[0m codexhost-platform v0.16.1 (/home/runner/work/codex-host/codex-host/crates/platform)
 �[1m�[92m   Compiling�[0m codexhost-launcher v0.16.1 (/home/runner/work/codex-host/codex-host/crates/launcher)
 �[1m�[92m   Compiling�[0m codexhost-shim v0.16.1 (/home/runner/work/codex-host/codex-host/crates/shim)
 �[1m�[92m   Compiling�[0m codexhost-gate-a-native v0.16.1 (/home/runner/work/codex-host/codex-host/tools/gate-a/native)
 �[1m�[92m   Compiling�[0m codexhost-updater v0.16.1 (/home/runner/work/codex-host/codex-host/crates/updater)
 �[1m�[92m    Finished�[0m `test` profile [unoptimized] target(s...

GitHub Actions: CI / Check Linux ARM64: fix(desktop): complete Renderer connection and external draft routing

Conclusion: failure

View job details

##[group]Run cargo clippy --workspace --all-targets --locked --features codexhost-shim/test-utils,codexhost-gate-a-native/gate-tools -- -D warnings && npm run test:rust
 �[36;1mcargo clippy --workspace --all-targets --locked --features codexhost-shim/test-utils,codexhost-gate-a-native/gate-tools -- -D warnings && npm run test:rust�[0m
 shell: /usr/bin/bash -e {0}
 env:
   CARGO_INCREMENTAL: 0
   CARGO_PROFILE_DEV_DEBUG: 0
   CARGO_PROFILE_TEST_DEBUG: 0
   CARGO_HOME: /home/runner/.cargo
   CARGO_TERM_COLOR: always
   CACHE_ON_FAILURE: false
 ##[endgroup]
 �[1m�[92m    Updating�[0m crates.io index
 �[1m�[92m    Checking�[0m codexhost-platform v0.16.1 (/home/runner/work/codex-host/codex-host/crates/platform)
 �[1m�[92m   Compiling�[0m codexhost-launcher v0.16.1 (/home/runner/work/codex-host/codex-host/crates/launcher)
 �[1m�[92m    Checking�[0m codexhost-shim v0.16.1 (/home/runner/work/codex-host/codex-host/crates/shim)
 �[1m�[92m    Checking�[0m codexhost-gate-a-native v0.16.1 (/home/runner/work/codex-host/codex-host/tools/gate-a/native)
 �[1m�[92m    Checking�[0m codexhost-updater v0.16.1 (/home/runner/work/codex-host/codex-host/crates/updater)
 �[1m�[92m    Finished�[0m `dev` profile [unoptimized] target(s) in 1.54s
 > [email protected] test:rust
 > cargo test --workspace --locked --features codexhost-shim/test-utils,codexhost-gate-a-native/gate-tools
 �[1m�[92m   Compiling�[0m codexhost-platform v0.16.1 (/home/runner/work/codex-host/codex-host/crates/platform)
 �[1m�[92m   Compiling�[0m codexhost-launcher v0.16.1 (/home/runner/work/codex-host/codex-host/crates/launcher)
 �[1m�[92m   Compiling�[0m codexhost-shim v0.16.1 (/home/runner/work/codex-host/codex-host/crates/shim)
 �[1m�[92m   Compiling�[0m codexhost-gate-a-native v0.16.1 (/home/runner/work/codex-host/codex-host/tools/gate-a/native)
 �[1m�[92m   Compiling�[0m codexhost-updater v0.16.1 (/home/runner/work/codex-host/codex-host/crates/updater)
 �[1m�[92m    Finished�[0m `test` profile [unoptimized] target(s...
Additional context used
Code guidelines: 1
AGENTS.md — auto-discovered
Path-based instructions: 1
Source excerpt: `codexhost` runs external Agent Harnesses as independent Threads inside Codex Desktop, preserving the official shell and native Codex path.

CodeRabbit inference engine (AGENTS.md)

Files:

  • packages/desktop-control/src/renderer-host-rpc-routing.ts
  • packages/desktop-control/src/renderer-scoped-draft-model.ts
  • packages/renderer-extension/src/versioned-renderer-adapter.ts
  • packages/renderer-extension/test/renderer-main-process-draft.test.ts
  • packages/renderer-extension/test/draft-selection-order.test.ts
  • docs/architecture/official-traffic-ownership.md
  • packages/desktop-control/src/renderer-draft-prewarm-policy.ts
  • packages/desktop-control/test/renderer-host-rpc-routing.test.ts
Learnings: 1
Common learnings
Learnt from: CR
Repo: BytePioneer-AI/codex-host PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-10-23T15:37:32.051Z
Learning: Applies to ** : Source excerpt:
# Repository Guidelines

## Testing & Completion

- Small, low-risk changes do not require tests. For high-risk or cross-package changes, or when explicitly requested, add focused tests for changed behavior and boundary conditions; do not run full test suites by default.
OpenGrep (1.30.2)
packages/renderer-extension/test/renderer-main-process-draft.test.ts

[ERROR] 112-112: new Function() with dynamic input can execute arbitrary code. Avoid dynamic code evaluation entirely, or use a safe alternative.

(coderabbit.code-injection.new-function-js)

Additional comments: 8
docs/architecture/official-traffic-ownership.md: 1

20-24: LGTM!

packages/renderer-extension/src/versioned-renderer-adapter.ts: 1

1097-1111: LGTM!

packages/renderer-extension/test/draft-selection-order.test.ts: 1

1-179: LGTM!

packages/desktop-control/src/renderer-draft-prewarm-policy.ts: 1

66-88: LGTM!

packages/desktop-control/test/renderer-host-rpc-routing.test.ts: 1

22-27: LGTM!

Also applies to: 81-90, 328-417

packages/desktop-control/src/renderer-scoped-draft-model.ts: 1

142-145: LGTM!

packages/desktop-control/src/renderer-host-rpc-routing.ts: 1

113-128: LGTM!

packages/renderer-extension/test/renderer-main-process-draft.test.ts: 1

1-165: LGTM!

📝 Summary

Summary by CodeRabbit

  • 功能改进

    • 切换代理时,草稿模型与当前选择保持同步;切回原生模型时会清除对应选择。
    • 桌面端创建对话时,可按已登记草稿使用所选外部模型,同时保留其他创建参数及明确指定的模型。
    • 原生管理器不可用时,可尝试通过主进程连接处理请求。
  • 问题修复

    • 模型选择或草稿写入失败时,会恢复先前选择;未能恢复时清除本次选择,避免草稿与选择状态不一致。
    • 预热请求不会覆盖明确指定的其他外部模型。

本次变更调整 Renderer 草稿的模型选择与写入顺序,并改进 Desktop 26.1027 的 Manager 连接发现和 RPC 回退。创建请求和预热请求会依据已登记的草稿及所选模型决定是否写入外部 carrier。

Changes: Renderer 草稿与路由

Layer / File(s) Summary
草稿选择与写入恢复
docs/architecture/official-traffic-ownership.md, packages/renderer-extension/src/versioned-renderer-adapter.ts, packages/renderer-extension/test/draft-selection-order.test.ts
applyAgent 先选择目标模型,再写入草稿。写入失败时尝试恢复该草稿写入前的模型选择。测试覆盖本地和远程 SSH 主机、策略拒绝及写入失败。
原生 Manager 检查与 RPC 回退
docs/architecture/official-traffic-ownership.md, packages/desktop-control/src/renderer-draft-prewarm-policy.ts, packages/desktop-control/test/renderer-host-rpc-routing.test.ts
路由安装会检查原生 Manager 是否已连接。若注册表可见但没有可用 Manager,则释放原生路由并尝试主进程 RPC。测试覆盖该回退路径。
创建请求的 carrier 路由
docs/architecture/official-traffic-ownership.md, packages/desktop-control/src/renderer-scoped-draft-model.ts, packages/desktop-control/src/renderer-host-rpc-routing.ts, packages/desktop-control/test/renderer-host-rpc-routing.test.ts, packages/renderer-extension/test/renderer-main-process-draft.test.ts
新增读取指定草稿模型的方法。RPC 创建路由保留原生模型,并依据已登记草稿、原生模型和所选模型决定是否写入 carrier。测试覆盖请求改写条件、预热模型标记和主进程请求参数保留。

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related issues

  • BytePioneer-AI/codex-host#658:报告 Renderer Host request manager unavailable;本次变更增加 Manager 可用性检查和主进程 RPC 回退。
  • BytePioneer-AI/codex-host#659:报告相同的 Renderer Host request manager unavailable 状态;本次变更处理了原生路由不可用时的回退。
  • BytePioneer-AI/codex-host#591:报告 Renderer Host request manager unavailable;本次变更涉及同一连接失败路径。
  • BytePioneer-AI/codex-host#656:该问题涉及活动对话切换渠道;本次变更修改草稿的模型选择和失败恢复,但不等同于完整实现该功能。

Possibly related PRs

  • BytePioneer-AI/codex-host#660:涉及 Desktop 26.1027 的 Manager RPC 发现与 carrier 转发;本次变更完善原生路由不可用时的释放和回退。
  • BytePioneer-AI/codex-host#630:建立外部 Harness 草稿模型写入、预热隔离和创建路由;本次变更修改同一草稿模型与 carrier 数据流。
  • BytePioneer-AI/codex-host#589:涉及 Renderer 草稿路由策略和模型提交顺序;本次变更补充选择失败和草稿写入失败时的恢复处理。

Suggested reviewers: bytepioneer-ai

Merge Risk: Minimal · up to 8a83f

No identified issue blocks merging; normal validation remains appropriate.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed 标题明确概括了 Renderer 连接处理和外部草稿路由这两个主要变更,内容与变更集一致且简洁。
Description check Passed 描述详细说明了 Renderer 连接、草稿选择时序、外部 carrier 路由、回归测试和验证范围,内容与变更集相关。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…oute Model-less creations

If the native draft setter rejected a change, the adapter cleared the
draft's selection even when the draft still carried an earlier external
carrier; the next send then failed with a missing selection identity.
Restore the selection the draft actually carries instead.

The RPC route also stopped rewriting a registered external draft whose
creation carried no native Model, which could start that Thread as a
Codex conversation. Write the carrier in that case too; an explicit
different external carrier is still left untouched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@BeiLuoqu
BeiLuoqu marked this pull request as ready for review October 30, 2026 10:21
@BytePioneer-AI

Copy link
Copy Markdown
Owner

审查意见(基线 de7b58ab → head 8a83f178)

整体方向没问题,也没有发现新增的跨包依赖、Rust 所有权或 Renderer 导入边界违规。以下 2 个 P2 建议合并前处理。复现均为对 PR 源码的内存执行,未做 Desktop 实机验证。

1. P2:冲突预热请求丢失预热生命周期标记

位置:packages/desktop-control/src/renderer-host-rpc-routing.ts:127–128

当前选择为 Claude Code,而预热请求显式携带另一个未标记的 Pi carrier 时,新增的冲突保护直接返回原消息,跳过了 prewarmCarrier()。出站 carrier 解码结果只有 { harnessId: "pi" },没有 prewarm: true。

影响:Host 把它当成普通 Thread 创建。app-server-host.ts:4082–4083 依赖该标记识别主进程预热,:4139–4162 因而可能提前持久化并发布空 Thread,且不登记为可丢弃的预热。

建议:保留该请求显式指定的 Harness/Model,同时正确标记预热。测试也应断言 Host 解码后的结果,而不只是断言消息原样保留。

2. P2:setter 失败污染 writer,后续回滚恢复到未提交的 carrier

位置:packages/desktop-control/src/renderer-scoped-draft-model.ts:143–144、packages/renderer-extension/src/versioned-renderer-adapter.ts:1098–1105

回滚从 draftModels.model() 取“原值”,但 writer 在 updater 内就更新了 captured(:152–154),没有等 setter 成功返回。

复现(真实 Adapter + writer,setter 先求值 updater 再拒绝提交):

  1. 草稿成功选择 A;
  2. 写入 B 失败:草稿仍是 A,writer 已记录 B;
  3. 再写入 C 失败:回滚选择变成 B,实际草稿仍是 A。

在官方目录过滤 carrier 的路径上,随后创建 Thread 可能采用未成功选中的 Model。

说明:尚未证明真实 Desktop 的 setter 会按这个顺序失败;现有测试只覆盖“调用 updater 之前就抛错”的情况。建议让 writer 状态与实际提交状态一致,或提供 setter 原子性保证并补测试。

其他

  • 当前 Ubuntu CI 的失败项是更新器 JSON 读取测试,看不出与本次改动有关,但合并前请确认是否为已知不稳定项。
  • 本次未运行完整测试,也没有 Desktop 实机验收。

@BytePioneer-AI

Copy link
Copy Markdown
Owner

@BeiLuoqu 上面的审查意见是给你这个 PR 的,请看一下;有疑问可以直接在这里讨论。

@BytePioneer-AI BytePioneer-AI added 待修改 审查发现需修正的问题,等待作者修改后重新评估合并 awaiting-author Waiting for the author to respond or update the PR. 暂缓 暂缓处理或合并,等待后续条件成熟 and removed awaiting-author Waiting for the author to respond or update the PR. 待修改 审查发现需修正的问题,等待作者修改后重新评估合并 labels Oct 30, 2026
@BytePioneer-AI
BytePioneer-AI merged commit 2b9a461 into BytePioneer-AI:main Oct 31, 2026
4 of 5 checks passed
@BytePioneer-AI BytePioneer-AI removed the 暂缓 暂缓处理或合并,等待后续条件成熟 label Oct 31, 2026
@BeiLuoqu

Copy link
Copy Markdown
Contributor Author

感谢审查,两项 P2 都已在 439cf7db 中处理。

1. 冲突预热丢失预热标记

renderer-host-rpc-routing.ts:预热请求如果自己指定了外部 carrier,就保留它的 Harness/Model,否则使用当前选择;两种情况都经过 prewarmCarrier() 加上预热标记。"指定另一个外部 carrier 时原样放行"现在只适用于 startConversation,不再适用于预热。

测试 marks every external prewarm, keeping an explicit different carrier 按你的建议,对出站 carrier 做 decodeCreateRoute,断言结果是 { harnessId: "pi", ..., prewarm: true },而不只是检查消息是否原样保留。把修复退回后,这个用例会失败。

2. setter 失败污染 writer

renderer-scoped-draft-model.ts:writer 不再在 updater 里写 captured。新的 entry 先在外面构造好,updater 执行时只用来记下写入前的草稿(entry.original ??= current,React 延迟执行 updater 时同样成立);captured.set() 放到 update() 正常返回之后。setter 求值了 updater 却拒绝提交时,writer 仍指向上次真正提交的 carrier。restore() 同时处理还没有 original 的记录。

draft-selection-order.test.ts 新增 keeps the committed carrier when the setter evaluates the updater and then rejects,按你给的步骤复现:

  1. 草稿成功选择 A;
  2. 写入 B 失败,setter 先执行 updater 再抛错;
  3. 再写入 C 失败,同样先执行 updater 再抛错。

用例断言:

  • 草稿和选择都仍是 A;
  • 切回 Codex 后草稿恢复为原生设置。

把修复退回后,这个用例会失败。

docs/architecture/official-traffic-ownership.md 的相关描述也同步更新了。

Ubuntu CI 的 updater 测试失败

我看了一下,和本 PR 无关:本 PR 没有改动 console-server。

失败的 packages/console-server/test/updates.test.ts › hands off to the Updater before returning 报的是 Unexpected end of JSON input。这个用例在第 171 行用 writeFile 直接覆写 status 文件,而 updates 模块此时还在轮询这个文件。writeFile 先截断再写入,不是原子操作,轮询正好读到空文件或半截内容时,JSON.parse 就会抛这个错,属于时序问题。

如果需要,我可以另开一个 PR,把测试里的写入改成"先写临时文件再 rename"的原子替换。

本地验证

  • 相关包 Vitest:1171 项通过;
  • tsc -b、Prettier、ESLint、边界检查均通过;
  • 仍未做 Desktop 实机验收。

BytePioneer-AI pushed a commit that referenced this pull request Oct 31, 2026
Adapt the follow-up fixes from #663, commit 439cf7d. Preserve explicit external prewarm routes while marking their lifecycle, and only record draft carriers after the setter accepts the update.

Keep native settings available across deferred draft updaters and queue restoration on Codex selection or disposal. Cover failed commits, explicit prewarms without a selection, and deferred restoration.

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.

2 participants