feat(setup): switch elapsed-time suffixes to "Xm Ys" past 60s
Adds a `fmtDuration(ms)` helper in `setup/lib/theme.ts` that returns
`47s` under a minute and `1m 34s` from 60s onward, then routes every
elapsed-time spinner suffix in the setup flow through it. Replaces
the inline `Math.round((Date.now() - start) / 1000)` + `(${elapsed}s)`
pattern at every site.
Format is consistent past 60s — `1m 0s` over `1m` — so the live
spinner doesn't change shape at every whole-minute crossing.
Sites updated: setup/auto.ts, setup/lib/{runner,tz-from-claude,
claude-assist}.ts, and setup/channels/{signal,whatsapp,telegram,
discord,slack}.ts. Pre-allocated suffix budgets in `fitToWidth`
calls bumped from `' (999s)'` to `' (99m 59s)'` so long-running
steps don't blow past the reserved width.
This commit is contained in:
@@ -51,6 +51,22 @@ export function accentGreen(s: string): string {
|
||||
return k.green(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format an elapsed-time duration (in milliseconds) for the spinner
|
||||
* suffixes setup writes everywhere. Sub-minute durations stay in plain
|
||||
* seconds (`47s`); once the timer crosses 60 seconds we switch to the
|
||||
* `Xm Ys` form (`2m 34s`) so a long step doesn't read as `247s` or
|
||||
* similar. The format is consistent above 60s — `4m 0s` over `4m` —
|
||||
* so live spinner output doesn't change shape at every whole minute.
|
||||
*/
|
||||
export function fmtDuration(ms: number): string {
|
||||
const totalSec = Math.round(ms / 1000);
|
||||
if (totalSec < 60) return `${totalSec}s`;
|
||||
const m = Math.floor(totalSec / 60);
|
||||
const s = totalSec % 60;
|
||||
return `${m}m ${s}s`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Brand body color for setup-flow prose. Used for card bodies (via the
|
||||
* `note()` formatter) and `p.log.*` body arguments — anywhere the
|
||||
|
||||
Reference in New Issue
Block a user