Skip to content

fix(jetbrains): harden Agent Manager worktree flows - #13423

Merged
kirillk merged 18 commits into
mainfrom
gentle-badger
Aug 25, 2026
Merged

fix(jetbrains): harden Agent Manager worktree flows#13423
kirillk merged 18 commits into
mainfrom
gentle-badger

Conversation

@kirillk

@kirillk kirillk commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Issue

No linked issue - defects found while testing the Agent Manager worktree flow in the JetBrains plugin.

Context

This PR groups several small JetBrains Agent Manager fixes that share the same worktree/session testing path. The fixes improve row presentation, worktree ordering, session activity state, hover popup placement, notification attention handling, and local worktree config hygiene.

What Changed

  • Render worktree-session row titles in regular weight so peer rows do not all look like headings.
  • Keep the account overlay hidden when a new worktree is created with an initial prompt while history is still loading.
  • Insert newly created, imported, or moved worktrees at the top and persist that newest-first order across reloads.
  • Restore the running worktree row indicator after Stop -> resume, and let running sibling sessions outrank stale errors.
  • Keep session header hover popups bounded to the visible session area instead of the whole IDE window.
  • Show failed sessions directly on their worktree rows with the error glyph.
  • Clear the Agents tab attention dot after the user has viewed the Agent Manager, while still re-lighting it for new attention.
  • Keep Agent Manager PR badges clickable by removing stale renderer geometry from the reused worktree row stamp.
  • Ignore local jetbrains.json files so generated/local JetBrains worktree state is not committed accidentally.

Implementation Notes

The account-overlay race came from opening a new session and dispatching its pending prompt in the same EDT event. The later empty history load fired ShowEmpty after the transcript was already active, re-showing the account overlay. The view-state handler now ignores ShowEmpty once the transcript is shown.

Worktree activity now makes busy outrank and clear pending errors, so a resumed session no longer depends on chat-event/status-stream ordering. Directory aggregation also prefers RUNNING over stale ERROR, while permission/question states still win because they require user action.

Attention tracking now records which sessions the user has already seen in Agent Manager. The tab dot represents unseen attention rather than every sticky activity item, so it clears when the user views the relevant rows and lights again for fresh attention.

The PR badge click bug was stale Swing geometry: WorktreeStatsView used a null layout in a single renderer stamp reused across rows, so min-size data from one row could shift the next row's visual badge away from its hit rectangle. The stats view now uses a real layout manager, the renderer invalidates the full stamp before layout, and the metrics memo key covers all state that sync() applies.

Verification

Executed from packages/kilo-jetbrains/:

  • ./gradlew typecheck - passes
  • ./gradlew test - passes
  • After merging latest origin/main: ./gradlew test typecheck - passes

New/updated automated coverage includes:

  • HistoryLoadingTest / SessionUiLayoutTest for the account-overlay history race.
  • KiloBackendActivityManagerTest / WorktreeActivityTest for activity precedence and resumed sessions.
  • AgentAttentionTest for seen/unseen Agent Manager attention.
  • WorktreeIconsTest, WorktreeControllerTest, AgentManagerPanelTest, and KiloWorktreeRpcApiImplTest for worktree row icons and ordering.
  • WorktreeSessionEditorPanelTest for regular-weight session titles.
  • HeaderPopupGeometryTest for visible-session popup bounds.
  • SettingsListViewTest for stable PR badge hit regions across rows with different metric widths.

Reviewer Notes

Manual IDE verification was not performed in this environment. A reviewer should still run ./gradlew runIde from packages/kilo-jetbrains/ and smoke-test the visual flows: create/import/move worktrees, Stop -> resume, failed sessions, Agent tab dot clearing, constrained header popups, and clicking PR badges in the worktree list.

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.

Session rows in the worktree editor are all peers, so bolding every title added noise without conveying hierarchy. ActiveListConfig now carries a bold flag that defaults to on and the worktree session list opts out, leaving the worktree, history and settings lists unchanged.
…tree start

Creating a worktree with a prompt opens the new session and dispatches the prompt in the same EDT event, so the history load resolves afterwards with no messages and fired ViewChanged.ShowEmpty. That re-showed the account overlay and wedged the view state, because showSession() early-returns once model.showSession is set, so hideAccountOverlay() could never run again and the account chip stayed on top of a running session. setControllerViewState now ignores ShowEmpty once the transcript is shown.
New worktrees were appended, so the row the user just created landed at the bottom of a long list. The optimistic row is now inserted at index 0 for create, import-PR and move, reload keeps pending rows on top newest-first, and the backend records the created path at the head of the persisted order so the row stays there across reloads and restarts. Drag reorder still overrides it.
A Stop makes the CLI publish session.error with MessageAbortedError, which the activity manager keeps in a sticky errors set that only session.turn.open cleared. kind() checked that set before busy, so a resumed session kept the resting glyph whenever the turn event was missed or arrived after the busy status: the status stream and the chat events are separate collectors, so their order is not guaranteed.

