trading_agent.terminal.widgets.command_menu
¶
The menu that opens above the message box when the user types a slash, as in Claude Code.
It lists the terminal program's own commands, then the desk's commands and skills, keeping those whose names start with what was typed. After an @ it lists files and folders instead, for attaching a file. Each name appears once, with the usage and description of its first entry.
Typical usage example:
menu = CommandMenu() menu.set_entries(entries) menu.filter('/st') menu.highlighted_name() # '/status'
CommandMenu
¶
Bases: OptionList
The command menu; hidden while nothing matches.
Creates the menu, hidden and empty.
Source code in src/trading_agent/terminal/widgets/command_menu.py
on_mount
¶
set_entries
¶
Replaces the commands the menu offers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entries
|
list[dict[str, Any]]
|
The entries, each with name, usage and description, in the order to show them. |
required |
Source code in src/trading_agent/terminal/widgets/command_menu.py
show_paths
¶
Shows file paths for an @ word.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
list[str]
|
The paths, as they would be typed after @. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True when the menu is showing. |
Source code in src/trading_agent/terminal/widgets/command_menu.py
filter
¶
Shows the commands whose names start with the draft.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
draft
|
str
|
What is in the message box. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True when the menu is showing. |
Source code in src/trading_agent/terminal/widgets/command_menu.py
move
¶
Moves the highlight, wrapping at the ends.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
int
|
-1 for up, 1 for down. |
required |
Source code in src/trading_agent/terminal/widgets/command_menu.py
highlighted_name
¶
The highlighted command's name.
Returns:
| Type | Description |
|---|---|
str | None
|
Such as "/status", or None when the menu is empty. |