tui

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const TickInterval = 80 * time.Millisecond

Variables

View Source
var (
	ColorPrimary = lipgloss.AdaptiveColor{Light: "#00AA44", Dark: "#00FF66"}
	ColorText    = lipgloss.AdaptiveColor{Light: "#0A2912", Dark: "#E0FFE9"}
	ColorDim     = lipgloss.AdaptiveColor{Light: "#2D663B", Dark: "#009944"}
	ColorBg      = lipgloss.AdaptiveColor{Light: "#F0FFF4", Dark: "#050B07"}
	ColorPanel   = lipgloss.AdaptiveColor{Light: "#DCF5E3", Dark: "#0D1C13"}
	ColorInput   = lipgloss.AdaptiveColor{Light: "#E6F7EB", Dark: "#12241A"}
	ColorSuccess = lipgloss.AdaptiveColor{Light: "#008833", Dark: "#00FF66"}
	ColorError   = lipgloss.AdaptiveColor{Light: "#CC0033", Dark: "#FF2A55"}
	ColorWarning = lipgloss.AdaptiveColor{Light: "#88A800", Dark: "#CCFF00"}
	ColorTool    = lipgloss.AdaptiveColor{Light: "#008B8B", Dark: "#00FFCC"}
	ColorBorder  = lipgloss.AdaptiveColor{Light: "#99CCAA", Dark: "#004D25"}
)
View Source
var (
	IconPending = "◦"
	IconSuccess = "✓"
	IconError   = "✗"
	IconUser    = "▸ You"
	IconAgent   = "◈ Matrix"
	IconInfo    = "◆ Info"
	IconErrMsg  = "✖ Error"
	IconTool    = "⚙ Tool"

	SpinnerFrames = []string{"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"}
)
View Source
var (
	StyleBase = lipgloss.NewStyle().
				Foreground(ColorText)

	StyleDim = lipgloss.NewStyle().
				Foreground(ColorDim)

	StylePrimary = lipgloss.NewStyle().
					Foreground(ColorPrimary).
					Bold(true)

	StyleSuccess = lipgloss.NewStyle().
					Foreground(ColorSuccess)

	StyleError = lipgloss.NewStyle().
				Foreground(ColorError)

	StyleWarning = lipgloss.NewStyle().Foreground(ColorWarning)

	StyleTool = lipgloss.NewStyle().
				Foreground(ColorTool)

	StyleBold = lipgloss.NewStyle().
				Bold(true)

	StyleActiveBorder = lipgloss.NewStyle().
						Border(lipgloss.RoundedBorder()).
						BorderForeground(ColorPrimary)

	StyleInactiveBorder = lipgloss.NewStyle().
						Border(lipgloss.RoundedBorder()).
						BorderForeground(ColorBorder)

	StyleActiveTab = lipgloss.NewStyle().
					Background(ColorPrimary).
					Foreground(lipgloss.AdaptiveColor{Light: "#FFFFFF", Dark: "#050B07"}).
					Bold(true).
					Padding(0, 1)

	StyleInactiveTab = lipgloss.NewStyle().
						Foreground(ColorDim).
						Padding(0, 1)

	StyleStatusBar = lipgloss.NewStyle().
					Background(ColorPanel).
					Foreground(ColorText).
					Padding(0, 1)

	StyleInput = lipgloss.NewStyle().
				Border(lipgloss.RoundedBorder()).
				BorderForeground(ColorBorder).
				Padding(0, 1)

	StyleInputFocused = lipgloss.NewStyle().
						Border(lipgloss.RoundedBorder()).
						BorderForeground(ColorPrimary).
						Padding(0, 1)

	StyleUserPrefix  = lipgloss.NewStyle().Foreground(ColorPrimary).Bold(true)
	StyleAgentPrefix = lipgloss.NewStyle().Foreground(ColorSuccess).Bold(true)
	StyleInfoPrefix  = lipgloss.NewStyle().Foreground(ColorTool)
	StyleErrPrefix   = lipgloss.NewStyle().Foreground(ColorError).Bold(true)
	StyleToolPrefix  = lipgloss.NewStyle().Foreground(ColorTool).Bold(true)
)
View Source
var AllCommands = []Command{
	{"/help", "Show all available commands"},
	{"/exit", "Gracefully exit DockCode"},
	{"/clear", "Clear chat and reset session memory"},
	{"/newchat", "Start a new chat session"},
	{"/settoken", "Set a new API token"},
	{"/seturl", "Set a new API base URL"},
	{"/model", "Interactive model picker"},
	{"/models", "List available models in chat"},
	{"/config", "Show current configuration"},
	{"/theme", "Toggle dark/light theme"},
	{"/sessions", "Open session browser"},
	{"/session rename", "Rename current session"},
	{"/session delete", "Delete current session"},
	{"/session export", "Export chat to markdown file"},
	{"/session tag", "Tag current session"},
	{"/containers", "Focus containers sidebar panel"},
	{"/images", "Focus images sidebar panel"},
	{"/volumes", "Focus volumes sidebar panel"},
	{"/networks", "Focus networks sidebar panel"},
	{"/logs", "Stream container logs (usage: /logs <name>)"},
	{"/stop", "Stop a container (usage: /stop <name>)"},
	{"/rm", "Remove a container (usage: /rm <name>)"},
}
View Source
var IsDarkMode = true

