runs

package
v0.1.16-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SpinnerFrames = []string{"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"}

SpinnerFrames defines deterministic spinner glyph order for running states.

Functions

func ColoredStatusGlyph

func ColoredStatusGlyph(status string, spinnerFrame int) string

ColoredStatusGlyph returns status glyphs with semantic colors.

func DeriveRunStateFromReport

func DeriveRunStateFromReport(report RunStatusReport) migsapi.RunState

DeriveRunStateFromReport computes terminal run state from repo statuses.

func FormatDurationCompact

func FormatDurationCompact(durationMs int64) string

FormatDurationCompact renders duration_ms in status-report compact form.

func FormatDurationForStatus

func FormatDurationForStatus(status string, durationMs int64, startedAt, finishedAt *time.Time, now time.Time) string

FormatDurationForStatus renders status-aware duration text. Terminal jobs are always rendered in seconds; non-terminal jobs keep millisecond-or-elapsed behavior.

func FormatDurationMsOrElapsed

func FormatDurationMsOrElapsed(durationMs int64, startedAt, finishedAt *time.Time, now time.Time) string

FormatDurationMsOrElapsed renders duration for follow-mode rows. It prefers duration_ms; otherwise falls back to timestamps.

func FormatErrorOneLiner

func FormatErrorOneLiner(lastErr *string) string

FormatErrorOneLiner normalizes a multi-line error to a single readable line.

func FormatNodeID

func FormatNodeID(nodeID *domaintypes.NodeID) string

FormatNodeID renders node ID values with the shared placeholder semantics.

func RenderFollowFrameText

func RenderFollowFrameText(frame FollowFrame) (string, int)

RenderFollowFrameText renders a reusable follow-style text frame and line count.

func RenderRunSBOM

func RenderRunSBOM(w io.Writer, result RunSBOMResult) error

func RenderRunStatusReportJSON

func RenderRunStatusReportJSON(w io.Writer, report RunStatusReport) error

RenderRunStatusReportJSON renders the canonical run status report payload as JSON.

func RenderRunStatusReportText

func RenderRunStatusReportText(w io.Writer, report RunStatusReport, opts TextRenderOptions) error

RenderRunStatusReportText renders a one-shot, follow-style run snapshot.

func RenderRunStatusSnapshotText

func RenderRunStatusSnapshotText(w io.Writer, report RunStatusReport, opts TextRenderOptions) error

RenderRunStatusSnapshotText renders a static status snapshot using the same output shape as `ploy run status`.

func RenderSBOMDiff

func RenderSBOMDiff(w io.Writer, packages []migsapi.RunSBOMDiffPackage) error

func StatusGlyph

func StatusGlyph(status string, spinnerFrame int) string

StatusGlyph maps a status to a deterministic display glyph.

Types

type CancelCommand

type CancelCommand struct {
	Client  *http.Client
	BaseURL *url.URL
	RunID   domaintypes.RunID
	Reason  string
	Output  io.Writer
}

CancelCommand requests cancellation for a run.

func (CancelCommand) Run

func (c CancelCommand) Run(ctx context.Context) error

Run executes the cancel request (POST /v1/runs/{id}/cancel).

type FollowDynamicSection

type FollowDynamicSection struct {
	StartLine int
	LineCount int
	Text      string
}

FollowDynamicSection describes one mutable line block in a rendered follow frame.

type FollowFrame

type FollowFrame struct {
	Repos []FollowRepoFrame
}

FollowFrame is a reusable follow-style text frame.

type FollowFrameRender

type FollowFrameRender struct {
	Text      string
	LineCount int
	Sections  []FollowDynamicSection
}

FollowFrameRender is the rendered follow frame with dynamic section metadata.

func RenderFollowFrameTextLayout

func RenderFollowFrameTextLayout(frame FollowFrame) FollowFrameRender

RenderFollowFrameTextLayout renders a follow frame plus per-repo dynamic section metadata.

type FollowRepoFrame

type FollowRepoFrame struct {
	HeaderLine string
	Columns    []string
	Rows       []FollowStepRow
	EmptyLine  string
}

FollowRepoFrame is one repo block inside a follow-style frame.

type FollowRunCommand

