Skip to content

Commit a918425

Browse files
committed
Add documentation for contextual help dialog
Assisted-By: docker-agent
1 parent 968b753 commit a918425

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

docs/HELP_DIALOG.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Contextual Help Dialog
2+
3+
## Overview
4+
5+
The cagent TUI now includes a contextual help dialog that displays all currently active key bindings. This makes it easy to discover available keyboard shortcuts without leaving the application.
6+
7+
## Usage
8+
9+
Press **Ctrl+?** (Ctrl+Shift+/) to open the help dialog.
10+
11+
The dialog will show all key bindings that are currently active based on:
12+
- Which panel is focused (content view vs editor)
13+
- Whether lean mode is enabled
14+
- Terminal capabilities (keyboard enhancements support)
15+
- Current UI state (history search active, etc.)
16+
17+
## Features
18+
19+
### Contextual Bindings
20+
The help dialog is **context-aware** - it shows only the key bindings that are valid for your current state:
21+
22+
- **When editor is focused**: Shows editor-specific bindings (Ctrl+g for external editor, Ctrl+r for history search, etc.)
23+
- **When content is focused**: Shows content view bindings (navigation, inline editing, etc.)
24+
- **Always visible**: Global bindings like Ctrl+c (quit), Tab (switch focus), Ctrl+k (commands)
25+
26+
### Automatic Categorization
27+
Key bindings are automatically grouped into three categories for easy scanning:
28+
29+
1. **General** - Common keys like Esc, Enter, Tab
30+
2. **Control Key Shortcuts** - All Ctrl+ combinations
31+
3. **Other** - Any remaining bindings
32+
33+
### Scrollable
34+
If there are more key bindings than fit on screen, the dialog is scrollable:
35+
- Use **↑/↓** arrow keys or **PgUp/PgDn** to scroll
36+
- Press **Esc** or **Enter** to close the dialog
37+
38+
## Implementation Details
39+
40+
The help dialog leverages the existing `Bindings()` method structure in the TUI, which already returns different key bindings based on context. This means:
41+
42+
- The help is always accurate and up-to-date
43+
- No manual maintenance of help text needed
44+
- Automatically adapts to new features and key bindings
45+
46+
### For Developers
47+
48+
To add new key bindings to the help:
49+
50+
1. Create your `key.Binding` with `.WithHelp()` to provide description
51+
2. Add it to the appropriate `Bindings()` method (app, component, or page level)
52+
3. It will automatically appear in the help dialog
53+
54+
Example:
55+
```go
56+
newFeatureKey := key.NewBinding(
57+
key.WithKeys("ctrl+f"),
58+
key.WithHelp("Ctrl+f", "new feature"),
59+
)
60+
```
61+
62+
The help dialog will pick this up automatically when it's included in any `Bindings()` return value.
63+
64+
## Related Files
65+
66+
- `pkg/tui/dialog/help.go` - Help dialog implementation
67+
- `pkg/tui/tui.go` - Key binding handler (Ctrl+? binding)
68+
- `pkg/tui/dialog/readonly_scroll_dialog.go` - Base dialog with scrolling support

0 commit comments

Comments
 (0)