From 03fbd73e992db11b551d4cdc2c204b3cdf0f6bee Mon Sep 17 00:00:00 2001 From: Balint Ipkovich Date: Wed, 3 Jun 2026 16:47:23 +0200 Subject: [PATCH] feat(web): wire gerbview tool (file-less launch, wizard-skip, UI) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Register the newly WASM-ported Gerber Viewer in the web app the same way as the other tools — registry entries only, no UI edits (ProjectDetailPage renders launch links generically from FILELESS_TOOLS). GERBVIEW_FRAME opens gerber/drill files through its own File→Open UI and projects carry no gerber files to auto-open, so it's treated as file-less (boot standalone), mirroring symbol_editor. It boots through single_top.cpp's STARTWIZARD, so it seeds config to skip the first-run wizard (TOOL_NEEDS_CONFIG_SEED) and gets a /usr/bin/gerbview argv0. - contract: add "gerbview" to TOOLS, TOOL_LABELS ("Gerber Viewer"), FILELESS_TOOLS - frontend: add gerbview to TOOL_ARGV0 and TOOL_NEEDS_CONFIG_SEED - e2e: add file-less gerbview case to tools-open.spec.ts (title "Gerber Viewer", canvas painted, wizard-free, no WASM abort) Verified in-browser via npm run test:web: gerbview boots wizard-free with the viewer chrome (toolbars + layers manager), 0 console errors. Co-Authored-By: Claude Opus 4.8 --- tests/web/tools-open.spec.ts | 1 + web/apps/frontend/src/wasm/constants.ts | 2 ++ web/packages/contract/src/schemas.ts | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/tests/web/tools-open.spec.ts b/tests/web/tools-open.spec.ts index ac01c84..5a83771 100644 --- a/tests/web/tools-open.spec.ts +++ b/tests/web/tools-open.spec.ts @@ -26,6 +26,7 @@ const CASES: Record = { pl_editor: { route: 'pl_editor/demo.kicad_wks', titleRe: /demo — Drawing Sheet Editor/i, fileless: false }, calculator: { route: 'calculator/', titleRe: /Calculator Tools/i, fileless: true }, symbol_editor: { route: 'symbol_editor/', titleRe: /Symbol Editor/i, fileless: true }, + gerbview: { route: 'gerbview/', titleRe: /Gerber Viewer/i, fileless: true }, }; /** Console text that must never appear (wizard-crash + URL-regex modal markers). */ diff --git a/web/apps/frontend/src/wasm/constants.ts b/web/apps/frontend/src/wasm/constants.ts index 74e57a7..97c5ec0 100644 --- a/web/apps/frontend/src/wasm/constants.ts +++ b/web/apps/frontend/src/wasm/constants.ts @@ -26,6 +26,7 @@ export const TOOL_ARGV0: Record = { calculator: "/usr/bin/pcb_calculator", pl_editor: "/usr/bin/pl_editor", symbol_editor: "/usr/bin/symbol_editor", + gerbview: "/usr/bin/gerbview", }; /** @@ -43,6 +44,7 @@ export const TOOL_NEEDS_CONFIG_SEED: Record = { calculator: true, pl_editor: true, symbol_editor: true, + gerbview: true, }; /** KiCad user settings dir for this build (PATHS::GetUserSettingsPath()). */ diff --git a/web/packages/contract/src/schemas.ts b/web/packages/contract/src/schemas.ts index 0722920..c8ebc79 100644 --- a/web/packages/contract/src/schemas.ts +++ b/web/packages/contract/src/schemas.ts @@ -7,6 +7,7 @@ export const TOOLS = [ "calculator", "pl_editor", "symbol_editor", + "gerbview", ] as const; export const toolSchema = z.enum(TOOLS); export type Tool = z.infer; @@ -18,6 +19,7 @@ export const TOOL_LABELS: Record = { calculator: "PCB Calculator", pl_editor: "Drawing Sheet Editor", symbol_editor: "Symbol Editor", + gerbview: "Gerber Viewer", }; /** Default file-extension → tool mapping (the explicit URL segment always wins). */ @@ -31,10 +33,13 @@ export const EXTENSION_TOOL: Record = { * Tools that do not take a file (booted standalone). The calculator has no file * concept; the symbol editor opens libraries through its own UI (its frame does * not implement OpenProjectFiles), so we boot it standalone rather than auto-open. + * The gerber viewer likewise opens gerber/drill files through its own File→Open + * UI — projects carry no gerber files to auto-open — so it boots standalone too. */ export const FILELESS_TOOLS: ReadonlySet = new Set([ "calculator", "symbol_editor", + "gerbview", ]); export const projectSlugSchema = z