Build App (Preview) / compute-version (pull_request) Successful in 7s
Build Container / build-container (pull_request) Successful in 2m53s
Build App (Preview) / create-release (pull_request) Successful in 5s
Build App (Preview) / build-macos (pull_request) Successful in 2m37s
Build App (Preview) / build-windows (pull_request) Successful in 6m2s
Build App (Preview) / build-linux (pull_request) Successful in 6m53s
Build App (Preview) / prune-previews (pull_request) Successful in 2s
A run is detached — cron has no terminal, and the app fires it as a detached exec — so triggering one and watching the log was indistinguishable from triggering one that died. Worse, `claude -p` writes its answer in a single burst at the end, so a healthy run shows nothing but its log header for as long as it is thinking. The honest reading of the old UI was "it stalled". triple-c-task-runner now publishes a state file per run (pid, start time, log path) and removes it from an EXIT trap. flock remains what actually prevents overlapping runs; this is purely observability, so every reader verifies the pid rather than trusting the file — a container stopped mid-run cannot fire a trap, and a task stuck on "running" forever would be a worse lie than no indicator at all. Stale files are cleared on read. On top of that: - `list` grows a status column: "running 4m12s" or "idle". - `status [--id] [--watch]` answers "is it still going?" directly, with elapsed time and the tail of the log when there is any output yet. - `run` streams the log instead of blocking silently, and refuses to start a task that is already running. - The Automation tab marks a running task, disables its Run now button, and polls while anything is in flight — including the second or two between firing a run and the runner registering it, which is the exact window that used to read as dead. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
55 lines
2.2 KiB
TypeScript
55 lines
2.2 KiB
TypeScript
/** Shared formatting helpers for the Project Home views. */
|
|
|
|
export function formatBytes(bytes: number): string {
|
|
if (bytes < 1024) return `${bytes} B`;
|
|
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
}
|
|
|
|
/** "2h ago" / "3d ago". Returns null for unparseable timestamps. */
|
|
export function formatAge(iso: string | null | undefined): string | null {
|
|
if (!iso) return null;
|
|
const then = Date.parse(iso);
|
|
if (Number.isNaN(then)) return null;
|
|
return formatElapsed(Date.now() - then);
|
|
}
|
|
|
|
export function formatElapsed(ms: number): string {
|
|
const seconds = Math.max(0, Math.floor(ms / 1000));
|
|
if (seconds < 60) return "just now";
|
|
const minutes = Math.floor(seconds / 60);
|
|
if (minutes < 60) return `${minutes}m ago`;
|
|
const hours = Math.floor(minutes / 60);
|
|
if (hours < 24) return `${hours}h ${minutes % 60}m ago`;
|
|
const days = Math.floor(hours / 24);
|
|
return `${days}d ago`;
|
|
}
|
|
|
|
/** "for 42s" / "for 4m" / "for 1h 12m" — elapsed phrasing for a run in flight.
|
|
* Seconds are kept below a minute because the first thing anyone wants from a
|
|
* freshly triggered run is evidence that it started at all. */
|
|
export function formatRunningFor(iso: string | null | undefined): string | null {
|
|
if (!iso) return null;
|
|
const started = Date.parse(iso);
|
|
if (Number.isNaN(started)) return null;
|
|
const seconds = Math.max(0, Math.floor((Date.now() - started) / 1000));
|
|
if (seconds < 60) return `for ${seconds}s`;
|
|
const minutes = Math.floor(seconds / 60);
|
|
if (minutes < 60) return `for ${minutes}m`;
|
|
const hours = Math.floor(minutes / 60);
|
|
return `for ${hours}h ${minutes % 60}m`;
|
|
}
|
|
|
|
/** Uptime phrasing for a known start timestamp. */
|
|
export function formatUptime(startedAtMs: number | undefined): string | null {
|
|
if (startedAtMs === undefined) return null;
|
|
const seconds = Math.floor((Date.now() - startedAtMs) / 1000);
|
|
if (seconds < 60) return "just started";
|
|
const minutes = Math.floor(seconds / 60);
|
|
if (minutes < 60) return `up ${minutes}m`;
|
|
const hours = Math.floor(minutes / 60);
|
|
if (hours < 24) return `up ${hours}h ${minutes % 60}m`;
|
|
return `up ${Math.floor(hours / 24)}d`;
|
|
}
|