Skip to main content

Module palette

Module palette 

Source
Expand description

Command palette state and rendering (keyboard-first, fuzzy-ish search). Integration hooks live in src/ui/app.rs; this module stays side-effect free.

§Interaction Contract

TriggerBehavior
Ctrl+P / Alt+POpen palette → push focus trap GROUP_PALETTE
EscClose palette → pop focus trap, discard query
EnterExecute selected action → close → dispatch CassMsg
Up / kMove selection -1 (wraps)
Down / jMove selection +1 (wraps)
Ctrl+UClear query
Any printableAppend to query → refilter → reset selection to 0
BackspaceRemove last char → refilter

§Action Groups

Each PaletteAction belongs to exactly one PaletteGroup. Groups are used for categorical rendering (section headers, icons) and mapping validation.

GroupActions
ChromeToggleTheme, ToggleDensity, ToggleHelpStrip, OpenUpdate
FilterFilterAgent, FilterWorkspace, FilterToday/Week/CustomDate
ViewOpenSavedViews, SaveViewSlot, LoadViewSlot, BulkActions, ReloadIndex
AnalyticsAnalyticsDashboard..AnalyticsCoverage
ExportScreenshotHtml, ScreenshotSvg, ScreenshotText
RecordingMacroRecordingToggle
SourcesSources

§Migration Target (FrankenTUI command_palette)

Each action maps to exactly one CassMsg dispatch (or batch). The mapping table in PaletteAction::target_msg_name documents the concrete target for every variant, ensuring no action is lost during migration.

§Filter Modes (F9 cycling)

PaletteMatchMode cycles through All → Exact → Prefix → WordStart → Substring → Fuzzy → All. Each mode trades recall for precision: All shows every action (useful for browsing), while Exact/Prefix are fast for users who know what they want. The Bayesian scorer in app.rs combines match-mode evidence with recency and frequency priors.

§Test Coverage

59 unit tests in this module cover: match mode cycling, action serialization round-trips, group membership exhaustiveness, and default_actions() stability. 12 regression tests in app.rs cover: lifecycle, dispatch coverage for all 28 action variants, boundary wrapping, rapid open/close, and selection clamping.

Structs§

PaletteItem
Render-ready descriptor for an action.
PaletteState

Enums§

AnalyticsTarget
Analytics sub-views addressable from the palette.
InputModeTarget
Input mode the palette can request.
PaletteAction
Action identifiers the palette can emit. These map to app-level commands.
PaletteGroup
Categorical grouping for palette actions. Used for section headers, icons, and migration validation.
PaletteMatchMode
Match-type filter mode for the command palette.
PaletteResult
Semantic result of executing a palette action. Decoupled from CassMsg so that palette.rs stays side-effect free and doesn’t depend on app.rs.
ScreenshotTarget
Screenshot export formats addressable from the palette.
TimeFilterPreset
Time filter presets the palette can apply.

Functions§

action_by_id
Find the PaletteAction whose action_id matches id.
action_id
Generate a stable string ID for a palette action.
default_actions
Prebuilt action catalog with keyboard shortcut hints from shortcuts.
execute_selected
Execute the currently selected palette action, returning a PaletteResult.