Skip to content

feat(jetbrains): fold pasted blocks in the prompt input and transcript - #13889

Merged
kirillk merged 9 commits into
mainfrom
jetbrains-paste-collapse
Sep 15, 2026
Merged

kirillk merged 9 commits into
mainfrom
jetbrains-paste-collapse

Conversation

@kirillk

@kirillk kirillk commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

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:

  1. Pasting text with 5+ lines or more than 800 chars collapses it into a [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.
  2. Sending a message carries the exact pasted ranges to the transcript, so the same block folds there too instead of being rendered (and mangled) as markdown.
  3. Rolling back a sent prompt restores the draft with its pastes folded again, not dumped as raw text.
  4. A folded block in the transcript no longer shows a stray horizontal scrollbar/reserved band underneath it.

Screenshots / Video

GIF Recording 2026-09-14 at 7 31 37 PM

How to Test

Manual/local verification

  • ./gradlew typecheck from packages/kilo-jetbrains/ — passes.
  • ./gradlew :frontend:test :backend:test from packages/kilo-jetbrains/ — full suites pass.

Reviewer test steps

  1. ./gradlew --no-configuration-cache runIdeSplitMode from packages/kilo-jetbrains/ (or the checked-in Run IDE (Split Mode) configuration).
  2. Paste ~200 lines of log into the prompt → collapses to a single [Pasted ~200 lines] chip.
  3. Paste a second block right after it on the same line, then unfold both → each gets its own gutter icon, and clicking one folds only that block back.
  4. Send the message → the transcript shows the same folded chip; unfold it and confirm a # ... log line stays literal text (not a heading) and there's no horizontal scrollbar under the collapsed chip.
  5. Roll the message back → the input restores with the pasted block folded again, not as raw text.
  6. Paste a log that ends with a trailing newline as the last of several pastes in one draft, then send → it still folds (regression check for a trim-related bug fixed here).
  7. Paste 2 short lines → inserted raw, no placeholder, in both the input and transcript.

Blocked checks and substitute verification

  • Manual split-mode run above was not executed by the agent (requires an interactive IDE session); automated coverage substitutes for it: PromptPanelTest, EditorFoldsTest, PromptViewTest, PastePromptTest, SessionUiLayoutTest, and backend KiloCliDataParserTest/KiloBackendChatManagerTest exercise fold creation/collapse/expand/detach-reattach/rollback and the metadata round trip against real EditorEx/FoldingModel instances and a mock CLI server.

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

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.
@kilo-code-bot

kilo-code-bot Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issues Found | Recommendation: Address before merge

Overview

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

SUGGESTION

File Line Issue
packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/PromptView.kt 41 Unfenced pasted logs still render at full height in the transcript
Files Reviewed (2 files)
  • 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/TextViewTest.kt

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

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

WARNING

File Line Issue
packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/md/hybrid/MdViewHybrid.kt 508 Unfolding a transcript fold does not grow the bubble

SUGGESTION

File Line Issue
packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/PromptView.kt 41 Unfenced pasted logs still render at full height in the transcript
Files Reviewed (10 files)
  • .changeset/jetbrains-paste-collapse.md
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptPanel.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/PromptView.kt - 1 issue
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/editor/EditorFolds.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/md/MdViewFactory.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/md/hybrid/MdViewHybrid.kt - 1 issue
  • packages/kilo-jetbrains/frontend/src/main/resources/messages/KiloBundle.properties
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/PromptPanelTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/views/TextViewTest.kt

Fix these issues in Kilo Cloud

Previous review (commit 0ff5533)

Status: 1 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/PromptView.kt 195 Overflow is measured without a layout width, so wrapped messages can clip with no Show more control
Files Reviewed (5 files)
  • .changeset/jetbrains-paste-collapse.md
  • 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/PromptView.kt - 1 issue
  • packages/kilo-jetbrains/frontend/src/main/resources/messages/KiloBundle.properties
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/views/TextViewTest.kt

Fix these issues in Kilo Cloud

Previous review (commit 914a4ee)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptPanel.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/PromptPanelTest.kt

Previous review (commit 9448c84)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (12 files)
  • .changeset/jetbrains-paste-collapse.md
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptPanel.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptPasteCollapse.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptTextPasteProvider.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/PromptView.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/TextView.kt
  • packages/kilo-jetbrains/frontend/src/main/resources/kilo.jetbrains.frontend.xml
  • packages/kilo-jetbrains/frontend/src/main/resources/messages/KiloBundle.properties
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/PromptPanelTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/prompt/PromptPasteCollapseTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/views/TextViewTest.kt

Previous review (commit d587809)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (12 files)
  • .changeset/jetbrains-paste-collapse.md
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptPanel.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptPasteCollapse.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptTextPasteProvider.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/PromptView.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/TextView.kt
  • packages/kilo-jetbrains/frontend/src/main/resources/kilo.jetbrains.frontend.xml
  • packages/kilo-jetbrains/frontend/src/main/resources/messages/KiloBundle.properties
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/PromptPanelTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/prompt/PromptPasteCollapseTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/views/TextViewTest.kt

Previous review (commit 39e129b)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptPanel.kt 947 Expanding a collapsed paste does not recalculate editor height
packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptPanel.kt 942 A second identical paste never inserts another copy once a paste is tracked

SUGGESTION

File Line Issue
packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptPanel.kt 970 Invalid paste range markers are dropped without dispose()
Files Reviewed (12 files)
  • .changeset/jetbrains-paste-collapse.md
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptPanel.kt - 3 issues
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptPasteCollapse.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptTextPasteProvider.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/PromptView.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/TextView.kt
  • packages/kilo-jetbrains/frontend/src/main/resources/kilo.jetbrains.frontend.xml
  • packages/kilo-jetbrains/frontend/src/main/resources/messages/KiloBundle.properties
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/PromptPanelTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/prompt/PromptPasteCollapseTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/views/TextViewTest.kt

Fix these issues in Kilo Cloud

Previous review (commit a30a196)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptPanel.kt 947 Expanding a collapsed paste does not recalculate editor height
packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptPanel.kt 942 A second identical paste never inserts another copy once a paste is tracked

SUGGESTION

File Line Issue
packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptPanel.kt 970 Invalid paste range markers are dropped without dispose()
Files Reviewed (12 files)
  • .changeset/jetbrains-paste-collapse.md
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptPanel.kt - 3 issues
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptPasteCollapse.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/prompt/PromptTextPasteProvider.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/PromptView.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/TextView.kt
  • packages/kilo-jetbrains/frontend/src/main/resources/kilo.jetbrains.frontend.xml
  • packages/kilo-jetbrains/frontend/src/main/resources/messages/KiloBundle.properties
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/PromptPanelTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/prompt/PromptPasteCollapseTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/views/TextViewTest.kt

Fix these issues in Kilo Cloud


Reviewed by grok-4.6 · Input: 188.9K · Output: 15.6K · Cached: 679.7K

Review guidance: REVIEW.md from base branch main

kirillk and others added 8 commits September 7, 2026 16:29
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.
@kirillk kirillk changed the title feat(jetbrains): collapse large prompt pastes and cap transcript height feat(jetbrains): fold pasted blocks in the prompt input and transcript Sep 14, 2026
@kirillk
kirillk merged commit cfdd830 into main Sep 15, 2026
23 checks passed
@kirillk
kirillk deleted the jetbrains-paste-collapse branch September 15, 2026 13:13
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