Skip to content

refactor(viewer): shrink Toolbar to id-keyed visible/enabled overrides - #54

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

  • A toolbar button is always defined and rendered by the frontend (built-in or installed from an npm package); the backend can only reference an existing button by its id and flip visible/enabled via set_visible/set_enabled, sent as a single overrides map (dispatch: "toolbar_control") under the toolbar's existing stable persisted obj_id.
  • Wires Toolbar up for real: Workspace owns one, and App.toolbar delegates to it the same way background_color/world_axis/etc. do, so app.toolbar.set_visible(id, False) now actually works.
  • Keeps Inbox/App's register_toggle_action/register_select_action - still needed so a custom or npm-installed toolbar button (which drives itself via runtime.handleUiAction(name, value) on the frontend) can register a backend callback.

Companion PR on the TS side: gramaziokohler/compas_threejs_ts (same branch name, feature/toolbar-schema).

Test plan

  • pytest (full suite, 14 tests including new register_action/register_toggle_action/register_select_action round-trip coverage)

Toolbar no longer models toolbar items at all - ToolbarItem, add_button/add_checkbox/
add_select/add_separator, and remove are gone. A toolbar button is always defined and
rendered by the frontend (built-in or installed from an npm package); the backend can
only reference an existing button by its id and flip visible/enabled via
set_visible/set_enabled, sent as a single overrides map (dispatch: "toolbar_control")
under the toolbar's existing stable persisted obj_id.

- Wires Toolbar up for real: Workspace owns one, and App.toolbar delegates to it the
  same way background_color/world_axis/etc. do, so app.toolbar.set_visible(id, False)
  now actually works.
- Keeps Inbox/App's register_toggle_action/register_select_action - still needed so a
  custom or npm-installed toolbar button (which drives itself via
  runtime.handleUiAction(name, value) on the frontend) can register a backend callback,
  independent of the now-removed Toolbar item model.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ericgozzi and others added 2 commits September 21, 2026 13:33
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Shows app.toolbar.set_visible/set_enabled toggling two of the frontend's built-in
toolbar buttons ("add_objects", "move") from Checkbox UI elements - the only two
things the backend can do to a toolbar button: show/hide or enable/disable one the
frontend already defines, by id.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ericgozzi
ericgozzi added this pull request to stack #56 September 21, 2026 13:04

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