Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Log the git preflight dialog wait at desktop startup (PRD-8660) (#6108)
Andrew Mikofalvyc2cedf468e90
diff --git a/.changeset/prd-8660-git-preflight-log.md b/.changeset/prd-8660-git-preflight-log.mdnew file mode 100644index 000000000..4cd2fd2b9--- /dev/null+++ b/.changeset/prd-8660-git-preflight-log.md@@ -0,0 +1,5 @@+---+"@inkeep/open-knowledge-desktop": patch+---++Bug reports now show when desktop startup is waiting on the "Git not found" dialog, and which button was chosen.diff --git a/knip.config.ts b/knip.config.tsindex 69344114d..0004a763a 100644--- a/knip.config.ts+++ b/knip.config.ts@@ -149,11 +149,15 @@ export default {'packages/server': {entry: ['src/**/*.test.ts', 'src/parse-worker.ts'],project: 'src/**',- ignoreDependencies: ['@types/shell-quote'],+ ignoreDependencies: [+ '@types/shell-quote',+ ],},'packages/cli': {entry: ['src/**/*.test.ts', 'scripts/*.ts', 'tests/**/*.ts', 'src/parse-worker.ts'],- ignoreDependencies: ['yjs'],+ ignoreDependencies: [+ 'yjs',+ ],},'packages/desktop': {entry: [diff --git a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts b/packages/app/tests/integration/bug3-source-mode-writeback.test.tsindex a50b00123..4549c74b3 100644--- a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts+++ b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts@@ -1,3 +1,4 @@+import { readFileSync } from 'node:fs';import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';diff --git a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts b/packages/app/tests/integration/indented-jsx-byte-sacred.test.tsindex 6fcdc23f2..4fc2c11f9 100644--- a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts+++ b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts@@ -1,3 +1,4 @@+import { setTimeout as wait } from 'node:timers/promises';import { normalizeBridge } from '@inkeep/open-knowledge-core';import { updateYFragment } from '@tiptap/y-tiptap';diff --git a/packages/app/tests/integration/interior-edit-freshness.test.ts b/packages/app/tests/integration/interior-edit-freshness.test.tsindex 40b5cdfd6..9f2f6feb6 100644--- a/packages/app/tests/integration/interior-edit-freshness.test.ts+++ b/packages/app/tests/integration/interior-edit-freshness.test.ts@@ -1,3 +1,4 @@+import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts b/packages/app/tests/integration/keystroke-cadence-danger-space.test.tsindex 93666af70..2a085742b 100644--- a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts+++ b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts@@ -1,3 +1,4 @@+import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/producer-guard-wiring.test.ts b/packages/app/tests/integration/producer-guard-wiring.test.tsindex 867598d34..878d5196b 100644--- a/packages/app/tests/integration/producer-guard-wiring.test.ts+++ b/packages/app/tests/integration/producer-guard-wiring.test.ts@@ -1,3 +1,4 @@+import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.tsindex 0970ac12f..4ada3cf26 100644--- a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts+++ b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts@@ -1,3 +1,4 @@+import { randomUUID } from 'node:crypto';import { afterEach, describe, expect, test } from 'vitest';import { agentWriteMd, createTestServer, type TestServer } from './test-harness';diff --git a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts b/packages/app/tests/integration/qa-045-restore-after-gc.test.tsindex b632185e1..cbe2b705f 100644--- a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts+++ b/packages/app/tests/integration/qa-045-restore-after-gc.test.ts@@ -1,3 +1,4 @@+import { execFileSync } from 'node:child_process';import { randomUUID } from 'node:crypto';import { join } from 'node:path';diff --git a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.tsindex c530ce4ba..89bc9b4d9 100644--- a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts+++ b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts@@ -1,3 +1,4 @@+import { randomUUID } from 'node:crypto';import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest';import type * as Y from 'yjs';diff --git a/packages/app/tests/integration/undo-after-rollback.test.ts b/packages/app/tests/integration/undo-after-rollback.test.tsindex d3767adc9..a78aeb0e4 100644--- a/packages/app/tests/integration/undo-after-rollback.test.ts+++ b/packages/app/tests/integration/undo-after-rollback.test.ts@@ -1,3 +1,4 @@+import { ROLLBACK_ORIGIN } from '@inkeep/open-knowledge-server';import { afterAll, beforeAll, describe, expect, test } from 'vitest';import * as Y from 'yjs';diff --git a/packages/app/tests/integration/undo-recycle-reset.test.ts b/packages/app/tests/integration/undo-recycle-reset.test.tsindex b076f955c..e7cc69c3f 100644--- a/packages/app/tests/integration/undo-recycle-reset.test.ts+++ b/packages/app/tests/integration/undo-recycle-reset.test.ts@@ -1,3 +1,4 @@+import { writeFileSync } from 'node:fs';import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';diff --git a/packages/app/tests/integration/undo-rederive-survival.test.ts b/packages/app/tests/integration/undo-rederive-survival.test.tsindex 7935e35f8..9ddcd0730 100644--- a/packages/app/tests/integration/undo-rederive-survival.test.ts+++ b/packages/app/tests/integration/undo-rederive-survival.test.ts@@ -1,3 +1,4 @@+import { prependFrontmatter } from '@inkeep/open-knowledge-core';import { Plugin, PluginKey } from '@tiptap/pm/state';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';diff --git a/packages/core/src/bridge/compose.ts b/packages/core/src/bridge/compose.tsindex f4cc8a286..2a597ec3d 100644--- a/packages/core/src/bridge/compose.ts+++ b/packages/core/src/bridge/compose.ts@@ -1,3 +1,4 @@+import { prependFrontmatter, stripFrontmatter } from '../extensions/frontmatter.ts';export type ComposeAdjustment = 'none' | 'body' | 'frontmatter' | 'unresolved';diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.tsindex e7e63f43d..ffd8fce06 100644--- a/packages/core/src/bridge/doc-boundary-space.ts+++ b/packages/core/src/bridge/doc-boundary-space.ts@@ -1,3 +1,4 @@+import { FRONTMATTER_RE, stripFrontmatter } from '../extensions/frontmatter.ts';import { carriedEdgeEmpties, type DocEdgeEmpties } from '../markdown/doc-edge-blank-runs.ts';diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.tsindex fc267cbea..fb0ba5a7c 100644--- a/packages/core/src/markdown/comment-promoter.ts+++ b/packages/core/src/markdown/comment-promoter.ts@@ -1,3 +1,4 @@+import type { Nodes, Paragraph, PhrasingContent, Root, RootContent, Text } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.tsindex bfd7e3109..fa3cfcd86 100644--- a/packages/core/src/markdown/merged-walker.ts+++ b/packages/core/src/markdown/merged-walker.ts@@ -1,3 +1,4 @@+import type { Nodes, Parent, Root } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.tsindex 4d3250d3a..8be632ba4 100644--- a/packages/core/src/markdown/safe-url.ts+++ b/packages/core/src/markdown/safe-url.ts@@ -1,3 +1,4 @@+export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');diff --git a/packages/desktop/src/main/git-preflight-handler.test.ts b/packages/desktop/src/main/git-preflight-handler.test.tsindex 4aa755061..410204646 100644--- a/packages/desktop/src/main/git-preflight-handler.test.ts+++ b/packages/desktop/src/main/git-preflight-handler.test.ts@@ -242,9 +242,10 @@ describe('ensureGitAvailable', () => {expect(boxCalls[1]?.type).toBe('error');expect(boxCalls[1]?.buttons).toEqual(['Quit']);expect(boxCalls[1]?.detail).toContain('git binary crashed unexpectedly');- expect(warn).toHaveBeenCalled();- const warnCall = warn.mock.calls[0];- expect(warnCall?.[0]).toContain('unexpected retry error');+ expect(warn.mock.calls.map(([msg]) => msg)).toEqual([+ expect.stringContaining('waiting on the install dialog'),+ expect.stringContaining('unexpected retry error'),+ ]);});test('openExternal failure surfaces the URL in the next dialog detail', async () => {@@ -328,9 +329,11 @@ describe('ensureGitAvailable', () => {expect(outcome).toBe('recovered');expect(attempts).toBe(2);expect(openExternal).toHaveBeenCalledTimes(1);- expect(warn).toHaveBeenCalled();- const warnCall = warn.mock.calls[0];- expect(warnCall?.[0]).toContain('openExternal failed');+ expect(warn.mock.calls.map(([msg]) => msg)).toEqual([+ expect.stringContaining('waiting on the install dialog'),+ expect.stringContaining('openExternal failed'),+ expect.stringContaining('waiting on the install dialog'),+ ]);});test('out-of-range dialog response is treated as Quit (defensive)', async () => {@@ -349,9 +352,96 @@ describe('ensureGitAvailable', () => {});expect(outcome).toBe('aborted');- expect(warn).toHaveBeenCalled();- const warnCall = warn.mock.calls[0];- expect(warnCall?.[0]).toContain('unexpected dialog response');+ expect(warn.mock.calls.map(([msg]) => msg)).toEqual([+ expect.stringContaining('waiting on the install dialog'),+ expect.stringContaining('unexpected dialog response'),+ ]);+ });++ test('logs the git failure before the install dialog settles, then the answer', async () => {+ const assertGitAvailable = vi.fn(() => {+ throw new GitNotAvailableError('linux', LINUX_GUIDANCE, {+ probe: { path: 'unparseable', fallback: 'enoent' },+ });+ });+ let answer: (value: { response: number }) => void = () => {};+ const showMessageBox = vi.fn(+ () =>+ new Promise<{ response: number }>((resolve) => {+ answer = resolve;+ }),+ );+ const warn = vi.fn((_msg: string, _obj?: unknown) => {});+ const info = vi.fn((_msg: string, _obj?: unknown) => {});++ const pending = ensureGitAvailable({+ assertGitAvailable,+ showMessageBox,+ openExternal: vi.fn(async () => {}),+ log: { warn, info },+ });+ await vi.waitFor(() => expect(showMessageBox).toHaveBeenCalledTimes(1));++ expect(warn).toHaveBeenCalledTimes(1);+ expect(warn).toHaveBeenCalledWith(expect.stringContaining('waiting on the install dialog'), {+ code: 'GIT_NOT_AVAILABLE',+ platform: 'linux',+ pathProbe: 'unparseable',+ fallbackProbe: 'enoent',+ });+ expect(info).not.toHaveBeenCalled();++ answer({ response: 2 });++ await expect(pending).resolves.toBe('aborted');+ expect(info).toHaveBeenCalledWith(expect.stringContaining('install dialog answered'), {+ response: 'quit',+ });+ });++ test('a too-old git logs the detected and required versions', async () => {+ const assertGitAvailable = vi.fn(() => {+ throw new GitTooOldError('darwin', '2.20.0', '2.31.0', '/usr/bin/git', MAC_GUIDANCE);+ });+ const { fn: showMessageBox } = showMessageBoxSequence([2]);+ const warn = vi.fn((_msg: string, _obj?: unknown) => {});++ await ensureGitAvailable({+ assertGitAvailable,+ showMessageBox,+ openExternal: vi.fn(async () => {}),+ log: { warn },+ });++ expect(warn).toHaveBeenCalledWith(expect.stringContaining('waiting on the install dialog'), {+ code: 'GIT_TOO_OLD',+ platform: 'darwin',+ detected: '2.20.0',+ required: '2.31.0',+ resolvedPath: '/usr/bin/git',+ });+ });++ test('a git-missing error without probe detail logs null probe fields', async () => {+ const assertGitAvailable = vi.fn(() => {+ throw new GitNotAvailableError('win32', LINUX_GUIDANCE);+ });+ const { fn: showMessageBox } = showMessageBoxSequence([2]);+ const warn = vi.fn((_msg: string, _obj?: unknown) => {});++ await ensureGitAvailable({+ assertGitAvailable,+ showMessageBox,+ openExternal: vi.fn(async () => {}),+ log: { warn },+ });++ expect(warn).toHaveBeenCalledWith(expect.stringContaining('waiting on the install dialog'), {+ code: 'GIT_NOT_AVAILABLE',+ platform: 'win32',+ pathProbe: null,+ fallbackProbe: null,+ });});test('handler does NOT require a log dep (no-op default)', async () => {diff --git a/packages/desktop/src/main/git-preflight-handler.ts b/packages/desktop/src/main/git-preflight-handler.tsindex 5f439008e..09f78b595 100644--- a/packages/desktop/src/main/git-preflight-handler.ts+++ b/packages/desktop/src/main/git-preflight-handler.ts@@ -26,7 +26,8 @@ export interface EnsureGitDeps {readonly showMessageBox: (opts: MessageBoxOptions) => Promise<MessageBoxReturnValue>;readonly openExternal: (url: string) => Promise<void>;readonly log?: {- readonly warn: (msg: string, obj?: unknown) => void;+ readonly warn: (msg: string, obj?: Readonly<Record<string, unknown>>) => void;+ readonly info?: (msg: string, obj?: Readonly<Record<string, unknown>>) => void;};}@@ -36,6 +37,30 @@ const BUTTON_QUIT = 2;const BUTTON_LABELS = ['Open Install Page', "I've Installed Git — Retry", 'Quit'] as const;+const BUTTON_NAMES: Readonly<Partial<Record<number, string>>> = {+ [BUTTON_OPEN_INSTALL_PAGE]: 'open-install-page',+ [BUTTON_RETRY]: 'retry',+ [BUTTON_QUIT]: 'quit',+};++function preflightFailureFields(err: GitNotAvailableError | GitTooOldError) {+ if (err instanceof GitTooOldError) {+ return {+ code: err.code,+ platform: err.platform,+ detected: err.detected,+ required: err.required,+ resolvedPath: err.resolvedPath,+ };+ }+ return {+ code: err.code,+ platform: err.platform,+ pathProbe: err.probe?.path ?? null,+ fallbackProbe: err.probe?.fallback ?? null,+ };+}+type PreflightAttempt =| { kind: 'ok'; detection: GitDetected }| { kind: 'typed'; err: GitNotAvailableError | GitTooOldError }@@ -94,6 +119,10 @@ export async function ensureGitAvailable(deps: EnsureGitDeps): Promise<EnsureGitfailedInstallUrl === null? currentErr.message: `${currentErr.message}\n\nCould not open browser automatically. Please visit: ${failedInstallUrl}`;+ deps.log?.warn(+ 'ensureGitAvailable: git unavailable, startup is waiting on the install dialog',+ preflightFailureFields(currentErr),+ );const result = await deps.showMessageBox({type: 'warning',buttons: BUTTON_LABELS,@@ -103,6 +132,9 @@ export async function ensureGitAvailable(deps: EnsureGitDeps): Promise<EnsureGitmessage,detail,});+ deps.log?.info?.('ensureGitAvailable: install dialog answered', {+ response: BUTTON_NAMES[result.response] ?? result.response,+ });if (result.response === BUTTON_OPEN_INSTALL_PAGE) {try {diff --git a/packages/desktop/src/main/index.ts b/packages/desktop/src/main/index.tsindex 30d395b64..110682cb8 100644--- a/packages/desktop/src/main/index.ts+++ b/packages/desktop/src/main/index.ts@@ -6616,7 +6616,13 @@ function bootPrimaryInstance(): void {showMessageBox: async (opts) =>dialog.showMessageBox({ ...opts, buttons: [...opts.buttons] }),openExternal: (url) => shell.openExternal(url),- log: { warn: (msg, obj) => console.warn(msg, obj) },+ log: {+ warn: (msg, obj) => {+ getLogger('git-preflight').warn({ ...obj }, msg);+ flushDesktopLogger();+ },+ info: (msg, obj) => getLogger('git-preflight').info({ ...obj }, msg),+ },});if (gitOutcome === 'aborted') {app.quit();@@ -7001,6 +7007,11 @@ function bootPrimaryInstance(): void {.catch((err: unknown) => {const message = err instanceof Error ? err.message : String(err);const stack = err instanceof Error ? (err.stack ?? '') : '';+ getLogger('startup').error(+ { event: 'whenReady-unhandled-rejection', err },+ 'startup chain rejected; its remaining steps did not run',+ );+ flushDesktopLogger();console.error(JSON.stringify({ event: 'whenReady-unhandled-rejection', message, stack }));});diff --git a/packages/server/src/git-preflight-probe-failure.test.ts b/packages/server/src/git-preflight-probe-failure.test.tsnew file mode 100644index 000000000..685c60c70--- /dev/null+++ b/packages/server/src/git-preflight-probe-failure.test.ts@@ -0,0 +1,61 @@+import { chmodSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';++vi.mock('node:fs', async (importOriginal) => {+ const actual = await importOriginal<typeof import('node:fs')>();+ return { ...actual, existsSync: () => false };+});++const { detectGit, GitNotAvailableError } = await import('./git-preflight.ts');++describe('detectGit probe failure detail', () => {+ let originalPath: string | undefined;+ let binDir: string;++ beforeEach(() => {+ originalPath = process.env.PATH;+ binDir = mkdtempSync(join(tmpdir(), 'ok-git-probe-'));+ });++ afterEach(() => {+ if (originalPath === undefined) delete process.env.PATH;+ else process.env.PATH = originalPath;+ rmSync(binDir, { recursive: true, force: true });+ });++ test('records enoent when no git is on PATH and no fallback exists', () => {+ process.env.PATH = join(binDir, 'empty');+ let thrown: unknown;+ try {+ detectGit();+ } catch (err) {+ thrown = err;+ }+ expect(thrown).toBeInstanceOf(GitNotAvailableError);+ expect((thrown as InstanceType<typeof GitNotAvailableError>).probe).toEqual({+ path: 'enoent',+ fallback: null,+ });+ });++ test('records unparseable when the git on PATH prints no version', (ctx) => {+ ctx.skip(process.platform === 'win32', 'the stub git is a POSIX shell script');+ const stub = join(binDir, 'git');+ writeFileSync(stub, '#!/bin/sh\necho "not a version"\n');+ chmodSync(stub, 0o755);+ process.env.PATH = binDir;+ let thrown: unknown;+ try {+ detectGit();+ } catch (err) {+ thrown = err;+ }+ expect(thrown).toBeInstanceOf(GitNotAvailableError);+ expect((thrown as InstanceType<typeof GitNotAvailableError>).probe).toEqual({+ path: 'unparseable',+ fallback: null,+ });+ });+});diff --git a/packages/server/src/git-preflight-probe-spawn.test.ts b/packages/server/src/git-preflight-probe-spawn.test.tsnew file mode 100644index 000000000..991ba369c--- /dev/null+++ b/packages/server/src/git-preflight-probe-spawn.test.ts@@ -0,0 +1,60 @@+import type { SpawnSyncReturns } from 'node:child_process';+import { afterEach, describe, expect, test, vi } from 'vitest';++const spawnSyncMock = vi.hoisted(() => vi.fn());+const existsSyncMock = vi.hoisted(() => vi.fn(() => false));++vi.mock('node:child_process', async (importOriginal) => {+ const actual = await importOriginal<typeof import('node:child_process')>();+ return { ...actual, spawnSync: spawnSyncMock };+});++vi.mock('node:fs', async (importOriginal) => {+ const actual = await importOriginal<typeof import('node:fs')>();+ return { ...actual, existsSync: existsSyncMock };+});++const { detectGit, fallbackPaths, GitNotAvailableError } = await import('./git-preflight.ts');++function spawnError(code: string): SpawnSyncReturns<string> {+ const error = Object.assign(new Error(`spawnSync git ${code}`), { code });+ return { pid: 0, output: [], stdout: '', stderr: '', status: null, signal: null, error };+}++function exited(status: number, stdout: string): SpawnSyncReturns<string> {+ return { pid: 1, output: [], stdout, stderr: '', status, signal: null };+}++function probeOf(fn: () => unknown) {+ try {+ fn();+ } catch (err) {+ expect(err).toBeInstanceOf(GitNotAvailableError);+ return (err as InstanceType<typeof GitNotAvailableError>).probe;+ }+ throw new Error('detectGit did not throw');+}++describe('detectGit probe reasons with a stubbed spawn', () => {+ afterEach(() => {+ spawnSyncMock.mockReset();+ existsSyncMock.mockReset();+ existsSyncMock.mockReturnValue(false);+ });++ test('a git on PATH that cannot be launched is spawn-failed, not enoent', () => {+ spawnSyncMock.mockReturnValue(spawnError('EACCES'));+ expect(probeOf(detectGit)).toEqual({ path: 'spawn-failed', fallback: null });+ });++ test('a failing fallback candidate records its own reason', (ctx) => {+ const [candidate] = fallbackPaths(process.platform);+ ctx.skip(candidate === undefined, 'this platform has no fallback git candidates');+ existsSyncMock.mockImplementation((path: unknown) => path === candidate);+ spawnSyncMock.mockImplementation((command: string) =>+ command === 'git' ? spawnError('ENOENT') : exited(1, ''),+ );+ expect(probeOf(detectGit)).toEqual({ path: 'enoent', fallback: 'nonzero' });+ expect(spawnSyncMock).toHaveBeenCalledWith(candidate, ['--version'], expect.anything());+ });+});diff --git a/packages/server/src/git-preflight.ts b/packages/server/src/git-preflight.tsindex 34a5ab858..e4e41aaf5 100644--- a/packages/server/src/git-preflight.ts+++ b/packages/server/src/git-preflight.ts@@ -27,16 +27,29 @@ export interface InstallGuidance {readonly url: string;}+type GitProbeFailureReason = 'enoent' | 'spawn-failed' | 'unparseable' | 'timeout' | 'nonzero';++export interface GitProbeFailures {+ readonly path: GitProbeFailureReason;+ readonly fallback: GitProbeFailureReason | null;+}+export class GitNotAvailableError extends Error {readonly code = 'GIT_NOT_AVAILABLE';readonly platform: NodeJS.Platform;readonly guidance: InstallGuidance;+ readonly probe: GitProbeFailures | null;- constructor(platform: NodeJS.Platform, guidance: InstallGuidance, options?: { cause?: unknown }) {+ constructor(+ platform: NodeJS.Platform,+ guidance: InstallGuidance,+ options?: { cause?: unknown; probe?: GitProbeFailures },+ ) {super(buildMissingMessage(guidance), options);this.name = 'GitNotAvailableError';this.platform = platform;this.guidance = guidance;+ this.probe = options?.probe ?? null;}}@@ -77,6 +90,7 @@ export function detectGit(): GitDetected {};}+ let fallback: GitProbeFailureReason | null = null;for (const candidate of fallbackPaths(process.platform)) {if (!existsSync(candidate)) continue;const result = probeGit(candidate);@@ -88,9 +102,12 @@ export function detectGit(): GitDetected {source: 'fallback',};}+ fallback = result.reason;}- throw new GitNotAvailableError(process.platform, buildGuidance(process.platform));+ throw new GitNotAvailableError(process.platform, buildGuidance(process.platform), {+ probe: { path: stage1.reason, fallback },+ });}export function assertGitAvailable(): GitDetected {@@ -109,7 +126,7 @@ export function assertGitAvailable(): GitDetected {type ProbeResult =| { kind: 'ok'; version: string; resolvedPath: string }- | { kind: 'fail'; reason: 'enoent' | 'unparseable' | 'timeout' | 'nonzero' };+ | { kind: 'fail'; reason: GitProbeFailureReason };function probeGit(command: string): ProbeResult {const opts: SpawnSyncOptions = withHiddenWindowsConsole({@@ -122,7 +139,8 @@ function probeGit(command: string): ProbeResult {if (result.error) {if ('signal' in result && result.signal === 'SIGTERM')return { kind: 'fail', reason: 'timeout' };- return { kind: 'fail', reason: 'enoent' };+ const code = (result.error as NodeJS.ErrnoException).code;+ return { kind: 'fail', reason: code === 'ENOENT' ? 'enoent' : 'spawn-failed' };}if (result.status !== 0) {return { kind: 'fail', reason: 'nonzero' };