Skip to content

Action registry with auto-footer#88

Merged
meszmate merged 1 commit intomainfrom
feature/action-system
Apr 23, 2026
Merged

Action registry with auto-footer#88
meszmate merged 1 commit intomainfrom
feature/action-system

Conversation

@meszmate
Copy link
Copy Markdown
Owner

Summary

Centralizes app actions in a single registry (`ActionRegistry`) that becomes the single source of truth for keybindings, the command palette, help screen, and a new auto-rendered footer. Inspired by Textual's action system.

How it works

Each `Action` couples a stable string id (`"app.quit"`, `"file.save"`) to a label, description, category, optional `KeyEvent` binding, and optional handler callback. The user's `update` looks up the matching action by id and dispatches:

```zig
if (registry.matchKey(key_event)) |a| {
return self.dispatch(a.id);
}
```

The same registry can be filtered (`registry.filter(query)`) to feed a `CommandPalette`, and a `Footer` reads it to render a key hint bar that stays in sync as actions are enabled/disabled or rebound.

API surface

  • `Action` — id, label, description, category, binding, enabled, show_in_footer, handler
  • `ActionRegistry` — register, rebind, setEnabled, addAlias, get, matchKey, invoke, filter, formatKey
  • `Footer` — auto-rendered single-line bar of footer-flagged bindings
  • Aliases let multiple keys map to one action (eg. `f5` + `t` both toggle a view)

Why now

The codebase already has a `KeyMap` / `KeyBinding` pair and a `CommandPalette`. `ActionRegistry` unifies them: register once, the palette and footer pick the same data up automatically.

Test plan

  • `zig build test` — added 8 tests covering register/duplicate/lookup, key matching, alias matching, fuzzy filter ranking, footer flag respected, and key formatting

Centralize app actions in a single registry that feeds the keybinding
matcher, command palette, help screen, and a new auto-footer (one-line
key hint bar). Each Action couples a stable string id to a label,
description, category, optional KeyEvent binding, and optional handler
callback. Aliases let multiple keys map to one action.

Footer auto-renders the bindings flagged with show_in_footer = true,
so the hint bar stays in sync with the registry as actions are
enabled/disabled or rebound at runtime.
@meszmate meszmate merged commit 3020d52 into main Apr 23, 2026
9 checks passed
@meszmate meszmate deleted the feature/action-system branch April 24, 2026 13:38
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