feat(terminal): enhance terminal task rendering with progress, lifecycle helpers, and configurable output modes

This commit is contained in:
2026-05-13 18:33:06 +00:00
parent c07b2969b8
commit 502cca375f
6 changed files with 507 additions and 124 deletions
+16 -5
View File
@@ -75,20 +75,19 @@ demo help
## Terminal Task Rendering
Use `SmartcliTerminal` for long-running jobs that should render cleanly in both interactive and non-interactive environments. In a TTY, active tasks render below each other with a fixed row count. In CI, pipes, Docker logs, or `TERM=dumb`, the same calls become append-only log lines.
Use `SmartcliTerminal` for long-running jobs that should render cleanly in both interactive and non-interactive environments. In a TTY, active tasks render below each other with a fixed row count, colored status symbols, and elapsed time. In CI, pipes, Docker logs, or `TERM=dumb`, the same calls become throttled append-only lifecycle logs.
```ts
import { SmartcliTerminal } from '@push.rocks/smartcli';
const terminal = new SmartcliTerminal();
const buildTask = terminal.createTask({
job: 'Build package',
const buildTask = terminal.task('Build package', {
rows: 3,
});
buildTask.update('Installing dependencies');
buildTask.log('Running tsbuild');
buildTask.setProgress(1, 2, 'Running tsbuild');
buildTask.complete('Build finished');
const publishTask = terminal.createProcess({
@@ -104,7 +103,19 @@ try {
}
```
Completed tasks collapse into a permanent `[ok]` line. Failed tasks collapse into a permanent `[err]` line with error details. If an error should remain visible inside the live task area, use `attachError(error, { keepOpen: true })`.
Completed tasks collapse into one permanent success line. Failed tasks collapse into one permanent failure line with error details. If an error should remain visible inside the live task area, use `attachError(error, { keepOpen: true })`.
For scoped work, `task.run()` completes or fails automatically:
```ts
await terminal.task('Generate assets').run(async (task) => {
task.setProgress(1, 3, 'Reading source files');
await readSourceFiles();
task.setProgress(2, 3, 'Rendering assets');
await renderAssets();
task.setProgress(3, 3, 'Writing output');
}, { successMessage: 'Assets generated' });
```
## Execution Model