Repository navigation
Plugin panels: atomic scene patches + retained projection cache (S03, api v29) - #3510
Merged
HakanSeven12 merged 1 commit intoNov 23, 2026
Conversation
… api v29)
Stage 3 of the atomic scene-ui train: a plugin updates its published
panel scene through bounded, revision-checked patches that apply
atomically (all-or-nothing) against the stored head, and the host's
canvas paints from a retained projection cache keyed by the actual
render inputs — repaints are free; a patch costs exactly one
re-projection.
Scene model (crates/ocs_plugin_api/src/scene.rs, ungated so the pure
store stays wasm-clean):
- SceneOp { Add { parent, element } (None = root append, Some = inside
that group; only groups are containers), Replace { id, element }
(replacement must carry the same StableId), Remove { id } (element
plus its whole subtree) } — appended op vocabulary, never renumbered.
- ScenePatch { base_revision, ops } with MAX_PATCH_OPS = 10_000 and
atomic apply_to: stale base or ANY op failure (unknown id/parent,
duplicate id, budget overflow) refuses with zero mutation; success
advances the revision by exactly one and re-validates the whole
result, so a stored scene is a validated scene by construction.
- SceneError gains StaleBase / PatchTooLarge / UnknownParent /
UnknownElement (internal type, not wire-serialized; appends only).
Wire: PluginRequest::PanelSurfacePatch (variant 64, after publish 63)
and PluginResponse::PanelSurfacePatchResult (variant 50, after 49),
pinned by panel_surface_patch_v29_wire_tail_is_pinned; HostApi gains
the paired panel_surface_patch / panel_surface_patch_for_plugin with
the transport-era Unattached defaults; server dispatch + client
override mirror the publish path. StaleBase maps to the existing
NonMonotonicRevision reject code with the stored head attached, so the
publisher can rebase — no new reject codes, no speculative ack report.
Host: PanelSurfaceStore::patch (attachment + ownership re-checks, then
the pure apply) and the session override; the dock seam is unchanged —
a patched scene simply renders at its new revision through the cache.
Retained cache: PROJECTION_CACHE keys the projected prim list by
(owner, panel, revision) — the actual render inputs; the theme applies
at paint time and never invalidates. One bounded entry per thread;
patched-away revisions are dead state. The proof test shows five
repaints cost zero re-projections and a one-subtree patch costs
exactly one — repaints never rebuild.
Verification: cargo test -p ocs_plugin_api --all-features 198 passed /
0 failed / 1 ignored; cargo test --lib -p OpenCADStudio -- panel_surfaces
plugin_scene 15 passed / 0 failed (new: atomicity, stale-base head
report, foreign-patch refusal, patch-without-store refusal, retained-
cache proof); wasm32 check green for OpenCADStudio + ocs_web_worker;
scoped rustfmt clean on touched files. Pre-existing upstream baseline
failures (fmt hunks, clippy -D warnings in entity_coverage/host/ipc/
process, non-blocking CI) inherited and untouched.
This was referenced Nov 23, 2026
Plugin panels: semantic button rows on widget surfaces; menus reuse quad panels (S06, api v29)
#3545
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and minimal scope
Stage 3 of the atomic panel-surface train (#3460, merged): a plugin updates its published panel scene through bounded, revision-checked patches that apply atomically (all-or-nothing) against the stored head, and the host's canvas paints from a retained projection cache keyed by the actual render inputs — repaints are free; a patch costs exactly one re-projection.
Public API / wire changes and current API-major basis
Based on upstream
mainat66c83e785(API_VERSION= 29, declared by #3460). No new API major — this stage rides v29's tails:PluginRequest::PanelSurfacePatch { panel_id, patch }— variant 64 (after publish 63).PluginResponse::PanelSurfacePatchResult(Result<SceneRevision, SurfaceReject>)— variant 50 (after 49). Both pinned bypanel_surface_patch_v29_wire_tail_is_pinned.SceneOp { Add{parent,element} (None=root, Some=inside that group; only groups are containers), Replace{id,element} (same StableId required), Remove{id} (element + whole subtree) }andScenePatch { base_revision, ops }withMAX_PATCH_OPS = 10_000— incrate::scene(ungated: the pure store stays wasm-clean and shares the wire's vocabulary).SceneErrorgainsStaleBase / PatchTooLarge / UnknownParent / UnknownElement(internal, not wire-serialized; appended).HostApigains the pairedpanel_surface_patch/panel_surface_patch_for_pluginwith the transport-eraUnattacheddefaults; server dispatch + client override mirror the publish path.Semantics
apply_tostages a candidate, applies ops in order, advances the revision by exactly one, and re-validates the whole result. Any failure (stale base, unknown id/parent, duplicate id, budget) refuses with zero mutation — the publisher rebases; it never muddles through.NonMonotonicRevisionreject code with the stored head attached — no new reject codes, no speculative ack report (finding F1's economy).PROJECTION_CACHEkeys projected prims by(owner, panel, revision)— the actual render inputs; the theme applies at paint time and never invalidates. One bounded entry per thread; patched-away revisions are dead state. Lifecycle-safe: panel re-registration and the dead-plugin reap (retain_owners) now callforget_all_projections(), so a re-registered panel that restarts its revisions can never paint a dead scene's prims at a reused revision.Explicit non-goals and dependency
Depends on #3460 (merged — rebased onto its follow-up fixes at
66c83e785). Non-goals: semantic events/drag (S04, in preparation), widget surfaces (S05+), MCP (S08), any per-subtree incremental projection splicing (the revision-keyed cache is the demonstrated-need cache; finer granularity waits for a consumer).Legacy compatibility
Existing variants untouched (appends only, tags pinned);
DialogControl/DialogValue/HostNotificationuntouched; panels without scenes render their exact legacy trees. A v28 runner cannot decode tags 63/64 (manifest gate; v29 already declared by #3460).Verification (exact commands, exit 0)
cargo test -p ocs_plugin_api --all-features→ 208 passed, 0 failed, 1 ignored (includes patch atomicity, stale-base head report, unknown-id/parent refusals, budget, wire pins 64/50).cargo test --lib -p OpenCADStudio -- panel_surfaces plugin_scene→ 16 passed, 0 failed (store patch semantics + cache proofs).cargo check --lib -p OpenCADStudio→ clean;cargo check --locked --target wasm32-unknown-unknown -p OpenCADStudio -p ocs_web_worker→ clean (recorded artifact).rustfmt --checkclean on touched files. Pre-existing upstream baseline failures (windows D3D12 trait errors — see the Plugin panels: publish declarative scene surfaces end to end (S02, api v29) #3460 discussion; fmt/clippy informational jobs) are inherited and untouched.Live-test evidence
Not run — honestly. The patch path is exercised at the store/wire/semantics level above; the live host acceptance run remains recorded as pending tooling availability (same note as #3460).
Adaptation to upstream movement
Rebased onto
66c83e785on top of this morning's panel-scene lifecycle fixes (95cdba06e): the projection cache now invalidates at the same lifecycle points the store forgets scenes (re-registration + reap), andpaint_primfollows the upstream signature (bounds parameter removed).