A desktop coding agent with free access to frontier models.
TypeScript
fix: an engine reload with nothing to reload never restarts the app
ogsamrat3124366a3b86
diff --git a/apps/app/src/react-app/shell/engine-reload-escalation.ts b/apps/app/src/react-app/shell/engine-reload-escalation.tsindex 0e495d43..ed5558a2 100644--- a/apps/app/src/react-app/shell/engine-reload-escalation.ts+++ b/apps/app/src/react-app/shell/engine-reload-escalation.ts@@ -58,7 +58,7 @@ export type ReloadEngineFallbackOptions = {* (it reports `restartDeferred`), so this never ends live runs by itself.*/export async function reloadEngineWithDesktopFallback(- client: Pick<OmniRushServerClient, "reloadEngine">,+ client: Pick<OmniRushServerClient, "reloadEngine"> & Partial<Pick<OmniRushServerClient, "getEngineV2PreviewStatus">>,workspaceId: string,options?: ReloadEngineFallbackOptions,): Promise<ReloadEngineFallbackResult> {@@ -73,6 +73,12 @@ export async function reloadEngineWithDesktopFallback(if (!canRestartDesktopForReloadError(error) || !isDesktop()) {throw error;}+ // Chats run on the 2.x engine: the 1.x one this reload targets is not there+ // ("unconfigured"), so there is nothing to reload and nothing to restart.+ if (error instanceof OmniRushServerError && error.code === "opencode_unconfigured") {+ const v2 = await client.getEngineV2PreviewStatus?.().catch(() => null);+ if (v2?.enabled && v2.chatRouting) return { restartedEngine: false };+ }await delay(options?.retryDelayMs ?? UNREACHABLE_RETRY_DELAY_MS);try {await client.reloadEngine(workspaceId);diff --git a/apps/app/tests/engine-reload-escalation.test.ts b/apps/app/tests/engine-reload-escalation.test.tsindex 3e9f497a..383335c1 100644--- a/apps/app/tests/engine-reload-escalation.test.ts+++ b/apps/app/tests/engine-reload-escalation.test.ts@@ -85,6 +85,17 @@ describe("reloadEngineWithDesktopFallback", () => {expect(harness.restartCalls).toBe(1);});+ test("chats on the 2.x engine: an unconfigured 1.x reload is nothing to reload, never a restart", async () => {+ const harness = makeHarness([unconfiguredError(), unconfiguredError()]);+ const client = { ...harness.client, getEngineV2PreviewStatus: async () => ({+ enabled: true, running: true, chatRouting: true, mirroredProviderIds: [], skippedProviderIds: [], catalogModelIds: [],+ }) };+ const result = await reloadEngineWithDesktopFallback(client, "ws", harness.options);+ expect(result.restartedEngine).toBe(false);+ expect(harness.reloadCalls).toBe(1);+ expect(harness.restartCalls).toBe(0);+ });+test("a restart the desktop deferred because sessions are running is not reported as a restart", async () => {const harness = makeHarness([unreachableError(), unreachableError()]);const result = await reloadEngineWithDesktopFallback(harness.client, "ws", {