Skip to content

Check out several parts of an assembly at once (#415) - #445

Merged
Sebagrei merged 3 commits into
mainfrom
feature/415-checkout-several-parts
Nov 22, 2026
Merged

Sebagrei merged 3 commits into
mainfrom
feature/415-checkout-several-parts

Conversation

@Sebagrei

Copy link
Copy Markdown
Collaborator

Closes #415

What changed

Server – POST /api/v1/checkouts (services::checkouts::checkout_many)

  • Body {"revisions": [{"id": …} | {"item": "PRT-1", "code": "A"}]} (code latest = newest), at most 500 entries, duplicates answered once.
  • Choice: a server batch with a result per revision, not all-or-nothing and not N client calls. The issue wants refusals reported while the rest go through. One round trip, one consistent moment for the whole set, and the rules of the single check-out (revisions::ensure_checkout_possible) stay in one place. This is documented in the CHANGELOG and api.md.
  • One transaction. All rows are locked in one SELECT … FOR UPDATE ORDER BY id, so two overlapping batches cannot deadlock: the second waits, then reports the parts the first took as locked. The full rows are read after the lock, so holder names are current.
  • Per revision: ok, already (held before: no change, no audit), reason (not_found, released, in_review, locked, forbidden), message, checked_out_by_name. Hidden revisions answer exactly like missing ones and echo only what the caller sent.
  • One revision.checkout audit record per changed revision. Viewers get 403 for the whole request.
  • Route added to the router and the route list in api/mod.rs.

Desktop

  • New command workspace_checkout_many (workspace::checkout_many): it calls POST /checkouts, then fetches the files of every revision now checked out through the existing fetch. The files become writable (locked_by_me), an unchanged copy only loses its read-only flag, and local changes are kept. It returns the results, the refused list, the download report and a summary (checkout_many_summary, unit-tested).
  • checkoutPartsDialog(tab) in ui/js/workspace.js builds the tree from the BOM (bom?expand=true&rule=latest) and adds state, group and lock holder from the workset. It shows checkboxes, and parts that are released, in review or held by someone else are disabled with the reason. After the check-out it shows a toast and the refused list.
  • Entry points: Check out parts… in the revision toolbar (Lock group, on assemblies or revisions with BOM lines, editors) and in the Structure tab.

Docs: CHANGELOG [Unreleased], README Features, docs/src/reference/api.md (new section and resource table), docs/src/guide/desktop.md (new section Check out parts of an assembly), desktop/README.md, docs/src/dev/threat-model.md, docs/OPEN_WORK.md (#415 ticked in the #408 line).

Out of scope (optional follow-up from the issue): Revise and check out for released parts.

Tests

tests/checkout_batch.rs:

  • mixed batch: one free part, one already mine, one locked by someone else, one released, one in review; a duplicate (by code and by id); checks the database state and the audit rows (changed revisions only, and a re-run audits nothing)
  • permissions: a viewer gets 403, and an editor of another group gets forbidden for that part while their own part goes through
  • bad requests: an entry without a code, more than 500 entries, an empty list
  • a hidden revision (restricted group), by code and by id, gives the same answer as a missing one, without the name, holder or resolved id
  • concurrent overlapping batches (tokio::join!): each revision has one winner, the other side reports it locked with the winner's name, and there is one audit record per revision

Unit tests: checkouts::tests::checkout_summaries (server) and workspace::tests::checkout_many_summaries (desktop).

Not compiled or run locally. There are no builds on this machine (the user's rule). Only cargo fmt --all ran, in the root and in desktop/. node --check was not available, so the JS was only reviewed by hand. CI verifies the build, clippy and tests.

Checklist

  • This is my own work (or my AI agent's, written from its own
    knowledge), or openly licensed material under a compatible licence
    that is credited. It contains no code decompiled, disassembled or
    rewritten from proprietary software
    and no leaked code
    (CONTRIBUTING.md).
  • Reading a file format: not applicable (no format work).
  • The documentation is updated in this pull request (CHANGELOG.md,
    README.md, docs/src/**, docs/OPEN_WORK.md where it applies).
  • cargo fmt --all --check, cargo clippy --all-targets -- -D warnings
    and cargo test pass locally, or CI runs them. (fmt ran; clippy and tests are left to CI)

🤖 Generated with Claude Code

fork and others added 2 commits November 22, 2026 19:37
Server: POST /api/v1/checkouts (services::checkouts::checkout_many) checks
out a list of revisions (by id, or item and code) in one transaction with a
result per revision: the ones that can be taken are checked out, the rest
are reported with a reason (not_found, released, in_review, locked,
forbidden). Rows are locked in one statement ordered by id, so overlapping
batches cannot deadlock and every revision has one winner; hidden
revisions answer like missing ones; one revision.checkout audit record per
changed revision. Tests in tests/checkout_batch.rs.

Desktop: "Check out parts..." on an assembly (revision toolbar and
Structure tab) shows the structure as a tree with check boxes, state and
lock holder, checks out the ticked parts with workspace_checkout_many,
makes their files writable and lists what was refused.

Docs: CHANGELOG, README, api.md, desktop guide, desktop/README.md,
threat model, OPEN_WORK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Server: checkout_many resolves every entry under the visibility guard
(by code and by id) before deduplicating and locking, so a hidden revision
is deduplicated by what was sent and never locked - exactly like a missing
one; the result count and row locks no longer tell them apart.

Desktop: an unreadable answer of POST /checkouts is an error instead of
"nothing was checked out"; Check out parts... greys out parts of groups
the user is not a member of (and everything for viewers).

Docs: threat model row no longer cites the read_permissions sweep (its
probe body does not reach POST /checkouts) and states the echo of the
caller's own identifiers; api.md not_found row; desktop guide reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Sebagrei
Sebagrei marked this pull request as ready for review November 22, 2026 20:50
…several-parts

# Conflicts:
#	CHANGELOG.md
#	docs/OPEN_WORK.md
#	docs/src/dev/threat-model.md
#	docs/src/reference/api.md
@Sebagrei
Sebagrei merged commit bece43d into main Nov 22, 2026
8 checks passed
@Sebagrei
Sebagrei deleted the feature/415-checkout-several-parts branch November 22, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UX B1: Check out several parts of an assembly at once (edit in assembly context)

1 participant