From a6dc3cfdc2b794a31c9b8fce1457525866074650 Mon Sep 17 00:00:00 2001 From: fork Date: Sun, 22 Nov 2026 20:15:00 +0100 Subject: [PATCH 1/2] Desktop: one "Local changes" list for the whole working folder (#416) A worklist section next to "New on this computer" lists every file of the working folder that is modified, outdated, in conflict, new or missing, grouped by item - also a file changed without a check-out - with Check out (keep my file), Get latest, Check in selected, Merge and Folder per row and for the ticked rows. The count joins the worklist badge on the rail. desktop/src/localchanges.rs: a local pass over state.json (no network, bounded by the limits of New on this computer and a hash budget), then the Workspace status of at most 100 revisions (local changes first, then own check-outs); pure classify() with unit tests. Command local_changes_scan. desktop/ui/js/local-changes.js: the pure planner, tested by scripts/desktop-local-changes.test.mjs (CI job ui). Co-Authored-By: Claude Opus 5.5 --- .github/workflows/desktop.yml | 4 + CHANGELOG.md | 20 + README.md | 4 +- desktop/README.md | 1 + desktop/src/commands.rs | 19 +- desktop/src/localchanges.rs | 701 +++++++++++++++++++++++++ desktop/src/main.rs | 2 + desktop/ui/app.css | 2 +- desktop/ui/js/local-changes.js | 146 +++++ desktop/ui/js/navigator.js | 189 ++++++- desktop/ui/js/shell.js | 47 +- docs/OPEN_WORK.md | 3 +- docs/src/guide/desktop.md | 25 + scripts/ci-changes.sh | 2 + scripts/desktop-local-changes.test.mjs | 131 +++++ 15 files changed, 1281 insertions(+), 15 deletions(-) create mode 100644 desktop/src/localchanges.rs create mode 100644 desktop/ui/js/local-changes.js create mode 100644 scripts/desktop-local-changes.test.mjs diff --git a/.github/workflows/desktop.yml b/.github/workflows/desktop.yml index 0a792851..1a76d889 100755 --- a/.github/workflows/desktop.yml +++ b/.github/workflows/desktop.yml @@ -107,6 +107,10 @@ 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 + # *Local changes* over the whole working folder (#416): grouping by + # item and the actions per file and per selection + - name: Test the rules of the Local changes list + run: node scripts/desktop-local-changes.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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bb48d14..55ac227f 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,26 @@ see the notices in the README. ## [Unreleased] +### Added + +- **Desktop: one *Local changes* list for the whole working folder** (#416): + a worklist section next to *New on this computer* lists every file of the + working folder that is modified, outdated, in conflict, new (a companion + such as a STEP export) or missing, grouped by item – also a file changed + after clearing its read-only flag without a check-out, and files outdated + because somebody checked in a newer version, without opening their item. + Each row and each selection offers *Check out (keep my file)*, *Get latest*, + *Check in selected* (the *Check in all* flow), *Merge…* for a conflict and + *Folder*. The count joins the worklist badge on the rail. The scan + (`local_changes_scan`, `desktop/src/localchanges.rs`) compares + `state.json` with the disk first (no network; unchanged files are never + read, at most 512 MiB hashed per scan) and then the Workspace status of at + most 100 revisions (local changes first, then own check-outs); it runs when + the worklist opens, when the window gets the focus back (at most every + 15 s) and after a check-out, check-in or Get. The list rules are in + `desktop/ui/js/local-changes.js`, tested by + `scripts/desktop-local-changes.test.mjs`. + ## [0.2.12] - 2026-11-22 ### Security diff --git a/README.md b/README.md index 6b9bde78..1857d73f 100755 --- a/README.md +++ b/README.md @@ -313,7 +313,9 @@ end-to-end tests against a real PostgreSQL. images), *Park* of work in progress, 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 + belong to no item yet), a *Local changes* list of the whole working folder + (modified, outdated, conflicting and missing files with *Check out (keep my + file)*, *Get latest* and *Check in selected*), an Agent view, crash reports the user decides about and an update notice (never installs anything itself). The download *with local server* also runs a private test server with its own database on the laptop (*Try TeamCraft on this computer*). diff --git a/desktop/README.md b/desktop/README.md index 3491c674..fcdc84bd 100755 --- a/desktop/README.md +++ b/desktop/README.md @@ -1,3 +1,4 @@ +| Local changes | Worklist section (#416): every file of the working folder that is modified, outdated, in conflict, new (a companion of a tracked file) or missing, grouped by item, counted on the rail – also a file changed without a check-out (read-only flag cleared, *not checked out*). Per row and for the ticked rows: *Check out* (keep my file, `workspace_checkout`), *Get latest* (`workspace_download`, local changes kept), *Check in selected* (`sendLocalChanges` of *Check in all*, conflicts stay checked out), *Merge…* (Workspace tab), *Folder*. The scan (`desktop/src/localchanges.rs`, `local_changes_scan`) first compares `.teamcraft/state.json` with the disk (no network, at most 50 000 entries, unchanged files not read, at most 512 MiB hashed), then runs the Workspace status (`workspace::status`) of at most 100 revisions one after the other – local changes first, then own check-outs; the first failing call stops that pass. Run when the worklist opens, on window focus (at most every 15 s) and after check-out, check-in or Get. Rules in `ui/js/local-changes.js` (`scripts/desktop-local-changes.test.mjs`) | A failed export never stops the check-in: the file goes without its STEP and the result says why. With exports the ticked files are uploaded first (parked), then exported, then checked in with the STEP files; *Cancel* during an export skips it and ends the CAD program the script started (`teamcraft-started-pid:` line, `taskkill`); rejected COM calls (`RPC_E_CALL_REJECTED`, `RPC_E_SERVERCALL_RETRYLATER`) are retried for a minute; the whole error output goes to `/export-logs/` (newest 20, 64 KiB each, local only) – #342 |# TeamCraft Desktop The rich client of TeamCraft for **Linux, macOS and Windows**: a navigation diff --git a/desktop/src/commands.rs b/desktop/src/commands.rs index d55a5a99..f6fcf635 100755 --- a/desktop/src/commands.rs +++ b/desktop/src/commands.rs @@ -20,8 +20,8 @@ use tokio::sync::Notify; use crate::{ acp, addfiles, api::{self, Api, ApiError, Transfer}, - bomimport, cadexport, cadlaunch, folderimport, layout, localserver, policy, profiles, scbridge, - scprops, + bomimport, cadexport, cadlaunch, folderimport, layout, localchanges, localserver, policy, + profiles, scbridge, scprops, settings::{self, Settings, TokenStorage}, signin, update, workspace, AppState, }; @@ -914,6 +914,21 @@ pub async fn workspace_local_changes( Ok(layout::local_changes(results)) } +/// *Local changes* (#416): the modified, outdated, conflicting, new and +/// missing files of every revision in the working folder – a local pass over +/// the state, then the Workspace status of at most +/// [`localchanges::MAX_REVISIONS`] revisions (`src/localchanges.rs`). Unlike +/// [`workspace_status`] it writes no SolidCraft bridge state per revision. +#[tauri::command] +pub async fn local_changes_scan( + app: AppHandle, + state: State<'_, AppState>, +) -> CmdResult { + let api = signed_in_api(&state)?; + let root = workspace_root(&app, &state); + localchanges::scan(&api, &root).await +} + /// A fresh cancel switch for the upload that starts now (`cancel_upload` /// flips the switch of the running one). fn new_upload(state: &State<'_, AppState>) -> Arc { diff --git a/desktop/src/localchanges.rs b/desktop/src/localchanges.rs new file mode 100644 index 00000000..c78033cb --- /dev/null +++ b/desktop/src/localchanges.rs @@ -0,0 +1,701 @@ +//! *Local changes* (#416): one list over the whole working folder – the +//! files of every revision the working folder tracks that are **modified**, +//! **outdated**, in **conflict**, **new** (a companion of a tracked file, as +//! the STEP export next to a part) or **missing**, grouped by revision. +//! +//! Two passes, both bounded so a huge folder never blocks the app: +//! +//! 1. A **local pass** without the network ([`local_pass`]): every entry of +//! `.teamcraft/state.json` (at most `newfiles::MAX_ENTRIES`, the limits of *New on this computer*) is compared +//! with the disk. A file that is gone is *missing*; a file whose size +//! differs is *modified*; a file with the same size but another +//! modification time is hashed (at most [`MAX_HASH_BYTES`] per scan, the +//! rest counts as modified until the server pass looks) and *modified* if +//! its SHA-256 differs from the base. An unchanged file is never read. +//! 2. A **server pass** ([`scan`]): the Workspace status of one revision +//! after the other (`workspace::status`, the same as the Workspace tab), +//! at most [`MAX_REVISIONS`] – revisions with a local change first, then +//! my check-outs, then the rest. Only this pass knows *outdated* (a newer +//! version on the server than the base) and *conflict* (changed here and +//! on the server). The first failing call (server unreachable, signed out) +//! stops the pass; the revisions not compared keep what the local pass +//! found and say so (`compared` false). +//! +//! [`classify`] puts both together; it is pure and unit-tested. Nothing is +//! uploaded or downloaded here: the actions of the list (*Check out (keep my +//! file)*, *Get latest*, *Check in selected*) are the commands the Workspace +//! tab uses (`ui/js/local-changes.js`). + +use std::{ + collections::{BTreeMap, HashMap}, + io::Read, + path::{Path, PathBuf}, + time::UNIX_EPOCH, +}; + +use serde::Serialize; +use sha2::{Digest, Sha256}; + +use crate::{ + api::{Api, ApiError}, + layout::{self, Entry, State}, + newfiles::Limits, + workspace, +}; + +/// Revisions the server pass compares at most per scan. +pub const MAX_REVISIONS: usize = 100; +/// Bytes the local pass hashes at most per scan (files with the same size +/// but a new modification time); beyond it a file counts as modified. +pub const MAX_HASH_BYTES: u64 = 512 * 1024 * 1024; + +/// The file states the list shows (everything but `up_to_date`, `clash` and +/// `inaccessible`). +pub const SHOWN: [&str; 5] = ["modified", "outdated", "conflict", "new", "missing"]; + +/// A revision: `(project, item, revision)`, compared ignoring case. +pub type RevKey = (String, String, String); + +fn key_of(project: Option<&str>, item: &str, revision: &str) -> RevKey { + ( + project.unwrap_or("").to_lowercase(), + item.to_lowercase(), + revision.to_lowercase(), + ) +} + +/// What the local pass found for one tracked file. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct Disk { + /// The file is in the working folder. + pub exists: bool, + /// Its content differs from the base (or could not be checked). + pub modified: bool, + /// The file is writable (not read-only). + pub writable: bool, +} + +/// One file of a revision as the server pass (Workspace status) saw it. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ServerFile { + pub name: String, + pub path: String, + pub state: String, + pub server_version: Option, + pub base_version: Option, + pub read_only: bool, +} + +/// One revision as the server pass saw it. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ServerRevision { + pub locked_by_me: bool, + pub inaccessible: bool, + pub dir: PathBuf, + pub files: Vec, +} + +impl From<&workspace::Status> for ServerRevision { + fn from(s: &workspace::Status) -> ServerRevision { + ServerRevision { + locked_by_me: s.locked_by_me, + inaccessible: s.inaccessible, + dir: s.dir.clone(), + files: s + .files + .iter() + .map(|f| ServerFile { + name: f.name.clone(), + path: f.path.clone(), + state: f.state.clone(), + server_version: f.server_version, + base_version: f.base_version, + read_only: f.read_only, + }) + .collect(), + } + } +} + +/// A file of the list. +#[derive(Clone, Debug, PartialEq, Eq, Serialize)] +pub struct ChangedFile { + /// Name on the server. + pub name: String, + /// Relative path in the working folder. + pub path: String, + /// `modified`, `outdated`, `conflict`, `new` or `missing`. + pub state: String, + pub server_version: Option, + /// The server version the local copy came from, if known. + pub base_version: Option, + pub writable: bool, + /// Changed here although the revision is not checked out by me (a file + /// whose read-only flag was cleared): *Check out (keep my file)*. + pub without_checkout: bool, +} + +/// A revision with at least one file of the list (or an error). +#[derive(Clone, Debug, PartialEq, Eq, Serialize)] +pub struct RevisionChanges { + pub project: Option, + pub item: String, + pub code: String, + /// The revision is checked out by me (server pass) or was when its files + /// were last written (local pass). + pub checked_out: bool, + /// The server pass compared it: `outdated` and `conflict` are known. + pub compared: bool, + /// The server answers "not found" (no longer accessible). + pub inaccessible: bool, + /// Why it could not be compared (the server pass stopped there). + pub error: Option, + /// The folder of its files (absolute). + pub dir: PathBuf, + pub files: Vec, +} + +/// Result of [`scan`]. +#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)] +pub struct LocalChangesScan { + /// Sorted by item and revision. + pub revisions: Vec, + /// A limit was hit (entries, files, or [`MAX_REVISIONS`]): there may be + /// more changes than listed. + pub truncated: bool, + /// Revisions the server pass compared. + pub compared: usize, + /// Revisions the working folder tracks (as far as the scan looked). + pub tracked: usize, +} + +// --------------------------------------------------------------------------- +// Local pass +// --------------------------------------------------------------------------- + +/// The tracked files read from the state, grouped by revision, and what the +/// disk says about each of them. +#[derive(Clone, Debug, Default)] +pub struct LocalPass { + pub entries: Vec, + /// [`layout::key_of`] of `entry.path` → disk state. + pub disk: HashMap, + /// The state held more than `limits.entries` files. + pub truncated: bool, +} + +fn modified_ms(meta: &std::fs::Metadata) -> u64 { + meta.modified() + .ok() + .and_then(|t| t.duration_since(UNIX_EPOCH).ok()) + .map(|d| d.as_millis() as u64) + .unwrap_or(0) +} + +fn sha256_file(path: &Path) -> std::io::Result { + let mut file = std::fs::File::open(path)?; + let mut hasher = Sha256::new(); + let mut buf = vec![0u8; 256 * 1024]; + loop { + let n = file.read(&mut buf)?; + if n == 0 { + break; + } + hasher.update(&buf[..n]); + } + Ok(hex::encode(hasher.finalize())) +} + +/// What the disk says about one tracked file; `budget` is the number of +/// bytes that may still be hashed. +pub(crate) fn disk_of(root: &Path, e: &Entry, budget: &mut u64) -> Disk { + let path = layout::join_rel(root, &e.path); + let meta = match std::fs::metadata(&path) { + Ok(m) if m.is_file() => m, + _ => { + return Disk { + exists: false, + modified: false, + writable: false, + } + } + }; + let writable = !workspace::is_read_only(&path); + let (size, mtime) = (meta.len(), modified_ms(&meta)); + let modified = if size != e.size { + // a known size that differs: changed for sure (no size known – an + // old state – is decided by the hash) + e.size != 0 || hash_differs(&path, e, size, budget) + } else if mtime == e.modified_ms && mtime != 0 { + false + } else { + hash_differs(&path, e, size, budget) + }; + Disk { + exists: true, + modified, + writable, + } +} + +fn hash_differs(path: &Path, e: &Entry, size: u64, budget: &mut u64) -> bool { + if e.sha256.is_empty() || size > *budget { + return true; + } + *budget -= size; + sha256_file(path).map(|s| s != e.sha256).unwrap_or(true) +} + +/// Compares the tracked files of `state` with the disk below `root`, at most +/// `limits.entries` of them. Never fails: what cannot be read counts as +/// missing or modified. +pub(crate) fn local_pass(root: &Path, state: &State, limits: Limits) -> LocalPass { + let mut out = LocalPass::default(); + let mut budget = MAX_HASH_BYTES; + for e in state.files.values() { + if out.entries.len() >= limits.entries { + out.truncated = true; + break; + } + out.disk + .insert(layout::key_of(&e.path), disk_of(root, e, &mut budget)); + out.entries.push(e.clone()); + } + out +} + +// --------------------------------------------------------------------------- +// Pure rules +// --------------------------------------------------------------------------- + +/// Sort key of a revision in the server pass: rank, item, revision order. +type Rank = (u8, String, (usize, String)); + +/// The revisions of `entries` in the order the server pass compares them: +/// revisions with a local change (missing or modified) first, then the ones +/// checked out by me, then the rest – each part by item and revision. +pub fn server_order(entries: &[Entry], disk: &HashMap) -> Vec { + // key → (rank, item, revision order) + let mut ranks: BTreeMap = BTreeMap::new(); + for e in entries { + let key = key_of(e.project.as_deref(), &e.item, &e.revision); + let d = disk.get(&layout::key_of(&e.path)); + let rank = if d.is_some_and(|d| !d.exists || d.modified) { + 0 + } else if e.checked_out { + 1 + } else { + 2 + }; + let slot = ranks.entry(key).or_insert(( + rank, + e.item.to_lowercase(), + layout::revision_order(&e.revision), + )); + slot.0 = slot.0.min(rank); + } + let mut keys: Vec<(RevKey, Rank)> = ranks.into_iter().collect(); + keys.sort_by(|a, b| a.1.cmp(&b.1).then_with(|| a.0.cmp(&b.0))); + keys.into_iter().map(|(k, _)| k).collect() +} + +/// The list: per revision of `entries` either the files of its server status +/// (`server`, when compared) in a [`SHOWN`] state, or the missing and +/// modified files of the local pass (`disk`). `errors` holds the revisions +/// the server pass failed on. Revisions without such a file and without an +/// error are left out; at most `max_files` files are listed (the second +/// value is true when some were left out). +pub fn classify( + root: &Path, + entries: &[Entry], + disk: &HashMap, + server: &HashMap, + errors: &HashMap, + max_files: usize, +) -> (Vec, bool) { + let mut groups: BTreeMap> = BTreeMap::new(); + for e in entries { + groups + .entry(key_of(e.project.as_deref(), &e.item, &e.revision)) + .or_default() + .push(e); + } + let mut out = Vec::new(); + let mut listed = 0usize; + let mut cut = false; + for (key, list) in groups { + let first = list[0]; + let local_checked_out = list.iter().any(|e| e.checked_out); + let dir_of_first = layout::join_rel(root, &first.path) + .parent() + .map(Path::to_path_buf) + .unwrap_or_else(|| root.to_path_buf()); + let mut rev = RevisionChanges { + project: first.project.clone(), + item: first.item.clone(), + code: first.revision.clone(), + checked_out: local_checked_out, + compared: false, + inaccessible: false, + error: errors.get(&key).cloned(), + dir: dir_of_first, + files: Vec::new(), + }; + if let Some(s) = server.get(&key) { + rev.compared = true; + rev.inaccessible = s.inaccessible; + rev.checked_out = s.locked_by_me; + if !s.dir.as_os_str().is_empty() { + rev.dir = s.dir.clone(); + } + for f in &s.files { + if !SHOWN.contains(&f.state.as_str()) { + continue; + } + let changed = matches!(f.state.as_str(), "modified" | "conflict" | "new"); + rev.files.push(ChangedFile { + name: f.name.clone(), + path: f.path.clone(), + state: f.state.clone(), + server_version: f.server_version, + base_version: f.base_version, + writable: f.state != "missing" && !f.read_only, + without_checkout: changed && !s.locked_by_me && !s.inaccessible, + }); + } + } else { + for e in &list { + let Some(d) = disk.get(&layout::key_of(&e.path)) else { + continue; + }; + let state = if !d.exists { + "missing" + } else if d.modified { + "modified" + } else { + continue; + }; + rev.files.push(ChangedFile { + name: e.filename.clone(), + path: e.path.clone(), + state: state.to_string(), + server_version: None, + base_version: Some(e.version), + writable: d.writable, + without_checkout: state == "modified" && !e.checked_out, + }); + } + } + if rev.files.is_empty() && rev.error.is_none() { + continue; + } + if listed + rev.files.len() > max_files { + cut = true; + continue; + } + listed += rev.files.len(); + rev.files + .sort_by_key(|f| (f.path.to_lowercase(), f.name.to_lowercase())); + out.push(rev); + } + out.sort_by_key(|r| (r.item.to_lowercase(), layout::revision_order(&r.code))); + (out, cut) +} + +// --------------------------------------------------------------------------- +// The scan +// --------------------------------------------------------------------------- + +/// The whole scan: local pass, then the server pass over at most +/// [`MAX_REVISIONS`] revisions, then [`classify`]. +pub async fn scan(api: &Api, root: &Path) -> Result { + if !root.is_dir() { + return Ok(LocalChangesScan::default()); + } + let limits = Limits::default(); + let dir = root.to_path_buf(); + let local = tokio::task::spawn_blocking(move || { + let state = State::load(&dir); + local_pass(&dir, &state, limits) + }) + .await + .map_err(|e| ApiError::local(format!("The scan for local changes stopped: {e}")))?; + let order = server_order(&local.entries, &local.disk); + let tracked = order.len(); + let names: HashMap, String, String)> = local + .entries + .iter() + .map(|e| { + ( + key_of(e.project.as_deref(), &e.item, &e.revision), + (e.project.clone(), e.item.clone(), e.revision.clone()), + ) + }) + .collect(); + let mut server = HashMap::new(); + let mut errors = HashMap::new(); + for key in order.iter().take(MAX_REVISIONS) { + let Some((project, item, code)) = names.get(key) else { + continue; + }; + match workspace::status(api, root, project.as_deref(), item, code).await { + Ok(status) => { + server.insert(key.clone(), ServerRevision::from(&status)); + } + Err(e) => { + // unreachable server, signed out …: the rest keeps the local view + errors.insert(key.clone(), e.to_string()); + break; + } + } + } + let compared = server.len(); + let (revisions, cut) = classify( + root, + &local.entries, + &local.disk, + &server, + &errors, + limits.files, + ); + Ok(LocalChangesScan { + revisions, + truncated: local.truncated || cut || tracked > MAX_REVISIONS, + compared, + tracked, + }) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn entry(item: &str, rev: &str, name: &str, checked_out: bool) -> Entry { + Entry { + path: format!("ROVER/{item}/{name}"), + project: Some("ROVER".into()), + item: item.into(), + revision: rev.into(), + file_id: format!("id-{name}"), + filename: name.into(), + version: 2, + sha256: "a".repeat(64), + checked_out, + size: 10, + modified_ms: 1000, + } + } + + fn disk(exists: bool, modified: bool, writable: bool) -> Disk { + Disk { + exists, + modified, + writable, + } + } + + fn server_file(e: &Entry, state: &str, server_version: Option) -> ServerFile { + ServerFile { + name: e.filename.clone(), + path: e.path.clone(), + state: state.into(), + server_version, + base_version: Some(e.version), + read_only: false, + } + } + + fn key(e: &Entry) -> RevKey { + key_of(e.project.as_deref(), &e.item, &e.revision) + } + + fn run( + entries: &[Entry], + d: &[(&Entry, Disk)], + server: &[(&Entry, ServerRevision)], + ) -> Vec { + let disk: HashMap = d + .iter() + .map(|(e, d)| (layout::key_of(&e.path), d.clone())) + .collect(); + let server: HashMap = + server.iter().map(|(e, s)| (key(e), s.clone())).collect(); + classify( + Path::new("/ws"), + entries, + &disk, + &server, + &HashMap::new(), + 1000, + ) + .0 + } + + #[test] + fn modified_without_checkout_from_the_local_pass() { + let e = entry("PRT-1", "A", "bracket.prt", false); + let out = run(&[e.clone()], &[(&e, disk(true, true, true))], &[]); + assert_eq!(out.len(), 1); + let f = &out[0].files[0]; + assert_eq!(f.state, "modified"); + assert!(f.without_checkout); + assert!(f.writable); + assert!(!out[0].compared); + } + + #[test] + fn modified_in_my_checkout_needs_no_checkout() { + let e = entry("PRT-1", "A", "bracket.prt", true); + let out = run(&[e.clone()], &[(&e, disk(true, true, true))], &[]); + assert!(!out[0].files[0].without_checkout); + assert!(out[0].checked_out); + } + + #[test] + fn conflict_and_outdated_come_from_the_server_pass() { + let a = entry("PRT-1", "A", "bracket.prt", false); + let b = entry("PRT-1", "A", "bracket.drw", false); + let s = ServerRevision { + locked_by_me: false, + inaccessible: false, + dir: PathBuf::from("/ws/ROVER/PRT-1"), + files: vec![ + server_file(&a, "conflict", Some(3)), + server_file(&b, "outdated", Some(4)), + ], + }; + let out = run( + &[a.clone(), b.clone()], + &[(&a, disk(true, true, true)), (&b, disk(true, false, false))], + &[(&a, s)], + ); + assert!(out[0].compared); + let states: Vec<_> = out[0].files.iter().map(|f| f.state.as_str()).collect(); + assert_eq!(states, ["outdated", "conflict"]); + let conflict = &out[0].files[1]; + assert!(conflict.without_checkout); + assert_eq!(conflict.server_version, Some(3)); + assert_eq!(conflict.base_version, Some(2)); + assert!(!out[0].files[0].without_checkout); + } + + #[test] + fn missing_and_unchanged_files() { + let a = entry("PRT-1", "A", "bracket.prt", false); + let b = entry("PRT-2", "B", "plate.prt", false); + let out = run( + &[a.clone(), b.clone()], + &[ + (&a, disk(false, false, false)), + (&b, disk(true, false, false)), + ], + &[], + ); + assert_eq!(out.len(), 1, "an unchanged revision is not listed"); + assert_eq!(out[0].files[0].state, "missing"); + assert!(!out[0].files[0].without_checkout); + } + + #[test] + fn up_to_date_and_clash_from_the_server_are_left_out() { + let a = entry("PRT-1", "A", "bracket.prt", true); + let s = ServerRevision { + locked_by_me: true, + inaccessible: false, + dir: PathBuf::new(), + files: vec![ + server_file(&a, "up_to_date", Some(2)), + server_file(&a, "clash", None), + ], + }; + let out = run(&[a.clone()], &[(&a, disk(true, false, true))], &[(&a, s)]); + assert!(out.is_empty()); + } + + #[test] + fn server_order_puts_local_changes_and_checkouts_first() { + let rest = entry("PRT-1", "A", "a.prt", false); + let mine = entry("PRT-2", "A", "b.prt", true); + let changed = entry("PRT-3", "A", "c.prt", false); + let disk: HashMap = [ + (layout::key_of(&rest.path), disk(true, false, false)), + (layout::key_of(&mine.path), disk(true, false, true)), + (layout::key_of(&changed.path), disk(true, true, true)), + ] + .into_iter() + .collect(); + let order = server_order(&[rest.clone(), mine.clone(), changed.clone()], &disk); + assert_eq!(order, vec![key(&changed), key(&mine), key(&rest)]); + } + + #[test] + fn file_cap_truncates() { + let entries: Vec = (0..5) + .map(|i| entry(&format!("PRT-{i}"), "A", "p.prt", false)) + .collect(); + let disk: HashMap = entries + .iter() + .map(|e| (layout::key_of(&e.path), disk(false, false, false))) + .collect(); + let (out, cut) = classify( + Path::new("/ws"), + &entries, + &disk, + &HashMap::new(), + &HashMap::new(), + 3, + ); + assert_eq!(out.len(), 3); + assert!(cut); + } + + #[test] + fn a_failed_revision_is_listed_with_its_error() { + let a = entry("PRT-1", "A", "bracket.prt", false); + let errors: HashMap = [(key(&a), "server unreachable".to_string())] + .into_iter() + .collect(); + let disk: HashMap = [(layout::key_of(&a.path), disk(true, false, false))] + .into_iter() + .collect(); + let (out, _) = classify(Path::new("/ws"), &[a], &disk, &HashMap::new(), &errors, 10); + assert_eq!(out[0].error.as_deref(), Some("server unreachable")); + assert!(out[0].files.is_empty()); + } + + #[test] + fn local_pass_reads_the_disk() { + let dir = tempfile::tempdir().unwrap(); + let root = dir.path(); + std::fs::create_dir_all(root.join("ROVER/PRT-1")).unwrap(); + let same = b"0123456789"; + std::fs::write(root.join("ROVER/PRT-1/same.prt"), same).unwrap(); + std::fs::write(root.join("ROVER/PRT-1/bigger.prt"), b"01234567890123").unwrap(); + let mut state = State::default(); + let mut add = |name: &str, sha: String| { + let mut e = entry("PRT-1", "A", name, false); + e.sha256 = sha; + state.insert(e); + }; + // same size, other time → hashed: the content equals the base + add("same.prt", hex::encode(Sha256::digest(same))); + add("bigger.prt", "b".repeat(64)); + add("gone.prt", "c".repeat(64)); + let pass = local_pass(root, &state, Limits::default()); + assert!(!pass.truncated); + let get = |name: &str| pass.disk[&layout::key_of(&format!("ROVER/PRT-1/{name}"))].clone(); + assert!(get("same.prt").exists && !get("same.prt").modified); + assert!(get("bigger.prt").modified); + assert!(!get("gone.prt").exists); + let small = local_pass( + root, + &state, + Limits { + entries: 2, + files: 10, + }, + ); + assert!(small.truncated); + assert_eq!(small.entries.len(), 2); + } +} diff --git a/desktop/src/main.rs b/desktop/src/main.rs index fd121692..bba0c23a 100755 --- a/desktop/src/main.rs +++ b/desktop/src/main.rs @@ -20,6 +20,7 @@ mod compat; mod crash; mod folderimport; mod layout; +mod localchanges; mod localserver; mod newfiles; mod policy; @@ -273,6 +274,7 @@ fn main() { commands::workspace_checkin, commands::workspace_park, commands::workspace_local_changes, + commands::local_changes_scan, commands::pick_files, commands::workspace_add_plan, commands::workspace_add_files, diff --git a/desktop/ui/app.css b/desktop/ui/app.css index 2ceede43..15d2feda 100755 --- a/desktop/ui/app.css +++ b/desktop/ui/app.css @@ -1054,7 +1054,7 @@ ul.file-picks li .mono { overflow: hidden; text-overflow: ellipsis; white-space: .new-item-info:empty { display: none; } .new-item-info .notice { margin: 0; } /* worklist: New on this computer – the tick box before the row's icon */ -.node.new-file input[type="checkbox"] { flex: none; margin: 0 4px 0 2px; } +.node.new-file input[type="checkbox"], .node.local-change input[type="checkbox"] { flex: none; margin: 0 4px 0 2px; } /* Preview images stored in CAD files (Inventor, Solid Edge, SolidWorks): drawings on paper, white in both schemes */ diff --git a/desktop/ui/js/local-changes.js b/desktop/ui/js/local-changes.js new file mode 100644 index 00000000..45c4790f --- /dev/null +++ b/desktop/ui/js/local-changes.js @@ -0,0 +1,146 @@ +// SPDX-License-Identifier: MPL-2.0 +// TeamCraft Desktop – *Local changes* (#416): the pure part (no DOM, no +// server calls, no imports), so it can be checked on its own +// (scripts/desktop-local-changes.test.mjs). navigator.js draws the worklist +// section *Local changes* from it, shell.js counts it into the rail badge. +// +// The scan (`local_changes_scan`, desktop/src/localchanges.rs) lists the +// files of every revision in the working folder that are modified, outdated, +// in conflict, new (a companion of a tracked file, e.g. a STEP export) or +// missing. This module groups them by item and says which actions each file +// and each selection allows – all of them the commands of the Workspace tab: +// +// * Check out (keep my file) – a file changed without a check-out (its +// read-only flag cleared): `workspace_checkout` keeps locally modified +// files and makes the revision mine; +// * Get latest – outdated or missing files: `workspace_download` replaces +// unchanged copies and never overwrites a local change; +// * Check in – modified and new files of my own check-outs: the Check in all +// flow (`sendLocalChanges` in shell.js) for the selection; +// * Merge – a conflict (changed here and on the server) is opened in its +// Workspace tab, a check-in would be refused; +// * Open folder – every row. + +/** The states the list shows, in the order of their urgency. */ +export var LOCAL_STATES = ["conflict", "modified", "new", "outdated", "missing"]; + +/** Labels of the states in the list. */ +export var LOCAL_LABEL = { + conflict: "Conflict", modified: "Modified", "new": "New", outdated: "Outdated", missing: "Not in working folder" +}; + +/** One file's key: unique over the whole scan (selection, ticks). */ +export function localRowKey(rev, file) { + return [rev.project || "", rev.item, rev.code, file.path || file.name].join("|").toLowerCase(); +} + +/** A revision's key: `project|item|code`, ignoring case. */ +export function localRevKey(rev) { + return [rev.project || "", rev.item, rev.code].join("|").toLowerCase(); +} + +/** The actions a file allows (in the order the row shows them). */ +export function localRowActions(rev, file) { + var out = []; + if (rev.inaccessible) return ["folder"]; + var changed = file.state === "modified" || file.state === "new"; + if (file.state === "conflict") out.push("merge"); + if (changed && !rev.checked_out) out.push("checkout"); + if (changed && rev.checked_out) out.push("checkin"); + if (file.state === "outdated" || file.state === "missing") out.push("get"); + out.push("folder"); + return out; +} + +/** A short line of the file's versions: "v4 on the server, yours v2". */ +export function localVersionText(file) { + if (file.server_version && file.base_version && file.server_version !== file.base_version) { + return "v" + file.server_version + " on the server, yours v" + file.base_version; + } + if (file.server_version) return "v" + file.server_version; + if (file.base_version) return "yours v" + file.base_version; + return ""; +} + +/** Sort order of the rows of a revision: urgency, then path. */ +function localRowOrder(a, b) { + var d = LOCAL_STATES.indexOf(a.state) - LOCAL_STATES.indexOf(b.state); + if (d) return d; + var pa = (a.path || a.name).toLowerCase(), pb = (b.path || b.name).toLowerCase(); + return pa < pb ? -1 : pa > pb ? 1 : 0; +} + +/** + * Groups the scan by item and attaches the actions. + * + * Returns `{items: [{item, project, revisions: [{…revision, key, rows: + * [{…file, key, actions}]}]}], count, counts: {state → files}, withoutCheckout, + * errors: ["PRT-1/A: …"], truncated, compared, tracked}`. `count` is the number + * of files the rail badge adds. + */ +export function planLocalChanges(scan) { + var out = { + items: [], count: 0, counts: {}, withoutCheckout: 0, errors: [], + truncated: !!(scan && scan.truncated), compared: (scan && scan.compared) || 0, tracked: (scan && scan.tracked) || 0 + }; + LOCAL_STATES.forEach(function (s) { out.counts[s] = 0; }); + var byItem = {}; + ((scan && scan.revisions) || []).forEach(function (rev) { + var rows = (rev.files || []).filter(function (f) { return LOCAL_STATES.indexOf(f.state) >= 0; }).map(function (f) { + out.count++; + out.counts[f.state]++; + if (f.without_checkout) out.withoutCheckout++; + return Object.assign({}, f, { key: localRowKey(rev, f), actions: localRowActions(rev, f) }); + }).sort(localRowOrder); + if (rev.error) out.errors.push(rev.item + "/" + rev.code + ": " + rev.error); + if (!rows.length) return; + var itemKey = ((rev.project || "") + "|" + rev.item).toLowerCase(); + if (!byItem[itemKey]) { + byItem[itemKey] = { item: rev.item, project: rev.project || null, revisions: [] }; + out.items.push(byItem[itemKey]); + } + byItem[itemKey].revisions.push(Object.assign({}, rev, { key: localRevKey(rev), rows: rows })); + }); + out.items.sort(function (a, b) { + var x = a.item.toLowerCase(), y = b.item.toLowerCase(); + return x < y ? -1 : x > y ? 1 : 0; + }); + return out; +} + +/** + * What a selection (`ticked`: row key → true) allows, one entry per + * revision: `checkout` (revisions to check out, keeping the files), `get` + * (revisions to get), and `checkin` in the shape of the Check in all report + * (`{changed: [{project, item, code, upload, conflicts}], unreadable: []}`, + * for `sendLocalChanges`). Conflicts are never checked in: they are named + * in `conflicts` so the flow keeps the revision checked out. + */ +export function selectionActions(plan, ticked) { + var out = { checkout: [], get: [], checkin: { changed: [], unreadable: [] }, rows: 0 }; + plan.items.forEach(function (it) { + it.revisions.forEach(function (rev) { + var chosen = rev.rows.filter(function (r) { return ticked && ticked[r.key]; }); + if (!chosen.length) return; + out.rows += chosen.length; + var ref = { project: rev.project || null, item: rev.item, code: rev.code }; + if (chosen.some(function (r) { return r.actions.indexOf("checkout") >= 0; })) out.checkout.push(ref); + if (chosen.some(function (r) { return r.actions.indexOf("get") >= 0; })) out.get.push(ref); + var upload = chosen.filter(function (r) { return r.actions.indexOf("checkin") >= 0; }).map(function (r) { return r.name; }); + if (upload.length) { + var conflicts = rev.rows.filter(function (r) { return r.state === "conflict"; }).map(function (r) { return r.name; }); + out.checkin.changed.push(Object.assign({}, ref, { upload: upload, conflicts: conflicts })); + } + }); + }); + return out; +} + +/** "3 modified · 1 conflict · 2 outdated" – the summary under the heading. */ +export function localSummaryText(plan) { + var parts = LOCAL_STATES.filter(function (s) { return plan.counts[s]; }).map(function (s) { + return plan.counts[s] + " " + (s === "missing" ? "missing" : LOCAL_LABEL[s].toLowerCase()); + }); + if (plan.withoutCheckout) parts.push(plan.withoutCheckout + " changed without a check-out"); + return parts.join(" · "); +} diff --git a/desktop/ui/js/navigator.js b/desktop/ui/js/navigator.js index ca70f9ed..f74eb945 100755 --- a/desktop/ui/js/navigator.js +++ b/desktop/ui/js/navigator.js @@ -5,12 +5,13 @@ import { $, ICONS, api, append, badge, call, clear, dialog, enc, errorText, field, h, lockIcon, setStatus, state, svgIcon, toast } from "./core.js"; import { fmtDate, label } from "/static/shared/js/format.js"; import { canSeeLocks, openLockOverview } from "./lock-overview.js"; -import { canEdit, checkInAll, fetchWorklist, refreshWorklistCount, reloadProjects, renderNotifications, rescanNewFiles, scanNewFiles, showWorklistCount } from "./shell.js"; +import { canEdit, checkInAll, fetchWorklist, refreshWorklistCount, reloadProjects, renderNotifications, rescanNewFiles, scanLocalChanges, scanNewFiles, sendLocalChanges, showWorklistCount } from "./shell.js"; import { assistantContextChanged } from "./assistant.js"; import { agent, renderAgentView } from "./agent.js"; import { openRevision } from "./revision.js"; import { impactGroups, relationShort, relationText } from "./references.js"; -import { lockAge } from "./workspace.js"; +import { getting, lockAge, reportDownload } from "./workspace.js"; +import { LOCAL_LABEL, localSummaryText, localVersionText, selectionActions } from "./local-changes.js"; import { openChange } from "./change.js"; import { openRequest } from "./requests.js"; import { checkNewItemFiles, createItemFromFiles, editableGroupOfFolder, newItemDialog } from "./dialogs.js"; @@ -351,7 +352,8 @@ export function sectionTitle(text, n) { export function renderWorklist() { // the files on this computer are looked at again whenever the worklist is // opened or refreshed (#359); a failing scan never hides the worklist - return Promise.all([fetchWorklist(), scanNewFiles(true).catch(function () { return null; })]).then(function (r) { + return Promise.all([fetchWorklist(), scanNewFiles(true).catch(function () { return null; }), + scanLocalChanges(false).catch(function () { return null; })]).then(function (r) { showWorklistCount(); drawWorklist(r[0]); }); @@ -377,6 +379,7 @@ export function drawWorklist(w) { h("span.meta.small.dim", { text: lockAge(r.checked_out_at) }) ])); })) : h("p.empty", { text: "Nothing checked out." })); + localChangesSection(nav); if (canEdit()) newFilesSection(nav); nav.appendChild(sectionTitle("Waiting for my review", w.reviews.length)); nav.appendChild(w.reviews.length ? h("ul.tree", null, w.reviews.map(changeNode)) : h("p.empty", { text: "Nothing to review." })); @@ -394,6 +397,184 @@ export function drawWorklist(w) { nav.scrollTop = top; } +// ------------------------------------------------ Local changes (#416) + +/** What a row's buttons are called. */ +var LOCAL_ACTION_LABEL = { checkout: "Check out", get: "Get latest", checkin: "Check in…", merge: "Merge…", folder: "Folder" }; +var LOCAL_ACTION_TITLE = { + checkout: "Check out this revision and keep your file – it becomes yours to check in", + get: "Copy the current files of this revision into the working folder – local changes are kept", + checkin: "Check in your changed files of this revision (new versions; the check-out is released)", + merge: "Changed here and on the server – open the Workspace tab to merge", + folder: "Open the folder of this revision" +}; + +/** The worklist section *Local changes*: every file of the working folder + * that is modified, outdated, in conflict, new or missing, grouped by item + * (local-changes.js plans it, desktop/src/localchanges.rs scans). Ticked + * rows take the bar's actions; every row has its own. */ +function localChangesSection(nav) { + var lc = state.localChanges; + if (!lc) return; + var plan = lc.plan, editor = canEdit(); + state.localTicked = state.localTicked || {}; + var ticked = state.localTicked, present = {}; + plan.items.forEach(function (it) { it.revisions.forEach(function (rev) { rev.rows.forEach(function (r) { present[r.key] = true; }); }); }); + Object.keys(ticked).forEach(function (k) { if (!present[k]) delete ticked[k]; }); + var checkoutBtn = h("button.small", { type: "button", title: "Check out the revisions of the ticked files and keep your files", + on: { click: function () { localCheckout(selectionActions(plan, ticked).checkout); } } }, "Check out"); + var getBtn = h("button.small", { type: "button", title: "Get the latest files of the ticked revisions – local changes are kept", + on: { click: function () { localGet(selectionActions(plan, ticked).get); } } }, "Get latest"); + var checkinBtn = h("button.small", { type: "button", title: "Check in the ticked files of your check-outs", + on: { click: function () { localCheckin(selectionActions(plan, ticked).checkin); } } }, "Check in selected"); + function updateBar() { + var sel = selectionActions(plan, ticked); + checkoutBtn.disabled = !sel.checkout.length; + getBtn.disabled = !sel.get.length; + checkinBtn.disabled = !sel.checkin.changed.length; + } + updateBar(); + nav.appendChild(h("div.row", null, [sectionTitle("Local changes", plan.count), + plan.count ? h("span.row", null, [editor ? checkoutBtn : null, getBtn, editor ? checkinBtn : null]) : null])); + if (!plan.count) { + nav.appendChild(h("p.empty", { text: "No modified, outdated or missing files in your working folder." })); + } else { + nav.appendChild(h("p.small.dim", { text: localSummaryText(plan) })); + nav.appendChild(h("ul.tree", null, plan.items.map(function (it) { + return h("li", null, [ + h("div.node", { title: it.project ? it.project + " / " + it.item : it.item }, [ + h("span.twisty"), h("span.ico", { text: "◇" }), + h("span.label", null, [h("span.mono", { text: it.item }), it.project ? h("span.dim", { text: " " + it.project }) : null]) + ]), + h("ul.tree", null, it.revisions.map(function (rev) { return localRevisionNode(rev, ticked, updateBar, editor); })) + ]); + }))); + } + var notes = []; + if (plan.truncated) notes.push("Only part of the working folder was compared – it holds very many files."); + if (plan.tracked > plan.compared) notes.push((plan.tracked - plan.compared) + " of " + plan.tracked + " revisions compared on this computer only (no outdated or conflict check)"); + if (notes.length) nav.appendChild(h("p.small.dim", { text: notes.join(" · ") })); + if (plan.errors.length) nav.appendChild(h("p.small.notice.error", { text: "Could not compare with the server: " + plan.errors.join("; ") })); + if (editor) { + nav.appendChild(h("p.small.dim", null, ["Files that belong to no item yet: ", + h("button.link.small", { type: "button", on: { click: function () { + var target = $("worklist-new-files"); + if (target) target.scrollIntoView({ block: "start" }); + } } }, "New on this computer")])); + } +} + +/** One revision of *Local changes*: its line (opens the Workspace tab) and its files. */ +function localRevisionNode(rev, ticked, updateBar, editor) { + var head = h("div.node", { title: "Open the Workspace tab of " + rev.item + "/" + rev.code, "data-item": rev.item, "data-rev": rev.code, + on: { click: function () { openRevision(rev.item, rev.code, "workspace"); } } }, [ + h("span.twisty"), h("span.ico", null, rev.checked_out ? lockIcon(true) : null), + h("span.label", null, [h("span.mono", { text: rev.item + "/" + rev.code }), + rev.inaccessible ? h("span.dim", { text: " – no longer accessible" }) : null, + !rev.compared ? h("span.dim", { text: " – not compared with the server" }) : null]) + ]); + return h("li", null, [head, h("ul.tree", null, rev.rows.map(function (r) { + var box = h("input", { type: "checkbox", "aria-label": "Tick " + r.name, checked: !!ticked[r.key], + on: { click: function (ev) { ev.stopPropagation(); }, change: function () { ticked[r.key] = box.checked; updateBar(); } } }); + var stateBadge = badge(r.state, LOCAL_LABEL[r.state] || r.state); + if (r.without_checkout) stateBadge.title = "Changed without a check-out – check out to keep your file"; + var buttons = r.actions.filter(function (a) { return editor || (a !== "checkout" && a !== "checkin"); }).map(function (a) { + return h("button.small", { type: "button", title: LOCAL_ACTION_TITLE[a], on: { click: function (ev) { + ev.stopPropagation(); + localRowAction(a, rev, r); + } } }, LOCAL_ACTION_LABEL[a]); + }); + return h("li", null, h("div.node.local-change", { title: r.path }, [ + box, + h("span.label", null, [h("span.fname", { text: r.name }), " ", stateBadge, + r.without_checkout ? h("span.small.dim", { text: " not checked out" }) : null]), + h("span.meta.small.dim", { text: localVersionText(r) }), + h("span.row", null, buttons) + ])); + }))]); +} + +function localRef(rev) { return { project: rev.project || null, item: rev.item, code: rev.code }; } + +function localRowAction(action, rev, row) { + if (action === "checkout") localCheckout([localRef(rev)]); + else if (action === "get") localGet([localRef(rev)]); + else if (action === "checkin") localCheckin({ changed: [Object.assign(localRef(rev), { + upload: rev.rows.filter(function (r) { return r.actions.indexOf("checkin") >= 0 && r.key === row.key; }).map(function (r) { return r.name; }), + conflicts: rev.rows.filter(function (r) { return r.state === "conflict"; }).map(function (r) { return r.name; }) + })], unreadable: [] }); + else if (action === "merge") openRevision(rev.item, rev.code, "workspace"); + else call("workspace_open", Object.assign(localRef(rev), { file: null })).catch(function (e) { toast(errorText(e), "error"); }); +} + +/** *Check out (keep my file)*: one revision after the other; the Get of the + * check-out never overwrites a locally modified file. */ +function localCheckout(refs) { + if (!refs.length) return; + var done = [], failed = []; + refs.reduce(function (chain, r) { + return chain.then(function () { + setStatus("Checking out " + r.item + "/" + r.code + " …"); + return getting(call("workspace_checkout", r)).then(function (res) { + done.push(r.item + "/" + r.code); + if (res.clashes.length || res.failed.length || res.unresolved.length) reportDownload(res); + }, function (err) { failed.push(r.item + "/" + r.code + ": " + errorText(err)); }); + }); + }, Promise.resolve()).then(function () { + setStatus(""); + toast((done.length ? "Checked out " + done.join(", ") + " – your files were kept" : "Nothing checked out") + + (failed.length ? ". Failed: " + failed.join("; ") : "."), failed.length ? "error" : null); + state.localTicked = {}; + refreshWorklistCount(); + }); +} + +/** *Get latest* for the given revisions, one after the other. */ +function localGet(refs) { + if (!refs.length) return; + var failed = [], kept = []; + refs.reduce(function (chain, r) { + return chain.then(function () { + setStatus("Getting " + r.item + "/" + r.code + " …"); + return getting(call("workspace_download", r)).then(function (res) { + kept = kept.concat(res.kept); + if (res.clashes.length || res.failed.length) reportDownload(res); + }, function (err) { failed.push(r.item + "/" + r.code + ": " + errorText(err)); }); + }); + }, Promise.resolve()).then(function () { + setStatus(""); + toast("Got the latest files of " + (refs.length - failed.length) + " of " + refs.length + (refs.length === 1 ? " revision" : " revisions") + + (kept.length ? " – kept your changed " + kept.join(", ") : "") + (failed.length ? ". Failed: " + failed.join("; ") : "."), failed.length ? "error" : null); + state.localTicked = {}; + refreshWorklistCount(); + }); +} + +/** *Check in selected*: asks for a comment, then the Check in all flow for + * the chosen files (revisions with a conflict stay checked out). */ +function localCheckin(report) { + if (!report.changed.length) return; + var comment = h("input", { type: "text", maxlength: "500", placeholder: "What changed?" }); + var names = report.changed.map(function (c) { return c.item + "/" + c.code + " (" + c.upload.join(", ") + ")"; }); + dialog("Check in selected", h("div.stack", null, [ + h("p", { text: "New versions of the ticked files; the check-outs are released:" }), + h("ul.small", null, names.map(function (t) { return h("li", { text: t }); })), + field("Comment", comment) + ]), [ + { label: "Cancel", onClick: function (d) { d.close(); } }, + { label: "Check in", primary: true, submit: true, onClick: function (d) { + d.close(); + sendLocalChanges(report, false, comment.value.trim() || "Checked in from Local changes").then(function (sent) { + var problems = sent.kept.concat(sent.failed); + toast((sent.done.length ? "Checked in " + sent.done.join(", ") : "Nothing checked in") + + (problems.length ? ". " + problems.join("; ") : "."), sent.failed.length ? "error" : null); + state.localTicked = {}; + refreshWorklistCount(); + }); + } } + ]); +} + // ------------------------------------------------ New on this computer (#359) /** The worklist section *New on this computer*: parts and assemblies in the @@ -412,7 +593,7 @@ function newFilesSection(nav) { var createBtn = h("button.small", { type: "button", title: "Create one item for each ticked file, in its folder", on: { click: function () { createSuggested(chosen()); } } }, "Create items…"); createBtn.disabled = !chosen().length; - var head = h("div.row", null, [sectionTitle("New on this computer", list.length), list.length ? createBtn : null]); + var head = h("div.row", { id: "worklist-new-files" }, [sectionTitle("New on this computer", list.length), list.length ? createBtn : null]); nav.appendChild(head); if (!list.length) { nav.appendChild(h("p.empty", { text: "No new parts or assemblies in your working folder." })); diff --git a/desktop/ui/js/shell.js b/desktop/ui/js/shell.js index 35e75278..d018aed7 100755 --- a/desktop/ui/js/shell.js +++ b/desktop/ui/js/shell.js @@ -16,6 +16,7 @@ import { openRequest } from "./requests.js"; import { openSettings } from "./settings.js"; import { formatKinds } from "./folder-import.js"; import { planNewFiles } from "./new-files.js"; +import { planLocalChanges } from "./local-changes.js"; // ====================================================================== // Shell @@ -310,9 +311,9 @@ export function initShell() { var t = activeTab(); if (t && t.data && t.recheckLocal) t.recheckLocal(); if (state.me) { - scanNewFiles(false).then(function () { + Promise.all([scanNewFiles(false).catch(function () {}), scanLocalChanges(false).catch(function () {})]).then(function () { if (state.view === "worklist" && state.worklist) drawWorklist(state.worklist); - }, function () {}); + }); } }); document.addEventListener("keydown", function (e) { @@ -621,14 +622,16 @@ export function fetchWorklist() { }); } -/** The count on the rail: the open worklist entries and the files on this - * computer suggested as new items (from the last scan, #359). */ +/** The count on the rail: the open worklist entries, the files on this + * computer suggested as new items (from the last scan, #359) and the files + * with local changes (#416). */ export function showWorklistCount() { var w = state.worklist; if (!w) return; // dependents count once, however many changes they have to be checked against var n = w.checkouts.length + w.reviews.length + impactGroups(w).length + (w.requests_assigned || []).length + - (state.newFiles ? state.newFiles.plan.suggestions.length : 0); + (state.newFiles ? state.newFiles.plan.suggestions.length : 0) + + (state.localChanges ? state.localChanges.plan.count : 0); var el = $("worklist-count"); el.textContent = String(n); el.classList.toggle("hidden", n === 0); @@ -674,10 +677,42 @@ export function rescanNewFiles() { /** After anything that changes the worklist (check out, cancel check-out, * check in, a review …): the count on the rail, and the worklist navigator * when it is shown – an action in a tab on the right shows up on the left at - * once (#347). */ + * once (#347) – and *Local changes* is scanned again (#416). */ export function refreshWorklistCount() { + // a check-in, Get or check-out changes the working folder too (#416) + rescanLocalChanges(); return fetchWorklist().then(function (w) { if (state.view === "worklist") drawWorklist(w); return w; }); } + +var localChangesScan = null; +/** *Local changes* (#416): the modified, outdated, conflicting, new and + * missing files of every revision in the working folder (desktop + * src/localchanges.rs). At most every 15 s unless `force`; one scan at a + * time. Only reads – the worklist section offers the actions. */ +export function scanLocalChanges(force) { + if (!state.me) { state.localChanges = null; return Promise.resolve(null); } + if (!force && state.localChanges && Date.now() - state.localChanges.at < 15000) return Promise.resolve(state.localChanges); + if (localChangesScan) return localChangesScan; + localChangesScan = call("local_changes_scan").then(function (scan) { + state.localChanges = { at: Date.now(), scan: scan, plan: planLocalChanges(scan) }; + localChangesScan = null; + showWorklistCount(); + return state.localChanges; + }, function (err) { + localChangesScan = null; + throw err; + }); + return localChangesScan; +} + +/** After a check-in, Get or check-out: scan again (once the running scan is + * done) and redraw the worklist when it is shown. */ +export function rescanLocalChanges() { + var running = localChangesScan || Promise.resolve(); + return running.catch(function () {}).then(function () { return scanLocalChanges(true); }).then(function () { + if (state.view === "worklist" && state.worklist) drawWorklist(state.worklist); + }, function () {}); +} diff --git a/docs/OPEN_WORK.md b/docs/OPEN_WORK.md index df153896..60c8ca54 100755 --- a/docs/OPEN_WORK.md +++ b/docs/OPEN_WORK.md @@ -756,7 +756,8 @@ needs an issue with a reason first (see *Direction*). review is #408: quick wins done (#409 check-in icon, #410 one vocabulary + glossary, #411 web check-out wording and *Get TeamCraft Desktop*, #412 preview at the top of the revision page, #413 no hash column, #414 revision vs version explained), #421 section nav of the revision page, #417 right-click menus in the desktop app; left: the - daily CAD loop (#415, #416, #418–#420) and onboarding (#422–#424) + daily CAD loop (#415, #418–#420; done: #416 one *Local changes* list of the whole working folder in the desktop + worklist) and onboarding (#422–#424) - [ ] Responsive pages on large data (1M files, 100k items, 10k-line BOMs – see the scale targets) - [ ] Faster opening of large CAD files and assemblies - [ ] Configurable lifecycle states and site-specific allowed transitions instead of one built-in state machine diff --git a/docs/src/guide/desktop.md b/docs/src/guide/desktop.md index 6118bbfb..13dfc8bf 100755 --- a/docs/src/guide/desktop.md +++ b/docs/src/guide/desktop.md @@ -154,6 +154,31 @@ check-outs and reviews, and a **local working folder**: most 50 000 entries and reports at most 2 000 files, so a huge folder never blocks the app. Nothing is uploaded from the worklist without the dialog or the confirmed summary. Viewers do not see the section; +* **Local changes** (worklist, #416) lists every file of the working folder + that is not the same as on the server, across all project groups and + grouped by item: **modified**, **outdated** (somebody checked in a newer + version), **conflict** (changed here and on the server), **new** (a file + next to a tracked one, such as a STEP export) and **missing**. A file you + changed after clearing its read-only flag shows up too, marked *not checked + out* – you do not have to open its item first. Each row has its actions, + and the ticked rows take the ones above the list: **Check out** (keep my + file) for a file changed without a check-out – your file stays as it is and + the revision becomes yours to check in; **Get latest** for outdated and + missing files (a changed file is never overwritten); **Check in selected** + for the changed files of your own check-outs (a comment, then the same flow + as *Check in all*; a revision with a conflict stays checked out); + **Merge…** opens the Workspace tab of a conflict; **Folder** opens the + folder. A click on a revision opens its Workspace tab. The count is part of + the worklist count on the rail. Files that belong to no item yet stay in + *New on this computer* (the link under the list jumps there). The list is + made in two steps: the working folder is compared with what TeamCraft + copied there (no network; unchanged files are not read again), then up to + 100 revisions are compared with the server – the ones with local changes + first, then your check-outs. Only that second step knows *outdated* and + *conflict*; the note under the list says how many revisions were compared + on this computer only. It runs when the worklist opens, when the app window + gets the focus back (at most every 15 s) and after a check-out, check-in or + Get. Viewers see the list with *Get latest* and *Folder* only; * *Check in all* in the worklist first lists the check-outs with local changes (modified or new files) and offers to **check them in first** with their files; *Only the others* checks in just the check-outs without diff --git a/scripts/ci-changes.sh b/scripts/ci-changes.sh index 5a1aa87f..3ee31021 100755 --- a/scripts/ci-changes.sh +++ b/scripts/ci-changes.sh @@ -197,6 +197,8 @@ self_test() { check tests/fixtures/cad/nist/ctc-01/inventor/ctc_01.ipt server=true desktop_rust=true check clippy.toml server=true desktop_rust=true check scripts/desktop-tab-order.test.mjs server=false desktop_ui=true 'codeql=["javascript-typescript"]' + check scripts/desktop-local-changes.test.mjs,desktop/ui/js/local-changes.js server=false desktop_rust=false desktop_ui=true + check desktop/src/localchanges.rs server=false desktop_rust=true desktop_ui=false check src/services/lock_overview.rs server=true desktop_ui=true desktop_rust=false # documentation and examples read by the guard tests check docs/src/admin/configuration.md server=false guards=true docs_site=true 'codeql=[]' diff --git a/scripts/desktop-local-changes.test.mjs b/scripts/desktop-local-changes.test.mjs new file mode 100644 index 00000000..95a670b1 --- /dev/null +++ b/scripts/desktop-local-changes.test.mjs @@ -0,0 +1,131 @@ +// SPDX-License-Identifier: MPL-2.0 +// Unit tests of desktop/ui/js/local-changes.js (*Local changes*, #416: the +// files of the whole working folder grouped by item, the actions per row +// and per selection). Plain Node.js, no packages; run by the CI job `ui`: +// +// node scripts/desktop-local-changes.test.mjs +// +// The module sits in a folder without package.json, so it is imported as a +// data: URL module instead of by path. +import assert from "node:assert/strict"; +import fs from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const source = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../desktop/ui/js/local-changes.js"); +const { + LOCAL_STATES, localRevKey, localRowActions, localRowKey, localSummaryText, localVersionText, planLocalChanges, selectionActions +} = await import("data:text/javascript;base64," + fs.readFileSync(source).toString("base64")); + +let passed = 0; +function test(name, fn) { + fn(); + passed++; + console.log("ok - " + name); +} + +const file = (o) => Object.assign({ name: "bracket.prt", path: "ROVER/PRT-1/bracket.prt", state: "modified", + server_version: null, base_version: 2, writable: true, without_checkout: false }, o); +const rev = (o) => Object.assign({ project: "ROVER", item: "PRT-1", code: "A", checked_out: false, compared: true, + inaccessible: false, error: null, dir: "/ws/ROVER/PRT-1", files: [] }, o); + +test("a file modified without a check-out offers Check out (keep my file)", () => { + const plan = planLocalChanges({ revisions: [rev({ files: [file({ without_checkout: true })] })], truncated: false, compared: 1, tracked: 1 }); + assert.equal(plan.count, 1); + assert.equal(plan.withoutCheckout, 1); + const row = plan.items[0].revisions[0].rows[0]; + assert.deepEqual(row.actions, ["checkout", "folder"]); + assert.match(localSummaryText(plan), /1 modified/); + assert.match(localSummaryText(plan), /1 changed without a check-out/); +}); + +test("a conflict is merged in the Workspace tab, never checked in", () => { + const r = rev({ checked_out: true, files: [ + file({ name: "a.prt", path: "ROVER/PRT-1/a.prt", state: "conflict", server_version: 4 }), + file({ name: "b.prt", path: "ROVER/PRT-1/b.prt", state: "modified" }) + ] }); + const plan = planLocalChanges({ revisions: [r] }); + const rows = plan.items[0].revisions[0].rows; + assert.deepEqual(rows.map((x) => x.state), ["conflict", "modified"], "conflicts first"); + assert.deepEqual(rows[0].actions, ["merge", "folder"]); + assert.deepEqual(rows[1].actions, ["checkin", "folder"]); + assert.equal(localVersionText(rows[0]), "v4 on the server, yours v2"); + // ticking both: only the modified file is checked in, the conflict keeps the revision checked out + const ticked = {}; + rows.forEach((x) => { ticked[x.key] = true; }); + const sel = selectionActions(plan, ticked); + assert.equal(sel.checkin.changed.length, 1); + assert.deepEqual(sel.checkin.changed[0].upload, ["b.prt"]); + assert.deepEqual(sel.checkin.changed[0].conflicts, ["a.prt"]); + assert.deepEqual(sel.checkin.unreadable, []); + assert.equal(sel.rows, 2); +}); + +test("outdated and missing files offer Get latest", () => { + const r = rev({ files: [ + file({ name: "o.prt", path: "ROVER/PRT-1/o.prt", state: "outdated", server_version: 3 }), + file({ name: "m.prt", path: "ROVER/PRT-1/m.prt", state: "missing", writable: false }) + ] }); + const plan = planLocalChanges({ revisions: [r] }); + const rows = plan.items[0].revisions[0].rows; + assert.deepEqual(rows.map((x) => x.state), ["outdated", "missing"]); + rows.forEach((x) => assert.deepEqual(x.actions, ["get", "folder"])); + const ticked = {}; + ticked[rows[0].key] = true; + ticked[rows[1].key] = true; + const sel = selectionActions(plan, ticked); + assert.deepEqual(sel.get, [{ project: "ROVER", item: "PRT-1", code: "A" }], "one Get per revision"); + assert.deepEqual(sel.checkout, []); + assert.equal(plan.counts.outdated, 1); + assert.equal(plan.counts.missing, 1); +}); + +test("own check-outs: modified and new files are checked in", () => { + const r = rev({ checked_out: true, files: [file({}), file({ name: "bracket.step", path: "ROVER/PRT-1/bracket.step", state: "new" })] }); + const plan = planLocalChanges({ revisions: [r] }); + const rows = plan.items[0].revisions[0].rows; + assert.deepEqual(rows.map((x) => x.state), ["modified", "new"]); + rows.forEach((x) => assert.deepEqual(x.actions, ["checkin", "folder"])); + const ticked = {}; + ticked[rows[1].key] = true; + const sel = selectionActions(plan, ticked); + assert.deepEqual(sel.checkin.changed, [{ project: "ROVER", item: "PRT-1", code: "A", upload: ["bracket.step"], conflicts: [] }]); + assert.deepEqual(selectionActions(plan, {}).checkin.changed, [], "nothing ticked, nothing to do"); +}); + +test("grouping by item, sorted; empty revisions and other states are left out", () => { + const plan = planLocalChanges({ + revisions: [ + rev({ item: "PRT-9", files: [file({ path: "ROVER/PRT-9/x.prt" })] }), + rev({ item: "PRT-1", code: "A", files: [file({})] }), + rev({ item: "PRT-1", code: "B", files: [file({ path: "ROVER/PRT-1/B/bracket.prt" })] }), + rev({ item: "PRT-5", files: [file({ state: "up_to_date" })] }), + rev({ item: "PRT-7", files: [], error: "server unreachable" }) + ], + truncated: true, compared: 3, tracked: 9 + }); + assert.deepEqual(plan.items.map((i) => i.item), ["PRT-1", "PRT-9"]); + assert.deepEqual(plan.items[0].revisions.map((r) => r.code), ["A", "B"]); + assert.equal(plan.count, 3); + assert.deepEqual(plan.errors, ["PRT-7/A: server unreachable"]); + assert.equal(plan.truncated, true); + assert.equal(plan.compared, 3); + assert.equal(plan.tracked, 9); + assert.notEqual(plan.items[0].revisions[0].rows[0].key, plan.items[0].revisions[1].rows[0].key); +}); + +test("an inaccessible revision only opens its folder", () => { + assert.deepEqual(localRowActions(rev({ inaccessible: true }), file({ without_checkout: false })), ["folder"]); +}); + +test("keys ignore case and an empty scan plans nothing", () => { + assert.equal(localRowKey(rev({ project: "Rover" }), file({})), localRowKey(rev({ project: "ROVER" }), file({ path: "rover/prt-1/BRACKET.prt" }))); + assert.equal(localRevKey(rev({ item: "prt-1" })), localRevKey(rev({ item: "PRT-1" }))); + const plan = planLocalChanges(null); + assert.equal(plan.count, 0); + assert.deepEqual(plan.items, []); + assert.equal(localSummaryText(plan), ""); + assert.deepEqual(LOCAL_STATES, ["conflict", "modified", "new", "outdated", "missing"]); +}); + +console.log(passed + " tests passed"); From efb45913e79a28858fabffdd9f5fde56d277964c Mon Sep 17 00:00:00 2001 From: fork Date: Sun, 22 Nov 2026 21:02:55 +0100 Subject: [PATCH 2/2] Local changes: review fixes (#416) - the scan compares without side effects (workspace::status_with(.., false): no read-only flags, renames or state.json writes) - the server pass rotates a window over the revisions without local changes or own check-outs, so outdated files anywhere are found over a few scans; more than 100 revisions no longer marks the scan as truncated - files the local pass cannot check (hash budget, no base hash) are unknown: compared first, never listed as modified or offered a check-out on a guess - a check-in from the list takes every changed file of the revision along (revisionCheckin); the dialog names the unticked ones and offers Park - refreshWorklistCount keeps the 15 s throttle; Get, check-out, check-in, park and cancelled check-out rescan at once, folded into one pending scan - revision label is a keyboard-reachable button, decorative icon hidden - docs: desktop/README.md row moved into the feature table (and the stray #342 fragment back into its row), CHANGELOG, desktop guide, CLAUDE.md map Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 12 +- CLAUDE.md | 1 + desktop/README.md | 6 +- desktop/src/commands.rs | 3 +- desktop/src/localchanges.rs | 185 +++++++++++++++++++------ desktop/src/workspace.rs | 21 ++- desktop/ui/js/local-changes.js | 39 ++++-- desktop/ui/js/navigator.js | 51 ++++--- desktop/ui/js/shell.js | 25 ++-- desktop/ui/js/workspace.js | 13 +- docs/src/guide/desktop.md | 22 +-- scripts/desktop-local-changes.test.mjs | 26 +++- 12 files changed, 299 insertions(+), 105 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55ac227f..c8357aba 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,9 +27,15 @@ see the notices in the README. (`local_changes_scan`, `desktop/src/localchanges.rs`) compares `state.json` with the disk first (no network; unchanged files are never read, at most 512 MiB hashed per scan) and then the Workspace status of at - most 100 revisions (local changes first, then own check-outs); it runs when - the worklist opens, when the window gets the focus back (at most every - 15 s) and after a check-out, check-in or Get. The list rules are in + most 100 revisions (local changes first, then own check-outs, then a window + over the rest that moves on with every scan, so outdated files anywhere in + the folder are found over successive scans). The scan only compares: it + sets no read-only flags and writes no state. A check-in from the list takes + every changed file of the revision along (the check-in releases the + check-out; the dialog names the unticked ones and offers *Park* instead). + It runs when the worklist opens or is refreshed and when the window gets + the focus back (at most every 15 s), and at once after a check-out, + check-in, park, cancelled check-out or Get. The list rules are in `desktop/ui/js/local-changes.js`, tested by `scripts/desktop-local-changes.test.mjs`. diff --git a/CLAUDE.md b/CLAUDE.md index 28e87544..37eff19b 100755 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -220,6 +220,7 @@ desktop/ TeamCraft Desktop (Tauri 2, own Cargo project – never part HTML card layer, checked by scripts/desktop-graph-check.mjs), files-view.js = Home *Files* view, 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); + local-changes.js + desktop/src/localchanges.rs = worklist *Local changes* over the whole working folder (#416); 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/) diff --git a/desktop/README.md b/desktop/README.md index fcdc84bd..284d65b5 100755 --- a/desktop/README.md +++ b/desktop/README.md @@ -1,5 +1,4 @@ -| Local changes | Worklist section (#416): every file of the working folder that is modified, outdated, in conflict, new (a companion of a tracked file) or missing, grouped by item, counted on the rail – also a file changed without a check-out (read-only flag cleared, *not checked out*). Per row and for the ticked rows: *Check out* (keep my file, `workspace_checkout`), *Get latest* (`workspace_download`, local changes kept), *Check in selected* (`sendLocalChanges` of *Check in all*, conflicts stay checked out), *Merge…* (Workspace tab), *Folder*. The scan (`desktop/src/localchanges.rs`, `local_changes_scan`) first compares `.teamcraft/state.json` with the disk (no network, at most 50 000 entries, unchanged files not read, at most 512 MiB hashed), then runs the Workspace status (`workspace::status`) of at most 100 revisions one after the other – local changes first, then own check-outs; the first failing call stops that pass. Run when the worklist opens, on window focus (at most every 15 s) and after check-out, check-in or Get. Rules in `ui/js/local-changes.js` (`scripts/desktop-local-changes.test.mjs`) | -A failed export never stops the check-in: the file goes without its STEP and the result says why. With exports the ticked files are uploaded first (parked), then exported, then checked in with the STEP files; *Cancel* during an export skips it and ends the CAD program the script started (`teamcraft-started-pid:` line, `taskkill`); rejected COM calls (`RPC_E_CALL_REJECTED`, `RPC_E_SERVERCALL_RETRYLATER`) are retried for a minute; the whole error output goes to `/export-logs/` (newest 20, 64 KiB each, local only) – #342 |# TeamCraft Desktop +# TeamCraft Desktop The rich client of TeamCraft for **Linux, macOS and Windows**: a navigation rail, a navigator tree of the project groups, object tabs with sub-tabs, a @@ -36,7 +35,7 @@ TeamCraft server – it is a client, not an offline copy. | Old workspaces | Folders of the older layout `///` (and `//`) 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) | -| Native CAD previews | The preview image stored in Inventor and Solid Edge files in the Files tab, a picture of the 3D preview for NX and SOLIDWORKS files; on Windows *STEP* in the Workspace tab and *Create STEP exports … first* at check-in export with the installed Inventor or Solid Edge (COM automation through Windows PowerShell; uses your own licence); on every system SolidCraft designs (`.sc`) export through SolidCraft's `solidcraft-cli run --in … --out ….stp` (found through `SOLIDCRAFT_CLI`, `PATH` or the default install folders). A failed export never stops the check-in: the file goes without its STEP and the result says why | +| Native CAD previews | The preview image stored in Inventor and Solid Edge files in the Files tab, a picture of the 3D preview for NX and SOLIDWORKS files; on Windows *STEP* in the Workspace tab and *Create STEP exports … first* at check-in export with the installed Inventor or Solid Edge (COM automation through Windows PowerShell; uses your own licence); on every system SolidCraft designs (`.sc`) export through SolidCraft's `solidcraft-cli run --in … --out ….stp` (found through `SOLIDCRAFT_CLI`, `PATH` or the default install folders). A failed export never stops the check-in: the file goes without its STEP and the result says why. With exports the ticked files are uploaded first (parked), then exported, then checked in with the STEP files; *Cancel* during an export skips it and ends the CAD program the script started (`teamcraft-started-pid:` line, `taskkill`); rejected COM calls (`RPC_E_CALL_REJECTED`, `RPC_E_SERVERCALL_RETRYLATER`) are retried for a minute; the whole error output goes to `/export-logs/` (newest 20, 64 KiB each, local only) – #342 | | SolidCraft item data | *Item data* in the Workspace tab (SolidCraft designs of your check-out, not open in SolidCraft): `solidcraft-cli run