fix(jetbrains): prune deleted sessions in the merged activity snapshot - #13470
Merged
Conversation
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.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (3 files)
Reviewed by grok-4.6 · Input: 54.5K · Output: 6.3K · Cached: 245K Review guidance: REVIEW.md from base branch |
marius-kilocode
approved these changes
Aug 26, 2026
This was referenced Aug 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
KiloSessionService.activitySnapshot()now subtracts the locally-removed session set when mergingstatusesandactivity.Why
The
testworkflow onmainfailed inKiloSessionServiceTest:statusesandactivityare two separateStateFlows, each pruning theremovedset through its owncombinecollector. 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 asRUNNING.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
removedset 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 onactivitybefore asserting on data sourced from both flows; it now waits on both.Verification
./gradlew :frontend:test --tests 'ai.kilocode.client.app.KiloSessionServiceTest' --rerun-tasksx3./gradlew typecheck./gradlew test(full JetBrains suite)