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

test(#140): cover the real ensureHarnessHome, Windows-safe path assertions

rajpreetcodesf8df0395f4a3
diff --git a/package.json b/package.json
index 97bb375a..f222bf69 100644
--- a/package.json
+++ b/package.json
@@ -19,7 +19,7 @@
"typecheck:node": "tsc --noEmit -p tsconfig.node.json",
"typecheck:web": "tsc --noEmit -p tsconfig.web.json",
"typecheck": "npm run typecheck:node && npm run typecheck:web",
- "test:focused": "node --test test/codex-remote.test.cjs test/control.test.cjs test/provider-automation.test.cjs test/provider-config.test.cjs test/queue-delivery.test.cjs test/terminal-automation.test.cjs test/terminal-recovery.test.cjs test/terminal-selection.test.cjs test/roster.test.cjs test/proc-kill.test.cjs test/expand-tilde.test.cjs test/hive-cwd.test.cjs test/hive-task-mutation.test.cjs test/hive-hook-node.test.cjs test/hive-roster-injection.test.cjs test/hive-runtime-path.test.cjs test/cli-install-ladder.test.cjs test/node-install.test.cjs test/office-gl-recovery.test.cjs test/update-state.test.cjs test/release-notes.test.cjs test/transcript-project-dir.test.cjs test/commit-graph.test.cjs test/ide-image.test.cjs test/win-cmd-shim.test.cjs test/hive-windows-prompt.test.cjs test/release-drop.test.cjs test/skills.test.cjs test/skills-install.test.cjs test/hero-payload.test.cjs",
+ "test:focused": "node --test test/codex-remote.test.cjs test/control.test.cjs test/provider-automation.test.cjs test/provider-config.test.cjs test/queue-delivery.test.cjs test/terminal-automation.test.cjs test/terminal-recovery.test.cjs test/terminal-selection.test.cjs test/roster.test.cjs test/proc-kill.test.cjs test/expand-tilde.test.cjs test/harness-home.test.cjs test/hive-cwd.test.cjs test/hive-task-mutation.test.cjs test/hive-hook-node.test.cjs test/hive-roster-injection.test.cjs test/hive-runtime-path.test.cjs test/cli-install-ladder.test.cjs test/node-install.test.cjs test/office-gl-recovery.test.cjs test/update-state.test.cjs test/release-notes.test.cjs test/transcript-project-dir.test.cjs test/commit-graph.test.cjs test/ide-image.test.cjs test/win-cmd-shim.test.cjs test/hive-windows-prompt.test.cjs test/release-drop.test.cjs test/skills.test.cjs test/skills-install.test.cjs test/hero-payload.test.cjs",
"check:links": "node tools/check-release-links.cjs",
"dist": "npm run build && electron-builder",
"dist:mac": "npm run build && electron-builder --mac",
diff --git a/src/renderer/src/components/OnboardingWizard.tsx b/src/renderer/src/components/OnboardingWizard.tsx
index 6f8979e4..63aa667a 100644
--- a/src/renderer/src/components/OnboardingWizard.tsx
+++ b/src/renderer/src/components/OnboardingWizard.tsx
@@ -667,7 +667,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 f818b0fc..b5d2ea1f 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', () => {
@@ -68,14 +70,14 @@ test('#140: the suggested default is expanded, not persisted literally', () => {
test('#140: the new home leads the recent list exactly once', () => {
const { recentHives } = normalizeHiveHome('~/HarnessAgents', ['/other/hive']);
- assert.deepEqual(recentHives, [path.join(HOME, 'HarnessAgents'), '/other/hive']);
+ assert.deepEqual(recentHives, [path.join(HOME, 'HarnessAgents'), path.resolve('/other/hive')]);
});
test('#140: stale `~` entries already on disk are normalized too', () => {
// Without this the launch picker could hand a pre-fix `~/…` string straight
// back and reintroduce the identical mkdir failure.
const { recentHives } = normalizeHiveHome('/now/here', ['~/HarnessAgents']);
- assert.deepEqual(recentHives, ['/now/here', path.join(HOME, 'HarnessAgents')]);
+ assert.deepEqual(recentHives, [path.resolve('/now/here'), path.join(HOME, 'HarnessAgents')]);
});
test('#140: the same home written twice does not duplicate', () => {
@@ -90,7 +92,7 @@ test('#140: the recent list stays capped and skips blanks', () => {
const prior = Array.from({ length: 20 }, (_, i) => `/hive/${i}`);
const { recentHives } = normalizeHiveHome('/hive/new', ['', ' ', ...prior]);
assert.equal(recentHives.length, 8);
- assert.equal(recentHives[0], '/hive/new');
+ assert.equal(recentHives[0], path.resolve('/hive/new'));
});
/* ------------------------------------------------------------------ *
@@ -100,20 +102,11 @@ test('#140: the recent list stays capped and skips blanks', () => {
* literal `~` — which either fails outright or, worse, silently creates a
* directory actually named "~" wherever the process cwd happens to be, leaving
* the hive somewhere the user will never find it.
+ *
+ * The real ensureHarnessHome is exercised end-to-end (through a stubbed
+ * electron `app`) in test/harness-home.test.cjs.
* ------------------------------------------------------------------ */
-test('#140: ensureHarnessHome creates the expanded path, never a literal ~', () => {
- const { ensureHarnessHome } = (() => {
- // config.ts imports electron, so exercise the same contract through the
- // expander that ensureHarnessHome now applies before mkdirSync.
- return { ensureHarnessHome: (p) => expandTilde(p) };
- })();
- const target = ensureHarnessHome('~/HarnessAgents');
- assert.equal(target, path.join(HOME, 'HarnessAgents'));
- assert.ok(!target.startsWith('~'), 'mkdirSync must never receive a bare ~');
- assert.ok(path.isAbsolute(target), 'a relative ~ path would land beside the process cwd');
-});
-
test('#140: both entry points agree on the same directory', () => {
// The mkdir (ensureHarnessHome) and the persisted value (normalizeHiveHome)
// must resolve identically, or the app creates one folder and then records a
diff --git a/test/harness-home.test.cjs b/test/harness-home.test.cjs
new file mode 100644
index 00000000..75655199
--- /dev/null
+++ b/test/harness-home.test.cjs
@@ -0,0 +1,54 @@
+'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.
+ *
+ * This file exercises the REAL ensureHarnessHome / writeConfig / readConfig from
+ * src/main/config.ts (electron's app.getPath stubbed to a temp dir). It replaces
+ * the stand-in test that used to live in expand-tilde.test.cjs — that one only
+ * re-ran expandTilde and would still have passed with the expandTilde call
+ * deleted from the real ensureHarnessHome.
+ */
+
+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');
+});