Repository navigation
feat(jetbrains): fold pasted blocks in the prompt input and transcript - #13889
Conversation
Pasting a large block (logs, files) into the JetBrains prompt input now collapses it into a [Pasted ~N lines] fold placeholder that can be expanded again, matching Kilo CLI behavior. The full text stays in the document at all times, so submit/copy/undo are unaffected. A large pasted block rendered in the transcript prompt bubble now caps at 15 lines instead of rendering at full height, and drops the extra 12px viewport inset that made pasted logs read as more indented than the rest of the transcript.
Code Review SummaryStatus: 1 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (2 files)
Fix these issues in Kilo Cloud Previous Review Summaries (7 snapshots, latest commit e68a279)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit e68a279)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (10 files)
Fix these issues in Kilo Cloud Previous review (commit 0ff5533)Status: 1 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (5 files)
Fix these issues in Kilo Cloud Previous review (commit 914a4ee)Status: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Previous review (commit 9448c84)Status: No Issues Found | Recommendation: Merge Files Reviewed (12 files)
Previous review (commit d587809)Status: No Issues Found | Recommendation: Merge Files Reviewed (12 files)
Previous review (commit 39e129b)Status: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (12 files)
Fix these issues in Kilo Cloud Previous review (commit a30a196)Status: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (12 files)
Reviewed by grok-4.6 · Input: 188.9K · Output: 15.6K · Cached: 679.7K Review guidance: REVIEW.md from base branch |
Setting the editor document text directly outside a write action tripped the platform's write-access assertion under CI's threading checks, failing the new selection-replace paste test.
Address review on the paste-collapse feature: - Expanding a collapsed paste now resizes the prompt field. The editor pins a fixed height with VERTICAL_SCROLLBAR_NEVER, so unfolding left the revealed text clipped. A FoldingListener scoped to the editor handles this for click, keyboard, and second-identical-paste alike, guarded so it never fires while the field is between editors. - Expanding untracks the paste, so a later identical paste collapses a fresh copy instead of being a no-op. This mirrors the CLI dropping its placeholder part on expand, and stops a deliberately expanded paste from silently re-collapsing on session switch. - Range markers are disposed when dropped rather than only removed from the list, so deleted pastes no longer linger in the document's marker tree for the life of the prompt.
An unfolded paste could not be folded again: EditorTextField turns the gutter folding outline off, so there was no handle to click and no discoverable way back to the placeholder. Show the gutter fold handles while the prompt has a tracked paste, and hide them again when it does not. The prompt disables every other gutter area, so the folding outline is the only thing that claims gutter width; gating it on having something to fold keeps the ordinary input geometry unchanged. Fold state now lives on the tracked paste rather than being inferred from the region existing, so folding and unfolding work repeatedly and survive the editor being released on detach. Fold regions also opt into a gutter handle when a paste occupies a single long line, which otherwise gets none.
Deleting a pasted block left the gutter behind. Removing text changes no fold state, so the folding listener never ran and the outline stayed on with nothing left to fold. Reconcile tracked pastes from the document listener instead, covering the bulk-update path too. A deleted range also leaves its marker valid but empty rather than invalid, so treat an empty range as gone.
A sent message containing a large pasted block filled the transcript, because the bubble rendered at full height. Capping the pasted code block alone was not enough: markdown splits a pasted log into a mix of code blocks and prose, so most of it stayed expanded. Clip the whole prompt bubble to a fixed number of lines and offer a Show more / Show less toggle below it. The clip lays the content out at its full height inside a shorter panel so Swing hides the overflow, rather than handing a layout manager the reduced height and having the text reflow. The toggle sits outside the clip so it cannot be clipped away, and disappears again if the content later shrinks below the cap.
Two problems with the paste folding: Pasting the same text twice unfolded the first block instead of adding a second one, because a second identical paste was treated as a gesture to expand the existing fold. Repeating it left a mix of open and folded blocks rather than three folds. Every collapsible paste now inserts its own fold, and inserting is guarded so a fold the edit expands on its own is not mistaken for the reader unfolding it. The transcript used a Show more / Show less clip, which was a second UX for the same idea. Extract the input's fold handling into EditorFolds and reuse it for transcript blocks, so a sent message folds behind the same placeholder, unfolds on click, folds back from the gutter handle, and shows the gutter only while something is foldable. A folded block measures itself from visual lines, so it takes one line and grows back to the existing cap when unfolded. Net effect is 360 lines removed against 172 added.
The fold resize callback revalidated the code pane but never repainted, so newly revealed text could show stale pixels, and it re-measured only the pane instead of the markdown root. Match how every other block size change in this view propagates. Also assert that unfolding grows the bubble, not just that the pane reports a taller preferred size.
Issue
Fixes #
No tracked issue; this closes the gap between the CLI's paste-collapse UX and the JetBrains plugin.
Context
Pasting a large block (logs, files) into the JetBrains prompt input previously inserted the raw text with no summarization, unlike Kilo CLI which collapses it into a
[Pasted ~N lines]placeholder. A pasted block that made it into the transcript fared worse: it rendered as plain markdown, so log lines starting with#turned into headings, URLs autolinked, and there was no way to fold it back down.This PR brings the JetBrains prompt input and transcript in line with the CLI, and keeps both in sync with each other:
[Pasted ~N lines]placeholder in the prompt input, expandable by click and foldable back from a gutter icon — several pastes on the same line each get their own icon.Screenshots / Video
How to Test
Manual/local verification
./gradlew typecheckfrompackages/kilo-jetbrains/— passes../gradlew :frontend:test :backend:testfrompackages/kilo-jetbrains/— full suites pass.Reviewer test steps
./gradlew --no-configuration-cache runIdeSplitModefrompackages/kilo-jetbrains/(or the checked-inRun IDE (Split Mode)configuration).[Pasted ~200 lines]chip.# ...log line stays literal text (not a heading) and there's no horizontal scrollbar under the collapsed chip.Blocked checks and substitute verification
PromptPanelTest,EditorFoldsTest,PromptViewTest,PastePromptTest,SessionUiLayoutTest, and backendKiloCliDataParserTest/KiloBackendChatManagerTestexercise fold creation/collapse/expand/detach-reattach/rollback and the metadata round trip against realEditorEx/FoldingModelinstances and a mock CLI server.Checklist
Get in Touch