fix(model-config-import): stop routing pi providers through cc-switch snapshot - #590
Merged
Merged
Conversation
… snapshot CC Switch only stores a one-shot v18 migration snapshot of ~/.pi/agent/models.json, and our importer dedupe key looks at endpoint + apiStyle + secret without comparing model coverage. When scanModelConfigs returned [...ccSwitch, ...extra], any pi provider that had grown after the sync landed under the cc-switch source with the snapshot's stale model list, and the fuller pi native draft was silently filtered out because it matched an earlier candidate. The reporter saw opencode-go lose deepseek-flash and deepseek lose two models after import. parseCcSwitchProvider now returns [] for app_type='pi' so the pi scanner keeps ownership of that authoritative file. Providers still missing on disk are simply skipped, which matches every other source whose native config no longer exists. fixes #588
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #588.
What broke
scanModelConfigstreated CC Switch'sproviderstable as the authoritative index for every downstream tool it supports, pi included. But pi has its own native config at~/.pi/agent/models.json, and CC Switch only holds a one-shot v18 migration snapshot of it — subsequent edits tomodels.jsonnever flow back. Our importer dedupe key compares(baseUrl, apiStyle, secret)and skips the pi native draft when the same triplet is already in the cc-switch pile, so the fuller pi draft gets silently filtered out and the stale snapshot wins.Concrete symptom the reporter observed on 0.15.0:
opencode-gocame in with 9 of 10 models (the defaultdeepseek-flashwas dropped).deepseekcame in missing two models.OpenCode Zen Goinstead ofopencode-go).runtime.log— the models silently disappeared. Root cause matches the issue's own analysis.Fix
parseCcSwitchProvidernow returns[]forapp_type='pi'. The pi scanner keeps ownership of~/.pi/agent/models.json, which is upstream of the cc-switch snapshot. This is the "minimum cost" fix the reporter suggested — it fixes both the silent model loss and the source/name mislabelling at once, without touching the dedupe key or the scan ordering that other appTypes rely on.If
~/.pi/agent/models.jsondoesn't exist locally, the pi scanner returns nothing and the cc-switch snapshot is no longer resurrected. That matches how every other source behaves when its native config is missing; the cc-switch snapshot was never a fresh copy anyway.Tests
packages/shared/src/model-config-import.test.ts: new regression test —parseCcSwitchProvidersskipsapp_type='pi'rows even when they carry a plausible model list.apps/desktop/test/model-config-import.test.mjs: new integration test — reproduces the reporter's setup (cc-switch DB row with 9 models +models.jsonwith 10) and asserts the pi source keeps 10 models and no draft lands undercc-switch.Verification run in the task worktree:
pnpm build:js— passespnpm --filter @pi-desktop/shared test— 392 pass (including the new case)pnpm --filter @pi-desktop/desktop typecheck— passesnode --test apps/desktop/test/model-config-import.test.mjs— 5 pass (including the new case)Not run to green:
pnpm lintand the broaderpnpm --filter @pi-desktop/desktop testfail on unrelated pre-existing issues (work-panel.test.mjsasserts aminWidth: windowMinWidthstring that isn't inapps/desktop/electron/main/index.ts; several CSS token violations underapps/desktop/src/styles/). Both reproduce on unmodifiedorigin/mainand are outside this fix's scope.Compatibility
models.json(this issue is about import; existing DB rows are not migrated).models.json's own name, instead of the CC Switch group with the snapshot's name.