Busy now outranks a pending error and also clears it, and the per-directory aggregate prefers running over error so one stopped session cannot mask a sibling that is still working. An error that is never resumed still persists through idle as before.
Header popups budgeted their height against the IDE layered pane and anchored on the session panel's full bounds, so a session in a short tool window or an editor tab got balloons spanning the whole window. Placement now uses the session panel's visible rect for the height budget and the vertical clamp, mirroring SessionHoverCopyOverlay. The pane still decides only which side has horizontal room: clamping the width to the view rect would collapse the popup, since it deliberately sits beside the session.
@kilo-code-bot

kilo-code-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 file)
  • .gitignore
Previous Review Summaries (9 snapshots, latest commit b3e1988)

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

Previous review (commit b3e1988)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (6 files)
  • .changeset/jetbrains-worktree-pr-badge-clicks.md
  • .gitignore
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/agentManager/worktree/WorktreeStatsView.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/list/ActiveListModel.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/list/ActiveListRenderer.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/settings/base/SettingsListViewTest.kt

Previous review (commit 80e8213)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (10 files)
  • .changeset/hover-popup-overlay.md
  • .changeset/overlay-takes-hover.md
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/SessionUi.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/popup/HeaderPopupController.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/views/base/AbstractSessionPartView.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/LayeredOverlayPanel.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/agentManager/WorktreeIconsTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/popup/HeaderPopupControllerTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/views/base/AbstractSessionPartViewTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/ui/LayeredOverlayPanelTest.kt

Previous review (commit 4078d7c)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (20 files)
  • .changeset/hover-popup-overlay.md
  • .changeset/plain-worktree-headers.md
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/agentManager/AgentManagerPanel.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/agentManager/worktree/WorktreeIcons.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/agentManager/worktree/WorktreeSessionEditorPanel.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/app/KiloSessionService.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/SessionUi.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/popup/HeaderPopupController.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/list/ActiveListModel.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/list/ActiveListRenderer.kt
  • packages/kilo-jetbrains/frontend/src/main/resources/icons/worktree-local.svg
  • packages/kilo-jetbrains/frontend/src/main/resources/icons/worktree-local_dark.svg
  • packages/kilo-jetbrains/frontend/src/main/resources/icons/worktreeBranch.svg
  • packages/kilo-jetbrains/frontend/src/main/resources/icons/worktreeBranch_dark.svg
  • packages/kilo-jetbrains/frontend/src/main/resources/icons/worktreeLock.svg
  • packages/kilo-jetbrains/frontend/src/main/resources/icons/worktreeLock_dark.svg
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/agentManager/AgentManagerPanelTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/app/KiloSessionServiceTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/popup/HeaderPopupControllerTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/settings/base/SettingsListViewTest.kt

Previous review (commit 64ab942)

Status: 1 Issue 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/ui/popup/HeaderPopupController.kt 202 Shadow-inset view used for card hit-testing can treat a still-visible header as off-screen
Files Reviewed (4 files)
  • .changeset/jetbrains-worktree-list-fixes.md - 0 issues
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/popup/HeaderPopupController.kt - 1 issue
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/popup/HeaderPopupGeometry.kt - 0 issues
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/popup/HeaderPopupGeometryTest.kt - 0 issues

Fix these issues in Kilo Cloud

Previous review (commit 322426d)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/popup/HeaderPopupController.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/popup/HeaderPopupGeometry.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/popup/HeaderPopupGeometryTest.kt

Previous review (commit 28d0f3f)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • .changeset/jetbrains-worktree-list-fixes.md
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/KiloToolWindowFactory.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/agentManager/AgentAttention.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/agentManager/AgentAttentionTest.kt

Previous review (commit a1ccea4)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (8 files)
  • .changeset/jetbrains-worktree-list-fixes.md
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/KiloToolWindowFactory.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/agentManager/AgentAttention.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/agentManager/worktree/WorktreeActivity.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/app/KiloSessionService.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/SessionActivityKind.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/agentManager/AgentAttentionTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/app/KiloSessionServiceTest.kt

Previous review (commit f80d7d3)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (8 files)
  • .changeset/jetbrains-worktree-list-fixes.md
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/KiloToolWindowFactory.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/agentManager/AgentAttention.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/agentManager/worktree/WorktreeIcons.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/agentManager/AgentAttentionTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/agentManager/AgentManagerPanelTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/agentManager/WorktreeControllerTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/agentManager/WorktreeIconsTest.kt

Previous review (commit 047c989)

