tui

package
v0.32.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxVisibleCommands is the maximum number of commands shown in the palette.
	MaxVisibleCommands = 12
	// CommandPaletteWidth is the content width of the command palette modal.
	CommandPaletteWidth = 90
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action = action.Action

Action is an alias for the unified action type.

type BuildInfo added in v0.32.0

type BuildInfo struct {
	Version string
	Commit  string
	Date    string
}

BuildInfo holds build-time metadata for display in the TUI.

type CommandEntry

type CommandEntry struct {
	Name    string
	Command config.UserCommand
}

CommandEntry represents an item in the command palette.

type CommandPalette

type CommandPalette struct {
	// contains filtered or unexported fields
}

CommandPalette is a vim-style command palette for user commands.

func NewCommandPalette

func NewCommandPalette(cmds map[string]config.UserCommand, sess *session.Session, width, height int, activeView ViewType) *CommandPalette

NewCommandPalette creates a new command palette with the given commands. Commands are filtered by scope - only commands active in the current view are shown.

func (*CommandPalette) Cancelled

func (p *CommandPalette) Cancelled() bool

Cancelled returns true if the user cancelled the palette.

func (*CommandPalette) IsFiltering

func (p *CommandPalette) IsFiltering() bool

IsFiltering returns whether the palette is currently filtering. Always true for the new text input-based palette.

func (*CommandPalette) KeyMap

func (p *CommandPalette) KeyMap() []key.Binding

KeyMap returns keys that the command palette uses (for help integration).

func (*CommandPalette) Overlay

func (p *CommandPalette) Overlay(background string, width, height int) string

Overlay renders the command palette as a layer over the given background.

func (*CommandPalette) SelectedCommand

func (p *CommandPalette) SelectedCommand() (*CommandEntry, []string, bool)

SelectedCommand returns the selected command entry and parsed args, if any.

func (*CommandPalette) Session

func (p *CommandPalette) Session() *session.Session

Session returns the session context for template rendering.

func (*CommandPalette) Update

func (p *CommandPalette) Update(msg tea.Msg) (*CommandPalette, tea.Cmd)

Update handles messages for the command palette.

func (*CommandPalette) View

func (p *CommandPalette) View() string

View renders the command palette.

type Deps added in v0.32.0

type Deps struct {
	// Required — nil causes a panic at construction time.
	Config          *config.Config
	Service         *hive.SessionService
	Renderer        *tmpl.Renderer
	TerminalManager *terminal.Manager
	PluginManager   *plugins.Manager

	// Optional — nil disables the corresponding feature.
	MsgStore      *hive.MessageService
	Bus           *eventbus.EventBus
	DB            *db.DB
	KVStore       corekv.KV
	BuildInfo     BuildInfo
	DoctorService *hive.DoctorService
}

Deps holds all external dependencies for the TUI Model.

type HiveDocReviewCmd

type HiveDocReviewCmd struct {
	Arg string // Optional document path argument
}

HiveDocReviewCmd activates the review tab with optional document selection.

func (HiveDocReviewCmd) Execute

func (c HiveDocReviewCmd) Execute(m *Model) tea.Cmd

Execute shows document picker on current view, then switches to review when document selected. When invoked without an argument, it scopes to the selected session's repository context.

type KVView

type KVView struct {
	// contains filtered or unexported fields
}

KVView is a two-column KV browser: searchable key list (left) + colorized JSON preview (right).

func NewKVView

func NewKVView() *KVView

NewKVView creates a new KV browser view.

func (*KVView) AddFilterRune

func (v *KVView) AddFilterRune(r rune)

AddFilterRune adds a character to the filter.

func (*KVView) CancelFilter

func (v *KVView) CancelFilter()

CancelFilter clears the filter and exits filtering mode.

func (*KVView) ConfirmFilter

func (v *KVView) ConfirmFilter()

ConfirmFilter exits filtering mode, keeping the filter active.

func (*KVView) DeleteFilterRune

func (v *KVView) DeleteFilterRune()

DeleteFilterRune removes the last character from the filter.

func (*KVView) IsFiltering

func (v *KVView) IsFiltering() bool

IsFiltering returns whether the view is in filter mode.

func (*KVView) MoveDown

func (v *KVView) MoveDown()

MoveDown moves the cursor down in the key list.

func (*KVView) MoveUp

func (v *KVView) MoveUp()

MoveUp moves the cursor up in the key list.

func (*KVView) ScrollPreviewDown

func (v *KVView) ScrollPreviewDown()

ScrollPreviewDown scrolls the JSON preview down.

