Skip to content

fix: sync providers in local_thread_catalog#1438

Open
XIUDENBENNY wants to merge 1 commit into
BigPizzaV3:mainfrom
XIUDENBENNY:fix/provider-sync-local-thread-catalog
Open

fix: sync providers in local_thread_catalog#1438
XIUDENBENNY wants to merge 1 commit into
BigPizzaV3:mainfrom
XIUDENBENNY:fix/provider-sync-local-thread-catalog

Conversation

@XIUDENBENNY

Copy link
Copy Markdown

Summary

  • discover Codex SQLite databases that only contain the newer local_thread_catalog table
  • include provider IDs from both threads and local_thread_catalog in provider sync target discovery
  • count and update model_provider in both tables within the same SQLite transaction
  • keep the existing provider-sync result shape and database backup flow unchanged

Problem

Recent Codex desktop builds maintain a second history catalog at sqlite/codex-dev.db/local_thread_catalog. Provider sync currently rewrites rollout session_meta.model_provider and threads.model_provider, but it does not update this newer catalog.

After switching from an official subscription to a custom provider, the rollout files and legacy index can be synchronized while the desktop catalog still contains the old provider IDs. Codex then filters or rebuilds the sidebar from inconsistent metadata, so only conversations originally created with the active provider remain visible.

Implementation

  • treat local_thread_catalog as a session database marker in codex_sqlite_dir_session_dbs
  • read provider IDs from both supported tables
  • aggregate update counts from both tables
  • update both tables in one transaction when they coexist in a database
  • include catalog-only databases in the existing backup path

Tests

  • added coverage for a codex-dev.db containing only local_thread_catalog
  • verifies provider discovery, row updates, update counts, and backup creation
  • added rollback coverage proving a catalog update failure also rolls back the preceding threads update
  • cargo fmt --all -- --check
  • cargo test -p codex-plus-data --test provider_sync (19 passed)
  • frontend npm install --package-lock=false and npm run vite:build
  • workspace tests passed until the local Windows installer test executable required elevation (os error 740); GitHub Actions will run the complete elevated Windows job

Related to #726 and #240.

@XIUDENBENNY

XIUDENBENNY commented Jul 11, 2026

Copy link
Copy Markdown
Author

不同的中转api或者订阅在codex++中切换后,聊天内容任完全保留

@BigPizzaV3

Copy link
Copy Markdown
Owner

感谢这个修复方向。当前 PR 已经和 main 冲突,主要在 crates/codex-plus-core/src/codex_sqlite.rscrates/codex-plus-data/tests/provider_sync.rs

另外 main 的 v1.2.43 已经覆盖了更完整的一部分:不仅同步 local_thread_catalog.model_provider,还会尝试从旧 threads 表补齐缺失的 local_thread_catalog 行并更新 catalog metadata/sync state。当前剩余的 #1644 反馈显示 1.2.43 后仍有未恢复场景,所以这个 PR 仅同步已有 catalog 行还不够。

暂时不能直接合并。建议先 rebase 到最新 main,然后把修复范围对齐到 #1644 / #1587 中仍未覆盖的场景。

@BigPizzaV3

Copy link
Copy Markdown
Owner

Codex++ maintainer review note

当前 main 下这个 PR 仍存在 merge conflict,暂时不能合并。请先 rebase 到最新 main 并解决冲突;更新后我们会重新跑针对性测试再复审。

This PR currently conflicts with main, so it is not mergeable yet. Please rebase onto the latest main and resolve the conflicts, then we can review and test it again.

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