Skip to content

fix(runtime): 恢复官方统一历史配置下的原生语音入口 - #596

Open
Llugaes wants to merge 2 commits into
BytePioneer-AI:mainfrom
Llugaes:fix/native-codex-voice
Open

Llugaes wants to merge 2 commits into
BytePioneer-AI:mainfrom
Llugaes:fix/native-codex-voice

Conversation

@Llugaes

@Llugaes Llugaes commented Oct 24, 2026

Copy link
Copy Markdown

CC Switch 开启统一 Codex 会话历史后,会把官方账号配置为 custom Provider。Desktop 26.1021.2667.0 按有效 Provider 是否为 openai 判断官方推理能力,导致听写和实时语音入口消失;登录、额度和语音开关正常时也会发生。

本次只识别 CC Switch 的无地址官方历史别名(name=OpenAI、requires_openai_auth=true、supports_websockets=true、wire_api=responses 四个字段),以真正的原生启动参数 -c model_provider="openai" 运行本地后端。保留原生登录、能力判断和语音协议。

  • 兼容层不写回 Codex / CC Switch 配置,不迁移或重写已有历史;新会话由原生后端保存,历史列表同时查询 openai 和 custom,旧 Thread 继续走原生 resume。
  • 显式 Profile、命令行路由 / 工作目录覆盖、端点或附加认证字段保持原生路径。兼容模式遇到项目 Provider 覆盖时明确拒绝新工作,提示使用显式 Profile 重启。
  • 运行期间切换到其他 Provider 后,新工作会提示重启 CodexHost,停止操作仍可执行。该边界适用于官方与第三方 Provider 之间切换。

验证:

  • 105 项聚焦测试通过,覆盖别名识别、真实启动参数、历史过滤及游标、路由变化拦截、Owner 两种转发入口、发布 bundle。
  • Typecheck、改动文件 ESLint / Prettier、依赖边界检查通过。
  • Windows 隔离真实 Desktop:两个语音按钮恢复,旧 custom 历史可列出并续接,正常发送收到预期回复,切换第三方路由得到重启提示。
  • 麦克风转写、WebRTC 实时音频往返尚未实测;按钮恢复与音频验收分开记录。未验证其他平台的真实 Desktop。

这是独立的语音兼容修复,与 #589 的编辑 / 发送绑定修复分开提交。

@coderabbitai

coderabbitai Bot commented Oct 24, 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 82e4839 and d086a5b.

Files ignored due to path filters: 1
  • package-lock.json is excluded by !**/package-lock.json
Files selected for processing: 13
  • docs/architecture/official-traffic-ownership.md
  • docs/product/codex-accounts.md
  • packages/host-runtime/package.json
  • packages/host-runtime/scripts/build-release.mjs
  • packages/host-runtime/src/app-server-host.ts
  • packages/host-runtime/src/codex-runtime/native-voice-compatibility.ts
  • packages/host-runtime/src/codex-runtime/official-runtime-owner.ts
  • packages/host-runtime/src/codex-runtime/official-runtime-scope.ts
  • packages/host-runtime/src/native-account-host.ts
  • packages/host-runtime/test/native-account-host.test.ts
  • packages/host-runtime/test/native-voice-compatibility.test.ts
  • packages/host-runtime/test/official-runtime-owner.test.ts
  • tests/release/host-bundle.test.mjs

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

Recent review details
Context from checks skipped due to timeout: 2
  • GitHub Check: Check ubuntu-22.04
  • GitHub Check: Check windows-latest
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/host-runtime/package.json
  • tests/release/host-bundle.test.mjs
  • packages/host-runtime/scripts/build-release.mjs
  • packages/host-runtime/src/codex-runtime/official-runtime-scope.ts
  • docs/architecture/official-traffic-ownership.md
  • packages/host-runtime/test/official-runtime-owner.test.ts
  • packages/host-runtime/src/app-server-host.ts
  • docs/product/codex-accounts.md
  • packages/host-runtime/test/native-account-host.test.ts
  • packages/host-runtime/src/native-account-host.ts
  • packages/host-runtime/test/native-voice-compatibility.test.ts
  • packages/host-runtime/src/codex-runtime/official-runtime-owner.ts
  • packages/host-runtime/src/codex-runtime/native-voice-compatibility.ts
OpenGrep (1.30.1)
packages/host-runtime/src/codex-runtime/native-voice-compatibility.ts

[ERROR] 83-83: A nonliteral argument is passed to exec/execSync. Identify the receiver: Node child_process methods execute shell commands, while regular-expression and database methods have different contracts. For shell execution, prefer execFile or spawn with an argument array.

(coderabbit.command-injection.exec-js)

Additional comments: 14
packages/host-runtime/package.json: 1

29-29: LGTM!

packages/host-runtime/src/codex-runtime/native-voice-compatibility.ts: 2

83-83: LGTM!

158-159: 🎯 Functional Correctness

无法据现有仓库证据判断 null 是否等同于省略。

仓库协议允许 modelProviders 为 string[] | null,但没有声明原生 app-server 对 null 的处理方式。已检查的 Desktop/Host 源码也没有建立 Desktop 会发送 modelProviders: null 的调用路径。因此,当前证据不足以支持修改实现或测试。

