view

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package view is the dashboard's model: one account's row, and every cell a human table renders it into.

It exists so that a renderer outside package cli can exist at all. Package cli exports nine identifiers and none of them is a row, so a second renderer would have had to spell every percentage, every reset span and every "could not be read" a second time — and the two spellings would agree until the day one of them changed. That `ccdad status` and the terminal dashboard can never disagree is a property of there being ONE of each of these, not of two of them being written carefully.

Nothing here reads the clock, the filesystem or the environment. A Row is built from documents somebody else read.

Index

Constants

View Source
const HeaderBudget = 10

HeaderBudget is the widest a window header may be, in display columns.

A scoped cap's display name is arbitrary wire text and the whole name is worse: `weekly_scoped:model:Fable` is 25 columns against a dashboard cell that reserves 20, and nothing between the cell and the terminal cut it, so the overflow came off the right where other columns live.

View Source
const NoQuantity = "-"

NoQuantity is what a cell renders when the quantity does not exist here, as against Unreadable's "somebody tried to read it and could not". The two are different verdicts and both appear in one rendered row: an account with no cached reading has an unknown percentage and no window to name, so its USED cell is "?" and its WINDOW cell is "-". Collapsing them would tell a reader that a quantity which cannot exist merely went unread, and send them looking for the reading.

View Source
const PlaceholderHeader = "QUOTA"

PlaceholderHeader is the one quota column a table shows when no visible row carried a readable window.

The block is never omitted. A table that simply stopped having quota columns would look like a build with no quota feature rather than like a fleet nobody could read, and the cells under this header are all Unreadable, which is the honest statement.

View Source
const Unreadable = "?"

Unreadable is what a value that could not be read renders as. Never "0%" -- unknown is never read as zero, and cswap's version of that bug parked its engine on the account that reset last, because one expired token made every account look empty.

Variables

This section is empty.

Functions

func ActiveLine added in v0.11.0

func ActiveLine(claude, codex string) string

ActiveLine is who this machine is spending, in one sentence.

It is a free function as well as a method because `ccdad which` has no Snapshot to build and must produce the identical line: two spellings of one sentence is how two commands come to describe one machine two ways, which is the failure this whole package exists to prevent.

With no codex account it is the Claude label ALONE, unlabelled. That is not a degradation -- it is the answer every reader and every script had before there was a second provider, and prefixing it with "Claude:" on a machine with one provider would be labelling a distinction that does not exist there.

func CompactRunwayLines added in v0.12.0

func CompactRunwayLines(f forecast.Fleet, now time.Time, loc *time.Location) []string

CompactRunwayLines is the terminal dashboard's vertical runway summary. The command-line status keeps RunwayLine's compact horizontal form; a full-screen page gives each axis and each supporting fact a row of its own.

func CompactTimestamp added in v0.12.0

func CompactTimestamp(t time.Time, loc *time.Location) string

CompactTimestamp is the dashboard's narrow absolute date: YYMMDD hh:mm. The dashboard is local and interactive, so its space budget wins over the zone suffix retained by the command-line and JSON forms.

func CurrentLine added in v0.12.0

func CurrentLine(m strategy.Mode) string

CurrentLine is the ranking mode currently in force. Recovery is the one a user needs told: the columns are identical to the ordinary case, so nothing else on the dashboard distinguishes "the engine is ranking by soonest reset because everything is spent" from "the engine has nothing to do".

The value begins after the `Current:` label and two spaces. No branch may contain the substring "exhaust": the human table keeps the projection to --json, and a mode line that used the word would put it back on the page the projection was kept off.

TestNoCurrentLineBranchSaysExhausted is what makes that red. It asks the question twice -- by rendering every mode this binary declares plus one it has never heard of, and by reading the branches below as source, so a case written for a mode nothing yet passes in is covered too -- and it pins the branch count, because a line added to a block without the test that covers the block growing with it is how this rule came to be held by prose.

func DaemonLine

