139 lines
4.7 KiB
Python
139 lines
4.7 KiB
Python
"""Help screen for oAI TUI."""
|
|
|
|
from textual.app import ComposeResult
|
|
from textual.containers import Container, Vertical
|
|
from textual.screen import ModalScreen
|
|
from textual.widgets import Button, Static
|
|
|
|
|
|
class HelpScreen(ModalScreen[None]):
|
|
"""Modal screen displaying help and commands."""
|
|
|
|
DEFAULT_CSS = """
|
|
HelpScreen {
|
|
align: center middle;
|
|
}
|
|
|
|
HelpScreen > Container {
|
|
width: 90%;
|
|
height: 85%;
|
|
background: #1e1e1e;
|
|
border: solid #555555;
|
|
}
|
|
|
|
HelpScreen .header {
|
|
dock: top;
|
|
width: 100%;
|
|
height: auto;
|
|
background: #2d2d2d;
|
|
color: #cccccc;
|
|
padding: 0 2;
|
|
}
|
|
|
|
HelpScreen .content {
|
|
height: 1fr;
|
|
background: #1e1e1e;
|
|
padding: 2;
|
|
overflow-y: auto;
|
|
color: #cccccc;
|
|
}
|
|
|
|
HelpScreen .footer {
|
|
dock: bottom;
|
|
width: 100%;
|
|
height: auto;
|
|
background: #2d2d2d;
|
|
padding: 1 2;
|
|
align: center middle;
|
|
}
|
|
"""
|
|
|
|
def compose(self) -> ComposeResult:
|
|
"""Compose the screen."""
|
|
with Container():
|
|
yield Static("[bold]oAI Help & Commands[/]", classes="header")
|
|
with Vertical(classes="content"):
|
|
yield Static(self._get_help_text(), markup=True)
|
|
with Vertical(classes="footer"):
|
|
yield Button("Close", id="close", variant="primary")
|
|
|
|
def _get_help_text(self) -> str:
|
|
"""Generate the help text."""
|
|
return """
|
|
[bold cyan]═══ KEYBOARD SHORTCUTS ═══[/]
|
|
[bold]F1[/] Show this help (Ctrl+H may not work)
|
|
[bold]F2[/] Open model selector (Ctrl+M may not work)
|
|
[bold]Ctrl+S[/] Show session statistics
|
|
[bold]Ctrl+L[/] Clear chat display
|
|
[bold]Ctrl+P[/] Show previous message
|
|
[bold]Ctrl+N[/] Show next message
|
|
[bold]Ctrl+Q[/] Quit application
|
|
[bold]Up/Down[/] Navigate input history
|
|
[bold]ESC[/] Close dialogs
|
|
[dim]Note: Some Ctrl keys may be captured by your terminal[/]
|
|
|
|
[bold cyan]═══ SLASH COMMANDS ═══[/]
|
|
[bold yellow]Session Control:[/]
|
|
/reset Clear conversation history (with confirmation)
|
|
/clear Clear the chat display
|
|
/memory on/off Toggle conversation memory
|
|
/online on/off Toggle online search mode
|
|
/exit, /quit, /bye Exit the application
|
|
|
|
[bold yellow]Model & Configuration:[/]
|
|
/model [search] Open model selector with optional search
|
|
/config View configuration settings
|
|
/config api Set API key (prompts for input)
|
|
/config stream on Enable streaming responses
|
|
/system [prompt] Set session system prompt
|
|
/maxtoken [n] Set session token limit
|
|
|
|
[bold yellow]Conversation Management:[/]
|
|
/save [name] Save current conversation
|
|
/load [name] Load saved conversation (shows picker if no name)
|
|
/list List all saved conversations
|
|
/delete <name> Delete a saved conversation
|
|
|
|
[bold yellow]Export:[/]
|
|
/export md [file] Export as Markdown
|
|
/export json [file] Export as JSON
|
|
/export html [file] Export as HTML
|
|
|
|
[bold yellow]History Navigation:[/]
|
|
/prev Show previous message in history
|
|
/next Show next message in history
|
|
|
|
[bold yellow]MCP (Model Context Protocol):[/]
|
|
/mcp on Enable MCP file access
|
|
/mcp off Disable MCP
|
|
/mcp status Show MCP status
|
|
/mcp add <path> Add folder for file access
|
|
/mcp list List registered folders
|
|
/mcp write Toggle write permissions
|
|
|
|
[bold yellow]Information & Utilities:[/]
|
|
/help Show this help screen
|
|
/stats Show session statistics
|
|
/credits Check account credits
|
|
/retry Retry last prompt
|
|
/paste Paste from clipboard and send
|
|
|
|
[bold cyan]═══ TIPS ═══[/]
|
|
• Type [bold]/[/] to see command suggestions with [bold]Tab[/] to autocomplete
|
|
• Use [bold]Up/Down arrows[/] to navigate your input history
|
|
• Type [bold]//[/] at start to escape commands (sends /help as literal message)
|
|
• All messages support [bold]Markdown formatting[/] with syntax highlighting
|
|
• Responses stream in real-time for better interactivity
|
|
• Enable MCP to let AI access your local files and databases
|
|
• Use [bold]F1[/] or [bold]F2[/] if Ctrl shortcuts don't work in your terminal
|
|
"""
|
|
|
|
def on_button_pressed(self, event: Button.Pressed) -> None:
|
|
"""Handle button press."""
|
|
self.dismiss()
|
|
|
|
def on_key(self, event) -> None:
|
|
"""Handle keyboard shortcuts."""
|
|
if event.key in ("escape", "enter"):
|
|
self.dismiss()
|