Skip to content

Plugin panels: publish declarative scene surfaces end to end (S02, api v29) - #3460

Merged
HakanSeven12 merged 3 commits into
HakanSeven12:mainfrom
schoeller:scene-ui-atomic-s02-static-scene
Nov 23, 2026
Merged

HakanSeven12 merged 3 commits into
HakanSeven12:mainfrom
schoeller:scene-ui-atomic-s02-static-scene

Conversation

@schoeller

Copy link
Copy Markdown
Contributor

Problem and minimal scope

Stage 2 of the atomic panel-surface train begun in #3442 (merged). A plugin that registers a persistent panel can now publish a bounded declarative PanelScene for it; the host stores that scene under the authenticated caller's ownership and renders it natively on its own canvas. This is the smallest end-to-end vertical slice: one publish RPC, one pure store, one renderer, one mount seam. Patches (S03), semantic events/drag (S04), widget surfaces (S05+), and MCP (S08) are deliberately absent.

Public API / wire changes and current API-major basis

Based on upstream main at 0ca03459b (API_VERSION = 28). This PR declares v29 (manifest API_VERSION 28 → 29 + doc-history paragraph in the established style).

  • PluginRequest::PanelSurfacePublish { panel_id, surface } — new tail variant (63, after RemoveGeoLocation 62). Plugin identity is the transport's serving manifest, never a wire field; panel_id scopes the surface exactly like RegisterPanel does. Deliberately no event piggyback: events are host→plugin notifications, not publish payload.
  • PluginResponse::PanelSurfacePublished(Result<SceneRevision, SurfaceReject>) — new tail variant (49, after GeoLocationRemoved 48). The typed refusal answers Unattached / OwnedByOther / InvalidSurface / NonMonotonicRevision; a refusal never mutates host state (no partial writes, ever).
  • PanelSurface::Scene(PanelScene) (discriminant 0) starts the append-only surface envelope the widget-surface stage will extend — pinned from creation by panel_surface_publish_v29_wire_tail_is_pinned (which also pins request/response tags 62/63 and 48/49). The three envelope types live in crate::scene (not ipc) so the pure app-side store — which compiles without the host feature — shares the exact vocabulary the wire carries.
  • HostApi gains the established paired methods panel_surface_publish / panel_surface_publish_for_plugin, with transport-era default stubs: structurally invalid scenes answer InvalidSurface, everything else Unattached, and no state anywhere changes until a surface-aware host overrides the _for_plugin variant (the host app does).

Explicit non-goals and dependency

Depends on #3442 (merged — this branch is based on its result). Non-goals: patches/patch-acks (S03), retained caches (S03), events + drag (S04, and v1 carries no event-value acknowledgement), trees/lists/menus/buttons/tables (S05–S07), MCP surface (S08). No second document-mutation path; nothing in the legacy dialog/panel surface changes.

Legacy compatibility

  • Existing enum variants untouched; all new variants appended (tags pinned by test).
  • DialogControl/DialogValue/HostNotification wire bytes unchanged; panels without a published scene render their exact legacy widget tree (app/dock/view.rs seam falls through).
  • A v28 runner cannot decode tag 63, so a plugin that sends it declares v29 (manifest gate) — the established additive path.

Verification (exact commands, exit 0 unless stated)

