Skip to content

fix(tui): unify skill messages and steering - #4084

Open
Grapedge wants to merge 4 commits into
mainfrom
feat/tui-skill-message-steer
Open

Grapedge wants to merge 4 commits into
mainfrom
feat/tui-skill-message-steer

Conversation

@Grapedge

@Grapedge Grapedge commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

TUI 行首技能曾走独立激活路径,行内技能消息无法 steer;消息式技能调用还会额外显示 Activated skill,而旧会话只有这张卡片、没有用户消息。

Bug Reproduction Steps

  1. 输入 /skill:review 检查这段代码:旧路径不显示原输入;新路径同时显示技能激活卡片和原输入。
  2. 在轮次运行时排入 请用 /skill:review 检查这段代码,再按 Ctrl-S:旧路径无法 steer。
  3. 恢复旧版独立激活的会话:只看到技能激活卡片。

Root Cause

行首技能原先调用独立的 activateSkill,行内技能则调用 promptWithSkills。TUI 还把每个 skill.activated 实时事件和回放的技能元数据都渲染为卡片;新版消息自身又渲染一次原始用户输入。本改动统一技能消息提交入口,并在回放时按落盘消息的 origin 区分旧版独立调用与新版消息式调用。

Code Changes

TUI 技能输入
- 行首单技能 → 独立激活
+ 行首和行内技能 → 原始用户消息 + 技能激活,一次提交
+ 只有行首单技能解析尾随参数;多个技能仍不解析参数

TUI 显示
- 激活事件 / 技能元数据 → Activated skill 卡片
+ 新版消息 → 显示原始用户消息一次
+ 旧版独立调用回放 → 由技能名和参数拼出一条用户消息

Ctrl-S
- 在首条含技能消息前停止
+ 普通消息与含技能消息按队列顺序提交
+ 含技能消息经 promptWithSkills(steerIfActive) 进入当前轮次

TUI 保留内置命令和插件命令的优先级、行首单技能的参数与命令遥测,以及失败时的输入和媒体恢复。行首技能等待进行中的视频上传;混合 Ctrl-S 批次中,技能成功而后续普通消息失败时,普通消息、媒体和队列顺序会恢复;技能提交失败后,idle 状态的新输入也会排在恢复的旧请求之后。SDK 原有两参数 promptWithSkills 调用及导出的 RPC 基类 Promise<void> 签名保持不变;steerIfActive 的结果走单独方法。web/desktop 的 steer 链路没有修改。

Behavior Changes and Affected Users

行为 之前 之后 依赖旧行为的用户 回退方式
TUI 行首单技能 独立激活,原输入不显示为用户消息;可解析参数 整条原输入作为用户消息提交并显示;仍解析参数 使用 /skill:name args 的 TUI 用户 无;需求已明确接受替换独立路径
TUI 技能激活提示 用户、模型或嵌套技能激活均显示 Activated skill 卡片 不显示激活卡片;用户发起的技能调用显示为用户消息 查看 TUI 技能激活卡片的用户 无;产品需求明确要求移除 TUI 卡片,事件和非 TUI 客户端不变
旧版独立调用的会话回放 显示技能激活卡片,不显示用户消息 用保存的技能名和参数拼出一条用户消息;旧版原文无法完全还原 恢复旧会话的 TUI 用户 原始输入未落盘,无法恢复逐字原文
TUI 行首多技能、行内技能 整条消息携带技能;不解析参数 同样携带整条消息且不解析参数,改用共同解析入口 在消息中使用多个或行内技能的 TUI 用户 不适用,行为保留
TUI 内置和插件斜杠命令 优先于技能解析 优先级不变 使用同名命令的 TUI 用户 不适用,行为保留
运行中对含技能消息按 Ctrl-S 行内技能消息阻断 steer,后续消息也留在队列 队列与草稿中的普通消息、技能消息按顺序 steer;bash 仍留队 排队使用技能并按 Ctrl-S 的 TUI 用户 不按 Ctrl-S 时仍按原排队流程提交
技能消息准备或 steer 失败 输入可能在编辑器清空后丢失 恢复草稿或按原顺序放回队列,保留媒体引用 遇到媒体准备或提交失败的 TUI 用户 不适用
SDK/klient 技能提交参数 不接受 steerIfActive;外部 RPC 子类覆盖 Promise<void> 可选参数;省略时维持原行为,外部子类签名不变 SDK 调用者,以及通过 klient 调用的客户端 省略该参数

旧路径的能力对应到新路径:命令优先级在 TUI resolver;单技能参数、遥测和多技能无参数规则在 dispatch/resolver;忙时排队、模型与媒体校验、失败恢复在 TUI 消息提交与 Ctrl-S 批次中。激活事件仍向其他客户端发送;本次只改变 TUI 呈现。

