Problem
Multiple save/versioning/export issues compound into a broken persistence story:
1. Export no longer routes to Agent Directory
The Agent Directory format (agentDirectory.ts — 609 lines generating agent.yaml + SOUL.md + INSTRUCTIONS.md + TOOLS.md + KNOWLEDGE.md + MEMORY.md) is disconnected from the main Export flow. SaveAgentModal.tsx (575 lines) offers download targets (Claude Code, Amp, Codex, etc.) but doesn't save to the agent library (~/.modular-studio/agents/).
User creates an agent through the wizard but has no clear path to persist it to the library AND export it.
2. Save flow unclear
The save flow has multiple entry points (SaveAgentModal, AgentActionBar, keyboard shortcut) but the relationship between:
agentStore.ts (server-side, ~/.modular-studio/agents/{id}/latest.json)
consoleStore.collectFullState() (client-side state snapshot)
agentDirectory.ts (human-readable directory format)
is not clear. Save sometimes works, sometimes silently fails (audit: .catch(() => {}) on save errors — P0-6).
3. Version history disconnected
Versions are stored in ~/.modular-studio/agents/{id}/versions/ but the UI version picker may not reflect actual persisted versions.
Success criteria
- Save button persists to agent library (
agentStore.ts) AND shows success/error toast
- Export offers: (a) download file, (b) save to library, (c) both
- Agent Directory format is the primary export format for the library
- Version history is accurate and matches persisted snapshots
- Loading an agent from the library restores full state
Implementation
- Wire
SaveAgentModal to call agentStore.saveAgent() as the PRIMARY action (not just download)
- Add "Save to Library" as a distinct action from "Export/Download"
- Replace
.catch(() => {}) with toast notification on save failure
- Add confirmation dialog before
restoreVersion()
- E2E test: Save → Back to Library → Load → verify all state restored
Problem
Multiple save/versioning/export issues compound into a broken persistence story:
1. Export no longer routes to Agent Directory
The Agent Directory format (
agentDirectory.ts— 609 lines generating agent.yaml + SOUL.md + INSTRUCTIONS.md + TOOLS.md + KNOWLEDGE.md + MEMORY.md) is disconnected from the main Export flow.SaveAgentModal.tsx(575 lines) offers download targets (Claude Code, Amp, Codex, etc.) but doesn't save to the agent library (~/.modular-studio/agents/).User creates an agent through the wizard but has no clear path to persist it to the library AND export it.
2. Save flow unclear
The save flow has multiple entry points (SaveAgentModal, AgentActionBar, keyboard shortcut) but the relationship between:
agentStore.ts(server-side,~/.modular-studio/agents/{id}/latest.json)consoleStore.collectFullState()(client-side state snapshot)agentDirectory.ts(human-readable directory format)is not clear. Save sometimes works, sometimes silently fails (audit:
.catch(() => {})on save errors — P0-6).3. Version history disconnected
Versions are stored in
~/.modular-studio/agents/{id}/versions/but the UI version picker may not reflect actual persisted versions.Success criteria
agentStore.ts) AND shows success/error toastImplementation
SaveAgentModalto callagentStore.saveAgent()as the PRIMARY action (not just download).catch(() => {})with toast notification on save failurerestoreVersion()