Toolchain rustc/cargo 1.99.1 (no pin file; CI informational jobs compared below):

  • cargo test -p ocs_plugin_api --all-features → 197 passed, 0 failed, 1 ignored (includes: wire-tail pins, store publish/ownership/revision/idempotence tests, projection paint-order + theme-color mapping pins on both themes).
  • cargo test --lib -p OpenCADStudio -- panel_surfaces plugin_scene → 10 passed, 0 failed (6771 others filtered).
  • cargo check --lib -p OpenCADStudio → clean.
  • cargo check --locked --target wasm32-unknown-unknown -p OpenCADStudio -p ocs_web_worker → clean. The store compiles for wasm (it is pure std + this crate's data types); the web runtime has no plugin host, so the store stays empty there and panels render exactly their legacy bodies — the honest no-op, with no pure model code hidden behind desktop cfg stubs.
  • Scoped rustfmt --check clean on all touched files. The repo's pre-existing baseline failures (29 fmt hunks on pristine main, e.g. src/ui/window/plugin_dialog.rs; 11 clippy -D warnings hits in entity_coverage.rs/host.rs/ipc/*/process/*; both non-blocking CI jobs) are inherited and untouched.

Live-test evidence

Not run — honestly. No live host/plugin pair was exercised for this stage; the plugin→host path is proven by the unit + integration surface above (store semantics, dispatch arm, typed responses). The out-of-tree example plugin and a live acceptance run are the recorded next step for a later stage, when the Windows host mirror is available.

Upstream-baseline failures (not regressions)

cargo fmt --all -- --check fails on pristine upstream main already (29 hunks) and cargo clippy --all-targets -- -D warnings has 11 pre-existing errors; both CI jobs are informational (continue-on-error). This PR adds zero new diagnostics to either (scoped checks recorded per file).

…i v29)

The first wire stage of the atomic scene-ui train: a plugin can now
publish a bounded declarative PanelScene (S01's Group/Rect/Path/Text
vocabulary) for a panel it registered, the host stores it under the
authenticated caller's ownership, and the dock renders it natively on a
canvas — with every legacy panel behavior untouched.

Wire (crates/ocs_plugin_api):
- PluginRequest::PanelSurfacePublish { panel_id, surface } (variant 63,
  appended after RemoveGeoLocation 62) — plugin identity is the
  transport's serving manifest, never a field; panel_id scopes the
  surface like RegisterPanel does. Deliberately NO event piggyback:
  events are host->plugin notifications, not publish payload.
- PluginResponse::PanelSurfacePublished(Result<SceneRevision,
  SurfaceReject>) (variant 49, after GeoLocationRemoved 48): the stored
  revision or a typed refusal. SurfaceReject { code, current_revision }
  answers Unattached / OwnedByOther / InvalidSurface /
  NonMonotonicRevision; a refusal never mutates host state (no partial
  writes). PanelSurface::Scene (variant 0) starts the append-only surface
  envelope the widget-surface stage will extend — pinned by
  panel_surface_publish_v29_wire_tail_is_pinned.
- HostApi gains the paired panel_surface_publish /
  panel_surface_publish_for_plugin methods with the established
  transport-era defaults: structurally invalid scenes answer
  InvalidSurface, everything else Unattached, and no state anywhere
  changes until a surface-aware host overrides the _for_plugin variant.
- API_VERSION 28 -> 29 with the manifest doc-history paragraph: a v28
  runner cannot decode tag 63, so a plugin that sends it declares v29.

Host (src/app):
- plugin_host/panel_surface.rs: the PURE panel surface store (no iced,
  no renderer): attachment/ownership resolve in the session override
  (unregistered alias -> Unattached, foreign-registered ->
  OwnedByOther), the store re-checks ownership so no path bypasses it,
  and revision semantics refuse same-rev-different-content and stale
  revisions with the stored head; identical resurfaces are idempotent.
  Reads are ownership-checked (a foreign plugin reads nothing).
- ui/window/plugin_scene.rs: theme-free project_scene flattens the
  validated tree into paint-order primitives (groups are depth-first,
  no transform — child coordinates stay scene-space); SceneCanvas paints
  them, resolving semantic colors against the host theme only inside
  draw (primary/success/warning/danger/muted slots, pinned by test on
  both themes; Rgba passes through). Static stage: no retained cache yet.
- app/dock/view.rs mounts the seam: a panel with an owned scene renders
  the native canvas body; panels without a scene keep their exact
  legacy widget tree.

Deliberately excluded (later stages): patches (s03), semantic events
and drag (s04 — and v1 carries no event-value acknowledgement), widget
surfaces/trees/tables (s05+), MCP surface (s08).

