Skip to content

Agentic Review: Baseline comparison#34926

Open
ghengeveld wants to merge 2 commits into
yann/agentic-review-mcp-integrationfrom
review-baseline-comparison
Open

Agentic Review: Baseline comparison#34926
ghengeveld wants to merge 2 commits into
yann/agentic-review-mcp-integrationfrom
review-baseline-comparison

Conversation

@ghengeveld
Copy link
Copy Markdown
Member

@ghengeveld ghengeveld commented May 27, 2026

Closes #

What I did

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

Caution

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make 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 pull request has been released as version 0.0.0-pr-34926-sha-a0498164. Try it out in a new sandbox by running npx storybook@0.0.0-pr-34926-sha-a0498164 sandbox or in an existing project with npx storybook@0.0.0-pr-34926-sha-a0498164 upgrade.

More information
Published version 0.0.0-pr-34926-sha-a0498164
Triggered by @yannbf
Repository storybookjs/storybook
Branch review-baseline-comparison
Commit a0498164
Datetime Thu May 28 12:17:46 UTC 2026 (1779970666)
Workflow run 26574136441

To request a new release of this pull request, mention the @storybookjs/core team.

core team members can create a new canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=34926

Summary by CodeRabbit

  • New Features

    • Baseline and latest preview side-by-side comparison with synchronized scrolling
    • Toggle between single and dual preview layouts; swap control in single-preview mode
    • Local proxy support added to reliably load baseline previews during review
  • Chores

    • Updated onboarding header text to “Onboarding guide”
    • Review details updated to target the Guide Page story and align story behaviors

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

📝 Walkthrough

Walkthrough

This PR adds baseline-vs-latest preview comparison to the Review addon: an experimental devServer preset that proxies baseline requests via /__review-baseline, a refactored DetailsScreen with dual iframes, synchronized scrolling and 1-up/2-up preview modes, and story updates targeting the GuidePage.

Changes

Baseline-vs-Latest Review Comparison

Layer / File(s) Summary
Baseline Proxy Middleware Setup
code/addons/review/src/preset.ts, code/addons/review/package.json
New experimental_devServer preset registers an HTTP proxy at /__review-baseline that forwards requests to the Chromatic origin with path-prefix stripping. Adds http-proxy-middleware devDependency.
DetailsScreen Baseline-vs-Latest Viewer
code/addons/review/src/screens/DetailsScreen.tsx
Converted to hooks-based component rendering baseline and latest iframes, adds PreviewMode (1-up/2-up) and VisibleSide, styled layout primitives, bidirectional scroll sync, baseline URL generation via proxy, STORY_RENDERED listener hookup, and dynamic toolbar controls for mode/swap actions.
DetailsScreen Stories and GuidePage Text
code/addons/review/src/screens/DetailsScreen.stories.tsx, code/core/src/manager/settings/GuidePage.tsx
Story meta updated to target manager-settings-guidepage--default; play assertions updated for baseline/latest elements. GuidePage title changed from "Guide" to "Onboarding guide".

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • storybookjs/storybook#32862: Both PRs implement the experimental_devServer preset mechanism; core PR exposes ServerApp and applies presets while this addon mounts the /__review-baseline proxy.
  • storybookjs/storybook#32816: The addon’s experimental_devServer(app) preset depends on the core infrastructure introduced in this PR to expose the dev server to presets/addons.
  • storybookjs/storybook#34890: Concurrent changes touching DetailsScreen and its stories; both PRs modify the review UI surface and story targets.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands and usage tips.

@storybook-app-bot
Copy link
Copy Markdown

storybook-app-bot Bot commented May 27, 2026

Package Benchmarks

Commit: b677c0a, ran on 29 May 2026 at 10:17:54 UTC

The following packages have significant changes to their size or dependencies:

@storybook/addon-review

Before After Difference
Dependency count 0 0 0
Self size 52 KB 201 KB 🚨 +149 KB 🚨
Dependency size 654 B 654 B 0 B
Bundle Size Analyzer Link Link

Base automatically changed from agentic-review-design-iterations to yann/agentic-review-mcp-integration May 28, 2026 08:04
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

1 similar comment
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

…screen with 1up/2up modes, view toggles, and readiness gating so latest stays visible while baseline loads. Also proxy baseline previews through a local __review-baseline dev-server route and keep the two iframes aligned by syncing URL and scroll position.
@ghengeveld ghengeveld force-pushed the review-baseline-comparison branch from 8f1fff5 to b677c0a Compare May 29, 2026 10:03
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/preset.ts`:
- Around line 79-87: The proxy created in createProxyMiddleware (assigned to
proxyRequest) lacks timeout and deterministic error handling; update the options
passed to createProxyMiddleware (for the instance referenced as proxyRequest and
mounted via app.use(BASELINE_PROXY_PATH)) to include timeout and proxyTimeout
values (e.g., sensible millisecond limits), and add an on.error handler that
sends a deterministic HTTP failure (e.g., 502/504 with a short JSON/plain text
body) and ends the response to avoid hanging the request when
BASELINE_TARGET_ORIGIN is slow/unreachable; keep existing changeOrigin and
pathRewrite behavior and ensure the handler checks res.headersSent before
writing a response.
🪄 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: 2c695d1e-0cc1-4f59-a8c6-bba28ad492a6

📥 Commits

Reviewing files that changed from the base of the PR and between 8f1fff5 and b677c0a.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • code/addons/review/package.json
  • code/addons/review/src/preset.ts
  • code/addons/review/src/screens/DetailsScreen.stories.tsx
  • code/addons/review/src/screens/DetailsScreen.tsx
  • code/core/src/manager/settings/GuidePage.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • code/core/src/manager/settings/GuidePage.tsx
  • code/addons/review/src/screens/DetailsScreen.stories.tsx
  • code/addons/review/src/screens/DetailsScreen.tsx

Comment on lines +79 to +87
const proxyRequest = createProxyMiddleware({
target: BASELINE_TARGET_ORIGIN,
changeOrigin: true,
pathRewrite: (path) =>
path.startsWith(BASELINE_PROXY_PATH) ? path.slice(BASELINE_PROXY_PATH.length) || '/' : path,
}) as unknown as Middleware;

app.use(BASELINE_PROXY_PATH, proxyRequest);
return app;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

For http-proxy-middleware v4.0.0, what are the exact supported options for request timeout and error handling (e.g., timeout, proxyTimeout, and error hooks like onErrororon.error)?

💡 Result:

In http-proxy-middleware v4.0.0, configuration options for timeouts and error handling are explicitly defined to manage proxy behavior [1][2]. Timeout Options: These options accept a value in milliseconds [1][3]. timeout: Sets the timeout for incoming requests [1][2]. proxyTimeout: Sets the timeout for the proxy when it receives no response from the target server [1][2]. Error Handling: In v4.0.0, default plugins are used, and users are advised to register their own error handlers to prevent the server from crashing [1][2]. The library provides specific plugins for this purpose, such as debugProxyErrorsPlugin and errorResponsePlugin [1][2]. The primary mechanism for custom error handling is via the 'on' option, which subscribes to httpxy events [2][4]. on.error: This function allows you to subscribe to the underlying httpxy 'error' event for custom error handling [1][2]. It typically follows the signature (err, req, res, target) [4]. To implement custom error handling and prevent crashes, you can eject default plugins and manually add error-handling plugins: import { debugProxyErrorsPlugin, errorResponsePlugin, proxyEventsPlugin, } from 'http-proxy-middleware'; // Example of subscribing to error events createProxyMiddleware({ target: 'http://www.example.org', on: { error: (err, req, res) => { // Custom error handling logic }, }, }); The proxyEventsPlugin is specifically used to implement the 'on:' option for event subscriptions [1][2].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the proxy setup code
sed -n '60,105p' code/addons/review/src/preset.ts

# Determine which http-proxy-middleware version this repo uses
# (try root package.json first; fall back to searching for the dependency)
if [ -f package.json ]; then
  rg -n "\"http-proxy-middleware\"" package.json || true
  cat package.json | head -n 80
fi

# Search for any package.json containing the dependency
fd -a 'package.json' -t f . | while read -r f; do
  if rg -q "\"http-proxy-middleware\"" "$f"; then
    echo "---- $f ----"
    rg -n "\"http-proxy-middleware\"" "$f"
  fi
done

Repository: storybookjs/storybook

Length of output: 4399


🌐 Web query:

http-proxy-middleware v4 options timeout proxyTimeout on.error errorResponsePlugin error hooks

💡 Result:

In http-proxy-middleware v4, which migrated from the http-proxy library to httpxy [1][2], the configuration options for timeouts and error handling remain central to the middleware's functionality [3][4][5]. Timeout Configuration: - option.timeout: Specifies the timeout (in milliseconds) for incoming requests [3][4][5]. - option.proxyTimeout: Specifies the timeout (in milliseconds) for the proxy when it receives no response from the target server [3][4][5]. Error Handling and Plugins: - option.on.error: This option allows you to subscribe to the underlying proxy's error event for custom error handling [3][4][5]. The callback signature generally follows: function(err, req, res, target) [4]. - errorResponsePlugin: In v3 and v4, the middleware features a plugin system [6][7]. The errorResponsePlugin is a built-in plugin that provides default error response behavior [8]. If you implement custom error handling, ensure you register your own handlers to prevent the server from crashing [8]. - Other Plugins: The middleware includes other plugins such as debugProxyErrorsPlugin, loggerPlugin, and proxyEventsPlugin, which can be configured or ejected to suit specific needs [8][7]. Important v4 Changes: - ESM-only: v4 is an ESM-only package and no longer supports CommonJS require [1][2]. - Runtime: The minimum supported Node.js version is now 22.15.0 [1][2]. - Dependencies: The core proxy engine has been switched to httpxy, which brings updated behavior and fixes [1][2]. For further customization, such as manipulating proxy responses, developers typically use the selfHandleResponse: true option, which allows the developer to take full responsibility for returning the response by listening to the proxyRes event [3][4].

Citations:


🌐 Web query:

http-proxy-middleware v4.0.0 createProxyMiddleware options list on error event signature

💡 Result:

In http-proxy-middleware v4.0.0, the recommended way to handle proxy events, including errors, is by using the on configuration object within the createProxyMiddleware options [1][2]. The signature for the error event handler in v4.0.0 is: (err, req, res) => { /* handle error */ } You configure this via the on property: import { createProxyMiddleware } from 'http-proxy-middleware'; const proxy = createProxyMiddleware({ target: 'http://www.example.org', on: { error: (err, req, res) => { // Your custom error handling logic here console.error(err); res.writeHead(500, { 'Content-Type': 'text/plain' }); res.end('Something went wrong.'); }, }, }); Key changes in v4.0.0: - Proxy logic has been migrated from the legacy http-proxy dependency to httpxy [3][4]. - While the previous versions allowed defining event handlers directly as options (e.g., options.onError), the modern and preferred approach is to group all event handlers within the on object [1][2]. - The package is now ESM-only and requires Node.js 22.15.0 or later [3][4].

Citations:


Add explicit proxy timeouts and deterministic error handling (http-proxy-middleware v4)

createProxyMiddleware in code/addons/review/src/preset.ts sets only target/changeOrigin/pathRewrite; http-proxy-middleware@^4 supports timeout (incoming request), proxyTimeout (no response from target), and on: { error: (err, req, res) => ... }—add these to avoid slow/unreachable Chromatic stalling the review UI and to return a deterministic failure response.

🤖 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/preset.ts` around lines 79 - 87, The proxy created in
createProxyMiddleware (assigned to proxyRequest) lacks timeout and deterministic
error handling; update the options passed to createProxyMiddleware (for the
instance referenced as proxyRequest and mounted via
app.use(BASELINE_PROXY_PATH)) to include timeout and proxyTimeout values (e.g.,
sensible millisecond limits), and add an on.error handler that sends a
deterministic HTTP failure (e.g., 502/504 with a short JSON/plain text body) and
ends the response to avoid hanging the request when BASELINE_TARGET_ORIGIN is
slow/unreachable; keep existing changeOrigin and pathRewrite behavior and ensure
the handler checks res.headersSent before writing a response.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant