Skip to content

Palette Parts

alikit:palette_parts is a copyable, parts-based variant of the command palette’s result list. It owns the retained virtual list, published List_Box collection, selection reconciliation by stable Item_ID, enabled-row navigation, reveal, and one activation event. The application owns the query, matching and ranking, commands, modal shell, dismissal, and focus restoration.

Native palette parts window with a filter field and a six-row result list
Native SDL_GPU capture of examples/palette_parts at Alicorn 47c9d4a. This is the reusable result-list part, not the modal command palette.
Interactive WebGPU preview is a later catalog step. This capture is the real native application; the row list is not recreated in JavaScript.
LayerResponsibility
AlicornVirtual list, scroll region, Button owners, List_Box semantics, focus, and rendering.
palette_partsRow drawing, selection by stable ID, enabled navigation, reveal, List_Box collection, and one activation event.
ApplicationQuery field, matching/ranking, commands, modal shell, dismissal, and focus restoration.

This package deliberately does not wrap alikit:command_palette. It exists to show which pieces of the stock palette are ordinary public Alicorn facilities and which policy remains application-owned. The stock palette remains the complete choice.

Files: palette_parts/parts.odin, palette_parts/parts_test.odin, palette_parts/pilot_test.odin, examples/palette_parts/main.odin.

import alicorn "alicorn:runtime"
import ui "alicorn:ui"
import model "alikit:palette_model"
import parts "alikit:palette_parts"
ITEMS := [2]model.Item{
{id=model.Item_ID(1), title="Open File", description="Browse the workspace"},
{id=model.Item_ID(2), title="Build Project", keywords="compile"},
}
App :: struct {
matches: [2]model.Match,
visible: int,
results: parts.State,
}
render :: proc(app: ^App, ctx: ^ui.UI) {
app.visible, _ = model.filter(ITEMS[:], "", app.matches[:])
event := parts.results(
ctx,
&app.results,
ITEMS[:],
app.matches[:app.visible],
key=alicorn.key_string("app-palette-results"),
options=parts.Options{accessible_label="Commands"},
)
if event.kind == .Activated {
// Dispatch event.item_id in application code.
}
}

Pass a fresh visible slice each description. The part never stores item strings. handle_key is the application’s keyboard path when its query field owns focus:

handled, event := parts.handle_key(&app.results, rt, ITEMS[:], app.matches[:app.visible], key)

When the list owns focus, its retained interaction scope delivers the same keys through interaction_event_next during the next description. Both paths use palette_model.move and palette_model.activate; there is no second selection policy. request_focus asks for one after-frame focus of the list.

PartIdentityWhat can be replaced
Virtual listlist_begin/list_endRow height, maximum height, and accessible name.
Row ownerstable Item_IDitem_begin/item_end owns List_Box_Option; draw any compatible subtree.
Leading iconicon partReplace the accent tile with an icon or swatch.
Label / descriptionlabel / description partsRestyle without changing identity.
Selected indicatorindicator partReplace the check glyph; keep the selected state.
Groupgroup_begin/group_endSingle-level semantic group for shorts lists where all rows are realized.
EmptyemptyNo-results label.
List collectionlist_semantic_id(namespace)The List_Box identity and logical count.

results is a convenience wrapper over list_begin, item_begin, the optional visual parts, item_end, and list_end. command_palette uses the same public parts for its modal result list, so the two paths share one contract.

Each realized row is a button_begin(presentation=.Custom) owner with a List_Box_Option semantic record. Rows expose Selected, Current, Disabled, and Select/Focus actions. The scroll region owns the List_Box collection with a logical count, realized range, and selected/current identity.

  • Visual parts are attached for .Icon, .Label, .Content, and .Selected_Indicator, so an application can restyle without changing behavior.
  • The part uses Alicorn core roles (Surface, Text, Muted_Text, Selection, Accent); it declares no theme contract.
  • Options carries the accessible label, empty label, row height, list maximum height, semantic namespace, and focus_on_pointer.
  • There is no part-authored motion. Reveal is a retained virtual-list request, not a second layout pass.
InputResult
Up / Downpalette_model.move with wrapping and disabled skipping.
Home / EndFirst/last enabled visible row.
ReturnOne activation event for the selected stable item.
pointerRow activation through the ordinary Button owner.
semantic SelectThe same activation through List_Box_Option.
caller reorder/removalSelection follows Item_ID; reconcile falls back to the first enabled row.

The part publishes only realized rows. virtual_list_ensure_visible is requested after navigation; the list remains a single Tab stop with non-focusable rows.

palette_parts/parts_test.odin covers the list part; the stock-versus-parts pilot now lives in command_palette/pilot_test.odin because the palette consumes this package:

  • retained virtual rows, published List_Box/List_Box_Option semantics, and logical count;
  • Up/Down wrapping, disabled skipping, Home/End, and Return activation;
  • pointer and semantic activation parity;
  • stable selection across caller reorder and removal;
  • reveal and focus request behavior, and idle return after navigation;
  • the stock-versus-parts comparison recorded in the issue 3 research note.
Terminal window
odin test palette_parts -define:ODIN_TEST_THREADS=1 -collection:alicorn=<alicorn> -collection:alikit=.
./out/palette_parts_example.exe --smoke

No dedicated testui pattern kind fits a result-list part; the suite uses explicit drive and semantic assertions. The .Roving_List pattern requires a List_Box container and a different focus owner model.

DeclarationNotes
Event / Event_KindOne Activated event carrying item_id.
OptionsAccessible label, empty label, row height, maximum list height, namespace, pointer focus.
StateSelection, derived visible index, list owner, namespace, reveal/focus flags.
List, Row, GroupPer-description contexts.
resultsDescribe the default list and return an activation event.
list_begin, list_end, item_begin, item_endPublic list/row parts.
row_surface, icon, label, description, indicatorOptional default visuals.
empty, group_begin, group_endEmpty and single-level group parts.
handle_keyNavigation when the query field owns focus.
request_focusAsk for one after-frame focus of the list.
selection_visible_indexReport the selected row’s current visible position without retained state.
item_semantic_id, list_semantic_id, group_semantic_id, row_keyStable identities and retained keys.
  • It is a result-list part, not a modal palette. Add the application’s own overlay/query shell.
  • It does not implement type-ahead; the query field owns text input.
  • Page Up / Page Down are not handled, matching the stock palette’s current keyboard contract.
  • Headless tests do not validate native IME or a platform accessibility bridge.
  • At the pinned Alicorn revision, row text layout can elide some labels under the current fit-content/grow measurement limits; the pilot record tracks the core layout gap. The part’s identity, navigation, semantics, and activation do not depend on the painted label width.
Pin: built and captured against Alicorn 47c9d4a7cd1f637876190fec899daeeac00a30ae. See Compatibility and pinning.