ui

package
v1.0.48633 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	RunWatchPollInterval    = 5 * time.Second
	RunWatchMaxPollInterval = 30 * time.Second
)

Poll cadence for the watch flow. The first poll follows RunWatchPollInterval and each subsequent one waits a step longer, up to RunWatchMaxPollInterval — a run that has been going for twenty minutes rarely needs second-by-second attention, and the API does not need the traffic. The clock redraws at least once a second regardless, so the display never looks frozen between polls.

Variables

View Source
var (
	// BindStatus cycles the run picker's status filter forward. It is both a
	// dispatch binding and a footer entry.
	BindStatus = key.NewBinding(key.WithKeys("s"), key.WithHelp("s", "status"))

	// KeyStatusClear jumps the status filter back to "all statuses".
	KeyStatusClear = key.NewBinding(key.WithKeys("S"))
)

Run-picker key bindings. These live here rather than in clikit/ui/components because they are not generic TUI keys: both describe the CircleCI run status filter, so an extension has no use for them. Generic bindings (movement, search, select, help, quit) stay in the shared keymap.

Functions

func FormatElapsed added in v1.0.48614

func FormatElapsed(d time.Duration) string

FormatElapsed renders a watch duration as the compact "1h2m3s" form, dropping the units that are zero from the left. It is exported because `run watch` prints the same elapsed figure in its final summary line, after this program has exited, and the two must agree.

Types

type LoginFlowModel

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

LoginFlowModel is a multi-stage bubbletea model that walks the user through CircleCI authentication:

  1. Pick a CircleCI host (circleci.com or a custom URL).
  2. Pick an auth method (browser OAuth or paste a token). 3a. For browser OAuth: press Enter → open browser → wait for callback. 3b. For token: type/paste the personal access token.

After tea.Program.Run() returns, call Result() to read the outcome and Close() to release the OAuth server if one was started.

func NewLoginFlow

func NewLoginFlow(ctx context.Context, opts LoginFlowOptions) LoginFlowModel

NewLoginFlow returns a LoginFlowModel ready to pass to tea.NewProgram.

func (LoginFlowModel) Close

func (m LoginFlowModel) Close()

Close shuts down the OAuth callback server if one was started.

func (LoginFlowModel) Init

func (m LoginFlowModel) Init() tea.Cmd

func (LoginFlowModel) Result

func (m LoginFlowModel) Result() LoginResult

Result returns the final login outcome. Only valid after tea.Program.Run() returns.

func (LoginFlowModel) Update

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

func (LoginFlowModel) View

func (m LoginFlowModel) View() tea.View

type LoginFlowOptions

type LoginFlowOptions struct {
	DeviceID        string
	OSInfo          string
	Signup          bool
	CallbackTimeout time.Duration
	// GetUser, if non-nil, is called after token exchange to display
	// the authenticated user's login name.
	GetUser func(ctx context.Context, host, token string) (id uuid.UUID, username string, err error)
	Color   bool
}

LoginFlowOptions configures a LoginFlowModel.

type LoginMethod

type LoginMethod int

LoginMethod indicates which authentication path the user selected.

const (
	LoginMethodBrowser LoginMethod = iota
)

LoginMethodBrowser selects the browser-based OAuth PKCE flow.

type LoginResult

type LoginResult struct {
	Cancelled bool
	Host      string    // resolved base URL
	Token     string    // set when auth succeeds (either method)
	UserID    uuid.UUID // set when GetUser is provided and succeeds
	Username  string    // set when GetUser is provided and succeeds
	Err       error
}

LoginResult is the outcome of a completed LoginFlowModel run.

type OrbInitCategory

type OrbInitCategory struct {
	ID   string
	Name string
}

OrbInitCategory is one selectable orb category. The flow keeps this decoupled from the API client's own category type (like RunGetItem for the run flow).

type OrbInitFlowModel

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