func DaemonLine(report daemon.Report, now time.Time) string

DaemonLine is the liveness line `ccdad status` prints at the top of the dashboard. It is one of TWO wordings this repository ships, and the other is DescribeRunning below. They are not merged: this one leads a nine-column label field that the Active: and Current: lines below it line up with, and the other is a fragment that reads as the tail of a sentence.

The default arm is DaemonUnknown and every future value. "Cannot tell" is never folded into "no": a supervisor gating on that folding respawns forever on a filesystem where locks do not work.

func DescribeRunning

func DescribeRunning(report daemon.Report, now time.Time) string

DescribeRunning is the one-line human form of a live daemon. now is a parameter rather than a call because nothing in this package reads a clock; package cli passes timeNow(), which is what the old body called.

func HumanDuration

func HumanDuration(d time.Duration) string

HumanDuration renders a span at the scale a reader cares about. A reset already behind us is "due" rather than a negative number: the endpoint has not rolled the window over yet, which is a real state and not a clock error.

func RunwayAccounts added in v0.7.0

func RunwayAccounts(f forecast.Fleet) string

RunwayAccounts is the seat-count line under the axis block: how many accounts the run had to work with, how many it would take to survive the horizon at the measured rate, and the difference between the two.

It answers the axis block's question from the other end. The rows above say how much is left and when it runs out; this says how many seats it would take for it not to. Both come from the same runs, so a reader can never be told "runs dry" and "you have enough accounts" on adjacent lines.

The parenthetical is the actionable half and is present exactly when there is something to act on: a fleet already sitting on the smallest count that holds gets the count and nothing after it. The gap before it is two spaces, matching the dry moments in the block above, which a reader scans down the same column.

An unmeasured count is Unreadable and never NoQuantity. Every fleet has a smallest size that holds -- supply is linear in the seat count and burn is not a function of the fleet -- so the number exists and what failed was the measuring. NoQuantity would say there is no such number and stop a reader looking for the history that produces it.

A fleet with no usable accounts gets no line at all. "0 usable, ? needed" is a sentence about a fleet the rotation cannot reach, and the basis line above it already carries how many accounts there are and why none of them counted.

func RunwayBurn added in v0.7.0

func RunwayBurn(b forecast.Band) string

RunwayBurn is a measured consumption rate, in percentage points per hour.

Low is what is printed and High is not: the upper bound is what a claim of "holds" had to survive, so it belongs to the verdict cell rather than to this one, and printing an interval in a column that is meant to be added up would make the column unaddable.

A band that cleared no gate is Unreadable and never 0.0. A measured zero, on the other hand, IS a reading -- the account was up, was polled, and did not burn -- and one live login at a time means most per-account rows carry one.

func RunwayCreditBasis added in v0.10.0

func RunwayCreditBasis(c forecast.CreditFleet) string

RunwayCreditBasis is what the credit row was measured from, as a sentence: the money, the span it was spent over, and how many readings carried it.

The window axes have had a basis line since they existed and the credit row has never had one, which was survivable only while no credit rate had ever been measured. The first one that was is the reason this exists: a dry date a decade out, correctly computed, from two cents. A reader cannot weigh that from the date, and the row has room for the one sentence that lets them.

It is empty for a refused figure, and the caller prints nothing rather than a sentence about a measurement that did not happen. There is no singular arm for the reading count because minSamples is three and creditSpend refuses below it, so "1 reading" is a state no figure reaching here can be in.

func RunwayCreditBurn added in v0.7.0

func RunwayCreditBurn(c forecast.CreditFleet) string

RunwayCreditBurn is the fleet's paid spend, in the currency's major unit per hour with the code beside it. Money's own width, because the unit is money; the code, because amounts in two currencies do not add and a bare figure invites a reader to add them anyway. creditRate is where the width is decided, and why it is not always two decimals.

