Skip to content

Add registerDrawingAction: host buttons on a selected drawing - #414

Merged
smack369 merged 3 commits into
devfrom
feat/drawing-toolbar-actions
Nov 17, 2026
Merged

smack369 merged 3 commits into
devfrom
feat/drawing-toolbar-actions

Conversation

@smack369

Copy link
Copy Markdown
Contributor

Background

Apps built on Vela can add buttons to the topbar, the right-click menus and the indicator legend, but not to a selected drawing. The toolbar that floats by a selected drawing and its settings dialog are closed to hosts. An app that acts on drawings (an alert on a line, a note, a share link) can only reach them through the right-click menu, where users rarely look for them.

Summary

A new plugin SDK contribution, registerDrawingAction, built the same way as registerLegendAction:

  • Descriptor (@luxalgo/vela/plugin): { id, icon, label, when?(drawing), run(ctx, drawing), surfaces?, order? }. drawing is the SerializedDrawing that chart.drawings.all() returns.
  • Renderer port: an optional setDrawingActions?(provider) method on IChartRenderer, also on RendererControl. Both shells wire the registry through it with drawingActionsProviderFor, from cell build and from refreshActions().
  • Native renderer:
    • An icon button on the selection toolbar, placed before the settings wheel.
    • A labelled ghost button at the start of the settings dialog footer.
    • The toolbar for a multi-drawing selection leaves actions out.
    • run gets a fresh WidgetContext, and reads the drawing again at click time.

Docs: the plugin SDK section, the renderer-author tier table, the user drawing guide, and the plugin skill. The changelog entry is under [Unreleased].

End-to-end verification

I tested in the playground (npm run playground, Chromium via Playwright, live BTCUSDT 1h data from Binance):

  • I drew a horizontal line (Alt+H) and clicked it to select it. The contributed button rendered in the toolbar between the text control and the gear, with a working tooltip.
  • Clicking the button ran the action with the line's current price.
  • I opened the settings dialog with the gear. The contributed button rendered first in the footer, before Cancel and OK, and clicking it ran the action.

The playground registers a neutral demo action ("Show drawing info") on line drawings so reviewers can try it.

Checklist

  • This PR does one thing (one fix, one feature, one refactor, or one docs change)
  • npm run typecheck, npm run lint, npm test, and npm run build all pass
  • Tests have been added / updated (for bug fixes / features)
  • Documentation in docs/ has been added / updated (for public interface or feature changes)
  • CHANGELOG.md has an entry under [Unreleased] (for user-visible changes)
  • I have signed the CLA (the bot asks in this PR)
  • I have reviewed this pull request myself (self-review)

Future work

  • None of the right-click menu actions take the selected drawing yet. That would need a separate contribution, out of scope here.

Generated by Claude Code

Apps can now contribute an action to one drawing: an icon button on the
toolbar that floats by a selected drawing (before its settings wheel) and
a labelled button at the start of the drawing's settings dialog footer.

The seam follows the legend-action pattern: a descriptor registry in the
plugin SDK (`registerDrawingAction`, with a per-drawing `when` gate,
optional `surfaces` and `order`), a provider both shells hand the renderer
through the optional `setDrawingActions` port method, and the native
renderer projecting the resolved views into its toolbar and dialog. `run`
receives a fresh WidgetContext and the drawing re-read at click time; a
multi-selection toolbar leaves the actions out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DR6sEXJjHhjbSfN4Qm4HGL
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DR6sEXJjHhjbSfN4Qm4HGL
@github-actions

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Copy link
Copy Markdown
Contributor Author

The CLA check fails because the commits are authored by Claude <noreply@anthropic.com>, a coding agent working for LuxAlgo. That isn't a GitHub account that can sign a CLA, and signing it on someone's behalf isn't my call. A LuxAlgo maintainer decides whether this check applies to internal agent commits, the way it was handled for earlier Claude-authored commits on dev. The diff doesn't affect any other check.


Generated by Claude Code

@smack369
smack369 merged commit 43302b0 into dev Nov 17, 2026
1 of 2 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants