feat: migrate room artist lookup to dedicated chats api#1613
feat: migrate room artist lookup to dedicated chats api#1613sweetmantech merged 3 commits intotestfrom
Conversation
|
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 5 minutes and 23 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 selected for processing (3)
✨ 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac59a7b6e3
ℹ️ 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".
hooks/useArtistFromRoom.ts
Outdated
| if (hasRun.current || !roomId || !userData?.id || !accessToken) return; | ||
| hasRun.current = true; |
There was a problem hiding this comment.
Set run guard only after successful artist lookup
This sets hasRun.current = true before the network request, so any transient failure from the new bearer-auth endpoint (for example a 401 during token refresh or a temporary 5xx) permanently disables retries for this chat mount, leaving selectedArtist unset even if accessToken or baseUrl later changes. Since this migration moved lookup to an authenticated external API, this failure mode is now much more likely and should be retried instead of being latched on first attempt.
Useful? React with 👍 / 👎.
Previously hasRun was set before the API call, so transient failures (401 during token refresh, 5xx) permanently blocked retries. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
hooks/useArtistFromRoom.ts
Outdated
| const apiOverride = useApiOverride(); | ||
| const baseUrl = apiOverride || NEW_API_BASE_URL; | ||
|
|
||
| useEffect(() => { |
There was a problem hiding this comment.
DRY
- actual: useEffect in the hook.
- required:
useQueryfrom tanstack
- Extract fetch to lib/chats/getChatArtist.ts (SRP) - Use useQuery with staleTime: Infinity (replaces hasRun ref) - Use getAccessToken from Privy directly (KISS) - TanStack handles retries, caching, and dedup automatically Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
useArtistFromRoomto dedicatedGET /api/chats/{id}/artistuseAccessTokenuseApiOverrideapp/api/room/artist/route.tsxValidation
pnpm exec eslint hooks/useArtistFromRoom.tsrg -n "/api/room/artist|room/artist" --glob "!**/node_modules/**"