func (*KVView) ScrollPreviewUp

func (v *KVView) ScrollPreviewUp()

ScrollPreviewUp scrolls the JSON preview up.

func (*KVView) SelectedKey

func (v *KVView) SelectedKey() string

SelectedKey returns the currently selected key, or empty if none.

func (*KVView) SetKeys

func (v *KVView) SetKeys(keys []string)

SetKeys updates the key list and reapplies the filter.

func (*KVView) SetPreview

func (v *KVView) SetPreview(entry *kv.Entry)

SetPreview sets the preview entry for the selected key.

func (*KVView) SetSize

func (v *KVView) SetSize(width, height int)

SetSize sets the viewport dimensions.

func (*KVView) StartFilter

func (v *KVView) StartFilter()

StartFilter begins filtering mode.

func (*KVView) View

func (v *KVView) View() string

View renders the two-column layout.

type KeybindingResolver

type KeybindingResolver struct {
	// contains filtered or unexported fields
}

KeybindingResolver resolves keybindings to actions via UserCommands. It handles resolution only - execution is handled by the command.Service.

func NewKeybindingResolver

func NewKeybindingResolver(keybindings map[string]config.Keybinding, commands map[string]config.UserCommand, renderer *tmpl.Renderer) *KeybindingResolver

NewKeybindingResolver creates a new resolver with the given config. Commands should be the merged user commands (user config + system defaults).

func (*KeybindingResolver) HelpEntries

func (h *KeybindingResolver) HelpEntries() []string

HelpEntries returns all configured keybindings for display, sorted by key. Only returns keybindings that are in scope for the current view.

func (*KeybindingResolver) HelpString

func (h *KeybindingResolver) HelpString() string

HelpString returns a formatted help string for all keybindings.

func (*KeybindingResolver) IsAction

func (h *KeybindingResolver) IsAction(key string, t action.Type) bool

IsAction checks if a key maps to the given built-in action.

func (*KeybindingResolver) IsCommand

func (h *KeybindingResolver) IsCommand(key string, cmdName string) bool

IsCommand checks if a key maps to the given command name.

func (*KeybindingResolver) KeyBindings

func (h *KeybindingResolver) KeyBindings() []key.Binding

KeyBindings returns key.Binding objects for integration with bubbles help system. Only returns keybindings that are in scope for the current view.

func (*KeybindingResolver) RenderWithFormData

func (h *KeybindingResolver) RenderWithFormData(
	name string,
	cmd config.UserCommand,
	sess session.Session,
	args []string,
	formData map[string]any,
) Action

RenderWithFormData resolves a user command with form data injected into the template context under the .Form namespace.

func (*KeybindingResolver) Resolve

func (h *KeybindingResolver) Resolve(key string, sess session.Session) (Action, bool)

Resolve attempts to resolve a key press to an action for the given session. Recycled sessions only allow delete actions to prevent accidental operations.

func (*KeybindingResolver) ResolveFormCommand

func (h *KeybindingResolver) ResolveFormCommand(key string, sess session.Session) (string, config.UserCommand, bool)

ResolveFormCommand checks if a key maps to a user command with form fields. Returns the command name and command if found, after scope and recycle checks.

func (*KeybindingResolver) ResolveUserCommand

func (h *KeybindingResolver) ResolveUserCommand(name string, cmd config.UserCommand, sess session.Session, args []string) Action

ResolveUserCommand converts a user command to an Action ready for execution. The name is used to display the command source (e.g., ":review"). Supports both action-based commands (recycle, delete) and shell commands.

func (*KeybindingResolver) SetActiveView

func (h *KeybindingResolver) SetActiveView(view ViewType)

SetActiveView updates the current active view for scope checking.

func (*KeybindingResolver) SetSelectedWindow

func (h *KeybindingResolver) SetSelectedWindow(windowName string)

SetSelectedWindow overrides the TmuxWindow template value for the next resolve call. The override is consumed (cleared) after each Resolve or ResolveUserCommand call. Pass empty string to clear the override and fall back to the lookup function.

func (*KeybindingResolver) SetTmuxWindowLookup

func (h *KeybindingResolver) SetTmuxWindowLookup(fn func(sessionID string) string)

SetTmuxWindowLookup sets a function that resolves tmux window names for sessions. This enables the TmuxWindow field in shell command templates.

func (*KeybindingResolver) SetToolLookup

func (h *KeybindingResolver) SetToolLookup(fn func(sessionID string) string)

SetToolLookup sets a function that resolves tool names for sessions.

type Modal struct {
	// contains filtered or unexported fields
}

