Repository navigation
feat(catalog): persist and reconcile provider snapshots - #905
Conversation
|
Warning Review limit reached
Next review available in: 32 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
📝 WalkthroughWalkthroughAdds persisted provider catalog snapshots with stale-while-revalidate refreshes, bounded reconciliation, server push events, Codex lifecycle handling, and web-store application of incremental catalog changes. ChangesProvider catalog contracts and persistence
Refresh orchestration
Server integration
Web client reconciliation
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/server/src/store/schema.ts (1)
325-341: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winDeleted workspaces leave orphaned catalog snapshot rows.
workspaceIdhas no FK/cascade toworkspaces, and the repo's eviction (per the referencedprovider-catalog-snapshot-repo.tsupsert) only caps rows per-provider, not per-workspace. Workspace deletion (workspace.delete/workspace.forceDeleteinws-router.ts) doesn't appear to clean up this table, so a deleted workspace's cached snapshot (with itscwd/path) can persist indefinitely until pushed out by unrelated provider activity.Consider adding a
references(() => workspaces.id, { onDelete: "cascade" })onworkspaceId, or an explicit repo method invoked from the workspace delete handlers.♻️ Proposed schema fix
contextKey: text("context_key").primaryKey().notNull(), providerId: text("provider_id").notNull(), - workspaceId: text("workspace_id"), + workspaceId: text("workspace_id").references(() => workspaces.id, { onDelete: "cascade" }), cwd: text("cwd"),🤖 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 `@apps/server/src/store/schema.ts` around lines 325 - 341, Update providerCatalogSnapshots.workspaceId to reference workspaces.id with onDelete cascade, using the existing workspaces table symbol and preserving its nullable behavior for non-workspace snapshots. Ensure the schema relation causes catalog snapshot rows to be removed automatically when a workspace is deleted.Source: Coding guidelines
🤖 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 `@apps/web/src/transport/ws-events.ts`:
- Around line 348-352: Update the provider.catalogChanged handler in the
pushEmitter subscription to validate each raw payload with
ProviderCatalogChangeSchema before calling
useProviderCatalogStore.getState().reconcile. Only reconcile successfully parsed
ProviderCatalogChange values, and silently drop invalid events so malformed data
cannot reach applyCatalogChange during pending-change replay.
---
Nitpick comments:
In `@apps/server/src/store/schema.ts`:
- Around line 325-341: Update providerCatalogSnapshots.workspaceId to reference
workspaces.id with onDelete cascade, using the existing workspaces table symbol
and preserving its nullable behavior for non-workspace snapshots. Ensure the
schema relation causes catalog snapshot rows to be removed automatically when a
workspace is deleted.
🪄 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: 5ae26e89-33f8-4e8c-af19-e742fd9d5cc1
📒 Files selected for processing (20)
apps/server/drizzle/0023_grey_wildside.sqlapps/server/drizzle/meta/0023_snapshot.jsonapps/server/drizzle/meta/_journal.jsonapps/server/src/container.tsapps/server/src/index.tsapps/server/src/repositories/provider-catalog-snapshot-repo.test.tsapps/server/src/repositories/provider-catalog-snapshot-repo.tsapps/server/src/services/__tests__/codex-catalog-service.test.tsapps/server/src/services/codex-catalog-service.tsapps/server/src/services/provider-catalog-service.test.tsapps/server/src/services/provider-catalog-service.tsapps/server/src/store/schema.tsapps/server/src/transport/ws-router.tsapps/server/src/transport/ws-router.validation.test.tsapps/web/src/stores/providerCatalogStore.test.tsapps/web/src/stores/providerCatalogStore.tsapps/web/src/transport/ws-events.tspackages/contracts/src/index.tspackages/contracts/src/providers/capability-catalog.tspackages/contracts/src/ws/channels.ts
What
Persist provider catalog snapshots per workspace and worktree context, then reconcile background refreshes by stable identity.
Why
Catalog pickers should render the last confirmed capabilities immediately across restarts and provider process eviction without blocking on Codex startup.
Key Changes
Closes #893
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by CodeRabbit