Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ jobs:
# where the file is, the duplicate findings, the worklist suggestions
- name: Test the rules of new items from local files
run: node scripts/desktop-new-files.test.mjs
# files dropped on the window (#418): New, Add files… or a refusal
- name: Test the drop routing
run: node scripts/desktop-drop-route.test.mjs
# the mesh check of the shared 3D viewer: empty, cut-off or invalid
# models end in a message, not in an empty canvas (#290)
- name: Test the 3D viewer's mesh check
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ see the notices in the README.

### Added

- Desktop: drag and drop of files from Explorer, Finder or the file manager onto the window (#418). On a revision tab you have checked out (or that *Add files…* would check out) the drop opens *Add files…*; elsewhere it opens *New item* with the files. A frame shows what the drop does; frozen revisions, revisions checked out by someone else, viewers and editors without a group are refused with the reason. Only regular files are taken (folders are skipped), with the same checks as the file dialog. Tab reordering keeps working (pointer events, not HTML5 drag and drop).
- **Getting started in the desktop app** (#422): after the first sign-in
TeamCraft Desktop opens a short wizard – server (skipped when a policy fixes
it), sign-in, the working folder (*Change…*, *Open folder*), *Get project
Expand Down
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ desktop/ TeamCraft Desktop (Tauri 2, own Cargo project – never part
list-thumbs.js = row pictures of Home and the search (lazy, IntersectionObserver, #420),
crash.js = crash reports; desktop/src/workspace.rs + layout.rs = working folder, park, local changes;
new-files.js + desktop/src/newfiles.rs = new items from local files, worklist *New on this computer* (#359);
drop.js + drop-rules.js = files dropped from the file manager → *New* / *Add files…* (#418, dragDropEnabled);
desktop/src/localserver.rs = *Try TeamCraft on this computer* (starts the bundled teamcraft-server local);
desktop/src/policy.rs = managed deployment policies (registry / macOS profile / /etc/teamcraft, #378);
tauri.local-server.conf.json = the *with local server* installers (externalBin teamcraft-server + postgresql/)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ end-to-end tests against a real PostgreSQL.
project group (with *New item here* on every folder, starting in a favourite folder, e.g. the one with the
Inventor project file, if you like), a navigable *Graph* of every revision (BOM children,
references and where-used, coloured by state, with quantities and preview
images), *Park* of work in progress, new items straight from the files
images), *Park* of work in progress, files dropped from the file manager into *New*
or *Add files…*, new items straight from the files
saved in the working folder (group and folder taken from where they are,
duplicates refused, the worklist suggesting the parts and assemblies that
belong to no item yet), an Agent view, crash reports the user
Expand Down
3 changes: 2 additions & 1 deletion desktop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ TeamCraft server – it is a client, not an offline copy.
| Graph | A navigable reference/BOM graph around the revision: the focused item in the middle, its BOM children and references below, the assemblies that use it above. Node **colour** = lifecycle state, **size** and the ⚙ badge = the item's own BOM complexity, **×n in the top-left corner** = how many instances of that part or sub-assembly the assembly contains (summed over its BOM lines, ×1 included). Every node is clickable and takes the tab to that item – a sub-assembly shows its own graph, anything else its overview, the item in the middle its own overview – with a **back control that stays in the same place** (the left of the sub-tab row) and leads back the way you came, one step per click; `Ctrl`/`⌘`+click opens a node in a tab of its own. Mouse-wheel zooms on the cursor; drag to pan; the view fits itself while details load until you zoom or pan, a double-click on the background fits it again. More than 8 neighbours on one side are laid out in rows; above 48 only the first 48 are fetched for preview and complexity (one request each), the rest keep a basic card. Preview images and filenames on the nodes; pure SVG, no external engine |
| Working folder | One folder per project group that **mirrors the folder structure of the files** (`<workspace>/<group>/<folder>/<file>`, the folder is stored with every file on the server), one copy of each file – the revision is metadata in `<workspace>/.teamcraft/state.json` (item, revision, file id, version, SHA-256, checked out). Files you have not checked out are **read-only** on disk; *Check out* takes the lock and makes them writable; *Check in…* uploads the chosen files as new versions, releases the lock in one step and makes them read-only again (files above 32 MiB go first as chunked, resumable uploads, then join the same check-in transaction). The check-in dialog shows the progress, and **Cancel** stops the check-in until its last byte is sent – before the next STEP export, between two chunks (the upload sessions are discarded, `DELETE /uploads/{id}`) or half-way through the streamed request with the small files: nothing is stored, the revision stays checked out (`src/abortable.rs`). Every check-in names the version each file is based on, so the server refuses (409) to overwrite a version somebody else checked in meanwhile. The Workspace tab shows *up to date* / *modified* / *outdated* / *conflict* / *new* / *missing* / *name clash* per file (from the server's file status) with its path, read-only flag and the lock owner. Two items with the same folder and file name are reported, never overwritten. Lock and backup files of the CAD programs are skipped; a SolidCraft design that is open in SolidCraft (a fresh `.~<file>.lock` beside it, `src/cadlock.rs`) is marked *Open in SolidCraft* with the computer and user, and the check-in dialog warns that unsaved changes there are not checked in; Creo iterations count as one file. A tracked revision the server no longer shows (you left a restricted project group) is listed as *No longer accessible*: its local copies stay untouched and are never synced again – delete them yourself if you must In *Check in…*, a new part or assembly file next to a revision that has a model already is offered unticked, with *New item from this file* (#359) |
| Get | *Get…* on a revision: the item with its BOM (revision rule *latest* or *released*) and the parts its CAD files reference, resolved by the server (`…/workset`); only missing and outdated files are downloaded (SHA-256, checked after the download), recorded one by one so an interrupted Get continues where it stopped – also inside a large file: the bytes received stay in `<name>.<sha>.teamcraft-download` and the next Get asks only for the rest (`Range` / `If-Range`, `src/resume.rs`), checks the SHA-256 of the whole file and renames it into place; progress and *Cancel* in the status bar. No browser downloads |
| Add files | *Add files…* (Files section and *More ▾*): file picker → the files are **copied** into the working folder of the revision (checked out first if needed; sub-folder selectable, originals untouched) and listed as *new* in *Check in…* (option *Check in now*; remembered in `.teamcraft/added.json` until checked in). A name that exists is a new version and asks first. The Files section says why it is unavailable (locked by someone else, in review, released = frozen → Revise). Pure logic and tests in `src/addfiles.rs`; drag and drop onto the window is not supported (`dragDropEnabled` is off) |
| Add files | *Add files…* (Files section and *More ▾*): file picker → the files are **copied** into the working folder of the revision (checked out first if needed; sub-folder selectable, originals untouched) and listed as *new* in *Check in…* (option *Check in now*; remembered in `.teamcraft/added.json` until checked in). A name that exists is a new version and asks first. The Files section says why it is unavailable (locked by someone else, in review, released = frozen → Revise). Pure logic and tests in `src/addfiles.rs`; files dropped on an open revision tab take the same way (*Drop files*) |
| Drop files | Files dragged from Explorer, Finder or the file manager onto the window (#418; Tauri's native file drop, `dragDropEnabled` on the main window): on a revision tab you have checked out – or that *Add files…* would check out – they open *Add files…* with the dropped paths instead of the picker; elsewhere *New item* with the files chosen (as *Create item* of the worklist suggestions). A frame over the window says what the drop does; a revision that takes no files (released, in review, checked out by someone else), viewers, editors without a group and an open dialog refuse it with the reason. The routing is a pure function (`ui/js/drop-rules.js`, tested by `scripts/desktop-drop-route.test.mjs`), the listener `ui/js/drop.js`. Only regular files are taken: `dropped_files` leaves folders out (with a note), and `addfiles::plan` and `new_item_copy` refuse anything that is not a regular file. The tabs are moved with pointer events, not HTML5 drag and drop, so tab dragging is unaffected |
| Old workspaces | Folders of the older layout `<group>/<item>/<revision>/` (and `<item>/<revision>/`) are found after the sign-in; the app offers to move the files into the new layout – never overwriting a file, keeping files whose place is taken and listing them, writing every step to `.teamcraft/migration.log` |
| Check in all | *Check in all* in the worklist (navigator and home page): the check-outs with local changes (modified, new, conflicting files) are listed first, with the offer to check them in with their files; then every check-out without local changes is checked in on the server (lock released, one revision at a time); check-outs with a conflict stay checked out. *Sign out* asks the same: *Check in and sign out*, *Park and sign out*, *Sign out anyway*. The list is the pure `layout::local_changes` |
| Park | *Park…* (Workspace tab, *More ▾*, the check-in dialog): the ticked files go up as new versions through the upload endpoint (`POST …/files`) and the check-out **stays** – work in progress survives a lost laptop. After somebody else released your check-out, the Workspace tab shows *Released by X; your local changes are kept and need a new check-out* (`released` of the server's file status) |
Expand Down
49 changes: 49 additions & 0 deletions desktop/src/addfiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ pub fn plan(
let disk = source.file_name().and_then(|n| n.to_str()).ok_or_else(|| {
ApiError::local(format!("{} has no usable file name.", source.display()))
})?;
// picked or dropped from the file manager (#418): regular files only
if !is_regular_file(source) {
return Err(ApiError::local(format!(
"{disk} is not a file – folders and other entries cannot be added."
)));
}
if is_ignored(disk) {
return Err(ApiError::local(format!(
"{disk} is a temporary or backup file and cannot be added."
Expand Down Expand Up @@ -119,6 +125,28 @@ pub fn plan(
Ok(out)
}

/// A regular file (a symbolic link counts by what it points to); folders,
/// devices, pipes and paths that do not exist are not.
pub fn is_regular_file(path: &Path) -> bool {
std::fs::metadata(path).is_ok_and(|m| m.is_file())
}

/// Paths dropped on the window from the file manager (#418), split into the
/// regular files (in their order, each once) and the number of entries
/// left out – folders and everything else that is not a regular file.
pub fn split_dropped(paths: &[PathBuf]) -> (Vec<PathBuf>, usize) {
let mut files: Vec<PathBuf> = Vec::new();
let mut skipped = 0;
for path in paths {
if !is_regular_file(path) {
skipped += 1;
} else if !files.contains(path) {
files.push(path.clone());
}
}
(files, skipped)
}

fn same_file(a: &Path, b: &Path) -> bool {
match (a.canonicalize(), b.canonicalize()) {
(Ok(a), Ok(b)) => a == b,
Expand Down Expand Up @@ -398,6 +426,27 @@ mod tests {
plan(ws.path(), None, &[], "", &[a.clone(), a.clone()], "").is_err(),
"picked twice"
);
// a dropped folder or a path that is gone is not a file (#418)
let folder = src.path().join("assembly");
std::fs::create_dir(&folder).unwrap();
let err = plan(ws.path(), None, &[], "", &[folder], "").unwrap_err();
assert!(err.to_string().contains("not a file"), "{err}");
let gone = src.path().join("gone.step");
assert!(plan(ws.path(), None, &[], "", &[gone], "").is_err());
}

#[test]
fn dropped_paths_keep_regular_files_only() {
let src = tempfile::tempdir().unwrap();
let a = write(src.path(), "a.step", "1");
let b = write(src.path(), "b.ipt", "2");
let folder = src.path().join("parts");
std::fs::create_dir(&folder).unwrap();
let gone = src.path().join("gone.prt");
let (files, skipped) = split_dropped(&[b.clone(), folder, a.clone(), gone, b.clone()]);
assert_eq!(files, [b, a], "in order, each once");
assert_eq!(skipped, 2);
assert_eq!(split_dropped(&[]), (Vec::new(), 0));
}

#[test]
Expand Down
26 changes: 26 additions & 0 deletions desktop/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,12 @@ pub async fn new_item_copy(
let disk = src.file_name().and_then(|n| n.to_str()).ok_or_else(|| {
ApiError::local(format!("{} has no usable file name.", src.display()))
})?;
// picked or dropped from the file manager (#418): regular files only
if !addfiles::is_regular_file(&src) {
return Err(ApiError::local(format!(
"{disk} is not a file – nothing was copied."
)));
}
let rel = layout::local_rel(Some(group), &folder, &layout::nfc(disk));
let dst = layout::join_rel(&root, &rel);
if dst == src {
Expand Down Expand Up @@ -2521,6 +2527,26 @@ pub async fn pick_files(app: AppHandle) -> CmdResult<Vec<PathBuf>> {
.map_err(|e| ApiError::local(format!("The file dialog failed: {e}")))
}

/// Files dropped on the window from the file manager (#418): the regular
/// files among the dropped paths and how many entries (folders, anything
/// that is not a regular file) were left out. The paths then take the same
/// way as picked ones – *New* or *Add files…* with all their checks.
#[derive(Serialize)]
pub struct DroppedFiles {
pub files: Vec<PathBuf>,
pub skipped: usize,
}

#[tauri::command]
pub async fn dropped_files(paths: Vec<PathBuf>) -> CmdResult<DroppedFiles> {
tokio::task::spawn_blocking(move || {
let (files, skipped) = addfiles::split_dropped(&paths);
DroppedFiles { files, skipped }
})
.await
.map_err(|e| ApiError::local(format!("The dropped files could not be read: {e}")))
}

/// *Add files…*: what copying `paths` into the working folder would do
/// (which names become new versions or replace a local file).
#[tauri::command]
Expand Down
1 change: 1 addition & 0 deletions desktop/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ fn main() {
commands::workspace_park,
commands::workspace_local_changes,
commands::pick_files,
commands::dropped_files,
commands::workspace_add_plan,
commands::workspace_add_files,
commands::workspace_open,
Expand Down
2 changes: 1 addition & 1 deletion desktop/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"minWidth": 980,
"minHeight": 620,
"center": true,
"dragDropEnabled": false
"dragDropEnabled": true
}
],
"security": {
Expand Down
24 changes: 24 additions & 0 deletions desktop/ui/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,30 @@ canvas.viewer-measuring { cursor: crosshair; }
.toast.info { box-shadow: inset 3px 0 0 var(--link), var(--shadow-pop); }
.toast.info::before { content: "i"; color: var(--link); }

/* Files dragged from the file manager over the window (#418, js/drop.js):
a dashed frame over the whole window with what the drop does; a refusal
(viewer, frozen revision, checked out by someone else) in the danger colour.
The overlay never takes pointer events – the native drop reports to Tauri. */
.drop-overlay {
position: fixed; inset: 8px; z-index: 55;
display: none; place-items: center; padding: 24px;
pointer-events: none;
background: var(--backdrop);
border: 2px dashed var(--accent);
border-radius: var(--radius-lg);
}
body.drop-target .drop-overlay { display: grid; }
.drop-overlay-text {
margin: 0; max-width: 520px; padding: 12px 16px;
color: var(--text); text-align: center;
background: var(--surface);
border: 1px solid var(--border-strong);
border-radius: var(--radius);
box-shadow: inset 3px 0 0 var(--accent), var(--shadow-pop);
}
body.drop-refused .drop-overlay { border-color: var(--st-danger-fg); }
body.drop-refused .drop-overlay-text { box-shadow: inset 3px 0 0 var(--st-danger-fg), var(--shadow-pop); }

@media (prefers-reduced-motion: reduce) {
/* fades stay, movement goes */
.dialog, .toast, .toast.leaving { transform: none; }
Expand Down
Loading
Loading