Skip to content

spawn list: no colour off-TTY, show TTL remaining; add --version (#898) - #900

Merged
scttfrdmn merged 2 commits into
mainfrom
fix/898
Oct 15, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
fix/898

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes

1. ANSI colour escapes when stdout isn't a TTY. The only colour code in cmd/ (spawn list's state cells and bold group headings) checked --no-color/--accessibility and nothing else, so spawn list | cat wrote raw \x1b[32m. Colour is now decided in one place, cmd/color.go colorEnabled(). It is off for --no-color/--accessibility, a non-empty NO_COLOR, TERM=dumb, or a stdout that isn't a terminal (golang.org/x/term, already in the module graph, now a direct dependency). --no-color still works.

2. The TTL column showed the configured TTL. It now shows the time left before the termination deadline. The deadline is resolved with lifecycleDeadline, the same function spawn status uses: the spawn:ttl-deadline tag, which spawn extend moves, else launch time + TTL. The issue's case (--ttl 1h, 7 minutes old) now reads 53m. The column shows none when there is no TTL, expired once the deadline has passed, and - for a terminated instance.
-o json: ttl keeps its meaning (the configured TTL). It gains ttl_deadline (RFC3339 UTC, or "") and ttl_remaining_seconds (null when there is no deadline or the instance is terminated, 0 once the deadline has passed).

3. spawn --version (Refs spore-host/truffle#189) was rejected as an unknown flag. rootCmd.Version is now set and the version template is the same block spawn version prints, shared through versionText(). The flag skips the network update check. -v is still --verbose.

Tests (each watched failing against a revert that compiles)

  • TestColorAllowed: flag, NO_COLOR, empty NO_COLOR, TERM=dumb, pipe vs terminal. Fails when the NO_COLOR, TERM=dumb or terminal check is removed.
  • TestColorizeStateOffTTYHasNoEscapes and TestSectionHeadingsOffTTYHaveNoEscapes: the reported symptom in list's own output. Fails when the decision goes back to flag-only, and when the terminal check is ignored. TestNoColorFlagStillWins checks the flag on a terminal.
  • TestColorDecisionIsCentral: discovers cmd/*.go and fails if anything other than root.go (declaration) or color.go reads flagNoColor. Fails when a direct read is added to list.go.
  • TestTTLRemaining: the issue's 53m case, the launch+TTL fallback, an extended tag beating launch+TTL, none, expired, stopped, terminated. Fails when the column goes back to inst.TTL, and when the deadline tag is ignored.
  • TestListJSONKeepsConfiguredTTL: fails if ttl changes meaning. Also checks the new fields.
  • TestRootVersionFlagMatchesVersionCommand: fails when rootCmd.Version is removed.

make check passes except TestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker in pkg/taskproto. That test needs a Docker daemon, none was running locally, and this PR doesn't touch it. No AWS resources were created.

Caveat

The column header still says "TTL". Its text lives in spore-host/libs i18n (spawn.list.header.ttl, six locales), so renaming it to "TTL LEFT" needs a libs release. That's left as a follow-up.

Fixes #898
Refs spore-host/truffle#189

@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.47619% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/list.go 91.37% 4 Missing and 1 partial ⚠️
cmd/color.go 83.33% 2 Missing ⚠️
cmd/version.go 92.85% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

scttfrdmn added a commit to spore-host/libs that referenced this pull request Oct 15, 2026
spawn list now shows the time left before the termination deadline in
the TTL column (spore-host/spawn#900), so a bare "TTL" header reads as
the configured TTL. spawn.list.header.ttl becomes "TTL Left" (en),
"Rest-TTL" (de), "TTL restante" (es), "TTL restant" (fr),
"TTL Restante" (pt) and "残りTTL" (ja), following each locale's
existing header casing. Message ID unchanged.

Fixes #54
Colour is decided in one place (cmd/color.go colorEnabled): off for
--no-color/--accessibility, NO_COLOR, TERM=dumb, or a non-terminal stdout.
The list TTL column shows time left before the deadline spawn status uses
(spawn:ttl-deadline, else launch + TTL); -o json keeps ttl and adds
ttl_deadline and ttl_remaining_seconds. spawn --version prints the same
block as spawn version (Refs spore-host/truffle#189).

Fixes #898
@scttfrdmn
scttfrdmn merged commit 2421bfd into main Oct 15, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/898 branch October 15, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spawn list: ANSI colour codes when stdout isn't a TTY; TTL column shows the configured TTL, not time remaining

1 participant