Repository navigation
Plugin panels: native widget tier for semantic trees/lists (S05, api v29) - #3540
Merged
HakanSeven12 merged 7 commits intoNov 23, 2026
Merged
Conversation
…part 1, api v29)
Stage 5 begins: semantic TREES and LISTS the host renders with its own
native widgets. Same ownership split as the scene tier — the plugin
owns the semantics, the host owns selection/expansion/scroll/focus
(host-local transient state) and renders natively; plugin and host
share nothing but this serializable vocabulary.
widget.rs (ungated, beside scene.rs — the store stays wasm-clean):
- Flat-by-design layout (finding F4): every row in a bounded map, plus
the display order of roots and of each loaded child list. Rows never
nest subtrees, so pages stay small and the model has no recursive
traversal costs.
- WidgetChildren::Leaf | Unloaded | Loaded(ordered child ids):
Unloaded marks children that exist but must be PAGED IN on expansion
— the lazy-expansion primitive.
- WidgetPage { base_revision, parent, after-cursor, bounded rows,
next-cursor }: revision-checked and ATOMIC like the scene patch —
installs under the parent (Unloaded parents become Loaded), positions
after an existing sibling when a cursor names one, refuses duplicates
/ over-budget / unknown parents / leaf parents / stale bases with
zero mutation. Installing another page never replaces the surface.
- Bounds: MAX_WIDGET_NODES 10_000 per surface, MAX_PAGE_ROWS 1_000 per
page, dialog text budget for labels; validate() enforces reachability
from the roots (no orphans, no cycles, exact coverage).
- WidgetRevision is INDEPENDENT of scene revisions (F1: surfaces
advance separately).
- 8 tests: lazy expansion, after-cursor continuation ordering, stale
base zero-mutation, atomic duplicate-id refusal, leaf/unknown parent
refusals, unknown after-cursor, page budget, orphan rejection.
Verification: cargo test -p ocs_plugin_api --all-features 217 passed /
0 failed / 1 ignored (208 + 8 new). Deliberately absent (S05 part 2+):
the PanelSurface::Widgets wire tail, the paged-children request flow,
the host-side widget store + native renderer, and host-local
selection/expansion state.
…(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.
…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.
…r (S05 part 2b, api v29)
Completes the widget tier's type-safety and fixes the host build:
- widget.rs: WidgetRejectCode + WidgetReject { code, current_revision:
Option<WidgetRevision> } — the widget tier's rejection vocabulary, so
its independent revision space (finding F1) is type-safe end to end;
From<scene::SurfaceRejectCode> maps the shared resolution codes.
- The wire page/widget-publish answers (response variants 51/52) and
the HostApi widget/page methods carry WidgetReject; the client mirrors
it.
- Host session: resolve_surface_panel moves to the INHERENT HostSession
impl (helpers cannot be trait-impl members) and returns the shared
code; the scene/widget/page overrides map it into their own tier's
rejection type. All three surface tiers now share one attachment/
ownership gate (unregistered -> Unattached, foreign -> OwnedByOther).
Also fixes the store's page install to call WidgetSurface::apply_page
(the atomic entry point) instead of a nonexistent page-side method.
Verification: cargo test -p ocs_plugin_api --all-features 218 passed /
0 failed / 1 ignored; cargo check --lib -p OpenCADStudio clean (the
earlier host failures were a stale shared-target artifact — a lib.rs
touch forced the re-check and the host compiles with the widget tier);
scoped rustfmt clean on touched files.
…nt wiring (S05 part 3, api v29) Completes the widget tier end to end: a published widget surface now RENDERS with the host's native widgets, and its interaction model keeps selection, expansion, scroll and focus HOST-LOCAL (finding F2's host-local law) — the plugin is notified only where it is the data source. - ui/window/plugin_widgets.rs: WidgetUiState (expanded set, single selection — host-local transient view state) and widget_view: a scrollable native column walking the validated surface depth-first with a hard 64-level render cap, depth-indented rows, expand affordances (collapsed/expanded markers for Unloaded and Loaded rows), and a host-local selection highlight. Clicks are plain native buttons — no canvas, no hit-testing: native widgets route their own events. - PanelEventRouter gains on_node_activated / on_node_expanded — the widget tier reuses the per-surface monotonic sequences for its explicit event identity. - Message + dispatch: PanelWidgetNodeActivated delivers SurfaceEvent::NodeActivated (best-effort, owner-targeted); PanelWidgetExpandToggled toggles host-local state and notifies SurfaceEvent::NodeExpanded ONLY when an Unloaded row expands — the one expansion case that is not host-local, because the plugin is the data source for those children (finding F4's lazy primitive; the plugin answers with a WidgetPage install). - dock seam precedence: widget view -> scene canvas -> exact legacy tree; a panel may own both surfaces side by side (finding F1). Verification: cargo test --lib -p OpenCADStudio -- panel_widgets panel_events 6 passed / 0 failed (expansion notify-once semantics, loaded/leaf never notify, host-local single selection, idempotent toggles); cargo test -p ocs_plugin_api --all-features 218 passed / 0 failed / 1 ignored; wasm32 check green for OpenCADStudio + ocs_web_worker (recorded); scoped rustfmt clean. Pre-existing upstream baseline failures (windows D3D12 trait errors; fmt/clippy informational jobs) inherited and untouched.
…5 rebase adaptation, api v29) The rebase onto the merged S03-era store (upstream evolved publish to the tier-generic PanelSurface with a 1-variant enum) applied S05's tier-split scene publish as a textual revert. S05's committed design keeps the scene tier scene-typed (HostApi::panel_surface_publish takes PanelScene; the widget tier publishes through the separate panel_widget_publish pair), so the upstream test bodies are retyped to the scene tier instead.
HakanSeven12
pushed a commit
that referenced
this pull request
Nov 23, 2026
…ays so The #3540 test expected a notification that toggle_expanded's contract and its sibling test rule out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013CaxnfG8bn5Bq4pU3gWTDs
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 5 of the atomic panel-surface train (#3460 static scenes, #3510 patches, #3530 events/drag — all merged): the native widget tier. A plugin that wants to show a tree or list today has no honest option short of repainting a scene canvas and re-implementing hit-testing, selection, and scrolling itself. This stage adds a semantic widget surface the host renders with NATIVE widgets: a bounded flat row model with lazy paging (
Leaf/Unloaded/Loadedchildren — anUnloadedrow asks its plugin for a page only when the user expands it), host-local expansion/selection/scroll/focus, and owner-targeted activation events. Findings honored: F1 (the widget tier advances on its own independent revision space — publishing a page never disturbs a co-existing scene tier), F4 (the paging primitive: installing another page never replaces the whole surface).Public API / wire changes and current API-major basis
Based on upstream
mainat81f499f79(v29, declared by #3460; patches by #3510, events by #3530). No new API major — the tier rides v29's append-only tails:widget.rs(new, ungated):WidgetSurface(flat rows map + root/child order, budgets: 10k rows/surface, 1k/page, bounded text),WidgetRevision(independent of scene revisions),WidgetPage(atomic revision-checked install withafter-cursor +nextcontinuation),WidgetChildren::Leaf/Unloaded/Loaded, reachability validation.PanelSurface::Widgets(WidgetSurface)appended as tier tag 1 (afterScene= 0 — the append S02's pin promised).ipc/protocol.rs:PluginRequest::PanelSurfacePage { panel_id, page }= request variant 65 (right after the scene patch 64); typed answersPluginResponse::PanelSurfacePageResult= 51 andPanelWidgetPublished= 52. Appends only.scene.rsSurfaceEventappends:NodeActivated { node },NodeExpanded { node }— delivered through the EXISTINGHostNotification::PanelSurfaceEvent(tag 16, v29-gated). No new notification tags.HostApipairs:panel_widget_publish/panel_widget_page(session overrides resolve transport identity; the store re-checks ownership).app/panel_surfaces.rs): the store holds a scene AND a widget surface per panel side by side;retain_owners/removecover both tiers; the widget tier refuses with its ownWidgetReject/WidgetRejectCodetypes.Semantics (host-local first)
NodeActivated) and expanding anUnloadedrow (NodeExpanded— the data source is the only party that can produce those rows). Both carry the surface's monotonic sequence as explicit identity and go to the OWNING plugin only (publish_surface_event_to_plugin, best-effort, same law as Plugin panels: semantic surface events with explicit identity + owner-targeted delivery (S04, api v29) #3530).ui/window/plugin_widgets.rs) draws an iced scrollable column with depth indent and expand affordance; a panel with a widget surface mounts it in the dock seam at the established precedence (table > widget > scene > legacy tree).Legacy compatibility
All wire changes are appends (tier tag 1, request 65, responses 51/52); existing tags, scenes, patches, and the tag-16 event envelope are untouched. Panels without a widget surface render their exact previous trees; pre-29 plugins never receive widget-tier requests and cannot send the new variants (unknown-tag
Unknownpassthrough on both sides). A v28 runner cannot decode tag 16 (unchanged gate). The scene tier's publish path keeps its scene-typed signature (see the rebase-adaptation commit: upstream's S03-era store tests were retyped to the tier-scene publish rather than regressing the tier split).Verification (exact commands, exit 0, at head
fa53236c0)cargo test -p ocs_plugin_api --all-features→ 218 passed, 0 failed, 1 ignored (includes:panel_widget_s05_wire_tails_are_pinned— tier tag 1, request 65, responses 51/52 pinned exactly like the legacy discriminant pins).cargo test --lib -p OpenCADStudio -- panel_events panel_surfaces plugin_scene panel_widgets→ 22 passed, 0 failed (widget-model validation/budgets/page-install semantics, store ownership/revision/retain rules, renderer regression, router activation/expansion identity).cargo check --lib -p OpenCADStudio→ clean.cargo check --locked -p OpenCADStudio -p ocs_web_worker --target wasm32-unknown-unknown→ clean (desktop-gated delivery, paired stubs on web).rustfmt --edition 2024 --checkon the new/owned leaf files (widget.rs,plugin_widgets.rs,panel_surfaces.rs) → clean. A full sweep over all 122 touched files reports exactly one fmt delta, insrc/ui/window/ifc_plan.rs— a file this PR does NOT modify (the checker reaches it via module recursion; the same hunks fail on pristine upstream). This branch's one-line edit inplugin_host/tables.rsactually FIXES one of the inherited baseline hunks (29 → 28).Live-test evidence
Not run — honestly. The model/store/renderer/router paths are proven by the unit suites above; a live plugin pushing real rows and a real click/expansion await the Windows host mirror (recorded as pending in the train ledger, same note as #3460/#3510/#3530).
Upstream-baseline failures (not regressions)
cargo fmt --all -- --checkandcargo clippy --all-targets -- -D warningsfail on pristine upstream main already (28 fmt hunks after this branch's tables.rs fix; 11 clippy errors inentity_coverage.rs/host.rs/ipc/*/process/*); both non-blocking jobs. The two Windows CI jobs fail with the inherited D3D12/windows-rs trait errors documented on #3460/#3530 with clean-checkout evidence. This PR adds zero new diagnostics.