Skip to content

fix: reduce grouped tool refreshes#1512

Open
NarwhalChen wants to merge 1 commit into
MoonshotAI:mainfrom
NarwhalChen:kobe/repo-issue-5pmhcs
Open

fix: reduce grouped tool refreshes#1512
NarwhalChen wants to merge 1 commit into
MoonshotAI:mainfrom
NarwhalChen:kobe/repo-issue-5pmhcs

Conversation

@NarwhalChen

Copy link
Copy Markdown

Related Issue

Fixes #1511

Problem

Grouped Agent and Read transcript components were doing redundant component-level refresh work when attaching a borrowed tool-call component. Actual terminal rendering is coalesced by the TUI scheduler, but the group components still rebuilt and requested render more often than needed.

What changed

  • Let the initial snapshot listener callback drive the first group refresh instead of flushing again from attach().
  • In grouped Agent and Read refresh paths, invalidate child render state through the base container instead of re-entering the component's overridden invalidate() path.
  • Added focused component tests that prove a single attach requests one render for Agent and Read groups.

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.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Verification:

  • pnpm exec vitest run apps/kimi-code/test/tui/components/messages/agent-group.test.ts apps/kimi-code/test/tui/components/messages/read-group.test.ts
  • pnpm exec vitest run apps/kimi-code/test/tui/message-replay.test.ts
  • pnpm exec oxlint --type-aware apps/kimi-code/src/tui/components/messages/agent-group.ts apps/kimi-code/src/tui/components/messages/read-group.ts apps/kimi-code/test/tui/components/messages/agent-group.test.ts apps/kimi-code/test/tui/components/messages/read-group.test.ts
  • pnpm --filter @moonshot-ai/kimi-code run typecheck

@changeset-bot

changeset-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5026e34

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

@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: 5026e34835

ℹ️ 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 on lines 84 to 86
tc.setSnapshotListener(() => {
this.scheduleRender();
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Flush newly attached agents with no phase

When an Agent tool call is grouped before its subagent.spawned event, getSubagentSnapshot().phase is still undefined; the immediate listener callback now goes through scheduleRender(), where detectPhaseTransition() compares undefined to the missing lastFlushPhases entry and returns false. In the existing group path (tryAttachAgentToolCall), no other render is requested for cur.group.attach(...), so the newly attached agent can remain absent/stale until the 200 ms throttle fires; during solo-to-group upgrade it can even render the empty 0 agents finished snapshot produced by transcriptContainer.invalidate(). Keep an immediate first flush for new entries, or treat a missing phase entry as a transition even when the phase is undefined.

Useful? React with 👍 / 👎.

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.

perf(tui): avoid redundant rebuilds in Agent and Read groups

1 participant