Skip to content

feat(kimi-code): specialize the WaitFor tool's transcript display - #3066

Merged
chengluyu merged 14 commits into
mainfrom
feat/wait-for-tui
Aug 19, 2026
Merged

feat(kimi-code): specialize the WaitFor tool's transcript display#3066
chengluyu merged 14 commits into
mainfrom
feat/wait-for-tui

Conversation

@chengluyu

Copy link
Copy Markdown
Collaborator

Related Issue

Stacks on #3060 (the WaitFor tool). When that PR merges, GitHub will retarget this one to main automatically.

Problem

WaitFor currently renders through the generic transcript path: a Used WaitFor (task_id) header plus the first 3 lines of the raw key-value output. The interesting facts — which task the wait returned with, its outcome, what else finished during the window, and what is still running — are buried in the collapsed ... (N more lines) tail. While the wait is pending (up to 600s), the card is completely static with no indication of progress.

What changed

  • Specialized result renderer (tool-renderers/wait-for.ts, registered in registry.ts): parses the wait timeline and renders a glance — ✓ question-80w0h7nw completed · <description> (or ✗ … failed), then +N more finished during wait · M background tasks still running; timeouts list the still-running tasks by description. Expanding still shows the full raw output. Errors fall back to the truncated renderer.
  • Header takeover (same pattern as the goal tools): Waiting for background task (id) while pending, Waited for background task (id) once completed, Wait timed out (id) in the warning tone (a timeout is not an error), Could not wait for background task on error.
  • Elapsed chip: · 10s next to the header once the wait returns.
  • Live progress while pending (engine side): WaitForTool emits an onUpdate status every 10s (Waiting 30s / 600s · 2 background tasks still running), rendered by the existing progress pipeline as dim lines inside the card.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works (renderer cases in registry.test.ts, header cases in tool-call.test.ts, progress emission in agent-core-v2's task-tools.test.ts).
  • Ran gen-changesets skill (two patch changesets, one per logical change).
  • No doc update needed (transcript rendering detail).

@changeset-bot

changeset-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0f6f2a2

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 Aug 19, 2026

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

commit: 0f6f2a2

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

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

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/kimi-code/src/tui/components/messages/tool-renderers/wait-for.ts Outdated
Comment thread packages/agent-core-v2/src/agent/tools/task/task-wait/taskWaitTool.ts Outdated
Comment thread packages/agent-core-v2/src/agent/tools/task/task-wait/taskWaitTool.ts Outdated
@chengluyu

Copy link
Copy Markdown
Collaborator Author

@codex review

All three suggestions from the last round are addressed in separate commits:

  1. Route WaitFor dimming through the TUI theme (42dc431): the new renderer's chalk.dim calls now go through currentTheme.dim.
  2. Replace the previous periodic wait status (d980888): ToolUpdate gained an optional replace flag, threaded through protocol (interface + zod schema), the klient mirror schema, agent-core-v2's toolContract.ts, and the TUI. WaitForTool's periodic updates emit replace: true, and ToolCallComponent.appendProgress swaps out the previous replaceable status block instead of stacking rows to the 24-row cap. Existing status emitters (e.g. the MCP OAuth wait) don't pass the flag and keep append semantics.
  3. Forward wait status updates from child agents (e13ab05): the foreground subagent card now folds kind: 'status' progress into the sub-tool live-output window, and SubagentActivityStore surfaces it as the call's liveOutputTail (which is already a latest-row surface, so each tick overwrites cleanly).

Each commit carries its own tests; full suites pass locally (agent-core-v2 5282, kimi-code TUI 2141, protocol 535, klient 108).

@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: e13ab05ebb

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

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agent-core-v2/src/tool/toolContract.ts Outdated
Comment thread apps/kimi-code/src/tui/controllers/subagent-event-handler.ts
Comment thread packages/agent-core-v2/test/agent/task/tools/task-tools.test.ts Outdated
@chengluyu

Copy link
Copy Markdown
Collaborator Author

@codex review

Third round addressed, one commit per suggestion:

  1. Drop redundant undefined from the optional flag (7ed7094): replace?: boolean now follows the repo-wide optional-property convention.
  2. Honor replacement for child wait statuses (653a3be): appendSubToolLiveOutput takes a replace option (replaces the rolling output instead of appending), and the subagent event handler forwards event.update.replace through it. This also required letting WaitFor render in the subagent card's active window at all — it was excluded once it gained a dedicated result renderer, so it now sits next to Bash in the live-output allowlist.
  3. Drive the interval test through a clock seam (9ffe707): the progress emission is extracted as the pure waitForProgressUpdate(args, runningCount, startedAt, now), and startProgress returns { stop, tick } where tick is the exact interval callback. The test fires a manual tick and asserts the composed update — no fake timers, per the agent-core-v2 test guidance.

Full suites green locally (agent-core-v2 5283, kimi-code TUI 2142, protocol 535, klient 108). The test (5) failure last round (serializes a temporary title-generation close against a public resume) is unrelated to this diff — watching whether it recurs on this push.

@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: 9ffe7073a8

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

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/protocol/src/events.ts
Comment thread packages/agent-core-v2/test/agent/task/tools/task-tools.test.ts Outdated
@chengluyu

Copy link
Copy Markdown
Collaborator Author

@codex review

Fourth round addressed:

  1. Add replace to the daemon event schema (b031a71): kap-server's events-zod.ts toolUpdateSchema now mirrors the optional replace boolean, so the /api/v1/ws contract and asyncapi-generated clients carry it.
  2. Drive the tick without casting through a private method (0a78a36): the scheduler is now the exported startWaitProgress(args, tasks, onUpdate, startedAt) returning { stop, tick }; WaitForTool composes it, and the test drives tick() directly on the public function — no casts, no private reach, no fake timers.

agent-core-v2 full suite green locally (5283); kap-server typecheck green. Note: kap-server's test/search/* suites fail identically on the base branch in this checkout (68 failures with or without this diff — local environment, CI passes them), so they are not caused by this change.

@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: 0a78a3617c

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

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/kimi-code/src/tui/controllers/subagent-event-handler.ts Outdated
@chengluyu

Copy link
Copy Markdown
Collaborator Author

@codex review

Fifth round: the child-agent status path now forwards the text without the appended newline (72d19ac) — with replace semantics the buffer resets every tick, so the separator was only producing a blank row that pushed the elapsed/timeout values out of the narrow two-row window. kimi-code TUI suites green locally (2142).

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 72d19ac85e

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

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Base automatically changed from feat/wait-for to main August 19, 2026 03:27
@chengluyu

Copy link
Copy Markdown
Collaborator Author

@codex review

Two more commits since the last review: per-second progress ticks (4b42116 — the progress event is transient/observable-only, not written to the wire log, so a 1s cadence is just one bus publish + one card re-render) and duration formatting (34d1c38Waiting 1m 15s / 10m 00s, matching the existing goal elapsed style).

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 34d1c38e3b

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

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chengluyu
chengluyu merged commit 01eeacb into main Aug 19, 2026
15 checks passed
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.

1 participant