Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(frontend): refuse a build that ships a name nothing defines
rubenluetke10-beep1c93a06afbe6
diff --git a/docs/BUGS.md b/docs/BUGS.mdindex 6981b4f1e4..f7c357c99a 100644--- a/docs/BUGS.md+++ b/docs/BUGS.md@@ -13879,3 +13879,52 @@ backend has the old module loaded; a restart picks the fix up.opens on garbage — and a cut taken only when a limit is EXCEEDED protectsnothing when the input is short. Measure a bound before keeping it: this onewas defended by a cost that was never there.++## BUG-197: the Agentic IDE crashed to "View could not be loaded — PANE_ACTIVITY_EVENT is not defined" although the source defined and imported that name (MEDIUM, FIXED 2026-08-27)++**Symptom.** Opening the Agentic IDE in the desktop app showed the view's+error boundary — "agentic-ide crashed. George stays usable." — with+`PANE_ACTIVITY_EVENT is not defined` (maintainer screenshot 2026-08-27 11:53).+`grep` over the source found the constant exported from+`store/workspacePanes.ts` and imported by `AgenticGrid.tsx`; `grep` over the+current `dist/` found no such identifier at all — a minified bundle never+carries one.++**Root cause.** A sibling session was building the shared working tree while+its own edit to `AgenticGrid.tsx` was half done: the `addEventListener` call+existed, the import line did not. `npm run build` runs `tsc -b` first and+would have refused, but `tsconfig.json` includes every test file, and one+foreign half-written test fails `tsc -b` for everyone — so sessions build+with a bare `vite build` (the recipe in the maintainer's memory since+2026-08-27). Rollup treats an identifier with no declaration as a browser+global and emits it verbatim into the chunk. The desktop window reloads+itself onto every fresh bundle (`bundleWatch.ts`), so the maintainer got the+broken chunk within a minute of the build. The next build, two minutes later+with the import in place, was clean — the crash was gone before anyone+looked, and nothing in the tree explained it.++**Fix.** `jarvis/ui/web/frontend/vite-plugins/missingNameGate.ts`, wired into+`vite.config.ts` for `build` only. It starts `tsc -b` beside the bundling+and, in `buildEnd` — before Vite empties the output directory, so a refused+build leaves the previous bundle in place — fails the build on exactly the+diagnostics that ARE a runtime crash: `TS2304`/`TS2552` "Cannot find name"+whose position is a value position. A missing name inside a type annotation,+a generic argument, an interface or `implements` is erased by the compiler+and passes, as does every other type error, the way a bare build always+let them through. Under `npm run build` the tree has just passed `tsc -b`+and the gate skips its second run. `tsconfig.node.json` gained `noEmit`, so+type-checking the config project no longer drops `.js`/`.d.ts` files beside+the sources.++Tests: `vite-plugins/missingNameGate.test.ts` (diagnostic parsing; value vs+type positions — bare use, generic argument, annotation, cast, interface,+`typeof` in both worlds, `extends` vs `implements`, JSX tag, a vanished line).+Proven on the tree of the day: a probe file with an undeclared name refused+the build and kept the old output; the same tree without it built despite a+foreign `TS2345` and a foreign type-only "Cannot find name".++**Lesson.** A type check that fails for foreign reasons gets skipped, and a+skipped check protects nothing. The gate that survives a shared tree is the+one that fails only on what is certainly broken — here, the one class of+type error that is a `ReferenceError` in disguise — and lets everything+merely disputed pass.diff --git a/jarvis/ui/web/frontend/tsconfig.node.json b/jarvis/ui/web/frontend/tsconfig.node.jsonindex 97ede7ee6f..4356e6c34c 100644--- a/jarvis/ui/web/frontend/tsconfig.node.json+++ b/jarvis/ui/web/frontend/tsconfig.node.json@@ -1,11 +1,12 @@{"compilerOptions": {"composite": true,+ "outDir": "./node_modules/.tmp/tsconfig.node","skipLibCheck": true,"module": "ESNext","moduleResolution": "bundler","allowSyntheticDefaultImports": true,"strict": true},- "include": ["vite.config.ts"]+ "include": ["vite.config.ts", "vite-plugins/*.ts"]}diff --git a/jarvis/ui/web/frontend/vite-plugins/missingNameGate.test.ts b/jarvis/ui/web/frontend/vite-plugins/missingNameGate.test.tsnew file mode 100644index 0000000000..1f04a178b6--- /dev/null+++ b/jarvis/ui/web/frontend/vite-plugins/missingNameGate.test.ts@@ -0,0 +1,108 @@+import { describe, expect, it } from "vitest";++import { isRuntimePosition, missingNames } from "./missingNameGate";++const TSC_OUTPUT = [+ "src/components/agentic/AgenticGrid.tsx(1009,29): error TS2304: Cannot find name 'PANE_ACTIVITY_EVENT'.",+ "src/components/agentic/AgenticGrid.tsx(780,10): error TS6133: 'drafting' is declared but its value is never read.",+ "src/store/newPaneChat.ts(179,35): error TS2345: Argument of type 'X' is not assignable to parameter of type 'Y'.",+ " Type 'X' is not assignable to type 'Y'.",+ "src/lib/x.ts(3,7): error TS2552: Cannot find name 'wnidow'. Did you mean 'window'?",+ "",+].join("\r\n");++describe("missingNames", () => {+ it("keeps only the two 'Cannot find name' codes, with their position", () => {+ expect(missingNames(TSC_OUTPUT)).toEqual([+ {+ file: "src/components/agentic/AgenticGrid.tsx",+ line: 1009,+ column: 29,+ message: "Cannot find name 'PANE_ACTIVITY_EVENT'.",+ },+ {+ file: "src/lib/x.ts",+ line: 3,+ column: 7,+ message: "Cannot find name 'wnidow'. Did you mean 'window'?",+ },+ ]);+ });++ it("reads a clean run as nothing", () => {+ expect(missingNames("")).toEqual([]);+ });+});++/** (line, column) of the first `needle` in `text`, 1-based like tsc. */+function at(text: string, needle: string): [number, number] {+ const index = text.indexOf(needle);+ if (index < 0) throw new Error(`no ${needle}`);+ const before = text.slice(0, index).split("\n");+ return [before.length, before[before.length - 1].length + 1];+}++describe("isRuntimePosition", () => {+ const check = (text: string, needle: string): boolean =>+ isRuntimePosition("probe.tsx", text, ...at(text, needle));++ it("a bare value use is live — the crash that shipped", () => {+ const text = [+ "export function attach() {",+ " window.addEventListener(PANE_ACTIVITY_EVENT, () => {});",+ "}",+ ].join("\n");+ expect(check(text, "PANE_ACTIVITY_EVENT")).toBe(true);+ });++ it("a generic argument, an annotation and a cast are erased", () => {+ const text = [+ "const [drops, setDrops] = useState<ChatAttachment[]>([]);",+ "let one: ChatAttachment | null = null;",+ "const two = drops[0] as ChatAttachment;",+ "export { setDrops, one, two };",+ ].join("\n");+ expect(check(text, "ChatAttachment[]")).toBe(false);+ expect(check(text, "ChatAttachment | null")).toBe(false);+ expect(check(text, "ChatAttachment;")).toBe(false);+ });++ it("an interface body and a type alias are erased", () => {+ const text = [+ "export interface Row { activity: PaneActivity; }",+ "export type Change = Omit<Row, 'activity'>;",+ ].join("\n");+ expect(check(text, "PaneActivity;")).toBe(false);+ expect(check(text, "Omit<")).toBe(false);+ });++ it("typeof in a type is erased; typeof in a value is live", () => {+ const text = [+ "export type Store = typeof missingStore;",+ "export const kind = typeof missingValue;",+ ].join("\n");+ expect(check(text, "missingStore")).toBe(false);+ expect(check(text, "missingValue")).toBe(true);+ });++ it("a class's extends runs; implements and an interface's extends do not", () => {+ const text = [+ "class A extends MissingBase {}",+ "class B implements MissingShape {}",+ "interface C extends MissingParent {}",+ "export { A, B }; export type { C };",+ ].join("\n");+ expect(check(text, "MissingBase")).toBe(true);+ expect(check(text, "MissingShape")).toBe(false);+ expect(check(text, "MissingParent")).toBe(false);+ });++ it("a JSX tag is live", () => {+ const text = "export const view = <MissingPill activity=\"working\" />;";+ expect(check(text, "MissingPill")).toBe(true);+ });++ it("a position the file no longer has is treated as live", () => {+ expect(isRuntimePosition("probe.ts", "const a = 1;\n", 40, 3)).toBe(true);+ });+});diff --git a/jarvis/ui/web/frontend/vite-plugins/missingNameGate.ts b/jarvis/ui/web/frontend/vite-plugins/missingNameGate.tsnew file mode 100644index 0000000000..13b36fa422--- /dev/null+++ b/jarvis/ui/web/frontend/vite-plugins/missingNameGate.ts@@ -0,0 +1,182 @@+/**+ * Refuse to ship a bundle that uses a name nothing defines.+ *+ * `npm run build` type-checks first, but the working tree is shared between+ * agent sessions and one sibling's half-written test file fails `tsc -b` for+ * everyone — so a session that has to ship a fix runs `vite build` on its own.+ * Rollup treats an identifier without a declaration as a browser global and+ * emits it verbatim: a component whose import line had not been written yet+ * became `PANE_ACTIVITY_EVENT is not defined` in the desktop app, whose window+ * reloads itself onto every fresh bundle, and the Agentic IDE crashed for the+ * maintainer (2026-08-27, BUG-197). Most type errors are noise at runtime; a+ * name TypeScript cannot find in a VALUE position is a guaranteed crash. So+ * this gate runs the type check beside the bundling and fails the build on+ * exactly those diagnostics, letting foreign type mismatches — and a missing+ * type-only name, which the bundle erases — through the way a bare build+ * always did.+ *+ * The check starts with the build and is awaited before Vite empties the+ * output directory, so a refused build leaves the previous bundle in place+ * for the app that is serving it. Under `npm run build` the whole tree has+ * just passed `tsc -b`, and the gate skips its redundant second run.+ */+import { spawn } from "node:child_process";+import fs from "node:fs";+import path from "node:path";+import ts from "typescript";+import type { Plugin } from "vite";++/** One tsc diagnostic: `src/x.ts(12,3): error TS2304: Cannot find name 'Y'.` */+const TSC_DIAGNOSTIC = /^(.+?)\((\d+),(\d+)\): error (TS\d+): (.*)$/;++/**+ * The diagnostics that MAY be a ReferenceError waiting to happen. TS2304 and+ * TS2552 are both "Cannot find name": an identifier nothing declares or+ * imports. Whether it survives into JavaScript depends on where it stands.+ */+const CANNOT_FIND_NAME: ReadonlySet<string> = new Set(["TS2304", "TS2552"]);++/** Where tsc found a name it could not resolve. */+export interface MissingName {+ /** As tsc printed it: relative to the directory tsc ran in. */+ file: string;+ /** 1-based. */+ line: number;+ /** 1-based. */+ column: number;+ message: string;+}++/** The "Cannot find name" diagnostics in tsc's output, in order. */+export function missingNames(tscOutput: string): MissingName[] {+ const hits: MissingName[] = [];+ for (const raw of tscOutput.split(/\r?\n/)) {+ const match = TSC_DIAGNOSTIC.exec(raw);+ if (match === null || !CANNOT_FIND_NAME.has(match[4])) continue;+ hits.push({+ file: match[1],+ line: Number(match[2]),+ column: Number(match[3]),+ message: match[5],+ });+ }+ return hits;+}++/** The deepest node whose span covers `position`, or the file itself. */+function nodeAt(file: ts.SourceFile, position: number): ts.Node {+ let node: ts.Node = file;+ for (;;) {+ const child = ts.forEachChild(node, (candidate) =>+ candidate.getStart(file) <= position && position < candidate.getEnd()+ ? candidate+ : undefined,+ );+ if (child === undefined) return node;+ node = child;+ }+}++/**+ * Does the name at (line, column) stand where JavaScript will still read it?+ *+ * A name inside a type node — an annotation, a generic argument, an+ * interface body, `typeof X` in a type — is erased by the compiler and can be+ * missing without consequence. `class A extends Missing` is the one heritage+ * clause that runs; `implements` and an interface's `extends` do not.+ */+export function isRuntimePosition(+ fileName: string,+ sourceText: string,+ line: number,+ column: number,+): boolean {+ const file = ts.createSourceFile(fileName, sourceText, ts.ScriptTarget.Latest, true);+ let position: number;+ try {+ position = file.getPositionOfLineAndCharacter(line - 1, column - 1);+ } catch {+ // The file changed under tsc (a sibling session is mid-edit) and the+ // reported line is gone. A name we cannot place is treated as live: the+ // gate errs toward refusing a build, never toward shipping one.+ return true;+ }+ for (let node: ts.Node | undefined = nodeAt(file, position); node; node = node.parent) {+ if (ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent)) {+ const clause = node.parent;+ return clause.token === ts.SyntaxKind.ExtendsKeyword && ts.isClassLike(clause.parent);+ }+ if (ts.isTypeNode(node)) return false;+ if (+ ts.isTypeAliasDeclaration(node) ||+ ts.isInterfaceDeclaration(node) ||+ ts.isTypeParameterDeclaration(node)+ ) {+ return false;+ }+ }+ return true;+}++/** The subset of `names` the emitted JavaScript would still reference. */+export function runtimeMissingNames(names: MissingName[], root: string): MissingName[] {+ return names.filter((name) => {+ const absolute = path.resolve(root, name.file);+ let text: string;+ try {+ text = fs.readFileSync(absolute, "utf8");+ } catch {+ // Gone between tsc and now — a sibling deleted it. Nothing to ship, so+ // nothing to refuse.+ return false;+ }+ return isRuntimePosition(absolute, text, name.line, name.column);+ });+}++function runTsc(root: string): Promise<string> {+ return new Promise((resolve) => {+ const tsc = path.resolve(root, "node_modules/typescript/lib/tsc.js");+ const child = spawn(process.execPath, [tsc, "-b", "--pretty", "false"], {+ cwd: root,+ windowsHide: true,+ stdio: ["ignore", "pipe", "pipe"],+ });+ const chunks: Buffer[] = [];+ child.stdout.on("data", (chunk: Buffer) => chunks.push(chunk));+ child.stderr.on("data", (chunk: Buffer) => chunks.push(chunk));+ child.on("error", (error) => {+ // A type check that cannot start must not pass for one that passed:+ // surface it as a diagnostic the gate reports, never as silence.+ resolve(`(0,0): error TS2304: Cannot find name check: ${error.message}`);+ });+ child.on("close", () => resolve(Buffer.concat(chunks).toString("utf8")));+ });+}++export function missingNameGate(root: string): Plugin {+ let pending: Promise<string> | null = null;++ return {+ name: "missing-name-gate",+ apply: "build",+ buildStart() {+ if (process.env.npm_lifecycle_event === "build") return;+ pending = runTsc(root);+ },+ async buildEnd(error) {+ if (pending === null || error !== undefined) return;+ const output = await pending;+ pending = null;+ const live = runtimeMissingNames(missingNames(output), root);+ if (live.length === 0) return;+ this.error(+ [+ `${live.length} name(s) nothing defines would crash the app at runtime:`,+ ...live.map((name) => ` ${name.file}(${name.line},${name.column}): ${name.message}`),+ "A missing import? Rollup would have shipped it as a bare global.",+ ].join("\n"),+ );+ },+ };+}diff --git a/jarvis/ui/web/frontend/vite.config.d.ts b/jarvis/ui/web/frontend/vite.config.d.tsdeleted file mode 100644index 340562aff1..0000000000--- a/jarvis/ui/web/frontend/vite.config.d.ts+++ /dev/null@@ -1,2 +0,0 @@-declare const _default: import("vite").UserConfig;-export default _default;diff --git a/jarvis/ui/web/frontend/vite.config.js b/jarvis/ui/web/frontend/vite.config.jsdeleted file mode 100644index 7458401fff..0000000000--- a/jarvis/ui/web/frontend/vite.config.js+++ /dev/null@@ -1,88 +0,0 @@-/// <reference types="vitest" />-import fs from "node:fs";-import { defineConfig } from "vite";-import react from "@vitejs/plugin-react";-import path from "node:path";-var MATERIAL_ICON_ROUTE = "/assets/material-file-icons";-var materialIconSource = path.resolve(__dirname, "node_modules/material-icon-theme/icons");-/**- * Keep the complete icon theme out of the Agentic IDE JavaScript chunk.- * Development serves the pinned package directly; production copies the same- * MIT-licensed SVGs beside the static assets for offline desktop use.- */-function materialIconAssets() {- var outputDirectory = "";- return {- name: "material-file-icon-assets",- configResolved: function (config) {- outputDirectory = path.resolve(config.root, config.build.outDir);- },- configureServer: function (server) {- server.middlewares.use(MATERIAL_ICON_ROUTE, function (request, response, next) {- var _a;- var requestedFile = "";- try {- requestedFile = decodeURIComponent((_a = request.url) !== null && _a !== void 0 ? _a : "")- .split("?", 1)[0]- .replace(/^\/+/, "");- }- catch (_b) {- next();- return;- }- if (!/^[a-zA-Z0-9_.-]+\.svg$/.test(requestedFile)) {- next();- return;- }- var sourceFile = path.resolve(materialIconSource, requestedFile);- if (path.dirname(sourceFile) !== materialIconSource ||- !fs.existsSync(sourceFile)) {- next();- return;- }- response.setHeader("Content-Type", "image/svg+xml");- response.setHeader("Cache-Control", "public, max-age=3600");- fs.createReadStream(sourceFile).pipe(response);- });- },- writeBundle: function () {- fs.cpSync(materialIconSource, path.join(outputDirectory, "assets", "material-file-icons"), { recursive: true });- },- };-}-export default defineConfig({- plugins: [react(), materialIconAssets()],- resolve: {- alias: {- "@": path.resolve(__dirname, "./src"),- },- },- server: {- port: 5173,- proxy: {- "/api": {- target: "http://127.0.0.1:47821",- changeOrigin: true,- },- "/ws": {- target: "ws://127.0.0.1:47821",- ws: true,- changeOrigin: true,- },- },- },- build: {- outDir: "../dist",- emptyOutDir: true,- // No source maps in production builds. They bloat the bundle, expose the- // full original source, and bake the absolute build path (e.g. a personal- // C:\Users\... home dir) into the .map files — none of which belongs in the- // prebuilt dist shipped to the public repo. The Vite dev server keeps its- // own inline maps, so local debugging is unaffected.- sourcemap: false,- },- test: {- environment: "jsdom",- globals: true,- },-});diff --git a/jarvis/ui/web/frontend/vite.config.ts b/jarvis/ui/web/frontend/vite.config.tsindex 048ae596e6..4b6fc0e8d4 100644--- a/jarvis/ui/web/frontend/vite.config.ts+++ b/jarvis/ui/web/frontend/vite.config.ts@@ -5,6 +5,8 @@ import type { Plugin } from "vite";import react from "@vitejs/plugin-react";import path from "node:path";+import { missingNameGate } from "./vite-plugins/missingNameGate";+const MATERIAL_ICON_ROUTE = "/assets/material-file-icons";const materialIconSource = path.resolve(__dirname,@@ -65,7 +67,7 @@ function materialIconAssets(): Plugin {}export default defineConfig({- plugins: [react(), materialIconAssets()],+ plugins: [react(), materialIconAssets(), missingNameGate(__dirname)],resolve: {alias: {"@": path.resolve(__dirname, "./src"),