A figure that could not be assembled is Unreadable, never zero. Every way it can fail -- mixed currencies, an uncapped account that is spending, no measured spend at all -- is a reason to say nothing rather than to report a fleet spending nothing, which would lengthen a runway made of money.

func RunwayCreditReplenish added in v0.7.0

func RunwayCreditReplenish() string

RunwayCreditReplenish is the credit row's replenishment cell, and it is a function taking nothing because the answer never varies: the endpoint reports no renewal boundary for paid usage, so there is no quantity here to read. That is NoQuantity and not Unreadable -- a reader told "?" would go looking for a renewal rate that does not exist.

func RunwayCreditVerdict added in v0.7.0

func RunwayCreditVerdict(c forecast.CreditFleet, now time.Time, loc *time.Location) string

RunwayCreditVerdict is when the fleet's paid balance reaches zero, or Unreadable when the figure was refused.

It means something different from the two window rows above it and the command says so in prose beside the block: those ask whether resets replenish faster than the fleet spends, and this is a balance divided by a rate with nothing coming back.

func RunwayEmpty added in v0.7.0

func RunwayEmpty(r forecast.AccountRow, now time.Time, loc *time.Location) string

RunwayEmpty is when the simulation first found one account out.

"now" comes first, ahead of any recorded moment, because it is a fact about this minute rather than a projection: an account that is out already must not be rendered as a date the reader could decide to wait for.

An account the run never found out is Unreadable. The run declining to empty an account is not the run promising it survives -- the axis may simply have held, or the band may have decided nothing.

func RunwayLeft added in v0.7.0

func RunwayLeft(pct float64) string

RunwayLeft is how much of an account's binding window is left, in percentage points and bare. No percent sign: the column is headed LEFT, it is summed into the fleet's points on the line above the table, and a percentage there would be read against the wrong window -- the one the account is REPORTED on elsewhere is not always this one.

func RunwayLine added in v0.7.0

func RunwayLine(f forecast.Fleet, now time.Time, loc *time.Location) string

RunwayLine is the one-line summary `ccdad status` renders. The dashboard uses the same verdict helpers in CompactRunwayLines.

It returns "" when there is nothing to say, and that empty string is load bearing: it is how both renderers know not to print a line at all, which is what keeps the dashboard's byte-compared golden fixtures from moving on a machine with no history behind it. A fleet with no basis gets no line, not a line saying it holds -- a promise resting on no reading is the one output this whole measurement exists to refuse.

The line carries VERDICTS, not rates. A rate is per axis, two of them do not fit a line that also has to carry the answer, and the number a dashboard owes a reader is when rather than how fast. It also carries no percentage, which is not a style choice: `ccdad status`'s human output is asserted to contain no "0%", "20%", "30m", "ahead" or "five_hour" anywhere, because each is a figure belonging to a window its table is not reporting.

The fleet run -- both axes burning at once -- appears only when it CONTRADICTS the two axes, which it can: it burns more windows and has more ways to end, so it can run dry, or run out of agreement between its two bands, while each axis alone holds. Printing it on every line would put a third verdict on a summary that already carries two and that agrees with them on every ordinary fleet; leaving it out when it disagrees would let "holds on both axes" stand over a fleet the arithmetic says empties.

A fleet that cannot hold also carries how many accounts would -- see RunwayNeedSegment for why only that fleet does.

func RunwayNeedSegment added in v0.7.0

func RunwayNeedSegment(f forecast.Fleet) string

RunwayNeedSegment is the seat count as one clause of RunwayLine, and it is carried only by a fleet that is SHORT.

A fleet that holds already has its answer in the word "holds", and the slack it has on top of that is a block-level figure rather than a dashboard one: the summary line is read at a glance beside Daemon:, Active: and Current:, and a clause spent on good news is a clause the short case needed. The full form, spare count and all, is in RunwayAccounts.

The parenthetical here is one space, not the two RunwayAccounts uses. The clauses of this line are already held apart by their own separator, and a second wide gap inside one of them would read as a third clause.