OrbInitFlowModel is a multi-stage bubbletea model that walks the user through scaffolding a new orb: pick public/private, choose automated setup or a bare template download, then (for automated setup) gather the org, namespace, orb name, categories, publishing-context and git choices. It performs the three gating operations (template download, orb-existence check, category list) via injected callbacks and reports every decision through Result().

func NewOrbInitFlow

func NewOrbInitFlow(ctx context.Context, opts OrbInitFlowOptions) OrbInitFlowModel

NewOrbInitFlow returns an OrbInitFlowModel ready to pass to tea.NewProgram. The initial stage honors any flags supplied in opts.

func (OrbInitFlowModel) Init

func (m OrbInitFlowModel) Init() tea.Cmd

func (OrbInitFlowModel) Result

func (m OrbInitFlowModel) Result() OrbInitResult

Result returns the final outcome. Only valid after tea.Program.Run() returns.

func (OrbInitFlowModel) Update

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

func (OrbInitFlowModel) View

func (m OrbInitFlowModel) View() tea.View

type OrbInitFlowOptions

type OrbInitFlowOptions struct {
	// Path is the target directory. It seeds the default orb name (its final
	// segment) and the default remote URL.
	Path string
	// Private / TemplateOnly / OrgSlug / SkipGit mirror the command flags. A
	// non-zero value skips the matching prompt: --private skips the visibility
	// picker, --template-only skips the mode picker, --org skips the org prompt,
	// and --skip-git skips the git-setup confirm (forcing GitSetup off).
	Private      bool
	TemplateOnly bool
	OrgSlug      string
	SkipGit      bool
	// Branch is the default primary branch (the --branch flag, default "main").
	Branch string
	// Remote is the --remote flag; unused by the interactive flow (which always
	// prompts for it) but carried for symmetry.
	Remote string

	// ExistingRemote and ExistingBranch are what the git repository already at
	// Path has configured, empty when there is no repository or the value is not
	// set there yet. When a value is present its prompt is skipped: asking for a
	// remote URL that is sitting in .git/config is asking the author to retype
	// something the CLI can read, and lets them mistype it.
	ExistingRemote string
	ExistingBranch string

	// Download fetches and extracts the orb template into Path, removing the
	// template LICENSE when private is true. Shown behind a spinner.
	Download func(ctx context.Context, private bool) error
	// GetOrb reports whether an orb already exists under the given full name
	// ("namespace/orb"). Shown behind a spinner.
	GetOrb func(ctx context.Context, fullName string) (exists bool, err error)
	// ListCategories lists the assignable orb categories. Shown behind a spinner;
	// an empty list skips the category picker entirely.
	ListCategories func(ctx context.Context) ([]OrbInitCategory, error)

	Color bool
	// Animate reports whether the loading spinner should animate. Pass false when
	// CIRCLE_SPINNER_DISABLED is set so the loading line stays static.
	Animate bool
}

OrbInitFlowOptions configures an OrbInitFlowModel. The callbacks keep the program decoupled from the API client and filesystem: the caller supplies closures for the three operations the wizard has to run between prompts.

type OrbInitResult

type OrbInitResult struct {
	Cancelled bool
	// Err is set when a download / orb-lookup / category-list callback failed.
	Err error

	Private      bool
	TemplateOnly bool
	OrgSlug      string
	Namespace    string
	OrbName      string
	Categories   []OrbInitCategory
	SetupContext bool
	GitSetup     bool
	Branch       string
	Remote       string
}

OrbInitResult is the outcome of a completed OrbInitFlowModel run, read via Result() after tea.Program.Run() returns. When Cancelled or Err is set the remaining fields are not meaningful; otherwise they carry every decision the caller needs to apply the setup (create the namespace/orb, assign categories, set up git, and so on).

type PreambleModel

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

PreambleModel is a bubbletea model for an "Enter to continue · Esc to cancel" gate shown before a multi-step orchestrator runs. Default is opt-in: Enter proceeds, Esc/Ctrl+C cancels.

func NewPreambleModel

func NewPreambleModel(title, dir string, bullets []string) PreambleModel

