Skip to content

feat: long-running commands report progress on stderr - #6672

Merged
janicduplessis merged 3 commits into
mainfrom
feat/6669-command-progress
Nov 29, 2026
Merged

janicduplessis merged 3 commits into
mainfrom
feat/6669-command-progress

Conversation

@janicduplessis

@janicduplessis janicduplessis commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Description

An acting stim gc runs on this home's stimd. Until now the client heard only the actions the pass took. Between the request and the first action (measuring pressure, finding checkouts, sizing caches, planning) it printed nothing. With a few hundred registered projects that silence can last minutes, and a slow run looks hung. stim engine install|use|update and stim remote update were also silent while they fetched, self-tested or waited.

Maintainer decisions, quoted on #6669:

  • "I feel like any command that can take long time should report some progress"
  • "Brief and agent friendly like build"

Solution

Progress reuses the format native builds already print: phaseLine(label, text) from command-output.ts, through gc's existing phase() helper. It is one line per phase plus a summary line, always on stderr, in JSON mode too. There is no TTY gate (an agent's stderr is never a TTY), no spinner and no carriage-return redraw.

gc (acting).

  • runMaintenanceAtLevel takes an optional onPhase. Only runGcPass passes it, so --dry-run, --refresh and the storage report print exactly what they printed before.
  • The phases are level, discover, measure, plan (with the action count), dormant and ladder. A final gc finished: N actions taken, X freed[, F failed] in T line closes the run. The client prints one gc line before it asks stimd.
  • Transport: stimd sends the pass's stderr lines as gc.output beside gc.action. The client opts in with progress: true on gc.run.
    • An older client would fail the request on an op it does not expect, so stimd never sends progress unasked.
    • An older stimd ignores the field, and the client then prints only its own line plus the action lines.
  • The lines fan out through the pass's listeners in disk-owner.ts. A request that joins a pass already under way hears the lines from the point it joined, after one gc joining a pass already under way ... line. A tick or lane pass prints none.
  • Phase lines that already existed inside the pass (worktree checks, Gradle and watchman probes) now reach the client too. Before, they went only to stimd's own log, and they still go there.
  • The existing per-action lines (done|failed|kept <kind> <target>) are unchanged. kept rows are already one per plan skip. Collapsing them into a count is left out of this PR.

engine install/use/update print engine fetching stim X from npm (or which directory or packages they add) and engine checking and self-testing stim X. The second line prints in the calling process before it hands the new build its own engine-select, whose stderr runFileAsync captures. remote update prints one line when it starts waiting on the remote machine, which can take up to 10 minutes.

Rule. AGENTS.md invariant 7 gains the rule, and the new LLP 0030 holds it with both quotes and the gc transport design. The facts guide topic (the output streams contract) and website/docs/commands.md get two short sentences each. Guide budgets are unchanged.

Overlap with #6623 / #6625. Both PRs also touch commands/gc.ts, daemon/client.ts, stimd/main.ts, stimd/threads.ts, guide/facts.ts and website/docs/commands.md. This PR changes only a few lines in each:

  • gc.ts: the acting pass's onPhase, its summary and one client line.
  • client.ts: the progress opt-in, and gc.output accepted for non-headroom requests.
  • main.ts: one argument.
  • threads.ts: an optional output argument, plus wrapping the pass operation's output.

Nothing touches the report, --dry-run, --refresh, stimd/gc-report.ts, DesktopReports or the report cache.

Audit: commands that can run long