Modal represents a confirmation dialog.

func NewModal

func NewModal(title, message string) Modal

NewModal creates a new modal with the given title and message.

func (Modal) ConfirmSelected

func (m Modal) ConfirmSelected() bool

ConfirmSelected returns true if the confirm button is selected.

func (Modal) Overlay

func (m Modal) Overlay(background string, width, height int) string

Overlay renders the modal as a layer over the given background content.

func (*Modal) ToggleSelection

func (m *Modal) ToggleSelection()

ToggleSelection switches the selected button.

func (Modal) Visible

func (m Modal) Visible() bool

Visible returns whether the modal should be displayed.

type ModalCoordinator added in v0.32.0

type ModalCoordinator struct {
	// Modal components
	Confirm         Modal
	Output          OutputModal
	NewSession      *NewSessionForm
	CommandPalette  *CommandPalette
	Help            *components.HelpDialog
	Notification    *NotificationModal
	InfoDialog      *components.InfoDialog
	FormDialog      *form.Dialog
	DocPicker       *review.DocumentPickerModal
	RenameInput     textinput.Model
	RenameSessionID string

	// Pending action state
	Pending                 Action
	PendingCreate           *PendingCreate
	PendingRecycledSessions []session.Session
	PendingFormCmd          config.UserCommand
	PendingFormName         string
	PendingFormSess         *session.Session
	PendingFormArgs         []string

	// Recycle streaming
	RecycleOutput <-chan string
	RecycleDone   <-chan error
	RecycleCancel context.CancelFunc
	// contains filtered or unexported fields
}

ModalCoordinator owns all modal component references, pending action state, recycle streaming state, and provides overlay rendering plus lifecycle methods.

func NewModalCoordinator added in v0.32.0

func NewModalCoordinator() *ModalCoordinator

NewModalCoordinator creates a new ModalCoordinator with default state.

func (*ModalCoordinator) ClearFormState added in v0.32.0

func (mc *ModalCoordinator) ClearFormState()

ClearFormState resets all form dialog state.

func (*ModalCoordinator) DismissConfirm added in v0.32.0

func (mc *ModalCoordinator) DismissConfirm()

DismissConfirm resets the confirm modal to zero value.

func (*ModalCoordinator) DismissHelp added in v0.32.0

func (mc *ModalCoordinator) DismissHelp()

DismissHelp closes the help dialog.

func (*ModalCoordinator) DismissInfo added in v0.32.0

func (mc *ModalCoordinator) DismissInfo()

DismissInfo closes the info dialog.

func (*ModalCoordinator) DismissNotifications added in v0.32.0

func (mc *ModalCoordinator) DismissNotifications()

DismissNotifications closes the notification modal.

func (*ModalCoordinator) HasEditorFocus added in v0.32.0

func (mc *ModalCoordinator) HasEditorFocus(state UIState) bool

HasEditorFocus returns true if a modal with text input is active.

func (*ModalCoordinator) Overlay added in v0.32.0

func (mc *ModalCoordinator) Overlay(state UIState, bg string, s spinner.Model, loadingMsg string) string

Overlay renders the appropriate modal overlay based on the current UI state. It returns the background string unchanged if no modal is active.

func (*ModalCoordinator) SetSize added in v0.32.0

func (mc *ModalCoordinator) SetSize(w, h int)

SetSize updates the available dimensions for modal rendering.

func (*ModalCoordinator) ShowConfirm added in v0.32.0

func (mc *ModalCoordinator) ShowConfirm(title, message string)

ShowConfirm creates and displays the confirmation modal.

func (*ModalCoordinator) ShowHelp added in v0.32.0

func (mc *ModalCoordinator) ShowHelp(title string, sections []components.HelpDialogSection)

ShowHelp creates and displays the help dialog.

func (*ModalCoordinator) ShowInfo added in v0.32.0

func (mc *ModalCoordinator) ShowInfo(title string, sections []components.InfoSection, footer, helpText string)

ShowInfo creates and displays the info dialog.

func (*ModalCoordinator) ShowNotifications added in v0.32.0

func (mc *ModalCoordinator) ShowNotifications(bus *tuinotify.Bus)

ShowNotifications creates and displays the notification modal.

func (*ModalCoordinator) ShowOutputModal added in v0.32.0

func (mc *ModalCoordinator) ShowOutputModal(title string)

ShowOutputModal creates and displays the output modal.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the main Bubble Tea model for the TUI.

func New

func New(deps Deps, opts Opts) Model

New creates a new TUI model. Panics if required Deps fields are nil.

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the model.

func (Model) PendingCreate

func (m Model) PendingCreate() *PendingCreate

PendingCreate returns any pending session creation data.

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages.

func (Model) View

func (m Model) View() tea.View

View renders the TUI.

type NewSessionForm

type NewSessionForm struct {
	// contains filtered or unexported fields
}

NewSessionForm manages the new session creation form.

func NewNewSessionForm

func NewNewSessionForm(repos []sessions.DiscoveredRepo, preselectedRemote string, existingNames map[string]bool) *NewSessionForm

NewNewSessionForm creates a new session form with the given repos. If preselectedRemote is non-empty, the matching repo will be pre-selected. existingNames is used to validate that the session name is unique.

func (*NewSessionForm) Cancelled

func (f *NewSessionForm) Cancelled() bool

Cancelled returns true if the form was cancelled.

func (*NewSessionForm) Init

func (f *NewSessionForm) Init() tea.Cmd

Init returns the initial command for the form.

func (*NewSessionForm) Result

Result returns the form result. Only valid if Submitted() is true. Returns zero value if repos slice is empty (should not happen in normal use).

func (*NewSessionForm) Submitted

func (f *NewSessionForm) Submitted() bool

Submitted returns true if the form was submitted.

func (*NewSessionForm) Update

func (f *NewSessionForm) Update(msg tea.Msg) (NewSessionForm, tea.Cmd)

Update handles messages for the form.

func (*NewSessionForm) View

func (f *NewSessionForm) View() string

View renders the form.

type NewSessionFormResult

type NewSessionFormResult struct {
	Repo        sessions.DiscoveredRepo
	SessionName string
}

NewSessionFormResult contains the form submission result.

type NotificationModal

type NotificationModal struct {
	// contains filtered or unexported fields
}

NotificationModal displays a scrollable history of notifications.

func NewNotificationModal

func NewNotificationModal(bus *tuinotify.Bus, width, height int) *NotificationModal

NewNotificationModal creates a modal showing notification history.

func (*NotificationModal) Clear

func (m *NotificationModal) Clear() error

Clear deletes all notifications and refreshes the view.

func (*NotificationModal) Overlay

func (m *NotificationModal) Overlay(background string, width, height int) string

Overlay renders the notification modal centered over the background.

func (*NotificationModal) ScrollDown

func (m *NotificationModal) ScrollDown()

ScrollDown scrolls the viewport down.

func (*NotificationModal) ScrollUp

func (m *NotificationModal) ScrollUp()

ScrollUp scrolls the viewport up.

type Opts added in v0.32.0

type Opts struct {
	LocalRemote string
	Warnings    []string
	ConfigPath  string
}

Opts holds runtime options that are not service dependencies.

type OutputModal

type OutputModal struct {
	// contains filtered or unexported fields
}

OutputModal displays streaming command output in a modal dialog.

func NewOutputModal

func NewOutputModal(title string) OutputModal

NewOutputModal creates a new output modal with the given title.

func (*OutputModal) AddLine

func (m *OutputModal) AddLine(line string)

AddLine appends a line of output to the modal.

func (*OutputModal) IsRunning

func (m *OutputModal) IsRunning() bool

IsRunning returns true if the command is still running.

func (OutputModal) Overlay

func (m OutputModal) Overlay(background string, width, height int) string

Overlay renders the output modal centered over the background.

func (*OutputModal) SetComplete

func (m *OutputModal) SetComplete(err error)

SetComplete marks the modal as complete with optional error.

func (*OutputModal) SetSpinner

func (m *OutputModal) SetSpinner(s spinner.Model)

SetSpinner updates the spinner model.

func (*OutputModal) Spinner

func (m *OutputModal) Spinner() spinner.Model

Spinner returns the spinner model for tick updates.

type ParsedCommand

type ParsedCommand struct {
	Name string
	Args []string
}

ParsedCommand represents a parsed command input.

func ParseCommandInput

func ParseCommandInput(input string) ParsedCommand

ParseCommandInput parses a command string like ":command arg1 arg2" into name and args. The input should start with ':' but it's optional. Arguments are split by whitespace.

type PendingCreate

type PendingCreate struct {
	Remote string
	Name   string
}

PendingCreate holds data for a session to create after TUI exits.

type ReviewOnlyModel

type ReviewOnlyModel struct {
	// contains filtered or unexported fields
}

ReviewOnlyModel is a minimal TUI for reviewing context documents.

func NewReviewOnly

func NewReviewOnly(opts ReviewOnlyOptions) ReviewOnlyModel

NewReviewOnly creates a new review-only TUI model.

func (ReviewOnlyModel) Init

func (m ReviewOnlyModel) Init() tea.Cmd

Init implements tea.Model.

func (ReviewOnlyModel) Update

func (m ReviewOnlyModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model.

func (ReviewOnlyModel) View

func (m ReviewOnlyModel) View() tea.View

View implements tea.Model.

type ReviewOnlyOptions

type ReviewOnlyOptions struct {
	Documents        []review.Document
	InitialDoc       *review.Document
	ContextDir       string // Directory for saving feedback files (e.g., context directory)
	DB               *db.DB
	CommentLineWidth int
	CopyCommand      string // Shell command for copying to clipboard (e.g., "pbcopy" on macOS)
}

ReviewOnlyOptions configures the review-only TUI.

type SelectField

type SelectField struct {
	// contains filtered or unexported fields
}

SelectField is a select input component wrapping list.Model.

func NewSelectField

func NewSelectField(title string, items []SelectItem, selected int) SelectField

NewSelectField creates a new select field with the given items. selected is the index to pre-select (-1 for none).

func (*SelectField) Blur

func (s *SelectField) Blur()

Blur removes focus from the select field.

func (*SelectField) Focus

func (s *SelectField) Focus() tea.Cmd

Focus sets focus state on the select field.

func (*SelectField) Focused

func (s *SelectField) Focused() bool

Focused returns whether the field is focused.

func (*SelectField) IsFiltering

func (s *SelectField) IsFiltering() bool

IsFiltering returns whether the list is currently filtering.

func (*SelectField) KeyMap

func (s *SelectField) KeyMap() []key.Binding

KeyMap returns keys that the select field uses (for help integration).

func (*SelectField) SelectedIndex

func (s *SelectField) SelectedIndex() int

SelectedIndex returns the index of the selected item.

func (*SelectField) SetSize

func (s *SelectField) SetSize(width, height int)

SetSize sets the dimensions of the select field.

func (SelectField) Update

func (s SelectField) Update(msg tea.Msg) (SelectField, tea.Cmd)

Update handles messages for the select field.

func (SelectField) View

func (s SelectField) View() string

View renders the select field.

type SelectItem

type SelectItem struct {
	// contains filtered or unexported fields
}

SelectItem represents an item in a SelectField.

func (SelectItem) FilterValue

func (i SelectItem) FilterValue() string

FilterValue implements list.Item.

type ToastController

type ToastController struct {
	// contains filtered or unexported fields
}

ToastController manages the lifecycle of active toast notifications. It handles push, eviction, TTL countdown, and dismissal.

func NewToastController

func NewToastController() *ToastController

func (*ToastController) Dismiss

func (c *ToastController) Dismiss()

Dismiss removes the newest (bottom-most) toast.

func (*ToastController) DismissAll

func (c *ToastController) DismissAll()

DismissAll removes all active toasts.

func (*ToastController) HasToasts

func (c *ToastController) HasToasts() bool

HasToasts returns true if there are any active toasts.

func (*ToastController) Push

func (c *ToastController) Push(n notify.Notification)

Push adds a notification to the toast stack. If the stack exceeds defaultMaxToasts, the oldest toast is evicted.

func (*ToastController) Tick

func (c *ToastController) Tick()

Tick removes any toasts whose expiration time has passed.

func (*ToastController) Toasts

func (c *ToastController) Toasts() []toast

Toasts returns the current active toast slice.

type ToastView

type ToastView struct {
	// contains filtered or unexported fields
}

ToastView renders toast notifications and composites them as an overlay.

func NewToastView

func NewToastView(controller *ToastController) *ToastView

func (*ToastView) Overlay

func (v *ToastView) Overlay(background string, width, height int) string

Overlay composites the toast stack over background in the lower-right corner.

func (*ToastView) View

func (v *ToastView) View() string

View renders the toast stack as a single string with toasts stacked vertically (oldest at top, newest at bottom).

type UIState

type UIState int

UIState represents the current state of the TUI.

type ViewType

type ViewType int

ViewType represents which view is active.

const (
	ViewSessions ViewType = iota
	ViewMessages
	ViewReview
	ViewStore
)

func (ViewType) String

func (v ViewType) String() string

String returns the lowercase name of the view type for scope matching.

Directories

Path Synopsis
Package components provides reusable TUI components.
Package components provides reusable TUI components.
views
review
Package review implements a TUI for reviewing and commenting on markdown documents.
Package review implements a TUI for reviewing and commenting on markdown documents.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL