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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ jobs:
# the reviewers of the release dialog and when a draft can be submitted
- name: Test the release rules
run: node scripts/desktop-release-rules.test.mjs
# the key inputs of a failed action in *Report…* (#381)
- name: Test the report inputs
run: node scripts/desktop-report-inputs.test.mjs
# the entries of the right-click menu of an item and why one is
# disabled – the revision toolbar's rules (#417)
- name: Test the item menu rules
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ see the notices in the README.

### Added

- **Request ids** (#381): every answer of the server carries an
`x-request-id` header (a new UUID, or a reverse proxy's own id of 1–64
characters `[A-Za-z0-9-]`), the request's log line records it as
`request_id`, and the web UI's error pages show it under *Details for a bug
report* and in *Copy details*.
- **Desktop: key inputs in problem reports** (#381): *Report…* on an error
now names what the action worked on – project group, item, revision, file
and format, the ticked files of a check-in, the options of a BOM or folder
import – for check-out, check-in and park, *Get files*, opening files, the
3D preview and STL export, STEP exports, new items, adding files, BOM and
folder imports and request attachments. Names and short values only (a path
is reduced to its file name, at most 12 values of 200 characters); a 3D
preview that cannot be loaded from the server now also shows an error
message with *Report…*.
- SolidCraft design properties (#367): part number, revision, description, project, author, organisation and licence are read from `.sc` designs at upload and check-in (bounded, text values only, migration `0078_file_properties`), listed under the file on the revision page and in the desktop app, returned as `properties`/`properties_line` with the file in the REST API (and `design_properties` in the MCP file briefs), and found by the full-text search. The revision page – web and desktop – shows a notice when they differ from the item number, revision code or name (`property_mismatches` of `GET /api/v1/items/{n}/revisions/{c}`) – worked out on every view, nothing is changed automatically. A new item created in the web UI with a design and no name takes the design's description; the desktop's *New item* (and *Create items…* of the worklist) and *Import a CAD folder* fill an empty description from it.
- **Thumbnails in lists** (#420): the picture of a revision's main model (the
rule of the revision page, now in `services::thumbnails`; a stand-alone JT
Expand Down
3 changes: 2 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ src/main.rs CLI (clap): serve (default), local (test installation, src/lo
src/localserver.rs `teamcraft local`: private PostgreSQL cluster (bundled postgresql/bin, --pg-bin or installed; initdb with a random
scram password, 127.0.0.1 + free port, no socket) + the server on 127.0.0.1 via a config overlay; stops PostgreSQL
after the server, port file against a second instance, --exit-with-stdin for the desktop app
src/lib.rs AppState, router (healthz/readyz, /api/v1, web UI), security headers, tracing
src/lib.rs AppState, router (healthz/readyz, /api/v1, web UI), security headers, request ids (x-request-id,
outermost layer; RequestId extension read by web::html_errors), tracing
src/config.rs env configuration; every variable also as NAME_FILE; all optional for local use
src/domain.rs pure rules: Role, ItemType, LifecycleState, ChangeStatus, revision letters, numbering schemes, skins, validation
src/services/ business logic – the only code that writes to the database
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ end-to-end tests against a real PostgreSQL.
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
decides about and an update notice (never installs anything itself). The
decides about, *Report…* on every error (a reviewed, redacted report with
the action and its key inputs; nothing is sent without a click) 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*).
- **REST API** – everything the UI does, with personal access tokens.
Expand Down
2 changes: 1 addition & 1 deletion desktop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ TeamCraft server – it is a client, not an offline copy.
| Notifications | Bell with unread count and toasts; **Watch** / **Unwatch** |
| Agent | **Agent** in the rail (`Ctrl/Cmd+4`, or *Agent* in a revision or change tab) – the app's one place for AI, on one of two backends. **Company AI**: the server's assistant (the web UI's *Ask TeamCraft*, inline in the Agent tab; the key stays on the server) – it knows the last revision (and section, BOM rule), change or request tab, offers matching quick actions (*Draft release notes*, *Check before release*, *Brief me for this review* …), the drafts checkbox and one conversation kept on the server; read-only unless drafts are allowed. **Local agent**: an agent you configure under *Settings → Agents…* (Claude Code through its ACP adapter, Gemini CLI, any [Agent Client Protocol](https://agentclientprotocol.com) agent; none by default). The app starts it in the workspace folder and hands it TeamCraft's MCP server with your token. Streamed conversation, tool calls, plan, permission prompts (*Allow once* / *Reject*; calls of TeamCraft's own read-only MCP tools – by the server's `tools/list` annotations – are allowed once without a prompt and marked *Allowed automatically (read-only)*, since the server answers with your rights only; write tools, other servers' tools, the agent's own tools and anything not identified for certain still ask; *Settings → Agents… → Ask before read-only TeamCraft tools* asks for everything), the agent's own model picker (remembered per agent), *Cancel*, quick prompts from the server's MCP prompts, the open revision or change as context. Through the app the agent may only read text files in the workspace – no writing, no terminal. With both on the server, *Company AI* / *Local agent* in the Agent toolbar switches (remembered per server and user; default: the local agent if one is set up). When the server sets `TEAMCRAFT_LOCAL_AGENTS=off` the Agent view runs on the company AI only, the Rust side ends a running agent and refuses to start one (the app asks the server again when the Agent view opens, every minute and before every message, so a changed setting needs no restart); without a company AI the view says that AI is switched off. See [the guide](../docs/src/guide/assistant.md#acp-agents-in-the-desktop-app) |
| Pack and Go, STL | ZIP of a revision and its structure, with a progress dialog and *Cancel* (also while the server packs); written as `<name>.teamcraft-download` and renamed when complete, removed on cancel or error; **Export STL…** from the 3D viewer |
| Report a problem | *Help → Report a Problem…* and *Report…* on every error message (toasts and dialog errors, #381): one review dialog with the title "<action>: <error>" (cut at a word, `…`), a description with the action, its key inputs (`run(text, fn, inputs)`, `toast(…, action, inputs)`, `dialog(…, { inputs })`: group, item, revision, file and format, import options – names only, a path reduced to its file name, at most 12 values of 200 characters; `ui/js/report-inputs.js`, tested by `scripts/desktop-report-inputs.test.mjs`), the error and the versions, "What were you trying to do?" (left out when empty) and, ticked, the last 50 error messages of the session – all redacted in Rust like crash reports (`src/report.rs`: home folder → `~`, addresses → `[url]`, tokens → `[token]`). Nothing leaves the app without a click: *Open issue form* (GitHub, or *Settings → Report problems to*: the operator's own form, which gets `title` and `body`, or the policy `ReportUrl`; a long text is cut in the link and copied in full), *Copy report*, *Save report…* (work offline). The web UI's error pages have *Copy details* (status, message, page, time, version, request id = the `x-request-id` header and the server log's `request_id`) |
| Usage report | Once a day of use the app sends its own TeamCraft server (`POST /api/v1/usage`) an anonymous report of the day before (`src/usage.rs`, #383): a random installation id, versions, OS, architecture, package type, minutes with the window in front, and counts of fixed actions (checkout, checkin, park, cancel_checkout, get_files, open_cad, open_3d_preview, import_bom, import_folder, new_item, release, search, assistant – a test checks each has a count site) and STEP exports per program – never names, numbers, paths or anything typed. *Settings → Privacy → Show what is sent* shows it. The server shares an aggregate with the developers only if its administrator turns that on (admin guide: *Privacy*) |
| Report a problem | *Help → Report a Problem…* and *Report…* on every error message (toasts and dialog errors, #381): one review dialog with the title "<action>: <error>" (cut at a word, `…`), a description with the action, key inputs, the error and the versions, "What were you trying to do?" (left out when empty) and, ticked, the last 50 error messages of the session – all redacted in Rust like crash reports (`src/report.rs`: home folder → `~`, addresses → `[url]`, tokens → `[token]`). Nothing leaves the app without a click: *Open issue form* (GitHub, or *Settings → Report problems to*: the operator's own form, which gets `title` and `body`, or the policy `ReportUrl`; a long text is cut in the link and copied in full), *Copy report*, *Save report…* (work offline). The web UI's error pages have *Copy details* (status, message, page, time, version) |
| Managed deployment | Policies per computer or user, read once at start and never sent (`src/policy.rs`, #378): `ServerUrl` (+ `AllowOtherServers`), `CheckForUpdates`, `CrashReportPrompt`, `WorkspaceRoot`, `OrganizationName`, `UsageStatistics` – Windows registry `Software\Policies\TeamCraft` (HKLM wins over HKCU; ADMX/ADML in `deploy/desktop-policies/windows`), macOS managed preferences of `io.github.rudalabs.teamcraft` (`plutil`), Linux `/etc/teamcraft/policies.json`. Wrong types and out-of-range values count as not set; fixed settings show *Set by your organization* and are disabled; *Managed by …* in Settings and About. Admin guide: *Deploying the desktop app* |
| Crash reports | Panics, uncaught UI errors and sessions that ended unexpectedly (web view crash, force-quit hang) are written to a local, redacted report (no home folder, server addresses, tokens or item data). At the next start the app shows it and asks: *Report on GitHub…* (a prefilled issue you submit yourself), *Copy* or *Delete report*. Nothing is sent without that choice; *Settings → Crash reports* turns the question off |
| Language | *Settings → Language* (#379): *As the system* (`navigator.languages`: exactly, then by base language, else English), *English*, *Deutsch* – kept on this computer, applied at the next start. Messages come from `shared/i18n/<lang>.json` through `shared/js/i18n.js` (`t(id, params)`, English fallback); translated so far: the *Settings* dialog and the empty states (#423) |
Expand Down
9 changes: 7 additions & 2 deletions desktop/ui/js/bom-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { selectView } from "./navigator.js";
import { activeTab, reloadActive, stat, table } from "./tabs.js";
import { openRevision } from "./revision.js";
import { baseName } from "./dialogs.js";
import { revisionInputs } from "./report-inputs.js";

// ------------------------------------------------------------ Import BOM

Expand Down Expand Up @@ -65,7 +66,7 @@ export function bomFromCadDialog(rev) {
}, function (err) { applyButton.disabled = false; d.fail(err); });
}
}
], { wide: true });
], { wide: true, inputs: revisionInputs(rev) });
applyButton = handle.form.querySelector(".dialog-actions button.primary");
applyButton.disabled = true;
api("GET", base).then(function (p) {
Expand Down Expand Up @@ -236,7 +237,11 @@ export function openImportBomDialog(rev) {
});
}
}
], { wide: true });
], { wide: true, inputs: function () {
// *Report…* (#381): the file name and the options, never the BOM lines
var extra = [["file", path ? baseName(path) : ""], ["numbers", numbers.value], ["match existing", match.checked ? "yes" : "no"]];
return rev ? revisionInputs(rev, extra) : [["group", project.value]].concat(extra);
} });
importButton = handle.form.querySelector(".dialog-actions button.primary");
importButton.disabled = true;
}
33 changes: 26 additions & 7 deletions desktop/ui/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { showConnect } from "./connect.js";
import { agent } from "./agent.js";
import { projectItems } from "./group-sync.js";
import { label } from "/static/shared/js/format.js";
import { failureOf } from "./report-inputs.js";

