From ef951aff5d3c6bf733decbac5aa08c461ff400ca Mon Sep 17 00:00:00 2001 From: mangeshraut712 Date: Thu, 30 Jul 2026 23:17:56 +0530 Subject: [PATCH] fix(web): register /usage slash command in the command menu Web documented /usage as available but the built-in slash list and handler omitted it, so the menu hid the command and free-typed /usage was sent as a normal prompt. Add the command, open the status panel (context tokens + cost), and cover it in the slash-menu tests. Fixes #2354 --- .changeset/web-usage-slash-command.md | 6 ++++++ apps/kimi-web/src/App.vue | 3 +++ apps/kimi-web/src/i18n/locales/en/commands.ts | 1 + apps/kimi-web/src/i18n/locales/zh/commands.ts | 1 + apps/kimi-web/src/lib/slashCommands.ts | 1 + apps/kimi-web/test/slash-menu.test.ts | 6 ++++++ 6 files changed, 18 insertions(+) create mode 100644 .changeset/web-usage-slash-command.md diff --git a/.changeset/web-usage-slash-command.md b/.changeset/web-usage-slash-command.md new file mode 100644 index 0000000000..e71a3df371 --- /dev/null +++ b/.changeset/web-usage-slash-command.md @@ -0,0 +1,6 @@ +--- +"@moonshot-ai/kimi-web": patch +"@moonshot-ai/kimi-code": patch +--- + +Register the /usage slash command in kimi web so it appears in the command menu and opens the session status panel with context and cost. diff --git a/apps/kimi-web/src/App.vue b/apps/kimi-web/src/App.vue index 5708bcc9bf..111a16687a 100644 --- a/apps/kimi-web/src/App.vue +++ b/apps/kimi-web/src/App.vue @@ -567,6 +567,9 @@ function handleCommand(cmd: string): void { client.setThinking(nextThinkingLevel(client.thinking.value)); break; case '/status': + case '/usage': + // /usage shares the status panel: it already surfaces context tokens and + // session cost, which is the web equivalent of the TUI /usage report. showStatusPanel.value = true; break; case '/login': diff --git a/apps/kimi-web/src/i18n/locales/en/commands.ts b/apps/kimi-web/src/i18n/locales/en/commands.ts index ef44f0f06a..31b909137b 100644 --- a/apps/kimi-web/src/i18n/locales/en/commands.ts +++ b/apps/kimi-web/src/i18n/locales/en/commands.ts @@ -16,5 +16,6 @@ export default { noSession: 'Open a session before exporting it.', }, status: { desc: 'View session status' }, + usage: { desc: 'Show session tokens, context window, and cost' }, undo: { desc: 'Undo the last message' }, } as const; diff --git a/apps/kimi-web/src/i18n/locales/zh/commands.ts b/apps/kimi-web/src/i18n/locales/zh/commands.ts index c3b753004f..38e1d464cc 100644 --- a/apps/kimi-web/src/i18n/locales/zh/commands.ts +++ b/apps/kimi-web/src/i18n/locales/zh/commands.ts @@ -16,5 +16,6 @@ export default { noSession: '请先打开一个会话再导出。', }, status: { desc: '查看会话状态' }, + usage: { desc: '查看会话 token、上下文窗口与费用' }, undo: { desc: '撤销上一条消息' }, }; diff --git a/apps/kimi-web/src/lib/slashCommands.ts b/apps/kimi-web/src/lib/slashCommands.ts index cbc080efd0..a89117233c 100644 --- a/apps/kimi-web/src/lib/slashCommands.ts +++ b/apps/kimi-web/src/lib/slashCommands.ts @@ -37,6 +37,7 @@ export const SLASH_COMMANDS: SlashCommand[] = [ { name: '/fork', desc: 'commands.fork.desc' }, { name: '/export', desc: 'commands.export.desc' }, { name: '/status', desc: 'commands.status.desc' }, + { name: '/usage', desc: 'commands.usage.desc' }, ]; /** diff --git a/apps/kimi-web/test/slash-menu.test.ts b/apps/kimi-web/test/slash-menu.test.ts index 35694194a6..18c7d8a2c7 100644 --- a/apps/kimi-web/test/slash-menu.test.ts +++ b/apps/kimi-web/test/slash-menu.test.ts @@ -52,6 +52,12 @@ describe('useSlashMenu — update', () => { expect(slash.active.value).toBe(0); }); + it('lists /usage among built-in commands', () => { + const { slash } = setup('/'); + slash.update(); + expect(slash.items.value.map((i) => i.name)).toContain('/usage'); + }); + it('filters to matching commands', () => { const { slash } = setup('/com'); slash.update();