command progress before this PR
ios, android yes: phase lines per step (cache, plan, build compiling / ok, device, install, launch); silent during the compile itself unchanged
macos partial: placement lines only not changed
start partial: metro start, lan, final lines; silent while waiting for Metro not changed
stop yes: one phase line per teardown step unchanged
worktree add / warm partial: lock, checkout, deps, pods, carry lines, each printed after its step not changed
worktree remove partial: lock wait, cleanup lines, removed not changed
test yes: plan, slot wait, exit unchanged
revive yes, through start/ios/android unchanged
ci yes: relays the child run's lines unchanged
setup yes, its own step printer (on stdout, stderr with --json) not changed
doctor no on a plain run (report at the end); --fix prints phase lines not changed
gc (acting) partial: one line per action, nothing while the pass measured and planned phase lines from the stimd pass, client line, summary
gc --dry-run partial: report/worktrees/daemons lines unchanged (out of scope, #6623/#6625)
engine install/use/update/rollback no fetch and self-test lines
remote update no (polls up to 10 min) one wait line
share no not changed
services start partial: slot wait, outcomes at the end not changed
device provision partial: plan lines, plain text not changed
remote add no not changed
plugin test no not changed
service install no (server package, stdout lines at the end) not changed
stats no not changed

The rows marked "not changed" with no or partial progress are follow-ups under the same rule. This PR does the gc acting run that #6669 names first, plus the two silent commands with an obvious seam.

Test plan

  • stimd-gc.integration.test.ts, new case: a real stimd runs an acting gc --json. Stdout holds exactly one parseable payload, and stderr carries a measure phase line that only the stimd pass prints. With the stimd hook disabled, the case fails.
  • stimd-gc.integration.test.ts, second new case: a raw gc.run without progress gets gc.done and no gc.output, so an older client never sees a message it would fail on. With the stimd guard removed, the case fails.
  • gc-queue.test.ts: a request that joins a pass under way hears the join line and the pass's progress line, and its action listener still sees only actions.
  • pnpm test on the gc, engine-store, remote-update, api-reports and disk-owner tests; the guide and guide-budget tests; pnpm run typecheck; oxlint; oxfmt --check; scripts/ref-check.mjs.
  • Manual run against a private scratch STIM_HOME (its own HOME and engine root, one registered fixture cache, after a dry run showed nothing outside that home was in scope): stim gc --pressure critical and stim gc --pressure critical --json. Output is in the first comment.

Fixes #6669

An acting gc streams the stimd pass's phase lines to every request on the pass, engine install/use/update and remote update print their slow steps, and LLP 0030 records the rule. Fixes #6669.
@janicduplessis janicduplessis added area: cli packages/stim-cli, including its README and guide area: website website/ area: docs docs/ and root documents labels Nov 29, 2026
@janicduplessis

Copy link
Copy Markdown
Collaborator Author

Sample: stim gc --pressure critical --json against a private scratch STIM_HOME (own HOME and engine root, one registered fixture cache). Stdout was one line that parses as the payload (mode: delete, level: critical). Stderr:

  gc          asking this home's stimd to run an acting pass
  level       measuring disk and memory pressure
  level       running at critical
  discover    finding checkouts under the managed folders
  measure     measuring caches, build outputs and owned devices
  plan        1 action planned
  kept        keep devices
  kept        keep Gradle daemons and versions
  kept        trim-cache fixture <scratch-home>/cache
  dormant     reducing workspaces idle past their dormant period
  ladder      running the pressure ladder to critical
  done        empty-cache <scratch-home>/cache
  kept        empty-cache /var/folders/48/lz49lr110ylfj2d84_6yhklc0000gn/T
  kept        empty-cache /private/var/folders/48/lz49lr110ylfj2d84_6yhklc0000gn/T/jest_dx
  gc          finished: 1 action taken, 0K freed in 2s

@janicduplessis
janicduplessis marked this pull request as ready for review November 29, 2026 03:10
@janicduplessis janicduplessis added the review: ai-approved A fresh AI review found nothing left to fix label Nov 29, 2026
@janicduplessis
janicduplessis enabled auto-merge (squash) November 29, 2026 03:11
@janicduplessis
janicduplessis merged commit 63e1eff into main Nov 29, 2026
59 of 60 checks passed
@janicduplessis
janicduplessis deleted the feat/6669-command-progress branch November 29, 2026 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli packages/stim-cli, including its README and guide area: docs docs/ and root documents area: website website/ review: ai-approved A fresh AI review found nothing left to fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Long-running commands report progress

1 participant