Skip to content

refactor(viewer): toolbar API - #26

Open
ericgozzi wants to merge 3 commits into
mainfrom
feature/toolbar-schema
Open

ericgozzi wants to merge 3 commits into
mainfrom
feature/toolbar-schema

Conversation

@ericgozzi

@ericgozzi ericgozzi commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Replaces the backend-declared toolbar descriptor (full groups/items/labels/icons synthesized into generic Button/Checkbox/Select components) with a small id-keyed control message (dispatch: "toolbar_control", overrides: { [id]: { visible?, enabled? } }).
  • Every toolbar button stays a hand-written .vue owning its own icon and behavior, matching every other button in this codebase; the backend can only show/hide or enable/disable a button the frontend already defines, never create one.
  • Adds useToolbarControl(id) composable, wired into all 14 built-in toolbar buttons.
  • Deletes the generic schema-driven renderer (ToolbarRenderer.vue, ToolbarItemTooltip.vue, toolbar_icons.ts, toolbar_utils.ts) - Toolbar.vue, already mounted via Sidebar.vue, is the only toolbar now.
  • Adds CompasViewerOptions.extraToolbarModules so an npm-installed .vue module can be mounted into the toolbar without forking this repo.

Companion PR on the Python side: compas-dev/compas_threejs#54

Test plan

  • npm run typecheck
  • npx eslint src tests --max-warnings=0
  • npx vitest run (all suites pass; tests/browser/kitchen_sink.spec.ts is a pre-existing Playwright/Vitest runner mismatch, unrelated)
  • npm run build:app

ericgozzi and others added 3 commits September 21, 2026 13:14
…oggles visible/enabled

Replaces the backend-declared toolbar descriptor (dispatch: "toolbar", full groups/
items/labels/icons synthesized into generic Button/Checkbox/Select components) with a
small id-keyed control message (dispatch: "toolbar_control", overrides: { [id]:
{ visible?, enabled? } }). Every toolbar button stays a hand-written .vue owning its
own icon and behavior, matching every other button in this codebase; the backend can
only show/hide or enable/disable a button the frontend already defines, never create
one.

- New useToolbarControl(id) composable wired into all 14 built-in toolbar buttons.
- Deletes the generic schema-driven renderer (ToolbarRenderer.vue,
  ToolbarItemTooltip.vue, toolbar_icons.ts, toolbar_utils.ts) - Toolbar.vue, already
  mounted via Sidebar.vue, is the only toolbar now.
- Adds CompasViewerOptions.extraToolbarModules so an npm-installed .vue module can be
  mounted into the toolbar without forking this repo.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
No logic change - line-wrapping only, so npm run check's format:check step
(which this branch hadn't been run through before) passes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds examples/embedded_custom_toolbar_button.html, showing extraToolbarModules with
a plain Vue component (as a real npm-installed module would ship) that reads its
own visible/enabled state via useToolbarControl(id) and sends interactions back to
the backend via useViewerRuntime().handleUiAction(id, value) - both now exported
from the public library entry point (they weren't before, so extraToolbarModules
was effectively unusable by anyone outside this codebase).

Also fixes src/library/public.d.ts, the hand-maintained published type declarations
file, which never gained extraToolbarModules when it was added to the internal
CompasViewerOptions - the npm package's own .d.ts didn't advertise the option at
all.

Verified end-to-end with a Playwright smoke check against the built dist-lib/
output: button renders, is clickable, no console errors.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ericgozzi ericgozzi changed the title refactor(viewer): frontend-owned toolbar buttons, backend only toggles visible/enabled refactor(viewer): toolbar API Sep 21, 2026
@ericgozzi
ericgozzi added this pull request to stack #29 September 21, 2026 12:47

This branch has not been deployed

No deployments
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.

1 participant