Skip to content

feat(vscode): auto-refresh model catalog - #4611

Merged
Grapedge merged 14 commits into
mainfrom
vsc-autorefresh-model
Nov 3, 2026
Merged

Grapedge merged 14 commits into
mainfrom
vsc-autorefresh-model

Conversation

@Grapedge

@Grapedge Grapedge commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

VS Code 用户此前只能在登录或手动重置后看到新模型。这个 PR 让插件在启动时和每 6 小时自动刷新模型目录,新模型会直接出现在模型选择器中。

没有关联的追踪 issue。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

扩展宿主复用 SDK 的目录刷新能力,在启动和每 6 小时触发刷新。目录实际变化后通知所有 webview,webview 再读取并替换模型数组。

flowchart LR
  A["启动和每 6 小时调度"] --> B["SDK 刷新模型目录"]
  B -->|"changed 非空"| C["广播目录变化"]
  C --> D["GetModels"]
  D --> E["替换选择器的模型数组"]
Loading

目录刷新只更新 models。当前模型、默认思考设置、登录流程、保存回滚和其他会话状态都不经过这条路径,避免引入额外的状态竞争。

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
模型选择器的数据 只在登录或手动重置时更新 启动和每 6 小时自动更新 使用动态模型目录的 VS Code 用户 可通过 [model_catalog] 或 KIMI_CODE_MODEL_CATALOG_REFRESH_* 环境变量关闭启动或定时刷新

没有改变静态 provider、当前模型选择、登录、保存或消息发送行为。

  • 调度测试覆盖启动、6 小时间隔、配置与环境变量、变化通知、失败和释放。
  • store 测试证明新模型出现时,当前选择和默认设置不变。
  • Playwright Electron 使用本地模型注册表验证,第二次发布模型后,新模型自动出现在选择器中,当前选择保持为 Beta Model。
完整验证结果
  • pnpm --filter kimi-code test:22 个测试文件,397 项测试全部通过。
  • pnpm --filter kimi-code typecheck:通过。
  • pnpm --filter kimi-code build:通过。
  • pnpm lint:0 errors。
  • 真实 Electron 验证:本地注册表收到 2 次请求,New Model 自动可见,选择保持为 Beta Model。

Checklist

  • I have read the CONTRIBUTING document.
  • Related issue: N/A, this change has no tracking issue.
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete; no other behavior is changed.
  • Ran gen-changesets skill.
  • Ran gen-docs skill; no documentation update is needed.

Copilot AI balanced review requested due to automatic review settings November 2, 2026 11:52
@changeset-bot

changeset-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 89cb93e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
kimi-code Minor

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T16:07:31.970448Z 89cb93e New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@89cb93e
npx https://pkg.pr.new/@moonshot-ai/kimi-code@89cb93e

commit: 89cb93e

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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
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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

@Grapedge
Grapedge merged commit cc6b98e into main Nov 3, 2026
17 checks passed
@Grapedge
Grapedge deleted the vsc-autorefresh-model branch November 3, 2026 04:45
@github-actions github-actions Bot mentioned this pull request Nov 3, 2026
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
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.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
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.

3 participants