Skip to content

feat: portable Aiden config under ~/.aiden - #3

Merged
sambitcreate merged 4 commits into
mainfrom
feat/portable-aiden-config
Jul 29, 2026
Merged

sambitcreate merged 4 commits into
mainfrom
feat/portable-aiden-config

Conversation

@sambitcreate

Copy link
Copy Markdown
Owner

Summary

Splits Aiden's persisted configuration into a portable half the user can hand-edit under ~/.aiden/config.json and a machine-local half that stays in Electron's userData, then picks up external edits live without a restart.

  • ~/.aiden/config.json (portable): provider intent + aliases, MCP servers, skills — the user's to edit by hand.
  • userData (local): UI settings, workspaces, regenerable model cache.
  • Secrets (provider-keys.json, pi-provider-credentials.json, mcp-oauth.json) stay safeStorage-bound in the local root, so a portable file carried to a second machine lists providers with hasKey: false until keys are re-entered there. (Intended, not a defect.)

Why

~/.aiden was already being read by skills-discovery and schedule-script, but the provider/MCP/skill config itself was trapped in userData — not portable, not editable, and silently overwritten on restart. This makes the portable directory the single source of truth for what a human maintains, and treats machine-local state as machine-local.

What changed

DataStore hardening (main/services/data-store.ts)

  • Roots in a caller-chosen directory (default userData), so the portable file can live under ~/.aiden.
  • reload() re-reads from disk and reports whether contents changed — gated by a content compare, not mtime/size, so two same-size hand-edits can't be silently dropped.
  • Atomic writes (stage sibling temp, then rename) so a mid-write crash or full disk can't truncate a hand-maintained file.
  • Unparseable files are parked aside as .invalid-<stamp> when preserveCorruptFile is set — a JSON typo costs a restart, not the config.

Config split (new)

  • aiden-config-dir.ts — resolves ~/.aiden (overridable via $AIDEN_CONFIG_DIR, which must be absolute; a relative override is rejected rather than resolved against an unpredictable packaged-app cwd).
  • portable-config-core.ts — the platform-independent split + one-time migration. Both roots are injected so the migration is exercisable against temp dirs.
  • config-store.ts → renamed to config-store-core.ts (platform-independent); a thin config-store.ts shim binds it to the portable stores.
  • skills-discovery.ts, schedule-script.ts now resolve roots via aidenConfigDir(), so redirecting the config dir moves skill/script discovery along with it. Explicitly injected homes still win → tests stay hermetic.

Live reload of external edits

  • portable-config-watch-core.ts coalesces a "re-read ~/.aiden/config.json" trigger fired on window focus and powerMonitor resume. The common path (no change) never reaches the renderer: reload() compares contents and only a real change raises app:config-externally-changed, which the renderer turns into invalidated providers, mcpServers, and skills query caches. Concurrent triggers coalesce into one re-read.

Commits

  1. feat(data-store): harden against corrupt files and support reload
  2. feat(config-dir): resolve Aiden's portable root via aidenConfigDir()
  3. feat(config): split persisted config into portable and local halves
  4. feat(config): re-read portable config on focus and wake

Tests

New suites added and registered in package.json (test, test:coverage), plus a focused test:portable-config script:

  • aiden-config-dir.test.ts
  • config-store-core.test.ts
  • portable-config-core.test.ts + portable-config-core.roundtrip.test.ts
  • portable-config-watch-core.test.ts
  • data-store.resilience.test.ts (corrupt-file, atomic-write, reload)

npm test is green.

Notes

  • Branch rebased onto latest main (includes the new pullfrog.yml workflow).
  • Only the portable store is reloaded on focus/wake; the three machine-local files are written exclusively by this process, so reloading them would only discard a warm cache.

DataStore now roots in a caller-chosen directory (defaulting to userData)
so the portable config file can live under ~/.aiden. Three behaviors follow:

- reload() re-reads the file from disk and reports whether contents
  changed, gated by a content compare rather than mtime/size so two
  same-size hand-edits cannot be silently dropped.
- Writes are atomic: stage a sibling temp, then rename over the target,
  so a mid-write crash or full disk cannot truncate a hand-maintained file.
- An unparseable file is parked beside itself (.invalid-<stamp>) before a
  write replaces it when preserveCorruptFile is set, so a JSON typo costs
  the user a restart rather than their config.

