Add reliable programmatic model load and save behavior - #16
Draft
burhop wants to merge 1 commit into
Draft
Conversation
Reject missing or invalid programmatic model loads without blocking alerts. Add explicit, cancellable saves with conflict handling, verification, rollback, browser coverage, and documentation.
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.
Summary
This change makes the existing embedded CAD API reliable for programmatic model loading and saving:
alert()and returning;CadEmbed.saveCurrentTo()saves to an explicit destination without dialogs orwindow.confirm();Why each file changed
src/UI/cad/CadEmbed.ts— exposessaveCurrentTo(), 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-requestAbortController, 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 callingalert().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
saveCurrent()toolbar behavior is preserved.Validation
pnpm install --frozen-lockfile— passedpnpm typecheck— passednode --import tsx --test ./scripts/nonInteractiveSave.test.ts— 6/6 passedpnpm exec tsx ./src/tests/tests.ts test_file_manager_missing_model_rejects_without_alert— passedpnpm exec vite build --config vite.config.kernel.ts— passedhttp://127.0.0.1:5196/— HTTP 200 during validationhttp://127.0.0.1:5196/src/CAD.ts— HTTP 200 during validationThe repository-wide
pnpm lintcommand still reports the pre-existingno-unreachableerror in unchangedscripts/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.