Skip to content

Vitest: Fix agent detection breaking runs#34681

Merged
JReinhold merged 1 commit into
nextfrom
jeppe/fix-vitest-provide-agent
May 1, 2026
Merged

Vitest: Fix agent detection breaking runs#34681
JReinhold merged 1 commit into
nextfrom
jeppe/fix-vitest-provide-agent

Conversation

@JReinhold
Copy link
Copy Markdown
Contributor

@JReinhold JReinhold commented May 1, 2026

Co-authored-by: Copilot copilot@github.com

Closes #

What I did

It is never valid to call context.vitest.provide() from within configureVitest, so I moved the computation of agent context to the config hook and used the provide config instead of providing dynamically using the function call.

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-34681-sha-1d5ea958. Try it out in a new sandbox by running npx storybook@0.0.0-pr-34681-sha-1d5ea958 sandbox or in an existing project with npx storybook@0.0.0-pr-34681-sha-1d5ea958 upgrade.

More information
Published version 0.0.0-pr-34681-sha-1d5ea958
Triggered by @yannbf
Repository storybookjs/storybook
Branch jeppe/fix-vitest-provide-agent
Commit 1d5ea958
Datetime Fri May 1 11:00:10 UTC 2026 (1777633210)
Workflow run 25211981040

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=34681

Summary by CodeRabbit

  • Refactor
    • Optimized Vitest plugin initialization by relocating telemetry detection and session management to an earlier configuration stage for improved efficiency.
    • Expanded conditions for test analysis feature activation to cover broader scenarios beyond component test paths.

Co-authored-by: Copilot <copilot@github.com>
@JReinhold JReinhold self-assigned this May 1, 2026
@JReinhold JReinhold requested a review from yannbf May 1, 2026 10:57
@JReinhold JReinhold moved this to In Progress in Core Team Projects May 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Fails
🚫 The "#### Manual testing" section must be filled in. Please describe how to test the changes you've made, step by step, so that reviewers can confirm your PR works as intended.

Generated by 🚫 dangerJS against 1d5ea95

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: db320cc6-d154-4bd7-8a95-df7be202a97a

📥 Commits

Reviewing files that changed from the base of the PR and between 5491707 and 1d5ea95.

📒 Files selected for processing (1)
  • code/addons/vitest/src/vitest-plugin/index.ts

📝 Walkthrough

Walkthrough

The Vitest plugin refactors telemetry and agent detection, moving this logic from the configureVitest hook to an earlier config hook. The reporter injection condition is updated to activate based on previously computed values, and render analysis activation is broadened to include agents within ai-setup sessions.

Changes

Cohort / File(s) Summary
Vitest Plugin Telemetry Refactoring
code/addons/vitest/src/vitest-plugin/index.ts
Relocated agent and session detection from configureVitest to config hook; gated reporter injection on previously computed detection state; expanded test.provide activation condition to include ai-setup session agents.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

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

@JReinhold JReinhold added bug ci:normal Run our default set of CI jobs (choose this for most PRs). addon: vitest labels May 1, 2026
@JReinhold JReinhold merged commit 4dfac81 into next May 1, 2026
128 of 133 checks passed
@JReinhold JReinhold deleted the jeppe/fix-vitest-provide-agent branch May 1, 2026 11:31
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Core Team Projects May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addon: vitest agent-scan:human bug ci:normal Run our default set of CI jobs (choose this for most PRs).

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants