Skip to content

refactor(web): extract pure turn-rendering helpers from ChatPane#1001

Merged
wbxl2000 merged 3 commits into
mainfrom
refactor/web-split-chatpane
Jun 23, 2026
Merged

refactor(web): extract pure turn-rendering helpers from ChatPane#1001
wbxl2000 merged 3 commits into
mainfrom
refactor/web-split-chatpane

Conversation

@wbxl2000

Copy link
Copy Markdown
Collaborator

Related Issue

N/A — internal refactor, no user-facing behavior change.

Problem

ChatPane.vue was ~1550 lines, with roughly 400 lines of <script setup> helper functions mixed in with the component's reactive state, props, and emits. Many of those helpers are pure functions of a chat turn (rendering, formatting, markdown conversion) and don't need to live in the component.

What changed

Extract the pure turn-rendering helpers into a new module chatTurnRendering.ts:

  • ChatPane.vue 1550 → 1427 lines.
  • New chatTurnRendering.ts (139 lines) exports: formatTokens, formatDuration, turnBlocks, rendersToolCard, toolStackPosition, toolStackKey, renderBlockKey, assistantRenderBlocks, turnFinalText, turnToMarkdown, plus the types ToolStackPosition, ToolStackItem, AssistantRenderBlock.
  • TurnBlock is imported from ../types (single source of truth) rather than redefined.
  • Stateful helpers (copy/edit/undo, time display, lazy-load sentinel, computed values, i18n-using compactionDividerLabel) stay in ChatPane.vue.

Function bodies are relocated byte-for-byte (only export added); ChatPane.vue imports them back. No behavior change. Verified with typecheck, test (26), build, and oxlint (0 errors / 0 warnings on the changed files).

This continues the big-component split from the web refactor plan (after Sidebar → WorkspaceGroup in #998).

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. (N/A — pure refactor; the moved helpers are pure functions already exercised by existing tests.)
  • Ran gen-changesets skill, or this PR needs no changeset. (Patch on @moonshot-ai/kimi-code; @moonshot-ai/kimi-web is ignored and bundled into the CLI.)
  • Ran gen-docs skill, or this PR needs no doc update. (No user-facing behavior change.)

@changeset-bot

changeset-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fd9568f

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 Jun 23, 2026

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

commit: fd9568f

Pure-logic tests for the helpers extracted from ChatPane, focused on
assistantRenderBlocks (tool-stack grouping, interrupt/media break, single
tool) plus the formatting/boundary helpers. Doubles as a safety net
confirming the extraction preserved behavior.
@wbxl2000 wbxl2000 merged commit ea1b33b into main Jun 23, 2026
8 checks passed
@wbxl2000 wbxl2000 deleted the refactor/web-split-chatpane branch June 23, 2026 07:20
@github-actions github-actions Bot mentioned this pull request Jun 23, 2026
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