Skip to content

feat(jetbrains): render edit tool diff previews in session view - #12491

Merged
kirillk merged 10 commits into
mainfrom
granite-anemone
Jul 24, 2026
Merged

feat(jetbrains): render edit tool diff previews in session view#12491
kirillk merged 10 commits into
mainfrom
granite-anemone

Conversation

@kirillk

@kirillk kirillk commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Context

Improves how edit-related tool results are presented in the JetBrains session view so changes are easier to read and inspect directly in the chat transcript.

Implementation

Features and improvements in this PR:

  • Render write, edit, and apply_patch tool results as expandable diff previews instead of generic tool output.
  • Show an Edit/Patch header with clickable file links and aggregate change counts.
  • Syntax-highlighted diff blocks for edited content.
  • Distinguish multi-file apply_patch results as a Patch with a file-count tag and one clickable per-file section.
  • Open the exact file referenced by an edit tool link.
  • Widen collapsed header popovers so edit and shell previews fit wider content while reasoning stays narrow.
  • Improve chat transcript scrolling performance in large sessions, scoping scroll-hover work to the hovered pane.

Screenshots

GIF Recording 2026-07-23 at 9 56 48 PM

How to Test

Manual/local verification

Reviewer test steps

  1. Open a JetBrains session that includes write, edit, and apply_patch tool results.
  2. Confirm each renders as an expandable diff preview with file links and change counts.
  3. Confirm multi-file patches show a file-count tag and separate clickable per-file sections.
  4. Scroll a large transcript and confirm smooth scrolling.

Blocked checks and substitute verification

Checklist

  • Issue linked above, or exception explained
  • Tests/verification described
  • Screenshots/video included for visual changes, or marked N/A
  • Changeset considered for user-facing changes
  • I personally reviewed the diff and can explain the changes, including any AI-assisted work.

Get in Touch

@kirillk
kirillk marked this pull request as draft July 23, 2026 12:56
@kilo-code-bot

kilo-code-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

This incremental review covers the diff since the last reviewed commit (79e606eb..f0b3a829), which contains only the removal of an internal planning document (.kilo/plans/1784814134016-jetbrains-session-scroll-perf.md) — no source or test changes. All previously flagged issues on this PR have author replies confirming fixes in 5379e96750 / 7ff2452072, consistent with the prior "No Issues Found" review of the code changes.

Files Reviewed (1 file in incremental diff)
  • .kilo/plans/1784814134016-jetbrains-session-scroll-perf.md (deleted, non-code planning doc)
Previous Review Summaries (4 snapshots, latest commit 79e606e)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 79e606e)

Status: No Issues Found | Recommendation: Merge

This incremental review covers the new fix(jetbrains): scope transcript scroll-hover work to the hovered pane commit — MdViewHybrid's prose pane now only subscribes to its enclosing viewport's scroll ChangeListener while the pointer is actually hovering it, instead of every prose block in the transcript listening unconditionally. The arm/disarm logic (listen(), retarget()) correctly tracks reparenting and disposal, and the new test (test prose pane tracks viewport scrolls only while hovered) verifies the listener is added on MOUSE_ENTERED and removed on MOUSE_EXITED against the real JViewport listener list rather than a mock.

No new issues found in this incremental diff (MdViewHybrid.kt, MdViewHybridTest.kt).

Files Reviewed (2 files in incremental diff)
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/md/hybrid/MdViewHybrid.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/ui/md/MdViewHybridTest.kt

Previous review (commit 7ff2452)

Status: No Issues Found | Recommendation: Merge

All 5 previously-reported issues (SessionLayout stale-height cache, dead setLinkText fallback mismatch, patchMarkdown missing metadata-only fallback, redundant EditToolView.update(item) call, vacuous EditToolViewTest assertions) were verified fixed in commit 7ff24520 and are resolved. forget()/forgetTurn() correctly invalidate the layout cache for settled TurnViews, patchMarkdown now falls back to the raw patch when stripping leaves nothing, and the new/updated tests exercise the intended behavior.

No new issues found in this incremental diff (SessionLayout.kt, SessionMessageListPanel.kt, EditToolView.kt, ToolSupport.kt, SessionLayoutTest.kt, EditToolViewTest.kt).

Files Reviewed (6 files in incremental diff)
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/SessionLayout.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/SessionMessageListPanel.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/tool/EditToolView.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/tool/ToolSupport.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/SessionLayoutTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/views/EditToolViewTest.kt

Previous review (commit 5379e96)

Status: 5 Issues Found | Recommendation: Address before merge

All 6 previously-reported issues (Disposer leak in swapBody(), unreachable is JComponent branch, applyStyle() under-reporting, MdDiffHighlight file-header misclassification, duplicate editPath(item) computation, weak badge-count assertion) were verified fixed in commit 5379e967 and are resolved.

This incremental review covers the new fix(jetbrains): distinguish multi-file patches commit, including the new session-scroll-performance work (SessionLayout, SessionScroll, SessionMessageListPanel) and the multi-file patch popup support.

Overview

Severity Count
CRITICAL 1
WARNING 2
SUGGESTION 2
Issue Details (click to expand)

CRITICAL

File Line Issue
SessionLayout.kt 82 New measurement cache can return a stale height when an independently-settled TurnView validate root self-validates before the panel's own relayout runs

WARNING

File Line Issue
ToolSupport.kt 517 setLinkText is now dead code (unreachable) with a fallback behavior mismatch vs. the code it replaced
ToolSupport.kt 889 patchMarkdown dropped its ifBlank fallback, rendering an empty code block for metadata-only patches (pure renames/mode changes)

SUGGESTION

File Line Issue
EditToolView.kt 214 Redundant update(item) call immediately after mount(item), which already updates internally
EditToolViewTest.kt 185 Two assertions are vacuously true and don't actually exercise the intended header-stripping case
Files Reviewed (21 files in incremental diff)
  • .changeset/jetbrains-diff-preview-fixes.md
  • .changeset/jetbrains-session-scroll-perf.md
  • .kilo/plans/1784814134016-jetbrains-session-scroll-perf.md
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/scroll/SessionScroll.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/SessionLayout.kt - 1 issue
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/SessionMessageListPanel.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/popup/HeaderPopup.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/MessageView.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/TurnView.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/tool/EditToolView.kt - 1 issue
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/tool/PatchBody.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/tool/ReadToolView.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/tool/ToolMarkdownBody.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/tool/ToolSupport.kt - 2 issues
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/md/hybrid/MdDiffHighlight.kt
  • packages/kilo-jetbrains/frontend/src/main/resources/kilo.jetbrains.frontend.xml
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/SessionLayoutTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/SessionMessageListPanelTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/views/EditToolViewTest.kt - 1 issue
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/views/ReadToolViewTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/ui/md/hybrid/MdDiffHighlightTest.kt

Localization property files and remaining changeset files were reviewed but had no issues beyond what's noted above.

Fix these issues in Kilo Cloud

Previous review (commit acaa893)

Status: 6 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 1
WARNING 3
SUGGESTION 2
Issue Details (click to expand)

CRITICAL

File Line Issue
EditToolView.kt 106 swapBody() leaks the outgoing EditBody's Disposer-registered editor resources on every single/multi-file boundary crossing during streaming

WARNING

File Line Issue
HeaderPopup.kt 60 is JComponent branch unreachable dead code — is Container matches first, undersizing popups for leaf components
PatchBody.kt 102 applyStyle() under-reports whether a style change occurred, can skip relayout after font/theme change
MdDiffHighlight.kt 63 File-header check matches on raw diff-line content, misclassifying inserted/removed lines starting with ++/--

SUGGESTION

File Line Issue
EditToolView.kt 179 editPath(item) computed twice on the same line
EditToolViewTest.kt 124 Assertion (>= 2) weaker than the one-badge-per-file behavior the comment claims to verify
Files Reviewed (16 files)
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/popup/HeaderPopup.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/style/SessionUiStyle.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/ViewFactory.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/tool/EditToolView.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/tool/PatchBody.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/tool/ReadToolView.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/tool/ShellToolView.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/tool/ToolMarkdownBody.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/tool/ToolSupport.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/md/hybrid/MdDiffHighlight.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/md/hybrid/MdLanguage.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/md/hybrid/MdViewHybrid.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/views/EditToolViewTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/views/ReasoningViewTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/views/ShellToolViewTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/views/ToolBodyStressTest.kt

Localization property files (KiloBundle*.properties) and changesets were reviewed but had no issues beyond what's noted above.

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-5 · Input: 24 · Output: 3.8K · Cached: 519.3K

Review guidance: REVIEW.md from base branch main

@kirillk
kirillk marked this pull request as ready for review July 23, 2026 18:47
kirillk added 9 commits July 23, 2026 19:43
…e sessions

Cache width-aware preferred-size measurement in SessionLayout (reused while
a child stays valid at the same width), so streaming and scrolling no longer
re-measure the whole transcript on every event. Mark settled (non-streaming)
turns as Swing validate roots behind the kilo.session.validateRoots flag to
confine repaint churn, and skip redundant panel refreshes on no-op content
events. Narrow the follow-scroll validate pass to the transcript subtree.

Adds SessionLayout cache tests, validate-root/settled behavior + width
propagation tests, and a panel-level streaming stress/teardown test.
- HeaderPopup.contentWidth: measure leaf JComponents by preferred width
  instead of the unreachable is-JComponent branch (Container matched first).
- PatchBody.applyStyle: report change when the per-file diff panes restyle,
  so a font/theme change relayouts the multi-file patch view.
- MdDiffHighlight: only treat +++/--- as file headers when followed by a
  space or end of line, so content lines like "++x;" stay colored as inserts.
- EditToolView.sync: compute editPath(item) once.
- Strengthen multi-file patch badge assertion and add MdDiffHighlight tests.
- SessionLayout: forget a turn's cached height on content change so a
  settled TurnView (its own validate root) that re-validates independently
  cannot return a stale measurement from the layout cache
- ToolSupport: remove dead setLinkText; restore patchMarkdown raw-text
  fallback for metadata-only patches (pure rename/mode change)
- EditToolView: drop redundant popup update() already done by mount()
- tests: make header-stripping assertions non-vacuous, cover the
  metadata-only patch fallback and SessionLayout.forget
Each prose markdown pane kept a viewport ChangeListener for its whole life, so every scroll tick fired a synthetic mouse move (native pointer query + event dispatch) on every prose block — cost that scaled with transcript size. Subscribe to viewport scrolls only while the pointer is over the pane, making per-scroll work O(1) while preserving hovered-link and cursor refresh.
@kirillk kirillk changed the title feat(jetbrains): render edit tool diff previews feat(jetbrains): render edit tool diff previews in session view Jul 24, 2026
@kirillk
kirillk enabled auto-merge July 24, 2026 10:16
@kirillk
kirillk merged commit 1a3c719 into main Jul 24, 2026
23 checks passed
@kirillk
kirillk deleted the granite-anemone branch July 24, 2026 10:20
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
feat(jetbrains): render edit tool diff previews in session view
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.

2 participants