Documentation
¶
Overview ¶
Package tui implements the interactive Bubble Tea dashboard for bare `wrk`. Dependencies (git, compose, dirt gates) are injected via RunDashboardOpts so this package never imports parent github.com/xhd2015/wrk/wrkcli.
Index ¶
- func OriginFromCPR(row1, viewLines int) (originY0 int, ok bool)
- func ParseCPR(buf []byte) (row1, col1 int, ok bool)
- func PlanRecipeStages(r Recipe) []string
- func RunDashboard(opts RunDashboardOpts) error
- func SplitCommitMessage(msg string) (subject, body string)
- type BuildDashboardHitmapOpts
- type Hit
- type LogFunc
- type LogLine
- type Recipe
- type ResolveMouseHitOpts
- type ResolveMouseHitResult
- type RunDashboardOpts
- type StageEvent
- type StagePreviewResult
- type StageRunState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OriginFromCPR ¶ added in v0.0.16
OriginFromCPR keeps clamped semantics for sealed doctests. Live origin tracking uses mouse.Tracker (strict OriginFromCPR).
func PlanRecipeStages ¶ added in v0.0.18
PlanRecipeStages returns ordered stage IDs included in r for RUN ALL. Fixed order matches the dashboard rows (Pre → Main → After).
func RunDashboard ¶
func RunDashboard(opts RunDashboardOpts) error
RunDashboard runs the interactive Bubble Tea dashboard until CANCEL. Stage / RUN ALL ops run in-process with a loading spinner (no tear-down flash).
func SplitCommitMessage ¶ added in v0.0.18
SplitCommitMessage splits a full commit message into subject (first line) and body. Pure helper for tests and any caller that holds a multi-line message string.
Types ¶
type BuildDashboardHitmapOpts ¶ added in v0.0.16
BuildDashboardHitmapOpts configures pure hitmap layout.
type Hit ¶ added in v0.0.16
type Hit struct {
Y0, Y1 int
X0, X1 int
Focus int // keyboard focus index; -1 if unused
RunStage string // non-empty for Run chip
}
Hit is a rectangular mouse hit region in view-local coordinates (Y = 0 at the first rendered dashboard line).
func BuildDashboardHitmap ¶ added in v0.0.16
func BuildDashboardHitmap(opts BuildDashboardHitmapOpts) (hits []Hit, viewLines int)
BuildDashboardHitmap returns view-local hit regions and the rendered line count.
type LogFunc ¶ added in v0.0.18
type LogFunc func(stage, line string)
LogFunc is a TUI-safe logger used while the dashboard owns the terminal. Lines must be delivered into the model Log ring (via tea msgs), never written with fmt.Print / log.Printf to the real tty (that corrupts Bubble Tea frames). stage may be empty for pipeline-level notes.
type LogLine ¶ added in v0.0.18
type LogLine struct {
Stage string
Level string // optional; empty for plain process output
Text string
At time.Time
}
LogLine is one captured stdout/stderr line from a stage / RUN ALL op.
type Recipe ¶
type Recipe struct {
AddAll bool
GenCommitMsg bool
Commit bool
AgentRunner string
Done bool
MergeBack bool
Sync bool
TagNext bool
Push bool
ReinstallLocal bool
DryRun bool
}
Recipe holds stage selection for RUN / single-phase compose.
type ResolveMouseHitOpts ¶ added in v0.0.16
type ResolveMouseHitOpts struct {
AbsX, AbsY int
Height int
ViewLines int
OriginY *int
Hitmap []Hit
Loading bool
}
ResolveMouseHitOpts is pure input for absolute mouse → hit resolution.
type ResolveMouseHitResult ¶ added in v0.0.16
ResolveMouseHitResult is the outcome of ResolveMouseHit.
func ResolveMouseHit ¶ added in v0.0.16
func ResolveMouseHit(opts ResolveMouseHitOpts) ResolveMouseHitResult
ResolveMouseHit maps an absolute terminal click onto a view-local Hit.
type RunDashboardOpts ¶
type RunDashboardOpts struct {
WorkDir string
Status string
// HasAddableDirt reports whether workDir has unstaged/untracked dirt.
HasAddableDirt func(workDir string) bool
// IsMainCheckout reports whether workDir is the primary (non-linked) checkout.
IsMainCheckout func(workDir string) bool
// GitAddAll stages all changes (git add -A) in workDir.
GitAddAll func(workDir string) error
// RunCompose executes compose for the given recipe.
// Legacy bridge: TUI may temporarily redirect process stdout/stderr to feed the Log panel.
// Prefer RunPipeline + LogFunc for structured stage output. Used for single-stage runs
// and as fallback when RunPipeline is nil.
RunCompose func(workDir string, r Recipe) error
// RunPipeline runs the recipe as ordered stages.
// emit delivers stage state transitions; log delivers user-visible lines for the Log panel
// (TUI-safe — do not fmt/log to the real tty from pipeline code).
// If nil, fall back to RunCompose once.
RunPipeline func(workDir string, r Recipe, emit func(StageEvent), log LogFunc) error
// ComposeArgv builds CLI tokens for preview / status from a recipe.
ComposeArgv func(r Recipe) []string
// StagePreview returns a brief one-line preview for stageID (e.g. "add-changes")
// plus optional log lines (captured tool stderr/diagnostics) for the Log panel.
// Preview text may be empty on soft failure; Logs must still be delivered — never
// discarded and never printed to the real tty. Called from background tea.Cmds
// after first paint — must not block Init.
StagePreview func(workDir string, stageID string) StagePreviewResult
}
RunDashboardOpts configures the interactive dashboard TUI and injects deps.
type StageEvent ¶ added in v0.0.18
type StageEvent struct {
StageID string
Kind string // start | ok | error | skipped
Err string // if error
Result string // brief one-line for any stage (e.g. "staged", "planned")
Subject string // gen-commit subject (first line of message)
Body string // remaining body (optional; may go to Log)
}
StageEvent is one stage transition during a phase-aware pipeline run. StageID values: add-changes | gen-commit-msg | commit | merge-back | done | sync | tag-next | push | reinstall-local. Kind values: start | ok | error | skipped.
type StagePreviewResult ¶ added in v0.0.18
type StagePreviewResult struct {
// Preview is the one-line stage meta (may be empty).
Preview string
// Logs are normal Log panel lines (e.g. captured "fatal: no upstream…").
// Never discarded; never written to the real terminal by the probe path.
Logs []string
}
StagePreviewResult is one async stage preview probe outcome.
type StageRunState ¶ added in v0.0.18
type StageRunState string
StageRunState is the per-stage run indicator for RUN ALL / single-stage ops.
const ( StageIdle StageRunState = "idle" StageQueued StageRunState = "queued" StageRunning StageRunState = "running" StageOK StageRunState = "ok" StageError StageRunState = "error" StageSkipped StageRunState = "skipped" )