Resilience tests cover the corrupt-file, atomic-write, and reload paths.
Introduce aiden-config-dir.ts to resolve the portable user config root
`~/.aiden` (overridable via $AIDEN_CONFIG_DIR, which must be absolute).
Point skills-discovery and schedule-script at this resolver so redirecting
the config directory moves global skill and script roots along with it.
An explicitly injected home directory still wins, keeping tests hermetic.
Split config storage into a portable half under ~/.aiden/config.json
(provider intent, aliases, MCP servers, skills — the user's to hand-edit)
and a machine-local half in userData (settings, workspaces, model cache).
Secrets stay safeStorage-bound in the local root, so a portable file
carried to a second machine lists providers with hasKey: false until keys
are re-entered.

- config-store.ts is renamed to config-store-core.ts (platform-independent)
  with a thin config-store.ts shim binding it to the portable stores.
- portable-config-core.ts owns the split and the one-time migration; both
  roots are injected so the migration is exercisable against temp dirs.
- portable-config.ts is the Electron runtime binding.
- Register the new suites in package.json (test, test:coverage) and add a
  focused test:portable-config script.
Wire a coalescing watcher that re-reads ~/.aiden/config.json on window
focus and powerMonitor resume. The common path (no change) never reaches
the renderer: reload() compares contents and only a real change raises
app:config-externally-changed, which the renderer turns into invalidated
provider, MCP server, and skill query caches. Concurrent triggers coalesce
into one re-read. Renderer edits (formatting only in root-view.tsx).

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed changes — this PR splits Aiden's configuration into a portable ~/.aiden/config.json (provider intent, aliases, MCP servers, skills) and machine-local stores (UI settings, workspaces, model cache), with DataStore hardenings and live reload on window focus/wake.

  • Harden DataStore — caller-chosen root, atomic rename-based writes, reload() with content-comparison gating (not stat), preserveCorruptFile option to rescue unparseable files as .invalid-<stamp> copies.
  • aidenConfigDir() — resolves ~/.aiden (overridable via $AIDEN_CONFIG_DIR), rejects relative overrides.
  • Portable config split + one-time migration in portable-config-core.ts — splits provider intent from regenerable cache, archives the pre-split config.json, and seeds the four new files.
  • config-store-core.ts — platform-independent routing layer that calls migratePiProviderConfig on a correctly-ordered composite draft carrying real models/modelMetadata.
  • Live reload on focus/wake — portable-config-watch-core.ts coalesces concurrent triggers; only a content change reaches the renderer via app:config-externally-changed.
  • skills-discovery.ts and schedule-script.ts now resolve ~/.aiden roots through aidenConfigDir(), moving skill/script discovery with redirected config directories.
  • root-view.tsx invalidates providers, mcpServers, and skills query caches on external changes.
  • New test suites registered in package.json (test, test:coverage) plus a focused test:portable-config script: aiden-config-dir, config-store-core, portable-config-core + roundtrip, portable-config-watch-core, and data-store.resilience.

✅ No new issues found.

This is a thorough, well-tested change. Migration ordering is correct (the split runs before Pi seeding, and the composite draft carries real models/metadata so isUntouchedPiPreset sees the right data), corrupt-file preservation is gated on preserveCorruptFile and only fires once, concurrent refreshes coalesce, the migration is idempotent across processes, and the crash-interruption recovery paths converge. All external callers of discoverSkills, resolveScheduledScript, and listScheduledScripts remain backward compatible. No concerns.

Pullfrog  | View workflow run | Using DeepSeek Pro | 𝕏

@sambitcreate
sambitcreate merged commit c0813be into main Jul 29, 2026
1 check passed
@sambitcreate
sambitcreate deleted the feat/portable-aiden-config branch July 30, 2026 13:35
sambitcreate added a commit that referenced this pull request Oct 13, 2026
…e condition, and text-only reply recognition

This commit addresses three findings from code review:

1. [chat-pane #1] Observed phone-started turns are no longer suppressed when the chat's cached messages end in an assistant message from a different run. The suppression now checks if the last cached assistant message matches the observed run's generation ID, allowing new observed turns to display even in existing chats.

2. [observed-local-run #2] Fixed a race condition where an obsolete idle-release grace-period read could close a retained observer. After the async read completes, we now recheck the release authority flag before closing, so a retained observation survives if it was claimed by a newer turn.

3. [observed-local-run #3] Text-only replies without timeline fields are now recognized as the current run's saved reply by matching the doneMessageId from the persisted message. The hasReplyFrom predicate now checks both timeline.generationId (for multi-step replies) and doneMessageId (for text-only replies).

All observer lifecycle and chat visibility tests pass, including two new tests covering the release race condition and text-only reply handoff.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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