Commit e7ea4be
committed
feat: add buildStreamingCommand + migrate log/list follow to generator
Add streaming command infrastructure and convert the log/list --follow
path from a callback/timer-based polling loop to an async generator
that yields typed LogStreamChunk values.
New infrastructure (src/lib/streaming-command.ts):
- StreamingOutputConfig<TChunk>: human + jsonLine formatters
- drainStreamingOutput(): iterates generator, writes to stdout
- Human mode: passes through pre-rendered text chunks
- JSON mode: JSONL with array expansion (one line per log)
- buildStreamingCommand(): full command builder for purely streaming
commands (e.g., auth/login). Generator receives StreamingContext
with banner(), cwd, env, setContext, json — no stdout/stderr.
- abortableSleep(): resolves on AbortSignal for clean shutdown
log/list follow-mode migration:
- executeFollowMode (callback+timer) → generateFollowLogs (async gen)
- FollowConfig (stdout/stderr) → FollowGeneratorConfig (onDiagnostic)
- writeLogs helper eliminated — rendering done inside generator via
yieldBatch() sub-generator and renderLogRows() pure function
- SIGINT handling: AbortController + abortableSleep replaces
setTimeout/clearTimeout with stopped flag
- Banner extracted to writeFollowBanner() helper
Non-follow paths unchanged — still return CommandOutput<LogListResult>
with JSON array output.1 parent fb38a16 commit e7ea4be
2 files changed
+555
-164
lines changed
0 commit comments