RunwayLine's both-axes-hold branch does not call this, and it does not need to: a fleet whose runs all hold was answered by a search counting downward, so its count is at most its usable seats. A fleet that claimed both -- holding and short -- would be a contradiction the run cannot produce, and printing both halves of it on one line is not an improvement on printing one.

func RunwayReplenish added in v0.7.0

func RunwayReplenish(perHour float64) string

RunwayReplenish is what an axis gives back, in percentage points per hour. It always exists for a window axis: an axis with no accounts replenishes at zero, which is a true statement about an empty fleet rather than a reading nobody could take.

func RunwayRowCells added in v0.7.0

func RunwayRowCells(r forecast.AccountRow) (window, left, burn string)

RunwayRowCells is one account row's three weekly cells -- the window its points are counted on, the room left in it, and this account's own measured burn -- rendered together because they stand or fall together.

An account whose response carried no weekly window at all gets NoQuantity in all three and not Unreadable. Nothing failed to be read: the account was read, and this quantity does not exist for it. Borrowing its five-hour window instead would put a five-hour room and a five-hour rate into a column that is summed into the weekly axis above it, and those are two different quantities.

func RunwayVerdict added in v0.7.0

func RunwayVerdict(a forecast.Axis, now time.Time, loc *time.Location) string

RunwayVerdict is an axis's answer as a cell: whether the fleet holds at the measured rate, and when it does not, the moment it empties.

An undecided axis renders Unreadable rather than either answer. The two runs of the band disagreeing means the evidence does not carry a claim, and both "holds" and a date would be claims.

func RunwayWrap added in v0.8.0

func RunwayWrap(label, line string, width int) string

RunwayWrap folds the runway line onto width display columns, breaking only at its own separators and hanging every line after the first under the first clause.

A width of zero means the caller does not know one -- a pipe, a redirect, the buffer a test renders into -- and returns the line exactly as it was joined, byte for byte. That is the case every non-terminal writer takes, and it is what keeps this function out of the way of everything that reads the output as data.

The width arrives as a PARAMETER for the reason the zone does: nothing in this package may read the environment, and the terminal is environment. The caller nearest the reader measures it.

Clauses are atomic. A clause wider than the room gets its own line and is allowed to overflow rather than be cut, because this line ends in an absolute moment and a span: `2026-08-26 08:1` reads as a shorter date, not as a line that did not fit. The dashboard cuts because a page has a right edge it cannot spend; a scrollback has one it can. That is the whole of why these two renderers of one wording answer this differently, and it is not drift.

Every width here is a display column count. The separator is U+00B7 -- one column, two bytes -- so a byte count is wrong by the number of separators on the line, which is the number that grows as the line gets longer.

func StrategyLine added in v0.12.0

func StrategyLine(name string) string

StrategyLine describes the one policy selected through `ccdad strategy`.

func ThresholdsFor

func ThresholdsFor(cfg config.Config, now time.Time, plan strategy.Plan, planErr error) (
	resolve func(uuid string) strategy.Thresholds, notices []string)

ThresholdsFor returns notices alongside the resolver so both CLI and TUI callers can publish them through the output channel they own.

The plan is read only when hover is on; with hover off it is ignored entirely, including its error.

func Timestamp added in v0.7.0

func Timestamp(t time.Time, loc *time.Location) string

Timestamp is the one absolute-time rendering in this repository, and the zone is always in it. The two human-facing absolute formats that came before it carry neither a date nor a zone: internal/cli/hover.go's clock is "15:04", and internal/switcher/evaluate.go's Explain uses time.Kitchen. Both are fine for a moment inside the hour and useless for a runway that names one days out. Every remaining .Format in the tree is RFC 3339 or the daemon log's millisecond variant of it, which are machine formats and not an answer here. It lives in internal/view so the runway command, status, list and the dashboard spell one layout once rather than four times.