覆盖:TUI message-flow 测试验证原消息、参数、媒体、排队、steer 顺序、失败恢复及旧会话回放后的 /undo;message-replay 测试验证新旧格式各只显示一条用户消息,并隐藏模型注入的技能正文;editor-keyboard 和 agent-core-v2 技能测试覆盖 Ctrl-S 与当前轮次提交。本次更新后的相关 TUI 测试 396 个、SDK 技能测试 11 个通过,TUI 与 SDK 类型检查、仓库 lint 通过。此前分支全量 Vitest 运行有 4 个非本改动失败:2 个缺少 zstd,另 2 个分别为超时和文件监听 EMFILE。

gen-docs 曾运行,但其前置文件 docs/scripts/sync-changelog.mjs 不在仓库中,故按技能要求停止文档流程;本 PR 未扩展到文档改动。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Copilot AI balanced review requested due to automatic review settings September 29, 2026 12:03
@changeset-bot

changeset-bot Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e39bc8e

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

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

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

@pkg-pr-new

pkg-pr-new Bot commented Sep 29, 2026 •

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

commit: e39bc8e

@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: 2afb567877

ℹ️ 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".

Comment thread apps/kimi-code/src/tui/kimi-tui.ts
Comment thread .changeset/tui-skill-message-steer.md Outdated

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.

Copilot review overview

🔵 Needs a closer look

It changes an externally-consumed SDK/contract surface and reworks an intricate TUI submission/steering state machine with user-facing behavior changes, warranting human verification despite thorough tests.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

This PR unifies how the TUI submits skill invocations so that a leading /skill:<name> args command follows the same path as inline skill tokens: instead of a standalone activateSkill call (which never displayed the original input), the raw user message plus skill activations are submitted together via promptWithSkills, and the original message is shown in the transcript. It also makes queued/draft skill messages steerable with Ctrl-S by threading a new opt-in steerIfActive option through the SDK (Session.promptWithSkills), the RPC layer, the klient contract schema, and the agent-core-v2 skill service (which routes it to the loop's existing steer-into-active-turn support).

Changes:

  • Add an opt-in steerIfActive option to promptWithSkills across node-sdk (overloaded to return PromptWithSkillsResult), the RPC interface, the klient schema, and the engine skill service (returning turn_id/state: 'running' when steered).
  • Rewrite the TUI dispatch/resolve/Ctrl-S paths so leading and inline skills share one submission entry point, with a mixed steer batch that preserves queue order, single-skill argument parsing, telemetry, and failure recovery of draft/queued input and media.
  • Add extensive TUI and engine tests plus a patch changeset.
File Description
packages/​node-sdk/​src/​session.ts Overloads promptWithSkills to optionally return the launch result when steerIfActive is set.
packages/​node-sdk/​src/​sdk-rpc-client-v2.ts Forwards steerIfActive and returns the engine result instead of dropping it.
packages/​node-sdk/​src/​rpc.ts Adds steerIfActive to the RPC input and changes the abstract return type to PromptWithSkillsResult.
packages/​klient/​src/​contract/​agent/​schemas.ts Adds optional steerIfActive to the wire payload schema.
packages/​agent-core-v2/​src/​features/​skill/​skill.ts Adds steerIfActive to PromptWithSkillsInput.
packages/​agent-core-v2/​src/​features/​skill/​skillService.ts Passes steerIfActive to loop.submit and returns turn_id/running when steered.
packages/​agent-core-v2/​test/​features/​skill/​activateSkill.test.ts Adds a test that a bundled skill message steers into a running turn with its args.
apps/​kimi-code/​src/​tui/​commands/​dispatch.ts Routes leading skills through sendInlineSkillUserInput; removes dispatchInlineSkillCombo and sendSkillActivation from the host.
apps/​kimi-code/​src/​tui/​commands/​resolve.ts Adds resolveSkillMessageActivations shared by dispatch and Ctrl-S.
apps/​kimi-code/​src/​tui/​controllers/​editor-keyboard.ts Rewrites Ctrl-S into an ordered steer batch of text/skill/bundle runs with failure recovery.
apps/​kimi-code/​src/​tui/​kimi-tui.ts Adds skill-steer batch flags, steerSkillMessage, recoverRejectedSkillInput, and media/turn binding in runInlineSkillActivations.
apps/​kimi-code/​src/​tui/​types.ts Drops the stale comment restricting InlineSkillActivation.args usage.
apps/​kimi-code/​test/​tui/​*.test.ts Broad new coverage for submission, media, queueing, steer ordering, and failure recovery.
.changeset/​tui-skill-message-steer.md Adds a patch changeset for the user-facing display change.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +475 to +481
else if (run.kind === 'skill') {
success = await host.steerSkillActivation(
session,
run.item.skillName!,
run.item.skillArgs ?? '',
);
} else success = await host.steerSkillMessage(session, run.item);

@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: 4cfe0d1664

ℹ️ 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".

Comment thread apps/kimi-code/src/tui/controllers/editor-keyboard.ts Outdated
Comment thread packages/node-sdk/src/rpc.ts Outdated

@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: 5511498e0b

ℹ️ 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".

Comment thread apps/kimi-code/src/tui/kimi-tui.ts
@Grapedge

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: e39bc8e486

ℹ️ 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".

This branch has not been deployed

No deployments
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.

2 participants