Agentic Review: Add progress bar and keyboard shortcuts#35062
Agentic Review: Add progress bar and keyboard shortcuts#35062ghengeveld wants to merge 2 commits into
Conversation
Register the detail screen's cross-collection navigation (back, prev/next story, prev/next collection) as customizable addon shortcuts instead of overriding the manager's built-in Opt+Arrow/Escape bindings, so users can rebind them and the review page no longer mutates global shortcut state. Add a progress bar pinned to the top of the detail header that spans 0% on the first story to 100% on the last; it rides with the header when the stale banner pushes it down rather than overlapping the banner.
Package BenchmarksCommit: No significant changes detected, all good. 👏 |
📝 WalkthroughWalkthroughThis PR extends the review addon with keyboard shortcut navigation and refinements to the details screen. It introduces pure navigation helpers for computing previous/next stories across collections with wraparound, integrates shortcut registration into ReviewPage, and enhances DetailsScreen with a progress bar and improved baseline-comparison UI with persisted mode switching. ChangesReview Navigation and Keyboard Shortcuts
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
Comment |
…uts-progress Resolve review addon conflicts by keeping cross-collection navigation shortcuts and the progress bar while adopting canonical story hrefs via getStoryHrefs.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@code/addons/review/src/screens/DetailsScreen.tsx`:
- Around line 319-329: Clamp the computed progress value to the [0,1] range
before using it in the ProgressFill width: replace the current progress
calculation (const progress = totalStories > 1 ? storyIndex / (totalStories - 1)
: 0) with a clamped value (e.g., const rawProgress = totalStories > 1 ?
storyIndex / (totalStories - 1) : 0; const progress = Math.max(0, Math.min(1,
rawProgress))); then use this clamped progress when setting the style width on
ProgressFill so negative or >100% widths cannot occur.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 52adc0b9-dffa-428d-b08a-0dca532ee9f1
📒 Files selected for processing (6)
code/addons/review/src/ReviewPage.stories.tsxcode/addons/review/src/ReviewPage.tsxcode/addons/review/src/review-navigation.test.tscode/addons/review/src/review-navigation.tscode/addons/review/src/screens/DetailsScreen.stories.tsxcode/addons/review/src/screens/DetailsScreen.tsx
| const progress = totalStories > 1 ? storyIndex / (totalStories - 1) : 0; | ||
|
|
||
| return ( | ||
| <Page> | ||
| {isStale ? <StaleBanner /> : null} | ||
| <ReviewHeader | ||
| autoFocusTitle | ||
| leading={ | ||
| <IconButton | ||
| variant="ghost" | ||
| size="small" | ||
| padding="small" | ||
| ariaLabel="Back to review" | ||
| asChild | ||
| > | ||
| <a href={backHref}> | ||
| <ChevronSmallLeftIcon /> | ||
| </a> | ||
| </IconButton> | ||
| } | ||
| title={title} | ||
| subtitle={subtitle} | ||
| actions={ | ||
| <> | ||
| <Counter variant="ghost" size="small" readOnly> | ||
| {storyIndex + 1}/{totalStories} | ||
| </Counter> | ||
| <HeaderWrap> | ||
| <ProgressBar aria-hidden data-testid="review-progress"> | ||
| <ProgressFill | ||
| data-testid="review-progress-fill" | ||
| style={{ width: `${progress * 100}%` }} | ||
| /> |
There was a problem hiding this comment.
Clamp progress to [0, 1] before applying width.
If storyIndex is ever out of range, the fill width can go negative or exceed 100%, which breaks the progress visualization.
Suggested fix
- const progress = totalStories > 1 ? storyIndex / (totalStories - 1) : 0;
+ const progress =
+ totalStories > 1 ? Math.min(1, Math.max(0, storyIndex / (totalStories - 1))) : 0;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const progress = totalStories > 1 ? storyIndex / (totalStories - 1) : 0; | |
| return ( | |
| <Page> | |
| {isStale ? <StaleBanner /> : null} | |
| <ReviewHeader | |
| autoFocusTitle | |
| leading={ | |
| <IconButton | |
| variant="ghost" | |
| size="small" | |
| padding="small" | |
| ariaLabel="Back to review" | |
| asChild | |
| > | |
| <a href={backHref}> | |
| <ChevronSmallLeftIcon /> | |
| </a> | |
| </IconButton> | |
| } | |
| title={title} | |
| subtitle={subtitle} | |
| actions={ | |
| <> | |
| <Counter variant="ghost" size="small" readOnly> | |
| {storyIndex + 1}/{totalStories} | |
| </Counter> | |
| <HeaderWrap> | |
| <ProgressBar aria-hidden data-testid="review-progress"> | |
| <ProgressFill | |
| data-testid="review-progress-fill" | |
| style={{ width: `${progress * 100}%` }} | |
| /> | |
| const progress = | |
| totalStories > 1 ? Math.min(1, Math.max(0, storyIndex / (totalStories - 1))) : 0; | |
| return ( | |
| <Page> | |
| {isStale ? <StaleBanner /> : null} | |
| <HeaderWrap> | |
| <ProgressBar aria-hidden data-testid="review-progress"> | |
| <ProgressFill | |
| data-testid="review-progress-fill" | |
| style={{ width: `${progress * 100}%` }} | |
| /> |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@code/addons/review/src/screens/DetailsScreen.tsx` around lines 319 - 329,
Clamp the computed progress value to the [0,1] range before using it in the
ProgressFill width: replace the current progress calculation (const progress =
totalStories > 1 ? storyIndex / (totalStories - 1) : 0) with a clamped value
(e.g., const rawProgress = totalStories > 1 ? storyIndex / (totalStories - 1) :
0; const progress = Math.max(0, Math.min(1, rawProgress))); then use this
clamped progress when setting the style width on ProgressFill so negative or
>100% widths cannot occur.
What I did
Two improvements to the review addon's detail screen:
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
yarn task --task sandbox --start-from auto --template react-vite/default-ts(or use the internal UI:cd code && yarn storybook:ui).display-reviewflow) so the review page opens with multiple stories across collections.Documentation
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsDeclare whether manual QA will be needed for this PR during the next release, through
qa:neededorqa:skipMake sure this PR contains one of the labels below:
Available labels
bug: Internal changes that fixes incorrect behavior.maintenance: User-facing maintenance tasks.dependencies: Upgrading (sometimes downgrading) dependencies.build: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup: Minor cleanup style change. Will not show up in release changelog.documentation: Documentation only changes. Will not show up in release changelog.feature request: Introducing a new feature.BREAKING CHANGE: Changes that break compatibility in some way with current major version.other: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/coreteam here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>Summary by CodeRabbit
Release Notes
New Features
Tests