Status: 1 Issue 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/backend/src/main/kotlin/ai/kilocode/backend/app/KiloBackendActivityManager.kt 128 Status-stream busy hides a sticky error but does not evict it; idle can restore the resting glyph after a resume
Files Reviewed (19 files)
  • .changeset/jetbrains-worktree-list-fixes.md - 0 issues
  • packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/app/KiloBackendActivityManager.kt - 1 issue
  • packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/rpc/KiloWorktreeRpcApiImpl.kt - 0 issues
  • packages/kilo-jetbrains/backend/src/test/kotlin/ai/kilocode/backend/app/KiloBackendActivityManagerTest.kt - 0 issues
  • packages/kilo-jetbrains/backend/src/test/kotlin/ai/kilocode/backend/rpc/KiloWorktreeRpcApiImplTest.kt - 0 issues
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/agentManager/worktree/WorktreeActivity.kt - 0 issues
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/agentManager/worktree/WorktreeController.kt - 0 issues
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/agentManager/worktree/WorktreeSessionEditorPanel.kt - 0 issues
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/controller/SessionController.kt - 0 issues
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/popup/HeaderPopupController.kt - 0 issues
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/popup/HeaderPopupGeometry.kt - 0 issues
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/list/ActiveListModel.kt - 0 issues
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/list/ActiveListRenderer.kt - 0 issues
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/agentManager/AgentManagerPanelTest.kt - 0 issues
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/agentManager/WorktreeControllerTest.kt - 0 issues
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/agentManager/worktree/WorktreeActivityTest.kt - 0 issues
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/agentManager/worktree/WorktreeSessionEditorPanelTest.kt - 0 issues
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/SessionUiLayoutTest.kt - 0 issues
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/controller/HistoryLoadingTest.kt - 0 issues
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/popup/HeaderPopupGeometryTest.kt - 0 issues

Fix these issues in Kilo Cloud


Reviewed by grok-4.6 · Input: 51.1K · Output: 4.4K · Cached: 323.8K

Review guidance: REVIEW.md from base branch main

The leading icon dropped back to the resting branch glyph for an errored session, so a worktree whose session had just failed looked idle and the failure was only visible after opening the session. Error now takes the leading slot like the other kinds that need the user, and an operation on the row still outranks it.
…read

The dot mirrored the activity snapshot, and an error stays in that snapshot until its session runs again, so a failed session left the dot lit for good. AgentAttention now tracks which sessions the user has already seen: attention that is pending while the Agent Manager is on screen counts as read, because the rows carry the badge there. The dot is therefore re-evaluated on tab selection and tool window visibility as well as on activity, and a session that recovers and fails again lights it once more.
…Agents dot

activitySnapshot() only mapped busy statuses to RUNNING, so session and history rows had no source for the other kinds: a failed session showed no badge even though the backend already reported ERROR for it. The snapshot now derives from that activity map, with the busy statuses kept as a fallback for sessions whose directory the backend cannot resolve. Worktree rows and session rows therefore read the same source.

The dot also treated 'the Agent Manager is on screen' as read, which suppressed it for a session that failed while the user was working in a session editor. Reading now means the panel is focused, so the dot appears on failure and still clears once the user looks at the tab.
Tracking which sessions the user had looked at made the dot disappear on a tab round trip while a worktree was still failed or waiting, which is the opposite of what the signal is for. The dot mirrors the activity snapshot again: it stays up while any session in any worktree needs the user, and clears only when that state does.
Header popups pointed at the edge of the whole session, so a balloon for a card in the middle of a wide transcript was flung to the far side of the session and read as belonging to whatever panel it landed on. The pointer now lands on the edge of the card the popup describes, which keeps it attached to that card.

Room is still measured against the window: cards are narrower than the session, so measuring inside the session would leave almost no width for a card in a split editor. Height still comes from the visible session, since a collapsed card header is only a couple of rows tall.
Header popups now set the platform corner-to-pointer distance instead of moving the target point when a balloon body has to shift into the visible session. This keeps the arrow attached to the card or row the popup describes while still fitting the body in the viewport.

The geometry tests cover top and bottom shifts, collapsed cards, offscreen fallback, and the platform-legal pointer distance range so the balloon keeps its pointer.
…ession status

Render the Agent Manager worktree list titles and section header in normal
weight and soften the idle worktree glyphs to a mid-tone neutral. Tint only
monochrome row icons to the selection foreground so colored status icons
(running/question/error) keep their hue. Prune a deleted session's lingering
question/error status locally so the session list, worktree list, and tab
attention dot re-evaluate instead of showing a stale badge.
Gate the header hover popup on a suppression predicate so it neither opens
nor stays alive while the connection banner or modal blocker covers the
session, and dismiss any open popup when such an overlay appears.
Replace the popup-level overlay suppression with hit-testing truth. A card's
hover exit test now asks which component is topmost at that point instead of
only comparing bounds, so an overlay painted above the transcript counts as
having left the row. An overlay child can declare that it blocks the content
beneath it, and the layered panel then releases the hover of whatever the
pointer rests on when such a cover appears, moves, or hides — Swing delivers
no exit for that case on its own.

The connection banner is the first blocking overlay, so a card it covers no
longer stays lit and no longer keeps its hover popup open behind the banner.

Also repair the worktree icon palette test the mid-tone glyph change broke.
# Conflicts:
#	packages/kilo-jetbrains/backend/src/test/kotlin/ai/kilocode/backend/rpc/KiloWorktreeRpcApiImplTest.kt
@kirillk kirillk changed the title fix(jetbrains): worktree list, session overlay and popup fixes fix(jetbrains): harden Agent Manager worktree flows Aug 25, 2026
@kirillk
kirillk enabled auto-merge August 25, 2026 20:02
@kirillk
kirillk merged commit a604d9f into main Aug 25, 2026
33 checks passed
@kirillk
kirillk deleted the gentle-badger branch August 25, 2026 20:06
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