Skip to content

feat(progress): add an opt-in live terminal dashboard for review and scan runs - #1781

Open
SaahiilM wants to merge 26 commits into
alibaba:mainfrom
SaahiilM:feat/live-progress-dashboard
Open

SaahiilM wants to merge 26 commits into
alibaba:mainfrom
SaahiilM:feat/live-progress-dashboard

Conversation

@SaahiilM

@SaahiilM SaahiilM commented Oct 20, 2026 •

Copy link
Copy Markdown

Description

ocr review and ocr scan print a wall of [ocr] progress lines during a run.
On a real 487-file scan that is hundreds of lines, none of which answer "which
file is it on right now", and a run can spend minutes inside one blocking LLM
call showing nothing at all.

With --tui on an interactive terminal this replaces those lines with a live
dashboard: header, progress bar, counters, a plan line carrying the run's
estimated cost, one row per unit of concurrent work, and a scrolling activity
log. Without --tui the run keeps printing the plain [ocr] progress lines, so
piping, CI, and --format json/sarif output stays byte-for-byte unchanged.

Where the dashboard lives, and why

The Bubble Tea program moved out of internal/progress and into
cmd/opencodereview, next to provider_tui.go. Upstream already keeps its
terminal UI in the command layer and nowhere else — before this restructure the
repository's only charm.land imports outside cmd/ were the ones this PR
introduced, which is a convention worth keeping rather than breaking in the
first patch that adds a second terminal UI. An early commit in this branch has
the renderer in internal/progress; a later one moves it.

The split that follows from it:

  • internal/progress owns the event stream and the plain [ocr] text sink.
    It is what six internal packages publish to, and it stays free of any UI
    framework.
  • cmd/opencodereview owns the dashboard: the model, the view, the program,
    and the decision of when to show them.

internal/progress exports a Sink interface and an Install function so the
command layer can take over the event stream for the duration of a run.

Relationship to the upstream ocr tui work

Upstream has an open PR (#1739) adding an ocr tui command: an interactive
workspace for choosing what to review, configuring the provider, launching
runs, following progress, and reading findings afterwards. The two coexist:

  • ocr tui is a workspace — it picks the scope, launches the run, and
    browses the results.
  • ocr review --tui is a live view of a run whose scope was already fixed on
    the command line.

They never render the same run: ocr tui launches its child review without
--tui and reads the child's stderr, so there is exactly one dashboard on
screen. The --tui name also matches the vocabulary upstream already uses for
terminal interfaces (provider_tui.go is on main).

This PR follows the conventions that work points towards, so the two can share
the codebase rather than diverge:

Convention How this PR follows it
Terminal UI lives in cmd/opencodereview The dashboard moved there.
One palette for the terminal interfaces The dashboard shares provider_tui.go's tui*Style declarations instead of declaring a second set.
The command layer resolves terminal capabilities interactiveTerminal() and progressColorProfile() live beside resolveColor(), and the dashboard is told the answer rather than probing the terminal itself.
--color decides the colour profile colorprofile.Detect for auto, TrueColor for always, Ascii for never.
Untrusted strings are sanitised before display Every event that enters the model is passed through the existing sanitizeTerminal, so a file name carrying an escape sequence cannot repaint the dashboard.
Truncation is width-aware ansi.Truncate rather than a hand-rolled cut.
A terminal too small for the view is told so A frame that cannot be laid out is replaced by a message asking for a bigger terminal.

The dashboard's UI copy stays English, like provider_tui.go on main. When
upstream's terminal-interface locale files land, the copy can move into them.

Design decisions a reviewer should weigh

  • Two sinks, one event stream. textSink reproduces the historical
    [ocr] bytes; the TUI consumes the same events. A dashboard-only event
    carries no text and prints nothing.
  • Skipped files are excluded from the bar numerator. The denominator is the
    count selected for review, and selection already removed what it skipped.
    Counting them again measured progress against a total that never contained
    them.
  • Reused is a separate bar segment. On a resumed run the bar opens partly
    full before this run has done any work; without the distinction that reads
    as progress the run did not make.
  • Per-task token accounting was added to llmloop.Runner. The process-wide
    total cannot attribute spend while N groups run concurrently; a snapshot
    delta around one group would capture every other group's calls.
  • No new dependency. The bar is hand-drawn rather than using
    bubbles/progress, which needs harmonica for spring physics a discrete file
    counter does not want.
  • The dashboard is opt-in. --tui turns it on and plain progress lines are
    the default, so an existing script or a piped run sees no change in output.

What the review should check

Each of these is a defect that existed at some point in this branch and was
fixed. They are the highest-yield things to re-derive:

  1. Byte-for-byte text compatibility. --format json must emit exactly one
    parseable document on stdout; --audience agent must still print its
    summary line. A second silencing mechanism once swallowed that summary
    because its restore ran after the summary was published.
  2. Program.Send/Wait block forever on a program that was never started.
    The dashboard hung on a real TTY until During quit the program when the
    work finished; only a piped run hid it.
  3. A textless event must print nothing. An event with no text still emitted
    a bare [ocr] prefix with no newline, which ran into the next line as a
    doubled prefix.
  4. One fact, one event. Emitting both a notice line and a state event per
    skip doubled every skip in the log and defeated run-collapsing, because the
    notice row landed between two skip rows.
  5. --resume arithmetic. Reused files were marked but published no done
    event, so the bar stalled short of full on a resumed run.
  6. Raw mode clears ISIG. ctrl+c produces no SIGINT while the dashboard
    is up, so the view has to hand the request back to the run itself.
  7. The scan's progress events were never published. The publishers existed
    and nothing called them, so ocr scan --tui had no denominator for its
    bar, an empty work list and zero counters — and the scan's own lines went
    straight to stdout and scribbled over the dashboard. Fixed.
  8. The tool-call lifecycle was never published either, so a row sat on
    "starting…" for the whole run instead of showing the tool it was calling.
    Fixed.
  9. The resume lookup re-hashed every file's content on a full-repo scan,
    where the run already builds that cache. Fixed.
  10. A line that carried its own [ocr] prefix showed it twice in the
    dashboard's log, because the text sink adds the prefix itself. The prefix
    is now stripped for the dashboard.
  11. The collapse-all control skipped groups the pager had hidden, so a
    group on the next page stayed open while the button read "Expand all".
    Every group is collapsed now.
  12. A file name carrying an escape sequence could repaint the dashboard.
    Events are now sanitised as they enter the model.
  13. The header and the summary line spelled the elapsed time two ways. The
    header rendered minutes and seconds, so a run of seventy-two minutes read
    as 72:00 where the same run's summary said 1h12s elapsed. The header
    now uses the summary's own formatter, which has an hours case, and the
    duplicate formatter left with no caller is gone.
  14. The bar drew outside the frame. Its cell count assumed the n/m
    counter was seven characters wide — a four-digit file count already beats
    that — and did not count the legend beside it at all, so a narrow window
    cut the legend off the right edge.
  15. The bar's three segments could add up to more than the bar had. Each
    was measured against the whole bar rather than against what was left of
    it, so the bar could run past the counter and the legend.
  16. A log entry could render as two rows. The region counts entries, not
    rendered lines, so an entry whose text spanned lines pushed the rows
    below it off the frame. One entry is now one row.

A second pass with the project's own review over the whole branch found seven
more, all of them in the pipeline rather than in the view, and all of them
making the dashboard disagree with the run it was showing:

  1. The scan counted a file's findings before the comment workers had
    drained.
    The count came back zero for every scanned file, so the
    findings counter never moved. The scan now drains the pool for the file
    before it counts, the way the review path does.
  2. The scan published its skips as plain notices. The review path
    publishes a skip event; the scan published a line, so a scan over a repo
    with many binary files filled the activity log with one row per file and
    the skipped counter stayed at zero. Both publish the same event now.
  3. A scan cut short mid-task never said so. The budget event was
    published by the between-files gate but not by the mid-task stop, so the
    dashboard finished without a budget line while the report said
    budget_exceeded: true.
  4. A review group that stopped short reached no terminal state at all.
    Two of the group's exits published nothing: a group that produced
    findings — reportAsError is false whenever the group has a comment —
    and a group that stopped without a reason. The row kept spinning and the
    bar never advanced. Both now publish the split between the files that
    finished and the ones that did not.
  5. The budget event printed a second line. It carried text, so the plain
    sink printed the budget notice twice, breaking the byte-for-byte promise
    for piped runs.
  6. Nothing published the per-task token total. The kind was declared and
    rendered but never emitted, so every row ended with zero tokens. The
    accounting it needed was lost when upstream's llmloop was merged in;
    the runner tracks each task's running total again.
  7. The tool error was published as a warning, leaving the kind reserved
    for it unused and its styling dead code. It is published as that kind
    now, on the same stream as before.

A later pass over the dashboard itself found four more, all of them about
what the reader could actually see:

  1. The estimate was a line in the log, so it scrolled away within
    seconds
    while the run spent exactly the thing the estimate predicted.
    The estimate is now published with the file count, before the first
    dispatch, and shown on a line of its own that stays for the whole run.
    A scan that groups its work says so beside it, and each row names the
    batch it belongs to.
  2. A row's note had fifteen columns to work with. The name column was a
    fixed sixty characters wide, so on an eighty-column terminal the note —
    the part that says which round the file is on, which tool it is calling
    and what it has spent — was cut off. The name column now follows the
    longest path in the run and gives ground to the note, and a note that
    still does not fit wraps under its own column instead of being cut.
  3. The scroll marker was appended to the last row of the window, which
    made the frame a column wider than the terminal. The terminal wrapped
    that row onto a second line, and the help line fell off the bottom. The
    marker is a line of its own now.
  4. The frame came out one line taller than the terminal at the smallest
    size it claimed to fit, once the plan line took a row of its own. The
    floor is 40x13 now — the layout's real minimum — and the too-small
    message is two short lines that fit the narrowest terminal it would
    otherwise have drawn.
  5. The work heading counted the wrong thing. Its number was every row the
    run had ever opened, so a heading reading work (51) sat next to a
    status row saying four files were in flight, and the two were about
    different things — a reader took the heading for the files being worked
    on, and it was the files already behind them. It counts what is being
    worked on now, and the folded rows are called finished rather than
    done, because some of them failed.

The first two of those have a regression test that fails without the fix.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

  • make test passes locally
  • Manual testing (describe below)
make check                 # licence, english-only, tidy, gofmt, vet
make coverage              # 91.5%, threshold 90%
make test                  # full suite, -race

Verified on a real 487-file scan under a PTY, and by diffing piped output
against a binary built from main on the same repo — the only differences were
LLM nondeterminism. The same diff was re-run after the fixes above, and the
structural lines still match, with no line carrying the prefix twice.

A scan and a resumed scan were also run under the dashboard: the first shows
the bar reaching the file count with the findings counted, the second the
reused segment. A work row shows the tool it is calling.

Notes for reviewers

  • internal/progress is a new package. The text sink deliberately keeps writing
    to stdout.Writer(), so the existing redirection (--audience agent,
    --format json) still controls where progress goes.

  • This adds a mutex acquisition per LLM response for the per-task usage map.
    That is negligible beside the network call, but it is the one new cost on a
    hot path.

  • Upstream main has been merged in. Its internal/telemetry still uses the
    two-argument PrintToolCall* API while this branch had moved it to three
    arguments, so the merge resolves the telemetry, llmloop, scan and
    output files to upstream's two-argument set. The dashboard package does
    not depend on that API, so the TUI and --tui are unaffected by it.

  • The code-review workflow was failing on main for every PR, including
    other contributors', with the runner reporting Can't find 'action.yml'. That
    was the workflow's own sparse checkout polluting the shared runner
    workspace, not a finding against any branch. Upstream has since fixed it
    (fix(ci): prevent PR policy checkout state pollution #1783), and this branch merges that fix. The workflow only triggers on
    opened, so a check from this branch's opening commit will not re-run by
    itself — a maintainer with write access has to re-run it, and it now gets
    past the checkout. The same review on feat(viewer): show live sessions as running with a ticking duration #1786 passed after the fix.

  • The workflow runs on this PR are waiting to be approved. Every one of
    them shows as action_required with no jobs at all, which is GitHub holding
    a fork pull request's workflows until a maintainer approves them — the
    Checks tab offers "Approve and run workflows". Nothing has failed and
    nothing is waiting for a runner: the jobs have not started. The same ground
    is covered locally by make check, make test and make coverage, which
    are what the CI test job runs, and the repository's own Analyze (go) and
    windows jobs pass on the fork.

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA
  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

AI Assistance

This branch was written with AI assistance. The original implementation was
produced with Claude Code (model claude-opus-5); the merge of upstream
main and the --tui opt-in with OpenCode; and the restructure onto
upstream's terminal-UI conventions described above, the review comments
addressed here, and the prose in this description with Claude Code, whose
session reports its model as minimax/minimax-m3.1-flash:free.

The diff has been reviewed by hand and every behavioural claim above was
checked against a real run rather than assumed. Commits carry no AI
attribution trailers.

🤖 Generated with Claude Code

…ckage

Replace the ~75 fmt.Fprintf(stdout.Writer(), "[ocr] ...") call sites with
progress.Publish, so run progress becomes structured events rather than
pre-formatted lines.

The default sink prints each event as the [ocr] line it always was, so
piped, CI and --format json/sarif output is byte-for-byte unchanged. Events
that exist only to update a live view carry no text and print nothing;
publishing both a notice and a state event for one fact doubled the output.

Token usage was a single process-wide total, which cannot attribute spend to
one unit of work while N groups run concurrently. The runner now keeps a
per-task breakdown alongside the aggregate, so a row can report what it
actually cost rather than a share of the total.
Replace the wall of [ocr] lines with a full-screen view that repaints in
place: a progress bar, counters, one row per unit of concurrent work, and a
scrolling activity log.

The bar is segmented because "reused from a resumed session" and "reviewed
during this one" are different states, and a resumed run opens partly full
before this run has done any work. Skipped files are excluded from the
numerator: the denominator is the count selected for review, which already
excludes everything selection skipped.

The dashboard starts only on an interactive terminal, for text format and
the human audience, so pipes, CI and --format json/sarif never see an
alternate screen. --no-tui opts out explicitly.
fix(llm): allow unlisted OpenRouter model overrides (alibaba#1610)
Flip the live terminal dashboard from opt-out (--no-tui, on by default on
interactive terminals) to opt-in (--tui). Plain [ocr] progress lines are now
the default, preserving the old text behavior unless --tui is passed. The
dashboard still only starts on an interactive terminal with --format text
and --audience human.

Renames progress.Options.Disabled to Enabled and inverts the gate, updates
the review and scan commands, and refreshes the CLI reference in all five
locales.
Pulls in main's 20 commits (ACP service, ChatGPT auth, scan token-budget
and prompt-overflow fixes, provider docs, dependency bumps, etc.) and
reconciles them with this branch's interactive dashboard work.

The branch had advanced internal/telemetry to a 3-arg PrintToolCall API
while main stayed on 2-arg, so the telemetry/llmloop/scan/output files
are resolved to main's consistent 2-arg set. The internal/progress
dashboard (independent of telemetry) and the opt-in --tui flag are kept
from this branch: plain [ocr] progress lines are the default and the
live dashboard only starts with --tui on an interactive terminal.
…rough the package

The scan's publishers were defined but never called, so a dashboard run of
`ocr scan` had no denominator, an empty work list and zero counters, while
the scan's own lines went straight to stdout and scribbled over the view. The
publishers are now called at the points the facts become known, and the
lines go through the progress package like every other one.

The tool-call lifecycle is published too, so a row shows the tool it is
calling rather than sitting on "starting…".

The resume lookup re-hashed every file's content; it now uses the
fingerprint cache the rest of the run already builds.

The dashboard's log rows are the events' own text, and the text sink adds
the "[ocr] " prefix itself, so a line that already carried one showed it
twice. The prefix is stripped for the dashboard.
The English page documented the dashboard and the flag, and the other
locales had only the flag row. The section describes what a reader sees
and which keys do what, so it belongs in all of them.
The ctrl+c row of the key table was missing its closing pipe, so the
row did not render as a table row.
Terminal UI now lives only in the command layer, as it does upstream, and
the dashboard shares the palette provider_tui.go already declares.

internal/progress keeps the event stream and the plain text sink; it
exports Sink and Install so the command layer can take the stream over for
the duration of a run.

The command layer now also resolves terminal interactivity and the colour
profile, untrusted strings are sanitised as events enter the model,
truncation is width-aware, and a terminal too small for the dashboard is
told to enlarge.

Details and reasoning are in the PR description.
The message hard-coded 40x12 while the floor lives in two constants, so
raising the floor would have left the two disagreeing.
Six events the live dashboard renders were never published, so the view
silently disagreed with the run:

- the scan counted a file's findings before the comment workers had
  drained, and reported zero for every file;
- the scan published its skips as plain notices, so a scan filled the
  activity log with one row per skipped file and never counted them;
- a scan cut short mid-task never published the budget event;
- a review group that stopped short published no terminal event at all,
  so its row kept spinning and its files never advanced the bar;
- the budget event carried text, so the plain sink printed the budget
  notice twice;
- the tool error was published as a warning, leaving the kind reserved
  for it unused.

Found by running the project's own review over the branch.
The dashboard's per-row token column is driven by the usage event, and
nothing published it: the kind was declared and rendered but never
emitted, so every row ended with zero tokens.

The accounting it needed was lost when upstream's llmloop was merged in.
Track each task's running total in the runner and publish it after every
response, so a row shows what it spent rather than what its last call
cost.
The rename that moved the dashboard into the command layer also rewrote
the word inside the help line, so the view offered "tab dashboardPane".

Found by running the dashboard under a real terminal.
The dashboard's row names the tool it is calling right now, but nothing
published the end of a call, so the name stayed after the tool had
finished and the row read as though it were still running that tool.

Publish the end of a call, and attribute a failed one to its row, so the
name clears when the call is over.
The header rendered the elapsed time as minutes and seconds, so a run of
seventy-two minutes read as "72:00" while the summary line the same run
printed said "1h12s elapsed". The header now uses the same formatter as
the summary, which also has an hours case, and the duplicate formatter
that was left with no caller is gone.

The token abbreviations diverge from the [ocr] progress lines on purpose:
theirs rounds, so 3800 tokens print as "4K" in the log and as "3.8k" here.
The comment says so, rather than leaving the difference to be discovered.
Three ways the dashboard could draw outside the width it was given:

- the bar's cell count assumed the "n/m" counter was seven characters
  wide, which a four-digit file count already beats, and the legend
  beside it was not counted at all, so a narrow window cut the legend
  off the right edge;
- the bar's three segments were each measured against the whole bar, so
  they could add up to more than the bar has and run past the counter
  and the legend;
- a log entry whose text spanned lines rendered as two rows while the
  region counted entries rather than lines, pushing the rows below it
  off the frame.

Found by the project's own review over the dashboard.
fix(tool): report an empty code_comment batch instead of success (alibaba#1773)
@SaahiilM

Copy link
Copy Markdown
Author

Reopening to re-run the automated review against the current head.

The review that ran at open time failed in the workflow's own checkout (upstream's sparse-checkout pollution, since fixed by #1783), so this branch's restructured form has never been through it. The branch is otherwise unchanged and up to date with upstream main.

@SaahiilM SaahiilM closed this Oct 20, 2026
@SaahiilM SaahiilM reopened this Oct 20, 2026
The session writer holds its file open until it is finalized, and Windows
cannot delete an open file, so the test's temp directory could not be
cleaned up. Finalizing the session closes it.
A row showed its spend under the header's input arrow, but the row's
number was input and output added together, so a row could read larger
than the whole run had spent. The arrows now mean the same thing in the
header, in a running row and in a finished one: ▲ is input, ▼ is output.

The status line's separators also had no spaces, so the counters ran
together and the documentation's example did not match what was drawn.
Four things the dashboard got wrong, all found by reading the rendered
screen rather than the code:

- a row cleared the tool name when the call ended, and tool calls finish
  in milliseconds, so the row sat at "starting…" while the activity log
  moved on. The name stays — it is the last thing the row did — and the
  row says whether the call is still in flight;
- the frame came out one line taller than the terminal, so the help line
  fell off the bottom, and a pane that was shorter than its allowance
  pulled the regions below it up, so the log moved as work came and went;
- the bar's segments were measured separately and truncated, so they
  never added up to the full width and the bar never quite filled. They
  are stacked now, each ending where the next begins;
- a failure small enough to round away left no trace in the bar at all,
  while the count beside it said files had failed.

The activity list also gets a scrollbar, so the reader can see how much
of the feed is left and where the window sits in it.
@SaahiilM
SaahiilM force-pushed the feat/live-progress-dashboard branch from 781d081 to bc5aa1b Compare October 20, 2026 16:19
The estimate was a line in the log, so it scrolled away within seconds
while the run spent it. It is now published with the file count and shown
on a line of its own, beside the batch plan, and every row names the batch
it belongs to.

Rows are wrapped rather than cut: a note that did not fit continued on the
next line, indented under its own column, and the name column gives ground
to the note so it always has room. The activity log folds away with "l",
and the work list takes the height the two of them shared.
The heading counted every row the run had ever opened, so it read "work
(51)" next to a status row saying four files were in flight, and the two
were about different things. It counts what is being worked on now, and
the folded rows are called finished rather than done, because some of
them failed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant