Skip to main content

Module picker

Module picker 

Source
Expand description

Slash-command picker — live-filtered list of commands the operator can tab-complete into the prompt.

§Activation

The picker is ambient: every render, app::state checks whether the first row of the prompt buffer starts with /, and if so, builds a fresh SlashPicker from the filter string (the characters after the /). There is no “open / close” flag — typing the leading slash opens it, deleting it closes it. This matches the “no mode” invariant used by the overlay system and avoids a stale picker hanging around when the operator clears the prompt.

The picker yields priority to the friction-pause overlay: when a gate is active, app::state suppresses the picker regardless of prompt contents.

§Matching

The match function is a deliberately simple subsequence scorer (fzf-lite). Each candidate name is walked character by character; a match requires the filter’s chars to appear in order. Score is built from:

  • -distance_to_prefix — matches that start at character 0 rank higher than mid-name matches (/h prefers /help over /flatten-all with h mid-word).
  • -cluster_penalty — contiguous runs are cheaper than scattered hits (so /sta prefers /status over /state only because the whole query is contiguous in both; the tiebreaker falls back to catalog order).

No external crate. fzf-rs and nucleo-matcher are both good libraries, but both are 5-figure-LOC deps and we need exactly 14 entries to match — a subsequence scorer is sufficient and zero-dep friendly.

Structs§

SlashMatch
One picker row — the catalog entry plus bookkeeping used by the widget to bold the matched chars.
SlashPicker

Constants§

PICKER_MAX_VISIBLE
Max visible rows in the picker popup. Six fits the common case (all current commands after a two-char filter) without stealing the conversation pane.