export var TAURI = window.__TAURI__;
export var invoke = TAURI.core.invoke;
Expand Down Expand Up @@ -289,15 +290,26 @@ function rememberError(text) {
state.recentErrors = (state.recentErrors || []).concat([new Date().toISOString().slice(11, 19) + " " + text]).slice(-50);
}

/** A message at the bottom; `action` names what failed, for *Report…*. */
export function toast(text, kind, action) {
/** `inputs` as given to run()/dialog(): a list of [name, value] or a function returning one. */
function inputsNow(inputs) {
if (typeof inputs !== "function") return inputs;
try { return inputs(); } catch (e) { return []; }
}

/**
* A message at the bottom; `action` names what failed and `inputs` are its
* key inputs (as for run()), both for *Report…*.
*/
export function toast(text, kind, action, inputs) {
var el = h("div.toast" + (kind ? "." + kind : ""), { role: kind === "error" ? "alert" : "status" }, [h("span", { text: text })]);
if (kind === "error") {
rememberError((action ? action + ": " : "") + text);
if (reportHook.open) {
// the key inputs of the action (#381), taken when the error is shown
var failure = failureOf(action, text, inputsNow(inputs));
el.appendChild(h("button.link.small", { type: "button", on: { click: function () {
el.remove();
reportHook.open({ action: action || "", error: text });
reportHook.open(failure);
} } }, "Report…"));
}
}
Expand Down Expand Up @@ -325,15 +337,20 @@ export function api(method, path, body) {

export function enc(s) { return encodeURIComponent(s); }

/** Runs an action with status text and error toast; returns its promise. */
export function run(statusText, fn) {
/**
* Runs an action with status text and error toast; returns its promise.
* `inputs` (optional): the key inputs of the action as [[name, value], …]
* (or a function returning them) – names and short values only, never file
* contents or item data; they go into a *Report…* of the error (#381).
*/
export function run(statusText, fn, inputs) {
setStatus(statusText + " …");
return Promise.resolve().then(fn).then(function (v) {
setStatus("");
return v;
}, function (err) {
setStatus("");
toast(errorText(err), "error", statusText);
toast(errorText(err), "error", statusText, inputs);
throw err;
});
}
Expand Down Expand Up @@ -369,7 +386,9 @@ export function dialog(title, body, actions, opts) {
rememberError(title + ": " + text);
// *Report…* (#381): the dialog's title is the action that failed
if (reportHook.open) {
errorEl.append(" ", h("button.link.small", { type: "button", on: { click: function () { reportHook.open({ action: title, error: text }); } } }, "Report…"));
// opts.inputs: the key inputs of the dialog's action, as for run()
var failure = failureOf(title, text, inputsNow(opts.inputs));
errorEl.append(" ", h("button.link.small", { type: "button", on: { click: function () { reportHook.open(failure); } } }, "Report…"));
}
errorEl.classList.remove("hidden");
}
Expand Down
11 changes: 9 additions & 2 deletions desktop/ui/js/dialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { newItemFolder } from "./files-view.js";
import { describeFromDesign, formatKinds } from "./folder-import.js";
import { newItemFindings, newItemKeyText, newItemPlacement, newItemSummary } from "./new-files.js";
import { openRevision } from "./revision.js";
import { revisionInputs } from "./report-inputs.js";

// ======================================================================
// Dialogs: new item, settings, about
Expand Down Expand Up @@ -264,6 +265,11 @@ export function openNewItemDialog(opts) {
runCheck(token).catch(function (err) { if (token === inspection) { findings = null; showInfo(); info.appendChild(line(".notice.error", errorText(err))); } });
}, 400);
}
// *Report…* (#381): what the new item was to be, never its description
function newItemInputs() {
return [["group", group()], ["type", type.value], ["item folder", itemFolder()], ["number", number.value.trim()],
["files", paths.map(baseName).join(", ")]];
}
dialog("New item", h("div.stack", null, [
field("Files", h("div.stack", null, [pick, fileList]), "the CAD model with its drawing and a STEP export for the 3D preview – uploaded right after the item is created; files in the working folder keep their folder"),
h("div.grid-2", null, [field("Type", type), field("Project group", project)]),
Expand Down Expand Up @@ -313,15 +319,16 @@ export function openNewItemDialog(opts) {
if (err && err.createdRevision) {
var rev = err.createdRevision;
d.close();
toast("Created " + rev.item_number + "/" + rev.code + ", but the files could not be uploaded: " + errorText(err), "error");
toast("Created " + rev.item_number + "/" + rev.code + ", but the files could not be uploaded: " + errorText(err), "error",
"Uploading the files of the new item", revisionInputs(rev, [["files", paths.map(baseName).join(", ")]]));
afterCreate(rev);
return;
}
d.fail(err);
});
}
}
], { wide: true });
], { wide: true, inputs: newItemInputs });
function afterCreate(rev) {
openRevision(rev.item_number, rev.code);
if (createdIn) delete state.expanded[createdIn];
Expand Down
6 changes: 5 additions & 1 deletion desktop/ui/js/folder-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,11 @@ export function openImportFolderDialog() {
{ label: "Close", onClick: function (d) { stop = true; d.close(); } },
{ label: "Scan", onClick: function (d) { if (!running) scanNow(d); } },
{ label: "Import", primary: true, submit: true, onClick: importNow }
], { wide: true });
], { wide: true, inputs: function () {
// *Report…* (#381): the folder's name (not its path) and the options
return [["folder", folder.value], ["group", project.value], ["numbers from names", fromNames.checked ? "yes" : "no"],
["documents item", extras.checked ? "yes" : "no"], ["bom", bom.checked ? "yes" : "no"]];
} });
}

/** The report line of the BOM lines created from the CAD references. */
Expand Down
Loading
Loading