Skip to content

feat(gui): model browser preview as a first-class state - #255

Merged
CameronBrooks11 merged 1 commit into
mainfrom
feat/249-browser-preview-state
Jun 27, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
feat/249-browser-preview-state

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Closes #249. Part of epic #246 (post-redesign audit follow-ups).

Problem

The backend-less browser preview wasn't modeled as its own state — it leaked raw runtime errors and rendered inconsistent signals:

  • [MED · runtime, live-QA] Generate-preview and entering the Machine tab (auto list-ports) threw Cannot read properties of undefined (reading 'invoke') via toast + inline state + log.
  • [MED · ia-flow] the status dot was red (error) for the preview state while the banner treated it as info.
  • [LOW] banner misfiled under components/machine/ though app-scoped; stale cliText identifier.

Fix

  • invokeBackend() (new, lib/tauri.ts): in the preview it rejects with a clear, actionable BROWSER_PREVIEW_MESSAGE instead of letting invoke throw a raw TypeError. Compute sidecar (apiClient), serial bridge (marlin-api), and file bridge (commands) all route through it; backend-health reuses the shared constant.
  • Skip the auto port-probe on Machine-tab entry when there's no backend → no unsolicited error on entry.
  • Status dot gets its own preview treatment (info blue) instead of reusing red unavailable. cliText → backendText.
  • Moved components/machine/BackendHealthWarning.svelte → shell/BackendStatusBanner.svelte (app-scoped, covers info + warning).
  • Test setup defaults __TAURI_INTERNALS__ so isTauri() resolves true by default (the app's primary runtime); the backend-health suite still manages the global for its preview-path test.

Verification

  • lint:css, lint:css:vars, check:svelte (0 errors), tsc, 316/316 tests ✓
  • Live Chrome QA (browser preview): Machine-tab entry shows the clean "No log entries yet" empty state (no error); user-initiated refresh shows "Browser preview — no backend. Run npm run tauri dev…" in toast + log; status dot is blue. Screenshots confirm.

The backend-less browser preview leaked raw
"Cannot read properties of undefined (reading 'invoke')" TypeErrors and
rendered an error-toned status dot, treating an expected dev state as a failure.

- Add invokeBackend() in lib/tauri.ts: in the browser preview it rejects with a
  clear, actionable message (BROWSER_PREVIEW_MESSAGE) instead of letting invoke
  throw a raw TypeError. Route the compute sidecar (apiClient), serial bridge
  (marlin-api), and file bridge (commands) through it. backend-health reuses the
  shared message constant.
- Skip the auto port-probe on Machine-tab entry when there is no backend, so the
  preview no longer surfaces an unsolicited error toast + log line on entry.
- Give the status-bar dot its own "preview" treatment (info blue via
  --status-info-fg) instead of reusing the red "unavailable" status, matching
  the info-tone banner. Rename the stale cliText -> backendText.
- Move components/machine/BackendHealthWarning.svelte to
  shell/BackendStatusBanner.svelte (it is app-scoped and covers both the info
  and warning states, not machine-only) and rename accordingly.
- Default __TAURI_INTERNALS__ in the test setup so isTauri()/invokeBackend
  resolve true by default (the app's primary runtime); the backend-health suite
  still manages the global itself for its browser-preview path.

User-initiated backend actions now show the clear message; auto actions stay
silent. Part of #246. Closes #249.
@CameronBrooks11
CameronBrooks11 merged commit e3f3af3 into main Jun 27, 2026
18 checks passed
@CameronBrooks11
CameronBrooks11 deleted the feat/249-browser-preview-state branch June 27, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GUI: model browser-preview as a first-class state

1 participant