fix: multi-agent sessions survive group deletion on restart#174
Merged
fix: multi-agent sessions survive group deletion on restart#174
Conversation
DeleteGroup marks sessions as IsHidden and fires CloseSessionAsync in a Task.Run, but if the app restarts before CloseSessionAsync completes, the sessions reappear because: 1. Their IDs aren't in _closedSessionIds 2. SaveActiveSessionsToDisk uses merge logic that re-adds entries from the existing file unless they're in the closed set Fix: In DeleteGroup, immediately add session IDs to _closedSessionIds and call SaveActiveSessionsToDisk() before the fire-and-forget close. Added 5 tests: - 2 merge-level tests proving sessions survive/excluded based on closedIds - 2 integration tests verifying IsHidden on real sessions - 1 integration test verifying _closedSessionIds is populated Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…stence Addresses code review finding that Demo mode skips SaveActiveSessionsToDisk, leaving the critical save call untested. This test simulates the snapshot+merge pipeline directly, verifying that sessions from a deleted group are excluded via _closedSessionIds while surviving sessions are preserved. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Problem
Deleting a multi-agent group (e.g., Code Review Team) left orphaned sessions in
active-sessions.json. On app restart, those sessions reappeared without their group.Root Cause
DeleteGroupmarks sessions asIsHiddenand callsCloseSessionAsyncin a fire-and-forgetTask.Run. If the app restarts beforeCloseSessionAsynccompletes:_closedSessionIdsSaveActiveSessionsToDisk's merge logic re-added them from the existing fileFix
In
DeleteGroup, immediately:_closedSessionIds(prevents merge re-adding)SaveActiveSessionsToDisk()(persists the exclusion before restart)8-line change in
CopilotService.Organization.cs.Tests (5 new, 1126 total passing)
_closedSessionIdspopulated with deleted session IDs