fix(codex): 修复 Codex provider 同步功能#1900
Conversation
1d6714d to
25b3836
Compare
|
已根据审查意见修复:
请 review。 |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25b38368d8
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // 避免 thread/list 因历史元数据与当前 provider 不一致而过滤空历史。 | ||
| // 注意:此操作只在正常切换时执行,不在热切换时执行(避免重 I/O 操作增加切换耗时) | ||
| if matches!(app_type, AppType::Codex) { | ||
| if let Err(e) = sync_codex_rollout_model_provider(id) { |
There was a problem hiding this comment.
Use Codex model_provider key for metadata sync
The id passed here is the cc-switch provider record ID, but Codex session metadata is keyed by TOML model_provider values (for example custom/openai), not by internal UUIDs. In this repo, non-additive providers are created with generated UUID IDs, so using id causes both sync helpers to write a value that does not match Codex’s active provider key, which means thread/list filtering can still miss or misclassify history after switching. Please parse the target provider’s settings_config.config and pass its model_provider value to these sync functions instead of the internal provider ID.
Useful? React with 👍 / 👎.
| lines[0] = | ||
| serde_json::to_string(&first).map_err(|e| AppError::JsonSerialize { source: e })?; | ||
| write_text_file(&path, &(lines.join("\n") + "\n"))?; |
There was a problem hiding this comment.
Avoid full-file rewrite during rollout metadata patch
This path rewrites the entire JSONL file from an in-memory snapshot after reading it, so if Codex is concurrently appending events to the same rollout file during a switch, any lines appended between the read and the atomic replace are lost. The severity depends on concurrent writes, but that scenario is realistic for active sessions and leads to irreversible history truncation. The sync should avoid replacing whole files (or use locking/active-session exclusion) when only the first line needs patching.
Useful? React with 👍 / 👎.
25b3836 to
da9b909
Compare
7bfb0db to
1906053
Compare
根据审查意见实现 Codex provider 同步功能: sync_codex_rollout_model_provider: 只修复缺失值(空字符串),不覆盖已有值 sync_codex_threads_model_provider: 只修复 NULL 值,不覆盖已有 provider 记录 不添加 rebuild_codex_session_index: 基于错误前提(threads 表不是全量来源) 只在 switch_normal 中执行,不在热切换路径执行(避免重 I/O 操作增加切换耗时) fixes farion1231#1694
1906053 to
06b0fcb
Compare
根据审查意见修复 Codex provider 同步功能:
修复内容
变更统计
Closes #1694