packages/host-runtime/src/native-account-host.ts: 1

43-62: LGTM!

Also applies to: 68-75

packages/host-runtime/test/native-voice-compatibility.test.ts: 1

1-175: LGTM!

docs/architecture/official-traffic-ownership.md: 1

26-26: LGTM!

docs/product/codex-accounts.md: 1

69-76: LGTM!

packages/host-runtime/scripts/build-release.mjs: 1

23-23: LGTM!

tests/release/host-bundle.test.mjs: 1

181-181: LGTM!

packages/host-runtime/src/codex-runtime/official-runtime-owner.ts: 1

52-53: LGTM!

Also applies to: 79-79, 90-90, 348-348, 379-401

packages/host-runtime/src/codex-runtime/official-runtime-scope.ts: 1

63-63: LGTM!

packages/host-runtime/test/native-account-host.test.ts: 1

1-1: LGTM!

Also applies to: 64-65, 103-109, 121-149

packages/host-runtime/test/official-runtime-owner.test.ts: 1

16-16: LGTM!

Also applies to: 132-132, 208-243

packages/host-runtime/src/app-server-host.ts: 1

2218-2220: 🎯 Functional Correctness

NativeProviderRestartRequiredError 会保留到 AppServerHost。OfficialRuntimeClient.sendFrame 委托给 OfficialClientSession.send。OfficialRuntimeOwner.#send 在清理状态后使用 throw error 重新抛出原错误对象。structuredClone 只处理请求数据,不处理错误对象。

因此,error instanceof NativeProviderRestartRequiredError 不会因该调用链失效。无需修改或补充此项测试。

📝 Summary

Summary by CodeRabbit

  • 新功能
    • 符合条件的本地官方历史别名配置现可使用 Codex 原生语音能力;原有配置与历史记录保持不变。
    • 历史列表可同时显示官方与旧别名下的会话,旧会话仍可继续。
  • 改进
    • 检测到路由配置变化或不受支持的项目级路由时,会提示重启;相关情况下,新建或续接工作将被拒绝,进行中的实时会话仍可停止。

新增本地官方历史别名的原生语音兼容模式。符合条件的配置会以 openai 后端启动,并通过请求预处理扩展历史筛选条件、检查路由变化。新增依赖、运行时接线、测试和文档说明。

Changes: 原生语音兼容

层 / 文件 摘要
识别别名并准备兼容模式
packages/host-runtime/src/codex-runtime/native-voice-compatibility.ts, packages/host-runtime/src/native-account-host.ts, packages/host-runtime/package.json, packages/host-runtime/test/native-voice-compatibility.test.ts, docs/architecture/official-traffic-ownership.md, docs/product/codex-accounts.md, packages/host-runtime/scripts/build-release.mjs, tests/release/host-bundle.test.mjs
新增官方共享历史别名识别和启动参数覆盖。显式路由、端点覆盖及不符合别名条件的配置保留原生路径。新增 smol-toml 依赖及对应测试和文档。
预处理请求并处理路由变化
packages/host-runtime/src/codex-runtime/official-runtime-owner.ts, packages/host-runtime/src/codex-runtime/official-runtime-scope.ts, packages/host-runtime/src/codex-runtime/native-voice-compatibility.ts, packages/host-runtime/src/app-server-host.ts, packages/host-runtime/test/native-account-host.test.ts, packages/host-runtime/test/native-voice-compatibility.test.ts, packages/host-runtime/test/official-runtime-owner.test.ts
OfficialRuntimeOwner 在转发前调用可选预处理器。thread/list 会按规则合并 openai 与 custom 筛选条件;不兼容的项目路由或配置变更会阻止新的工作请求,并返回重启错误。测试覆盖请求转发、路由检查及错误处理。

Priority: Normal

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant NativeAccountHost
  participant prepareNativeVoiceCompatibility
  participant OfficialRuntimeScope
  participant OfficialRuntimeOwner
  NativeAccountHost->>prepareNativeVoiceCompatibility: prepare arguments and request preparer
  prepareNativeVoiceCompatibility-->>NativeAccountHost: compatibility arguments and request preparer
  NativeAccountHost->>OfficialRuntimeScope: pass arguments and request preparer
  OfficialRuntimeScope->>OfficialRuntimeOwner: configure prepareRequest
  OfficialRuntimeOwner->>prepareNativeVoiceCompatibility: prepare request method and params
  prepareNativeVoiceCompatibility-->>OfficialRuntimeOwner: adjusted params or restart error
Loading

Suggested reviewers: bytepioneer-ai

Merge Risk: Minimal · up to d086a

No confirmed issue currently blocks merging. The untested audio round trips and other-platform behavior remain validation limits, not established failures.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed 标题明确概括了本次修复的主要内容,即恢复官方统一历史配置下的原生语音入口,且与变更范围一致。
Description check Passed 描述与变更内容直接相关,说明了兼容条件、路由行为、历史处理、重启边界、测试结果及未验证范围。
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
🧪 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.

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.

1 participant