Skip to content

feat: render edit and write tool input as a line diff - #40

Open
johnnyhuy wants to merge 1 commit into
mainfrom
agent/issue-39-tool-card-diff-view
Open

johnnyhuy wants to merge 1 commit into
mainfrom
agent/issue-39-tool-card-diff-view

Conversation

@johnnyhuy

Copy link
Copy Markdown
Contributor

Edit and write tool cards now render their Input as a line diff instead of one plain text block. Removed lines show with a minus prefix and a removed tone, added lines show with a plus prefix and an added tone, and unchanged lines stay plain. A write renders every file line as added.

Part of #2
Closes #39

What changed:

  • src/renderer/timeline.ts carries the structured payload on the tool entry. Edit keeps its old and new text and write keeps its content as new text against an empty old side, for both saved messages and live tool events. The plain input text is unchanged, so summaries and copying keep their current behaviour.
  • src/renderer/components/WorkbenchControls.tsx adds a diff section for edit and write cards. It computes a line diff with a shared prefix check that falls back to a plain removed-then-added listing for very large inputs, keeps the Copy input button copying the exact plain input text, and keeps the long-text Show more and Show less toggle. Other tools keep the plain Input section.
  • src/renderer/workbench.css adds the diff row styles using the existing success and error tokens.

Verified:

  • bun install --frozen-lockfile passed
  • bun run lint passed, 0 warnings and 0 errors
  • bun run typecheck passed across renderer, main, and preload configs
  • bun run test:unit passed, 74 tests. New tests are carries old and new text for an edit tool call, carries write content as new text against an empty old side, and tool_execution_start carries edit old and new text.
  • bun run test:integration shows the new ToolCard tests passing, 40 passed with 6 failures in SettingsView.test.tsx. Those 6 failures reproduce on clean origin/main at 9c0a66b in this environment with the same localStorage error, so they are pre-existing here and not caused by this change. Focused run bunx vitest run --project integration tests/integration/ToolCard.test.tsx passed, 7 tests.
  • mise run build passed after mise trust for this worktree
  • bun run test:e2e blocked in this environment. Electron fails to launch and all 43 e2e tests skip with 5 failed files and 3 errors, matching the previous run on this machine. Noted once here and not retried.

Proof:

  • Capture method (b) succeeded through the renderer. A temporary Vite proof page rendered an expanded edit tool card, and a scripted Chrome capture saved .tmp/proof/tool-card-diff.png. The capture log recorded hasAdd: 1, hasDel: 1, hasContext: 1, hasCopyInput: 1, addText: +const after = 2;, and delText: -const before = 1;. The screenshot shows the context line plain, the removed line in the removed tone with a minus prefix, the added line in the added tone with a plus prefix, and both Copy buttons. The PNG is kept under .tmp/proof/ locally and is not committed, matching the scratch-capture rule for this repo. The temporary proof page was removed before committing.
  • Capture method (a) was blocked by the Electron launch failure above, so method (c) carries the logic proof. New integration tests in ToolCard.test.tsx are renders edit input as a diff with added, removed, and context lines, renders write input as added lines, and copies the exact plain input text from a diff card.

Known gaps and follow-ups:

  • No syntax highlighting and no side-by-side layout in the diff. The Changes view keeps the full diff renderer for Git patches.
  • Parent Render tool calls as interactive cards #2 stays open. This slice covers edit and write input diff rendering only.

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.

Render edit and write tool input as a line diff on tool call cards

1 participant