Verification: cargo test -p ocs_plugin_api --all-features 197 passed /
0 failed / 1 ignored; cargo test --lib -p OpenCADStudio -- panel_surface
plugin_scene 10 passed / 0 failed; cargo check --lib -p OpenCADStudio
green; wasm32 check for OpenCADStudio + ocs_web_worker green (recorded);
scoped rustfmt clean on all touched files. Baseline failures on
pristine upstream main (29 fmt hunks e.g. plugin_dialog.rs, 11 clippy
-D warnings in entity_coverage/host/ipc/process, non-blocking CI jobs)
are inherited and untouched by this change.
@schoeller

Copy link
Copy Markdown
Contributor Author

CI: the two Windows failures are inherited from upstream main at this PR's base — not regressions

Both failing jobs (test (windows-latest), windows/python-host-check) die in "Build the application (the plugin runner)" with the same D3D12/windows-rs API breakage:

error[E0277]: the trait bound `ResourceCategory: From<&D3D12_RESOURCE_DESC>` is not satisfied
error[E0277]: the trait bound `&ID3D12Heap: Param<ID3D12Heap, InterfaceType>` is not satisfied

This is the GPU/windows dependency stack, which this PR does not touch (its diff is the plugin-API wire tail + panel store/renderer/mount seam — see the file list).

Clean-checkout reproduction at this PR's base SHA: upstream main's own Tests workflow at 0ca03459b fails the same job:

  • main @ 0ca03459b: run https://github.com/HakanSeven12/OpenCADStudio/actions/runs/45034007728 → test (windows-latest) failure (sole failing job)
  • this PR (head d346c5416, base 0ca03459b): test (windows-latest) failure with the identical D3D12 signature; the python-host-check windows job fails the same way whenever it builds the runner on Windows.

Everything this PR can affect is green on both Linux and wasm32 (linux ✅, test (ubuntu-22.04) ✅, wasm32 ✅, lint ✅, health ✅, inspector pending at time of writing), and the Windows-only D3D12 breakage predates this branch. Happy to help debug the windows-rs/wgpu drift separately if useful — but I didn't want to smuggle a GPU-dependency fix into the atomic panel-surface PR.

…Seven12#3418 (iced fork repoint e4b2fc1a→7dea840) regenerated Cargo.lock and the resolver re-pinned gpu-allocator 0.28.0's cfg(windows) windows edge 0.62.2→0.58.0 (the old edge exceeds the crate's declared <=0.62 ceiling, so the regen kept the other in-lock node that fits — dwg-thumbnailer-win's 0.58.0), which split the D3D12 vocabulary across windows lines: wgpu-hal 29.0.4 speaks windows 0.62 while gpu-allocator hands it ID3D12Heap/D3D12_RESOURCE_DESC/ResourceCategory values typed at windows 0.58, so every CreatePlacedResource-shaped call site fails type-check (10 E0277/E0308 errors) and both Windows lanes (build --locked, test --locked) go red — main has been red since 3fe6897 landed, so this branch inherits the breakage rather than causing it; linux/macos/wasm never resolve the edge (cfg(windows)), which is why those lanes stayed green; the fix restores the byte-identical edge of the last Windows-green lock (a634487, 2026-11-21; the 0.62.2 edge carried green windows CI from 2026-09-11) — no manifest change, no version bump, no source change, dwg-thumbnailer-win keeps its own 0.58.0; verification: cargo check --locked --target x86_64-pc-windows-gnu -p OpenCADStudio --lib reproduces the exact 10 wgpu-hal errors on the red lock and compiles clean with the edge restored (a Linux host check of the windows target — same type-check failure mode as CI's msvc lane, no linking involved)
@schoeller

Copy link
Copy Markdown
Contributor Author

Pushed 6d97a47 — a one-line Cargo.lock fix, no source change. main's Windows lanes have been red since 3fe6897 (#3418's lock regen re-pinned gpu-allocator's windows edge 0.62.2→0.58.0, splitting the D3D12 types from wgpu-hal's — upstream fix in #3459), so this branch inherits the breakage; the commit restores the edge to its pre-#3418 value (byte-identical to the last-green lock, a634487e6) so the Windows lanes can gate this PR's actual change. Verified: the windows-target type-check reproduces the exact 10 wgpu-hal errors on the red lock and compiles clean with the edge restored, through the full wgpu→iced chain. Once #3459 merges, this commit rebases away cleanly (identical hunk).