The zone is not optional, and it is not read here. The arithmetic that produces these moments must not touch the environment, so the location arrives as a parameter. A nil location falls back to UTC rather than to time.Local: a caller that passed none has not told us its zone, and time.Local would print a confidently wrong hour on any machine whose TZ is not the reader's -- including CI, where nothing sets it.

func UpdateLine added in v0.9.0

func UpdateLine(report daemon.Report, running string) (string, bool)

UpdateLine is the release line `ccdad status` prints under the daemon line and the terminal dashboard prints under its liveness block.

The daemon publishes what it SAW -- a version string -- and never a verdict, so the comparison happens here, against the version of the binary doing the reading. That is not a preference: upgrading replaces the binary while the old daemon keeps publishing, so a boolean computed by a 0.6.1 daemon would tell a 0.7.0 CLI to upgrade to what it is already running.

It is SILENT -- ok false -- for every reading it cannot turn into that sentence: no published document, nothing recorded, a recorded release that does not parse, a running version that does not parse (every `dev` build, so every build a developer makes), or a release that is not newer. A line that says nothing useful under a dashboard people read every day is worse than no line.

func WindowHeader added in v0.11.0

func WindowHeader(n usage.WindowName) string

WindowHeader is the short name a column carries.

The wire key stays the vocabulary -- it is what `ccdad config` and `--json` use -- and the legend under the table maps one to the other, so shortening here costs a reader nothing they cannot look up two lines down.

func WrapLabeled added in v0.8.0

func WrapLabeled(line string, width int) string

WrapLabeled folds one line of the labelled block -- Daemon:, Active:, Strategy:, Current: -- onto width display columns, breaking at spaces and hanging every line after the first under the value.

Current's recovery explanation is wider than an 80-column terminal, so an unwrapped line folds wherever its own right edge falls -- mid-word or mid-clause.

It is a SEPARATE function from RunwayWrap, and the difference is not duplication. These lines are prose and break at spaces; the runway line is a row of values whose spaces are inside them, and a break at the one in `2026-08-26 08:19 KST` would produce a date that is not a date. Each knows where its own line may be cut, and neither may be pointed at the other's. What they share is the hanging alignment, which is `hang` below.

The label is found rather than passed, because these lines arrive with it already spelled: the block's contract is a name, a colon, and padding to nine columns, and that is what this looks for. A line with no colon has no label and no indent, which is the honest rendering of a line this block did not produce.

A width of zero -- every writer that is not a terminal -- returns the line exactly as its builder spelled it, and so does a terminal too narrow to hold the label, where there is no room to hang anything in.

Types

type Columns added in v0.11.0

type Columns struct {
	Windows []WindowColumn
	Resets  []ResetColumn
}

Columns is the whole quota block: the window columns and the reset columns they point into.

func ColumnsOf added in v0.11.0

func ColumnsOf(rows []Row) Columns

ColumnsOf builds the block for a set of rows.

MEMBERSHIP is the union, over the visible rows, of every window each row actually carries. That is exactly the set `ccdad status --json` has published since it was written -- it walks the same windows and skips the absent ones -- so the human tables gain no new source here. They stop a derivation that threw away all but one of a set they already had.

cinder_cove can never appear and needs no filter: it is left out of the snapshot's own window list on purpose, because its reset is an EXPIRY rather than a rollover, so a countdown under a header meaning "rolls over in" would be counting down to a deletion.

func (Columns) Headers added in v0.11.0

func (c Columns) Headers() []string

Headers is the quota block's header row: one per window, then one per rollover. Both CLI tables and the dashboard call this rather than each assembling the same slice, which is what stops one of them growing a column the others do not have.

func (Columns) Legend added in v0.11.0

func (c Columns) Legend() string

Legend maps every header back to the wire key it stands for.

It is the only place a human table still shows the key `ccdad config` takes a threshold on, which is what a full-name window column used to buy -- at the price of being one column naming one window per row.

func (Columns) Names added in v0.11.0

func (c Columns) Names() []usage.WindowName

Names is every window column's wire key, in column order.

func (Columns) Unranked added in v0.11.0

func (c Columns) Unranked() []usage.WindowName

Unranked is the columns the engine does not bind on.

func (Columns) UnrankedNote added in v0.11.0

func (c Columns) UnrankedNote() string

UnrankedNote is the sentence for a column carrying real quota nothing switches away from, or empty when every column ranks.

It names the hand edit and NOT `ccdad config set`, deliberately: the setter refuses exactly these names while the loader carries them, so advice to run it would send the reader into the binary's own refusal.

type Exec

type Exec func(argv []string) (code int, stdout, stderr string)

Exec runs one ccdad command through a FRESH cobra root and reports what it wrote and what it exited with. It is a function value declared in this leaf package because internal/cli must import internal/tui to register a command, so internal/tui must never import internal/cli. internal/mcpsrv takes the identical seam.

type ResetColumn added in v0.11.0

type ResetColumn struct {
	Header  string
	Windows []usage.WindowName
}

ResetColumn is one rollover, shared by every window that rolls with it.

type Row

type Row struct {
	Account  store.Account
	Active   bool
	Entry    usage.Entry
	HasEntry bool
	Headroom strategy.Headroom
	// Thresholds is the bundle this row was MEASURED against, kept so a cell can
	// be coloured against the same numbers.
	//
	// It is resolved once in Rows and handed to HeadroomOrCredit from this
	// field, so the bundle a cell reads and the bundle the row was ranked on
	// are one object by construction rather than two calls that agree until the
	// day one of them moves. Under hover that matters twice over: the table is
	// derived per account and per window, so a second resolution could hand a
	// cell a number no part of this row was measured with.
	Thresholds strategy.Thresholds
	Pace       map[usage.WindowName]usage.Pace
	Engine     daemon.AccountStatus
}

Row is one account with everything the dashboard knows about it, from each field's one authoritative source.

func Rows

func Rows(accounts []store.Account, cache *usage.Cache, active store.Account,
	hasActive bool, now time.Time, thresholds func(uuid string) strategy.Thresholds) []Row

Rows pairs every account with its cached reading.

Both status forms and the dashboard build their rows through this: one cache, read one way, into one shape. Separate renderers deriving headroom for themselves would agree until the day one of them changed.

Engine state is deliberately NOT filled in here. It comes from status.json, the daemon's own document, and loadSnapshot joins it after building rows.

func (Row) AgeLabel

func (r Row) AgeLabel(now time.Time) string

AgeLabel is how old this account's reading is.

func (Row) CarriedWindows added in v0.11.0

func (r Row) CarriedWindows() []usage.NamedWindow

CarriedWindows is every window this row's reading actually carries, in wire order, plus the credit meter when it reported a percentage.

The Present filter is load-bearing rather than tidiness. Snapshot's fixed Claude keys are listed unconditionally, so an unfiltered walk hands every Claude fleet five columns with three of them null on every row forever.

func (Row) Cells added in v0.11.0

func (r Row) Cells(c Columns, now time.Time) []string

Cells is one row's quota block, in Headers' own order and always the same length, so a caller can append it between its own fixed columns.

func (Row) CreditLine added in v0.11.0

func (r Row) CreditLine() (string, bool)

CreditLine is the money sentence for a seat metered in credits, which no percentage column can carry.

A balance beats a percentage here: "795.23/2000.00 used, 1204.77 left (USD)" is what a person deciding whether to top up needs, and 40% is not.

func (Row) Empty added in v0.8.0

func (r Row) Empty() (empty, known bool)

func (Row) HoverCells added in v0.12.0

func (r Row) HoverCells(c Columns, now time.Time) []string

HoverCells is Cells with each quota cell expanded to used/threshold. The reset cells are unchanged. It lets unified status carry the extra figure the former hover-specific report existed to show.

func (Row) ListLabel

func (r Row) ListLabel() string

