Skip to content

Adds a progress bar renderer - #1395

Merged
justin-thurman merged 5 commits into
clack-renderer-featurefrom
CAP-4613
Jun 16, 2026
Merged

justin-thurman merged 5 commits into
clack-renderer-featurefrom
CAP-4613

Conversation

@justin-thurman

@justin-thurman justin-thurman commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Description

This PR implements a Clack progress bar renderer for tasks like upload and snapshot. In addition to the core changes, there was a bit of cleanup (moving taskMessageFormatter to a location to be shared by both renderers and renaming renderer.ts to taskLogRenderer.ts, since we now have a progressBarRenderer.ts). These refactorings are in their own commits. As usual, I recommend reviewing commit-by-commit.

progressBarRenderer

At its core, this renderer is a wrapper around Clack's progress function, which returns a progress bar primitive. But there are two complications. The first is that Clack's progress function 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 with total=100 and 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 tests or whatever it is) are handled by the UI state components in ui/tasks/*.

The other complication is around the terminal UI states. The progress bar primitive includes a stop and error method, 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's log primitives 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 a clear method, which handles tearing down the progress bar without writing anything, so we can just call that and then use the regular clack.log primitives 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 captureTask helper 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 monkeypatches setInterval and clearInterval, 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:

npm install [email protected]
# or 
yarn add [email protected]

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

📦 Package Size: 7148 KB

@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.91667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.90%. Comparing base (1029648) to head (f380c6f).

Files with missing lines Patch % Lines
node-src/renderer/engine/clack/progressRenderer.ts 96.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@justin-thurman justin-thurman changed the title CAP 4613 Adds a progress bar renderer Jun 15, 2026
@justin-thurman
justin-thurman force-pushed the CAP-4613 branch 2 times, most recently from bdecd03 to f9e39f5 Compare June 15, 2026 17:17
@justin-thurman justin-thurman added patch Auto: Increment the patch version when merged skip-release Auto: Preserve the current version when merged labels Jun 15, 2026
Base automatically changed from CAP-4590 to clack-renderer-feature June 15, 2026 17:25
@justin-thurman
justin-thurman requested a review from a team June 15, 2026 18:32
@justin-thurman
justin-thurman marked this pull request as ready for review June 15, 2026 18:32
@justin-thurman
justin-thurman merged commit 8515ea8 into clack-renderer-feature Jun 16, 2026
23 checks passed
@justin-thurman
justin-thurman deleted the CAP-4613 branch June 16, 2026 12:38
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
@chromatic-ci-bot

Copy link
Copy Markdown
Collaborator

🚀 PR was released in v18.0.0 🚀

@chromatic-ci-bot chromatic-ci-bot added the released Verdict: This issue/pull request has been released label Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Auto: Increment the patch version when merged released Verdict: This issue/pull request has been released skip-release Auto: Preserve the current version when merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants