Skip to content

Plugin panels: semantic surface events with explicit identity + owner-targeted delivery (S04, api v29) - #3530

Merged
HakanSeven12 merged 3 commits into
HakanSeven12:mainfrom
schoeller:scene-ui-atomic-s04-events-drag
Nov 23, 2026
Merged

HakanSeven12 merged 3 commits into
HakanSeven12:mainfrom
schoeller:scene-ui-atomic-s04-events-drag

Conversation

@schoeller

Copy link
Copy Markdown
Contributor

Problem and minimal scope

Stage 4 of the atomic panel-surface train (#3460 scene publish, #3510 patches — both merged): the event leg. A panel surface's canvas now translates raw pointer input into best-effort semantic events, routes them through a pure host-owned state machine, and delivers them to the OWNING plugin only. Finding F2's contract exactly: events are never acknowledged by re-publishing values, identical-looking activations are DISTINCT events (per-surface monotonic sequences are the explicit identity), drag moves are COALESCED (absolute positions — dropped intermediates lose nothing), and DragSettled/DragCancelled are authoritative and never dropped. Host-local drag preview: paint-time only, the stored scene and the plugin's data are untouched until the plugin settles with its own patch.

Public API / wire changes and current API-major basis

Based on upstream main at 0f00b8c2c (v29, declared by #3460; patches by #3510). No new API major — this stage rides v29's notification tail:

  • scene.rs (ungated): SurfaceEvent — ElementClicked{element,pos}, DragStarted{element,origin}, DragMoved{element,pos}, DragSettled{element,pos}, DragCancelled{element,origin} (append-only enum).
  • HostNotification::PanelSurfaceEvent { panel_id, sequence, event } — notification tag 16 (appended after the v27 delta's 15 per the established append-only tag story; pinned). The manual serde arms follow the file's exact per-variant framing.
  • runner.rs notification_api_version gate: the variant maps to 29 — a v28 runner can never receive a tag it cannot represent.
  • HostApi/session: no new request paths; the event tier is notifications only (finding F2: no event-value acks, no AckBatch, no retry policy — none has a consumer).

Explicit non-goals and dependency

Depends on #3460 + #3510 (both merged — rebased onto their result). Non-goals: prompt/table state machines, any per-event acknowledgement or realignment, widget-surface events beyond the shared vocabulary (S05 uses NodeActivated-style appends if needed), text-selection or keyboard routing.

Semantics (the pure router, app/panel_events.rs — unit-tested, no renderer/wire coupling)

  • Click contract: press begins a POTENTIAL drag (no event yet); the first move emits DragStarted (pre-drag origin) + a coalesced DragMoved; release after moves emits exactly one DragSettled; release without moves emits ElementClicked.
  • Cancellation restores the pre-drag origin losslessly; a cancelled potential drag emits nothing and burns no sequence numbers.
  • One pointer, one law: a new press settles (or silently drops) the in-flight drag first — what the preview showed is what settles.
  • Delivery: v4_support::publish_surface_event_to_plugin — owner-targeted (grip_endpoint, no fan-out; panel surfaces are plugin-owned), best-effort (a dead owner's event drops silently, the same law as every v4 notification).
  • Canvas seam: SceneCanvas::update hit-tests the retained prims (each prim carries its element's StableId) and publishes pointer messages; scene space equals canvas-local space (S01 no-transform invariant). Desktop-only delivery — the web runtime has no plugin host and its routed events die at the dispatch arm (paired-stub convention; no surface can exist on web).

Legacy compatibility

Existing notification tags untouched (16 appended); HostNotification::Unknown passthrough and pre-29 plugin streams unchanged; panels without scenes render their exact legacy trees; the canvas seam is inert without a published surface. A v28 runner cannot decode tag 16 (gate).

Verification (exact commands, exit 0)

  • cargo test -p ocs_plugin_api --all-features → 209 passed, 0 failed, 1 ignored (includes: tag-16 pin with the length-prefixed offset the legacy pins use, sequence/payload round-trip, gate mapping).
  • cargo test --lib -p OpenCADStudio -- panel_events panel_surfaces plugin_scene → 22 passed, 0 failed (router: click identity, drag start/coalesce/settle-once, lossless cancel restore, cancelled-potential silence, cross-panel press settle, per-surface monotonic sequences; store + renderer regression suites).
  • cargo check --lib -p OpenCADStudio → clean; cargo check --locked --target wasm32-unknown-unknown -p OpenCADStudio -p ocs_web_worker → clean (the router is pure std; delivery is desktop-gated with the paired-stub no-op on web).
  • Scoped rustfmt --check clean on touched files. Pre-existing upstream baseline failures (windows D3D12 trait errors at this era — see the Plugin panels: publish declarative scene surfaces end to end (S02, api v29) #3460 discussion; fmt/clippy informational jobs) inherited and untouched.

Live-test evidence

Not run — honestly. The router/canvas/delivery paths are proven by the unit suites above; a live plugin sending real clicks awaits the Windows host mirror (recorded as pending in the train ledger, same note as #3460/#3510).

Upstream-baseline failures (not regressions)

cargo fmt --all -- --check and cargo clippy --all-targets -- -D warnings fail on pristine upstream main already (29 fmt hunks; 11 clippy errors in entity_coverage.rs/host.rs/ipc/*/process/*; both non-blocking jobs). This PR adds zero new diagnostics (scoped per-file checks recorded).

… 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.
…am (S04 part 2, api v29)

The host-owned input half of the event stage, as pure testable logic:
- app/panel_events.rs (no renderer, no wire, wasm-clean):
  PanelEventRouter turns pointer transitions into ordered
  best-effort notifications. Click contract: press begins a POTENTIAL
  drag (no event yet); the first move emits DragStarted (pre-drag
  origin) plus a coalesced DragMoved; further moves COALESCE (absolute
  positions — dropped intermediates lose nothing); release after moves
  emits exactly one DragSettled; release without moves emits
  ElementClicked. Cancellation restores the pre-drag origin
  losslessly; a cancelled potential drag emits nothing and burns no
  sequence numbers. One pointer, one law: a new press settles (or
  silently drops) the in-flight drag first — at most one settle per
  drag, what the preview showed is what settles. Per-surface monotonic
  sequences are the explicit event identity: identical-looking clicks
  carry distinct sequences (F2).
- v4_support.rs: publish_surface_event_to_plugin — owner-targeted
  delivery of HostNotification::PanelSurfaceEvent (grip_endpoint +
  best-effort notify, the same guarded path and dead-owner law as
  every v4 notification). Panel surfaces are plugin-owned: no fan-out.

Verification: cargo test --lib -p OpenCADStudio -- panel_events
6 passed / 0 failed (click identity, drag start/coalesce/settle,
lossless cancel restore, cancelled-potential silence, cross-panel
press settle); cargo test -p ocs_plugin_api --all-features 199 passed /
0 failed / 1 ignored.

Part 3 (next): the canvas pointer seam (hit-test against cached prims,
Program::update pushing the pointer Message), the dispatch arm routing
through PanelEventRouter to publish_surface_event_to_plugin, and the
host-local drag preview in the canvas paint.
…iew (S04 part 3, api v29)

The event stage's live seam: a published scene's canvas now translates
raw pointer input into semantic events, routes them through the pure
router, and delivers them to the OWNING plugin — with a host-local
drag preview that never touches the stored scene.

- Prims carry their element: ScenePrim::element (hit-testing and the
  preview target); project_elements sets it.
- hit_test: the topmost prim containing the scene-space point (bounding
  boxes, deliberately coarse — the plugin owns finer semantics).
- SceneCanvas::update (the vendored canvas Program::update, Option<
  Action>): left press/release/cursor-move inside bounds publish
  Message::PanelSurfacePointer { owner, panel, pointer, element, pos };
  scene space equals canvas-local space (S01 no-transform invariant).
- dispatch: the PanelEventRouter owns the semantics (click vs drag,
  move coalescing, at-most-one settle, lossless cancel); each routed
  event goes out owner-targeted via
  v4_support::publish_surface_event_to_plugin. Desktop-only delivery —
  the web runtime has no plugin host and its routed events die there
  (paired-stub convention; no surface can exist on web).
- Host-local preview: the canvas paints the dragged element shifted by
  (preview pos − origin) at PAINT time; the stored scene, the retained
  cache and the plugin's data are untouched until the plugin settles
  with its own patch.

Verification: cargo test --lib -p OpenCADStudio -- panel_events
panel_surfaces plugin_scene 22 passed / 0 failed; cargo test
-p ocs_plugin_api --all-features 209 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 trait errors, fmt/clippy
informational jobs) inherited and untouched.
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