Skip to content

Plugin panels: typed editable table tier (S07, api v29) - #3576

Merged
HakanSeven12 merged 3 commits into
HakanSeven12:mainfrom
schoeller:scene-ui-atomic-s07-typed-tables
Nov 24, 2026
Merged

HakanSeven12 merged 3 commits into
HakanSeven12:mainfrom
schoeller:scene-ui-atomic-s07-typed-tables

Conversation

@schoeller

Copy link
Copy Markdown
Contributor

Staged train (this PR is stage 7)

Stages 1–6 are merged (scenes #3460, patches #3510, events #3530, widget tier #3540, buttons #3545). The remaining delta — this PR is the last content stage:

Stage Delta
7 — typed editable tables (this PR) this PR
8 — MCP parity (agent reads/actions) schoeller 4deecd147...3adbc6462 — opens as its own PR when this one merges

Problem and minimal scope

Stage 7 of the atomic panel-surface train (#3460 scenes, #3510 patches, #3530 events, #3540 widget tier, and the button stage stacked before this): typed tables. A plugin that needs a grid today has to fake it out of widget rows (no types, no editing) or repaint scenes (no editing at all). This stage adds a native, EDITABLE table tier: typed scalar cells (Text/Number/Bool), stable row/column keys, atomic cell/row patches (SetCell single-cell proof / InsertRow positioned page batches / RemoveRow), a 3-tier host lifecycle, and a host-local editing session — drafts live in the host UI until a typed commit, then the plugin (still the data authority) canonicalizes by pushing its own table patch. No shared-table reference machinery and no non-scalar presentation cells (explicit non-goals).

Public API / wire changes and current API-major basis

Based on upstream main at the train merge (v29 throughout). No new API major — the tier appends to v29's tails:

  • tables.rs (new, ungated): typed CellValue (Text/Number/Bool), stable row/column keys, atomic TablePatch (SetCell/InsertRow/RemoveRow) with budgets and validation (4 model tests incl. the single-cell-update proof).
  • scene.rs: PanelSurface::Tables(TableSurface) appended as tier tag 2 (after Scene = 0, Widgets = 1).
  • ipc/protocol.rs: PluginRequest::PanelSurfaceTablePatch { panel_id, patch } — request variant 66 (after the widget page 65); PluginResponse::PanelTablePublished = 53 and PanelTablePatchResult = 54 (after the widget tier's 51/52). Appends only.
  • HostApi pair: panel_table_publish / panel_table_publish_for_plugin (+ the patch path), tier-typed TableReject/TableRejectCode (From for the shared codes).
  • scene.rs SurfaceEvent append: CellEdited { row, column, value } — rides the EXISTING tag-16 PanelSurfaceEvent envelope (no new notification tags).

Semantics (editing is host-local until typed commit)

  • The native renderer (ui/window/plugin_tables.rs) draws an editable grid; each cell edit creates a host-local DRAFT keyed (row, col) — the stored table is untouched until commit.
  • The typed-commit rule: an edit takes the EXISTING cell's type; a failed parse keeps the draft (the user sees and fixes their input — nothing silently reverts). On commit: SurfaceEvent::CellEdited to the OWNING plugin (best-effort, sequence-identified, tag 16); the plugin canonicalizes by pushing its own PanelSurfaceTablePatch, which the store applies atomically (all-or-nothing, revision-checked) exactly like scene patches.
  • Dock precedence extends to table > widget > scene > legacy tree.
  • Web: desktop-gated delivery with the paired-stub no-op (no plugin host on web; no surface can exist there).

Legacy compatibility

All wire changes are appends (tier 2, request 66, responses 53/54, one SurfaceEvent variant inside tag 16); scenes, widgets, patches, drag, and buttons are untouched; panels without table surfaces render exactly as before; pre-29 peers never see the variants (unknown-tag passthrough). The store's remove/retain_owners lifecycle now covers all three tiers symmetrically.

Verification (exact commands, exit 0, at head 4deecd147, rebased on upstream 3e738a244)

  • cargo test -p ocs_plugin_api --all-features → 223 passed, 0 failed, 1 ignored (S06's 219 + 4 table-model tests).
  • cargo test --lib -p OpenCADStudio -- panel_events panel_surfaces plugin_scene panel_widgets plugin_tables → 25 passed, 0 failed; renderer subset -- plugin_tables → 3 passed, 0 failed (draft shadowing, typed commit, failed-parse survival).
  • cargo check --lib -p OpenCADStudio → clean.
  • cargo check --locked -p OpenCADStudio -p ocs_web_worker --target wasm32-unknown-unknown → clean.
  • Scoped rustfmt --check on the two owned files (tables.rs, plugin_tables.rs) → 0 diffs.
    (Exact recorded artifacts at push time.)

Live-test evidence

Not run — honestly. The model/store/renderer/editing-session paths are proven by the unit suites above; a live plugin receiving CellEdited and canonicalizing with a real patch awaits the Windows host mirror (pending note unchanged across the train).

Upstream-baseline failures (not regressions)

Unchanged from #3540: windows D3D12/windows-rs trait errors (inherited, documented with clean-checkout evidence on #3460/#3530); fmt/clippy informational jobs fail on pristine main. This PR adds zero new diagnostics.

…ll/row patches (S07 part 1, api v29)

Stage 7 begins: TYPED TABLES with stable row keys, typed scalar cells,
and atomic cell/row patches. Same ownership split as the scene/widget
tiers; the wire carries only this serializable vocabulary (ungated
module beside scene/widget so the pure store stays wasm-clean).

- CellValue: Text (bounded) / Number (finite-enforced) / Bool — typed
  scalar cells initially; non-scalar presentation types wait for a
  concrete example (finding-scope exclusion).
- TableSurface: ordered stable-key columns (cell positions are DERIVED
  from column order, never stored per cell), rows keyed by stable id,
  display order. Finding F4: SetCell updates ONE cell without touching
  the rest; InsertRow batches are the visible-range paging primitive
  (a page = a positioned row batch); RemoveRow by stable key.
- TablePatch: revision-checked, atomic (clone-stage-validate-swap),
  MAX_TABLE_OPS/MAX_TABLE_ROWS budgets, arity and finiteness enforced,
  whole-table re-validation on success.
- 4 tests: the single-cell-update proof (one cell, one revision bump,
  nothing else moves), atomic no-partial-mutation on a failing
  multi-op patch, positioned page batches, stale-base/arity/finiteness
  refusals.

Verification: cargo test -p ocs_plugin_api --all-features 223 passed /
0 failed / 1 ignored (219 + 4 table tests). Deliberately absent (S07
part 2+): the PanelSurface::Tables wire tail, table page/patch request
flows, the host-side store + native editable renderer, and the editing
session (host-local) wiring.
…07 part 2, api v29)

The table tier crosses the wire: a plugin publishes a typed table
surface beside (not instead of) its scene/widget surfaces, and updates
it with bounded atomic cell/row patches - the single-cell-edit and
paging primitives.

- PanelSurface::Tables(TableSurface) - the append-only envelope grows
  its third kind (tag 2, pinned next to Scene=0/Widgets=1).
- PluginRequest::PanelSurfaceTablePatch { panel_id, patch } (variant
  66, after page 65) + PanelTablePublished (response 53) +
  PanelTablePatchResult (response 54): the table tier's independent
  revision space, type-safely carried by the tier's own TableReject
  (finding F1).
- HostApi: panel_table_publish / panel_surface_table_patch (+ _for_plugin)
  with the transport-era Unattached defaults; server dispatch matches
  the surface kind; client methods mirror the tier split.
- Host store: a table map beside scenes/widgets with publish_table /
  patch_table / ownership-checked table reads; remove/retain_owners
  clear all THREE tiers (the lifecycle lesson, applied proactively).
  Host session: resolve_surface_panel reused behind the two new
  overrides.

Verification: cargo test -p ocs_plugin_api --all-features 223 passed /
0 failed / 1 ignored; cargo check --lib -p OpenCADStudio clean; wasm32
check green for OpenCADStudio + ocs_web_worker (recorded). Pre-existing
upstream baseline failures (windows D3D12; fmt/clippy informational
jobs) inherited and untouched. Part 3 (next): the native table renderer
with the host-local editing session and CellEdited event wiring.
…ssion (S07 part 3, api v29)

Completes the table tier end to end: a published table surface RENDERS
as a native editable grid, and its editing session is HOST-LOCAL
transient state — the plugin stays the data authority.

- ui/window/plugin_tables.rs: TableUiState (draft cell texts keyed by
  (row, column), host-local selection) and table_view: a scrollable
  native grid - header row + one text-input editor per cell bound to
  the draft (or the stored cell when no draft). Edits are keystroke
  Messages (host-local drafts only); submission runs the TYPED-COMMIT
  RULE - the edited value takes the existing cell's type (Number/Bool
  parse, Text free); a failed parse keeps the user's draft and commits
  nothing.
- A successful commit notifies SurfaceEvent::CellEdited (sequence-
  identified, owner-targeted, best-effort - the S04 delivery law) via
  the desktop-gated dispatch path; the plugin remains the data
  authority and canonicalizes by pushing its own table patch through
  the normal wire path (the store's revision rules apply - the host
  never mutates plugin data directly).
- dock seam precedence: table view -> widget view -> scene canvas ->
  exact legacy tree. Web runtime: editing drafts work host-locally but
  delivery dies at the dispatch no-op (no plugin host on web).

Verification: cargo test -p ocs_plugin_api --all-features 223 passed /
0 failed / 1 ignored; cargo test --lib -p OpenCADStudio -- panel_tables
green (draft shadowing, typed commit, failed-parse draft survival);
host lib clean; wasm32 check green for OpenCADStudio + ocs_web_worker
(recorded). Pre-existing upstream baseline failures (windows D3D12;
fmt/clippy informational jobs) inherited and untouched.
@HakanSeven12
HakanSeven12 merged commit 6e7385c into HakanSeven12:main Nov 24, 2026
8 checks passed
HakanSeven12 added a commit that referenced this pull request Nov 24, 2026
… VISIBILITYSTATES docs name no other product

Follow-up to #3573, #3576.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants