Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
test(desktop): ungate 8 smoke specs for Windows/Linux (#3084)
mike-inkeep873b9305a02f
diff --git a/.changeset/default-projects-root-known-folder.md b/.changeset/default-projects-root-known-folder.mdnew file mode 100644index 000000000..b0ff5dd1e--- /dev/null+++ b/.changeset/default-projects-root-known-folder.md@@ -0,0 +1,5 @@+---+"@inkeep/open-knowledge": patch+---++Fixed the Create-new-project dialog showing "No location selected" instead of the remembered location on systems where the OS cannot resolve the Documents folder (seen on headless Windows Server sessions). The location probe no longer fails outright in that case: it uses the remembered parent when one exists, and falls back to `<home>/Documents/OpenKnowledge` otherwise.diff --git a/packages/desktop/src/main/index.ts b/packages/desktop/src/main/index.tsindex 8754a904c..67818a302 100644--- a/packages/desktop/src/main/index.ts+++ b/packages/desktop/src/main/index.ts@@ -5230,7 +5230,24 @@ function registerIpcHandlers() {// as defense-in-depth (renderer is untrusted at the IPC boundary).handle('ok:fs:default-projects-root', async () => {- return resolveDefaultProjectsRoot(appState.lastUsedProjectParent, app.getPath('documents'));+ // `app.getPath('documents')` throws when the OS can't resolve the+ // Documents known folder (seen on headless Windows Server sessions,+ // where SHGetKnownFolderPath fails for never-provisioned per-user+ // folders). Evaluated eagerly it would reject the whole probe — even+ // when a perfectly good persisted parent exists — and the dialog+ // falls to its empty "No location selected" state. `home` resolves+ // from the environment and does not have this failure mode.+ let documentsDir: string;+ try {+ documentsDir = app.getPath('documents');+ } catch (err) {+ getLogger('fs').warn(+ { err },+ "app.getPath('documents') failed; falling back to home/Documents",+ );+ documentsDir = join(app.getPath('home'), 'Documents');+ }+ return resolveDefaultProjectsRoot(appState.lastUsedProjectParent, documentsDir);});handle('ok:fs:folder-state', async (_event, path) => {diff --git a/packages/desktop/tests/smoke/_helpers/electron-cleanup.test.ts b/packages/desktop/tests/smoke/_helpers/electron-cleanup.test.tsindex d97903ec1..4126b3555 100644--- a/packages/desktop/tests/smoke/_helpers/electron-cleanup.test.ts+++ b/packages/desktop/tests/smoke/_helpers/electron-cleanup.test.ts@@ -107,7 +107,7 @@ describe('closeAppBounded — real subprocess contract', () => {};const start = Date.now();- await closeAppBounded(proc, { gracefulMs: 5_000, kill: spyKill });+ await closeAppBounded(proc, { gracefulMs: 5_000, kill: spyKill, platform: 'linux' });const elapsed = Date.now() - start;// Subprocess takes ~100 ms to exit; closeAppBounded should return@@ -144,7 +144,7 @@ describe('closeAppBounded — real subprocess contract', () => {};const start = Date.now();- await closeAppBounded(proc, { gracefulMs: 300, kill: spyKill });+ await closeAppBounded(proc, { gracefulMs: 300, kill: spyKill, platform: 'linux' });const elapsed = Date.now() - start;// Upper bound only: gracefulMs + generous slack for the kill call.@@ -195,7 +195,7 @@ describe('closeAppBounded — real subprocess contract', () => {};const start = Date.now();- await closeAppBounded(proc, { gracefulMs: 5_000, kill: spyKill });+ await closeAppBounded(proc, { gracefulMs: 5_000, kill: spyKill, platform: 'linux' });const elapsed = Date.now() - start;// Early-return: no wait, no kill. Generous 100 ms ceiling for setup +diff --git a/packages/desktop/tests/smoke/_helpers/electron-cleanup.ts b/packages/desktop/tests/smoke/_helpers/electron-cleanup.tsindex b0ace263f..ecc0d2207 100644--- a/packages/desktop/tests/smoke/_helpers/electron-cleanup.ts+++ b/packages/desktop/tests/smoke/_helpers/electron-cleanup.ts@@ -58,23 +58,38 @@* `process.kill(-pid, 'SIGKILL')` — same kill mechanism Playwright's* own processLauncher uses. The negated* PID kills the entire group atomically: Electron main + helper- * subprocesses + utility process tree.+ * subprocesses + utility process tree. On win32 this step is+ * `taskkill /T /F` plus a bounded wait for the OS to finish reaping+ * (see below).*- * The `kill` opts parameter exists for unit testability — the bun test- * passes a spy to assert which arguments were sent without monkey-patching- * the global `process.kill`. Production callers (the smoke fixture) omit- * it; the helper defaults to `process.kill`.+ * The `kill` / `taskkill` / `platform` opts exist for unit testability —+ * the unit test passes spies to assert which arguments were sent, and pins+ * the platform so both force-kill branches are exercised from any host,+ * without monkey-patching the global `process.kill`. Production callers+ * (the smoke fixture) omit all three.*- * Process-group kill is POSIX-specific. The smoke harness is darwin-only- * (per `.e2e.ts` skip gates referencing `process.platform === 'darwin'`),- * so this is a sound assumption. If the harness is ever extended to- * Windows, the kill code path here would need a parallel branch using- * `taskkill`.+ * Process-group kill is POSIX-specific — Windows has no process groups+ * and Node throws on a negative pid there, which the catch below would+ * swallow, making the force-kill a silent no-op. That exact shape broke+ * the first cross-platform run of the multi-launch specs: app1 survived+ * its "kill", held the Chromium userData singleton, and app2's browser+ * process did the singleton rendezvous and exited 0 mid-CDP-attach+ * (`electron.launch: WebSocket error: read ECONNRESET`). POSIX was never+ * affected because `kill(-pid)` nukes the whole group. On win32 the+ * force-kill therefore shells out to `taskkill /pid <pid> /T /F` — the+ * `/T` tree flag is the load-bearing part.+ *+ * `taskkill` only REQUESTS termination, so returning on its exit reproduces+ * the same ECONNRESET intermittently: the lock survives until Windows has+ * actually reaped the browser process. The win32 branch therefore also waits+ * (bounded) for the real `'exit'`, which is what makes "dead on resolution"+ * true rather than merely requested.** No production code dependency. Test infrastructure only.*/import type { ChildProcess } from 'node:child_process';+import { spawnSync } from 'node:child_process';import { type Dirent, readdirSync, readFileSync } from 'node:fs';import { join } from 'node:path';import type { ElectronApplication } from '@playwright/test';@@ -93,10 +108,46 @@ export interface CloseAppBoundedOpts {*/gracefulMs?: number;/**- * Kill function. Defaults to `process.kill`. Exposed as opts for unit- * testability — the bun unit test passes a spy.+ * POSIX kill function. Defaults to `process.kill`. Exposed as opts for+ * unit testability — the unit test passes a spy.*/kill?: (pid: number, signal: NodeJS.Signals | string) => void;+ /**+ * Windows tree-kill. Defaults to `taskkill /pid <pid> /T /F`. A seam+ * separate from `kill` because the Windows call carries no signal+ * argument, so pinning platform dispatch needs a spy per branch.+ */+ taskkill?: (pid: number) => void;+ /**+ * Platform the force-kill branches on. Defaults to `process.platform`.+ * Tests pin it so both branches are exercised from any host — otherwise+ * the win32 branch would only ever run on a Windows runner.+ */+ platform?: NodeJS.Platform;+}++/**+ * Default Windows force-kill: `taskkill /pid <pid> /T /F`. The `/T` tree+ * flag is the load-bearing part — Windows has no process groups, so+ * without it Electron's helper and utility subprocesses survive.+ *+ * `timeout` keeps this synchronous call inside the primitive's bounded-+ * time contract. taskkill returns in well under a second in practice; the+ * bound exists so a wedged call can't block the event loop indefinitely+ * and defeat the very invariant `closeAppBounded` enforces.+ */+/**+ * Cap on the post-taskkill wait for Windows to actually reap the tree. Short+ * because the reap is normally sub-second; the bound exists so a wedged+ * process can't stretch teardown past the fixture's budget.+ */+const POST_KILL_REAP_MS = 2_000;++function taskkillTree(pid: number): void {+ spawnSync('taskkill', ['/pid', String(pid), '/T', '/F'], {+ stdio: 'ignore',+ timeout: 5_000,+ });}/**@@ -222,12 +273,31 @@ export async function closeAppBounded(if (isProcessGone(proc)) return;// Process is still alive after the graceful budget. Force-kill the- // process group. Negated PID = process-group kill on POSIX.+ // process group. Negated PID = process-group kill on POSIX; Windows has+ // no groups, so taskkill's /T walks the tree instead (see file header —+ // without it the kill is a silent no-op and the app survives).// Defensive: only attempt if pid is a positive integer (Playwright's// launchedProcess.pid is set on successful launch, but defending against// unexpected shapes is cheap).const killFn = opts.kill ?? process.kill.bind(process);if (typeof proc.pid === 'number' && Number.isInteger(proc.pid) && proc.pid > 0) {+ if ((opts.platform ?? process.platform) === 'win32') {+ (opts.taskkill ?? taskkillTree)(proc.pid);+ // taskkill REQUESTS termination; it returns before Windows has reaped+ // the tree. That gap is observable: Chromium holds `SingletonLock` in+ // userData open until the browser process is actually gone, so a+ // relaunch against the same userData inside the window fails the+ // singleton rendezvous ("Lock file can not be created! Error code: 32"+ // == ERROR_SHARING_VIOLATION) and the new app exits mid-CDP-attach with+ // `electron.launch: WebSocket error: read ECONNRESET`. Waiting for the+ // real exit makes the post-condition — dead on resolution — hold.+ //+ // POSIX needs no equivalent: `kill(-pid, SIGKILL)` is delivered by the+ // kernel before it returns, and the singleton there is a symlink with a+ // liveness check rather than an exclusively-held handle.+ await waitForExit(proc, Math.min(gracefulMs, POST_KILL_REAP_MS));+ return;+ }try {killFn(-proc.pid, 'SIGKILL');} catch {diff --git a/packages/desktop/tests/smoke/_nav-empty-840x600.e2e.ts b/packages/desktop/tests/smoke/_nav-empty-840x600.e2e.tsindex 611fece06..9db908af8 100644--- a/packages/desktop/tests/smoke/_nav-empty-840x600.e2e.ts+++ b/packages/desktop/tests/smoke/_nav-empty-840x600.e2e.ts@@ -9,6 +9,10 @@* from the populated state.** Output: packages/desktop/tmp/nav-shot-empty-840x600.png+ *+ * Gated on a supported host platform, not on darwin: the capture is of the+ * renderer's own layout, which is the same React tree everywhere, so the shot+ * is worth having per-OS (window chrome differs and that is the point).*/import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';@@ -21,14 +25,17 @@ import {desktopLaunchOptions,resolveDesktopTarget,} from './_helpers/launch-desktop';+import {+ homeEnv,+ PLATFORM_SKIP_REASON,+ PLATFORM_SUPPORTED,+ SMOKE_ENABLED,+} from './_helpers/platform-gate';import { expect, test } from './_helpers/smoke-test';const TARGET = resolveDesktopTarget();const SHOT_DIR = resolve(DESKTOP_ROOT, 'tmp');-const SMOKE_ENABLED = process.env.OK_DESKTOP_E2E_SMOKE === '1';-const DARWIN = process.platform === 'darwin';-function userDataDirFor(tmpHome: string): string {return join(tmpHome, 'electron-userdata');}@@ -58,7 +65,7 @@ async function launchApp(tmpHome: string): Promise<ElectronApplication> {target: TARGET,args: [`--user-data-dir=${userDataDirFor(tmpHome)}`],timeout: 30_000,- env: { ...process.env, HOME: tmpHome, OK_DESKTOP_E2E_SMOKE: '1' },+ env: { ...process.env, ...homeEnv(tmpHome), OK_DESKTOP_E2E_SMOKE: '1' },}),);}@@ -95,7 +102,7 @@ function rmSafe(p: string): void {test.describe('Navigator empty-state screenshot (dev-only)', () => {test.skip(!SMOKE_ENABLED, 'Set OK_DESKTOP_E2E_SMOKE=1 to run.');- test.skip(!DARWIN, 'Smoke harness is darwin-only in v0.');+ test.skip(!PLATFORM_SUPPORTED, PLATFORM_SKIP_REASON);test.skip(!TARGET.exists, TARGET.missingReason);test('capture empty Navigator at 840x600', async ({ captureStderrFor }) => {diff --git a/packages/desktop/tests/smoke/_nav-size-screenshots.e2e.ts b/packages/desktop/tests/smoke/_nav-size-screenshots.e2e.tsindex b4deaf4a4..00d51333e 100644--- a/packages/desktop/tests/smoke/_nav-size-screenshots.e2e.ts+++ b/packages/desktop/tests/smoke/_nav-size-screenshots.e2e.ts@@ -9,6 +9,10 @@* between captures. One Electron instance — no single-instance-lock fight.** Output: packages/desktop/tmp/nav-shot-<w>x<h>.png (gitignored).+ *+ * Gated on a supported host platform, not on darwin: the capture is of the+ * renderer's own layout, which is the same React tree everywhere, so the shots+ * are worth having per-OS (window chrome differs and that is the point).*/import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';@@ -21,14 +25,17 @@ import {desktopLaunchOptions,resolveDesktopTarget,} from './_helpers/launch-desktop';+import {+ homeEnv,+ PLATFORM_SKIP_REASON,+ PLATFORM_SUPPORTED,+ SMOKE_ENABLED,+} from './_helpers/platform-gate';import { expect, test } from './_helpers/smoke-test';const TARGET = resolveDesktopTarget();const SHOT_DIR = resolve(DESKTOP_ROOT, 'tmp');-const SMOKE_ENABLED = process.env.OK_DESKTOP_E2E_SMOKE === '1';-const DARWIN = process.platform === 'darwin';-const SIZES = [{ w: 800, h: 750, label: 'current-800x750' },{ w: 840, h: 600, label: 'proposed-default-840x600' },@@ -90,7 +97,7 @@ async function launchApp(tmpHome: string): Promise<ElectronApplication> {target: TARGET,args: [`--user-data-dir=${userDataDirFor(tmpHome)}`],timeout: 30_000,- env: { ...process.env, HOME: tmpHome, OK_DESKTOP_E2E_SMOKE: '1' },+ env: { ...process.env, ...homeEnv(tmpHome), OK_DESKTOP_E2E_SMOKE: '1' },}),);}@@ -131,7 +138,7 @@ function rmSafe(p: string): void {test.describe('Navigator size screenshots (dev-only)', () => {test.skip(!SMOKE_ENABLED, 'Set OK_DESKTOP_E2E_SMOKE=1 to run.');- test.skip(!DARWIN, 'Smoke harness is darwin-only in v0.');+ test.skip(!PLATFORM_SUPPORTED, PLATFORM_SKIP_REASON);test.skip(!TARGET.exists, TARGET.missingReason);test('capture Navigator at 3 candidate sizes', async ({ captureStderrFor }) => {diff --git a/packages/desktop/tests/smoke/agent-patch-divergence-probe.e2e.ts b/packages/desktop/tests/smoke/agent-patch-divergence-probe.e2e.tsindex 6c2269b16..ab5628475 100644--- a/packages/desktop/tests/smoke/agent-patch-divergence-probe.e2e.ts+++ b/packages/desktop/tests/smoke/agent-patch-divergence-probe.e2e.ts@@ -31,8 +31,11 @@* never false-GREEN. If the agent's `replace` never reaches the Y.Doc,* the marker never appears and the assertion fails after the budget.*- * Skip conditions mirror the existing smoke tests (smoke-gated, darwin-- * only, build-must-exist).+ * Skip conditions mirror the existing smoke tests (smoke-gated, supported+ * host platform, build-must-exist). The deep link is delivered through+ * `electron.launch`'s argv, which `src/main/url-scheme.ts` scans+ * synchronously on every OS — no `open(1)` and no Apple Event involved, so+ * this driver is not macOS-bound.*/import { randomUUID } from 'node:crypto';@@ -42,11 +45,10 @@ import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';import { type ElectronApplication, _electron as electron } from '@playwright/test';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';+import { PLATFORM_SKIP_REASON, PLATFORM_SUPPORTED, SMOKE_ENABLED } from './_helpers/platform-gate';import { expect, test } from './_helpers/smoke-test';const TARGET = resolveDesktopTarget();-const SMOKE_ENABLED = process.env.OK_DESKTOP_E2E_SMOKE === '1';-const DARWIN = process.platform === 'darwin';// Bounded budget to poll the server Y.Doc for the converged post-race state.// A fixed sleep risks a false-RED on a slow runner but never a false-GREEN:@@ -185,9 +187,13 @@ async function executeRace(opts: {await targetPara.click();await page.keyboard.press('End');- // For mark-overlap: select a span overlapping BANANA and apply bold via- // the keyboard shortcut Cmd+B. This creates a Y.XmlText with a strong- // mark whose simpleDiff window MAY shift when the agent's replace lands.+ // For mark-overlap: select a span overlapping BANANA and apply bold via the+ // keyboard shortcut. TipTap binds bold to `Mod-b`, which ProseMirror+ // resolves to Cmd on mac and Ctrl elsewhere, so the chord pressed here has+ // to resolve the same way or the mark never lands and the variant degrades+ // into a duplicate of the same-paragraph case. This creates a Y.XmlText with+ // a strong mark whose simpleDiff window MAY shift when the agent's replace+ // lands.if (variant === 'mark-overlap') {// Select from end-of-line backward by 16 chars (covers "is here in the f"// — overlaps the BANANA paragraph's content but NOT the BANANA word@@ -195,7 +201,7 @@ async function executeRace(opts: {for (let i = 0; i < 16; i++) {await page.keyboard.press('Shift+ArrowLeft');}- await page.keyboard.press('Meta+B');+ await page.keyboard.press('ControlOrMeta+B');// Deselect, return to end of paragraph.await page.keyboard.press('End');// Let the bold-mark update propagate.@@ -291,7 +297,7 @@ async function setupElectron(userDataDir: string;}> {test.skip(!SMOKE_ENABLED, 'Set OK_DESKTOP_E2E_SMOKE=1 to run Electron smoke tests.');- test.skip(!DARWIN, 'Driver uses macOS open(1).');+ test.skip(!PLATFORM_SUPPORTED, PLATFORM_SKIP_REASON);test.skip(!TARGET.exists, TARGET.missingReason);const contentDir = mkdtempSync(join(tmpdir(), `ok-agent-patch-probe-${variantTag}-`));diff --git a/packages/desktop/tests/smoke/background-throttle.e2e.ts b/packages/desktop/tests/smoke/background-throttle.e2e.tsindex 14663d467..6aae4c983 100644--- a/packages/desktop/tests/smoke/background-throttle.e2e.ts+++ b/packages/desktop/tests/smoke/background-throttle.e2e.ts@@ -27,9 +27,10 @@* the test's signal the last writer on each attempt rather than depending on* the window being quiescent.*- * Skip gates (same as the rest of the smoke suite):+ * Skip gates (same as the rest of the cross-platform smoke suite):* - `OK_DESKTOP_E2E_SMOKE !== '1'` — opt-in.- * - `process.platform !== 'darwin'` — darwin-only.+ * - an unsupported host platform — `backgroundThrottling` is a Chromium+ * property, so the contract is the same wherever Electron runs.* - `out/main/index.js` missing — `pnpm run build:desktop` must have run.*/@@ -39,13 +40,17 @@ import { dirname, join, resolve } from 'node:path';import { fileURLToPath } from 'node:url';import type { ElectronApplication, JSHandle, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import {+ homeEnv,+ PLATFORM_SKIP_REASON,+ PLATFORM_SUPPORTED,+ SMOKE_ENABLED,+} from './_helpers/platform-gate';import { expect, test } from './_helpers/smoke-test';const __dirname = dirname(fileURLToPath(import.meta.url));const MAIN_ENTRY = resolve(__dirname, '..', '..', 'out', 'main', 'index.js');-const SMOKE_ENABLED = process.env.OK_DESKTOP_E2E_SMOKE === '1';-const DARWIN = process.platform === 'darwin';const BUILD_EXISTS = existsSync(MAIN_ENTRY);interface SeededHome {@@ -93,7 +98,7 @@ async function launchApp(tmpHome: string): Promise<ElectronApplication> {timeout: 30_000,env: {...process.env,- HOME: tmpHome,+ ...homeEnv(tmpHome),OK_DESKTOP_E2E_SMOKE: '1',},});@@ -179,7 +184,7 @@ async function pushAndExpectThrottling(test.describe('background-throttle smoke', () => {test.skip(!SMOKE_ENABLED, 'Set OK_DESKTOP_E2E_SMOKE=1 to run Electron smoke tests.');- test.skip(!DARWIN, 'Smoke harness is darwin-only in v0.');+ test.skip(!PLATFORM_SUPPORTED, PLATFORM_SKIP_REASON);test.skip(!BUILD_EXISTS,`Main build missing at ${MAIN_ENTRY} — run "pnpm run build:desktop" first.`,diff --git a/packages/desktop/tests/smoke/consent-dialog.e2e.ts b/packages/desktop/tests/smoke/consent-dialog.e2e.tsindex 7973c37c4..1a2003e2f 100644--- a/packages/desktop/tests/smoke/consent-dialog.e2e.ts+++ b/packages/desktop/tests/smoke/consent-dialog.e2e.ts@@ -18,7 +18,10 @@* so the seam can never fire in production.** Skip gates mirror `navigator-return.e2e.ts` — opt-in via- * `OK_DESKTOP_E2E_SMOKE=1`, darwin-only, and build-must-exist.+ * `OK_DESKTOP_E2E_SMOKE=1`, a supported host platform, and build-must-exist.+ * Nothing here is macOS-specific: the flow is renderer clicks plus+ * main-process filesystem state, and the folder picker is replaced by the+ * env-var seam on every OS.*/import { execSync } from 'node:child_process';@@ -39,13 +42,16 @@ import { reapDetachedServers } from './_helpers/electron-cleanup';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import { seedMcpConsentComplete } from './_helpers/mcp-consent';import { clickNavOpen } from './_helpers/navigator-actions';+import {+ homeEnv,+ PLATFORM_SKIP_REASON,+ PLATFORM_SUPPORTED,+ SMOKE_ENABLED,+} from './_helpers/platform-gate';import { expect, test } from './_helpers/smoke-test';const TARGET = resolveDesktopTarget();-const SMOKE_ENABLED = process.env.OK_DESKTOP_E2E_SMOKE === '1';-const DARWIN = process.platform === 'darwin';-const DESKTOP_PRODUCT_NAME = '@inkeep/open-knowledge-desktop';function seedTmpHome(prefix: string): string {@@ -115,7 +121,7 @@ async function launchApp(tmpHome: string, opts: LaunchOpts = {}): Promise<Electrargs: [`--user-data-dir=${userDataDir}`],env: {...process.env,- HOME: tmpHome,+ ...homeEnv(tmpHome),OK_DESKTOP_E2E_SMOKE: '1',...(opts.pickedPath !== undefined ? { OK_DESKTOP_TEST_PICKED_PATH: opts.pickedPath } : {}),},@@ -180,7 +186,7 @@ function trackForCleanup(...paths: string[]): void {test.describe('Consent-dialog smoke', () => {test.skip(!SMOKE_ENABLED, 'Set OK_DESKTOP_E2E_SMOKE=1 to run Electron smoke tests.');- test.skip(!DARWIN, 'Smoke harness is darwin-only.');+ test.skip(!PLATFORM_SUPPORTED, PLATFORM_SKIP_REASON);test.skip(!TARGET.exists, TARGET.missingReason);test.afterEach(async () => {diff --git a/packages/desktop/tests/smoke/qa-create-new-extended.e2e.ts b/packages/desktop/tests/smoke/qa-create-new-extended.e2e.tsindex 35f3feb4c..b73230b46 100644--- a/packages/desktop/tests/smoke/qa-create-new-extended.e2e.ts+++ b/packages/desktop/tests/smoke/qa-create-new-extended.e2e.ts@@ -16,6 +16,10 @@* basename is supplied by typing into the Name <Input>. Tests set* `OK_DESKTOP_TEST_PICKED_PATH = parent` and use the `typeProjectName`* helper to fill the name.+ *+ * Skip gates match its 3-test sibling — opt-in via `OK_DESKTOP_E2E_SMOKE=1`,+ * a supported host platform, and build-must-exist. The picker is replaced by+ * the env-var seam on every OS, so nothing here is macOS-specific.*/import { execSync } from 'node:child_process';@@ -36,12 +40,16 @@ import { typeProjectName } from './_helpers/create-new-dialog';import { captureAppProcess, closeAppBounded } from './_helpers/electron-cleanup';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import { clickNavCreateNew } from './_helpers/navigator-actions';+import {+ homeEnv,+ PLATFORM_SKIP_REASON,+ PLATFORM_SUPPORTED,+ SMOKE_ENABLED,+} from './_helpers/platform-gate';import { expect, test } from './_helpers/smoke-test';const TARGET = resolveDesktopTarget();-const SMOKE_ENABLED = process.env.OK_DESKTOP_E2E_SMOKE === '1';-const DARWIN = process.platform === 'darwin';const DESKTOP_PRODUCT_NAME = '@inkeep/open-knowledge-desktop';/**@@ -91,7 +99,7 @@ async function launchApp(tmpHome: string, opts: LaunchOpts = {}): Promise<Electrtimeout: 30_000,env: {...process.env,- HOME: tmpHome,+ ...homeEnv(tmpHome),OK_DESKTOP_E2E_SMOKE: '1',...(opts.pickedParent !== undefined? { OK_DESKTOP_TEST_PICKED_PATH: opts.pickedParent }@@ -146,7 +154,7 @@ function trackForCleanup(...paths: string[]): void {test.describe('QA extended create-new-project', () => {test.skip(!SMOKE_ENABLED, 'Set OK_DESKTOP_E2E_SMOKE=1 to run.');- test.skip(!DARWIN, 'Darwin-only.');+ test.skip(!PLATFORM_SUPPORTED, PLATFORM_SKIP_REASON);test.skip(!TARGET.exists, TARGET.missingReason);test.afterEach(async () => {diff --git a/packages/desktop/tests/smoke/rename-divergence-probe.e2e.ts b/packages/desktop/tests/smoke/rename-divergence-probe.e2e.tsindex ccf07ec43..f2c6f61ae 100644--- a/packages/desktop/tests/smoke/rename-divergence-probe.e2e.ts+++ b/packages/desktop/tests/smoke/rename-divergence-probe.e2e.ts@@ -23,8 +23,11 @@* sign needed — any Electron wrapper of the production build exercises* the same reconnect path).*- * Skip conditions mirror the existing smoke tests (smoke-gated,- * darwin-only, build-must-exist).+ * Skip conditions mirror the existing smoke tests (smoke-gated, supported+ * host platform, build-must-exist). The deep link is delivered through+ * `electron.launch`'s argv, which `src/main/url-scheme.ts` scans+ * synchronously on every OS — no `open(1)` and no Apple Event involved, so+ * this driver is not macOS-bound.*/import { randomUUID } from 'node:crypto';@@ -34,11 +37,10 @@ import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';import { type ElectronApplication, _electron as electron } from '@playwright/test';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';+import { PLATFORM_SKIP_REASON, PLATFORM_SUPPORTED, SMOKE_ENABLED } from './_helpers/platform-gate';import { expect, test } from './_helpers/smoke-test';const TARGET = resolveDesktopTarget();-const SMOKE_ENABLED = process.env.OK_DESKTOP_E2E_SMOKE === '1';-const DARWIN = process.platform === 'darwin';const MARKER_PREFIX = 'rename-divergence-PROBE';// Bounded budget to poll the destination server Y.Doc for body rehydration.@@ -67,7 +69,7 @@ async function runProbe(captureStderrFor: (app: ElectronApplication) => void,): Promise<ProbeOutcome> {test.skip(!SMOKE_ENABLED, 'Set OK_DESKTOP_E2E_SMOKE=1 to run Electron smoke tests.');- test.skip(!DARWIN, 'Driver uses macOS open(1).');+ test.skip(!PLATFORM_SUPPORTED, PLATFORM_SKIP_REASON);test.skip(!TARGET.exists, TARGET.missingReason);// Fresh isolated everything@@ -87,9 +89,8 @@ async function runProbe()}&doc=${encodeURIComponent(sourceDocName)}`;// Deliver deep-link via argv at cold launch (Playwright _electron.launch- // doesn't fire open-url Apple Event, but main process parses argv URLs- // for first-instance — confirmed by the packaged .app working earlier- // with the same args shape).+ // doesn't fire the macOS open-url Apple Event, but the main process parses+ // argv URLs for first-instance on every platform).const app = await electron.launch(desktopLaunchOptions({target: TARGET,diff --git a/packages/desktop/tests/smoke/report-bug.e2e.ts b/packages/desktop/tests/smoke/report-bug.e2e.tsindex 57b32dc4e..1065cd84f 100644--- a/packages/desktop/tests/smoke/report-bug.e2e.ts+++ b/packages/desktop/tests/smoke/report-bug.e2e.ts@@ -1,6 +1,6 @@/*** Report-a-bug entry-point smoke — drives the real Electron build through- * both entry points (Help menu, ⌘K command palette) into the shared+ * both entry points (Help menu, ⌘K / Ctrl+K command palette) into the shared* ReportBugDialog, then through compose → create → review against the real* main-process bundling pipeline.*@@ -12,17 +12,19 @@* zip on disk under the test-isolated `~/.ok/bug-reports/`.** The Help-menu drive calls `MenuItem.click()` programmatically via- * `app.evaluate` — Playwright cannot click native macOS menu chrome. The- * programmatic click fires the exact handler wired in `menu.ts`, so- * everything from the click handler down is the production path; only the- * OS-level mouse event on the native menu bar is simulated.+ * `app.evaluate` — the menu bar is native chrome on every OS, outside any+ * page Playwright can drive. The programmatic click fires the exact handler+ * wired in `menu.ts`, so everything from the click handler down is the+ * production path; only the OS-level mouse event on the menu bar is+ * simulated. The lookup walks every submenu rather than assuming a+ * placement, so the per-platform template shape does not matter.** Send and Reveal stay unexercised here by design: Send needs the intake* endpoint (ships separately; absent here), and Reveal opens a real Finder* window on the host running the suite.** Skip gates mirror consent-dialog.e2e.ts — opt-in via OK_DESKTOP_E2E_SMOKE=1,- * darwin-only, and build-must-exist.+ * a supported host platform, and build-must-exist.*/import {@@ -38,16 +40,19 @@ import { join } from 'node:path';import type { Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';+import {+ homeEnv,+ PLATFORM_SKIP_REASON,+ PLATFORM_SUPPORTED,+ SMOKE_ENABLED,+} from './_helpers/platform-gate';import { expect, test } from './_helpers/smoke-test';const TARGET = resolveDesktopTarget();-const SMOKE_ENABLED = process.env.OK_DESKTOP_E2E_SMOKE === '1';-const DARWIN = process.platform === 'darwin';-test.describe('Report-a-bug entry points', () => {test.skip(!SMOKE_ENABLED, 'Set OK_DESKTOP_E2E_SMOKE=1 to run Electron smoke tests.');- test.skip(!DARWIN, 'Smoke harness is darwin-only.');+ test.skip(!PLATFORM_SUPPORTED, PLATFORM_SKIP_REASON);test.skip(!TARGET.exists, TARGET.missingReason);test('Help menu and palette open the dialog; create lands a zip shown in review', async ({@@ -88,7 +93,7 @@ test.describe('Report-a-bug entry points', () => {timeout: 30_000,env: {...process.env,- HOME: tmpHome,+ ...homeEnv(tmpHome),OK_DESKTOP_E2E_SMOKE: '1',},}),@@ -134,8 +139,10 @@ test.describe('Report-a-bug entry points', () => {await page.keyboard.press('Escape');await expect(composeDialog).not.toBeVisible();- // Entry point 2 — ⌘K palette → "Report a bug" command.- await page.keyboard.press('Meta+k');+ // Entry point 2 — palette → "Report a bug" command. The app registers the+ // opener as a `mod` chord (⌘K on mac, Ctrl+K elsewhere), so the chord this+ // presses has to resolve per-platform the same way.+ await page.keyboard.press('ControlOrMeta+k');const paletteRow = page.getByTestId('command-palette-report-bug');await expect(paletteRow).toBeVisible({ timeout: 10_000 });await paletteRow.click();diff --git a/packages/desktop/tests/unit/electron-cleanup-bounded.test.ts b/packages/desktop/tests/unit/electron-cleanup-bounded.test.tsindex 94ed2346d..65e22fbed 100644--- a/packages/desktop/tests/unit/electron-cleanup-bounded.test.ts+++ b/packages/desktop/tests/unit/electron-cleanup-bounded.test.ts@@ -141,6 +141,7 @@ describe('closeAppBounded — bounded-time process-group reap', () => {await closeAppBounded(proc as unknown as ChildProcess, {gracefulMs: 5_000,kill,+ platform: 'linux',});const elapsed = Date.now() - start;@@ -158,6 +159,7 @@ describe('closeAppBounded — bounded-time process-group reap', () => {await closeAppBounded(proc as unknown as ChildProcess, {gracefulMs: 200,kill,+ platform: 'linux',});const elapsed = Date.now() - start;@@ -178,6 +180,71 @@ describe('closeAppBounded — bounded-time process-group reap', () => {expect(firstKill?.signal).toBe('SIGKILL');});+ test('hung process on win32 → tree-kills via taskkill, never the negated PID', async () => {+ // Windows has no process groups, and Node throws on a negative pid+ // there. Routing the win32 force-kill through `process.kill(-pid)`+ // is a silent no-op: the app survives, keeps the Chromium userData+ // singleton, and the next launch in the same spec never gets a+ // window. The positive, unsignalled pid is the whole contract.+ const proc = makeProc(23456);+ // Don't schedule any exit — process hangs forever.+ const kill = mockKill(proc);+ const taskkillPids: number[] = [];++ await closeAppBounded(proc as unknown as ChildProcess, {+ gracefulMs: 200,+ kill,+ taskkill: (pid) => taskkillPids.push(pid),+ platform: 'win32',+ });++ expect(taskkillPids).toEqual([23456]);+ expect(proc.killCalls).toEqual([]);+ });++ test('win32 → does not resolve until the tree is actually reaped', async () => {+ // taskkill returns before Windows has reaped the tree. Resolving on that+ // return leaves Chromium's `SingletonLock` open, and a relaunch against+ // the same userData inside the window loses the singleton rendezvous —+ // observed as an ECONNRESET mid-CDP-attach in the multi-launch spec.+ const proc = makeProc(23458);+ let resolved = false;++ const pending = closeAppBounded(proc as unknown as ChildProcess, {+ gracefulMs: 1_000,+ taskkill: () => {+ // Reap 150ms after the kill request, as the OS would.+ setTimeout(() => proc.fireExit(0), 150);+ },+ platform: 'win32',+ }).then(() => {+ resolved = true;+ });++ await new Promise((r) => setTimeout(r, 50));+ expect(resolved).toBe(false); // still waiting on the reap++ await pending;+ expect(resolved).toBe(true);+ expect(proc.exitCode).toBe(0);+ });++ test('graceful exit on win32 → no taskkill (idempotency holds on both branches)', async () => {+ const proc = makeProc(23457);+ scheduleExitIn(proc, 50);+ const taskkillPids: number[] = [];++ await closeAppBounded(proc as unknown as ChildProcess, {+ gracefulMs: 5_000,+ kill: mockKill(proc),+ taskkill: (pid) => taskkillPids.push(pid),+ platform: 'win32',+ });++ expect(taskkillPids).toEqual([]);+ expect(proc.exitCode).toBe(0);+ });+test('already-exited process → no kill (idempotent on dead)', async () => {const proc = makeProc(11111);proc.exitCode = 0;@@ -186,6 +253,7 @@ describe('closeAppBounded — bounded-time process-group reap', () => {await closeAppBounded(proc as unknown as ChildProcess, {gracefulMs: 5_000,kill,+ platform: 'linux',});expect(proc.killCalls).toEqual([]);@@ -199,6 +267,7 @@ describe('closeAppBounded — bounded-time process-group reap', () => {await closeAppBounded(proc as unknown as ChildProcess, {gracefulMs: 5_000,kill,+ platform: 'linux',});expect(proc.killCalls).toEqual([]);@@ -216,6 +285,7 @@ describe('closeAppBounded — bounded-time process-group reap', () => {await closeAppBounded(proc as unknown as ChildProcess, {gracefulMs: 5_000,kill,+ platform: 'linux',});expect(proc.killCalls).toEqual([]);@@ -233,6 +303,7 @@ describe('closeAppBounded — bounded-time process-group reap', () => {await closeAppBounded(proc as unknown as ChildProcess, {gracefulMs: 100,kill,+ platform: 'linux',});const elapsed = Date.now() - start;@@ -268,6 +339,7 @@ describe('closeAppBounded — bounded-time process-group reap', () => {await closeAppBounded(proc as unknown as ChildProcess, {gracefulMs: 100,kill: throwingKill,+ platform: 'linux',});// Proves the catch path was actually exercised. Without this, a future@@ -285,6 +357,7 @@ describe('closeAppBounded — bounded-time process-group reap', () => {await closeAppBounded(proc as unknown as ChildProcess, {gracefulMs: 100,kill,+ platform: 'linux',});const killCountAfterFirst = proc.killCalls.length;expect(killCountAfterFirst).toBe(1); // first call killed@@ -293,6 +366,7 @@ describe('closeAppBounded — bounded-time process-group reap', () => {await closeAppBounded(proc as unknown as ChildProcess, {gracefulMs: 100,kill,+ platform: 'linux',});expect(proc.killCalls.length).toBe(killCountAfterFirst);@@ -343,6 +417,7 @@ describe('closeAppBounded — bounded-time process-group reap', () => {await closeAppBounded(proc as unknown as ChildProcess, {gracefulMs: 5_000,kill,+ platform: 'linux',});expect(proc.exitCode).toBe(0);