Skip to content

Codex/fix fail to fetch#285

Merged
Cmochance merged 3 commits into
Cmochance:mainfrom
Alpaca233114514:codex/fix-fail-to-fetch
May 27, 2026
Merged

Codex/fix fail to fetch#285
Cmochance merged 3 commits into
Cmochance:mainfrom
Alpaca233114514:codex/fix-fail-to-fetch

Conversation

@Alpaca233114514
Copy link
Copy Markdown
Contributor

@Alpaca233114514 Alpaca233114514 commented May 27, 2026

修复了检查更新不可用的问题
(Co-authored by GPT 5.5)

注意:因为时间和数据污染原因,未进行实机测试,请review后谨慎提交


Open in Devin Review

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

Cmochance and others added 3 commits May 27, 2026 22:27
Cmochance#278 已合并 Disabled 状态自动 re-apply,但 Applied 状态 theme_id 不
一致(切换 race / 重启后状态错位)或 Failed 状态时仍需用户手动 re-
toggle。本提交把 re-apply 抽成 autoReapplySelectedTheme 辅助函数,
在 Applied(theme_id 不匹配)+ Failed 两个分支也调用,让背景主题完
全自愈,无需用户介入。

Refs PR Cmochance#285。基于 ALPACA LI 的原始 PR diff 应用到当前 main(其
codex_theme_injector.rs 与 Disabled 分支已被 Cmochance#278 完整覆盖,本提交
只保留 Applied/Failed 两个状态的 net new delta)。

Co-authored-by: ALPACA LI <alpaca8570@outlook.com>
真根因:reqwest 在 src-tauri/Cargo.toml 没开 gzip feature,但 GitHub
release API 默认返回 gzip 压缩响应,客户端没法解压 → 前端"检查更新
失败"。

改动:

- src-tauri/Cargo.toml
  - reqwest features 加 "gzip"(真根因修复)
  - tokio features 加 "time"(下面 tokio::time::timeout 需要)
- src-tauri/src/admin/handlers/update.rs
  - update_check / update_install 各自的 reqwest Client 用 OnceLock
    缓存复用,避免每次 fetch 都重新 builder + Windows system-proxy
    自动检测可能的慢启动
  - 引入 connect_timeout(check 5s / install 10s)区分连接 vs 总
    timeout
  - update_check 外层包 tokio::time::timeout(15s) — 防 reqwest 内部
    timeout 在 DNS/TLS 握手卡死场景不触发(reqwest 0.12 已知边缘
    情况),双层保险

主题 A — PR Cmochance#285 的 net new 修复,update.rs / Cargo.toml 未被 Cmochance#278
触碰,完全保留作者原意。代码模式 sound,实机验证留 Phase 4。

Refs PR Cmochance#285。

Co-authored-by: ALPACA LI <alpaca8570@outlook.com>
silent-failure-hunter 对 PR Cmochance#285 主题 A 的评审 6 项里采纳 5 项,
拒绝 1 项(事实错误):

BLOCKER 1 — OnceLock 永久 cache 失败的 Err [采纳]
旧设计 `OnceLock<Result<Client, String>>` 在冷启动 reqwest builder
失败时(rustls 配置冲突 / Windows system-proxy 解析失败等极端 case)
会把 Err 永久 cache,后续每次调用都返同样 string,用户需重启进程
才能恢复。改成 `OnceLock<Client>` 只 cache 成功的 Client,失败时
tracing::error! 记录后返 Err,下次调用会重新尝试 build。

IMPORTANT 2 — update_install 缺 outer timeout [采纳]
update_check 已包 tokio::time::timeout(15s),但 update_install 没
对应保护,reqwest 内部 timer 在 DNS/TLS 握手卡死场景偶发不触发,
用户看到下载 spinner 无尽转。加 tokio::time::timeout(310s) =
reqwest 内部 300s + 10s grace,跟 check 双层 timeout 模式一致。

NIT 4 — outer/inner timeout 关系无 inline 注释 [采纳]
commit message 说明 15s outer = 10s inner + 5s grace,但 call site
无注释,日后调整 inner 容易破坏 outer 关系。在两处 tokio::time::
timeout 上方加注释说明该关系。

NIT 5 — apply 卡住会 block 后续 poll [无需修复]
跟 IMPORTANT 3 关联,3 拒绝了 5 自然无需处理。

[拒绝] IMPORTANT 3 — auto-reapply on Failed 无限循环
事实查证:renderTheme 是 event-driven(路由切换 / 用户操作触发),
**不是** setInterval polling。单次 renderTheme 内 Failed 分支只
reapply 一次,不构成 spamming / 死循环。Agent 假设 polling 错误,
拒绝该建议。

BLOCKER 6 — Cargo.toml 是 stale base [采纳]
PR Cmochance#285 基于老 main(2.1.15)起,直接 git checkout PR Cargo.toml
会丢掉主仓 Cmochance#280/Cmochance#284 引入的 codex-app-transfer-conversation-export
+ codex-app-transfer-usage-tracker 依赖,导致 cargo check 11 errors
(我之前误读 tail -3 的 exit code = 0,实际编译失败)。改成只对
当前 main 的 Cargo.toml apply 2 个 feature 增量(reqwest gzip +
tokio time),保留所有现有依赖与 version=2.1.16。