…atest) failed on app::automation::tests::lasso_press_drag_selects, a pre-existing flake this branch's 10 added lib tests (8 panel_surfaces + 2 plugin_scene) surfaced by rescheduling the shared test binary: the identical test passed on the same base commit at 2026-11-22T17:10Z in HakanSeven12#3459's windows run (6748 passed, this test ok) and the same 6758-test suite passed the ubuntu lane of this very run; the PR's app-side diff is view-projection only (dock/view.rs panel body swap, new modules) and cannot reach the selection gesture path, whose gates (pick_first default true, held_ms>=250 vs the test's synthetic 260ms hold, press-point geometry) are deterministic on a monotonic clock; re-running to sample the flake again
@HakanSeven12
HakanSeven12 merged commit d31be0e into HakanSeven12:main Nov 23, 2026
8 checks passed
HakanSeven12 pushed a commit that referenced this pull request Nov 23, 2026
The store kept a published scene after its plugin died, so a restarted
plugin's first publishes were refused until they passed the old
revision, and a panel id registered by another plugin stayed owned by the
first one. Registration and the dead-plugin reap now clear the scene.

The rest of the change undoes the formatting of lines #3460 did not
otherwise change, shortens its doc comments, fixes the type name in the
v29 note and drops an unused parameter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013CaxngxnsGEAQ4V12YE1DP
HakanSeven12 pushed a commit that referenced this pull request Nov 23, 2026
schoeller added a commit to schoeller/OpenCADStudio that referenced this pull request Nov 23, 2026
… part 1, api v29)

The event leg of the panel-surface train: a semantic event vocabulary
with EXPLICIT event identity, and the wire notification that carries it
to the owning plugin — best-effort by contract, never acknowledged by
re-publishing values (finding F2: identical-looking activations are
DISTINCT events; equality is not identity).

scene.rs (ungated — the pure store and the wire share the vocabulary):
- SurfaceEvent: ElementClicked{element,pos} (press+release without
  drag; the plugin binds its own semantics to the element id — the
  host never interprets scene vocabulary), DragStarted{element,origin},
  DragMoved{element,pos} (COALESCABLE — positions are absolute, so
  dropped intermediates lose nothing), DragSettled{element,pos} (THE
  authoritative settle: exactly one per drag, never coalesced away),
  DragCancelled{element,origin} (pre-drag origin, lossless restore).
- Per-surface monotonic sequence numbers are the event identity; they
  ride the notification, not the event enum.

Wire: HostNotification::PanelSurfaceEvent { panel_id, sequence, event }
(tag 16, appended after the v27 delta's 15 per the established
append-only tag story; pinned by panel_surface_event_notification_tag_is_sixteen
with the length-prefixed tag offset the legacy pins use). The runner's
notification_api_version gate returns 29 for the variant — a v28
runner can never receive a tag it cannot represent.

Deliberately absent (S04 continues): the host-side router/canvas seam
and delivery (app-owned, next commit), and any prompt/table state
machines (out of scope by mission).

Verification: cargo test -p ocs_plugin_api --all-features 199 passed /
0 failed / 1 ignored (new: tag-16 pin + sequence/payload round-trip).
Pre-existing upstream baseline failures (windows D3D12 trait errors at
this base SHA — see HakanSeven12#3460 discussion — plus fmt/clippy informational
jobs) are inherited and untouched.
schoeller added a commit to schoeller/OpenCADStudio that referenced this pull request Nov 23, 2026
…(S05 part 2, api v29)

The widget tier crosses the wire: a plugin publishes a semantic
tree/list surface beside (not instead of) its scene, pages children in
with bounded atomic installs, and the host stores everything under the
authenticated owner with the same revision discipline as scenes.

