feat(chat): migrate GET /api/accounts/{id}/catalogs#1691
Conversation
Repoints the chat caller off the legacy Agent API host onto the new nested route on recoup-api.vercel.app. Adds Privy Bearer auth and threads the access token through useCatalogs.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 0 minutes and 39 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c7c9381edc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (!accessToken) throw new Error("No access token"); | ||
| return getCatalogs(accountId, accessToken); | ||
| }, | ||
| enabled: !!accountId, |
There was a problem hiding this comment.
Gate catalog query on auth readiness
The query is enabled as soon as accountId exists, but this migrated path now requires a Privy bearer token and queryFn throws when getAccessToken() returns null. In the startup window where account data is loaded before Privy auth is ready, this puts the Catalogs page into an error state ("No access token") instead of waiting, and it may not recover until a manual refetch/focus. Please include auth readiness (e.g., authenticated/ready) in the enabled predicate so the request only runs once a token can be issued.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: API migration involving endpoint changes and new authentication requirements; carries risk of breaking the feature if not synchronized with backend deployment.
Add `authenticated` from usePrivy() to the query's `enabled` flag so the request doesn't fire with an empty Bearer token before Privy resolves. Matches the canonical pattern in useAccountOrganizations.ts / useSandboxes.ts. Note: pnpm lint / typecheck not run — node_modules missing in worktree. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="hooks/useCatalogs.ts">
<violation number="1" location="hooks/useCatalogs.ts:18">
P2: Gating the query with `authenticated` suppresses the `No access token` error path and can produce a silent empty-state instead of an auth error.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| if (!accessToken) throw new Error("No access token"); | ||
| return getCatalogs(accountId, accessToken); | ||
| }, | ||
| enabled: !!accountId && authenticated, |
There was a problem hiding this comment.
P2: Gating the query with authenticated suppresses the No access token error path and can produce a silent empty-state instead of an auth error.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At hooks/useCatalogs.ts, line 18:
<comment>Gating the query with `authenticated` suppresses the `No access token` error path and can produce a silent empty-state instead of an auth error.</comment>
<file context>
@@ -15,7 +15,7 @@ const useCatalogs = (): UseQueryResult<CatalogsResponse> => {
return getCatalogs(accountId, accessToken);
},
- enabled: !!accountId,
+ enabled: !!accountId && authenticated,
staleTime: 5 * 60 * 1000, // 5 minutes
refetchOnWindowFocus: false,
</file context>
| enabled: !!accountId && authenticated, | |
| enabled: !!accountId, |
Cut
getCatalogs/useCatalogsover toGET /api/accounts/{id}/catalogsonrecoup-api.vercel.appwith Privy Bearer auth; id moves from query to path. Newtypes/Catalog.tsreplaces the Supabase-coupled type.Test plan
/catalogspreview renders catalog listGET …/api/accounts/<uuid>/catalogswithAuthorization: Bearer …, status 200