Skip to content

fix(ui): make Write tool expandable and show overwrite indicator#9056

Open
Githubguy132010 wants to merge 6 commits intoKilo-Org:mainfrom
Githubguy132010:fix/9053-write-tool-expandable
Open

fix(ui): make Write tool expandable and show overwrite indicator#9056
Githubguy132010 wants to merge 6 commits intoKilo-Org:mainfrom
Githubguy132010:fix/9053-write-tool-expandable

Conversation

@Githubguy132010
Copy link
Copy Markdown
Contributor

Context

Closes #9053.

The reporter said the Write tool card in the chat "is not expandable at all, so you can't see what the agent did / wrote," and asked for an indicator of whether the write was an overwrite or a new file.

Tracing it, the content is already wrapped in a ToolFileAccordion, but the trigger carried no at-a-glance signal — no "Created" badge, no +N -M change count like the sibling Edit tool — so users read the card as flat / non-interactive and never tried to expand it.

Backend already emits exists: boolean and filediff.{additions,deletions} in the Write tool metadata (packages/opencode/src/tool/write.ts), so no backend changes needed.

Implementation

Brings the Write tool's trigger to parity with Edit / apply_patch:

  • packages/kilo-ui/src/components/message-part.tsx (used by the VS Code sidebar): ToolMetaLine in the trigger now receives changes={props.metadata.filediff} — so the header shows +N -M at rest. The ToolFileAccordion gets an actions prop that shows a "Created" badge (data-slot="apply-patch-change" data-type="added", reusing the ui.patch.action.created i18n key) when metadata.exists === false, or <ToolChanges> otherwise.
  • packages/ui/src/components/message-part.tsx (upstream @opencode-ai/ui): same logic, using the simpler DiffChanges-only pattern this file already uses for Edit/apply_patch. Wrapped in // kilocode_change start/end per repo convention.
  • Accordion now renders whenever the path is known (previously gated on input.content && path), so the header + badge show even for an empty write; the inner content body still guards on input.content != null.
  • Reuses the existing ui.patch.action.created i18n key — no new translation strings.

Screenshots

before after

How to Test

  1. Run the VS Code extension (or kilo-vscode webview storybook).
  2. Ask the agent to write a new file. The Write card header should show a Created badge next to the filename.
  3. Ask the agent to overwrite an existing file. The header should show +N -M additions/deletions counts instead of the badge.
  4. Click the card. The accordion expands and shows the file contents that were written.
  5. Repeat in the opencode TUI / @opencode-ai/ui storybook — same behavior via the shared packages/ui renderer.

Get in Touch

🤖 Generated with Claude Code

…te tool

The Write tool card in the chat had no at-a-glance signal of what it
did — no "Created" vs overwrite indicator, and no additions/deletions
count like the sibling Edit tool shows. Without those cues the
`ToolFileAccordion` expand affordance read as a flat non-interactive
card, even though the file contents were already available.

Adds a "Created" badge when `metadata.exists === false`, and +/- change
counts from `metadata.filediff` otherwise, both in the trigger header
and as actions on the accordion header — matching the patterns used by
the Edit and apply_patch renderers. Also drops the `input.content`
guard on the accordion so empty writes still render their header.

Closes Kilo-Org#9053

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Comment thread packages/ui/src/components/message-part.tsx Outdated
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Apr 16, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/kilo-ui/src/components/message-part.tsx
  • packages/ui/src/components/message-part.tsx

Reviewed by gpt-5.4-20260305 · 641,340 tokens

The outer BasicTool trigger in packages/ui was gating on
metadata.exists, so newly created files rendered a plain
filename/path header with no change indicator — defeating the
whole point of the fix, since users can't tell the card is
expandable in the first place.

Mirror the inner accordion's Switch in the outer trigger: Created
badge when exists === false, +/- counts otherwise.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

The Write tool be expandable to show what was written and whether it was an overwrite

1 participant