feat(chat): migrate agent templates calls to dedicated api#1745
feat(chat): migrate agent templates calls to dedicated api#1745arpitgupta1214 wants to merge 1 commit into
Conversation
Cuts over the 6 agent-templates / agent-creator callers to the new dedicated api endpoints with Bearer auth and snake_case bodies. The GET list now embeds the creator block per row, so AgentCreator no longer fires a per-card fetch. Deletes the orphaned local routes (app/api/agent-templates/, app/api/agent-creator/) and their backing supabase helpers (lib/supabase/agent_templates/), plus admin.ts/getAccountById.ts/ getAccountDetailsByEmails.ts where no other callers remain. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ 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 (42)
✨ 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.
1 issue found across 43 files
Confidence score: 4/5
- This PR is likely safe to merge with minimal risk, since the reported issue is moderate (5/10) and limited to one error-handling path.
- In
components/Agents/AgentEditDialog.tsx, callingres.json()before checking response status can throw on non-JSON error bodies, which may mask the original API failure and surface a less helpful error to users. - Pay close attention to
components/Agents/AgentEditDialog.tsx- ensure status/error handling happens before JSON parsing so API failures are reported reliably.
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="components/Agents/AgentEditDialog.tsx">
<violation number="1" location="components/Agents/AgentEditDialog.tsx:67">
P2: `res.json()` is called unconditionally before error-status handling, which can throw on non-JSON responses and mask the real API failure.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| const data = await res.json(); | ||
| if (!res.ok || data.status === "error") { | ||
| throw new Error(data.error || "Failed to update template"); |
There was a problem hiding this comment.
P2: res.json() is called unconditionally before error-status handling, which can throw on non-JSON responses and mask the real API failure.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At components/Agents/AgentEditDialog.tsx, line 67:
<comment>`res.json()` is called unconditionally before error-status handling, which can throw on non-JSON responses and mask the real API failure.</comment>
<file context>
@@ -35,26 +38,37 @@ const AgentEditDialog: React.FC<AgentEditDialogProps> = ({ agent }) => {
+ }),
+ },
+ );
+ const data = await res.json();
+ if (!res.ok || data.status === "error") {
+ throw new Error(data.error || "Failed to update template");
</file context>
| const data = await res.json(); | |
| if (!res.ok || data.status === "error") { | |
| throw new Error(data.error || "Failed to update template"); | |
| const data = await res.json().catch(() => null); | |
| if (!res.ok || data?.status === "error") { | |
| throw new Error(data?.error || "Failed to update template"); | |
| } |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 01d05c0500
ℹ️ 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 (!res.ok) { | ||
| throw new Error("Failed to toggle favorite"); | ||
| } |
There was a problem hiding this comment.
Validate favorite response payload before treating as success
The new favorite toggle call only checks res.ok, but this migration’s API contract uses a { status: "success" | "error" } payload (see ToggleFavoriteResponse and the other migrated agent-template calls that check data.status === "error"). If /favorite returns HTTP 200 with status: "error" (a pattern already handled elsewhere in this repo), this path will incorrectly show a success toast and refresh the list as if the mutation succeeded.
Useful? React with 👍 / 👎.
|
Closing — chat repo deprecated; cutover no longer needed. api#543 and docs#199 remain valid for the new surface. |
Cuts over the 6 agent-templates / agent-creator callers to the dedicated api endpoints (recoupable/api#543) with Bearer auth and snake_case bodies. The list response now embeds creator info per row, so
AgentCreatorno longer fires a per-card lookup. Deletes the orphaned local routes and supabase helpers.Test plan
creatorblock (not from a/api/agent-creatorfetch)🤖 Generated with Claude Code
Summary by cubic
Migrate Agents templates to the dedicated API with Bearer auth and snake_case bodies, removing local routes and Supabase helpers. The list now embeds a
creatorobject per template, eliminating extra per-card fetches and speeding up the Agents tab.New Features
@privy-io/react-authcreator;AgentCreatorrenders fromagent.creatoris_private,share_emails)Refactors
app/api/agent-templates/*,app/api/agent-creator) and unused Supabase helpersfetchAgentTemplates(accessToken)andgetClientApiBaseUrlcreatorIdprops withcreatorobjects across componentsWritten for commit 01d05c0. Summary will update on new commits.