NewPreambleModel returns a PreambleModel rendering the given title, bullet lines, and directory context.

func (PreambleModel) Done

func (m PreambleModel) Done() bool

Done reports whether the user has made a choice.

func (PreambleModel) Init

func (m PreambleModel) Init() tea.Cmd

func (PreambleModel) Proceed

func (m PreambleModel) Proceed() bool

Proceed reports whether the user pressed Enter to continue. False when cancelled via Esc or Ctrl+C.

func (PreambleModel) Update

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

func (PreambleModel) View

func (m PreambleModel) View() tea.View

type RunCreatedFilter

type RunCreatedFilter struct {
	Newer    bool
	Duration time.Duration
	Label    string
}

RunCreatedFilter narrows runs by creation time relative to now, as chosen on the filter dialog's "Created" tab. Duration is the relative window (e.g. 24h); a zero Duration means no created filter is active. Newer keeps runs created within the window (newer than now-Duration); when false — the default — it keeps runs older than now-Duration. Label is the human wording of the window (e.g. "24 Hours") for the picker title.

func (RunCreatedFilter) Active

func (f RunCreatedFilter) Active() bool

Active reports whether a created filter is set (a duration was chosen). The caller resolves the actual [from, to] window it requests (an "older than" query needs an explicit lower bound so the API does not apply its short default; see RUN_DATE_RANGES.md and createdWindow in internal/cmd/run).

type RunGetAction

type RunGetAction int

RunGetAction is the terminal choice the user reached in the run-get flow.

const (
	// RunGetActionCancel means the user quit (esc on the first picker, ctrl+c
	// anywhere) without choosing what to display.
	RunGetActionCancel RunGetAction = iota
	// RunGetActionShowRun displays the whole run (all its workflows).
	RunGetActionShowRun
	// RunGetActionShowWorkflow displays a single workflow (all its jobs).
	RunGetActionShowWorkflow
	// RunGetActionShowJob displays a single job.
	RunGetActionShowJob
	// RunGetActionShowJobOutput displays the full per-step output report for a
	// job (the equivalent of "circleci job output list").
	RunGetActionShowJobOutput
	// RunGetActionShowResourceUsage displays a job's CPU and memory usage charts
	// (the equivalent of "circleci job resource-usage get").
	RunGetActionShowResourceUsage
)

type RunGetArtifactItem added in v1.0.48340

type RunGetArtifactItem struct {
	Path      string
	URL       string
	Execution int
}

RunGetArtifactItem is one artifact file a job produced: the path it was stored under, the URL it can be fetched from, and the parallel execution that made it. It mirrors internal/artifacts.Entry, keeping this package independent of the API client like the rest of the flow's item types.

type RunGetError

type RunGetError struct {
	Type    string
	Message string
}

RunGetError is a single run-level error (type + message) surfaced under the workflow picker title.

type RunGetExecution

type RunGetExecution struct {
	Label string
	Icon  string
	Index int
	Steps []RunGetStepItem
}

RunGetExecution is one parallel execution of a job, carrying its steps. When a job's parallelism is greater than one the flow inserts an execution picker before the step picker; with a single execution that picker is skipped.

type RunGetFlowModel

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

RunGetFlowModel is a single multi-stage bubbletea program that drives the interactive "circleci run get" flow by composing components.SelectModel and a spinner:

  1. Pick a run from the recent list.
  2. Pick a workflow, or "see all workflows" (→ RunGetActionShowRun).
  3. Pick a job, or "all jobs in workflow" (→ RunGetActionShowWorkflow).
  4. For a job with parallelism > 1, pick an execution (skipped otherwise).
  5. Pick a step, or one of three summaries — "job report" (→ RunGetActionShowJob), the full per-step output report (→ RunGetActionShowJobOutput), or "failed tests", which opens a further picker of the job's failed tests. The cursor starts on the first failed step. Picking a step opens its output in an in-flow pager (r refreshes, esc returns to the step picker) rather than ending the program.
  6. From the failed-tests picker, picking a test opens its message in the same pager (esc returns to the test picker).

Between selections the next level's items are fetched off the Update loop via a tea.Cmd, with a spinner shown meanwhile. esc moves back one step (on the first picker it quits); ctrl+c quits anywhere. After Run() returns, read the outcome with Result(); the caller then prints the corresponding summary.

func NewRunGetFlow

func NewRunGetFlow(ctx context.Context, opts RunGetFlowOptions) RunGetFlowModel

NewRunGetFlow returns a RunGetFlowModel ready to pass to tea.NewProgram.

func (RunGetFlowModel) Init

func (m RunGetFlowModel) Init() tea.Cmd

func (RunGetFlowModel) Result

func (m RunGetFlowModel) Result() RunGetResult

Result returns the final outcome. Only valid after tea.Program.Run() returns.

func (RunGetFlowModel) Update

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

func (RunGetFlowModel) View

func (m RunGetFlowModel) View() tea.View

type RunGetFlowOptions

type RunGetFlowOptions struct {
	// Runs is an optional pre-loaded run list. When non-nil the model skips the
	// initial fetch and opens the picker immediately. When nil, Init() fetches
	// runs for the InitialScope asynchronously.
	Runs            []RunGetItem
	FetchWorkflows  func(ctx context.Context, runID uuid.UUID) ([]RunGetItem, error)
	FetchJobs       func(ctx context.Context, workflowID uuid.UUID) ([]RunGetItem, error)
	FetchExecutions func(ctx context.Context, jobID uuid.UUID) ([]RunGetExecution, error)
	// FetchStepStdout reads a step's stdout from byte offset, returning the new
	// bytes (raw, ANSI intact) and whether stdout has finished. The pager polls
	// this until terminal. FetchStepStderr reads the step's full stderr once
	// stdout terminates (stdout always completes first).
	FetchStepStdout func(ctx context.Context, jobID uuid.UUID, execution, stepNum int, offset int64) (data []byte, terminal bool, err error)
	FetchStepStderr func(ctx context.Context, jobID uuid.UUID, execution, stepNum int) ([]byte, error)
	// FetchFailedTests lists a job's failed tests for the "failed tests" picker.
	// Each item carries the message shown in the pager when the test is picked.
	FetchFailedTests func(ctx context.Context, jobID uuid.UUID) ([]RunGetTestItem, error)
	// RenderRunSummary returns the run summary (all workflows) as markdown, shown
	// in an in-flow pager when "see all workflows" is chosen so esc returns to the
	// workflow picker rather than quitting the flow. When nil (or RenderMarkdown is
	// nil) the option instead quits with RunGetActionShowRun and the caller prints
	// the summary itself. RenderMarkdown renders the returned markdown.
	RenderRunSummary func(ctx context.Context, runID uuid.UUID) (string, error)
	// RenderWorkflowSummary is the counterpart for the "all jobs in workflow"
	// option: it returns the workflow summary (all jobs) as markdown, shown in an
	// in-flow pager whose esc returns to the job picker. When nil the option quits
	// with RunGetActionShowWorkflow instead.
	RenderWorkflowSummary func(ctx context.Context, workflowID uuid.UUID) (string, error)
	// RenderJobSummary returns the job report (the short per-job summary) as
	// markdown for the "job report" option, and RenderJobOutput the full per-step
	// output report for the "full job report" option. Both are shown in an in-flow
	// pager whose esc returns to whichever picker offered them (the execution
	// picker for a parallel job, else the step picker). When nil the option quits
	// with RunGetActionShowJob / RunGetActionShowJobOutput instead.
	RenderJobSummary func(ctx context.Context, jobID uuid.UUID) (string, error)
	RenderJobOutput  func(ctx context.Context, jobID uuid.UUID) (string, error)
	// FetchArtifacts lists a job's artifacts for the artifact browser. When nil the
	// "artifacts" option is not offered at all. FetchArtifactContent reads one
	// artifact for viewing in the pager, reporting whether it is displayable text
	// (the caller decides: it applies the size cap and the binary sniff, since it
	// owns the transport). DownloadArtifacts writes the given artifacts under dir,
	// preserving their paths; when nil the download key is not offered.
	// OpenArtifactURL opens an artifact's URL in a browser; when nil that key is
	// not offered either.
	//
	// The items handed to DownloadArtifacts carry the path the browser displayed
	// (which for a job with parallel executions includes the per-execution
	// directory), so what lands on disk mirrors what was on screen for any subset
	// of the job's artifacts.
	FetchArtifacts       func(ctx context.Context, jobID uuid.UUID) ([]RunGetArtifactItem, error)
	FetchArtifactContent func(ctx context.Context, item RunGetArtifactItem) (data []byte, text bool, err error)
	DownloadArtifacts    func(ctx context.Context, items []RunGetArtifactItem, dir string) error
	OpenArtifactURL      func(url string) error
	// RenderResourceUsage returns the job's CPU and memory usage report as
	// markdown for the "resource usage" option, paged in-flow like the summaries
	// above. When nil the option quits with RunGetActionShowResourceUsage
	// instead.
	RenderResourceUsage func(ctx context.Context, jobID uuid.UUID) (string, error)
	Color               bool
	// Animate reports whether the loading spinner should animate. Pass false when
	// CIRCLE_SPINNER_DISABLED is set (or the session is non-interactive) so the
	// loading line stays static instead of repainting.
	Animate bool

	// CurrentBranch is the branch the initial Runs were fetched for (or that
	// the initial scope-based fetch will target). When FetchRuns is non-nil
	// (project available), the picker offers branch scopes and optionally "my
	// runs". When FetchRuns is nil (no project), only the "my runs" scope is
	// available.
	CurrentBranch string
	// DefaultBranch is the project's default branch. When it differs from
	// CurrentBranch a second branch scope is added to the toggle cycle. When
	// empty or equal to CurrentBranch the extra scope is omitted.
	DefaultBranch string
	// FetchRuns lists runs for a branch. The status argument is the active
	// status filter ("" = every status). The created argument is the active
	// "Created" filter from the filter dialog.
	FetchRuns func(ctx context.Context, branch, status string, created RunCreatedFilter) ([]RunGetItem, error)
	// FetchMyRuns lists the authenticated user's recent runs across all projects
	// (the counterpart to "circleci my runs"). When set, the run picker's
	// shift+tab cycle gains a "my runs" scope that fetches via this callback
	// rather than by branch; when nil the scope is omitted. status and created are
	// the active status and created filters, as for FetchRuns.
	FetchMyRuns func(ctx context.Context, status string, created RunCreatedFilter) ([]RunGetItem, error)
	// InitialScope selects which scope the picker opens on. The default
	// (ScopeCurrentBranch) starts on the current branch. Use ScopeMyRuns to
	// open on the user's runs. When FetchRuns is nil, InitialScope is ignored
	// and "my runs" is the only available scope.
	InitialScope RunScopeKind
	// StatusFilters are the pipeline statuses the "s" key cycles through, in
	// order. The picker prepends an "all statuses" (no filter) entry, so pressing
	// "s" cycles no-filter → each status → back. When empty, the "s" action is
	// omitted.
	StatusFilters []RunStatusFilter

	// RenderMarkdown renders markdown as styled text wrapped to width columns,
	// backing the "?" keyboard-shortcut help overlay the pickers offer. The flow
	// supplies its own help markdown; the caller only provides the renderer (which
	// keeps the ui package decoupled from glamour). When nil, the "?" key is inert
	// and no help hint is shown.
	RenderMarkdown func(md string, width int) string
}

RunGetFlowOptions configures a RunGetFlowModel. The fetch callbacks keep this program decoupled from the API client: the caller supplies closures that return each level's items on demand. When Runs is nil the model fetches its own initial data on Init() based on InitialScope; when Runs is pre-populated the model starts directly on the run picker (useful for tests).

type RunGetItem

type RunGetItem struct {
	Label string
	Icon  string
	ID    uuid.UUID
	// Errors, set only for run rows, are the run's config/setup errors. When the
	// run is selected they are shown beneath the workflow picker's title so a run
	// that produced no workflows (e.g. a config that failed to compile) explains
	// itself rather than presenting an empty list.
	Errors []RunGetError
	// Pending, set only for job rows, names the status of a job that has not started
	// yet — "queued", "created" — and is empty once the job is running or finished.
	// Those states are the ones the glyph column conveys least well: they sit a
	// hollow or neutral dot away from the running one, and the API's own jobs list
	// reports a queued job as "started" until the CLI corrects it
	// (apiclient.effectiveJobPhase). Such a job also has no steps to pick from — it
	// opens straight into its job report — so the picker appends the status to the
	// label, making it unmistakable beside a running job before it is picked.
	Pending string
}

RunGetItem is one selectable row: a display label, an optional status symbol (uncolored — the flow colors it when color is enabled), and the UUID it maps to.

type RunGetResult

type RunGetResult struct {
	Action     RunGetAction
	RunID      uuid.UUID
	WorkflowID uuid.UUID
	JobID      uuid.UUID
	// Err is set when a mid-flow fetch (workflows, jobs or steps) failed; Action
	// is RunGetActionCancel in that case.
	Err error
}

RunGetResult is the outcome of a completed RunGetFlowModel run, read via Result() after tea.Program.Run() returns.

type RunGetStepItem

type RunGetStepItem struct {
	Label     string
	Icon      string
	Execution int
	StepNum   int
}

RunGetStepItem is one selectable job step. Steps have no UUID; they are addressed by their parallel-execution index and step number.

type RunGetTestItem

type RunGetTestItem struct {
	Label   string
	Icon    string
	Message string
}

RunGetTestItem is one selectable failed test: a display label, a status symbol, and the test's message shown in the pager when the row is picked.

type RunScopeKind

type RunScopeKind int

RunScopeKind identifies a scope for the run picker's initial selection.

const (
	// ScopeCurrentBranch starts the picker on the current branch (default).
	ScopeCurrentBranch RunScopeKind = iota
	// ScopeDefaultBranch starts the picker on the default branch.
	ScopeDefaultBranch
	// ScopeAllBranches starts the picker on the "all branches" scope.
	ScopeAllBranches
	// ScopeMyRuns starts the picker on the cross-project "my runs" scope.
	ScopeMyRuns
)

type RunStatusFilter

type RunStatusFilter struct {
	Value string // pipeline.status value
	Label string // title/footer wording, e.g. "failed", "needs approval"
	Icon  string // status glyph shown in the filter dialog's status list
}

RunStatusFilter is one selectable pipeline-status filter offered by the run picker's "s" key: the API pipeline.status value and the label shown to the user. The caller supplies the list (from apiclient status constants) so the ui package stays decoupled from the API client.

type RunWatchFlowModel added in v1.0.48614

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

RunWatchFlowModel is the bubbletea program behind `circleci run watch` in an interactive terminal: a live table of the run's workflows and their jobs, each row carrying a status glyph, redrawn in place as the run progresses.

It polls through the caller-supplied Fetch callback — first immediately, then on a widening interval — and ends itself when every workflow has reached a terminal phase, when --failfast trips on a failed job, or when the timeout elapses. r polls again straight away; q, esc and ctrl+c stop watching (the run itself keeps going). After Run() returns, read the outcome with Result(); the caller prints the final summary line and decides the exit code.

The program is deliberately inline rather than full-screen: the final frame is the completed table, and the caller's summary line prints directly beneath it.

func NewRunWatchFlow added in v1.0.48614

func NewRunWatchFlow(ctx context.Context, opts RunWatchFlowOptions) RunWatchFlowModel

NewRunWatchFlow returns a RunWatchFlowModel ready to pass to tea.NewProgram.

func (RunWatchFlowModel) Init added in v1.0.48614

func (m RunWatchFlowModel) Init() tea.Cmd

func (RunWatchFlowModel) Result added in v1.0.48614

func (m RunWatchFlowModel) Result() RunWatchResult

Result returns the final outcome. Only valid after tea.Program.Run() returns.

func (RunWatchFlowModel) Update added in v1.0.48614

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

func (RunWatchFlowModel) View added in v1.0.48614

func (m RunWatchFlowModel) View() tea.View

type RunWatchFlowOptions added in v1.0.48614

type RunWatchFlowOptions struct {
	RunID  uuid.UUID
	Branch string

	Color   bool
	Animate bool

	// FailFast ends the watch as soon as any job has failed, without waiting for
	// the rest of the run.
	FailFast bool

	// Timeout ends the watch once this much time has elapsed. Zero means no
	// timeout.
	Timeout time.Duration

	// PollInterval and MaxPollInterval override the default poll cadence. Zero
	// means RunWatchPollInterval / RunWatchMaxPollInterval.
	PollInterval    time.Duration
	MaxPollInterval time.Duration

	Fetch func(ctx context.Context) (RunWatchState, error)
}

RunWatchFlowOptions configures a RunWatchFlowModel. Fetch is the only required field: it returns the run's current state and is called once on start and then on every poll.

type RunWatchJob added in v1.0.48614

type RunWatchJob struct {
	ID     uuid.UUID
	Name   string
	Symbol string
	Status string
	Type   string
	Failed bool
}

RunWatchJob is one job row in the watch table. Symbol is the uncolored status glyph (the flow colors it when color is enabled) and Status the matching word, kept apart so the word can be padded into a fixed-width column without the glyph's width throwing the alignment off. Failed marks a job whose outcome is a failure, which is what --failfast trips on and what the final error's suggestions are built from.

type RunWatchResult added in v1.0.48614

type RunWatchResult struct {
	State     RunWatchState
	Elapsed   time.Duration
	Cancelled bool
	TimedOut  bool
	FailFast  bool
	Err       error
}

RunWatchResult is the outcome of a completed RunWatchFlowModel run, read via Result() after tea.Program.Run() returns. Exactly one of Cancelled, TimedOut, FailFast, Err or "the run finished" is true; in the last case State.Outcome says how it finished. State is always the most recent poll, so the caller can report failed jobs whichever way the flow ended.

type RunWatchState added in v1.0.48614

type RunWatchState struct {
	Workflows []RunWatchWorkflow
	Done      bool
	Outcome   string
}

RunWatchState is one poll's worth of run state: the rows to draw, whether every workflow has reached a terminal phase, and the run's derived display status once it has. Like the run-get item types this mirrors what the API client returns rather than embedding it, keeping this package independent of internal/apiclient — the caller's Fetch callback does the conversion.

func (RunWatchState) FailedJobs added in v1.0.48614

func (s RunWatchState) FailedJobs() []RunWatchJob

FailedJobs returns every job across every workflow whose outcome is a failure, in the order they appear in the table.

type RunWatchWorkflow added in v1.0.48614

type RunWatchWorkflow struct {
	Name     string
	Symbol   string
	Status   string
	Duration string
	Jobs     []RunWatchJob
}

RunWatchWorkflow is one workflow row and the job rows nested under it.

type TokenModel added in v1.0.47928

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

TokenModel collects a CircleCI personal access token. It lives here rather than in clikit/ui/components because it is not a reusable widget: the header copy and the CCIPAT_ placeholder (which also sets the input's width and char limit) are specific to CircleCI auth. It is a stage of the login flow.

func NewTokenModel added in v1.0.47928

func NewTokenModel() TokenModel

func (TokenModel) Init added in v1.0.47928

func (m TokenModel) Init() tea.Cmd

func (TokenModel) Token added in v1.0.47928

func (m TokenModel) Token() string

func (TokenModel) Update added in v1.0.47928

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

func (TokenModel) View added in v1.0.47928

func (m TokenModel) View() tea.View

Jump to

Keyboard shortcuts

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