A desktop coding agent with free access to frontier models.
TypeScript
fix: the sidebar lists chats from the new engine from the start
ogsamratab25b2193919
diff --git a/apps/app/src/react-app/shell/use-workspace-route-state.ts b/apps/app/src/react-app/shell/use-workspace-route-state.tsindex 51bb1833..bfdb1140 100644--- a/apps/app/src/react-app/shell/use-workspace-route-state.ts+++ b/apps/app/src/react-app/shell/use-workspace-route-state.ts@@ -203,7 +203,8 @@ export function useWorkspaceRouteState(input: UseWorkspaceRouteStateInput) {const [client, setClient] = useState<OmniRushServerClient | null>(null);const [baseUrl, setBaseUrl] = useState("");const [token, setToken] = useState("");- const [engineV2ChatRouting, setEngineV2ChatRouting] = useState(false);+ // The app ships only the 2.x engine: chats route there until a server says otherwise.+ const [engineV2ChatRouting, setEngineV2ChatRouting] = useState(true);const [engineRoutingReady, setEngineRoutingReady] = useState(false);const engineV2ChatRoutingRef = useRef(engineV2ChatRouting);engineV2ChatRoutingRef.current = engineV2ChatRouting;@@ -1247,7 +1248,7 @@ export function useWorkspaceRouteState(input: UseWorkspaceRouteStateInput) {const routingServerToken = selectedWorkspaceEndpoint?.token ?? "";useEffect(() => {if (!routingServerUrl || !routingServerToken) {- setEngineV2ChatRouting(false);+ setEngineV2ChatRouting(true);return;}const omnirushClient = createOmniRushServerClient({ baseUrl: routingServerUrl, token: routingServerToken });@@ -1262,11 +1263,14 @@ export function useWorkspaceRouteState(input: UseWorkspaceRouteStateInput) {} catch (error) {if (cancelled) return;// Older servers do not expose the preview endpoint and use v1.- if (error instanceof OmniRushServerError && error.status === 404) setEngineRoutingReady(true);+ if (error instanceof OmniRushServerError && error.status === 404) {+ setEngineV2ChatRouting(false);+ setEngineRoutingReady(true);+ }console.warn("[opencode-v2] failed to read chat routing status; retaining the current engine", error);}};- setEngineV2ChatRouting(false);+ setEngineV2ChatRouting(true);setEngineRoutingReady(false);void refresh();window.addEventListener("omnirush-server-settings-changed", refresh);diff --git a/apps/app/tests/engine-v2-routing-default.test.ts b/apps/app/tests/engine-v2-routing-default.test.tsnew file mode 100644index 00000000..084edb2a--- /dev/null+++ b/apps/app/tests/engine-v2-routing-default.test.ts@@ -0,0 +1,12 @@+import { readFileSync } from "node:fs";+import { fileURLToPath } from "node:url";+import { expect, test } from "bun:test";++const source = readFileSync(fileURLToPath(new URL("../src/react-app/shell/use-workspace-route-state.ts", import.meta.url)), "utf8");++test("the sidebar starts on the 2.x engine and goes back to 1.x only for a server without the routing status", () => {+ expect(source).toContain("useState(true);");+ expect(source).not.toContain("setEngineV2ChatRouting(false);\n setEngineRoutingReady(false);");+ expect(source).not.toMatch(/if \(!routingServerUrl \|\| !routingServerToken\) \{\s*setEngineV2ChatRouting\(false\)/);+ expect(source).toMatch(/error\.status === 404\) \{\s*setEngineV2ChatRouting\(false\);/);+});