ui

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	YankFeedbackDuration       = 2 * time.Second
	PruneErrorFeedbackDuration = 3 * time.Second
	YankChordTimeout           = 300 * time.Millisecond
)

UI feedback durations

View Source
const PruneFilePromptTemplate = `` /* 137-byte string literal not displayed */

PruneFilePromptTemplate is the template for file summarization prompts

Variables

This section is empty.

Functions

func AppHeader

func AppHeader() string

AppHeader renders the application header

func BuildViewportContent

func BuildViewportContent(reviewResponse string, chatHistory []ChatMessage, renderer *Renderer, width int) string

BuildViewportContent builds the viewport content from review response and chat history

func CalculateViewportHeight

func CalculateViewportHeight(height int, state State, hasYankFeedback bool) int

CalculateViewportHeight calculates the dynamic viewport height based on UI state

func ClearYankFeedbackCmd

func ClearYankFeedbackCmd(duration time.Duration) tea.Cmd

ClearYankFeedbackCmd creates a command to clear yank feedback after a delay

func CollectIntent

func CollectIntent(interactive bool) (*appcontext.Intent, error)

CollectIntent collects user intent using a huh form Returns nil if skipped (non-interactive mode)

func GetSelectedFile

func GetSelectedFile(l list.Model) (string, bool)

GetSelectedFile returns the currently selected file path

func HelpFooter

func HelpFooter() string

HelpFooter renders the help footer

func NavigatePromptHistory(history []string, currentIndex int, direction int) ([]string, int, string)

NavigatePromptHistory navigates through prompt history Returns updated history, new index, and the prompt at that index (empty if new prompt)

func NewFileListModel

func NewFileListModel(reviewCtx *appcontext.ReviewContext, pruningFiles map[string]bool) list.Model

NewFileListModel creates a new file list model from ReviewContext pruningFiles may be nil if pruning state is not needed

func RenderBox

func RenderBox(content string) string

RenderBox renders content in a box

func RenderCompactHelp

func RenderCompactHelp(state string) string

RenderCompact renders a compact version of the help for the footer

func RenderDivider

func RenderDivider(width int) string

RenderDivider renders a divider line

func RenderError

func RenderError(text string) string

RenderError renders an error message

func RenderHelp

func RenderHelp(text string) string

RenderHelp renders help text

func RenderLoadingDots

func RenderLoadingDots(tick int) string

RenderLoadingDots renders animated loading dots

func RenderProgress

func RenderProgress(current, total int) string

RenderProgress renders a simple progress indicator

func RenderPrompt

func RenderPrompt() string

RenderPrompt renders an input prompt

func RenderSearchInput

func RenderSearchInput(query string, matchCount, currentMatch int, mode SearchMode) string

RenderSearchInput renders the search input bar

func RenderSecretWarning

func RenderSecretWarning(secrets []SecretInfo) string

RenderSecretWarning renders a warning about detected secrets

func RenderSubtitle

func RenderSubtitle(text string) string

RenderSubtitle renders a subtitle

func RenderSuccess

func RenderSuccess(text string) string

RenderSuccess renders a success message

func RenderTitle

func RenderTitle(text string) string

RenderTitle renders a title

func RenderTokenUsage

func RenderTokenUsage(prompt, completion, total int32) string

RenderTokenUsage renders token usage information

func RenderWarning

func RenderWarning(text string) string

RenderWarning renders a warning message

func Run

func Run(reviewCtx *appcontext.ReviewContext, appInstance *app.App, sessionID string, p *preset.Preset) error

Run starts the Bubbletea program

func RunSimple

func RunSimple(ctx context.Context, w io.Writer, reviewCtx *appcontext.ReviewContext, appInstance *app.App, sessionID string, p *preset.Preset) error

RunSimple runs a simple non-interactive review using coordinator

func ScrollToCurrentMatch

func ScrollToCurrentMatch(vp *viewport.Model, search *SearchState)

ScrollToCurrentMatch scrolls the viewport to show the current search match

func SendChatMessage

func SendChatMessage(ctx context.Context, appInstance *app.App, sessionID, question string) tea.Cmd

SendChatMessage sends a follow-up question using coordinator

func SendMessageCmd

func SendMessageCmd(message string, sendFunc func(string) tea.Msg) tea.Cmd

SendMessageCmd creates a command to send a message to the LLM

func UpdateFileListModel

func UpdateFileListModel(l list.Model, reviewCtx *appcontext.ReviewContext, pruningFiles map[string]bool) list.Model

UpdateFileListModel updates the file list model with current pruned state pruningFiles may be nil if pruning state is not needed

func UpdatePromptHistory

func UpdatePromptHistory(history []string, question string) []string

UpdatePromptHistory adds a question to prompt history, avoiding duplicates

func UpdateViewportWithSearch

func UpdateViewportWithSearch(vp *viewport.Model, rawContent string, search *SearchState)

UpdateViewportWithSearch updates the viewport with search highlighting

func YankLastResponse

func YankLastResponse(reviewResponse string, chatHistory []ChatMessage) tea.Cmd

YankLastResponse yanks only the last/most recent assistant response

func YankReview

func YankReview(reviewResponse string, chatHistory []ChatMessage) tea.Cmd

YankReview yanks the entire review content to clipboard

Types

type ChatErrorMsg

type ChatErrorMsg struct {
	Err error
}

ChatErrorMsg contains an error from a chat interaction

type ChatMessage

type ChatMessage struct {
	Role    ChatRole
	Content string
}

ChatMessage represents a message in the chat history

type ChatResponseMsg

type ChatResponseMsg struct {
	Response string
}

ChatResponseMsg contains a response to a follow-up question

type ChatRole

type ChatRole int

ChatRole represents the role of a chat message

const (
	ChatRoleUser ChatRole = iota
	ChatRoleAssistant
)

func (ChatRole) String

func (r ChatRole) String() string

String returns the string representation of ChatRole

type FileListItem

type FileListItem struct {
	Path    string
	Size    int
	Pruned  bool
	Pruning bool // Whether file is currently being pruned
}

FileListItem represents an item in the file list

func (FileListItem) Description

func (f FileListItem) Description() string

Description returns the description (file size)

func (FileListItem) FilterValue

func (f FileListItem) FilterValue() string

FilterValue returns the value to filter by

func (FileListItem) Title

func (f FileListItem) Title() string

Title returns the display title for the item

type HelpOverlay

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

HelpOverlay renders the help overlay with all keybindings

func NewHelpOverlay

func NewHelpOverlay(width, height int) *HelpOverlay

NewHelpOverlay creates a new help overlay

func (*HelpOverlay) Render

func (h *HelpOverlay) Render() string

Render renders the help overlay

type KeyMap

type KeyMap struct {
	// Global
	Quit      key.Binding
	ForceQuit key.Binding

	// Navigation (reviewing mode)
	Up           key.Binding
	Down         key.Binding
	Top          key.Binding
	Bottom       key.Binding
	HalfPageDown key.Binding
	HalfPageUp   key.Binding
	PageDown     key.Binding
	PageUp       key.Binding

	// Search
	Search      key.Binding
	NextMatch   key.Binding
	PrevMatch   key.Binding
	ToggleMode  key.Binding
	SearchEnter key.Binding
	SearchEsc   key.Binding

	// Help
	Help key.Binding

	// Chat
	EnterChat       key.Binding
	ExitChat        key.Binding
	SendMessage     key.Binding
	PrevPrompt      key.Binding
	NextPrompt      key.Binding
	CancelRequest   key.Binding
	ToggleWebSearch key.Binding

	// Yank
	YankReview key.Binding
	YankLast   key.Binding

	// File list
	FileList      key.Binding
	FileListPrune key.Binding
	SelectFile    key.Binding
	Back          key.Binding
}

KeyMap defines all keybindings for the TUI

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap returns the default keymap

type Model

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

Model represents the application state for Bubbletea

func NewModel

func NewModel(reviewCtx *appcontext.ReviewContext, appInstance *app.App, sessionID string, p *preset.Preset) *Model

NewModel creates a new application model

func (*Model) Init

func (m *Model) Init() tea.Cmd

Init initializes the model

func (*Model) Update

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

Update handles messages and updates the model

func (*Model) View

func (m *Model) View() tea.View

View renders the UI

type PruneFileMsg

type PruneFileMsg struct {
	FilePath string
	Summary  string
	Err      error
}

PruneFileMsg contains the result of pruning a file

type QuitMsg

type QuitMsg struct{}

QuitMsg signals the program should quit

type Renderer

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

Renderer handles markdown rendering

func NewRenderer

func NewRenderer() (*Renderer, error)

NewRenderer creates a new markdown renderer

func (*Renderer) RenderMarkdown

func (r *Renderer) RenderMarkdown(content string) (string, error)

RenderMarkdown renders markdown content for the terminal

type ReviewCompleteMsg

type ReviewCompleteMsg struct {
	Response string
}

ReviewCompleteMsg contains the completed review response

type ReviewErrorMsg

type ReviewErrorMsg struct {
	Err error
}

ReviewErrorMsg contains an error from the review process

type ReviewStartMsg

type ReviewStartMsg struct{}

ReviewStartMsg signals that a review has started

type SearchMatch

type SearchMatch struct {
	Line      int    // Line number (0-indexed)
	StartCol  int    // Start column in the line
	EndCol    int    // End column in the line
	LineText  string // The full line text
	MatchText string // The matched text
}

SearchMatch represents a match in the content

type SearchMode

type SearchMode int

SearchMode represents the search behavior

const (
	SearchModeHighlight SearchMode = iota // Highlight matches, show all content
	SearchModeFilter                      // Show only lines with matches
)

type SearchState

type SearchState struct {
	Active       bool
	Query        string
	Mode         SearchMode
	Matches      []SearchMatch
	CurrentMatch int
}

SearchState holds the current search state

func NewSearchState

func NewSearchState() *SearchState

NewSearchState creates a new search state

func (*SearchState) CurrentMatchLine

func (s *SearchState) CurrentMatchLine() int

CurrentMatchLine returns the line number of the current match

func (*SearchState) FilterContent

func (s *SearchState) FilterContent(content string) string

FilterContent returns only lines containing matches

func (*SearchState) FilteredLineIndex

func (s *SearchState) FilteredLineIndex(originalLine int) int

FilteredLineIndex translates an original line number to its index in the filtered view. Returns -1 if the line is not in the filtered set.

func (*SearchState) HighlightContent

func (s *SearchState) HighlightContent(content string) string

HighlightContent highlights all matches in the content

func (*SearchState) MatchCount

func (s *SearchState) MatchCount() int

MatchCount returns the number of matches

func (*SearchState) MatchStatus

func (s *SearchState) MatchStatus() string

MatchStatus returns a string describing the current match status

func (*SearchState) NextMatch

func (s *SearchState) NextMatch()

NextMatch moves to the next match

func (*SearchState) PrevMatch

func (s *SearchState) PrevMatch()

PrevMatch moves to the previous match

func (*SearchState) Reset

func (s *SearchState) Reset()

Reset clears the search state

func (*SearchState) Search

func (s *SearchState) Search(content string)

Search performs a case-insensitive search and returns matches

func (*SearchState) ToggleMode

func (s *SearchState) ToggleMode()

ToggleMode switches between highlight and filter modes

type SecretInfo

type SecretInfo struct {
	FilePath string
	Line     int
	Match    string
}

SecretInfo contains information about a detected secret

type State

type State int

State represents the current state of the application

const (
	StateLoading State = iota
	StateReviewing
	StateChatting
	StateSearching
	StateHelp
	StateFileList
	StateError
	StateQuitting
)

type StreamChunkMsg

type StreamChunkMsg struct {
	Chunk string
}

StreamChunkMsg contains a chunk of streamed response

type StreamDoneMsg

type StreamDoneMsg struct {
	FullResponse string
}

StreamDoneMsg signals that streaming is complete

type StreamStartMsg

type StreamStartMsg struct {
	ChunkChan chan string
	ErrChan   chan error
	DoneChan  chan string
}

StreamStartMsg signals that streaming has started and provides channels

type TickMsg

type TickMsg struct{}

TickMsg is used for spinner animation

type YankFeedbackMsg

type YankFeedbackMsg struct{}

YankFeedbackMsg signals that yank feedback should be cleared

type YankMsg

type YankMsg struct {
	Type YankType
}

YankMsg signals that content was yanked to clipboard

type YankType

type YankType int

YankType represents the type of yanked content

const (
	YankTypeReview YankType = iota
	YankTypeLastResponse
)

func (YankType) String

func (t YankType) String() string

String returns the string representation of YankType

Jump to

Keyboard shortcuts

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