Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
[codex] Structure web diff worker failures (#3356)
Julius Marminge08650a7424f0
diff --git a/apps/web/src/components/DiffWorkerPoolProvider.tsx b/apps/web/src/components/DiffWorkerPoolProvider.tsxindex 8f7addc5b..3ec748c6b 100644--- a/apps/web/src/components/DiffWorkerPoolProvider.tsx+++ b/apps/web/src/components/DiffWorkerPoolProvider.tsx@@ -1,9 +1,20 @@import { WorkerPoolContextProvider, useWorkerPool } from "@pierre/diffs/react";import DiffsWorker from "@pierre/diffs/worker/worker.js?worker";+import * as Schema from "effect/Schema";import { useEffect, useMemo, type ReactNode } from "react";import { useTheme } from "../hooks/useTheme";import { resolveDiffThemeName, type DiffThemeName } from "../lib/diffRendering";+export class DiffWorkerError extends Schema.TaggedErrorClass<DiffWorkerError>()("DiffWorkerError", {+ operation: Schema.Literals(["create-worker", "get-render-options", "set-render-options"]),+ themeName: Schema.Literals(["pierre-light", "pierre-dark"]),+ cause: Schema.Defect(),+}) {+ override get message(): string {+ return `Diff worker operation ${this.operation} failed for theme ${this.themeName}.`;+ }+}+function DiffWorkerThemeSync({ themeName }: { themeName: DiffThemeName }) {const workerPool = useWorkerPool();@@ -12,17 +23,23 @@ function DiffWorkerThemeSync({ themeName }: { themeName: DiffThemeName }) {return;}- const current = workerPool.getDiffRenderOptions();- if (current.theme === themeName) {- return;- }+ let operation: DiffWorkerError["operation"] = "get-render-options";+ void (async () => {+ try {+ const current = workerPool.getDiffRenderOptions();+ if (current.theme === themeName) {+ return;+ }- void workerPool- .setRenderOptions({- ...current,- theme: themeName,- })- .catch(() => undefined);+ operation = "set-render-options";+ await workerPool.setRenderOptions({+ ...current,+ theme: themeName,+ });+ } catch (cause) {+ console.error(new DiffWorkerError({ operation, themeName, cause }));+ }+ })();}, [themeName, workerPool]);return null;@@ -40,7 +57,17 @@ export function DiffWorkerPoolProvider({ children }: { children?: ReactNode }) {return (<WorkerPoolContextProviderpoolOptions={{- workerFactory: () => new DiffsWorker(),+ workerFactory: () => {+ try {+ return new DiffsWorker();+ } catch (cause) {+ throw new DiffWorkerError({+ operation: "create-worker",+ themeName: diffThemeName,+ cause,+ });+ }+ },poolSize: workerPoolSize,totalASTLRUCacheSize: 240,}}