Skip to content

Add reliable programmatic model load and save behavior - #16

Draft
burhop wants to merge 1 commit into
mmiscool:masterfrom
burhop:agent/programmatic-load-save-errors
Draft

Add reliable programmatic model load and save behavior#16
burhop wants to merge 1 commit into
mmiscool:masterfrom
burhop:agent/programmatic-load-save-errors

Conversation

@burhop

@burhop burhop commented Jul 27, 2026

Copy link
Copy Markdown

Summary

This change makes the existing embedded CAD API reliable for programmatic model loading and saving:

  • missing or invalid model loads reject with useful errors instead of opening a blocking alert() and returning;
  • CadEmbed.saveCurrentTo() saves to an explicit destination without dialogs or window.confirm();
  • save conflicts, explicit overwrite, cancellation, persistence verification, and rollback are handled deterministically;
  • timed-out or aborted requests cancel the frame-side operation so they cannot write later;
  • the existing interactive toolbar save behavior remains unchanged.

Why each file changed

  • src/UI/cad/CadEmbed.ts — exposes saveCurrentTo(), accepts cancellation, sends cancel messages on abort/timeout, and cleans up pending requests.
  • src/UI/cad/CadFrameApp.ts — routes explicit save requests, owns a per-request AbortController, and cancels frame-side work when requested or disposed.
  • src/UI/fileManagerWidget.ts — adds the non-interactive save path with explicit conflict/overwrite behavior, verification, and rollback; programmatic load failures now reject instead of displaying alerts.
  • src/UI/cad/nonInteractiveSave.ts — isolates destination validation, abort handling, persistence verification, and rollback logic.
  • src/services/modelLoadErrors.ts — provides consistent errors for missing and invalid model records.
  • apiExamples/Embeded_CAD_Integration_Test.ts — covers explicit save, conflicts, overwrite, cancellation, ghost-write prevention, and pending-request cleanup in the browser.
  • scripts/nonInteractiveSave.test.ts — covers save validation, destination planning, cancellation, verification, and rollback without requiring the full browser toolchain.
  • src/tests/test_file_manager_programmatic_load_errors.ts — verifies a missing programmatic model load rejects without calling alert().
  • src/tests/tests.ts — registers the load-error regression test in the existing Node/browser harness.
  • docs/developer/embedding/cad-embed.md — documents the interactive and non-interactive save APIs, options, results, cancellation, and rollback behavior.

Compatibility and scope

  • The existing interactive saveCurrent() toolbar behavior is preserved.
  • No geometry, feature, topology, serialization, or rendering behavior changes.
  • No dependency or lockfile changes.
  • No server, protocol, headless packaging, or platform bootstrap changes.
  • The new embedding save method is additive.

Validation

  • pnpm install --frozen-lockfile — passed
  • pnpm typecheck — passed
  • changed-file ESLint — passed
  • node --import tsx --test ./scripts/nonInteractiveSave.test.ts — 6/6 passed
  • pnpm exec tsx ./src/tests/tests.ts test_file_manager_missing_model_rejects_without_alert — passed
  • pnpm exec vite build --config vite.config.kernel.ts — passed
  • CadEmbed browser integration — 25 passed, 1 optional load test skipped because no model path was supplied
  • http://127.0.0.1:5196/ — HTTP 200 during validation
  • http://127.0.0.1:5196/src/CAD.ts — HTTP 200 during validation

The repository-wide pnpm lint command still reports the pre-existing no-unreachable error in unchanged scripts/capture.ts:1149; this PR does not modify that file. The contributor has reviewed and accepted the repository license's pull-request copyright-assignment condition.

Reject missing or invalid programmatic model loads without blocking alerts. Add explicit, cancellable saves with conflict handling, verification, rollback, browser coverage, and documentation.
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.

1 participant