ListLabel is both the address and the handle, which is NOT Account.Label(): that one returns the alias alone, and the dashboard is where a user learns which alias belongs to which address.

func (Row) Marker

func (r Row) Marker() string

Marker is the active-row marker printed in front of the IDX column.

func (Row) Reported

func (r Row) Reported() (usage.NamedWindow, bool)

Reported resolves ReportedName to the window itself, together with when it rolls over. It is what the USED, WINDOW, RESETS IN and PACE columns all read, so they always describe the same window.

The Known check is redundant TODAY and is kept deliberately: with no window reporting a utilization, strategy leaves both names as the empty WindowName and the loop below matches nothing anyway. A mutation removing it survives for exactly that reason. It stays because the alternative is for this function's correctness to rest on an invariant of another package's zero value.

func (Row) ReportedName

func (r Row) ReportedName() usage.WindowName

ReportedName is the window this account is REPORTED against, which is not always the one it is ordered on.

A tripped WEEKLY cap wins, because it is the one that will not come back for days: an account whose five-hour window rolls over in eight minutes is still unusable until Friday, and naming the five-hour window would tell the user to wait eight minutes for it. Ordering still runs on Headroom.Slack, which is the tightest window whichever family it belongs to, so this rule moves no account in the ordinary order. It is not inert in RECOVERY order: what an account has to wait out is the weekly floor, so the same field decides whether it counts as returning inside the horizon.

func (Row) ResetCell added in v0.11.0

func (r Row) ResetCell(c ResetColumn, now time.Time) string

ResetCell is one countdown, for the group a column points into.

func (Row) StatusFlags

func (r Row) StatusFlags() string

StatusFlags is the suffix `ccdad status` prints after the age column. An account may carry more than one flag, so they are joined in one suffix.

func (Row) StatusLabel

func (r Row) StatusLabel() string

func (Row) TierLabel

func (r Row) TierLabel() string

func (Row) TypeLabel

func (r Row) TypeLabel() string

TypeLabel is what the TYPE column says about an account.

It is shared by status and the dashboard because it cannot be derived from Kind alone. Every ChatGPT plan is a subscription, so a codex row rendered from Kind would say "subscription" -- true, and useless: it would be the word on every codex row and on most of the Claude rows beside them, distinguishing nothing. What a reader needs in that column is which side of the machine the row belongs to, because that is what decides which command moves it.

Status and the dashboard both call this rather than formatting Kind themselves. Two renderers formatting one value two ways is the exact failure package view exists to remove.

func (Row) WindowCell added in v0.11.0

func (r Row) WindowCell(n usage.WindowName) string

WindowCell is one quota cell: the percentage USED.

Used and not left, so that 100% means the same thing in every cell of the table and the eye can scan a row for the number that stops it. The polarity is stated once, here, and the header row says nothing about it.

func (Row) WindowPct added in v0.11.0

func (r Row) WindowPct(n usage.WindowName) (float64, WindowState)

WindowPct is this row's utilization of one window, and why there is no number when there is none.

func (Row) WindowReset added in v0.11.0

func (r Row) WindowReset(n usage.WindowName) (time.Time, bool)

WindowReset is when one window rolls over.

func (Row) WindowThreshold added in v0.12.0

func (r Row) WindowThreshold(n usage.WindowName) float64

WindowThreshold returns the threshold for the exact displayed axis. Credit has its own fail-closed threshold and must not fall through to the ordinary window default merely because it shares the table with quota windows.

type Snapshot

