Repository navigation
Core: Add ai-review observability - #35300
Conversation
📝 WalkthroughWalkthroughAdds a new ChangesReview pageview telemetry
Estimated code review effort: 2 (Simple) | ~12 minutes Sequence Diagram(s)sequenceDiagram
participant ReviewProvider
participant Channel
participant TelemetryChannel
participant Telemetry
ReviewProvider->>Channel: emit REVIEW_EVENTS.PAGEVIEW (page, reviewCreatedAt)
Channel->>TelemetryChannel: REVIEW_EVENTS.PAGEVIEW listener
TelemetryChannel->>Telemetry: telemetry('review', {action: 'pageview', source: 'mcp-review', page, reviewCreatedAt})
Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
Comment |
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/core/src/core-server/server-channel/telemetry-channel.test.ts`:
- Around line 59-63: The telemetry test expectations use the wrong event name,
causing the assertions in initTelemetryChannel to fail. Update the calls in
telemetry-channel.test.ts to match the actual event type forwarded by
initTelemetryChannel, which is the ai-review literal in the EventType union, and
apply the same fix to both pageview assertions so they verify the correct
telemetry arguments.
🪄 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: 524a457d-db90-406f-b6d3-084eaaa6afdb
📒 Files selected for processing (6)
code/core/src/core-server/server-channel/telemetry-channel.test.tscode/core/src/core-server/server-channel/telemetry-channel.tscode/core/src/manager/components/review/ReviewProvider.tsxcode/core/src/shared/review/events.tscode/core/src/shared/review/index.tscode/core/src/telemetry/types.ts
…bservability # Conflicts: # code/core/src/manager/components/review/components/ReviewProvider.tsx
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
code/core/src/manager/components/review/components/ReviewProvider.tsx (1)
199-221: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winDedup key ignores review identity, so a new review can be silently missed by telemetry.
keyis derived only from the surface ('summary'ordetail:${storyId}), not fromstate.createdAt. IfDISPLAY_REVIEWdelivers a new review (differentcreatedAt) while the user stays on the same summary overlay or the same story's detail view — which is possible since the handler callssetState(next)directly whenisDeferredReviewUpdate/isSameReviewPayloadare both false — the surface key is unchanged, so no pageview fires for the new review even thoughreviewCreatedAtwould differ. This undercounts pageviews for the "arrives while viewing" case.Include
state.createdAtin the dedup key so a new review on an unchanged surface still reports a pageview:🐛 Proposed fix
if (isSummaryVisible) { page = 'summary'; - key = 'summary'; + key = `summary:${state.createdAt}`; } else if (isInReviewMode && activeEntry) { page = 'detail'; - key = `detail:${activeEntry.storyId}`; + key = `detail:${activeEntry.storyId}:${state.createdAt}`; }🤖 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/core/src/manager/components/review/components/ReviewProvider.tsx` around lines 199 - 221, The pageview dedup logic in ReviewProvider’s useEffect is only keyed by the visible surface and story, so a new review with a different state.createdAt can be skipped when the user remains on the same summary or detail view. Update the lastPageviewKeyRef comparison to include state.createdAt in the key used for deduping, while keeping the existing page selection logic and emit(EVENTS.PAGEVIEW, ...) call in sync with the current review identity.
🤖 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.
Outside diff comments:
In `@code/core/src/manager/components/review/components/ReviewProvider.tsx`:
- Around line 199-221: The pageview dedup logic in ReviewProvider’s useEffect is
only keyed by the visible surface and story, so a new review with a different
state.createdAt can be skipped when the user remains on the same summary or
detail view. Update the lastPageviewKeyRef comparison to include state.createdAt
in the key used for deduping, while keeping the existing page selection logic
and emit(EVENTS.PAGEVIEW, ...) call in sync with the current review identity.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8917f68a-71f9-4075-b8a3-b642a88241e1
📒 Files selected for processing (5)
code/core/src/core-server/server-channel/telemetry-channel.test.tscode/core/src/core-server/server-channel/telemetry-channel.tscode/core/src/manager/components/review/components/ReviewProvider.tsxcode/core/src/shared/review/index.tscode/core/src/telemetry/types.ts
✅ Files skipped from review due to trivial changes (1)
- code/core/src/shared/review/index.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- code/core/src/telemetry/types.ts
- code/core/src/core-server/server-channel/telemetry-channel.test.ts
LogDetails |
Closes #
What I did
Added "pageview"-style observability events for the Storybook Review UI, so we can see how the summary and detail surfaces are used. When a user lands on the review summary overlay or opens a specific reviewed story, the manager emits a channel event that core-server forwards as an
ai-reviewobservability event ({ action: 'pageview', page, reviewCreatedAt }).Follows the existing manager-emits → server-forwards pattern (same shape as
share,sidebar-filter, andai-prompt-nudge):core/src/shared/review/events.ts: newREVIEW_EVENTS.PAGEVIEW(tab → core-server) plusReviewPage/ReviewPageviewPayloadtypes, re-exported fromshared/review/index.ts.core/src/manager/components/review/ReviewProvider.tsx: auseEffectfires a pageview when the active review surface changes (summarywhen the overlay is visible,detailwhen a reviewed story is open in review mode). Keyed via a ref (summary/detail:<storyId>) so re-renders that don't change the surface or story don't re-fire. The review'screatedAtrides along as a correlation id.core/src/core-server/server-channel/telemetry-channel.ts: listens forREVIEW_EVENTS.PAGEVIEWand emits theai-reviewobservability event.core/src/telemetry/types.ts: addedai-reviewto theEventTypeunion.These are usage/observability events only — no change to how the Review UI renders or behaves.
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-tsSTORYBOOK_TELEMETRY_DEBUG=1when starting Storybook so observability events are logged to the terminaldisplay-reviewflow so the review summary appearsai-reviewevent with{ action: 'pageview', page: 'summary' }is logged when the summary overlay showsai-reviewevent with{ action: 'pageview', page: 'detail' }is loggeddetailevent fires; navigating to a different reviewed story fires a newdetaileventDocumentation
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.Summary by CodeRabbit
New Features
Bug Fixes