Functions

func FormatContainerStatus

func FormatContainerStatus(status string) string

func HasUnicodeSupport

func HasUnicodeSupport() bool

func HelpText

func HelpText() string

func ParseSlashCommand

func ParseSlashCommand(input string) (cmd, arg string)

func SessionsBaseDir

func SessionsBaseDir() string

func SidebarTickCmd

func SidebarTickCmd() tea.Cmd

func ToggleTheme

func ToggleTheme()

Types

type AutocompleteState

type AutocompleteState struct {
	Visible  bool
	Matches  []Command
	Selected int
}

func NewAutocompleteState

func NewAutocompleteState() AutocompleteState

func (*AutocompleteState) Current

func (a *AutocompleteState) Current() string

func (*AutocompleteState) Hide

func (a *AutocompleteState) Hide()

func (*AutocompleteState) MoveDown

func (a *AutocompleteState) MoveDown()

func (*AutocompleteState) MoveUp

func (a *AutocompleteState) MoveUp()

func (*AutocompleteState) Update

func (a *AutocompleteState) Update(input string)

func (AutocompleteState) View

func (a AutocompleteState) View(width int) string

type ChatMessage

type ChatMessage struct {
	Kind    ChatMessageKind
	Content string
}

type ChatMessageKind

type ChatMessageKind int
const (
	KindUser ChatMessageKind = iota
	KindAssistant
	KindToolStart
	KindToolDone
	KindInfo
	KindError
)

type ChatView

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

func NewChatView

func NewChatView() ChatView

func (*ChatView) AddMessage

func (c *ChatView) AddMessage(kind ChatMessageKind, content string)

func (*ChatView) AppendStream

func (c *ChatView) AppendStream(text string)

func (*ChatView) FlushStream

func (c *ChatView) FlushStream()

func (*ChatView) ScrollDown

func (c *ChatView) ScrollDown()

func (*ChatView) ScrollUp

func (c *ChatView) ScrollUp()

func (*ChatView) SetAgentRunning

func (c *ChatView) SetAgentRunning(running bool)

func (*ChatView) SetFocus

func (c *ChatView) SetFocus(f bool)

func (*ChatView) SetSize

func (c *ChatView) SetSize(w, h int)

func (*ChatView) TickThinking

func (c *ChatView) TickThinking()

func (ChatView) View

func (c ChatView) View() string

type Command

type Command struct {
	Name string
	Desc string
}

type ExitMsg

type ExitMsg struct{}

type KeyMap

type KeyMap struct {
	Send       key.Binding
	Tab        key.Binding
	ShiftTab   key.Binding
	ScrollUp   key.Binding
	ScrollDown key.Binding
	Quit       key.Binding
	Escape     key.Binding
	Enter      key.Binding
	Panel1     key.Binding
	Panel2     key.Binding
	Panel3     key.Binding
	Panel4     key.Binding
}

func DefaultKeyMap

func DefaultKeyMap() KeyMap

type Model

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

func NewModel

func NewModel(
	ctx context.Context,
	cancel context.CancelFunc,
	cfg *config.Manager,
	dockerClient *docker.Client,
	llmClient *llm.Client,
	sess *agent.Session,
	sessIdx *agent.SessionIndex,
	sup *concurrency.Supervisor,
) Model

func (*Model) Init

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

func (*Model) SetProgram

func (m *Model) SetProgram(p *tea.Program)

func (*Model) Update

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

func (*Model) View

func (m *Model) View() string

type OnboardDoneMsg

type OnboardDoneMsg struct {
	BaseURL string
	Token   string
	Model   string
}

type OnboardingModel

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

func NewOnboardingModel

func NewOnboardingModel(ctx context.Context, cfg *config.Manager) OnboardingModel

func (OnboardingModel) Init

func (m OnboardingModel) Init() tea.Cmd

func (OnboardingModel) Update

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

func (OnboardingModel) View

func (m OnboardingModel) View() string

type SessionBrowserCloseMsg

type SessionBrowserCloseMsg struct{}

type SessionBrowserModel

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

func NewSessionBrowserModel

func NewSessionBrowserModel(index *agent.SessionIndex) SessionBrowserModel

func (SessionBrowserModel) Init

func (m SessionBrowserModel) Init() tea.Cmd

func (SessionBrowserModel) Update

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

func (SessionBrowserModel) View

func (m SessionBrowserModel) View() string

type SessionBrowserMsg

type SessionBrowserMsg struct{ SessionID string }

type SessionDetailCloseMsg

type SessionDetailCloseMsg struct{}

type SessionDetailModel

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

func NewSessionDetailModel

func NewSessionDetailModel(
	summary agent.SessionSummary,
	chatMD string,
	agentMD string,
) SessionDetailModel

func (SessionDetailModel) Init

func (m SessionDetailModel) Init() tea.Cmd

func (SessionDetailModel) Update

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

func (SessionDetailModel) View

func (m SessionDetailModel) View() string

type SessionDetailOpenMsg

type SessionDetailOpenMsg struct{ SessionID string }
type Sidebar struct {
	// contains filtered or unexported fields
}

func NewSidebar

func NewSidebar() Sidebar

func (*Sidebar) SetFocus

func (s *Sidebar) SetFocus(f bool)

func (*Sidebar) SetPanel

func (s *Sidebar) SetPanel(p SidebarPanel)

func (*Sidebar) SetSize

func (s *Sidebar) SetSize(w, h int)

func (*Sidebar) Update

func (s *Sidebar) Update(msg agent.SidebarRefreshMsg)

func (Sidebar) View

func (s Sidebar) View() string

type SidebarPanel

type SidebarPanel int
const (
	PanelContainers SidebarPanel = iota
	PanelImages
	PanelVolumes
	PanelNetworks
)

type SidebarRefresher

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

func NewSidebarRefresher

func NewSidebarRefresher(
	parent context.Context,
	dockerClient *docker.Client,
	program *tea.Program,
	agentBusy *atomic.Bool,
) *SidebarRefresher

func (*SidebarRefresher) Start

func (r *SidebarRefresher) Start()

func (*SidebarRefresher) Stop

func (r *SidebarRefresher) Stop()

type SidebarTickMsg

type SidebarTickMsg struct{}

type SpinTickMsg

type SpinTickMsg struct{}

type Spinner

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

func NewSpinner

func NewSpinner() Spinner

func (*Spinner) Tick

func (s *Spinner) Tick()

func (Spinner) View

func (s Spinner) View() string

type StatusBar

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

func NewStatusBar

func NewStatusBar(model string) StatusBar

func (*StatusBar) SetWidth

func (s *StatusBar) SetWidth(w int)

func (*StatusBar) Update

func (s *StatusBar) Update(tokenCount int64, dockerAlive, agentBusy bool)

func (StatusBar) View

func (s StatusBar) View() string

Jump to

Keyboard shortcuts

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