type Snapshot struct {
	Now         time.Time
	Rows        []Row
	Report      daemon.Report
	ActiveLabel string // "work@example.com (work)", or "none of the managed accounts"
	// CodexServingLabel is the account ccdad's codex proxy serves new threads
	// from, or "" when there is no pointer or it names no stored account.
	//
	// EMPTY IS LOAD-BEARING. It is what keeps every surface rendering the exact
	// bytes it rendered before codex existed on a machine that has no codex
	// account -- seven byte-compared dashboard pages among them.
	CodexServingLabel string
	// CodexServingUUID is the same account's key, for the --json payloads. A
	// label is for a person and a uuid is what a script keys on, and deriving
	// one from the other at the payload builder would be a second lookup of a
	// pointer this snapshot has already read.
	CodexServingUUID string
	Strategy         string // the selected policy: hover, manual, headroom or consume-first
	Hover            bool   // compatibility storage for the hover policy
	// Manual is compatibility storage for the manual policy. The selected
	// strategy remains explicit so a healthy ranking under manual cannot look
	// like a broken engine.
	Manual      bool
	Mode        strategy.Mode
	HasMode     bool
	Version     string   // buildinfo.String()'s first field, or a test constant
	Notices     []string // everything cli would have written to stderr
	UnknownKeys []string // unrecognised top-level credential keys retained by the store

	// Forecast is the measured burn and what it implies, and HasForecast is
	// whether one could be produced at all.
	//
	// The pair is a tri-state and not a nilable pointer, for the reason the
	// fields above it are: a dashboard reads this struct and must never be able
	// to dereference its way into a panic on a machine that has been recording
	// for ten minutes. HasForecast false is "no measurement", never "a fleet
	// burning nothing" -- the zero Fleet's verdicts are all VerdictUnknown, so
	// a renderer that ignored the flag would still print no promise.
	//
	// Package cli computes it, as it computes everything else here, so the same
	// value reaches the dashboard and the command line and no number is derived
	// in two places.
	Forecast    forecast.Fleet
	HasForecast bool
}

Snapshot is one complete read of the documents a dashboard renders. Package cli builds it — it owns the attribution probe and the notice stream — and package tui only reads it, so no number is derived in two places.

func (Snapshot) ActiveLine added in v0.11.0

func (s Snapshot) ActiveLine() string

ActiveLine is this snapshot's.

func (Snapshot) StrategyLabel added in v0.7.0

func (s Snapshot) StrategyLabel() string

StrategyLabel is the single user-facing switching policy. New snapshots already carry that value in Strategy; the boolean fallback keeps snapshots built by older callers and tests truthful during an in-process upgrade.

type WindowColumn added in v0.11.0

type WindowColumn struct {
	// Name is the wire key. It is the key `ccdad config` takes a per-window
	// threshold on and the key `--json` files the window under, so a reader who
	// moves between the table and either of those reads one vocabulary.
	Name usage.WindowName
	// Header is short, and unique within its Columns by construction.
	Header string
	// Reset indexes Columns.Resets, or -1 when no visible row reported a
	// rollover for this window.
	Reset int
	// Ranked is whether the engine binds on this window without being asked.
	// A window it does not rank can sit at 100% with nothing switching away
	// from it, and a column that did not say so would be a lie by omission.
	Ranked bool
}

WindowColumn is one quota column.

type WindowState added in v0.11.0

type WindowState int

WindowState is why a cell says what it says. The three are kept apart because they are three different facts and one of them is a bug if it is guessed.

const (
	// WindowAbsent: the reading does not carry this window at all. Rendered
	// "-". It is a statement about the ACCOUNT -- a Codex seat has no
	// five-hour window and never will -- and it is only ever said about a
	// reading somebody actually took.
	WindowAbsent WindowState = iota
	// WindowUnreadable: nothing was read, or the window was carried and
	// reported no utilization. Rendered Unreadable.
	//
	// Never "-" and never "0%". An account nobody could read is not an account
	// with a fresh window, and cswap's engine parked itself permanently on
	// exactly that confusion. Present-with-null is a real shape on the wire --
	// a freshly reset window reports {"utilization":null,"resets_at":null} and
	// still HAS the window -- so the two absences are not the same absence.
	WindowUnreadable
	// WindowRead: a utilization came back.
	WindowRead
)

Jump to

Keyboard shortcuts

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