Skip to content

Watch Codex Desktop model cache for catalog updates - #6143

Closed
blairevan wants to merge 1 commit into
lidge-jun:devfrom
blairevan:codex/model-catalog-sync
Closed

blairevan wants to merge 1 commit into
lidge-jun:devfrom
blairevan:codex/model-catalog-sync

Conversation

@blairevan

@blairevan blairevan commented Sep 27, 2026 •

Copy link
Copy Markdown

Summary

  • Watch Codex Desktop's models_cache.json while OpenCodex is running and reconcile the native model catalog when a newly available account-native model appears.
  • Preserve account selector isolation and ignore OpenCodex's own cache invalidation writes to prevent sync loops.
  • Document the behavior in English and Chinese.

Verification

  • bun test tests/codex-integration/native-model-toggle.test.ts — 42 passed.
  • git diff --check — passed.
  • bun run typecheck — not clean because unrelated existing errors in src/server/claude-messages.ts:699 and src/server/responses/fetch-helpers.ts:443 (RequestInit.timeout is missing from the resolved dependency types).
  • Documentation build was not verified; locked dependency installation failed with UNKNOWN_CERTIFICATE_VERIFICATION_ERROR while downloading packages.

Checklist

  • Scope is focused on model catalog synchronization.
  • User-facing documentation is updated in English and Chinese.
  • No authentication, secrets, or credential handling was changed.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

@coderabbitai

coderabbitai Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the enhancement New feature or request label Sep 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • review readiness checklist open (0/4 boxes ticked).

What to do

  • Tick all four boxes in the PR description once you're done (currently 0/4).

Review readiness checklist

  • ⬜ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ⬜ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ⬜ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

0/4 boxes ticked.

This PR stays in draft until every box above is ticked.

@lidge-jun

Copy link
Copy Markdown
Owner

리뷰 · 우선순위 54 / 80

OpenCodex가 켜져 있고 Codex 연동이 켜져 있으면, Codex Desktop이 쓰는 models_cache.json을 지켜봐요. 계정에만 있는 새 모델 이름이 그 파일에 있고 OpenCodex 카탈로그에는 없으면, 시작할 때 쓰던 카탈로그 동기화를 다시 돌려요. OpenCodex가 캐시를 일부러 옛 표시(client_version이 0.0.0)로 다시 쓰면 그 쓰기는 무시해요. 그래서 서로 계속 불러 도는 고리를 끊어요. 새 이름은 설정된 계정 선택자 안에만 두고, 모두가 쓰는 고정 목록에는 넣지 않아요. 영어 안내와 중국어 안내에 이 동작을 적었어요. 바탕은 dev예요. 아직 초안이고, 준비 체크 네 칸은 비어 있어요.

라인 - src/cli/index.ts 698행. 감시기가 부르는 함수는 syncCodexOnStartIfEnabled예요. 이 함수는 동기화가 실패해도 오류를 삼키고 평범하게 끝나요 (src/codex/desired-state.ts 279행). src/codex/catalog/watch.ts 35행의 catch는 그 실패를 보지 못해요. 36행의 경고는 실제로 안 나와요. 새 모델이 카탈로그에 안 들어갔는데도 로그는 조용해요.

라인 - src/codex/catalog/metadata.ts 901–903행. 이미 아는 이름에, 계정 모델이 아닌 슬래시 없는 카탈로그 이름까지 넣어요. 같은 글자가 카탈로그에 있으면 desktop/모델 같은 계정 줄이 없어도 동기화를 건너뛰어요. tests/codex-integration/native-model-toggle.test.ts 487행은 그 맨 이름만 카탈로그에 넣고 492행에서 false를 기대해요. 감시기가 계정 줄을 만드는 일은 이 테스트에 없어요.

라인 - src/codex/catalog/metadata.ts 896행. client_version이 0.0.0이면 안의 모델은 안 봐요. 동기화는 끝나는 길에 캐시를 그 값으로 다시 써요. 그 사이에 Desktop이 더 새 모델을 넣으면, 그 이름은 숨은 줄로 캐시에 남거나 덮일 수 있어요. 감시기 다음 확인은 0.0.0이라 바로 멈춰요. 프로세스를 다시 켜거나 Desktop이 진짜 버전으로 다시 쓸 때까지 그 모델은 카탈로그에 안 들어와요.

라인 - src/codex/catalog/watch.ts 61–63행. 감시가 오류로 멈추면 로그만 남기고 다시 열지 않아요. stopped도 안 켜요. 그때부터 자동 갱신은 프로세스가 다시 켜질 때까지 꺼져 있어요.

메인테이너의 판단이 필요한 지점

새 모델 하나 때문에 시작 때와 같은 전체 동기화를 돌릴지예요. 그 길은 프로바이더 목록도 다시 가져오고, 끝나면 캐시를 0.0.0으로 다시 써요. 좁게 계정 모델만 맞출지, 이 넓은 길을 쓸지는 선택이 필요해요.

0.0.0 파일은 항상 무시할지, 카탈로그에 없는 계정 모델이 들어 있으면 한 번 더 맞출지도 같이 정하면 돼요. 고리를 막으려면 방금 OpenCodex가 쓴 파일만 건너뛰는 쪽이 맞아요. 버전 문자열만 보면, 실패 뒤에 남은 숨은 모델을 더 이상 안 봐요.

너의 추천

바탕 dev를 유지하세요. types.ts / config.ts 나누기와 겹치는 열린 PR은 없고, 이 PR 때문에 닫을 중복도 없어요.

머지 전에 세 곳을 고치세요. 698행은 실패를 삼키지 않는 동기화에 연결하거나, 카탈로그가 안 바뀌면 경고를 남기세요. 901행은 계정 모델 줄의 이름만 이미 아는 이름으로 보세요. 61행은 감시가 죽으면 한 번 다시 여세요.

469행 테스트는 startCodexDesktopModelCacheWatcher를 실제로 켜세요. 다른 파일 변경은 무시하는지, stop 뒤에는 더 이상 안 부르는지, 동기화 실패가 로그로 남는지 보면 돼요.

준비 체크는 아직 0/4예요. 본문은 타입 검사가 기존 src/server/claude-messages.ts와 src/server/responses/fetch-helpers.ts 오류 때문에 깨끗하지 않고, 문서 빌드는 인증서 오류로 못 돌렸다고 해요. 그 칸을 채우기 전에 머지하지 마세요.

이 댓글은 grok-bot이 작성했습니다

@Ingwannu Ingwannu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Reviewed exact head 2a8f4ef. Four correctness gaps still block this draft:

  1. The sync helper catches and suppresses its own failures, so the watcher-level catch/recovery path cannot run.
  2. A bare catalog slug is treated as proof that an account-qualified model was synchronized, which can leave the qualified entry absent.
  3. Ignoring every client_version=0.0.0 event can miss a legitimate concurrent Desktop write.
  4. After a watcher error the code does not establish a replacement subscription, so automatic model sync can remain disabled until restart.

The current tests do not start the real watcher or exercise debounce, stop, error, and resubscription behavior. Please make failures observable to the watcher, compare the exact qualified identity, distinguish self-writes without discarding unrelated 0.0.0 writes, and prove watcher recovery with an integration-style test.

@lidge-jun

Copy link
Copy Markdown
Owner

Closing during triage: draft inactive since late September and now far behind dev. Happy to review a fresh rebase on dev.

@lidge-jun lidge-jun closed this Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants