Skip to content

feat(gui): Svelte file operations + toasts (#217) - #225

Merged
CameronBrooks11 merged 1 commit into
mainfrom
feat/svelte-fileops
Jun 26, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
feat/svelte-fileops

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Closes #217 (the file-operations half; the editing half landed in #224). Part of epic #214 (strangler-on-main: React still ships; Svelte stays behind the dev-only entry and out of vite build — unchanged at 595.75 kB).

What changed

  • File operations — src/services/file-operations.svelte.ts: newProject / openProject / openRecent / saveProject / saveProjectAs / exportGcode, ported from the React createFileOperations against projectSession. Reuses the existing commands (saveWindFile / loadWindFile / planWind), @tauri-apps/plugin-dialog, the WindDefinitionSchema runtime validation, and recentFiles unchanged.
    • Dirty prompt preserved: new/open/openRecent ask before discarding unsaved changes; a declined prompt or cancelled dialog leaves the document untouched; a failed save does not clear dirty (markSaved only on success).
    • Divergence from React (deliberate): the service notifies via toast + returns false instead of throwing across the event-handler boundary — no unhandled rejections from menu/keyboard handlers (the menu run() and the keyboard helper also swallow stray dialog rejections).
  • Toasts pulled forward (a file-ops dependency for feedback) — notifications.svelte.ts runes store (replaces the Zustand toast store) + Toasts.svelte renderer, wired into App.svelte. (This is the toast portion of Migrate dialogs, toasts, chrome & theme to Svelte #220, done early; the dialogs/theme remain in Migrate dialogs, toasts, chrome & theme to Svelte #220.)
  • Menu + keyboard wiring — File (New/Open/Save/Save As/Export) and Edit (Duplicate/Delete selected layer) menu items are now enabled and wired; keyboard shortcuts Ctrl/Cmd+N/O/S, +Shift+S, +E, +D and Delete (skipped while typing in a field, matching the React app).
  • Domain/state split — ProjectDocument + createEmptyDocument extracted to a plain src/types/document.ts so tsc-checked modules (converters, the service) share the type; the runes session re-exports them. Added windDefinitionToDocument (reuses convertWindSchemaToLayer).

Verification

  • Local gate green: tsc, svelte-check (0/0), 693 vitest tests (+13: 9-case file-ops service, notifications, converter round-trip, menu wiring), coverage 82.2/72.3/80.8/81.8 (> 60/65/50/60), stylelint, lint:css:vars, vite build, bundle budget.
  • Production bundle unchanged at 595.75 kB (the service, notifications, Toasts, and the newly-imported @tauri-apps/plugin-dialog are all out of the rollup input).
  • Not browser-verifiable (file dialogs need the Tauri runtime) — covered by the mocked-boundary service tests: save/saveAs/open/export, dirty-prompt accept+decline, save-failure-keeps-dirty, dialog-cancel-no-write.
  • Adversarially reviewed before commit (findings folded in).

Notes for reviewers

Closes #217. Part of #214.

Closes #217 (file-operations half; editing landed in #224). Part of epic #214,
strangler-on-main: React still ships; Svelte stays behind the dev-only entry and
out of the production bundle (unchanged at 595.75 kB).

- file-operations.svelte.ts: new/open/openRecent/save/saveAs/exportGcode against
  projectSession, reusing commands (save/load/planWind), @tauri-apps/plugin-dialog,
  WindDefinitionSchema validation, and recentFiles. Dirty prompt preserved; a
  failed save keeps the doc dirty; declined prompt / cancelled dialog leave it
  untouched. Errors notify + return false (no unhandled rejections from handlers).
- notifications.svelte.ts runes store + Toasts.svelte renderer (self-contained
  scoped styles), replacing the Zustand toastStore + ToastContainer; wired into
  App.svelte. (Toast portion of #220, brought forward as a file-ops dependency.)
- MenuBar File/Edit items enabled + wired; keyboard shortcuts Ctrl/Cmd+N/O/S,
  +Shift+S, +E, +D, Delete (skipped while typing; Alt excluded so AltGr is safe).
- Domain/state split: ProjectDocument + createEmptyDocument extracted to a plain
  types/document.ts (shared by tsc-checked modules); added windDefinitionToDocument.

696 tests; coverage 83.0/72.6/81.7/82.x. Adversarially reviewed (a toast-styling
defect — the Svelte entry never imported ToastContainer.css — caught and fixed
with self-contained scoped styles + a Toasts render test).

Closes #217. Refs #214
@CameronBrooks11 CameronBrooks11 added the gui Pull requests that update GUI components label Jun 26, 2026
@CameronBrooks11
CameronBrooks11 merged commit 4e986f6 into main Jun 26, 2026
18 checks passed
@CameronBrooks11
CameronBrooks11 deleted the feat/svelte-fileops branch June 26, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gui Pull requests that update GUI components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate project & layer editing to Svelte (editors, native reorder, file ops, export)

1 participant