README 致谢:加 @Alpaca233114514 到中英 README 社区贡献者段,
归属 Cmochance#278 + Cmochance#285 两次 PR 贡献。

Refs PR Cmochance#285。

Co-authored-by: ALPACA LI <alpaca8570@outlook.com>
@Cmochance Cmochance force-pushed the codex/fix-fail-to-fetch branch from 2dcf941 to 3e2df72 Compare May 27, 2026 14:35
@Cmochance
Copy link
Copy Markdown
Owner

@Alpaca233114514 谢谢这次贡献!原 PR 因为 base 落后于 main(已合并 #278 / #280 / #284 / #286 等)直接 merge 会冲突 + 编译失败,我已经 force-push 一份 rebase 后的版本到你的 fork branch(commit 历史 3e2df72)以推进 review,保留你为 Co-authored-by。具体改动如下:

跟已合并 #278 重叠分析

仔细 diff 了 #285#278(ba7bf38),发现:

主题 #278 已含 #285 净新增 处理
codex_theme_injector.rs drain_until_response(expected_id) + 4 处 caller 改造 ✅ 100% 重叠(#278 实现简洁些,用 Result<(), String>) 重复 + Box error 是回退 全 drop
app.js Disabled 分支 auto re-apply ✅ 已含 重复(逐字相同) drop
app.js Applied 状态 theme_id 不匹配自动 re-apply ❌ 没有 ✅ ~5 行 保留 net new
app.js Failed 状态自动 re-apply ❌ 没有 ✅ ~3 行 保留 net new
update.rs + Cargo.toml 更新修复 ❌ 没碰 ✅ 全部 完整保留

Rebase 后 3 个 commit

  1. feat(theme): Applied/Failed 状态下自动 re-apply 选中主题(0e0cc7a) — 把你的 autoReapplySelectedTheme 辅助函数提取出来,在 Applied(theme_id 不匹配)+ Failed 两个分支调用,Disabled 分支也复用 helper(替代 fix: 修复背景主题功能不可用的问题 #278 的 inline 写法)。

  2. fix(update): 修复 check_update 拉 GitHub release 失败(dcd173c) — 完整保留你的 update 修复(reqwest gzip / tokio time / OnceLock / connect_timeout / check 外层 timeout),只把 Cargo.toml 整合到 main 当前版本(2.1.16 + conversation_export + usage_tracker 依赖)。

  3. review(update): 采纳 silent-failure-hunter 评审 + 修复 stale base(3e2df72) — 跑了一遍 silent-failure-hunter agent,采纳 5 项建议 / 拒绝 1 项:

    采纳:

    • OnceLock 永久 cache Err → 改成 OnceLock<Client> 只 cache 成功结果,失败时 tracing::error! 记录后返 Err,下次调用会重试 build(原 OnceLock<Result<Client, String>> 在冷启动 builder 失败时会把 Err 永久 cache,用户需重启进程才能恢复)
    • update_install 缺 outer timeout → 加 tokio::time::timeout(310s),跟你 update_check 的双层 timeout 模式一致(同 DNS/TLS hang 风险,reqwest 内部 timer 偶发不触发)
    • outer/inner timeout 关系无 inline 注释 → 两处 tokio::time::timeout 上方加注释说明 outer = inner + grace
    • Cargo.toml stale base → fix(已说明)

    拒绝:

    • agent 认为 auto-reapply on Failed 会无限循环 — 事实查证 renderTheme 是 event-driven(路由切换 / 用户操作触发),不是 setInterval polling,单次 render 内 Failed 只 reapply 一次,不存在死循环风险。Agent 假设有误,拒绝。

致谢

README 中英都加了你到社区贡献者段(归属 #278 + #285 两次 PR)。

验证状态

  • cargo check -p codex-app-transfer
  • silent-failure 评审 ✅(见上)
  • 实机测留我们 maintainer 这边做(rebuild .app + 点检查更新 / Codex restart 后看主题 auto re-apply),完事会回报
  • CI 现在自动 trigger 了(no-ai-coauthor ✅ + Rust check in progress)

CI 全绿 + 实机验证通过后会 squash-merge,squash commit 会保留你为 Co-authored-by。

辛苦了 🙏 如果对 rebase 有任何不同意见(尤其重叠分析或拒绝 agent 那条建议)随时 comment,我们调整。

@Cmochance Cmochance merged commit af89a39 into Cmochance:main May 27, 2026
5 checks passed
Cmochance added a commit to Alpaca233114514/codex-app-transfer that referenced this pull request May 27, 2026
issue Cmochance#266 UP7 真根因定位:用户改 model mapping 后,~/.codex/
model_catalog.json 没主动落盘,Codex CLI 重启读到 stale catalog →
模型选择 / 推理预算 UI 注入失败。

workaround 是先在 Codex 里发一条消息触发 proxy 路径 auto-sync 才
把新 mapping 落盘,但用户不该需要这步操作。UP8 印证 — responses
原生协议 pass-through 不查 catalog 没问题;chat-completions 协议
必须查 model_catalog.json,stale 直接挂。

修复:把 sync_desktop_for_active_provider 调用前置到两个关键节点
(apply_desktop_target → upsert_catalog_models 落 model_catalog.json
+ ~/.codex/config.toml):

- src-tauri/src/admin/handlers/desktop.rs::restart_codex_app
  - signature 加 State(state): State<AdminState>(router 已 with_state)
  - launch_codex_app_restart 之前先 sync;attempted+failure 拦下
    restart 让用户解决根因(no-active-provider 不拦);response 多
    desktopSync 字段
- src-tauri/src/admin/handlers/providers/crud.rs::update_models
  - signature 加 State(state): State<AdminState>
  - 改 active provider 的 models 时,with_config_write 释放锁后
    立即 sync;非阻塞(sync 失败不挂 API,放 desktopSync 字段);
    非 active provider 不 sync(desktopSync=null)

Refs issue Cmochance#266 / PR Cmochance#287。基于 ALPACA LI 的原始 PR diff,只保
留净新增的 desktop.rs + providers/crud.rs 改动(其它文件已被
Cmochance#278 / Cmochance#285 完整覆盖,drop)。code-reviewer LGTM,无 fixup。

Co-authored-by: ALPACA LI <alpaca8570@outlook.com>
Cmochance added a commit to Alpaca233114514/codex-app-transfer that referenced this pull request May 27, 2026
issue Cmochance#266 UP7 真根因定位:用户改 model mapping 后,~/.codex/
model_catalog.json 没主动落盘,Codex CLI 重启读到 stale catalog →
模型选择 / 推理预算 UI 注入失败。

workaround 是先在 Codex 里发一条消息触发 proxy 路径 auto-sync 才
把新 mapping 落盘,但用户不该需要这步操作。UP8 印证 — responses
原生协议 pass-through 不查 catalog 没问题;chat-completions 协议
必须查 model_catalog.json,stale 直接挂。

修复:把 sync_desktop_for_active_provider 调用前置到两个关键节点
(apply_desktop_target → upsert_catalog_models 落 model_catalog.json
+ ~/.codex/config.toml):

- src-tauri/src/admin/handlers/desktop.rs::restart_codex_app
  - signature 加 State(state): State<AdminState>(router 已 with_state)
  - launch_codex_app_restart 之前先 sync;attempted+failure 拦下
    restart 让用户解决根因(no-active-provider 不拦);response 多
    desktopSync 字段
- src-tauri/src/admin/handlers/providers/crud.rs::update_models
  - signature 加 State(state): State<AdminState>
  - 改 active provider 的 models 时,with_config_write 释放锁后
    立即 sync;非阻塞(sync 失败不挂 API,放 desktopSync 字段);
    非 active provider 不 sync(desktopSync=null)

Refs issue Cmochance#266 / PR Cmochance#287。基于 ALPACA LI 的原始 PR diff,只保
留净新增的 desktop.rs + providers/crud.rs 改动(其它文件已被
Cmochance#278 / Cmochance#285 完整覆盖,drop)。code-reviewer LGTM,无 fixup。

Co-authored-by: ALPACA LI <alpaca8570@outlook.com>
Cmochance added a commit that referenced this pull request May 27, 2026
issue #266 UP7 真根因定位:用户改 model mapping 后,~/.codex/
model_catalog.json 没主动落盘,Codex CLI 重启读到 stale catalog →
模型选择 / 推理预算 UI 注入失败。

workaround 是先在 Codex 里发一条消息触发 proxy 路径 auto-sync 才
把新 mapping 落盘,但用户不该需要这步操作。UP8 印证 — responses
原生协议 pass-through 不查 catalog 没问题;chat-completions 协议
必须查 model_catalog.json,stale 直接挂。

修复:把 sync_desktop_for_active_provider 调用前置到两个关键节点
(apply_desktop_target → upsert_catalog_models 落 model_catalog.json
+ ~/.codex/config.toml):

- src-tauri/src/admin/handlers/desktop.rs::restart_codex_app
  - signature 加 State(state): State<AdminState>(router 已 with_state)
  - launch_codex_app_restart 之前先 sync;attempted+failure 拦下
    restart 让用户解决根因(no-active-provider 不拦);response 多
    desktopSync 字段
- src-tauri/src/admin/handlers/providers/crud.rs::update_models
  - signature 加 State(state): State<AdminState>
  - 改 active provider 的 models 时,with_config_write 释放锁后
    立即 sync;非阻塞(sync 失败不挂 API,放 desktopSync 字段);
    非 active provider 不 sync(desktopSync=null)

Refs issue #266 / PR #287。基于 ALPACA LI 的原始 PR diff,只保
留净新增的 desktop.rs + providers/crud.rs 改动(其它文件已被
#278 / #285 完整覆盖,drop)。code-reviewer LGTM,无 fixup。

Co-authored-by: Cmochance <3216202644@qq.com>
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