merge origin/main: unify our web branch with 277 upstream commits

Conflicts resolved as unions of behavior wherever possible:

- #1350 (set_properties numeric CAS): kept our stricter
  json_values_match (guards u64>f64 precision loss); upstream's
  duplicate removed.
- #1351 (web open-from-bytes): our implementation wins (guarded
  queue, settle semantics, protocol 2) using upstream's validation
  helper so both sides' tests pass.
- #1358/#1359 (Windows printer routing/media): merged both engines —
  upstream's route planning, media tables, GDI raster path and driver
  options on top of our level-2 enumeration fallback, true-default
  resolution, quoted printto params, existence probe, and error
  descriptions.
- #1360 (plot-style leniency): decompress_ctb now carries both our
  CTBVER1/STBVER1 container tags and structured flag, and upstream's
  lenient reader with Windows-1252 handling.
- 3D snapping precedence: upstream's F4 3D osnap system takes
  precedence over our #1030 solid edge wires when the mesh cache has
  geometry edges; our wires remain the fallback for triangle-only
  caches and mesh entities (both test suites pass).
- Fixed upstream-side bugs surfaced by the merge: parametric arc
  grips impl/test contradiction, psetupin test path separators, and
  our pdf_raster regression where the new dpi argument was threaded
  but ignored (GDI 300-DPI would have cached at 150).
- ocs_save repinned to the upstream acadrust rev; docs/command-
  reference.md regenerated (the staleness test caught it).
This commit is contained in:
Afonsop committed 2026-09-21 13:33:39 +01:00
commit 55e3a6a9e2
323 files changed
+82297 -4351

No files matched your search

+26 -1
View File
@@ -17,6 +17,10 @@ The server provides four tools:
- `ocs_execute` performs one operation, an atomic record update, or a sequential batch against the real editor.
- `ocs_capture` returns a bounded PNG of the drawing viewport or complete window.
Native builds also accept a second, headless entry point (`OpenCADStudio --serve`, one
JSON request per line) for scripts and CI; the two native channels, their startup dialogs
and their limits are described in [native.md](native.md).
The normal flow is to call `ocs_sessions`, pass its returned `session_id` as `ocs_session_id` to the other tools, read the chosen session with `ocs_read`, then pass the returned document state into `ocs_execute`. For example, an undo request has this shape:
```json
@@ -138,7 +142,27 @@ Execute responses use `response_detail: "compact"` by default and return only th
For unfamiliar or conditional commands, use `start`, then inspect `state.command` in every response. Its `accepts` array gives the valid MCP input kinds, `options` gives the current tokens, and `input_example` gives the next request shape. Add the current state fields and a new `request_id` to each step.
Every `ocs_execute` request requires a caller-generated `request_id`. Reuse that ID only to retry the identical request after a timeout, together with the same session ID, document ID, expected revision, and selection. Commands report `waiting_input` while more input is required and asynchronous work remains `running` until its real callback finishes. Geometry stays in OpenCADStudio and its geometry kernel.
Every `ocs_execute` request requires a caller-generated `request_id`. Reuse that ID only to retry the identical request after a timeout, together with the same session ID, document ID, expected revision, and selection. Commands report `waiting_input` while more input is required and asynchronous work remains `running` until its real callback finishes.
A `run` reply also carries two fields that describe what happened to the line:
* `blocked_by` — `null` when the command finished, otherwise what *this line*
left open and waiting: `"command"` (an interactive command), `"text_editor"`
(the in-place editor opened by the `TEXT` content step), `"mtext_editor"`, or
`"modal:<Kind>"` for a dialog. A surface that was already open when the line
started (an earlier line's editor, another tab, a startup dialog) is not
attributed to this line, so a caller polling for `completed` is never stuck
waiting on someone else's editor. `blocked_by` is set whenever `status` is
`waiting_input`.
* `unconsumed` — the tokens of the line that no prompt ever asked for, in order.
A fully consumed line reports `[]`; `CIRCLE 0,0 5 9` reports `["9"]` because
the radius step ends the command. Over-typed input is reported instead of
being dropped on the floor.
When a line ends at the `TEXT` content step (`TEXT 0,0 5 0 hello`) the text is
typed into the in-place editor and committed, so the line behaves exactly as the
same input typed into the GUI command line would: one `Text` entity, nothing
unconsumed, and the command closed rather than left armed for a second line. Geometry stays in OpenCADStudio and its geometry kernel.
`ocs_capture` defaults to the drawing viewport and a longest edge of 1600 pixels. Set `scope` to `window` for the full interface or change `max_dimension` between 256 and 4096.
@@ -198,3 +222,4 @@ The operation stays pending until the open settles; if another open holds the sl
### Startup prompts during automation
The first control request of a session marks it automated: a donation prompt that has not been shown yet is dropped, and no new one is queued while control stays enabled. A prompt already on screen is left for its reader — close it with `{"op":"action","name":"close_modal"}`. A web host that intends to automate from the first page load can set `localStorage["opencadstudio.automation"] = "1"` before loading the app so the prompt never appears (the same pre-load mechanism the settings use).
The web build is driven through two JavaScript functions instead of a process; the protocol details are summarised above and in [web.md](web.md).