A desktop coding agent with free access to frontier models.
TypeScript
fix: start screen types and test
ogsamrat38966034bdb8
diff --git a/apps/app/tests/start-failure-overlay.test.tsx b/apps/app/tests/start-failure-overlay.test.tsxindex db73e94f..d6d87c2d 100644--- a/apps/app/tests/start-failure-overlay.test.tsx+++ b/apps/app/tests/start-failure-overlay.test.tsx@@ -8,17 +8,21 @@ test("couldn't start: one report, the hint it answers with, and Reset app data aif (registeredDom) GlobalRegistrator.register({ url: "http://localhost/" });Object.defineProperty(globalThis, "IS_REACT_ACT_ENVIRONMENT", { configurable: true, value: true });+ // Stable values, as the real providers keep them across renders.+ const desktopConfig = { config: {}, refreshFresh: async () => ({}) };+ const cloudStatus = { gatewayMode: false, visible: false, viewModel: { variant: "hidden" } };mock.module("@/react-app/domains/cloud/desktop-config-provider", () => ({- useDesktopConfig: () => ({ config: {}, refreshFresh: async () => ({}) }),+ useDesktopConfig: () => desktopConfig,}));mock.module("@/react-app/shell/cloud-workspace-overlay", () => ({- useCloudWorkspaceStatus: () => ({ gatewayMode: false, visible: false, viewModel: { variant: "hidden" } }),+ useCloudWorkspaceStatus: () => cloudStatus,}));const technical = "spawn C:\\Program Files\\omnirush.ai\\resources\\sidecars\\opencode.exe ENOENT";+ const bootState = { phase: "error", routeReady: false, message: "Something went wrong", error: technical };mock.module("@/react-app/shell/boot-state", () => ({bootOverlayCanHide: () => false,useBootOverlayVisible: () => true,- useBootState: () => ({ phase: "error", routeReady: false, message: "Something went wrong", error: technical }),+ useBootState: () => bootState,}));const reportFailure = mock(async (_input: { message?: string | null }) => ({diff --git a/apps/desktop/electron/main.mjs b/apps/desktop/electron/main.mjsindex 0c6bc8e6..15c32082 100644--- a/apps/desktop/electron/main.mjs+++ b/apps/desktop/electron/main.mjs@@ -1479,18 +1479,19 @@ async function readSidecarVersions(files) {function startReportScrubRoots() {const roots = [os.homedir(), os.tmpdir(), process.resourcesPath, process.env.USERPROFILE, process.env.LOCALAPPDATA, process.env.APPDATA];- for (const name of ["userData", "appData", "home", "temp"]) {+ for (const read of [+ () => app.getPath("userData"),+ () => app.getPath("appData"),+ () => app.getPath("home"),+ () => app.getPath("temp"),+ () => path.dirname(app.getPath("exe")),+ ]) {try {- roots.push(app.getPath(name));+ roots.push(read());} catch {// Not every path exists on every platform.}}- try {- roots.push(path.dirname(app.getPath("exe")));- } catch {- // Ignore.- }return roots;}diff --git a/apps/desktop/electron/start-report.mjs b/apps/desktop/electron/start-report.mjsindex 19ccbe55..46af17bc 100644--- a/apps/desktop/electron/start-report.mjs+++ b/apps/desktop/electron/start-report.mjs@@ -243,7 +243,16 @@ function execText(file, args, timeoutMs) {* Whether the CPU has AVX2 (the bundled engine's x64 build needs it), or* null when unknown or not applicable (arm64).*/-export async function cpuHasAvx2({ platform = process.platform, arch = process.arch, release = os.release(), readText = readFile, run = execText } = {}) {+/**+ * @param {{+ * platform?: string;+ * arch?: string;+ * release?: string;+ * readText?: (file: string, encoding: "utf8") => Promise<string>;+ * run?: (file: string, args: string[], timeoutMs: number) => Promise<string | null>;+ * }} [options]+ */+export async function cpuHasAvx2({ platform = process.platform, arch = process.arch, release = os.release(), readText = (file, encoding) => readFile(file, encoding), run = execText } = {}) {if (arch !== "x64") return null;try {if (platform === "linux") {@@ -360,8 +369,8 @@ export function buildStartFailureReport({avHint,cpuAvx2 = null,message = null,- appVersion,- engineVersion,+ appVersion = "unknown",+ engineVersion = "unknown",electronVersion = process.versions.electron,platform = process.platform,arch = process.arch,@@ -493,6 +502,15 @@ function today(nowMs) {** `send(body)` resolves to a fetch Response, or null while signed out.*/+/**+ * @param {{+ * filePath: string;+ * send: (body: object) => Promise<{ ok: boolean; status: number } | null>;+ * now?: () => number;+ * maxPerDay?: number;+ * log?: (message: string) => void;+ * }} options+ */export function createStartReporter({ filePath, send, now = Date.now, maxPerDay = MAX_REPORTS_PER_DAY, log = () => {} }) {let chain = Promise.resolve();const serialize = (task) => {diff --git a/apps/desktop/electron/start-report.test.mjs b/apps/desktop/electron/start-report.test.mjsindex 56bbe25f..7ed931fc 100644--- a/apps/desktop/electron/start-report.test.mjs+++ b/apps/desktop/electron/start-report.test.mjs@@ -59,7 +59,7 @@ test("start failures are classified from the error the start threw", () => {assert.deepEqual({ category: result.category, phase: result.phase, errorCode: result.errorCode, avHint: result.avHint },{ category, phase, errorCode, avHint },- error.message,+ String(error instanceof Error ? error.message : error),);}const workspace = Object.assign(new Error("Workspace path is not accessible: D:\\Clients\\Acme"), {diff --git a/apps/desktop/electron/start-reset.mjs b/apps/desktop/electron/start-reset.mjsindex 308433d1..c481bd0e 100644--- a/apps/desktop/electron/start-reset.mjs+++ b/apps/desktop/electron/start-reset.mjs@@ -62,6 +62,15 @@ export async function scheduleStartReset({ userDataPath, now = () => new Date()* `<userData>/start-reset-<time>/` (or, across drives, beside itself with a* `.omnirush-reset-<time>` suffix). Never throws; returns what moved.*/+/**+ * @param {{+ * userDataPath: string;+ * targets: Array<{ label: string; path: string }>;+ * now?: () => Date;+ * renameImpl?: (from: string, to: string) => Promise<void>;+ * log?: (message: string) => void;+ * }} options+ */export async function applyPendingStartReset({ userDataPath, targets, now = () => new Date(), renameImpl = rename, log = () => {} }) {const marker = path.join(userDataPath, START_RESET_PENDING);if (!existsSync(marker)) return { ran: false, moved: [], failed: [] };