Skip to content

fix: detect all changed packages for changeset in model sync pipeline#445

Open
AlemTuzlak wants to merge 2 commits intomainfrom
fix/sync-models-changeset-detection
Open

fix: detect all changed packages for changeset in model sync pipeline#445
AlemTuzlak wants to merge 2 commits intomainfrom
fix/sync-models-changeset-detection

Conversation

@AlemTuzlak
Copy link
Copy Markdown
Contributor

@AlemTuzlak AlemTuzlak commented Apr 12, 2026

Summary

  • The pnpm generate:models pipeline runs 3 scripts: fetch, convert (@tanstack/ai-openrouter regeneration), and sync (provider-specific model additions). The changeset was only created when the sync step found new provider-specific models (totalAdded > 0), silently skipping changesets when only the convert step modified packages (e.g. PR chore: sync model metadata from OpenRouter #441).
  • Replaced the totalAdded > 0 guard with detectChangedPackages() which uses git diff HEAD --name-only -- packages/ to find all packages with uncommitted changes from any pipeline step, then creates a changeset covering all of them.
  • Removed the now-unnecessary hardcoded changedPackages.add('@tanstack/ai-openrouter') from createChangeset() since git diff detection handles it generically.

Fixes the missing changeset in #441.

Test plan

  • Manually trigger the Sync Model Metadata workflow and verify a .changeset/sync-models.md file is created when @tanstack/ai-openrouter changes
  • Verify changeset includes all packages with actual git changes
  • Verify no changeset is created when no packages have changes

Summary by CodeRabbit

  • Chores
    • Improved internal changeset automation to more accurately track package modifications and determine release inclusion.

The `pnpm generate:models` pipeline runs three scripts sequentially:
fetch, convert (regenerates @tanstack/ai-openrouter), and sync
(adds new models to provider-specific packages). The changeset was
only created when sync found new provider-specific models
(totalAdded > 0), missing changes from the convert step entirely.

Replace the totalAdded guard with git-based detection that finds all
packages with uncommitted changes across the entire pipeline, ensuring
changesets are created whenever any package is modified.
@AlemTuzlak AlemTuzlak requested a review from a team April 12, 2026 18:01
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 12, 2026

📝 Walkthrough

Walkthrough

The scripts/sync-provider-models.ts script now detects changed packages via git diff and combines them with internally-tracked changes before creating changesets. The hardcoded inclusion of @tanstack/ai-openrouter was removed in favor of dynamic set-based inclusion.

Changes

Cohort / File(s) Summary
Git-based change detection
scripts/sync-provider-models.ts
Added detectChangedPackages() function using node:child_process to run git diff HEAD --name-only -- packages/ and derive changed package names. Modified main() to union git-detected packages with script-tracked packages. Removed hardcoded @tanstack/ai-openrouter logic from createChangeset().

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A git-sniffing script hops into view,
Detecting changes old and new,
No hardcoding needed anymore,
Just dynamic sets to explore!
The changeset flows with nature's way,
Hooray for better sync, hooray!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: detecting all changed packages for changeset creation in the model sync pipeline.
Description check ✅ Passed The description covers the problem (missing changesets), the solution (git-based detection), and includes a test plan; however, it deviates from the template structure with informal formatting and incomplete checklist items.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sync-models-changeset-detection

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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 12, 2026

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 12, 2026

View your CI Pipeline Execution ↗ for commit c6bc732

Command Status Duration Result
nx run-many --targets=build --exclude=examples/** ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-12 18:08:25 UTC

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 12, 2026

Open in StackBlitz

@tanstack/ai

npm i https://pkg.pr.new/@tanstack/ai@445

@tanstack/ai-anthropic

npm i https://pkg.pr.new/@tanstack/ai-anthropic@445

@tanstack/ai-client

npm i https://pkg.pr.new/@tanstack/ai-client@445

@tanstack/ai-code-mode

npm i https://pkg.pr.new/@tanstack/ai-code-mode@445

@tanstack/ai-code-mode-skills

npm i https://pkg.pr.new/@tanstack/ai-code-mode-skills@445

@tanstack/ai-devtools-core

npm i https://pkg.pr.new/@tanstack/ai-devtools-core@445

@tanstack/ai-elevenlabs

npm i https://pkg.pr.new/@tanstack/ai-elevenlabs@445

@tanstack/ai-event-client

npm i https://pkg.pr.new/@tanstack/ai-event-client@445

@tanstack/ai-fal

npm i https://pkg.pr.new/@tanstack/ai-fal@445

@tanstack/ai-gemini

npm i https://pkg.pr.new/@tanstack/ai-gemini@445

@tanstack/ai-grok

npm i https://pkg.pr.new/@tanstack/ai-grok@445

@tanstack/ai-groq

npm i https://pkg.pr.new/@tanstack/ai-groq@445

@tanstack/ai-isolate-cloudflare

npm i https://pkg.pr.new/@tanstack/ai-isolate-cloudflare@445

@tanstack/ai-isolate-node

npm i https://pkg.pr.new/@tanstack/ai-isolate-node@445

@tanstack/ai-isolate-quickjs

npm i https://pkg.pr.new/@tanstack/ai-isolate-quickjs@445

@tanstack/ai-ollama

npm i https://pkg.pr.new/@tanstack/ai-ollama@445

@tanstack/ai-openai

npm i https://pkg.pr.new/@tanstack/ai-openai@445

@tanstack/ai-openrouter

npm i https://pkg.pr.new/@tanstack/ai-openrouter@445

@tanstack/ai-preact

npm i https://pkg.pr.new/@tanstack/ai-preact@445

@tanstack/ai-react

npm i https://pkg.pr.new/@tanstack/ai-react@445

@tanstack/ai-react-ui

npm i https://pkg.pr.new/@tanstack/ai-react-ui@445

@tanstack/ai-solid

npm i https://pkg.pr.new/@tanstack/ai-solid@445

@tanstack/ai-solid-ui

npm i https://pkg.pr.new/@tanstack/ai-solid-ui@445

@tanstack/ai-svelte

npm i https://pkg.pr.new/@tanstack/ai-svelte@445

@tanstack/ai-vue

npm i https://pkg.pr.new/@tanstack/ai-vue@445

@tanstack/ai-vue-ui

npm i https://pkg.pr.new/@tanstack/ai-vue-ui@445

@tanstack/preact-ai-devtools

npm i https://pkg.pr.new/@tanstack/preact-ai-devtools@445

@tanstack/react-ai-devtools

npm i https://pkg.pr.new/@tanstack/react-ai-devtools@445

@tanstack/solid-ai-devtools

npm i https://pkg.pr.new/@tanstack/solid-ai-devtools@445

commit: c6bc732

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 the current code and only fix it if needed.

Inline comments:
In `@scripts/sync-provider-models.ts`:
- Around line 526-528: The catch block that swallows all execFileSync errors in
scripts/sync-provider-models.ts should distinguish expected "not a repo" cases
from real failures: inside the catch after the execFileSync(...) call, log the
caught error (e.g., console.warn or processLogger.warn) and only return the
empty set when the error message indicates a non-repo (match on "not a git
repository" / exit code), otherwise rethrow or exit non‑zero so CI fails; update
the handler around the execFileSync invocation (the try/catch that currently
returns an empty set) to implement this conditional logging-and-fail behavior.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: f871ac4f-879e-4253-898c-5b7162e53efd

📥 Commits

Reviewing files that changed from the base of the PR and between e832506 and b0088be.

📒 Files selected for processing (1)
  • scripts/sync-provider-models.ts

Comment on lines +526 to +528
} catch {
// git not available (e.g. running outside a repo) — fall back to empty set
}
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 | 🟡 Minor

Surface unexpected git diff failures here.

Returning an empty set for every execFileSync error makes the workflow quietly skip the changeset again when Git detection breaks for any reason other than an intentional local “not a repo” run. I’d at least warn on the fallback and fail loudly in CI.

🔧 Suggested tightening
-  } catch {
-    // git not available (e.g. running outside a repo) — fall back to empty set
+  } catch (error) {
+    if (process.env.GITHUB_ACTIONS === 'true') {
+      throw error
+    }
+    console.warn('Failed to detect changed packages via git diff:', error)
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/sync-provider-models.ts` around lines 526 - 528, The catch block that
swallows all execFileSync errors in scripts/sync-provider-models.ts should
distinguish expected "not a repo" cases from real failures: inside the catch
after the execFileSync(...) call, log the caught error (e.g., console.warn or
processLogger.warn) and only return the empty set when the error message
indicates a non-repo (match on "not a git repository" / exit code), otherwise
rethrow or exit non‑zero so CI fails; update the handler around the execFileSync
invocation (the try/catch that currently returns an empty set) to implement this
conditional logging-and-fail behavior.

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.

1 participant