fix: prevent agent settings from being silently deleted on channel deletion#752
Merged
Merged
Conversation
…letion cleanupChannelAgents relied on stale relay kind:10100 data to determine orphan status, incorrectly deleting agents that were still in other channels. Both cleanupChannelAgents and cleanupManagedAgentIfOrphaned are now no-ops — agent records are cheap to keep and users can manually remove orphans from the agents page. Also makes save_managed_agents atomic (write-to-tmp + rename) to prevent partial writes from corrupting the agent store on crash. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced May 28, 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.
Summary
Disable auto-deletion of managed agents on channel deletion.
cleanupChannelAgentsandcleanupManagedAgentIfOrphanedrelied on relay kind:10100 events to determine whether an agent was "orphaned" — but relay data can be stale/incomplete, causing agents that are still active in other channels to be incorrectly deleted. This wiped all customized settings (ENV vars, MCP config, parallelism, system prompts). Both functions and their call sites have been removed entirely.Make
save_managed_agentsuse atomic writes. Previously used barefs::writewhich can leave a corrupted/partial file if the process crashes mid-write. Now writes to a.json.tmpfile first, then atomically renames it into place.Remove legacy migration code. The
com.wesb.sprout→xyz.block.sprout.appdata directory migration is no longer needed — all existing users have been migrated. Removesmigration.rsand its call site entirely.Root cause
When a channel is deleted, the frontend called
cleanupChannelAgents(channelId), which:The relay data used in step 2 can be stale or incomplete — an agent that IS still active in another channel may appear orphaned because its kind:10100 event hasn't been indexed yet. This causes the agent record (with all its customized settings) to be deleted.
Changes
desktop/src/features/channels/cleanupChannelAgents.tsdesktop/src/features/channels/hooks.tsremoveChannelMemberWithManagedAgentCleanuphelperdesktop/src/features/channels/ui/useMembersSidebarActions.tsremoveChannelMembercalldesktop/src-tauri/src/managed_agents/storage.rssave_managed_agentsdesktop/src-tauri/src/migration.rsdesktop/src-tauri/src/lib.rsmod migrationandmigrate_legacy_data_dircallNet: -397 lines
Test plan
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com