fix(desktop): safely rebuild Codex thread across credential providers - #3586
Conversation
Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7f4f4acb49
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
| Filename | Overview |
|---|---|
| apps/desktop/src/main/maker-ipc/codexProviderThreadRelink.ts | 新增独立的源 thread 读取、fork 与 CAS 提交编排,失败时保持 fail-closed。 |
| apps/desktop/src/main/maker-ipc/runtimeSetModel.ts | 为需要重建的 Codex 跨凭证切换增加忙碌拒绝、关闭会话、relink 和持久化完成标记。 |
| apps/desktop/src/main/maker-ipc/register.ts | 接入数据库快照、源凭证 fork、完整路由 CAS 和广播,并避免随后重复持久化。 |
| apps/desktop/src/main/maker-ipc/tests/codexProviderThreadRelink.test.ts | 覆盖凭证方向过滤、源身份 fork、无持久 thread 及 CAS 竞争失败。 |
| apps/desktop/src/main/maker-ipc/tests/runtimeSetModelCodexRelink.test.ts | 覆盖空闲、忙碌、关闭前竞态以及无 live session 的 relink 行为。 |
Sequence Diagram
sequenceDiagram
participant UI as 本地 Renderer
participant IPC as Desktop IPC
participant Runtime as RuntimeSetModel
participant Maker as Codex Runtime
participant DB as SQLite
UI->>IPC: 选择目标 model/provider/effort/fast
IPC->>IPC: 校验本地 Codex、持久 thread、XD↔OpenAI
IPC->>Runtime: applyRuntimeSetModelChange
Runtime->>Runtime: 检查任务是否忙碌
alt 任务忙碌
Runtime-->>UI: 拒绝并要求稍后重试
else 任务空闲
Runtime->>Maker: 关闭 live session
Runtime->>Maker: 使用源凭证 fork thread
Maker-->>Runtime: newSdkSessionId
Runtime->>DB: CAS 提交新 thread 与完整目标路由
DB-->>Runtime: 提交成功
Runtime-->>UI: applied / persistedRoute
end
Reviews (1): Last reviewed commit: "fix(desktop): rebuild Codex thread acros..." | Re-trigger Greptile
Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a2d5489bd7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>
|
@zqchris 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/main/maker-ipc/runtimeSetModel.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6974fc9186
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7b5c5afcec
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@zqchris 👋 这个 PR 还有 3 条 review conversation 没 resolve(apps/desktop/src/main/maker-ipc/runtimeSetModel.ts / apps/desktop/src/main/maker-ipc/register.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
|
当前所有 review conversation 已按本 PR 的既定范围处理并 resolve:契约内意见已完成修复;Profile 生命周期串行化、pending/队列恢复与 Device Link 等越界项已按 Chris 的范围裁决不纳入本 PR。当前 head 可继续进行合并审查,请按现有代码与已确认边界重新检查。 |
|
@codex review 请按当前 head 本批意见均已在对应 review thread 中逐条公开说明并 resolve:
请基于当前 head 和上述已处理边界继续审查。 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7b5c5afcec
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fb16ce0a7a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf64fe9119
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>
MagicLizi
left a comment
There was a problem hiding this comment.
代码重审通过:当前 head 未发现 P0/P1。凭证源切换时重建 Codex thread 的 CAS/清理路径,未发现安全/正确性问题。
|
合了。换凭证时把 Codex thread 重建成可继续的会话,busy 直接失败、CAS 绑在替换线程上,比留下半截状态要踏实。 |
这次改了什么
摘要
重新实现本地 Codex 任务在 XD 与 OpenAI 包月之间切换时的 thread 安全重建,替代已关闭且范围失控的 #3543。fork 始终使用源 thread 的凭证身份;新
sdk_session_id与目标 model/provider/effort/fast 在同一条 SQLite CAS 中提交。任务忙碌或提交条件变化时直接失败,不建立 deferred/pending 状态机。变更类型
feat新功能fix缺陷修复refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
model:pick、agent/fallback/scheduler、远程 host、其它 provider/agent、授权与模型目录、Windows 启动屏障、通用 pending 恢复状态机。UI 变化
怎么验证的
自动验证
手工验证
不涉及;未启动 Desktop DEV。
未执行的验证
未做实机切换;遵守本仓禁止未经明确授权启动 Desktop DEV 的约束。完整 CI 交由 PR 门禁执行。
风险
风险分类
影响与回滚
提交前检查
git commit -s,见 DCO)