Adds a progress bar renderer - #1395
Merged
Merged
Conversation
Contributor
|
📦 Package Size: 7148 KB |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## clack-renderer-feature #1395 +/- ##
==========================================================
+ Coverage 82.59% 82.90% +0.30%
==========================================================
Files 246 249 +3
Lines 4643 4685 +42
Branches 1317 1322 +5
==========================================================
+ Hits 3835 3884 +49
+ Misses 697 690 -7
Partials 111 111 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
justin-thurman
force-pushed
the
CAP-4613
branch
2 times, most recently
from
June 15, 2026 17:17
bdecd03 to
f9e39f5
Compare
codykaup
approved these changes
Jun 15, 2026
justin-thurman
added a commit
that referenced
this pull request
Jun 25, 2026
Adds a progress bar renderer
justin-thurman
added a commit
that referenced
this pull request
Jun 30, 2026
Adds a progress bar renderer
Collaborator
|
🚀 PR was released in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR implements a Clack progress bar renderer for tasks like
uploadandsnapshot. In addition to the core changes, there was a bit of cleanup (movingtaskMessageFormatterto a location to be shared by both renderers and renamingrenderer.tstotaskLogRenderer.ts, since we now have aprogressBarRenderer.ts). These refactorings are in their own commits. As usual, I recommend reviewing commit-by-commit.progressBarRendererAt its core, this renderer is a wrapper around Clack's
progressfunction, which returns a progress bar primitive. But there are two complications. The first is that Clack'sprogressfunction works in absolutes, rather than percentages, but when we start a renderer, we don't know the total value that drives the progress bar. Because of this, we need to work in percentages, so we initialize the progress bar withtotal=100and then convert the progress updates we get into percentages before rendering the bar. Note that this only applies to the bar. The labels around these UI events (i.e.,Running X/Y testsor whatever it is) are handled by the UI state components inui/tasks/*.The other complication is around the terminal UI states. The progress bar primitive includes a
stopanderrormethod, but they don't fit our requirements for success/failure hooks on the renderer. These methods render a hollow glyph (rather than the filled glyph we use elsewhere) and their messages are hardcoded to the terminal, rather than routing through Clack'slogprimitives like the task log primitive does. Because of this, they clobber the task log gutter, even with our wrapping helper. Thankfully, the progress bar also has aclearmethod, which handles tearing down the progress bar without writing anything, so we can just call that and then use the regularclack.logprimitives for our success/failure messages, and it looks identical to our other tasks.Storybook rendering changes
Clack's progress bar (and spinner, which will come in another renderer PR and which progress bar is just a subclass of) render their update frames asynchronously. But our
captureTaskhelper that enables rendering Clack in Storybook is synchronous and must stay that way due to how it monkeypatches things. Furthermore, even if we could go async, it would be difficult to get deterministic output because our rendering happens at build time through a Storybook addon, so we can't rely on, e.g.,vi.useFakeTimers. So in order to enable capturing the progress bar update states in our Storybook, I added a helper that basically monkeypatchessetIntervalandclearInterval, which Clack uses to register its frame updating callbacks, saves the callbacks in an array, and then calls them synchronously after the renderer work finishes. Internally, when Clack tears down the progress bar, it clears registered callbacks, so we duplicate that logic as well for our terminal story states.Manual QA
N/A. It's not wired up yet. The added stories show what the UI will look like though and validate the Storybook rendering changes.
I did run a few builds to confirm that the new stories aren't flaky. See here. Build 10395 is the manually accepted new baseline. The following five builds show no changes.
📦 Published PR as canary version:
18.0.1--canary.1395.28528478297.0✨ Test out this PR locally via: