Skip to content

fix(swarm): stop deleting teams and task lists when the CLI process exits - #213

Merged
GoDiao merged 3 commits into
GoDiao:mainfrom
pcbeingused333:fix/keep-team-dirs-on-exit
Oct 30, 2026
Merged

GoDiao merged 3 commits into
GoDiao:mainfrom
pcbeingused333:fix/keep-team-dirs-on-exit

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Fixes #199

When the CLI process of a session that created a team exits, the team directory and its task list were deleted. init() registered a shutdown hook (cleanupSessionTeams) that removed every team created in the session unless TeamDelete had run. The server stops the CLI in many ordinary situations (Stop after the 3 s interrupt window, /clear, a session restart, the disconnect timeout, an idle prewarmed session, quitting the app, rewinding a session), so each of them lost the team, its members' messages and all tasks.

This removes that hook. Teams are now deleted only when the user or the lead runs TeamDelete, and a restarted or resumed session finds its team and task list on disk. The session-team tracking and cleanupSessionTeams stay in place and are no longer called on exit; what to do with teams that are never deleted is the separate decision the issue leaves open.

One behaviour to be aware of: the removed hook also killed teammates' tmux/iTerm2 panes when the leader exited. That no longer happens, so pane-backed teammates are left running, in line with keeping the team available to the next session.

Test: src/entrypoints/init.teamCleanup.test.ts creates a team and task list on disk, marks the team as created by the session, runs the real init() and the registered shutdown cleanups, and asserts both still exist. It fails on current main and passes with this change; src/utils/swarm and src/server/__tests__/teams.test.ts still pass (37 tests, bun 1.4). The CHANGELOG has a line under Unreleased. The full type check and lint were not run, and this was not tried against a live tmux session.

This change was made with Claude Code.

pcbeingused333 and others added 3 commits October 29, 2026 20:36
…xits

init() registered a shutdown hook that removed every team created in the session
(team directory, task directory) unless TeamDelete had run. The server stops the
CLI on Stop, /clear, restart and app quit, so a stop lost the whole team. Delete
teams only through TeamDelete.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@GoDiao GoDiao left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pcbeingused333! This is the fix #199 proposed: no shutdown hook, so teams go away only on an explicit TeamDelete. We ran the new test against main's init.ts and it fails there (the team directory is gone); with your change it passes, also in random order with the swarm and teams tests.

We pushed a merge of main and a small commit on top: your CHANGELOG entry had landed in the 0.6.1 section, so it now sits under [Unreleased] with a thanks line; we removed the added comments (we keep new code comment-free); and we fixed two existing comments in teamHelpers.ts and state.ts that said teams are cleaned up on exit.

We left cleanupSessionTeams and the session tracking in place, as you did: what to do with teams nobody deletes is the separate decision #199 leaves open. Approving and merging. Thanks again!

@GoDiao
GoDiao merged commit f96dda5 into GoDiao:main Oct 30, 2026
4 checks passed
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.

Stopping or restarting a lead session deletes its team and task directories

2 participants