type FollowRunCommand struct {
	Client          *http.Client
	BaseURL         *url.URL
	RunID           domaintypes.RunID
	Output          io.Writer
	EnableOSC8      bool
	AuthToken       string
	SpecDisplayName string
	MaxRetries      int
	PollInterval    time.Duration
}

FollowRunCommand drives `run --follow` rendering with Bubble Tea v2.

func (FollowRunCommand) Run

Run executes follow-mode rendering until the run reaches a terminal state.

type FollowStepRow

type FollowStepRow struct {
	Cells        []string
	ExitOneLiner string
	DetailLines  []string
}

FollowStepRow is one row in a repo table, with optional second-line summary.

type GetRunSBOMCommand

type GetRunSBOMCommand struct {
	Client  *http.Client
	BaseURL *url.URL
	RunID   domaintypes.RunID
	View    string
}

func (GetRunSBOMCommand) Run

type GetRunStatusReportCommand

type GetRunStatusReportCommand struct {
	Client  *http.Client
	BaseURL *url.URL
	RunID   domaintypes.RunID
}

GetRunStatusReportCommand builds the canonical RunStatusReport payload for a run.

func (GetRunStatusReportCommand) Run

Run assembles run summary, mig identity, run job rows, and links.

type GetStatusCommand

type GetStatusCommand struct {
	Client  *http.Client
	BaseURL *url.URL
	RunID   domaintypes.RunID
}

GetStatusCommand retrieves detailed status for a single run using the run summary view (ID, repo refs, repo counts).

func (GetStatusCommand) Run

Run executes GET /v1/runs/{id} and returns the run domaintypes.RunSummary.

type ListRunDiffsCommand

type ListRunDiffsCommand struct {
	Client  *http.Client
	BaseURL *url.URL
	RunID   domaintypes.RunID
}

ListRunDiffsCommand fetches the diff listing for a run. It returns structured data suitable for machine consumption (e.g., TUI).

func (ListRunDiffsCommand) Run

Run executes GET /v1/runs/{run_id}/diffs and returns structured diffs.

type ListRunDiffsResult

type ListRunDiffsResult struct {
	Diffs []RunDiffEntry
}

ListRunDiffsResult is the response from ListRunDiffsCommand.

type ListRunJobsCommand

type ListRunJobsCommand struct {
	Client  *http.Client
	BaseURL *url.URL
	RunID   domaintypes.RunID
	Attempt *int32 // Optional: specific attempt
}

ListRunJobsCommand fetches jobs for a run execution.

func (ListRunJobsCommand) Run

Run executes GET /v1/runs/{run_id}/jobs.

type ListRunJobsResult

type ListRunJobsResult = migsapi.ListRunJobsResponse

ListRunJobsResult contains the response from listing run jobs.

type RestartCommand

type RestartCommand struct {
	Client  *http.Client
	BaseURL *url.URL
	RunID   domaintypes.RunID
}

RestartCommand requests a new attempt for a terminal run.

func (RestartCommand) Run

type RunDiffEntry

type RunDiffEntry struct {
	ID        domaintypes.DiffID      `json:"id"`
	JobID     domaintypes.JobID       `json:"job_id"`
	CreatedAt time.Time               `json:"created_at"`
	Size      int                     `json:"gzipped_size"`
	Summary   domaintypes.DiffSummary `json:"summary,omitempty"`
}

RunDiffEntry is a single diff item from the run diffs listing.

type RunDiffsCommand

type RunDiffsCommand struct {
	Client  *http.Client
	BaseURL *url.URL
	RunID   domaintypes.RunID // Run ID (KSUID-backed)
	Output  io.Writer

	Download bool   // when true, download newest diff and print to stdout (gunzipped)
	SavePath string // optional path to save the gunzipped patch
}

RunDiffsCommand lists diffs for a specific run and optionally downloads the newest patch.

func (RunDiffsCommand) Run

func (c RunDiffsCommand) Run(ctx context.Context) error

Run executes the command.

type RunEntry

type RunEntry struct {
	RepoID          domaintypes.RepoID    `json:"repo_id"`
	RepoURL         string                `json:"repo_url"`
	BaseRef         string                `json:"base_ref"`
	SourceCommitSHA string                `json:"source_commit_sha,omitempty"`
	Attempt         int32                 `json:"attempt"`
	Status          domaintypes.RunStatus `json:"status"`
	LastError       *string               `json:"last_error,omitempty"`
	PatchURL        string                `json:"patch_url,omitempty"`
	Jobs            []RunJobEntry         `json:"jobs"`
}

RunEntry captures repo-level status, job graph data, and report links for a single repo attempt.

type RunJobArtifact

type RunJobArtifact struct {
	Name      string `json:"name"`
	CID       string `json:"cid"`
	LookupURL string `json:"lookup_url,omitempty"`
}

RunJobArtifact is the per-job artifact view emitted by run status JSON. It includes the CID plus a lookup URL that resolves artifact bundle metadata.

type RunJobDetailEntry

type RunJobDetailEntry = migsapi.RunJob

type RunJobEntry

type RunJobEntry struct {
	JobID       domaintypes.JobID     `json:"job_id"`
	JobType     domaintypes.JobType   `json:"job_type"`
	JobImage    string                `json:"job_image"`
	NodeID      *domaintypes.NodeID   `json:"node_id,omitempty"`
	Status      domaintypes.JobStatus `json:"status"`
	ExitCode    *int32                `json:"exit_code,omitempty"`
	StartedAt   *time.Time            `json:"started_at,omitempty"`
	FinishedAt  *time.Time            `json:"finished_at,omitempty"`
	DurationMs  int64                 `json:"duration_ms"`
	DisplayName string                `json:"display_name,omitempty"`
	BugSummary  string                `json:"bug_summary,omitempty"`
	Artifacts   []RunJobArtifact      `json:"artifacts,omitempty"`
	JobLogURL   string                `json:"job_log_url,omitempty"`
	PatchURL    string                `json:"patch_url,omitempty"`
}

RunJobEntry is one row in the follow-style job graph.

type RunJobIOPreview

type RunJobIOPreview struct {
	Stdout []string
	Stderr []string
}

RunJobIOPreview contains bounded stdout/stderr previews for a single job.

type RunSBOMResult

type RunSBOMResult struct {
	RunID        domaintypes.RunID
	View         string
	Packages     []migsapi.RunSBOMPackage
	DiffPackages []migsapi.RunSBOMDiffPackage
}

type RunStatusReport

type RunStatusReport struct {
	RunID       domaintypes.RunID            `json:"run_id"`
	MigID       domaintypes.MigID            `json:"mig_id"`
	MigName     string                       `json:"mig_name"`
	SpecID      domaintypes.SpecID           `json:"spec_id"`
	Repos       []RunEntry                   `json:"repos"`
	WaitingRuns int                          `json:"waiting_runs,omitempty"`
	SBOMDiff    []migsapi.RunSBOMDiffPackage `json:"sbom_diff,omitempty"`
}

RunStatusReport is the canonical status report contract shared by all status renderers.

type RunStatusReportDynamicSection

type RunStatusReportDynamicSection struct {
	StartLine int
	LineCount int
	Text      string
}

RunStatusReportDynamicSection represents one mutable block of lines in rendered run text.

type RunStatusReportTextLayout

type RunStatusReportTextLayout struct {
	Text            string
	LineCount       int
	DynamicSections []RunStatusReportDynamicSection
}

RunStatusReportTextLayout is a rendered run status report with per-repo mutable sections.

func RenderRunStatusReportTextLayout

func RenderRunStatusReportTextLayout(report RunStatusReport, opts TextRenderOptions) (RunStatusReportTextLayout, error)

RenderRunStatusReportTextLayout renders run status report text plus mutable per-repo row sections.

type TextRenderOptions

type TextRenderOptions struct {
	EnableOSC8         bool
	AuthToken          string
	BaseURL            *url.URL
	SpinnerFrame       int
	LiveDurations      bool
	Now                time.Time
	JobIOPreviews      map[domaintypes.JobID]RunJobIOPreview
	ExpandStdout       bool
	ExpandStderr       bool
	FilterRunningRepos bool
	EmptyReposLine     string
	SpecDisplayName    string
}

TextRenderOptions controls optional features for the text report renderer.

Jump to

Keyboard shortcuts

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