Skip to content

TUI Stage 4.5b: Actions / Intents / Shortcuts - #37

Merged
xvrh merged 13 commits into
masterfrom
claude/brave-mirzakhani-6fc740
May 17, 2026
Merged

TUI Stage 4.5b: Actions / Intents / Shortcuts#37
xvrh merged 13 commits into
masterfrom
claude/brave-mirzakhani-6fc740

Conversation

@xvrh

@xvrh xvrh commented May 17, 2026

Copy link
Copy Markdown
Owner

Summary

Adds the declarative key-binding layer to the TUI framework (app/lib/src/tui/) — the second half of the interactivity stage, building on the Stage 4.5a focus system.

  • actions.dartIntent, Action<T>, and the Actions widget (chained Type → Action lookup), plus the standard ActivateIntent / DismissIntent.
  • shortcuts.dartShortcutMap (Map<KeyEvent, Intent>), ShortcutManager, the Shortcuts widget, and defaultShortcuts().
  • Traversal intents/actions added to focus_traversal.dart (NextFocusIntent/PreviousFocusIntent/DirectionalFocusIntent + actions).
  • Migrated the 4.5a fallbackFocusManager._handleTraversalKey (and _directional/_policyFor/defaultTraversalPolicy) deleted. The default key bindings (Tab/arrows → traversal, Enter → Activate, Escape → Dismiss) are now installed on rootScope.onKeyEvent via a root ShortcutManager, wired by attachRootWidget. rootScope is the last node in every dispatch chain, so traversal still works even when nothing is focused.
  • shortcuts_demo.dart — a 2×2 grid exercising default traversal, per-panel Enter-to-activate counters, a local Shortcuts override, and Escape-to-quit.

Design: full transcription of Flutter's Actions/Intents/Shortcuts, trimmed for the TUI (no ActionDispatcher, no ContextAction, no ShortcutActivatorKeyEvent's value equality lets a plain map serve as the shortcut map). See the design spec and plan.

Note: a latent bug in FocusTraversalPolicy._move was fixed along the way — next()/previous() from a scope node with a single traversable descendant previously returned false; it now focuses that descendant. This is what makes Tab-from-nothing-focused work.

Test Plan

  • flutter analyze clean
  • cd app && flutter test — all 381 tests pass
  • dart tool/prepare_submit.dart produces no diff
  • New suites: actions_test.dart, shortcuts_test.dart, traversal-action additions to focus_traversal_test.dart
  • Manual smoke: cd app && dart run examples/tui/shortcuts_demo.dart in a real terminal — Tab/arrows traverse, Enter/+ increment counters, Esc/q quit

🤖 Generated with Claude Code

xvrh and others added 13 commits May 17, 2026 11:59
The declarative key-binding layer — Intent/Action/Actions and
Shortcuts/ShortcutManager — plus migration of the 4.5a built-in
traversal fallback onto default shortcuts wired to rootScope.onKeyEvent.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Eight TDD tasks: actions.dart, shortcuts.dart, traversal intents/actions,
the Shortcuts widget + default map, rootScope wiring, fallback deletion,
demo, and docs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rage

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds rootShortcutManager to TuiBinding, wired onto
FocusManager.rootScope.onKeyEvent in attachRootWidget, so Tab/arrows/Enter/Escape
route through defaultShortcuts()/defaultTraversalActions() out of the box.
Also fixes FocusTraversalPolicy._move to focus the first/last node when the
current primary focus is a scope node not itself in the traversal list.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Update roadmap and TUI README to record Stage 4.5b (Actions/Intents/Shortcuts)
as complete, add its spec/plan links, and replace the deferred-limitation bullet
with the accurate done state.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…sAction direction

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@xvrh
xvrh merged commit 70fc2fd into master May 17, 2026
1 check passed
@xvrh
xvrh deleted the claude/brave-mirzakhani-6fc740 branch May 17, 2026 19:43
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