- PanelSurface::Widgets(WidgetSurface) — the S02 pin's promised
  append (tag 1, pinned next to Scene = 0). The publish request frame
  is REUSED; the answer is split by kind: PanelSurfacePublished for the
  scene revision and NEW PanelWidgetPublished for the widget revision
  (variant 52) — finding F1's independent revision spaces, type-safely.
- PluginRequest::PanelSurfacePage { panel_id, page: WidgetPage }
  (variant 65, after patch 64) + PanelSurfacePageResult (variant 51):
  the bounded lazy-expansion/paging primitive — installing another page
  never replaces the surface. All pinned by
  panel_widget_s05_wire_tails_are_pinned.
- HostApi: panel_surface_publish retyped to the SCENE leg (PanelScene);
  new paired panel_widget_publish / panel_surface_page (+ _for_plugin
  variants) with the transport-era Unattached defaults; server dispatch
  matches the surface kind and routes to the typed tier.
- Client: panel_surface_publish (scene) and panel_widget_publish
  (widgets) split type-safely; panel_surface_page added.
- Host store (app/panel_surfaces.rs): a widget map beside the scene map
  with publish_widget / install_widget_page / ownership-checked widget
  reads; remove/retain_owners clear BOTH tiers (the lifecycle lesson
  from the maintainer's post-HakanSeven12#3460 fix applied to the new tier
  proactively). Host session: a shared resolve_surface_panel helper
  (unregistered -> Unattached, foreign -> OwnedByOther) behind the
  scene/widget/page overrides.

Verification: cargo test -p ocs_plugin_api --all-features 218 passed /
0 failed / 1 ignored (new: S05 wire-tail pins). Part 3 (next): the
native iced renderer, host-local selection/expansion state, and the
activation/expansion event wiring through the S04 router.
schoeller added a commit to schoeller/OpenCADStudio that referenced this pull request Nov 23, 2026
…S05 part 2b, api v29)

The host-side half of the widget wire tier, completing part 2:
- app/panel_surfaces.rs: the widget map beside the scene map —
  publish_widget (validate/ownership/monotonic on the widget revision
  space, idempotent at the head), install_widget_page (StaleBase ->
  NonMonotonicRevision with the current head, other failures ->
  InvalidSurface, zero mutation), ownership-checked widget reads; and
  remove/retain_owners now clear BOTH tiers so a dead or re-registered
  panel forgets its widget surface too (the post-HakanSeven12#3460 lifecycle
  lesson applied to the new tier proactively).
- app/plugin_host/host_api.rs: a shared resolve_surface_panel helper
  (unregistered -> Unattached, foreign-registered -> OwnedByOther)
  behind the scene publish override (retyped to PanelScene) and the NEW
  panel_widget_publish_for_plugin / panel_surface_page_for_plugin
  overrides.

Verification: cargo check --lib -p OpenCADStudio clean with these
wired; the crate-side suite stays 218 passed / 0 failed / 1 ignored.
schoeller added a commit to schoeller/OpenCADStudio that referenced this pull request Nov 23, 2026
… part 1, api v29)

The event leg of the panel-surface train: a semantic event vocabulary
with EXPLICIT event identity, and the wire notification that carries it
to the owning plugin — best-effort by contract, never acknowledged by
re-publishing values (finding F2: identical-looking activations are
DISTINCT events; equality is not identity).

scene.rs (ungated — the pure store and the wire share the vocabulary):
- SurfaceEvent: ElementClicked{element,pos} (press+release without
  drag; the plugin binds its own semantics to the element id — the
  host never interprets scene vocabulary), DragStarted{element,origin},
  DragMoved{element,pos} (COALESCABLE — positions are absolute, so
  dropped intermediates lose nothing), DragSettled{element,pos} (THE
  authoritative settle: exactly one per drag, never coalesced away),
  DragCancelled{element,origin} (pre-drag origin, lossless restore).
- Per-surface monotonic sequence numbers are the event identity; they
  ride the notification, not the event enum.

