-
Notifications
You must be signed in to change notification settings - Fork 16
Folder/ZIP bundle grouping, multi-model preview, and Send to Slicer #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes contributed via pull request are documented in this file. | ||
|
|
||
| ## [Unreleased] | ||
|
|
||
| ### Added | ||
|
|
||
| - **Folder and ZIP bundle grouping** — When scanning, models that share the same parent folder or the same ZIP archive (2+ files) are grouped into a single row in List, Preview, and Detailed views. Single-file folders stay as individual entries. | ||
| - **Bundle 3D preview** — Click a folder or ZIP bundle to open one preview dialog showing every STL/3MF part laid out on a grid, with per-part colors for clarity. Up to 32 previewable parts per bundle. | ||
| - **Bundle details panel** — Double-click a bundle (or use **Open 3D preview** from the panel) to see path, combined size, print status, and a sortable file list. Chevron still expands/collapses the bundle in the grid. | ||
| - **Send to Slicer in preview** — The 3D preview dialog includes a **Send to Slicer** button. Works for single models and full bundles (all STL/3MF paths). If multiple slicers are configured, a picker is shown. | ||
| - **New slicer instance on send** — macOS launches slicers with `open -n` so a new window opens even when the slicer is already running. Prusa-family binaries also receive `--single-instance=0` when launched directly. | ||
| - **`bundle-keys.js`** — Shared logic to derive `bundleKey`, `bundleLabel`, and `bundleKind` from file paths (including `zipPath::entry` paths). | ||
| - **`npm run test:bundle`** — Unit tests for bundle key derivation. | ||
|
|
||
| ### Changed | ||
|
|
||
| - Scan insert/update and `saveModel` persist bundle metadata (`bundleKey`, `bundleLabel`, `bundleKind`) with automatic migration on startup. | ||
| - Context menu **Open in Slicer** and preview **Send to Slicer** share the same launch helper (`buildSlicerLaunchCommand` / `open-file-in-slicer` IPC). | ||
| - `window.openSlicerSettings` is exposed from `slicer.js` for use from the preview flow. | ||
|
|
||
| ### Database | ||
|
|
||
| - New optional columns on `models`: `bundleKey`, `bundleLabel`, `bundleKind` (backfilled on existing databases). |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /** | ||
| * Derive folder / zip bundle identity from a model filePath. | ||
| * Shared by main process (scan, save) and tests. | ||
| */ | ||
| const path = require('path'); | ||
|
|
||
| function normalizePath(filepath) { | ||
| return String(filepath || '').replace(/\\/g, '/'); | ||
| } | ||
|
|
||
| /** | ||
| * @param {string} filePath | ||
| * @returns {{ bundleKey: string, bundleLabel: string, bundleKind: string }} | ||
| */ | ||
| function deriveBundleFromFilePath(filePath) { | ||
| const empty = { bundleKey: '', bundleLabel: '', bundleKind: '' }; | ||
| if (!filePath || typeof filePath !== 'string') return empty; | ||
| if (filePath.startsWith('url::')) return empty; | ||
|
|
||
| if (filePath.includes('::')) { | ||
| const zipPath = filePath.split('::')[0]; | ||
| const normalized = normalizePath(zipPath); | ||
| if (!normalized) return empty; | ||
| const label = path.basename(normalized) || normalized; | ||
| return { | ||
| bundleKey: `zip:${normalized.toLowerCase()}`, | ||
| bundleLabel: label, | ||
| bundleKind: 'zip', | ||
| }; | ||
| } | ||
|
|
||
| const dir = path.dirname(filePath); | ||
| const normalizedDir = normalizePath(dir); | ||
| if (!normalizedDir || normalizedDir === '.' || normalizedDir === '/') { | ||
| return empty; | ||
| } | ||
| const label = path.basename(normalizedDir) || normalizedDir; | ||
| return { | ||
| bundleKey: `folder:${normalizedDir.toLowerCase()}`, | ||
| bundleLabel: label, | ||
| bundleKind: 'folder', | ||
| }; | ||
| } | ||
|
|
||
| module.exports = { | ||
| deriveBundleFromFilePath, | ||
| normalizePath, | ||
| }; | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #!/usr/bin/env node | ||
| 'use strict'; | ||
|
|
||
| const assert = require('assert'); | ||
| const { deriveBundleFromFilePath } = require('./bundle-keys'); | ||
|
|
||
| function test(name, fn) { | ||
| try { | ||
| fn(); | ||
| console.log(`ok ${name}`); | ||
| } catch (err) { | ||
| console.error(`FAIL ${name}:`, err.message); | ||
| process.exitCode = 1; | ||
| } | ||
| } | ||
|
|
||
| test('folder bundle from sibling STLs', () => { | ||
| const stem = deriveBundleFromFilePath('/Downloads/flower-model/stem.stl'); | ||
| const petal = deriveBundleFromFilePath('/Downloads/flower-model/petal.stl'); | ||
| assert.strictEqual(stem.bundleKind, 'folder'); | ||
| assert.strictEqual(stem.bundleLabel, 'flower-model'); | ||
| assert.strictEqual(stem.bundleKey, petal.bundleKey); | ||
| }); | ||
|
|
||
| test('zip bundle from archive entry', () => { | ||
| const entry = deriveBundleFromFilePath('C:\\Models\\flower.zip::parts/flower.stl'); | ||
| assert.strictEqual(entry.bundleKind, 'zip'); | ||
| assert.strictEqual(entry.bundleLabel, 'flower.zip'); | ||
| assert.ok(entry.bundleKey.startsWith('zip:')); | ||
| }); | ||
|
|
||
| test('url models have no bundle', () => { | ||
| const url = deriveBundleFromFilePath('url::https://example.com/model.stl'); | ||
| assert.strictEqual(url.bundleKey, ''); | ||
| }); | ||
|
|
||
| if (process.exitCode) { | ||
| process.exit(process.exitCode); | ||
| } |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎥 Observed in a test run
Folder grouping breaks on POSIX for Windows-style paths — separators aren't normalized before
path.dirname.The zip branch above normalizes first (
normalizePath(zipPath)on line 22, then derives), but the folder branch callspath.dirname(filePath)on the raw path and only normalizes the result. Whenpathresolves topath.posix(the Linux/Docker/server-bridgeruntime this repo ships),path.dirnamedoesn't treat\as a separator.I ran the shipped function under
path.posixwith a Windows-style path:path.dirnamereturns".", so the=== '.'guard on line 34 returnsemptyand the two siblings never group. This bitesmigrateBundleColumns()backfill (main.js:1811) and scan insert/update (main.js:2940) whenever the process runs on Linux against a DB populated with Windows paths — exactly the cross-platform / Docker scenario this repo supports. On a native Windows install (path.win32) it works, which is why the bug is easy to miss.The shipped tests pass but only cover a forward-slash folder path, so they never exercise this. Fix: normalize first, then derive, e.g.
so folder behavior is separator-independent, matching the zip branch.