tui

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package tui hosts the ONLY code in this module that imports charm.land/bubbletea/v2 and charm.land/bubbles/v2 (D-09/D-11). It is a sibling of internal/cli/present, not a subpackage of it, so the pure, side-effect-free TTY-gate helpers in present stay untouched while this package grows the stateful, interactive components (daemon picker, install/uninstall multi-select) that later plans in this phase add.

internal/cli/tui is excluded from the TUI-01 archtest's guarded closure (internal/cli/present/archtest/import_graph_test.go already excludes the whole internal/cli prefix), so importing bubbletea/bubbles here can never leak into the serve-reachable surface (internal/daemon, internal/mcp, etc.) by construction.

07-01 anchored bubbles/bubbletea here via blank imports so `go mod tidy` wouldn't prune the requires before a real importer existed; both agentpicker.go (07-06) and daemonpicker.go (07-07) now import them directly, so the anchor is no longer needed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InteractiveAllowed

func InteractiveAllowed(cmd *cobra.Command) bool

InteractiveAllowed reports whether an interactive component may call tea.NewProgram() for cmd: BOTH stdin and stdout must be real terminals, composing present.ChoosePresentation (the SAME stdout+NO_COLOR seam every other renderer gates on, D-10) with the additional stdin-TTY requirement bubbletea's raw-mode input driver needs. Not a TTY on either fd (piped/CI) or NO_COLOR set ⇒ false — the caller falls back to a non-interactive path and never issues a blocking stdin read (TUI-04's never-hang invariant).

func RunAgentPicker

func RunAgentPicker(cmd *cobra.Command, loc agents.Location) ([]agents.AgentTarget, error)

RunAgentPicker constructs and runs the checkbox multi-select Program over agents.AllTargets(), pre-checked from agents.DetectAll(loc), wiring cmd's own stdin/stdout so both the real CLI and any test harness capture the same I/O every other command uses. RunAgentPicker does NOT re-check tui.InteractiveAllowed itself — the caller (install.go/uninstall.go) MUST have already gated on it (D-10); calling this off a non-TTY is the caller's bug, not this function's job to detect.

func RunDaemonPicker

func RunDaemonPicker(cmd *cobra.Command, currentRepo string, records []daemon.Record) error

RunDaemonPicker constructs and runs the daemon picker Program over records (sorted current-repo-first), wiring cmd's own stdin/stdout so both the real CLI and any test harness capture the same I/O every other command uses, then dispatches the resolved action and prints a confirmation of what was actually stopped (WR-01, 07-REVIEW.md) — giving the interactive path the same on-screen feedback `daemon stop [--all]` already gives non-interactively. RunDaemonPicker does NOT re-check tui.InteractiveAllowed itself — the caller (daemon.go) MUST have already gated on it (D-10); calling this off a non-TTY is the caller's bug, not this function's job to detect.

func SortRecordsCurrentFirst

func SortRecordsCurrentFirst(records []daemon.Record, currentRepo string) []daemon.Record

SortRecordsCurrentFirst orders records with the current repo's own record(s) first, then a stable secondary order by (RepoRoot, PID) — the DMON-01/TUI-04 ordering both this Model and daemon.go's plain non-TTY list (D-12) must share, so the two presentations never diverge. Exported so internal/cli's bare `daemon` RunE can reuse the exact same ordering for its plain-list fallback. currentRepo is compared via resolveRepoRoot (WR-03, 07-REVIEW.md) — the same filepath.EvalSymlinks normalization internal/daemon/stop.go's StopMatching uses to target a daemon — so the "is this my repo" ordering answer never diverges from the "is this my repo" targeting answer just because the two sides of a symlinked path (e.g. macOS's /tmp -> /private/tmp) were spelled differently. Secondary ordering (RepoRoot, PID) intentionally still compares the raw RepoRoot strings, not resolved ones — records within the same actual repo could have been recorded through different symlink spellings, and stable raw string ordering is enough to keep the secondary sort deterministic without adding another resolveRepoRoot call per comparison.

Types

This section is empty.

Jump to

Keyboard shortcuts

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