Skip to content
Merged
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ see the notices in the README.

### Added

- **SolidCraft plugin ↔ desktop app** (research page *Talking to the desktop
app from inside SolidCraft*). SolidCraft plugins have no network, so the
plugin and the desktop app share `<working folder>/.teamcraft/solidcraft`:
the app writes a heartbeat and the state of each revision it shows, the
plugin's new entries read it and leave requests – *TeamCraft live status*,
*Check out in TeamCraft*, *Check in with TeamCraft*, *Open in TeamCraft*.
The app checks each request (a revision of its working folder, a known
action, fresh, small, a regular file), asks before a check-out and opens its
check-in dialog for a check-in. The app not running is never an error: the
plugin says so and shows what the app last knew; a request waits 10 minutes.
The old entries need no folder. 14 cases in `plugins/solidcraft/tests/` run
on the real SolidCraft (`solidcraft-cli plugin test --require-cases`), and
`build.sh` also makes the `.zip` SolidCraft installs.
- **SolidCraft designs show their picture** (#364). The preview image of a
`.sc` design is the PNG SolidCraft embeds when saving with its model, read
from the ZIP container with size and CRC checks and shown only when its key
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ end-to-end tests against a real PostgreSQL.
- **SolidCraft and FieldCraft** – [SolidCraft](https://github.com/tangency-labs/solidcraft)
designs (`.sc`, checked by content) and
[FieldCraft](https://github.com/tangency-labs/fieldcraft) models (`.fieldcraft`) are recognised, SolidCraft's embedded picture is the preview image, linked designs are
file references with quantities, SolidCraft's BOM CSV and the design itself import as a BOM, the desktop app exports designs to STEP with `solidcraft-cli`, a TeamCraft plugin for SolidCraft shows and checks the design's TeamCraft item inside SolidCraft, and their STEP and 3MF
file references with quantities, SolidCraft's BOM CSV and the design itself import as a BOM, the desktop app exports designs to STEP with `solidcraft-cli`, a TeamCraft plugin for SolidCraft shows and checks the design's TeamCraft item inside SolidCraft – and, through a folder shared with the desktop app, its live state and requests to check out, check in or open it – and their STEP and 3MF
exports previewed –
design, export and analysis in one revision ([more](https://warr-ev.github.io/TeamCraft/reference/interop.html)).

Expand Down
2 changes: 2 additions & 0 deletions desktop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ TeamCraft server – it is a client, not an offline copy.
| 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 |
| SolidCraft item data | *Item data* in the Workspace tab (SolidCraft designs of your check-out, not open in SolidCraft): `solidcraft-cli run <script> --in <design> --save <design>` with one `document.metadata.set` – `part_number`, `revision`, `description` and `teamcraft.pdm` (item and revision ids, server); `src/scprops.rs` |
| SolidCraft plugin bridge | The TeamCraft plugin inside SolidCraft has no network, so the app shares `<workspace>/.teamcraft/solidcraft` with it (`src/scbridge.rs`, `ui/js/solidcraft-bridge.js`): every 30 s a heartbeat (`desktop.json`: the app runs, the server answers), on every Workspace refresh the state of the revision (`state-<key>.json`: checked out by, local changes, released), every 5 s the plugin's requests (`request-<key>.<time>.<action>.json`) are picked up, checked (a revision of this working folder, a known action, fresh, small, a regular file) and removed: *open* shows the revision, *check out* asks first, *check in* opens the check-in dialog. Only for a working folder that exists; no secrets in the folder |
| Check out and open | *Check out and open* on the revision toolbar (*Open in CAD* for one's own check-out) takes the lock, gets the files and opens the main CAD file; the chip next to it names the program (e.g. *Inventor 2026*). The program: the project group's default CAD program (`default_cad`, `default_cad_version` of `GET /api/v1/projects`) in its version, else its newest installed version; without a default, or for a file of another program, the newest installed version of the program that fits the file (`format_info.family`); else the system's default application. Installed programs are found by their install folders (Windows *Program Files*, SOLIDWORKS via `reg query`; macOS `/Applications`; FreeCAD on the Linux `PATH`), once per start – `src/cadlaunch.rs`, `ui/js/cad-open.js`; *Open* in the Files tab uses the same choice. On Windows an Inventor that already runs – the chosen installation, with the working folder's Inventor project active (the `.ipj` in the nearest folder up to the working folder root) – opens the file as a new window instead of a second instance (#350; asked through COM by a Windows PowerShell script: `GetActiveObject`, `InstallPath`, `ActiveDesignProject`, `Documents.Open`); otherwise a new instance starts and the message says why. After *Cancel* during the download, or with files that could not be copied, nothing is opened (#348, `ui/js/get-rules.js`). *Import CAD folder* detects the folder's program (Inventor with the release year read from the files, `folderimport::inventor_year`) and offers to set it as the group's default |
| Preferred CAD program | The account setting of the web UI (`preferred_cad` of `GET /api/v1/me`, read at sign-in): when a revision has files of that program, the Files tab lists the native files of other CAD programs (`format_info.family`) in a collapsed *N files in other CAD formats (…)* group; neutral files (STEP, JT, STL, PDF, …) stay visible. Grouped in `ui/js/revision.js` (`groupByFamily`) with the same rule as the server's `cadformat::group_by_family`; display only |
| Whole project groups locally | the download icon in the navigator (*Tools → Get Project Groups…*): copies the files of every item of the chosen groups – latest revision (also in work, the default since #355) or latest released – into the working folder with their folder structure; unchanged files are skipped, locally modified files kept, name clashes reported. For new team members or a fresh computer |
Expand Down Expand Up @@ -199,6 +200,7 @@ src/settings.rs settings.json (incl. the configured agents), the token in the
src/update.rs update notice and window: latest GitHub release at most daily, version comparison, install kind,
release file, SHA256SUMS.txt verification of the download (#377)
src/scprops.rs item number, revision and name written into a SolidCraft design's properties through solidcraft-cli (#369)
src/scbridge.rs the folder shared with the SolidCraft plugin: heartbeat, revision state, the plugin's requests (checked, then the UI)
src/cadlock.rs files a CAD program has open, from its lock files (SolidCraft `.~<file>.lock`; stale locks ignored)
src/crash.rs crash reports: panic hook, session markers (unexpected exits), UI errors – redacted, kept locally until the user shares them
src/acp.rs Agent Client Protocol client: agent subprocess, JSON-RPC over stdio, session, permissions, workspace-only reads
Expand Down
59 changes: 50 additions & 9 deletions desktop/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ use tokio::sync::Notify;
use crate::{
acp, addfiles,
api::{self, Api, ApiError, Transfer},
bomimport, cadexport, cadlaunch, folderimport, layout, localserver, policy, profiles, scprops,
bomimport, cadexport, cadlaunch, folderimport, layout, localserver, policy, profiles, scbridge,
scprops,
settings::{self, Settings, TokenStorage},
signin, update, workspace, AppState,
};
Expand Down Expand Up @@ -793,14 +794,15 @@ pub async fn workspace_status(
code: String,
) -> CmdResult<workspace::Status> {
let api = signed_in_api(&state)?;
workspace::status(
&api,
&workspace_root(&app, &state),
project.as_deref(),
&item,
&code,
)
.await
let root = workspace_root(&app, &state);
let status = workspace::status(&api, &root, project.as_deref(), &item, &code).await?;
// the SolidCraft plugin shows it (bridge folder, src/scbridge.rs); a
// failed write only means the plugin shows older state
if root.is_dir() {
let value = scbridge::state(scbridge::now_secs(), &item, &code, &status);
let _ = scbridge::write(&root, &scbridge::state_file(&item, &code), &value);
}
Ok(status)
}

/// Check in the chosen files (new versions) and release the lock.
Expand Down Expand Up @@ -2666,3 +2668,42 @@ pub fn set_report_url(state: State<'_, AppState>, url: String) -> CmdResult<()>
update_settings(&state, |s| s.report_url = value)?;
Ok(())
}

/// The bridge to the SolidCraft plugin (src/scbridge.rs), for as long as the
/// app runs: every 5 s the plugin's requests are picked up and handed to the
/// user interface (event `solidcraft-request`); every 30 s the heartbeat says
/// that the app runs and whether it reaches the server. Only for a working
/// folder that exists – the bridge never creates one.
pub(crate) async fn solidcraft_bridge(app: AppHandle) {
let mut tick: u64 = 0;
loop {
let (root, api) = {
let state = app.state::<AppState>();
(workspace_root(&app, &state), signed_in_api(&state).ok())
};
if root.is_dir() {
let beat = if tick % 6 == 0 {
let reachable = match &api {
Some(api) => api.json(Method::GET, "/me", None).await.is_ok(),
None => false,
};
Some(scbridge::heartbeat(scbridge::now_secs(), reachable))
} else {
None
};
let requests = tokio::task::spawn_blocking(move || {
if let Some(beat) = beat {
let _ = scbridge::write(&root, "desktop.json", &beat);
}
scbridge::take_requests(&root, scbridge::now_secs())
})
.await
.unwrap_or_default();
for request in requests {
let _ = app.emit("solidcraft-request", &request);
}
}
tick = tick.wrapping_add(1);
tokio::time::sleep(std::time::Duration::from_secs(5)).await;
}
}
3 changes: 3 additions & 0 deletions desktop/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ mod policy;
mod profiles;
mod report;
mod resume;
mod scbridge;
mod scprops;
mod settings;
mod signin;
Expand Down Expand Up @@ -224,6 +225,8 @@ fn main() {
get_cancel: Arc::new(AtomicBool::new(false)),
local_server: Mutex::new(None),
});
// the SolidCraft plugin's bridge folder: heartbeat, state, requests
tauri::async_runtime::spawn(commands::solidcraft_bridge(app.handle().clone()));
build_menu(app)?;
if let Some(window) = app.get_webview_window("main") {
if let Some(zoom) = zoom {
Expand Down
Loading
Loading