Skip to content

Fix desktop STL download: native Save As instead of dead HTTP route#1

Merged
deehw merged 1 commit into
mainfrom
fix/desktop-stl-download-native-save
Jun 2, 2026
Merged

Fix desktop STL download: native Save As instead of dead HTTP route#1
deehw merged 1 commit into
mainfrom
fix/desktop-stl-download-native-save

Conversation

@deehw

@deehw deehw commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Problem

Downloading an STL from the packaged desktop app produced a file BambuLab Studio rejected with "the file doesn't contain any geometry data" — even though the on-disk STLs are valid (verified: real facets, real geometry).

Root cause: the download went through /__cad/download, a dev-only Vite/Node middleware route that isn't served in the packaged app (only the pandaasset:// scheme is registered in Rust). The <a download> therefore saved a 404/SPA-HTML response renamed .stl, which slicers read as empty geometry. Works in scripts/dev.sh (Vite serves the route), fails only when bundled.

Fix

Files already live locally, so a download is just a local-to-local copy. New file_save IPC command:

  • Resolves the source under the open project via resolve_in_project (rejects .. traversal).
  • Shows the native Save As dialog (tauri-plugin-dialog, already wired in).
  • Copies bytes with fs::copy. Never touches the source; the OS dialog handles overwrite confirmation. Returns the chosen path, or null on cancel.

The desktop download path now calls file_save; browser/hosted backends keep the HTTP path since the file isn't local there.

Verification

  • cargo test commands::files — 6 pass (incl. 4 new: path-escape rejection, name/ext derivation, missing-file).
  • cargo build clean; viewer build typechecks; transport + download test files pass directly (npm test runner is broken by an unrelated Node 24.6 flag removal).
  • ⚠️ Not yet smoke-tested in a packaged build — worth a manual check: right-click a part → Download → save → open in Bambu.

Out of scope

The assembly (product) still emits no product.stl — only individual parts do. Separate gap if whole-product printing is expected.

🤖 Generated with Claude Code

Downloads went through /__cad/download, a dev-only Vite/Node middleware
route that isn't served in the packaged app (only the pandaasset:// scheme
is registered). The <a download> therefore saved a 404/SPA-HTML response
renamed .stl, which slicers reject as "no geometry data" — even though the
on-disk STLs are valid.

Files already live locally, so a download is just a local-to-local copy.
Add a file_save IPC command that resolves the source under the open project
(rejecting `..`), shows the native Save As dialog, and copies the bytes —
no HTTP round-trip, no loading the file into JS. The desktop download path
now calls it; browser/hosted backends keep the HTTP path since the file
isn't local there.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@deehw deehw merged commit f3e1417 into main Jun 2, 2026
3 checks passed
@deehw deehw deleted the fix/desktop-stl-download-native-save branch June 2, 2026 05:44
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