Repository navigation
Report program status to the terminal with OSC 7501 - #1040
Conversation
Send OSC 7501 program status reports to stderr so terminals can show whether bk is working, waiting on the user, or finished. Spinners report working, confirmations and prompts report blocked, and bk build watch reports job progress then done or error when the build finishes. Reports are only sent when stderr is a terminal outside CI, and BUILDKITE_PROGRAM_STATUS=true|false overrides that. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-e8ace642-180b-4cd2-a865-21662f7a18ca
mcncl
left a comment
There was a problem hiding this comment.
Really keen on testing this out and seeing how we might get clearer feedback to bk callers 🚀
There was a problem hiding this comment.
Want to dig deeper?
Paste this into your agent to explore the findings from this review's Buildkite build:
Download the buildsworth logs from build 41566, then answer my questions about the findings.
Install the reading-buildsworth-logs skill to run this.
About buildsworth
Model: gpt-6.1-sol with xhigh thinking.
How to request a review: Comment @buildsworth-bk review on the PR, or request buildsworth-bk as a reviewer.
Risk labels (how buildsworth classifies risk) — buildsworth classifies risk itself from the diff. Unless repository policy already allows L2 approval, grant it by mentioning @buildsworth-bk (see approval ceiling and L2 approval grant):
- L1 — Low risk (dep bumps, docs/copy, lockfiles, small presentational fixes). buildsworth may approve by default.
- L2 — Standard risk (new UI, additive API fields, refactors). Approved only when repository policy or a verified grant allows it; otherwise comment-only.
- L3 — High risk (auth, migrations, payments, secrets, perf-critical pipeline paths). Human approval required unless repository policy explicitly allows L3 approval; per-PR grants cannot allow it.
Distinguish the watch's own timeout from repeated poll request timeouts by checking the command context instead of the error, which wraps context.DeadlineExceeded in both cases. Report idle or error when build resolution fails too, not only when polling stops. Drop broken jobs from the finished count: watchJobs removes them first. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-e8ace642-180b-4cd2-a865-21662f7a18ca
Superseded by a newer Buildsworth review.
There was a problem hiding this comment.
The earlier polling-timeout feedback is addressed; no new findings.
Want to dig deeper?
Paste this into your agent to explore the findings from this review's Buildkite build:
Download the buildsworth logs from build 41572, then answer my questions about the findings.
Install the reading-buildsworth-logs skill to run this.
Description
OSC 7501 is a draft terminal protocol for a program to tell the terminal what it is doing: working (with progress), blocked on the user, done, or failed. Terminals and agent harnesses can show that state, such as a spinner on a background tab or a "needs you" marker, instead of guessing from output.
This adopts it in
bkso we can dogfood the spec and get feedback on whether it is useful from the CLI. It starts with the shared spinner and prompt helpers and withbk build watch, the main long-running command.bk preflight,bk auth loginand downloads can follow.The sequences come from
ansi.SetProgramStatusingithub.com/charmbracelet/x/ansiv0.11.9, whichbkalready depends on, so there is no new dependency.Reports go to stderr, so piped stdout is unaffected. They are only sent when stderr is a terminal,
TERMis notdumb, and neitherCInorBUILDKITEis set. Agents run jobs in a PTY, so a terminal check alone would put these sequences in job logs.BUILDKITE_PROGRAM_STATUS=true|falseoverrides the detection.Changes
internal/programstatuspackage that tags every report withapp=bk. It is process-wide because terminal records belong to the process andPromptForOnehas no factory.SpinWhilereportsworkingwith the spinner text.Confirmreportsblocked kind=permission.PromptForOneandPromptForInputreportblocked kind=question. Once answered, the previous status is restored.bk build watchreportsworkingwith progress from finished script jobs (retried and non-script jobs excluded), thendonewhen the build finishes, orerrorif it failed or was canceled. A--timeoutreportsidle, since the build keeps running.Quick commands do not leave a
donerecord behind; terminals dropworkingrecords when the process exits. Reports are still sent with--quietbecause they are not shown as output.Testing
go test ./...)go fmt ./...)I also ran the built binary in a PTY against a fake REST API, with stdout redirected to a file:
working0% → 50% → 75% →done"widgets #429 passed"error"widgets #429 failed"--timeout=1500msworking0% → 50% →idleCI=trueorBUILDKITE_PROGRAM_STATUS=falsebk maintainer delete, answerednblocked kind=permission→workingNot yet tried in a terminal that renders OSC 7501.