Skip to content

feat(collections): create studio collections for AI if detected#3709

Merged
farnabaz merged 3 commits intomainfrom
feat/studio-ai
Feb 5, 2026
Merged

feat(collections): create studio collections for AI if detected#3709
farnabaz merged 3 commits intomainfrom
feat/studio-ai

Conversation

@larbish
Copy link
Collaborator

@larbish larbish commented Jan 29, 2026

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Adds automatic detection and configuration of Studio AI context collections when nuxt-studio is installed.

What it does

When Nuxt Studio is installed with AI features enabled (studio.ai.apiKey configured), the Content module automatically:

  • Creates a studio collection for AI context files (configurable via studio.ai.context.collection)
  • Excludes .studio/** files from all other collections to prevent conflicts
  • Uses schema { rawbody: string } for storing raw markdown context

Implementation

  • New: src/utils/studio.ts - Contains resolveStudioCollection() utility
  • Modified: src/utils/config.ts - Detects nuxt-studio and applies configuration during collection loading

Configuration

Studio module can configure the collection:

export default defineNuxtConfig({
  studio: {
    ai: {
      apiKey: 'xxx',
      context: {
        collection: {
          name: 'studio',    // defaults to 'studio'
          folder: '.studio'  // defaults to '.studio'
        }
      }
    }
  }
})

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@vercel
Copy link

vercel bot commented Jan 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
content Ready Ready Preview, Comment Feb 5, 2026 0:32am

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 29, 2026

npm i https://pkg.pr.new/@nuxt/content@3709

commit: 947ecf2

@farnabaz farnabaz marked this pull request as ready for review February 5, 2026 11:16
@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

Adds automatic nuxt-studio configuration when the nuxt-studio module is present. Introduces src/utils/studio.ts with resolveStudioCollection(nuxt, collectionsConfig) which creates or ensures a studio collection (schema and source) when an AI apiKey is configured and appends exclude patterns for the studio folder to other collections' sources. Updates src/utils/config.ts to compute a final collections config, invoke resolveStudioCollection conditionally when hasNuxtModule('nuxt-studio'), then resolve collections from the final configuration. Test calls to loadContentConfig now include empty _installedModules and modules arrays in Nuxt options.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding automatic Studio AI collection configuration detection and creation when nuxt-studio is present.
Description check ✅ Passed The description is directly related to the changeset, explaining the feature's purpose, implementation details, and configuration, which aligns with the code changes across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/studio-ai

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/utils/config.ts (1)

68-78: ⚠️ Potential issue | 🟠 Major

Preserve the default content collection when auto-adding the studio collection.

Because resolveStudioCollection() runs before hasNoCollections, a project with no user-defined collections but AI enabled will end up with only the studio collection—skipping both the default content collection and the warning. That changes existing behavior and can break content indexing.

✅ Suggested fix (keep default content + studio when no user collections exist)
-  // If nuxt-studio is installed, automatically configure studio collection
-  if (hasNuxtModule('nuxt-studio')) {
-    resolveStudioCollection(nuxt, collectionsConfig)
-  }
-
-  const hasNoCollections = Object.keys(collectionsConfig || {}).length === 0
-  if (hasNoCollections) {
+  const hasUserCollections = Object.keys(collectionsConfig || {}).length > 0
+
+  // If nuxt-studio is installed, automatically configure studio collection
+  if (hasNuxtModule('nuxt-studio')) {
+    resolveStudioCollection(nuxt, collectionsConfig)
+  }
+
+  if (!hasUserCollections) {
     logger.warn('No content configuration found, falling back to default collection. In order to have full control over your collections, create the config file in project root. See: https://content.nuxt.com/docs/getting-started/installation')
   }
 
-  const collections = resolveCollections(hasNoCollections ? defaultConfig.collections : collectionsConfig)
+  const collections = resolveCollections(
+    !hasUserCollections
+      ? { ...defaultConfig.collections, ...collectionsConfig }
+      : collectionsConfig,
+  )

Copy link

@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: 2

🤖 Fix all issues with AI agents
In `@src/utils/config.ts`:
- Around line 73-79: finalCollectionsConfig currently aliases the module-level
defaultConfig.collections when hasNoCollections is true, and
resolveStudioCollection mutates it; to fix, ensure you create a fresh copy of
the default collections before any mutation: when hasNoCollections is true,
clone defaultConfig.collections into a new object (deep clone via
structuredClone or a utility) and assign that to finalCollectionsConfig, then
call resolveStudioCollection(nuxt, finalCollectionsConfig) and
resolveCollections(finalCollectionsConfig) so the module-level
defaultConfig.collections is never mutated by resolveStudioCollection.
- Around line 73-77: The call to hasNuxtModule currently relies on global
context; update the check to pass the available nuxt instance as the second
argument so it uses the local Nuxt context. Specifically, change the condition
that checks hasNuxtModule(...) to call hasNuxtModule('nuxt-studio', nuxt) so the
local nuxt is used when deciding whether to call
resolveStudioCollection(finalCollectionsConfig, ...) (reference symbols:
hasNuxtModule, nuxt, finalCollectionsConfig, resolveStudioCollection).

@farnabaz farnabaz merged commit 7744645 into main Feb 5, 2026
8 checks passed
@farnabaz farnabaz deleted the feat/studio-ai branch February 5, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants