Repository navigation
feat(vscode): auto-refresh model catalog - #4611
Conversation
🦋 Changeset detectedLatest commit: 89cb93e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 217cbbcab0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved refresh and rollback races can restore stale selections or discard unsent text, while unchecked timer intervals and overlapping refreshes can cause excessive requests and unbounded queue growth.
5 open issues
Handle refresh intervals beyond the maximum timer delay · New Skip refresh ticks while a directory request is in flight · New Preserve unsent chat text when refreshing after skipped login · New Prevent stale model-directory responses from overwriting current state · New Validate rollback selections against the latest model directory · New
What changed in this PR
此 PR 在 VS Code 扩展宿主中统一调度模型目录刷新,并通知已打开的 webview 更新模型列表,无需重载界面。
Changes:
- 启动时及默认每 6 小时刷新目录,支持配置和环境变量覆盖,并处理失败与释放。
- 目录变化后广播事件;ready 页面更新模型状态,保留仍有效的模型选择和思考档位。
- 添加调度、初始化竞态、空模型门禁及选择回退测试,并记录版本变更。
| File | Description |
|---|---|
apps/vscode/webview-ui/src/stores/settings.store.ts |
更新目录并保留或回退模型选择与思考档位。 |
apps/vscode/webview-ui/src/hooks/useAppInit.ts |
接收目录事件,更新列表或重新执行初始化门禁。 |
apps/vscode/test/webview/app-init.test.tsx |
覆盖目录事件、初始化竞态、空列表和读取失败。 |
apps/vscode/test/settings-store.test.ts |
覆盖选择保留、失效值回退及保存失败回滚。 |
apps/vscode/test/kimi-runtime.test.ts |
覆盖刷新周期、配置优先级、通知、失败和释放。 |
apps/vscode/src/runtime/model-catalog-refresh.ts |
实现宿主侧刷新调度器。 |
apps/vscode/src/runtime/kimi-runtime.ts |
接入调度器、广播通知及生命周期清理。 |
apps/vscode/shared/bridge.ts |
新增模型目录变化事件。 |
.changeset/vscode-auto-refresh-models.md |
记录 VS Code 自动刷新模型列表的功能变更。 |
Review effort: Balanced
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 52fb501e48
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ccdd7b2609
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6c67d23901
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f975fcf11
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 336f1a3fa6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a44504babf
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c7cb286cad
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0280aadc2f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 983d44abd4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8d83898daa
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d3a033be2a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Port of upstream cc6b98e (MoonshotAI#4611). A provider catalog that gained or retired models while the window was open stayed stale until the window reloaded, so a new model never appeared and a retired default kept failing. `KimiRuntime` now starts `startModelCatalogRefresh` next to the harness and stops it in `dispose()`. It refreshes once at startup unless disabled, then every `modelCatalog.refreshIntervalMs` (six hours by default, 0 disables the timer), and broadcasts `Events.ModelCatalogChanged` only when the refresh actually changed something. `KIMI_CODE_MODEL_CATALOG_REFRESH_INTERVAL_MS` and `KIMI_CODE_MODEL_CATALOG_REFRESH_ON_START` override the config values. The webview subscribes to the event, re-reads the catalog, and prefers the refreshed list over the one captured during initialization. Local-form notes: the fork's extension and webview sources are formatted with single quotes, so the new module and the `useAppInit` hunks are the upstream logic in the repository's own style rather than a verbatim diff. The timer is `unref()`d so an idle window can still exit. Verified: `tsc -p apps/vscode/tsconfig.json` clean; the new `model-catalog-refresh.test.ts` 5 pass (start refresh, silent when nothing changed, disabled start, env override, failed refresh logged not thrown); `kimi-runtime` + `settings-store` 60 pass.


Requirement or Bug
VS Code 用户此前只能在登录或手动重置后看到新模型。这个 PR 让插件在启动时和每 6 小时自动刷新模型目录,新模型会直接出现在模型选择器中。
没有关联的追踪 issue。
Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
扩展宿主复用 SDK 的目录刷新能力,在启动和每 6 小时触发刷新。目录实际变化后通知所有 webview,webview 再读取并替换模型数组。
目录刷新只更新
models。当前模型、默认思考设置、登录流程、保存回滚和其他会话状态都不经过这条路径,避免引入额外的状态竞争。Behavior Changes and Affected Users
[model_catalog]或KIMI_CODE_MODEL_CATALOG_REFRESH_*环境变量关闭启动或定时刷新没有改变静态 provider、当前模型选择、登录、保存或消息发送行为。
Beta Model。完整验证结果
pnpm --filter kimi-code test:22 个测试文件,397 项测试全部通过。pnpm --filter kimi-code typecheck:通过。pnpm --filter kimi-code build:通过。pnpm lint:0 errors。New Model自动可见,选择保持为Beta Model。Checklist
gen-changesetsskill.gen-docsskill; no documentation update is needed.