perf(jetbrains): speed up transcript tab switching and list painting - #14520
Conversation
A CPU profile of switching between JetBrains worktree editor tabs showed most of the cost came from Swing rebuilding the private HTML document of every `<html>` JLabel in the transcript. Detaching or re-attaching a tab resets a component's graphics configuration, which the JDK label code treats as a screen-scale change and reparses. Tool card headers, file links, to-do rows, and attachment chips all used `<html>` text for single-line clipping and underline/strikethrough, so this cost was paid twice per switch and scaled with the number of tool calls in both sessions. - Add `PlainLabel`, a `JBLabel` that always renders text literally and paints underline/strikethrough via font attributes instead of markup, and use it for every single-line transcript label that previously used `<html>` text. - Detach the collapse/expand arrow and the file link header slot from cards that never show them (most tool cards never show a link), rather than keeping them attached and hidden. Every tab switch walks the whole transcript tree, so idle-but-attached components still cost something. - Attach the copy-toolbar placeholder in `TextView` only while the toolbar is shown, instead of hiding it under every text part. - Collapse each to-do row from three components to one label using the check as its icon. The Agent Manager list reuses one renderer component for every row and invalidates it wholesale on each paint, so nested `Stack`/`Align` layouts recomputed their sizes for every ancestor on every row. Add `LayoutPass`, which memoizes each container's size per layout pass, and wrap the renderer's paint validation, row-height measurement and hit-testing in it. Also set `AnimatedIcon.REFRESH_DELEGATE` so a spinner frame repaints only the rows actually showing an animated glyph instead of the whole list.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Reviewed the follow-up commit Files Reviewed (2 files)
Previous Review Summaries (2 snapshots, latest commit 8e83b74)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 8e83b74)Status: 1 Issue Found | Recommendation: Address before merge Reviewed follow-up commit Overview
Issue Details (click to expand)WARNING
Files Reviewed (5 files)
Fix these issues in Kilo Cloud Previous review (commit ceb83ea)Status: 4 Issues Found | Recommendation: Address before merge Reviewed the JetBrains perf change (34 files: Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (34 files)
Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0 Review guidance: REVIEW.md from base branch |
- PlainLabel: key the underline/strikethrough decoration cache on the font's resolved size and style, not just object identity. JBFont is one instance whose getSize()/getStyle() resolve dynamically off the current IDE zoom (JBFont.refreshScaledFont mutates its own size/ pointSize fields in place), so identity alone would keep painting a to-do row's strikethrough at its pre-zoom size forever. - LayoutPass: annotate the internal size()/forget() helpers with @RequiresEdt. They mutate a shared IdentityHashMap reached from Swing's LayoutManager2 callbacks, which are EDT-bound; the annotation makes an off-EDT caller fail loud instead of racing the map. - ActiveListView: clear the AnimatedIcon.REFRESH_DELEGATE client property on removeNotify() so the delegate (which closes over the view's model/renderer/items) doesn't outlive the view if the platform's animation registry retains it longer than expected. - ActiveListModel: rewrite activeListAnimated() as direct any() checks instead of wrapping the three badge lists in a listOf(...) first, avoiding a per-row allocation on every animation frame. Addresses the 4 suggestions from the automated review on PR #14520.
removeNotify() cleared AnimatedIcon.REFRESH_DELEGATE but nothing ever put it back on the next addNotify(). A worktree session editor tab switch detaches and re-attaches this exact view, so after the first switch the delegate stayed null for the rest of the view's life and the per-row animation repaint this PR introduced silently reverted to repainting the whole list on every spinner frame. Move the client property installation from init into a new addNotify() override, symmetric with the existing removeNotify() clear, and reuse one Runnable instance across attach/detach cycles instead of allocating a fresh one each time. Addresses the follow-up review finding on PR #14520 (commit 8e83b74).
|
Can we add before after time tables of real reproductions? |
| |---|---| | ||
| | Rich HTML with modern CSS, icons, shortcuts | `JBHtmlPane` (`com.intellij.ui.components.JBHtmlPane`) | | ||
| | Simple multi-line label with HTML | `JBLabel` + `XmlStringUtil.wrapInHtml()` | | ||
| | Single-line transcript text (tool headers, file links, to-do rows) | `PlainLabel` (`ai.kilocode.client.ui.PlainLabel`) with `underline`/`strike`; never `<html>` text, because Swing re-parses every HTML label each time an editor tab is detached or re-attached | |
There was a problem hiding this comment.
This AGENTS.md file is getting too long. At this size you will greatly degrade model output quality with that. Would it make sense to extract certain parts to skills instead?
There was a problem hiding this comment.
I's been working better and better for me in time but I think it makes sense to re-iterate on that. I planned to make a clean up day this week that would include checking for bad smells, code duplication, memory leaks and running the profiler. I think I will add this to the plan too, that makes sense.
…4554) ## Automated docs sync — 2026-09-25 This PR keeps kilo.ai/docs in sync with features merged to [Kilo-Org/cloud](https://github.com/Kilo-Org/cloud) and [Kilo-Org/kilocode](https://github.com/Kilo-Org/kilocode). Every change below links to the merged PR it documents. - Window: `2026-09-24T07:08:33.639Z` → `2026-09-25T07:05:29.302Z` - Verification (docs build + tests): **passing** ### Surface: `cloud-mobile` - Assignees / requested reviewers: @iscekic and @eshurakov - Derivation: Derived from the repository layout. A product surface is a package under packages/ that ships a distinct client, plugin, backend, or hosted service: cli = packages/opencode/ + packages/tui/ + packages/server/ + packages/sdk/ + packages/plugin/; vscode = packages/kilo-vscode/ + packages/kilo-web-ui/ + packages/kilo-ui/; jetbrains = packages/kilo-jetbrains/; gateway = packages/kilo-gateway/; web = packages/kilo-console/ + packages/kilo-indexing/ + packages/kilo-memory/ + packages/kilo-sandbox/. Docs route from the IA tree packages/kilo-docs/pages/ plus docs/jetbrains-vscode-settings-parity.md: each surface lists the pages sections that document it, and the per-platform pages under packages/kilo-docs/pages/code-with-ai/platforms/ map to the matching extension surface (the vscode/ directory to vscode, jetbrains.md to jetbrains). A doc path belongs to the surface with the longest matching prefix; a path that matches none of those prefixes falls to `other` (the explicit other prefixes are listed under other.docs). The cloud surfaces are derived the same way from the Kilo-Org/cloud layout: cloud-mobile = apps/mobile/, cloud-web = apps/web/, cloud-extension = apps/extension/, and cloud-agent = the cloud-agent packages under packages/ (packages/cloud-agent-sdk/ + packages/cloud-agent-profile/). A cloud source names its repository while a bare string still means this repository. The pages under packages/kilo-docs/pages/collaborate/ document the cloud web app (app.kilo.ai: teams dashboard, billing, SSO, adoption dashboard), so they route to cloud-web. No page under packages/kilo-docs/pages/ documents the browser side-panel extension yet, so cloud-extension lists no docs prefix. - Map: `.github/docs-sync/surfaces.json` - Surface map: `cli`, `vscode`, `jetbrains`, `gateway`, `web`, `cloud-mobile`, `cloud-web`, `cloud-extension`, `cloud-agent`, `other` - Source prefixes: `apps/mobile/` (Kilo-Org/cloud) - Doc prefixes: `packages/kilo-docs/pages/code-with-ai/platforms/mobile.md` - Paths that fall to `other`: `packages/kilo-docs/pages/community/`, `packages/kilo-docs/pages/kiloclaw/`, `packages/kilo-docs/pages/contributing/`, `packages/kilo-docs/LEARNINGS.md`, `docs/` - Reviewers are ranked from `Kilo-Org/cloud`; the workflow needs a token with `contents: read` on that repository (repository secret `CROSS_REPO_ACCESS_TOKEN`, exposed to the upsert step as `CLOUD_REPO_TOKEN`). - How the two were computed: Reviewers for `cloud-mobile` are ranked from `Kilo-Org/cloud` git history over `apps/mobile/` (a commit 180 days old counts half as much, half-life 180 days). Bots (author type "Bot" or a login matching /\[bot\]$/i) and people without admin, write, or maintain permission are excluded. ### Changes <!-- docs-sync:changes:start --> | Docs change | Source | | --- | --- | | updated pages/code-with-ai/platforms/mobile.md | [Kilo-Org/cloud#6386](Kilo-Org/cloud#6386) | | updated pages/ai-providers/openai-chatgpt-plus-pro.md | [Kilo-Org/cloud#6702](Kilo-Org/cloud#6702) | | updated pages/code-with-ai/platforms/cloud-agent.md | [Kilo-Org/cloud#6683](Kilo-Org/cloud#6683) | | updated pages/getting-started/byok.md | [Kilo-Org/cloud#6692](Kilo-Org/cloud#6692) | <!-- docs-sync:changes:end --> ### Pending — will retry <!-- docs-sync:pending:start --> _None._ <!-- docs-sync:pending:end --> ### Considered, no docs change needed <!-- docs-sync:skipped:start --> | PR | Reason | | --- | --- | | [Kilo-Org/cloud#6658](Kilo-Org/cloud#6658) | Internal sandbox lifecycle fix with no user-visible workflow or setting. | | [Kilo-Org/cloud#6673](Kilo-Org/cloud#6673) | Internal container CA trust plumbing, no user-facing behavior. | | [Kilo-Org/cloud#6672](Kilo-Org/cloud#6672) | Internal sandbox launch/recovery fix with no documented workflow change. | | [Kilo-Org/cloud#6660](Kilo-Org/cloud#6660) | Internal cloud-agent queue delivery fix; no new command, setting, or workflow for users. | | [Kilo-Org/cloud#6226](Kilo-Org/cloud#6226) | Internal gateway alias-routing change, not user-visible. | | [#14490](#14490) | Tool-call animation and streaming UI polish; users do not need to learn a new workflow. | | [#14530](#14530) | Bug fix restoring intended worktree-pool behavior, no doc change needed. | | [#14529](#14529) | Bug fix restoring tab/panel state across project switches. | | [#14531](#14531) | Reconnect recovery bug fix, restores already-documented behavior. | | [#14532](#14532) | Bug fix keeping session tab title in sync on rename. | | [Kilo-Org/cloud#6088](Kilo-Org/cloud#6088) | Removes internal/admin model-experiment surfaces, not public product docs. | | [Kilo-Org/cloud#6682](Kilo-Org/cloud#6682) | Internal control-socket reconnect race fix, no user-facing change. | | [#14534](#14534) | Transcript re-render performance bug fix. | | [#14535](#14535) | Bug fix preserving the loaded browser page across context switches. | | [Kilo-Org/cloud#6684](Kilo-Org/cloud#6684) | Reverted by Kilo-Org/cloud#6685. | | [Kilo-Org/cloud#6678](Kilo-Org/cloud#6678) | Dead-code constant removal, no user-visible effect. | | [Kilo-Org/cloud#6687](Kilo-Org/cloud#6687) | Removes internal model-experiment maintenance and retains tables, no user-facing change. | | [#14515](#14515) | JetBrains plugin unload crash fix, no documented behavior change. | | [#14520](#14520) | JetBrains transcript/list rendering performance work. | | [Kilo-Org/cloud#6614](Kilo-Org/cloud#6614) | Mobile PR Review header and session title bug fix, no doc change needed. | | [Kilo-Org/cloud#6625](Kilo-Org/cloud#6625) | Internal mobile secure-store error-handling refactor. | | [Kilo-Org/cloud#6624](Kilo-Org/cloud#6624) | Mobile auth bug fix that stops a retry loop; restores expected sign-in behavior with no new setting or workflow. | | [#14310](#14310) | Contributor/CI fix making the kilo-v2 checkout installable; not user-visible product behavior. | | [Kilo-Org/cloud#6611](Kilo-Org/cloud#6611) | Mobile notification-tap fix that selects the session's organization; restores correct behavior rather than adding a learnable feature. | | [Kilo-Org/cloud#6644](Kilo-Org/cloud#6644) | Mobile sign-in layout/alignment polish; no change to what a user must do. | | [Kilo-Org/cloud#6601](Kilo-Org/cloud#6601) | Mobile layout fix keeping empty states clear of the tab bar; purely visual. | | [#14543](#14543) | CI/release infrastructure adding Windows binary code signing; no public docs impact. | | [Kilo-Org/cloud#6616](Kilo-Org/cloud#6616) | Mobile visual defect fixes and a session-title fallback; no new user workflow or setting. | | [Kilo-Org/cloud#6630](Kilo-Org/cloud#6630) | Reports an edge-case partial worktree restore; failure-path plumbing with no new user-facing workflow, target setting, or config. | | [Kilo-Org/cloud#6699](Kilo-Org/cloud#6699) | Cloud Agent e2e stabilization plus internal idle-sandbox capacity handling; not user-visible. | | [#14545](#14545) | Automated JetBrains release/changelog PR; underlying user-facing changes are triaged from their own PRs. | | [Kilo-Org/cloud#6708](Kilo-Org/cloud#6708) | Internal AI-gateway request-logging policy change in the admin panel; no existing public docs surface and no change to how users run Kilo Code. | | [#14533](#14533) | Documentation already shipped with the merged PR. The experimental.task_model_selection flag is gone from the current source, and pages/code-with-ai/agents/model-selection.md, pages/code-with-ai/agents/context-mentions.md, and pages/getting-started/settings/index.md already describe per-task selection as default-on with no stale experiment references. | | [#14510](#14510) | Documentation already shipped with the merged PR. Marketplace companion-skill support is present in the current source (packages/opencode/src/kilocode/marketplace/companions.ts and installer), and pages/customize/marketplace.md already documents installing, publishing, and removing MCP servers with companion skills. | <!-- docs-sync:skipped:end --> --- (bot) Generated by the docs-sync workflow. Humans review and merge; while this PR stays open, the next daily run appends new changes here. Branch: `docs/auto-sync-2026-09-25`. <!-- docs-sync: processed-through 2026-09-25T07:05:29.302Z -->
Issue
No linked issue. Found via a user-provided JetBrains CPU profile (
.jfr) of switching between worktree session editor tabs.Context
A CPU profile of switching between JetBrains worktree editor tabs showed most of the cost came from Swing rebuilding the private HTML document of every
<html>-textJLabelin the session transcript. Detaching or re-attaching a tab resets a component's graphics configuration, and the JDK's label code (BasicLabelUI.propertyChange→SwingUtilities2.isScaleChanged) treats that as a screen-scale change and reparses the label's HTML. Tool card headers, file links, to-do rows, and attachment chips all used<html>text just for single-line clipping and underline/strikethrough, so this was paid twice per switch and scaled with the number of tool calls in both the outgoing and incoming session.Two smaller contributors from the same profile:
Stack/Alignlayouts recomputed their sizes for every ancestor container on every row paint, row-height measurement, and hit test.Implementation
PlainLabel(ui/PlainLabel.kt), aJBLabelthat always renders its text literally — even text starting with<html>— and paints underline/strikethrough via font attributes instead of markup. Replaced every single-line transcript label that used<html>text (tool card title/subtitle/state, file links, to-do rows, attachment chips, task child rows, the approval footer, the edit card's files tag) with it. Removed the now-unusedFileLinkText.ktand its HTML-wrapping helpers.toolParts()takes alinkflag; onlyRead/Editcards build the file-link wrapper slot. Other tool cards (Tool,Shell,Board,Task, search) no longer carry a hiddenFileLinkLabel+ wrapper panel they never show.TextView's copy-toolbar placeholder is added/removed from the layout instead of togglingisVisible, so only the one text part per assistant message that has a copy button carries it.PlainLabelusing the check mark as its icon.LayoutPass(ui/layout/LayoutPass.kt): a scoped memo thatStackandAlignconsult so each container answers each kind of size (min/preferred/max) once per layout pass, keyed by the container's current size, and dropped as soon as Swing invalidates it. Wrapped the Agent Manager renderer's paintvalidate(), row-height measurement, andactiveListLayout(hit-testing) in it. On a small test row this cut preferred-size reads from 132 to 26 for a full measure+layout pass.AnimatedIcon.REFRESH_DELEGATEon the Agent Manager list so a spinner frame repaints only the visible rows that actually paint an animated glyph (including badges wearing a live-run dot), instead of the whole list. This relies on an experimental IntelliJ Platform API (@ApiStatus.Experimental), flagged per the repo's Platform API guidance.PlainLabel/LayoutPasspatterns and the "don't keep rarely-shown header parts attached" rule inpackages/kilo-jetbrains/AGENTS.md.Screenshots / Video
N/A — no visible layout change other than long single-line labels ending in "…" instead of a hard cut when they overflow (pre-existing clipping behavior, same effective outcome).
How to Test
Manual/local verification
./gradlew typecheckfrompackages/kilo-jetbrains/— passes../gradlew :frontend:testfrompackages/kilo-jetbrains/— full suite (4,272 tests) passes.bun run script/check-md-table-padding.ts— no padded tables..jfrprofile plus targeted before/after measurement tests (LayoutPassTest,ActiveListPaintCostTest) added in this PR, not a second live capture.Reviewer test steps
ActiveListRenderer/RepaintManager).Blocked checks and substitute verification
PlainLabelTest,LayoutPassTest,ActiveListPaintCostTest, plus the existing session-view suites updated for thePlainLabel/attachment changes) run via./gradlew :frontend:test.Checklist
Get in Touch