fix(desktop): sync persona pack directory across worktree instances#782
Merged
Conversation
Worktree app instances share agent JSON files via symlinks but `agents/packs/` was excluded, causing agents created from a worktree to store a `persona_pack_path` pointing to a non-existent local packs directory. On next launch (from any instance), ACP fails with ENOENT trying to resolve the pack. Add `agents/packs` as a directory symlink in `sync_shared_agent_data` so all worktree instances share the canonical pack storage. Add a per-launch `reconcile_persona_pack_paths` that rewrites any stale worktree-specific paths to the canonical dev data directory.
The first attempt symlinked `agents/packs` from worktree to canonical, but canonical never had a packs directory — packs were installed in the `.main` instance's data dir. The symlink was silently skipped (`src.exists()` returned false) and all agents crashed. Scan sibling Application Support directories for a real (non-symlink) `agents/packs/` dir and move its contents to canonical before symlinking. This one-time migration ensures the canonical dir has the physical pack files regardless of which instance originally installed them.
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
agents/packsas a directory symlink insync_shared_agent_data, so all worktree app instances share the canonical dev instance's pack storageagents/packs/dirs and migrates their contents into the canonical directory -- handles the case where packs were installed from a specific worktree (e.g.,.main) before this syncing existedreconcile_persona_pack_paths(called at launch alongsidereconcile_provider_mcp_commands) that rewrites any stale worktree-specificpersona_pack_pathvalues inmanaged-agents.jsonto point to the canonical dev data directoryContext
PR #728 introduced worktree data syncing via symlinks for
managed-agents.json,personas.json, andteams.json. Theagents/packs/directory was deliberately excluded at the time ("recursive directory symlink is out of scope"). Now that pack-backed personas are in active use (com.wpfleger.sietch-tabr), agents created from worktree instances store apersona_pack_pathpointing to that worktree's own Application Support directory, which has no localpacks/folder. Sincemanaged-agents.jsonis shared via symlink, the bad path is visible to all instances and ACP crashes with ENOENT on startup.The key insight: the canonical
xyz.block.sprout.app.devdirectory never hadagents/packs/because packs were installed when running from the.maininstance, which has its own separate data directory. A simple symlink from worktree to canonical was silently skipped because the source didn't exist. The migration step finds packs wherever they actually live (scanning siblings) and moves them to canonical before creating symlinks.