Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Align smoke boot-log capture with the launched home (#6178)
Nick Gomeze56036f4b720
diff --git a/packages/desktop/tests/smoke/_helpers/capture-home.test-helper.ts b/packages/desktop/tests/smoke/_helpers/capture-home.test-helper.tsnew file mode 100644index 000000000..dd764953e--- /dev/null+++ b/packages/desktop/tests/smoke/_helpers/capture-home.test-helper.ts@@ -0,0 +1,49 @@+import { realpathSync } from 'node:fs';+import { type ElectronApplication, expect, test } from '@playwright/test';+import { readBootLog, tryLaunchHomeFor } from './launch-readiness';++export async function expectCaptureHomeMatchesProcess(app: ElectronApplication): Promise<void> {+ await test.step('capture home matches the Electron process home', async () => {+ const observed = await app.evaluate(() => ({+ home: process.getBuiltinModule('node:os').homedir(),+ pid: process.pid,+ HOME: process.env.HOME,+ USERPROFILE: process.env.USERPROFILE,+ }));+ const registeredHome = tryLaunchHomeFor(app);+ const actualLog = readBootLog(observed.home);+ const registeredLog = registeredHome === undefined ? undefined : readBootLog(registeredHome);+ await test.info().attach('capture-home-observation', {+ contentType: 'application/json',+ body: JSON.stringify(+ {+ observed,+ registeredHome,+ actualLog: {+ dir: actualLog.dir,+ fileCount: actualLog.fileCount,+ lineCount: actualLog.lineCount,+ unreadableFiles: actualLog.unreadableFiles,+ tail: actualLog.tail,+ },+ registeredLog:+ registeredLog === undefined+ ? null+ : {+ dir: registeredLog.dir,+ fileCount: registeredLog.fileCount,+ lineCount: registeredLog.lineCount,+ unreadableFiles: registeredLog.unreadableFiles,+ tail: registeredLog.tail,+ },+ },+ null,+ 2,+ ),+ });+ expect(+ registeredHome === undefined ? undefined : realpathSync(registeredHome),+ 'diagnostic capture must read the home used by this Electron process',+ ).toBe(realpathSync(observed.home));+ });+}diff --git a/packages/desktop/tests/smoke/_helpers/launch-in-home.ts b/packages/desktop/tests/smoke/_helpers/launch-in-home.tsnew file mode 100644index 000000000..7fbd3895e--- /dev/null+++ b/packages/desktop/tests/smoke/_helpers/launch-in-home.ts@@ -0,0 +1,16 @@+import { type ElectronApplication, _electron as electron } from '@playwright/test';+import { launchDesktopApp } from './launch-readiness';+import { homeEnv } from './platform-gate';++type ElectronLaunchOptions = NonNullable<Parameters<typeof electron.launch>[0]>;++export function launchDesktopInHome(+ home: string,+ launchOptions: ElectronLaunchOptions,+): Promise<ElectronApplication> {+ return launchDesktopApp(+ electron,+ { ...launchOptions, env: Object.assign({}, process.env, launchOptions.env, homeEnv(home)) },+ { home },+ );+}diff --git a/packages/desktop/tests/smoke/deep-link.e2e.ts b/packages/desktop/tests/smoke/deep-link.e2e.tsindex f428db808..8ab62d873 100644--- a/packages/desktop/tests/smoke/deep-link.e2e.ts+++ b/packages/desktop/tests/smoke/deep-link.e2e.ts@@ -2,9 +2,11 @@ import { execSync } from 'node:child_process';import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';-import { _electron as electron, type Page } from '@playwright/test';+import type { Page } from '@playwright/test';import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';+import { expectCaptureHomeMatchesProcess } from './_helpers/capture-home.test-helper';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';+import { launchDesktopInHome } from './_helpers/launch-in-home';import { expect, test } from './_helpers/smoke-test';const TARGET = resolveDesktopTarget();@@ -33,14 +35,16 @@ test.describe('deep-link warm-start smoke (M4 US-009 / AC7)', () => {);writeFileSync(join(projectDir, 'target.md'), '# Target Doc\n\nDeep-link smoke content.\n');- const app = await electron.launch(+ const app = await launchDesktopInHome(+ tmpHome,desktopLaunchOptions({target: TARGET,args: [`--user-data-dir=${userDataDirFor(tmpHome)}`],timeout: 30_000,}),);- captureStderrFor(app, { home: tmpHome, cleanupDirs: [projectDir, tmpHome] });+ captureStderrFor(app, { cleanupDirs: [projectDir, tmpHome] });+ await expectCaptureHomeMatchesProcess(app);const firstWindow = await app.firstWindow({ timeout: 15_000 });expect(firstWindow).toBeDefined();@@ -79,14 +83,16 @@ test.describe('deep-link warm-start smoke (M4 US-009 / AC7)', () => {'# Meeting Notes\n\nNested doc smoke.\n',);- const app = await electron.launch(+ const app = await launchDesktopInHome(+ tmpHome,desktopLaunchOptions({target: TARGET,args: [`--user-data-dir=${userDataDirFor(tmpHome)}`],timeout: 30_000,}),);- captureStderrFor(app, { home: tmpHome, cleanupDirs: [projectDir, tmpHome] });+ captureStderrFor(app, { cleanupDirs: [projectDir, tmpHome] });+ await expectCaptureHomeMatchesProcess(app);const firstWindow = await app.firstWindow({ timeout: 15_000 });expect(firstWindow).toBeDefined();diff --git a/packages/desktop/tests/smoke/okf-rule-toggle.e2e.ts b/packages/desktop/tests/smoke/okf-rule-toggle.e2e.tsindex 5a671e9d4..9f99d256e 100644--- a/packages/desktop/tests/smoke/okf-rule-toggle.e2e.ts+++ b/packages/desktop/tests/smoke/okf-rule-toggle.e2e.ts@@ -2,8 +2,9 @@ import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } fromimport { tmpdir } from 'node:os';import { dirname, join, resolve } from 'node:path';import { fileURLToPath } from 'node:url';-import { _electron as electron } from '@playwright/test';import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';+import { expectCaptureHomeMatchesProcess } from './_helpers/capture-home.test-helper';+import { launchDesktopInHome } from './_helpers/launch-in-home';import { expect, test } from './_helpers/smoke-test';const __dirname = dirname(fileURLToPath(import.meta.url));@@ -38,11 +39,12 @@ test.describe('okf per-rule toggle round-trip', () => {mkdirSync(userDataDir, { recursive: true });const deepLink = `openknowledge://open?project=${encodeURIComponent(projectDir)}&doc=note`;- const app = await electron.launch({+ const app = await launchDesktopInHome(tmpHome, {args: [MAIN_ENTRY, deepLink, `--user-data-dir=${userDataDir}`],timeout: 30_000,});- captureStderrFor(app, { home: tmpHome, cleanupDirs: [projectDir, tmpHome] });+ captureStderrFor(app, { cleanupDirs: [projectDir, tmpHome] });+ await expectCaptureHomeMatchesProcess(app);await app.firstWindow({ timeout: 15_000 });const settingsPage = await (async () => {diff --git a/packages/desktop/tests/smoke/share-receive-miss-terminal.e2e.ts b/packages/desktop/tests/smoke/share-receive-miss-terminal.e2e.tsindex f2002dc3b..2b32db27b 100644--- a/packages/desktop/tests/smoke/share-receive-miss-terminal.e2e.ts+++ b/packages/desktop/tests/smoke/share-receive-miss-terminal.e2e.ts@@ -3,9 +3,10 @@ import { randomUUID } from 'node:crypto';import { mkdirSync, mkdtempSync, readFileSync, realpathSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { basename, dirname, join } from 'node:path';-import { _electron as electron } from '@playwright/test';import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';+import { expectCaptureHomeMatchesProcess } from './_helpers/capture-home.test-helper';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';+import { launchDesktopInHome } from './_helpers/launch-in-home';import { PLATFORM_SKIP_REASON, PLATFORM_SUPPORTED } from './_helpers/platform-gate';import { expect, type SmokeFixtures, test } from './_helpers/smoke-test';@@ -164,14 +165,16 @@ async function expectDeletedTargetMiss(}),);- const app = await electron.launch(+ const app = await launchDesktopInHome(+ tmpHome,desktopLaunchOptions({target: TARGET,args: [`--user-data-dir=${userData}`, shareUrl],timeout: 30_000,}),);- captureStderrFor(app, { home: tmpHome, cleanupDirs: [fixture.root, tmpHome] });+ captureStderrFor(app, { cleanupDirs: [fixture.root, tmpHome] });+ await expectCaptureHomeMatchesProcess(app);const firstWindow = await app.firstWindow({ timeout: 15_000 });expect(firstWindow).toBeDefined();@@ -256,14 +259,16 @@ test.describe('share-receive miss terminal smoke', () => {JSON.stringify({ recentProjects: [], projectSessions: {} }),);- const app = await electron.launch(+ const app = await launchDesktopInHome(+ tmpHome,desktopLaunchOptions({target: TARGET,args: [`--user-data-dir=${userData}`, MAX_V2_CUSTOM_URI],timeout: 30_000,}),);- captureStderrFor(app, { home: tmpHome, cleanupDirs: [tmpHome] });+ captureStderrFor(app, { cleanupDirs: [tmpHome] });+ await expectCaptureHomeMatchesProcess(app);await app.firstWindow({ timeout: 15_000 });let dialogText = '';diff --git a/packages/desktop/tests/smoke/share-receive-multi-worktree.e2e.ts b/packages/desktop/tests/smoke/share-receive-multi-worktree.e2e.tsindex 4f429a654..6aed94dd7 100644--- a/packages/desktop/tests/smoke/share-receive-multi-worktree.e2e.ts+++ b/packages/desktop/tests/smoke/share-receive-multi-worktree.e2e.ts@@ -2,9 +2,10 @@ import { execSync } from 'node:child_process';import { mkdirSync, mkdtempSync, realpathSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';-import { _electron as electron } from '@playwright/test';import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';+import { expectCaptureHomeMatchesProcess } from './_helpers/capture-home.test-helper';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';+import { launchDesktopInHome } from './_helpers/launch-in-home';import { expect, test } from './_helpers/smoke-test';const TARGET = resolveDesktopTarget();@@ -105,7 +106,8 @@ test.describe('share-receive multi-worktree smoke (US-014 / J1 silent dispatch)'};writeFileSync(join(userData, 'Electron', 'state.json'), JSON.stringify(recentsState, null, 2));- const app = await electron.launch(+ const app = await launchDesktopInHome(+ tmpHome,desktopLaunchOptions({target: TARGET,args: [`--user-data-dir=${userData}`],@@ -113,9 +115,9 @@ test.describe('share-receive multi-worktree smoke (US-014 / J1 silent dispatch)'}),);captureStderrFor(app, {- home: tmpHome,cleanupDirs: [fixture.root, tmpHome],});+ await expectCaptureHomeMatchesProcess(app);const firstWindow = await app.firstWindow({ timeout: 15_000 });expect(firstWindow).toBeDefined();diff --git a/packages/desktop/tests/smoke/uninstall-ipc-bridge.e2e.ts b/packages/desktop/tests/smoke/uninstall-ipc-bridge.e2e.tsindex 671fb458a..a97069c4b 100644--- a/packages/desktop/tests/smoke/uninstall-ipc-bridge.e2e.ts+++ b/packages/desktop/tests/smoke/uninstall-ipc-bridge.e2e.ts@@ -1,8 +1,10 @@import { mkdtempSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';-import { _electron as electron, type Page } from '@playwright/test';+import type { Page } from '@playwright/test';+import { expectCaptureHomeMatchesProcess } from './_helpers/capture-home.test-helper';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';+import { launchDesktopInHome } from './_helpers/launch-in-home';import { expect, test } from './_helpers/smoke-test';const TARGET = resolveDesktopTarget();@@ -39,7 +41,8 @@ test.describe('uninstall renderer IPC bridge smoke', () => {test('carries main’s screen down and the user’s intent back up', async ({ captureStderrFor }) => {const home = mkdtempSync(join(tmpdir(), 'ok-uninstall-ipc-'));- const app = await electron.launch(+ const app = await launchDesktopInHome(+ home,desktopLaunchOptions({target: TARGET,args: [`--user-data-dir=${join(home, 'electron-userdata')}`],@@ -47,7 +50,8 @@ test.describe('uninstall renderer IPC bridge smoke', () => {timeout: 30_000,}),);- captureStderrFor(app, { home, cleanupDirs: [home] });+ captureStderrFor(app, { cleanupDirs: [home] });+ await expectCaptureHomeMatchesProcess(app);await app.firstWindow({ timeout: 20_000 });const editorWindow = await findWindowByPath(app, '/index.html');diff --git a/packages/desktop/tests/smoke/uninstall-notice.e2e.ts b/packages/desktop/tests/smoke/uninstall-notice.e2e.tsindex 0a3208251..e18566cb3 100644--- a/packages/desktop/tests/smoke/uninstall-notice.e2e.ts+++ b/packages/desktop/tests/smoke/uninstall-notice.e2e.ts@@ -1,8 +1,10 @@import { mkdtempSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';-import { _electron as electron, type Page } from '@playwright/test';+import type { Page } from '@playwright/test';+import { expectCaptureHomeMatchesProcess } from './_helpers/capture-home.test-helper';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';+import { launchDesktopInHome } from './_helpers/launch-in-home';import { expect, test } from './_helpers/smoke-test';const TARGET = resolveDesktopTarget();@@ -43,7 +45,8 @@ async function launchNoticePreview(prefix: string,): Promise<{ app: import('@playwright/test').ElectronApplication; home: string }> {const home = mkdtempSync(join(tmpdir(), prefix));- const app = await electron.launch(+ const app = await launchDesktopInHome(+ home,desktopLaunchOptions({target: TARGET,args: [`--user-data-dir=${join(home, 'electron-userdata')}`],@@ -61,7 +64,8 @@ test.describe('uninstall notice smoke', () => {test('pressing each notice through carries the answer to main', async ({ captureStderrFor }) => {const { app, home } = await launchNoticePreview('ok-uninstall-notice-');- captureStderrFor(app, { home, cleanupDirs: [home] });+ captureStderrFor(app, { cleanupDirs: [home] });+ await expectCaptureHomeMatchesProcess(app);await app.firstWindow({ timeout: 20_000 });@@ -88,7 +92,8 @@ test.describe('uninstall notice smoke', () => {captureStderrFor,}) => {const { app, home } = await launchNoticePreview('ok-uninstall-notice-close-');- captureStderrFor(app, { home, cleanupDirs: [home] });+ captureStderrFor(app, { cleanupDirs: [home] });+ await expectCaptureHomeMatchesProcess(app);await app.firstWindow({ timeout: 20_000 });diff --git a/packages/desktop/tests/smoke/uninstall-picker.e2e.ts b/packages/desktop/tests/smoke/uninstall-picker.e2e.tsindex 215c3605a..91e3b83b4 100644--- a/packages/desktop/tests/smoke/uninstall-picker.e2e.ts+++ b/packages/desktop/tests/smoke/uninstall-picker.e2e.ts@@ -1,8 +1,10 @@import { mkdtempSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';-import { _electron as electron, type Page } from '@playwright/test';+import type { Page } from '@playwright/test';+import { expectCaptureHomeMatchesProcess } from './_helpers/capture-home.test-helper';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';+import { launchDesktopInHome } from './_helpers/launch-in-home';import { expect, test } from './_helpers/smoke-test';const TARGET = resolveDesktopTarget();@@ -41,7 +43,8 @@ test.describe('uninstall project picker smoke', () => {}) => {const home = mkdtempSync(join(tmpdir(), 'ok-uninstall-picker-'));- const app = await electron.launch(+ const app = await launchDesktopInHome(+ home,desktopLaunchOptions({target: TARGET,args: [`--user-data-dir=${join(home, 'electron-userdata')}`],@@ -49,7 +52,8 @@ test.describe('uninstall project picker smoke', () => {timeout: 30_000,}),);- captureStderrFor(app, { home, cleanupDirs: [home] });+ captureStderrFor(app, { cleanupDirs: [home] });+ await expectCaptureHomeMatchesProcess(app);await app.firstWindow({ timeout: 20_000 });const picker = await findWindowByPath(app, '/uninstall.html');@@ -90,7 +94,8 @@ test.describe('uninstall project picker smoke', () => {test('closing the picker window cancels rather than proceeding', async ({ captureStderrFor }) => {const home = mkdtempSync(join(tmpdir(), 'ok-uninstall-picker-close-'));- const app = await electron.launch(+ const app = await launchDesktopInHome(+ home,desktopLaunchOptions({target: TARGET,args: [`--user-data-dir=${join(home, 'electron-userdata')}`],@@ -98,7 +103,8 @@ test.describe('uninstall project picker smoke', () => {timeout: 30_000,}),);- captureStderrFor(app, { home, cleanupDirs: [home] });+ captureStderrFor(app, { cleanupDirs: [home] });+ await expectCaptureHomeMatchesProcess(app);await app.firstWindow({ timeout: 20_000 });const picker = await findWindowByPath(app, '/uninstall.html');diff --git a/packages/desktop/tests/smoke/uninstall-survey.e2e.ts b/packages/desktop/tests/smoke/uninstall-survey.e2e.tsindex e0dfaea80..a164f202e 100644--- a/packages/desktop/tests/smoke/uninstall-survey.e2e.ts+++ b/packages/desktop/tests/smoke/uninstall-survey.e2e.ts@@ -1,8 +1,10 @@import { mkdtempSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';-import { _electron as electron, type Page } from '@playwright/test';+import type { Page } from '@playwright/test';+import { expectCaptureHomeMatchesProcess } from './_helpers/capture-home.test-helper';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';+import { launchDesktopInHome } from './_helpers/launch-in-home';import { expect, test } from './_helpers/smoke-test';const TARGET = resolveDesktopTarget();@@ -33,7 +35,8 @@ async function launchSurveyPreview(prefix: string,): Promise<{ app: import('@playwright/test').ElectronApplication; home: string }> {const home = mkdtempSync(join(tmpdir(), prefix));- const app = await electron.launch(+ const app = await launchDesktopInHome(+ home,desktopLaunchOptions({target: TARGET,args: [`--user-data-dir=${join(home, 'electron-userdata')}`],@@ -51,7 +54,8 @@ test.describe('uninstall churn survey smoke', () => {test('carries a filled-in survey back to main as answers', async ({ captureStderrFor }) => {const { app, home } = await launchSurveyPreview('ok-uninstall-survey-');- captureStderrFor(app, { home, cleanupDirs: [home] });+ captureStderrFor(app, { cleanupDirs: [home] });+ await expectCaptureHomeMatchesProcess(app);await app.firstWindow({ timeout: 20_000 });const survey = await findWindowByPath(app, '/uninstall.html');@@ -85,7 +89,8 @@ test.describe('uninstall churn survey smoke', () => {captureStderrFor,}) => {const { app, home } = await launchSurveyPreview('ok-uninstall-survey-close-');- captureStderrFor(app, { home, cleanupDirs: [home] });+ captureStderrFor(app, { cleanupDirs: [home] });+ await expectCaptureHomeMatchesProcess(app);await app.firstWindow({ timeout: 20_000 });const survey = await findWindowByPath(app, '/uninstall.html');@@ -103,7 +108,8 @@ test.describe('uninstall churn survey smoke', () => {test('skipping continues with nothing filed', async ({ captureStderrFor }) => {const { app, home } = await launchSurveyPreview('ok-uninstall-survey-skip-');- captureStderrFor(app, { home, cleanupDirs: [home] });+ captureStderrFor(app, { cleanupDirs: [home] });+ await expectCaptureHomeMatchesProcess(app);await app.firstWindow({ timeout: 20_000 });const survey = await findWindowByPath(app, '/uninstall.html');diff --git a/packages/desktop/tests/smoke/uninstall-window-chrome.e2e.ts b/packages/desktop/tests/smoke/uninstall-window-chrome.e2e.tsindex 8bf0be638..c6b7a4e9b 100644--- a/packages/desktop/tests/smoke/uninstall-window-chrome.e2e.ts+++ b/packages/desktop/tests/smoke/uninstall-window-chrome.e2e.ts@@ -1,8 +1,10 @@import { mkdtempSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';-import { _electron as electron, type Page } from '@playwright/test';+import type { Page } from '@playwright/test';+import { expectCaptureHomeMatchesProcess } from './_helpers/capture-home.test-helper';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';+import { launchDesktopInHome } from './_helpers/launch-in-home';import { expect, test } from './_helpers/smoke-test';const TARGET = resolveDesktopTarget();@@ -41,7 +43,8 @@ test.describe('uninstall renderer chrome smoke', () => {}) => {const home = mkdtempSync(join(tmpdir(), 'ok-uninstall-chrome-'));- const app = await electron.launch(+ const app = await launchDesktopInHome(+ home,desktopLaunchOptions({target: TARGET,args: [`--user-data-dir=${join(home, 'electron-userdata')}`],@@ -49,7 +52,8 @@ test.describe('uninstall renderer chrome smoke', () => {timeout: 30_000,}),);- captureStderrFor(app, { home, cleanupDirs: [home] });+ captureStderrFor(app, { cleanupDirs: [home] });+ await expectCaptureHomeMatchesProcess(app);await app.firstWindow({ timeout: 20_000 });const editorWindow = await findWindowByPath(app, '/index.html');