Skip to content

fix(jetbrains): prune deleted sessions in the merged activity snapshot - #13470

Merged
kirillk merged 1 commit into
mainfrom
fix/jetbrains-deleted-session-activity-snapshot
Aug 26, 2026
Merged

fix(jetbrains): prune deleted sessions in the merged activity snapshot#13470
kirillk merged 1 commit into
mainfrom
fix/jetbrains-deleted-session-activity-snapshot

Conversation

@kirillk

@kirillk kirillk commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

What

KiloSessionService.activitySnapshot() now subtracts the locally-removed session set when merging statuses and activity.

Why

The test workflow on main failed in KiloSessionServiceTest:

expected:<{ses_failed=ERROR}> but was:<{ses_asking=RUNNING, ses_failed=ERROR}>

statuses and activity are two separate StateFlows, each pruning the removed set through its own combine collector. When a session is deleted, there is no ordering guarantee between them — one can still carry the session while the other has already dropped it. activitySnapshot() merged both raw values, so during that window a deleted session was reported as RUNNING.

That is not just a test artifact: every snapshot consumer (session list badges, worktree list, tab attention dot, history rows) could read the inconsistent merge and paint a badge for a session that no longer exists. This is the exact lingering-badge class of bug the removed set was introduced to prevent, so the fix belongs in the snapshot rather than in the test's wait condition.

The same latent race existed in test activity snapshot carries every kind the backend reports, which only waited on activity before asserting on data sourced from both flows; it now waits on both.

Verification

  • ./gradlew :frontend:test --tests 'ai.kilocode.client.app.KiloSessionServiceTest' --rerun-tasks x3
  • ./gradlew typecheck
  • ./gradlew test (full JetBrains suite)

activitySnapshot() merged statuses and activity, two StateFlows that each
prune the removed-session set through their own collector. After a delete,
one flow can still carry the session while the other has already dropped
it, so the snapshot briefly reported a deleted session as RUNNING and any
consumer reading it at that moment rendered a stale badge.

Subtract the removed set in the snapshot itself so the merged view is
consistent regardless of collector ordering, and wait on both flows in the
test that asserts every activity kind, which had the same latent race.

This fixes the flaky KiloSessionServiceTest failure on main.
@kilo-code-bot

kilo-code-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • .changeset/jetbrains-deleted-session-badge.md
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/app/KiloSessionService.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/app/KiloSessionServiceTest.kt

Reviewed by grok-4.6 · Input: 54.5K · Output: 6.3K · Cached: 245K

Review guidance: REVIEW.md from base branch main

@kirillk
kirillk merged commit 4032c39 into main Aug 26, 2026
24 checks passed
@kirillk
kirillk deleted the fix/jetbrains-deleted-session-activity-snapshot branch August 26, 2026 13:40
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