Repository navigation
feat: add /provider refresh subcommand - #4316
Conversation
🦋 Changeset detectedLatest commit: 60c8a43 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: 040ae7301b
ℹ️ 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".
| const result = await this.host.harness.refreshProviderModels(options); | ||
| if (result.changed.length > 0) { | ||
| await this.refreshAvailableModels(); |
There was a problem hiding this comment.
Reload provider state after config-only refreshes
When a custom registry changes only provider configuration (for example type or baseUrl) while its models are identical, core persists the provider change but returns changed: [] and puts the ID in unchanged. This guard then leaves appState.availableProviders stale, so effort/model protocol decisions keep using old provider data until /reload or restart even though the new runtime command reported success; reload provider state after any successful refresh rather than only model changes.
AGENTS.md reference: AGENTS.md:L104-L104
Useful? React with 👍 / 👎.
| // removals surface as a warning rather than a plain status. | ||
| const total = change.added + change.removed; | ||
| host.showStatus( | ||
| `${change.provider_name}: ${parts.join(' / ')} model${total === 1 ? '' : 's'}.`, |
There was a problem hiding this comment.
Handle metadata-only refresh results
Registry responses deliberately represent display-name, capability, or upgrade-only updates as a changed entry with both counters zero. Here parts stays empty, so the command prints output such as Example: models. after a successful metadata refresh; add an explicit metadata-updated message and cover the 0/0 response shape.
AGENTS.md reference: AGENTS.md:L112-L112
Useful? React with 👍 / 👎.
| export async function handleProviderCommand(host: SlashCommandHost, rawArgs = ''): Promise<void> { | ||
| const args = rawArgs.trim().split(/\s+/).filter((part) => part.length > 0); | ||
| if (args[0] === 'refresh') { | ||
| await handleProviderRefresh(host, args[1]); |
There was a problem hiding this comment.
Reject extra refresh arguments
With input such as /provider refresh foo unexpected, this branch immediately refreshes foo and silently discards the remaining token; if foo exists, an invocation outside the advertised syntax can mutate its catalog instead of showing the usage error. Validate the argument count before dispatching (or parse the full provider ID) so surplus input does not trigger a refresh.
AGENTS.md reference: AGENTS.md:L112-L112
Useful? React with 👍 / 👎.
| "@moonshot-ai/kimi-code": minor | ||
| --- | ||
|
|
||
| Add a `/provider refresh [providerId]` subcommand that re-fetches model lists from providers at runtime. Run `/provider refresh` to update every provider, or `/provider refresh <providerId>` to update one. Typing an unknown `/provider` subcommand now shows a usage hint instead of silently opening the provider manager. |
There was a problem hiding this comment.
Use a single sentence in the changeset
This user-facing entry contains three sentences, while the repository requires one short sentence that states only what changed; condense it before release so the generated changelog follows the mandated changeset format.
AGENTS.md reference: AGENTS.md:L90-L90
Useful? React with 👍 / 👎.
…ider refresh parsing
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 60c8a437cc
ℹ️ 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".
| for (const change of result.changed) { | ||
| if (change.added === 0 && change.removed === 0) { | ||
| // Metadata-only refresh: display name, capabilities, or upgrade info changed. | ||
| host.showStatus(`${change.provider_name}: model metadata updated.`); |
There was a problem hiding this comment.
Report default self-healing in zero-count refreshes
When a refresh repairs an absent defaultModel (the rewrites a missing defaultModel even when the catalog is unchanged case in packages/agent-core-v2/test/app/kosongConfig/discovery.test.ts), the engine deliberately returns a changed item with added: 0 and removed: 0 even though no model metadata changed. This branch therefore tells the user only that metadata changed while the command actually selected and persisted a new default model; use wording that covers configuration changes or compare before/after state and report the default switch. This is fresh evidence beyond the earlier malformed models. output.
AGENTS.md reference: AGENTS.md:L112-L112
Useful? React with 👍 / 👎.
Requirement or Bug
让
/provider支持在运行时手动刷新 provider 的模型列表(此前只有 TUI 启动时和 kap-server 定时器会自动刷新)。Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
apps/kimi-code/src/tui/commands/provider.ts:新增refresh子命令与结果汇报;handleProviderCommand接收参数。apps/kimi-code/src/tui/commands/dispatch.ts:/provider把参数传入 handler;SlashCommandHost接口暴露modelMigration(KimiTUI 已有该 controller,默认模型退役迁移直接复用)。apps/kimi-code/src/tui/controllers/auth-flow.ts:refreshProviderModels增加可选{ providerId }透传(可选参数,向后兼容);有变化时照旧自动refreshAvailableModels(),界面模型列表立即生效。docs/en|zh/reference/slash-commands.md新增/provider refresh [providerId]行;docs/en|zh/configuration/providers.md补充手动刷新说明。scope: 'all'路径);被下架的 alias 会以 warning 色标出(绑定它的 agent 下一轮会报 "Model X is not configured in config.toml");默认模型被 registry 退役且声明了upgrade替代品时,引擎自动迁移所有绑定它的 live agent,TUI 复用现有 model-migration 提示。Behavior Changes and Affected Users
/provider无参数/provider refresh [providerId]/provider <未知文本>/provider受影响模块与测试覆盖:
commands/provider.ts刷新子命令:test/tui/commands/provider.test.ts新增 6 个用例(全量汇报 +N/-M 与 failed、单 provider 范围、removed 警告色、retired_default 走迁移、抛错路径、未知子命令 usage)。controllers/auth-flow.ts可选参数:test/tui/controllers/现有用例全过。test/tui/commands/295 通过、test/tui/controllers/334 通过、tsc --noEmit与oxlint干净。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.