Redraws one status line in place while work runs, then erases it so scrollback stays clean. Methods no-op off a TTY so captured logs stay untouched. Reuse for CLI progress indicators.
// Source: https://github.com/trailhq/Trail-Code | License: MIT | Copyright 2026 Context Graph Engine contributors
// Provided via justclaw.it.com; keep this notice with the code.
/**
* One line that redraws in place while something runs, and is erased when it
* stops — so nothing interactive is left in the scrollback.
*
* Only on a TTY. Anywhere else every method is a no-op, and the caller prints
* whatever finished lines it wants a log to keep.
*/
const FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
export interface Spinner {
/** Change the text after the frame. */
update(text: string): void;
/** Print a finished line above the spinner, which keeps spinning below it. */
print(line: string): void;
/** Erase the line and stop. Safe to call more than once. */
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key