Skip to content

fix(desktop): sync persona pack directory across worktree instances#782

Merged
wpfleger96 merged 2 commits into
mainfrom
wpfleger/worktree-sync-persona-packs
May 29, 2026
Merged

fix(desktop): sync persona pack directory across worktree instances#782
wpfleger96 merged 2 commits into
mainfrom
wpfleger/worktree-sync-persona-packs

Conversation

@wpfleger96
Copy link
Copy Markdown
Collaborator

@wpfleger96 wpfleger96 commented May 29, 2026

Summary

  • Adds agents/packs as a directory symlink in sync_shared_agent_data, so all worktree app instances share the canonical dev instance's pack storage
  • Before symlinking, scans sibling Application Support directories for existing (non-symlink) agents/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 existed
  • Adds reconcile_persona_pack_paths (called at launch alongside reconcile_provider_mcp_commands) that rewrites any stale worktree-specific persona_pack_path values in managed-agents.json to point to the canonical dev data directory

Context

PR #728 introduced worktree data syncing via symlinks for managed-agents.json, personas.json, and teams.json. The agents/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 a persona_pack_path pointing to that worktree's own Application Support directory, which has no local packs/ folder. Since managed-agents.json is 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.dev directory never had agents/packs/ because packs were installed when running from the .main instance, 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.

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.
@wpfleger96 wpfleger96 requested a review from a team as a code owner May 29, 2026 00:15
@wpfleger96 wpfleger96 marked this pull request as draft May 29, 2026 00:16
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.
@wpfleger96 wpfleger96 marked this pull request as ready for review May 29, 2026 00:41
@wpfleger96 wpfleger96 merged commit fa7febe into main May 29, 2026
15 checks passed
@wpfleger96 wpfleger96 deleted the wpfleger/worktree-sync-persona-packs branch May 29, 2026 00:41
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.

1 participant