Wire: HostNotification::PanelSurfaceEvent { panel_id, sequence, event }
(tag 16, appended after the v27 delta's 15 per the established
append-only tag story; pinned by panel_surface_event_notification_tag_is_sixteen
with the length-prefixed tag offset the legacy pins use). The runner's
notification_api_version gate returns 29 for the variant — a v28
runner can never receive a tag it cannot represent.

Deliberately absent (S04 continues): the host-side router/canvas seam
and delivery (app-owned, next commit), and any prompt/table state
machines (out of scope by mission).

Verification: cargo test -p ocs_plugin_api --all-features 199 passed /
0 failed / 1 ignored (new: tag-16 pin + sequence/payload round-trip).
Pre-existing upstream baseline failures (windows D3D12 trait errors at
this base SHA — see HakanSeven12#3460 discussion — plus fmt/clippy informational
jobs) are inherited and untouched.
schoeller added a commit to schoeller/OpenCADStudio that referenced this pull request Nov 23, 2026
…(S05 part 2, api v29)

The widget tier crosses the wire: a plugin publishes a semantic
tree/list surface beside (not instead of) its scene, pages children in
with bounded atomic installs, and the host stores everything under the
authenticated owner with the same revision discipline as scenes.

- PanelSurface::Widgets(WidgetSurface) — the S02 pin's promised
  append (tag 1, pinned next to Scene = 0). The publish request frame
  is REUSED; the answer is split by kind: PanelSurfacePublished for the
  scene revision and NEW PanelWidgetPublished for the widget revision
  (variant 52) — finding F1's independent revision spaces, type-safely.
- PluginRequest::PanelSurfacePage { panel_id, page: WidgetPage }
  (variant 65, after patch 64) + PanelSurfacePageResult (variant 51):
  the bounded lazy-expansion/paging primitive — installing another page
  never replaces the surface. All pinned by
  panel_widget_s05_wire_tails_are_pinned.
- HostApi: panel_surface_publish retyped to the SCENE leg (PanelScene);
  new paired panel_widget_publish / panel_surface_page (+ _for_plugin
  variants) with the transport-era Unattached defaults; server dispatch
  matches the surface kind and routes to the typed tier.
- Client: panel_surface_publish (scene) and panel_widget_publish
  (widgets) split type-safely; panel_surface_page added.
- Host store (app/panel_surfaces.rs): a widget map beside the scene map
  with publish_widget / install_widget_page / ownership-checked widget
  reads; remove/retain_owners clear BOTH tiers (the lifecycle lesson
  from the maintainer's post-HakanSeven12#3460 fix applied to the new tier
  proactively). Host session: a shared resolve_surface_panel helper
  (unregistered -> Unattached, foreign -> OwnedByOther) behind the
  scene/widget/page overrides.

Verification: cargo test -p ocs_plugin_api --all-features 218 passed /
0 failed / 1 ignored (new: S05 wire-tail pins). Part 3 (next): the
native iced renderer, host-local selection/expansion state, and the
activation/expansion event wiring through the S04 router.
schoeller added a commit to schoeller/OpenCADStudio that referenced this pull request Nov 23, 2026
…S05 part 2b, api v29)

The host-side half of the widget wire tier, completing part 2:
- app/panel_surfaces.rs: the widget map beside the scene map —
  publish_widget (validate/ownership/monotonic on the widget revision
  space, idempotent at the head), install_widget_page (StaleBase ->
  NonMonotonicRevision with the current head, other failures ->
  InvalidSurface, zero mutation), ownership-checked widget reads; and
  remove/retain_owners now clear BOTH tiers so a dead or re-registered
  panel forgets its widget surface too (the post-HakanSeven12#3460 lifecycle
  lesson applied to the new tier proactively).
- app/plugin_host/host_api.rs: a shared resolve_surface_panel helper
  (unregistered -> Unattached, foreign-registered -> OwnedByOther)
  behind the scene publish override (retyped to PanelScene) and the NEW
  panel_widget_publish_for_plugin / panel_surface_page_for_plugin
  overrides.

Verification: cargo check --lib -p OpenCADStudio clean with these
wired; the crate-side suite stays 218 passed / 0 failed / 1 ignored.
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