Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

fix(onboarding): expand ~ in harness home so setup cannot die on ENOENT

rajpreetcodesfbbce307a8bc
diff --git a/src/main/config.ts b/src/main/config.ts
index f2d5292b..48e4e8d0 100644
--- a/src/main/config.ts
+++ b/src/main/config.ts
@@ -600,12 +600,17 @@ export function writeConfig(patch: Partial<HarnessConfig>): HarnessConfig {
.map((r) => expandTilde(r))
.filter((r) => r && !seen.has(r) && (seen.add(r), true));
}
- // Track recently-opened hive homes so the launch picker can list them. Any write
- // that SETS harnessHome (onboarding finish, changeHome) promotes it to the front,
- // deduped and capped. Skips empty/null so a clear doesn't pollute the list.
+ // harnessHome ingestion — the onboarding home field is typed by hand as often as
+ // it is picked from the folder dialog, and "~" is the natural way to write it.
+ // Expand like registeredRepos above so the persisted home is ABSOLUTE; a literal
+ // `~` would otherwise fail mkdir and poison every path derived from getHome().
if (typeof patch.harnessHome === 'string' && patch.harnessHome) {
+ next.harnessHome = expandTilde(patch.harnessHome);
+ // Track recently-opened hive homes so the launch picker can list them. Any write
+ // that SETS harnessHome (onboarding finish, changeHome) promotes it to the front,
+ // deduped and capped. Skips empty/null so a clear doesn't pollute the list.
const prior = current.recentHives ?? [];
- next.recentHives = [patch.harnessHome, ...prior.filter((h) => h !== patch.harnessHome)].slice(0, 8);
+ next.recentHives = [next.harnessHome, ...prior.filter((h) => h !== next.harnessHome)].slice(0, 8);
}
return persistConfig(next);
}
@@ -671,10 +676,12 @@ export function commandForAutoMode(
return flag ? `${base} ${flag}` : base;
}
-/** Ensure harnessHome exists on disk. */
+/** Ensure harnessHome exists on disk. The path may come straight from a text
+ * field ("~/HarnessAgents"), so expand `~` first — Node's fs treats a literal
+ * tilde as a directory name and the mkdir fails with ENOENT. */
export function ensureHarnessHome(path: string): { ok: boolean; error?: string } {
try {
- mkdirSync(path, { recursive: true });
+ mkdirSync(expandTilde(path), { recursive: true });
return { ok: true };
} catch (e) {
return { ok: false, error: e instanceof Error ? e.message : String(e) };
diff --git a/src/renderer/src/components/OnboardingWizard.tsx b/src/renderer/src/components/OnboardingWizard.tsx
index c592e9cb..82bf1d63 100644
--- a/src/renderer/src/components/OnboardingWizard.tsx
+++ b/src/renderer/src/components/OnboardingWizard.tsx
@@ -199,7 +199,7 @@ export function OnboardingWizard({ onComplete }: OnboardingWizardProps) {
}
noPadding
>
- <div style={{ padding: 20, display: 'flex', flexDirection: 'column', gap: 16 }}>
+ <div style={{ padding: 20, display: 'flex', flexDirection: 'column', gap: 16, maxHeight: '86vh', overflowY: 'auto' }}>
{step === 'persona' && (
<>
@@ -650,7 +650,8 @@ export function OnboardingWizard({ onComplete }: OnboardingWizardProps) {
background: 'var(--cth-coral-light)',
boxShadow: 'inset 0 0 0 1px var(--cth-coral)',
fontSize: 13,
- color: 'var(--cth-ink-900)'
+ color: 'var(--cth-ink-900)',
+ overflowWrap: 'anywhere'
}}>{error}</div>
)}
diff --git a/test/expand-tilde.test.cjs b/test/expand-tilde.test.cjs
index 75194c74..4fc01179 100644
--- a/test/expand-tilde.test.cjs
+++ b/test/expand-tilde.test.cjs
@@ -25,9 +25,11 @@ test('expands the tilde-home forms', () => {
});
test('leaves absolute paths alone (beyond normalizing)', () => {
- assert.equal(expandTilde('/a/b/c'), '/a/b/c');
- assert.equal(expandTilde('/a/b/c/'), '/a/b/c');
- assert.equal(expandTilde('/a/b/../c'), '/a/c');
+ // path.resolve anchors POSIX-looking paths to the current drive on Windows
+ // ("L:\a\b\c"), so compare against resolve() output rather than literals.
+ assert.equal(expandTilde('/a/b/c'), path.resolve('/a/b/c'));
+ assert.equal(expandTilde('/a/b/c/'), path.resolve('/a/b/c'));
+ assert.equal(expandTilde('/a/b/../c'), path.resolve('/a/c'));
});
test('does not touch anything that is not a tilde-home path', () => {
diff --git a/test/harness-home.test.cjs b/test/harness-home.test.cjs
new file mode 100644
index 00000000..50afe68d
--- /dev/null
+++ b/test/harness-home.test.cjs
@@ -0,0 +1,48 @@
+'use strict';
+
+/**
+ * Issue #140 — the onboarding harness-home field is typed by hand as often as it
+ * is picked, and `~/HarnessAgents` is the suggestion itself. Node's fs treats a
+ * literal `~` as a directory name, so ensureHarnessHome died with ENOENT and the
+ * un-expanded home would have been persisted, poisoning every path derived from
+ * it. The home now goes through the same expandTilde as registered repos.
+ */
+
+const test = require('node:test');
+const assert = require('node:assert/strict');
+const fs = require('node:fs');
+const os = require('node:os');
+const path = require('node:path');
+const loadTs = require('./load-ts.cjs');
+
+// config.ts pulls app.getPath('userData') from electron; outside Electron that
+// resolve gives a path string, so seed the cache with a temp userData dir.
+const userData = fs.mkdtempSync(path.join(os.tmpdir(), 'md-config-'));
+const electron = require.resolve('electron');
+require.cache[electron] = {
+ id: electron,
+ filename: electron,
+ loaded: true,
+ exports: { app: { getPath: () => userData } }
+};
+
+const { ensureHarnessHome, writeConfig, readConfig } = loadTs('src/main/config.ts');
+
+const HOME = os.homedir();
+
+test('ensureHarnessHome creates a tilde path on disk (issue #140)', (t) => {
+ const name = `md-harness-home-${process.pid}`;
+ t.after(() => fs.rmSync(path.join(HOME, name), { recursive: true, force: true }));
+ const res = ensureHarnessHome(`~/${name}`);
+ assert.equal(res.ok, true, res.error);
+ assert.equal(fs.existsSync(path.join(HOME, name)), true, 'the REAL home dir, not a literal "~" folder');
+});
+
+test('writeConfig persists harnessHome EXPANDED, like registeredRepos', () => {
+ const name = `md-harness-home-${process.pid}-cfg`;
+ const expanded = path.join(HOME, name);
+ const cfg = writeConfig({ harnessHome: `~/${name}` });
+ assert.equal(cfg.harnessHome, expanded);
+ assert.equal(cfg.recentHives[0], expanded, 'recent-hives tracking stores the same absolute path');
+ assert.equal(readConfig().harnessHome, expanded, 'what lands on disk is absolute');
+});