Repository navigation
refactor(gui): consume the API client for compute operations (#193) - #208
Merged
Merged
Conversation
Member
Author
|
CI is fully green (GUI tsc+vitest, Freeze API ×3, Build Installers ×3). Ready to merge — awaiting a smoke-test of the built app to confirm export/preview/validate round-trip through the sidecar (per the PR description, I'm not auto-merging this one). |
Member
Author
|
Smoke-test found a real bug (and fixed it): the bundled CLI + sidecar weren't being found on Linux/macOS. Tauri places resources from the |
Swap the compute wrappers in lib/commands.ts from Tauri `invoke` to the
generated OpenAPI client (via getApiClient):
- validateWindDefinition -> POST /validate (4xx mapped to {valid:false,errors}).
- plotDefinition -> POST /plan then POST /plot (PNG bytes -> base64).
- planWind -> POST /plan, then writes the returned gcode to the chosen path
(content-based; handleExportGcode no longer writes a temp .wind).
- Delete the dead simulateProgram/previewPlot wrappers (no callers).
- streamProgram + save/load file I/O stay on the Tauri bridge.
Retire the hand-maintained compute response schemas/types (PlanSummary,
SimulationSummary, PlotPreviewPayload, ValidationResult) — the generated
client types supersede them (completes #191's acceptance).
Marlin streaming and its event apparatus are unchanged here; that REST
swap + /jobs polling lands with #190/#199.
Closes #193. Finishes #191.
Known caveat: the preview's planner warnings (previously captured CLI
stderr) have no structured API equivalent yet, so they render empty.
Resources bundled from the `../bundled-cli/*` and `../bundled-api/*` globs
land under a `_up_/` subdirectory on every platform (Tauri encodes the
parent-dir `../`), not just Windows. cli_path.rs and api_path.rs only
checked `_up_` on Windows, so on Linux/macOS the bundled `fiberpath` CLI
and `fiberpath-api` sidecar were never found: the GUI showed "CLI Backend
Unavailable" and the sidecar never spawned (compute paths would fail).
Check `_up_/bundled-*/` first on all platforms, falling back to a flat
`bundled-*/` for dev layouts. Verified against the extracted Linux
AppImage: the binaries live at `<resource_dir>/_up_/bundled-{cli,api}/`
and run correctly (CLI --help, sidecar handshake + /health) — the only
bug was the path lookup.
Surfaced by the #193 smoke-test; also fixes the pre-existing CLI-path bug.
The Tauri webview fetches the sidecar cross-origin (its tauri:// origin →
127.0.0.1:<port>), so the browser enforces CORS. Without these headers the
webview can't read responses ("TypeError: Load failed") and POST preflights
fail, breaking preview/validate/export. Add permissive CORSMiddleware — the
sidecar binds loopback only and is never network-exposed, so allowing any
origin is safe.
Surfaced by the #193 smoke-test.
CameronBrooks11
force-pushed
the
refactor/gui-consume-client-193
branch
from
June 26, 2026 15:52
3cb3119 to
1b1c2f7
Compare
This was referenced Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #193. Finishes #191 (retires the hand-maintained compute response types). Builds on the merged sidecar (#192).
This is the first change that flips the GUI's runtime path onto the sidecar (export / preview / validate now POST to the local API instead of shelling out to the CLI). It's green in CI (tsc + vitest), but only a built-app run can confirm the webview actually round-trips to the sidecar. The review assessed the fetch/CSP risk as LOW (Tauri 2 with no
cspkey imposes noconnect-srclimit, and the already-merged/healthpoll uses the samefetch-to-127.0.0.1mechanism) — but please confirm export/preview/validate work end-to-end. I won't auto-merge this one.What
lib/commands.ts:validateWindDefinition→POST /validate(4xx →{valid:false, errors});plotDefinition→POST /planthenPOST /plot(PNG → base64);planWind→POST /planthen writes the gcode to the chosen path (content-based; no temp.wind). DeadsimulateProgram/previewPlotremoved.streamProgram+ file I/O stay on the Tauri bridge.PlanSummary/SimulationSummary/PlotPreviewPayload/ValidationResultschemas+types — the generated client types supersede them (build: OpenAPI-generated TS client + CI drift gate #191 acceptance).commands.test.tsrewritten against a mocked client. Net −188 lines.Review
Independent adversarial review: SHIP-WITH-NITS, no blocking — verified openapi-fetch usage against its source, the 422
loc.slice(1)mapping,bytesToBase64, and retirement completeness. Nits addressed: CHANGELOG now notes the warnings caveat;validatehardened against a hypothetical200 {valid:false}.Known caveat + follow-ups
/planwarnings field is the fix./validateand/planreturn a custom 400 not declared in the OpenAPI spec. Handled at runtime; declaring it in the FastAPIresponseswould make the contract explicit (backend follow-up).Verification