fix(jetbrains): settle attention badges during auto-approve - #13765
Conversation
Auto-approve is a client-only policy: the CLI still asks for every edit/bash permission, so JetBrains replies once right away. Each ask/reply pair flips KiloSessionService.activity into an attention kind and back, which flickered the worktree rows and the worktree tab's session-list toggle, and left the toggle badge stuck once attention actually cleared elsewhere. - Settle the activity StateFlow: a rising transition into an attention kind (permission/question/plan) is held for a short grace window so a permission the client auto-answers itself never reaches downstream consumers. Clearing and RUNNING/ERROR transitions stay immediate. - Scope the worktree toggle badge to this worktree's listed session ids, so a permission in another directory or an auto-approved task subagent (which has no row here) can no longer badge it. - Subscribe the worktree session editor panel to session activity directly so a background session's cleared/changed state re-syncs the panel instead of waiting on the open session's own state to change.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (5 files)
Previous Review Summary (commit 63d7aad)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 63d7aad)Status: No Issues Found | Recommendation: Merge Files Reviewed (5 files)
Reviewed by grok-4.6 · Input: 140.2K · Output: 16.1K · Cached: 507.6K Review guidance: REVIEW.md from base branch |
Holding the whole activity snapshot meant a session going to ERROR or RUNNING in the same emission as another session newly entering PERMISSION also waited out the grace window. Hold only the sessions that just entered an attention state, keyed by session id, and publish every other entry in the snapshot immediately. Held sessions keep the kind they were last published with, so a spinner keeps spinning instead of blinking to the attention glyph.
|
CI note: the earlier red runs were flaky tests unrelated to this change — no code fix was needed and the suite is green now. Three different tests failed across three runs, none of them touched by this PR:
Run 2 is decisive: this PR is frontend-only, so a On the first failure specifically: it asserts Verified locally on this branch: |
Issue
Fixes #
Context
Agent Manager's orange
?attention glyph flickered on worktree rows and on the worktree tab's session-list toggle while a session ran through auto-approved edits, and the toggle badge sometimes stayed stuck even after attention had actually cleared.Implementation
JetBrains auto-approve is a client-only policy: the CLI still emits a real
permission.asked/permission.repliedpair for every edit, soKiloBackendActivityManagerbriefly reportsPERMISSIONbefore flipping back toRUNNINGon each tool call.WorktreeActivity.rank()ranksPERMISSIONaboveRUNNING, so the glyph visibly swapped twice per call with nothing to debounce it.KiloSessionService.activitynow settles throughtransformLatest: a rising transition into an attention kind (PERMISSION/QUESTION/PLAN) is held for a short grace window (400ms) so a permission the client auto-answers itself is cancelled before ever reaching downstream consumers. Clearing andRUNNING/ERRORtransitions stay immediate — this is the single choke point for worktree rows, the toggle badge, session-list row pills, and the Agents tab dot.WorktreeSessionEditorPanel.syncToggle()now filters activity down to this worktree's listed session ids before ranking attention. Previously it read the full global activity map, so a permission in another worktree or an auto-approvedtasksubagent (which has no row here and so could never be cleared by the user) could badge this tab.KiloSessionService.activitydirectly (mirroringWorktreeController.init) and re-syncs on every change. Previously it only refreshed via list changes andonListChanged, which only fires for the currently open session's own state — a background session's activity clearing elsewhere never reached the panel, leaving the badge stuck.Non-goals (documented in the plan, left for follow-up): backend reconciliation of stuck permissions on reconnect, and pushing auto-approve into CLI config so no ask event exists at all (touches shared upstream code).
Screenshots / Video
N/A — no visual/layout change, only timing of an existing badge.
How to Test
Manual/local verification
./gradlew typecheckand./gradlew testfrompackages/kilo-jetbrains/— both green, including the full existing suite (no regressions)../gradlew :frontend:test --tests '*KiloSessionServiceTest*' --tests '*WorktreeSessionEditorPanelTest*' --tests '*WorktreeActivityTest*'— 65/65 tests pass, including 5 new tests added for this fix.Reviewer test steps
?on every tool call, and the worktree tab's collapsed session-list toggle does not gain a?badge for that worktree.Blocked checks and substitute verification
./gradlew --no-configuration-cache runIdeSplitModemanual sandbox run was not performed by the agent (requires an interactive IDE session); substitute verification was the full automated Gradle test suite plus the new unit tests exercising the exact debounce/scoping/subscription behavior described above.Checklist
Get in Touch