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:
@@ -17,7 +17,7 @@ import * as p from '@clack/prompts';
|
||||
import k from 'kleur';
|
||||
|
||||
import { isValidTimezone } from '../../src/timezone.js';
|
||||
import { fitToWidth } from './theme.js';
|
||||
import { fitToWidth, fmtDuration } from './theme.js';
|
||||
|
||||
export function claudeCliAvailable(): boolean {
|
||||
try {
|
||||
@@ -44,18 +44,16 @@ export async function resolveTimezoneViaClaude(
|
||||
const s = p.spinner();
|
||||
const start = Date.now();
|
||||
const label = 'Looking up that timezone…';
|
||||
s.start(fitToWidth(label, ' (999s)'));
|
||||
s.start(fitToWidth(label, ' (99m 59s)'));
|
||||
const tick = setInterval(() => {
|
||||
const elapsed = Math.round((Date.now() - start) / 1000);
|
||||
const suffix = ` (${elapsed}s)`;
|
||||
const suffix = ` (${fmtDuration(Date.now() - start)})`;
|
||||
s.message(`${fitToWidth(label, suffix)}${k.dim(suffix)}`);
|
||||
}, 1000);
|
||||
|
||||
const reply = await queryClaude(prompt);
|
||||
|
||||
clearInterval(tick);
|
||||
const elapsed = Math.round((Date.now() - start) / 1000);
|
||||
const suffix = ` (${elapsed}s)`;
|
||||
const suffix = ` (${fmtDuration(Date.now() - start)})`;
|
||||
|
||||
const resolved = reply ? extractTimezone(reply) : null;
|
||||
if (resolved) {
|
||||
|
||||
Reference in New Issue
Block a user