diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts index d278cf663f..58c7b0fb81 100644 --- a/apps/desktop/src/main.ts +++ b/apps/desktop/src/main.ts @@ -324,14 +324,8 @@ function resolveBackendLaunch(backendEntry: string): { }; } - if (isDevelopment) { - return { - command: "bun", - args: [backendEntry], - env: backendEnv(), - }; - } - + // Default to Node-mode execution under Electron in both dev and production. + // This matches main and avoids runtime-specific PTY behavior differences. return { command: process.execPath, args: [backendEntry], diff --git a/apps/server/src/sqliteAdapter.ts b/apps/server/src/sqliteAdapter.ts index 7a07d4f445..229d7dc8ff 100644 --- a/apps/server/src/sqliteAdapter.ts +++ b/apps/server/src/sqliteAdapter.ts @@ -79,6 +79,8 @@ function openBunSqliteDatabase( export function openSqliteDatabase(dbPath: string): SqliteDatabase { const requireFn = createRequire(path.join(process.cwd(), "t3code-sqlite-adapter.cjs")); + console.log(process, globalThis, typeof Bun); + if (process.versions.bun) { // Development mode runs in Bun, so use Bun's SQLite adapter return openBunSqliteDatabase(requireFn, dbPath); diff --git a/apps/web/src/diffRouteSearch.test.ts b/apps/web/src/diffRouteSearch.test.ts index becf9e335f..ef00874bd2 100644 --- a/apps/web/src/diffRouteSearch.test.ts +++ b/apps/web/src/diffRouteSearch.test.ts @@ -17,6 +17,28 @@ describe("parseDiffRouteSearch", () => { }); }); + it("treats numeric and boolean diff toggles as open", () => { + expect( + parseDiffRouteSearch({ + diff: 1, + diffTurnId: "turn-1", + }), + ).toEqual({ + diff: "1", + diffTurnId: "turn-1", + }); + + expect( + parseDiffRouteSearch({ + diff: true, + diffTurnId: "turn-1", + }), + ).toEqual({ + diff: "1", + diffTurnId: "turn-1", + }); + }); + it("drops turn and file values when diff is closed", () => { const parsed = parseDiffRouteSearch({ diff: "0", @@ -50,4 +72,3 @@ describe("parseDiffRouteSearch", () => { }); }); }); - diff --git a/apps/web/src/diffRouteSearch.ts b/apps/web/src/diffRouteSearch.ts index fd3d6cae70..7a2544d663 100644 --- a/apps/web/src/diffRouteSearch.ts +++ b/apps/web/src/diffRouteSearch.ts @@ -4,6 +4,10 @@ export interface DiffRouteSearch { diffFilePath?: string; } +function isDiffOpenValue(value: unknown): boolean { + return value === "1" || value === 1 || value === true; +} + function normalizeSearchString(value: unknown): string | undefined { if (typeof value !== "string") { return undefined; @@ -20,7 +24,7 @@ export function stripDiffSearchParams>( } export function parseDiffRouteSearch(search: Record): DiffRouteSearch { - const diff = search.diff === "1" ? "1" : undefined; + const diff = isDiffOpenValue(search.diff) ? "1" : undefined; const diffTurnId = diff ? normalizeSearchString(search.diffTurnId) : undefined; const diffFilePath = diff && diffTurnId ? normalizeSearchString(search.diffFilePath) : undefined; diff --git a/apps/web/src/routes/__root.tsx b/apps/web/src/routes/__root.tsx index db2e6d50e4..a4933da575 100644 --- a/apps/web/src/routes/__root.tsx +++ b/apps/web/src/routes/__root.tsx @@ -1,7 +1,14 @@ -import { Outlet, createRootRouteWithContext, useParams } from "@tanstack/react-router"; +import { + Outlet, + createRootRouteWithContext, + type ErrorComponentProps, + useParams, +} from "@tanstack/react-router"; import { useEffect, useRef } from "react"; import { QueryClient, useQueryClient } from "@tanstack/react-query"; +import { APP_DISPLAY_NAME } from "../branding"; +import { Button } from "../components/ui/button"; import { AnchoredToastProvider, ToastProvider } from "../components/ui/toast"; import { isElectron } from "../env"; import { useNativeApi } from "../hooks/useNativeApi"; @@ -9,7 +16,6 @@ import { invalidateGitQueries } from "../lib/gitReactQuery"; import { hydratePersistedState } from "../persistenceSchema"; import { useStore } from "../store"; import { onServerWelcome } from "../wsNativeApi"; -import { APP_DISPLAY_NAME } from "../branding"; const CURRENT_RENDERER_STATE_KEY = "t3code:renderer-state:v7"; const LEGACY_RENDERER_STATE_KEYS = [ @@ -27,6 +33,7 @@ export const Route = createRootRouteWithContext<{ queryClient: QueryClient; }>()({ component: RootRouteView, + errorComponent: RootRouteErrorView, }); function RootRouteView() { @@ -55,6 +62,77 @@ function RootRouteView() { ); } +function RootRouteErrorView({ error, reset }: ErrorComponentProps) { + const message = errorMessage(error); + const details = errorDetails(error); + + return ( +
+
+
+
+
+ +
+

+ {APP_DISPLAY_NAME} +

+

+ Something went wrong. +

+

{message}

+ +
+ + +
+ +
+ + Show error details + Hide error details + +
+            {details}
+          
+
+
+
+ ); +} + +function errorMessage(error: unknown): string { + if (error instanceof Error && error.message.trim().length > 0) { + return error.message; + } + + if (typeof error === "string" && error.trim().length > 0) { + return error; + } + + return "An unexpected router error occurred."; +} + +function errorDetails(error: unknown): string { + if (error instanceof Error) { + return error.stack ?? error.message; + } + + if (typeof error === "string") { + return error; + } + + try { + return JSON.stringify(error, null, 2); + } catch { + return "No additional error details are available."; + } +} + function readLegacyRendererImportPayload() { if (typeof window === "undefined") { return null; diff --git a/apps/web/src/routes/_chat.$threadId.tsx b/apps/web/src/routes/_chat.$threadId.tsx index 8bb8aa389c..5efee58f5b 100644 --- a/apps/web/src/routes/_chat.$threadId.tsx +++ b/apps/web/src/routes/_chat.$threadId.tsx @@ -1,5 +1,5 @@ import { createFileRoute, useNavigate } from "@tanstack/react-router"; -import { Activity, Suspense, lazy, type ReactNode, useCallback, useEffect } from "react"; +import { Suspense, lazy, type ReactNode, useCallback, useEffect } from "react"; import ChatView from "../components/ChatView"; import { parseDiffRouteSearch, stripDiffSearchParams } from "../diffRouteSearch"; @@ -97,13 +97,11 @@ function ChatThreadRouteView() { return ( <> - - - - - - - + + + + + ); }