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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ see the notices in the README.

### Added

- **SolidCraft plugin: answers you can see.** SolidCraft shows the result of a
plugin entry only for read entries, so *TeamCraft status*, *Check for
TeamCraft* and *TeamCraft live status* are read entries again, over
`document.inspect`; until now their answers never appeared in SolidCraft's
dialog. *check* and *live* also say when the design has unsaved changes.
The BOM and linked-design checks moved to *Check assembly for TeamCraft*
(an edit entry: its findings go to the CLI, MCP and the assistant).
Requests now have one file per revision and action, so asking twice does
not ask twice, and *live* shows requests the desktop app has not taken yet.
16 cases pass on SolidCraft 0.45.0.
- **Desktop: the problem-report tracker as a policy** (#378, #381). The
managed-deployment policy `ReportUrl` (registry, macOS profile,
`/etc/teamcraft/policies.json`; ADMX/ADML and examples updated) names the
Expand Down
2 changes: 1 addition & 1 deletion desktop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +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 |
| 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>.<action>.json`, one per revision and action) 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
7 changes: 4 additions & 3 deletions desktop/src/scbridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
//! folder, `<working folder>/.teamcraft/solidcraft`, which the user grants
//! the plugin as `teamcraft`. This app writes its heartbeat (`desktop.json`)
//! and the state of each revision it shows (`state-<key>.json`); the plugin
//! leaves requests (`request-<key>.<time>.<action>.json`) that this app picks
//! leaves requests (`request-<key>.<action>.json`: one per revision and
//! action, so asking twice replaces the first) that this app picks
//! up, checks and hands to the user interface (event `solidcraft-request`).
//!
//! The plugin's side is `plugins/solidcraft/src/bridge.rs`; both use the same
Expand Down Expand Up @@ -169,7 +170,7 @@ pub fn check_request(
let revision = v["revision"].as_str().unwrap_or("");
let written = v["written_at"].as_u64().unwrap_or(0);
// the name and the content must say the same
let expected = format!("{}.{written}.{action}", key(item, revision));
let expected = format!("{}.{action}", key(item, revision));
if rest != expected {
return Err("name and content differ".into());
}
Expand Down Expand Up @@ -253,7 +254,7 @@ mod tests {
}

fn request(action: &str, at: u64) -> (String, Vec<u8>) {
let name = format!("request-PRT_2D000042.A.{at}.{action}.json");
let name = format!("request-PRT_2D000042.A.{action}.json");
let body = json!({"schema": "teamcraft.solidcraft.request", "version": 1,
"action": action, "item_number": "PRT-000042", "revision": "A",
"written_at": at});
Expand Down
43 changes: 30 additions & 13 deletions docs/src/research/solidcraft-bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,24 @@ directly. A **folder grant** is the one channel in both directions:
### Design properties stay for identity

`teamcraft.pdm` in the design (written by *Item data* or the plugin's
*Link*) keeps the stable identity: item number, revision and `revision_id`.
`revision_id` is the key into the bridge folder. Live state never goes into
the design.
*Link*) keeps the stable identity: item number and revision. They are the
key into the bridge folder (the desktop app's working-folder state knows
them, not the revision ids). Live state never goes into the design.

### Only read entries show a result

SolidCraft's entry dialog shows the result of a `read` entry; an `edit`
entry's dialog closes with *done* in the status bar
(`crates/ui-egui/src/plugin_menu.rs`, `poll_dialog`), and messages a plugin
logs go to the session log, which the window does not show. A read entry may
only call read-classified commands. `document.inspect` is one: it returns the
design's metadata as saved (`teamcraft.pdm` and SolidCraft's properties as
text keys), `dirty` (unsaved changes) and the file `path`
(`crates/engine/src/cmd/inspect.rs`; tried on 0.45.0). `document.metadata`,
`assembly.bom` and `component.links` are classed as edit commands. So the
plugin's *status*, *check* and *live* are read entries over
`document.inspect`; the BOM and link checks are an edit entry of their own,
whose findings reach the CLI, MCP and the assistant.

## Decision

Expand All @@ -73,13 +88,15 @@ plugin's run, a missing file does not. Times are Unix seconds (the plugin's
- `desktop.json` – the desktop app's heartbeat (`schema
"teamcraft.solidcraft.desktop"`, `version 1`, `written_at`, whether the
server is reachable), rewritten every 30 s.
- `state-<revision_id>.json` – the state of one revision in the working
folder: item number, revision, who has it checked out (display name, and
whether it is me), the latest revision on the server, the local state and
lifecycle state, the actions offered.
- `request-<revision_id>-<time>-<action>.json` – an intent from the plugin:
`check_out`, `check_in`, `open` or `refresh`. The desktop app deletes it
when handled; the result shows in the state file.
- `state-<key>.json` – the state of one revision in the working folder:
item number, revision, who has it checked out (display name, and whether it
is me), local changes, whether the check-out was released. `<key>` is the
item number and revision, every byte outside `A-Z a-z 0-9` written as `_XX`,
joined by `.` – reversible and safe as a file name.
- `request-<key>.<action>.json` – an intent from the plugin: `check_out`,
`check_in` or `open`, one file per revision and action (asking twice
replaces the first). The desktop app deletes it when it takes it; while it
is there, the plugin's *live* says the request waits.

Rules:

Expand All @@ -88,9 +105,9 @@ Rules:
"update TeamCraft".
- **No secrets** in the bridge: no tokens, no server credentials, display
names only. The folder is created `0700` where the system has modes.
- Requests are **untrusted intents**: the `revision_id` must be one in the
desktop app's working folder state (`[A-Za-z0-9-]` only), requests older
than 10 minutes are ignored, links, non-regular and oversized files are
- Requests are **untrusted intents**: the item and revision must be one in
the desktop app's working-folder state and match the file name, requests
older than 10 minutes are ignored, links, non-regular and oversized files are
refused. `check_in` only opens the desktop app's own check-in dialog; it
never runs silently.
- The existing entries (*status*, *check*, *link*, *unlink*) never touch
Expand Down
23 changes: 14 additions & 9 deletions plugins/solidcraft/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,27 @@ table) and a row in the Plugins menu.

| Entry | Effect | What it does |
|-------|--------|--------------|
| **status** – *TeamCraft status* | edit¹ | The TeamCraft item and revision the design belongs to, the page of the revision on the server, and whether the design's part number and revision still say the same. |
| **check** – *Check for TeamCraft* | edit¹ | What keeps the design from going into TeamCraft cleanly: no part number, a part number or revision that differs from the linked item, BOM rows without a part number, one part number with two descriptions, quantities SolidCraft cannot add up, linked designs with an absolute path or two linked designs with the same file name. `ready` is true when only notes are left. |
| **status** – *TeamCraft status* | read | The TeamCraft item and revision the design belongs to, the page of the revision on the server, and whether the design's part number and revision still say the same. |
| **check** – *Check for TeamCraft* | read | What keeps the design from going into TeamCraft cleanly: no part number, a part number or revision that differs from the linked item, unsaved changes. `ready` is true when only notes are left. |
| **check-assembly** – *Check assembly for TeamCraft* | edit¹ | The bill of materials and the linked designs: BOM rows without a part number, one part number with two descriptions, quantities SolidCraft cannot add up, linked designs with an absolute path or two linked designs with the same file name. |
| **link** – *Link to TeamCraft item* | edit | Writes item number, revision and (optional) name into the design properties (*Part number*, *Revision*, *Description*) and TeamCraft's object – for designs edited without the desktop app. Ids written by the desktop app are kept while the item stays the same. One undo step; save the design afterwards. |
| **unlink** – *Unlink from TeamCraft* | edit | Removes TeamCraft's object; part number and revision stay. |
| **live** – *TeamCraft live status* | edit¹ | What the TeamCraft desktop app last shared about this revision: who has it checked out, the latest revision on the server, local changes – and whether the desktop app runs and reaches the server. Needs the folder (below). |
| **live** – *TeamCraft live status* | read | What the TeamCraft desktop app last shared about this revision: who has it checked out, local changes, requests it has not taken yet, unsaved changes – and whether the desktop app runs and reaches the server. Needs the folder (below). |
| **check-out** – *Check out in TeamCraft* | edit | Asks the desktop app to check out this revision; it asks you before it does. Needs the folder. |
| **check-in** – *Check in with TeamCraft* | edit | Asks the desktop app to open its check-in dialog for this revision. Save the design first. Needs the folder. |
| **open** – *Open in TeamCraft* | edit | Asks the desktop app to show this revision. Needs the folder. |

¹ *status*, *check* and *live* only read. They are declared `edit` because SolidCraft
classes `document.metadata`, `assembly.bom` and `component.links` as edit
commands and refuses them from a read entry (*permission denied: edit command
document.metadata from read entry*).
SolidCraft shows the result of a **read** entry in its dialog; an **edit**
entry's dialog just closes with *done*. *status*, *check* and *live* are read
entries over `document.inspect`, so their answers are shown.

¹ *check-assembly* only reads, but SolidCraft classes `assembly.bom` and
`component.links` as edit commands and refuses them from a read entry, so it
is an edit entry: its findings reach the CLI, MCP and the assistant, while
SolidCraft's dialog only says *done*.

SolidCraft commands it calls (declared in `plugin.json`, none of them reads
or writes files): `document.metadata`, `document.metadata.set`,
or writes files): `document.inspect`, `document.metadata.set`,
`document.metadata.remove`, `assembly.bom`, `component.links`.

## The folder shared with the desktop app
Expand Down Expand Up @@ -75,7 +80,7 @@ not running never makes it fail. What it says when something does go wrong:
cannot catch it (SolidCraft 0.45). So the plugin only calls commands that
answer on any design – a part without components gives an empty BOM and no
links – and checks its input before it writes. On a host that hands the
error back, the plugin adds what to do, and *check* reports a BOM or link
error back, the plugin adds what to do, and *check-assembly* reports a BOM or link
list it could not read as a warning instead of *ready*.

## Build
Expand Down
14 changes: 10 additions & 4 deletions plugins/solidcraft/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@
"entries": [
{
"name": "status",
"effect": "edit",
"effect": "read",
"input_schema": {"type": "object", "properties": {}},
"slots": [{"kind": "ribbon", "name": "TeamCraft status"}]
},
{
"name": "check",
"effect": "edit",
"effect": "read",
"input_schema": {"type": "object", "properties": {}},
"slots": [{"kind": "ribbon", "name": "Check for TeamCraft"}]
},
{
"name": "check-assembly",
"effect": "edit",
"input_schema": {"type": "object", "properties": {}},
"slots": [{"kind": "ribbon", "name": "Check assembly for TeamCraft"}]
},
{
"name": "link",
"effect": "edit",
Expand All @@ -42,7 +48,7 @@
},
{
"name": "live",
"effect": "edit",
"effect": "read",
"input_schema": {"type": "object", "properties": {}},
"slots": [{"kind": "ribbon", "name": "TeamCraft live status"}]
},
Expand All @@ -66,7 +72,7 @@
}
],
"commands": [
"document.metadata",
"document.inspect",
"document.metadata.set",
"document.metadata.remove",
"assembly.bom",
Expand Down
19 changes: 9 additions & 10 deletions plugins/solidcraft/src/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! as `teamcraft` when installing it. The desktop app writes its heartbeat
//! (`desktop.json`) and the state of each revision in the working folder
//! (`state-<key>.json`); the plugin writes requests
//! (`request-<key>.<time>.<action>.json`) that the desktop app carries out.
//! (`request-<key>.<action>.json`) that the desktop app carries out.
//! The format is the desktop app's too (`desktop/src/scbridge.rs`); the test
//! vectors below are the same on both sides.
//!
Expand Down Expand Up @@ -50,9 +50,11 @@ pub fn state_file(item: &str, revision: &str) -> String {
format!("state-{}.json", key(item, revision))
}

/// `request-<key>.<time>.<action>.json`.
pub fn request_file(item: &str, revision: &str, now: u64, action: &str) -> String {
format!("request-{}.{now}.{action}.json", key(item, revision))
/// `request-<key>.<action>.json` – one name per revision and action: asking
/// twice replaces the first request, and while the file is there the desktop
/// app has not taken it yet.
pub fn request_file(item: &str, revision: &str, action: &str) -> String {
format!("request-{}.{action}.json", key(item, revision))
}

/// A bridge file, checked: its schema, a version this plugin understands.
Expand Down Expand Up @@ -171,13 +173,10 @@ mod tests {
assert_ne!(key("A_2D", "B"), key("A-", "B"));
assert_eq!(state_file("PRT-000042", "A"), "state-PRT_2D000042.A.json");
assert_eq!(
request_file("PRT-000042", "A", 1_700_000_000, "check_in"),
"request-PRT_2D000042.A.1700000000.check_in.json"
request_file("PRT-000042", "A", "check_in"),
"request-PRT_2D000042.A.check_in.json"
);
for name in [
state_file("../x", ".."),
request_file("a b", "c", 1, "open"),
] {
for name in [state_file("../x", ".."), request_file("a b", "c", "open")] {
assert!(name
.bytes()
.all(|b| b.is_ascii_alphanumeric() || b"_.-".contains(&b)));
Expand Down
Loading
Loading