interactive

package
v8.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package interactive houses interactive UI types and helpers shared across the application.

Package interactive houses interactive UI types and helpers shared across the application.

Package interactive houses interactive UI types and helpers shared across the application.

Package interactive houses interactive UI types and helpers shared across the application.

Package interactive houses interactive UI types and helpers shared across the application.

Package interactive houses interactive UI types and helpers shared across the application.

Index

Constants

This section is empty.

Variables

View Source
var ErrWorkflowCanceled = errors.New("workflow canceled")

ErrWorkflowCanceled indicates the workflow was aborted by the user via soft cancel.

Functions

func Run

func Run(gitClient git.StatusInfoReader) []string

Run executes the incremental search interactive UI with the provided custom git client, and returns the selected command as []string (or nil if nothing is selected).

Types

type ANSIColors

type ANSIColors = uiutil.ANSIColors

ANSIColors is an alias to the shared UI palette definition.

func NewANSIColors

func NewANSIColors() *ANSIColors

NewANSIColors exposes the shared ANSI color palette helper.

type CommandInfo

type CommandInfo struct {
	Command     string
	Description string
}

CommandInfo contains the name and description of a command available in interactive mode. The list is injected at construction time via NewUI so that this package does not depend on the cmd layer.

type CommandRouter

type CommandRouter interface {
	Route(args []string) error
}

CommandRouter represents an interface for routing commands

type GitStatus

type GitStatus struct {
	Branch     string
	Modified   int
	Staged     int
	Ahead      int
	Behind     int
	HasChanges bool
}

GitStatus represents the current Git repository status

type KeyHandler

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

KeyHandler manages keyboard input processing

func (*KeyHandler) GetCurrentKeyMap

func (h *KeyHandler) GetCurrentKeyMap() *kb.KeyBindingMap

GetCurrentKeyMap returns the appropriate keybinding map for the current context

func (*KeyHandler) HandleKey

func (h *KeyHandler) HandleKey(r rune, _ bool, oldState *term.State, reader *bufio.Reader) (bool, []string)

HandleKey processes UTF-8 rune input and returns true if should continue This method handles both single-byte (ASCII/control) and multibyte characters

type Renderer

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

Renderer handles all terminal rendering operations

func (*Renderer) Render

func (r *Renderer) Render(ui *UI, state *UIState)

Render displays the command list with proper terminal handling

type UI

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

UI represents the interface for terminal UI operations

func NewUI

func NewUI(gitClient git.StatusInfoReader, commands []CommandInfo, cfg *config.Config, router ...CommandRouter) *UI

NewUI creates a new UI with the provided git client, command list, optional pre-loaded config, and optional command router. commands is the list of entries shown in interactive search; pass nil to start with an empty list. Pass cfg=nil to have NewUI load configuration from gitClient (fallback path used by the standalone Run helper).

func (*UI) AddToWorkflow

func (ui *UI) AddToWorkflow(command string, args []string, description string) int

AddToWorkflow adds a command to the active workflow.

func (*UI) ApplyContextualKeybindings

func (ui *UI) ApplyContextualKeybindings(contextual *kb.ContextualKeyBindingMap)

ApplyContextualKeybindings updates the active keybinding map, satisfying keybindings.ContextualMapApplier.

func (*UI) ClearWorkflow

func (ui *UI) ClearWorkflow()

ClearWorkflow removes all steps from the workflow

func (*UI) ExecuteWorkflow

func (ui *UI) ExecuteWorkflow() error

ExecuteWorkflow executes the current workflow

func (*UI) ResetToSearchMode

func (ui *UI) ResetToSearchMode() bool

ResetToSearchMode clears the interactive search UI back to its default state.

func (*UI) Run

func (ui *UI) Run() []string

Run executes the interactive UI

func (*UI) ToggleWorkflowView

func (ui *UI) ToggleWorkflowView()

ToggleWorkflowView toggles between search mode and workflow mode.

type UIMode

type UIMode int

UIMode describes the high-level mode of the interactive UI.

const (
	// ModeSearch renders the classic search/execute interface.
	ModeSearch UIMode = iota
	// ModeWorkflow renders the dedicated workflow management interface.
	ModeWorkflow
)

type UIState

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

UIState holds the current state of the interactive UI

func (*UIState) AddRune

func (s *UIState) AddRune(r rune)

AddRune adds a UTF-8 rune to the input at cursor position

func (*UIState) ClearInput

func (s *UIState) ClearInput()

ClearInput clears all input

func (*UIState) DeleteToEnd

func (s *UIState) DeleteToEnd()

DeleteToEnd deletes from cursor to end of line (Ctrl+K)

func (*UIState) DeleteWord

func (s *UIState) DeleteWord()

DeleteWord deletes word before cursor (Ctrl+W)

func (*UIState) EnterContext

func (s *UIState) EnterContext(newContext kb.Context)

EnterContext pushes the current context onto the stack and switches to the new context

func (*UIState) ExitContext

func (s *UIState) ExitContext()

ExitContext pops the previous context from the stack

func (*UIState) FocusInput

func (s *UIState) FocusInput()

FocusInput moves focus to the command input/results pane.

func (*UIState) FocusWorkflowList

func (s *UIState) FocusWorkflowList()

FocusWorkflowList moves focus to the workflow list pane.

func (*UIState) GetCurrentContext

func (s *UIState) GetCurrentContext() kb.Context

GetCurrentContext returns the current UI context

func (*UIState) GetSelectedCommand

func (s *UIState) GetSelectedCommand() *CommandInfo

GetSelectedCommand returns the currently selected command

func (*UIState) HasInput

func (s *UIState) HasInput() bool

HasInput returns true if there is input

func (*UIState) HasMatches

func (s *UIState) HasMatches() bool

HasMatches returns true if there are filtered matches

func (*UIState) IsInInputMode

func (s *UIState) IsInInputMode() bool

IsInInputMode returns true if currently in input context

func (*UIState) IsInResultsMode

func (s *UIState) IsInResultsMode() bool

IsInResultsMode returns true if currently in results context

func (*UIState) IsInSearchMode

func (s *UIState) IsInSearchMode() bool

IsInSearchMode returns true if currently in search context

func (*UIState) IsInputFocused

func (s *UIState) IsInputFocused() bool

IsInputFocused reports whether the command input/results pane has focus.

func (*UIState) IsWorkflowMode

func (s *UIState) IsWorkflowMode() bool

IsWorkflowMode reports whether the UI is currently in workflow mode.

func (*UIState) MoveDown

func (s *UIState) MoveDown()

MoveDown moves selection down

func (*UIState) MoveLeft

func (s *UIState) MoveLeft()

MoveLeft moves cursor one rune left

func (*UIState) MoveRight

func (s *UIState) MoveRight()

MoveRight moves cursor one rune right

func (*UIState) MoveToBeginning

func (s *UIState) MoveToBeginning()

MoveToBeginning moves cursor to beginning of line (Ctrl+A)

func (*UIState) MoveToEnd

func (s *UIState) MoveToEnd()

MoveToEnd moves cursor to end of line (Ctrl+E)

func (*UIState) MoveUp

func (s *UIState) MoveUp()

MoveUp moves selection up

func (*UIState) MoveWordLeft

func (s *UIState) MoveWordLeft()

MoveWordLeft moves cursor to the beginning of the previous word

func (*UIState) MoveWordRight

func (s *UIState) MoveWordRight()

MoveWordRight moves cursor to the start of the next word

func (*UIState) RemoveChar

func (s *UIState) RemoveChar()

RemoveChar removes character before cursor (backspace)

func (*UIState) SetContext

func (s *UIState) SetContext(ctx kb.Context)

SetContext directly sets the context (use with caution)

func (*UIState) SetMode

func (s *UIState) SetMode(mode UIMode)

SetMode switches between search and workflow modes.

func (*UIState) SetWorkflowListIndex

func (s *UIState) SetWorkflowListIndex(idx, total int)

SetWorkflowListIndex sets and clamps the workflow list selection.

func (*UIState) UpdateFiltered

func (s *UIState) UpdateFiltered()

UpdateFiltered updates the filtered commands based on current input using fuzzy matching

type Workflow

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

Workflow manages a sequence of commands to be executed

func NewWorkflow

func NewWorkflow() *Workflow

NewWorkflow creates a new workflow

func (*Workflow) AddStep

func (w *Workflow) AddStep(command string, args []string, description string) int

AddStep adds a step to the workflow

func (*Workflow) Clear

func (w *Workflow) Clear()

Clear removes all steps from the workflow

func (*Workflow) GetSteps

func (w *Workflow) GetSteps() []WorkflowStep

GetSteps returns a copy of all workflow steps

func (*Workflow) IsEmpty

func (w *Workflow) IsEmpty() bool

IsEmpty returns true if the workflow has no steps

func (*Workflow) Size

func (w *Workflow) Size() int

Size returns the number of steps in the workflow

type WorkflowExecutor

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

WorkflowExecutor executes workflow steps sequentially using existing Route mechanism

func NewWorkflowExecutor

func NewWorkflowExecutor(router CommandRouter, ui *UI) *WorkflowExecutor

NewWorkflowExecutor creates a new workflow executor

func (*WorkflowExecutor) Execute

func (we *WorkflowExecutor) Execute(workflow *Workflow) error

Execute runs all steps in the workflow sequentially

type WorkflowFocus

type WorkflowFocus int

WorkflowFocus indicates which pane in workflow mode has focus.

const (
	// FocusInput targets the command input/results pane.
	FocusInput WorkflowFocus = iota
	// FocusWorkflowList targets the workflow list pane.
	FocusWorkflowList
)

type WorkflowManager

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

WorkflowManager manages multiple workflows and their lifecycle.

func NewWorkflowManager

func NewWorkflowManager() *WorkflowManager

NewWorkflowManager constructs a manager with an initial empty workflow.

func (*WorkflowManager) AddStep

func (m *WorkflowManager) AddStep(id int, command string, args []string, description string) (int, bool)

AddStep adds a step to the specified workflow.

func (*WorkflowManager) ClearWorkflow

func (m *WorkflowManager) ClearWorkflow(id int) bool

ClearWorkflow removes all steps from the specified workflow.

func (*WorkflowManager) CloneWorkflow

func (m *WorkflowManager) CloneWorkflow(id int, name string) (int, bool)

CloneWorkflow duplicates an existing workflow into a new dynamic workflow.

func (*WorkflowManager) CreateWorkflow

func (m *WorkflowManager) CreateWorkflow(name string) int

CreateWorkflow adds a new empty workflow and makes it active.

func (*WorkflowManager) CycleActive

func (m *WorkflowManager) CycleActive(delta int) int

CycleActive moves the active workflow by delta in the ordered list.

func (*WorkflowManager) DeleteWorkflow

func (m *WorkflowManager) DeleteWorkflow(id int) (int, bool)

DeleteWorkflow removes a workflow by ID, returning the new active workflow ID.

func (*WorkflowManager) GetActiveID

func (m *WorkflowManager) GetActiveID() int

GetActiveID returns the current active workflow ID.

func (*WorkflowManager) GetWorkflow

func (m *WorkflowManager) GetWorkflow(id int) (*Workflow, bool)

GetWorkflow returns the workflow and whether it exists.

func (*WorkflowManager) ListWorkflows

func (m *WorkflowManager) ListWorkflows() []WorkflowSummary

ListWorkflows returns ordered summaries of all workflows.

func (*WorkflowManager) LoadFromConfig added in v8.2.0

func (m *WorkflowManager) LoadFromConfig(workflows map[string][]string)

LoadFromConfig registers pre-defined workflows from the config's workflows section. Each map key becomes the workflow name; each string in the slice becomes a step where the first whitespace-delimited token is the command and the remainder are arguments. Interactive placeholder syntax (<name>) is supported and preserved in the step description.

Workflows are inserted in alphabetical order by name so that the order shown in ListWorkflows / the UI cycling key is stable and predictable across runs.

The scratch workflow that was active before the call is restored as active afterwards so the user can start typing immediately in the UI.

func (*WorkflowManager) SetActive

func (m *WorkflowManager) SetActive(id int) bool

SetActive designates the workflow with the provided ID as active.

type WorkflowStep

type WorkflowStep struct {
	ID          int      `json:"id"`
	Command     string   `json:"command"`
	Args        []string `json:"args"`
	Description string   `json:"description"`
}

WorkflowStep represents a single step in a workflow

func (*WorkflowStep) String

func (ws *WorkflowStep) String() string

String returns a string representation of the workflow step

type WorkflowSummary

type WorkflowSummary struct {
	ID        int
	StepCount int
	IsActive  bool
	Name      string
}

WorkflowSummary describes a workflow for listing/selection purposes.

Jump to

Keyboard shortcuts

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