Documentation
¶
Index ¶
- func HandlePasteEvent(app KeyHandlerContext, pastedText string) tea.Cmd
- func IsValidKey(key string) bool
- func NewHintFormatterFromRegistry(registry *Registry) *hints.Formatter
- type ContextCondition
- type HelpShortcut
- type ImageOptimizer
- type KeyAction
- type KeyBindingManager
- func (m *KeyBindingManager) GetHelpShortcuts() []HelpShortcut
- func (m *KeyBindingManager) GetHintFormatter() *hints.Formatter
- func (m *KeyBindingManager) GetRegistry() *Registry
- func (m *KeyBindingManager) IsKeyHandledByAction(keyMsg tea.KeyPressMsg) bool
- func (m *KeyBindingManager) ProcessKey(keyMsg tea.KeyPressMsg) tea.Cmd
- func (m *KeyBindingManager) ShouldSkipInputUpdate(keyMsg tea.KeyPressMsg) bool
- type KeyContext
- type KeyHandler
- type KeyHandlerContext
- type OptimizeResult
- type Registry
- func (r *Registry) GetAction(id string) *KeyAction
- func (r *Registry) GetActiveActions(app KeyHandlerContext) []*KeyAction
- func (r *Registry) GetHelpShortcuts(app KeyHandlerContext) []HelpShortcut
- func (r *Registry) GetSequenceActionForPrefix(prefix string, app KeyHandlerContext) *KeyAction
- func (r *Registry) HasSequenceWithPrefix(prefix string, app KeyHandlerContext) bool
- func (r *Registry) KnownActionIDs() []string
- func (r *Registry) ListAllActions() []*KeyAction
- func (r *Registry) Register(action *KeyAction) error
- func (r *Registry) Resolve(msg tea.KeyPressMsg, app KeyHandlerContext) *KeyAction
- func (r *Registry) ResolveKey(keyStr string, app KeyHandlerContext) *KeyAction
- type StateManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandlePasteEvent ¶
func HandlePasteEvent(app KeyHandlerContext, pastedText string) tea.Cmd
HandlePasteEvent handles when the terminal sends clipboard content directly
func IsValidKey ¶
IsValidKey checks if a key string is a known/valid key This is exposed for use in validation commands
func NewHintFormatterFromRegistry ¶
NewHintFormatterFromRegistry creates a hints.Formatter from a keybinding Registry
Types ¶
type ContextCondition ¶
type ContextCondition struct {
Name string
Check func(app KeyHandlerContext) bool
}
ContextCondition represents a condition that must be met for key binding to be active
type HelpShortcut ¶
HelpShortcut represents a key shortcut for help display
type ImageOptimizer ¶
type ImageOptimizer struct {
// contains filtered or unexported fields
}
ImageOptimizer handles image optimization for clipboard images
func NewImageOptimizer ¶
func NewImageOptimizer(cfg config.ClipboardImageOptimizeConfig) *ImageOptimizer
NewImageOptimizer creates a new image optimizer with the given configuration
func (*ImageOptimizer) OptimizeImage ¶
func (o *ImageOptimizer) OptimizeImage(imagePath string) (*OptimizeResult, error)
OptimizeImage optimizes an image file according to configuration Returns the optimized image data, extension, and any error encountered
type KeyAction ¶
type KeyAction struct {
ID string
Category string
Binding key.Binding
Handler KeyHandler
Context KeyContext
}
KeyAction represents a key binding action. Keys, description, and enabled state live in the Binding, which is constructed at registry init from the resolved keybindings config (defaults + keybindings.yaml overrides) — the single source of truth shared by dispatch and help rendering.
type KeyBindingManager ¶
type KeyBindingManager struct {
// contains filtered or unexported fields
}
KeyBindingManager manages the key binding system for ChatApplication
func NewKeyBindingManager ¶
func NewKeyBindingManager(app KeyHandlerContext, cfg *config.Config) *KeyBindingManager
NewKeyBindingManager creates a new key binding manager
func (*KeyBindingManager) GetHelpShortcuts ¶
func (m *KeyBindingManager) GetHelpShortcuts() []HelpShortcut
GetHelpShortcuts returns help shortcuts for the current context
func (*KeyBindingManager) GetHintFormatter ¶
func (m *KeyBindingManager) GetHintFormatter() *hints.Formatter
GetHintFormatter returns a hint formatter for displaying keybinding hints in UI
func (*KeyBindingManager) GetRegistry ¶
func (m *KeyBindingManager) GetRegistry() *Registry
GetRegistry returns the underlying registry (for advanced usage)
func (*KeyBindingManager) IsKeyHandledByAction ¶
func (m *KeyBindingManager) IsKeyHandledByAction(keyMsg tea.KeyPressMsg) bool
IsKeyHandledByAction returns true if the key would be handled by a keybinding action
func (*KeyBindingManager) ProcessKey ¶
func (m *KeyBindingManager) ProcessKey(keyMsg tea.KeyPressMsg) tea.Cmd
ProcessKey handles key input and executes the appropriate action
func (*KeyBindingManager) ShouldSkipInputUpdate ¶
func (m *KeyBindingManager) ShouldSkipInputUpdate(keyMsg tea.KeyPressMsg) bool
ShouldSkipInputUpdate reports whether a keybinding action fully consumed the key. Textarea-owned editing actions still pass through to InputView.Update.
type KeyContext ¶
type KeyContext struct {
Views []tui.ViewState
Conditions []ContextCondition
ExcludeViews []tui.ViewState
}
KeyContext defines when and where a key binding is active
type KeyHandler ¶
type KeyHandler func(app KeyHandlerContext, keyMsg tea.KeyPressMsg) tea.Cmd
KeyHandler represents a function that handles a key binding
type KeyHandlerContext ¶
type KeyHandlerContext interface {
// State management
GetStateManager() StateManager
GetConversationRepository() convdomain.ConversationRepository
GetConfig() *config.Config
GetConfigDir() string
// Services
GetAgentService() agentdomain.AgentService
GetImageService() agentdomain.ImageService
// UI components
GetConversationView() tui.ConversationRenderer
GetInputView() tui.InputComponent
GetStatusView() tui.StatusComponent
GetAutocomplete() tui.AutocompleteComponent
// Actions
ToggleToolResultExpansion()
ToggleThinkingExpansion()
ToggleRawFormat()
SendMessage() tea.Cmd
GetPageSize() int
// Mouse mode
GetMouseEnabled() bool
SetMouseEnabled(bool)
}
KeyHandlerContext provides access to application context for key handlers
type OptimizeResult ¶
OptimizeResult contains the optimized image data and format information
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds all key binding actions and resolves key presses against their bubbles/key Bindings. View-scoped actions win over global ones; within a scope, registration order breaks ties.
func NewRegistry ¶
NewRegistry creates a registry whose action Bindings are resolved from the keybindings config: built-in defaults merged with any keybindings.yaml overrides. Dispatch and help both read these same Bindings.
func (*Registry) GetActiveActions ¶
func (r *Registry) GetActiveActions(app KeyHandlerContext) []*KeyAction
GetActiveActions returns all currently active actions
func (*Registry) GetHelpShortcuts ¶
func (r *Registry) GetHelpShortcuts(app KeyHandlerContext) []HelpShortcut
GetHelpShortcuts generates help shortcuts for current context
func (*Registry) GetSequenceActionForPrefix ¶
func (r *Registry) GetSequenceActionForPrefix(prefix string, app KeyHandlerContext) *KeyAction
GetSequenceActionForPrefix returns the action that matches a sequence starting with the given prefix
func (*Registry) HasSequenceWithPrefix ¶
func (r *Registry) HasSequenceWithPrefix(prefix string, app KeyHandlerContext) bool
HasSequenceWithPrefix checks if any registered action has a key sequence that starts with the given prefix
func (*Registry) KnownActionIDs ¶
KnownActionIDs returns every action ID the application recognises: the runtime registry actions unioned with the default keybindings config IDs (which include the namespace-path actions consumed directly via config.ResolveNamespaceBindings). The CLI validator shares this notion of "valid" so they agree on what is a genuine typo.
func (*Registry) ListAllActions ¶
ListAllActions returns all registered actions for debugging/management
func (*Registry) Register ¶
Register adds a key binding action to the registry. Multiple actions can share the same key - view context resolves conflicts.
func (*Registry) Resolve ¶
func (r *Registry) Resolve(msg tea.KeyPressMsg, app KeyHandlerContext) *KeyAction
Resolve finds the action bound to a pressed key via key.Matches. View-scoped actions are consulted before global ones, mirroring the old layer priorities.
func (*Registry) ResolveKey ¶
func (r *Registry) ResolveKey(keyStr string, app KeyHandlerContext) *KeyAction
ResolveKey resolves a raw key string, used for comma-joined sequences ("esc,esc") that never arrive as a single tea.KeyPressMsg — bubbles/key has no chord support, so sequences stay string-matched.
type StateManager ¶
type StateManager interface {
tui.ViewManager
agentdomain.AgentModeManager
agentdomain.ChatSessionManager
agentdomain.ToolExecutionManager
agentdomain.ApprovalUIManager
agentdomain.PlanApprovalUIManager
agentdomain.UserQuestionUIManager
IsEditingMessage() bool
ClearMessageEditState()
}
StateManager is the narrow slice of the application state manager that key handlers need. *statemanager.StateManager satisfies it.