Skip to content

Ariadne: right-click menus, context_menu: (shell phase SH8) - #1512

Merged
transfix merged 3 commits into
masterfrom
tfx/shell-sh8-context-menus-d35e2c
Nov 25, 2026
Merged

transfix merged 3 commits into
masterfrom
tfx/shell-sh8-context-menus-d35e2c

Conversation

@transfix

@transfix transfix commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Phase SH8 of the Ariadne shell design (docs/roadmap/ARIADNE_SHELL.md §4.7, gap 4): a document's own right-click menus, context_menu:. Documented as docs/ARIADNE.md §5.30. Master is merged in, including #1476 (§5.28, the built-in context menu on text: Cut, Copy, Paste, Select text...) and §5.29 (a picture's Save). SH8 is now part of that one menu rather than a second system. SH9 (contributes: context_menus:) builds on it.

What it adds

  • context_menu: on a window (and an overlay), a group (and a panel), a viewport (any custom widget; a viewport adds its pick) and the document's top level (the main view). Its items are a menu's items:. It is written as a list, or as { id: <name>, items: [...] }. The loader warns about it anywhere else, and ignores a loaded document's top-level one with a warning (the main view belongs to the outermost document).
  • One menu. One request opens one menu: a right-click, a long press, the Menu key or Shift+F10.
    • Over a widget with entries of its own (a field's Cut/Copy/Paste/Select all, a text's Copy, a picture's Save image...), those come first. The items of the innermost context_menu: around it follow, under a rule.
    • Over anything else inside one (a viewport, a checkbox, a group's empty space), the menu is that context_menu:'s items alone.
    • With no context_menu: around it, the menu is ariadne: a context menu on text in every backend: Cut, Copy, Paste, Select all (§5.28) #1476's, unchanged.
    • A window without a context_menu: adds nothing over its widgets.
  • event is taken when the menu opens and kept while it stays open:
    • on: group, window, main, or a custom widget's type.
    • id and menu: the widget's id and the menu's id.
    • via: pointer, touch or key.
    • px/py: where the menu opened.
    • Over a scene view, the pick fields an input: pick viewport writes (node, hit, x, y, z, i, j, k, value, axis, view, mods) as strings, plus tags, the node's own tags as a list.
    • Every field is always there, so (get-attr event "node") never throws.
    • Items' visible_when: (and enabled/disabled_when) read event. A read-lane result that read it is never cached.
  • The pick: a viewport hands the core CustomEdit::context_pick, which picks at the pointer only on the frame the menu opens. The main view's pick comes from Runtime::set_main_view_pick, which AriRuntime wires to SceneViews::main_pick_fields (it leaves out what main_view: hides). A viewport's pick key and its on_pick: event gain tags.
  • id is parsed and kept for SH9. Nothing adds items to a menu yet, and a menu without an id takes items from no one.
  • requires: token ui.context_menu: ImGui, FTXUI, tvision.
  • Schema: the closed .ari schema (ari.v1.schema.json, Ariadne: a closed .ari schema every load checks, and ari validate #1464) learns context_menu on the document, groups, panels, windows, overlays, custom widgets and include sites, and kBuiltinBlocks lists it.

Backends

Choices to review

Tests

Run locally on Windows/MSVC, built with FTXUI and with tvision (from .deps/tray-term):

  • ariadne_runtime_test: 368 pass, including 4 for SH8:
    • an item runs with its event over a group;
    • over a viewport with a pick, visible_when: reads event and is not cached across menus;
    • the main view's menu, and a repeated group's menus acting on their rows;
    • the token.
  • ariadne_loader_test: 272 pass, including 2 for SH8.
  • ariadne_ftxui_test: 126 pass. Six are SH8's, including the field-in-a-card merge and the hosted model a host reads.
  • ariadne_requires_test 20 and ariadne_schema_test 13: all pass.
  • cvcgl_imgui_document_menu (SH8's ImGui test): passes. It covers a text in a card (its Copy, then the card's items), the window's and the main view's menus, a right-drag opening nothing, the long press, and the Menu key.
  • cvcgl_ariadne_pick: 38/38. It covers tags under the pick key and real right-clicks on a viewport and on the main view.
  • Golden context_menu: regenerated under Mesa llvmpipe. It shows the text's Copy and Select text... above the card's items, with the scene-node item hidden.
  • ariadne: a context menu on text in every backend: Cut, Copy, Paste, Select all (§5.28) #1476's cvcgl_imgui_context_menu: its 16 clipboard checks fail in this session because the Windows clipboard itself is refused here (Set-Clipboard fails). Its menu checks pass, and that test reaches none of SH8's code paths. CI's Windows job runs it with a clipboard.
  • tmux: ari_run_context_menu_ftxui / _tvision (src/ari/tests/context_menu_test.sh) run only in the Linux CI jobs; this box has no tmux. Before this push, _ftxui passed in CI and _tvision failed as described above.

Not in this PR

  • contributes: (SH9).

context_menu: on a window, a group, a viewport (any custom widget) and
the document's top level (the main view): a menu's items, as a list or
{ id, items }. The innermost menu under the pointer, or around the
focus, opens. Its items get an `event` dict taken when it opens: what
it is over and that widget's id, the menu's id, how and where, and
over a scene view the pick there plus the node's tags (a list). Their
visible_when: reads it; results that read it are never cached.

- Backend: begin_context_area / end_context_area around what a menu is
  over, then begin_context_menu / end_context_menu; Capabilities::
  context_menu and the requires: token ui.context_menu.
- ImGui: a popup, opened on a right-click released without a drag (a
  right-drag pans a view), a touch long press when the finger lifts,
  or the Menu key / Shift+F10 at the pointer; an item's area is a group
  whose inner last item is kept for on_click and tooltips.
- FTXUI and tvision: the Menu key or Shift+F10 opens the menu around
  the focus, a right-click the one under the pointer; worked like a
  dropdown. Shift+F10 decoded from CSI 21;2~ and kbShiftF10.
- cvcGL: a viewport's CustomEdit::context_pick and the main view's
  Runtime::set_main_view_pick (SceneViews::main_pick_fields); pick_at's
  cell pick factored into pick_props; picks gain `tags`.
- The menu id is parsed and kept for SH9's contributes:; nothing adds
  to a menu yet. kAriSchema learns context_menu.

Docs: ARIADNE.md 5.28, the token, the pick's tags. Tests: runtime,
loader, FTXUI, cvcgl_imgui_context_menu, cvcgl_ariadne_pick, the
context_menu golden, and ari_run_context_menu_ftxui / _tvision (tmux).
…ext_menu:)

Master's #1476 gave every backend a built-in context menu on text (Cut,
Copy, Paste, Select text..., ARIADNE.md 5.28) and 5.29 a picture's Save.
SH8's context_menu: now joins that menu instead of running beside it:

- One request opens one menu. Over a widget with entries of its own
  (a field, a text, a picture) those come first, then under a rule the
  items of the innermost context_menu: around it; over anything else
  inside one, its items alone; with none around, #1476's menu as is.
- ImGui: the document's areas live in #1476's ContextMenus. A menu a
  text or field opens remembers the innermost area, which appends its
  items to the same popup; elsewhere the area opens one through the
  same open()/begin() (its long press, Escape, one claim a frame).
- FTXUI: #1476's ctx menu holds the leaf's entries and keeps the
  area's items as rows after them; one Shift+F10 / Menu path, one
  right-click path. The duplicate key decoding is gone (master had it).
- tvision: Options::host_draws_context_menu; hosted_context_menu() and
  pick_context_entry() let the bridge show the menu with popupMenu at
  its place, so a short window no longer cuts it off. That was the
  failing ari_run_context_menu_tvision: a two-row window drew the menu
  as an empty frame.
- The section is ARIADNE.md 5.30; 5.28 points to it. The closed schema
  (ari.v1.schema.json, from #1464) learns context_menu on the document,
  groups, panels, windows, overlays, custom widgets and include sites,
  and kBuiltinBlocks lists it.
- Picks: pick_props takes master's node map (id and node, for a node's
  own on_pick:); CustomEdit keeps both events and context_pick.

The ImGui test for SH8 is cvcgl_imgui_document_menu (master's
cvcgl_imgui_context_menu keeps its name); FTXUI gains
AFieldInACardOffersItsOwnEntriesThenTheCards and
AHostedContextMenuIsAModelForTheHost; the context_menu golden now shows
the text's Copy and Select text... above the card's items.
ari_run_context_menu_tvision now opened the menu (tvision's popup) but
Enter picked nothing: TMenuPopup::execute clears the menu's default
entry on purpose ("would look ugly"), so a popup starts with nothing
lit and Enter does nothing until an arrow key. The context menu's popup
is now a ContextPopup, a TMenuPopup that lights the first enabled entry
when a key opened it (HostedContextMenu::by_key), placed as popupMenu
places its own; opened by the pointer it keeps tvision's look.
@transfix
transfix merged commit 9a68dae into master Nov 25, 2026
31 checks passed
@transfix
transfix deleted the tfx/shell-sh8-context-menus-d35e2c branch November 25, 2026 19:09
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