fix(jetbrains): improve diff performance and session layout - #12746
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Notes (incremental review at b2f17a2)
Files Reviewed (1 file)
Previous Review Summaries (7 snapshots, latest commit f194769)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit f194769)Status: 1 Issue Found | Recommendation: Optional follow-up Overview
Issue Details (click to expand)SUGGESTION
Notes (incremental review at f194769)
Files Reviewed (2 files)
Fix these issues in Kilo Cloud Previous review (commit 6820530)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Notes (incremental review at 6820530)
Files Reviewed (3 files)
Fix these issues in Kilo Cloud Previous review (commit 87b00a9)Status: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Notes (incremental review at 87b00a9)
Files Reviewed (2 files)
Fix these issues in Kilo Cloud Previous review (commit 820d5d5)Status: 4 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Notes (incremental review at 820d5d5)
Files Reviewed (2 files)
Fix these issues in Kilo Cloud Previous review (commit e0fa585)Status: 4 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Notes (incremental review at e0fa585)
Files Reviewed (2 files)
Fix these issues in Kilo Cloud Previous review (commit 632e4ca)Status: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Notes (incremental review at 632e4ca)
Files Reviewed (2 files)
Fix these issues in Kilo Cloud Previous review (commit 7e0468f)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Notes
Files Reviewed (30 files)
Reviewed by claude-opus-5 · Input: 32 · Output: 4.9K · Cached: 1.2M Review guidance: REVIEW.md from base branch |
Opening a session could pin the transcript to a bottom computed from a zero-width measurement, cropping the last content until a toolwindow resize forced a re-measure. Reflow now no-ops until the panel has a real width and re-arms from doLayout once it does, so the transcript is always measured on-screen. The streaming path is untouched: pendingReflow is only set by a rebuild/clear that ran before layout, so the added doLayout check short-circuits during live updates.
Expanded folders already reveal child file badges, so showing the rolled-up folder total duplicates the visible counts. Keep aggregate badges only on collapsed folders while preserving file badges.
The reflow chain restarted its pass budget on every height change, so a session that keeps streaming after open reset the budget each EDT cycle and held the panel in a perpetual forgetAll()/re-measure loop, defeating the width-keyed height cache. Add a hard total-pass budget that never resets so the layout can still settle across a few height changes while capping the work a streaming session can trigger. Covers the doLayout re-arm path with a test that latches pendingReflow via a real turn at zero width.
A folder row hides its rolled-up badge while expanded, so its preferred width now depends on expansion state. JTree only invalidates cached path bounds on model changes, not on expand/collapse, so a collapsed folder could keep its narrower expanded-state bounds and let the re-shown badge squeeze the file name until an unrelated re-measure. Add a TreeExpansionListener that invalidates the layout cache on toggle so the row re-measures immediately.
Only treat a moving preferred height as an unsettled layout while the session is idle. During streaming the height just tracks incoming content, so the chain now counts its passes down instead of restarting the settle window, settling in REFLOW_PASSES and handing off to the per-turn forgetTurn path rather than risking a narrow crop-until-resize when the hard budget trips mid-stream. Keep the budget as the idle backstop and cover it with a test that drives an ever-growing child so the chain would spin without the cap.
…ggle invalidateCacheAndRepaint is UI-scoped, so firing it from the expansion listener on every row made expand/collapse-all O(rows^2) to re-measure on large branch diffs. Suppress the listener during bulk toggles and invalidate once at the end, and register it after the initial expandAll. Per-row user toggles still invalidate immediately.
isBusy() is true for awaiting-permission/question, retry, and offline — states recoverPending() can seed right after history load, where no deltas arrive and a moving height genuinely means the panes are still settling. Gating the settle-window shortcut on those states cut the reflow chain to REFLOW_PASSES and reintroduced the crop-until-resize bug on exactly that path. Gate only on SessionState.Busy (the streaming state) so the runaway fix stays while blocked/retry/offline sessions keep their full settle window. Add a Busy-state test that fails if the term is dropped or inverted.
Add a Retry-state reflow test (isBusy() == true but not SessionState.Busy): it must keep restarting the settle window toward the idle budget rather than collapsing to REFLOW_PASSES. This is the only case that distinguishes `is SessionState.Busy` from the old `isBusy()` predicate — verified it fails (7 passes) if the gate is reverted to isBusy().
fix(jetbrains): improve diff performance and session layout
Context
This improves the JetBrains plugin experience for large branch diffs, long session transcripts, and queued-prompt UX. The main problems were expensive full-transcript restyling while rendering diff previews, large inline patches freezing the EDT, cramped diff file names, existing sessions sometimes loading with cropped transcript content until the panel was resized, and the prompt send/stop button getting out of sync when attachments changed during a busy session.
Implementation
Screenshots / Video
Cap preview size so it won't slow down UI
How to Test
Manual/local verification
./gradlew typecheckfrompackages/kilo-jetbrains/../gradlew :frontend:test --tests "ai.kilocode.client.session.ui.PromptPanelTest"frompackages/kilo-jetbrains/../gradlew :frontend:test --tests "ai.kilocode.client.session.ui.SessionLayoutTest" --tests "ai.kilocode.client.session.ui.SessionMessageListPanelTest" --tests "ai.kilocode.client.session.ui.SessionRootPanelTest"frompackages/kilo-jetbrains/../gradlew :frontend:test --tests "ai.kilocode.client.session.SessionUiLayoutTest" --tests "ai.kilocode.client.session.SessionScrollTest"frompackages/kilo-jetbrains/.Reviewer test steps
Blocked checks and substitute verification
Checklist
Get in Touch
Kilo maintainers can reach me through the usual GitHub PR thread.