Skip to content

feat: migrate artist delete to dedicated api#1665

Merged
sweetmantech merged 3 commits intotestfrom
codex/artist-delete-endpoint-chat
Apr 10, 2026
Merged

feat: migrate artist delete to dedicated api#1665
sweetmantech merged 3 commits intotestfrom
codex/artist-delete-endpoint-chat

Conversation

@arpitgupta1214
Copy link
Copy Markdown
Collaborator

@arpitgupta1214 arpitgupta1214 commented Apr 9, 2026

Summary

  • switch both artist delete UI flows to the dedicated DELETE /api/artists/{id} endpoint
  • keep optimistic removal but refresh from the server and roll back on failure
  • remove the unused local app/api/artist/remove route

Stack

Testing

  • pnpm exec eslint components/ArtistSetting/DeleteModal.tsx components/Artists/DropDown.tsx lib/artists/deleteArtist.ts

Summary by cubic

Migrated artist deletion to the dedicated DELETE /api/artists/{id} endpoint and centralized the flow in a useDeleteArtist hook with optimistic UI and clearer errors. Roll back only if the delete API fails; keep state if refresh fails and show a toast.

  • Refactors
    • Removed app/api/artist/remove and added lib/artists/deleteArtist using getClientApiBaseUrl() and Bearer auth.
    • Introduced hooks/useDeleteArtist to handle optimistic updates, @privy-io/react-auth token, refresh via getArtists(), and sonner toasts.
    • Updated DeleteModal and Artists/DropDown to use the hook and simplify delete UI.

Written for commit 4f5e58a. Summary will update on new commits.

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
recoup-chat Ready Ready Preview Apr 10, 2026 0:34am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 9, 2026

Warning

Rate limit exceeded

@arpitgupta1214 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 16 minutes and 39 seconds before requesting another review.

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 16 minutes and 39 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 03f306c0-9fe9-4a6f-9a72-fc2d258359c5

📥 Commits

Reviewing files that changed from the base of the PR and between 48ef4ed and 4f5e58a.

📒 Files selected for processing (5)
  • app/api/artist/remove/route.ts
  • components/ArtistSetting/DeleteModal.tsx
  • components/Artists/DropDown.tsx
  • hooks/useDeleteArtist.ts
  • lib/artists/deleteArtist.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/artist-delete-endpoint-chat

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.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2657aa6cdd

ℹ️ 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".

Comment on lines +30 to +32
await getArtists();
} catch (error) {
setArtists(previousArtists);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Separate delete errors from refresh errors

If deleteArtist succeeds but getArtists() fails (e.g., transient API/network error), this catch path restores previousArtists, which re-adds an artist that was already deleted server-side. That leaves the UI in an incorrect state and can prompt duplicate delete attempts. Handle post-delete refresh failures separately so rollback only happens when the DELETE request itself fails.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b21109b. Rollback now only happens when the DELETE call fails; refresh failures keep the optimistic removal and surface a toast instead.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 2 files (changes from recent commits).

Requires human review: This PR migrates a core data deletion operation to a new API, introduces new authentication logic, and implements optimistic UI state management, which requires human review.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 4 files

Confidence score: 3/5

  • There is a concrete user-impact risk: in both components/Artists/DropDown.tsx and components/ArtistSetting/DeleteModal.tsx, a getArtists() refresh failure can trigger rollback logic and re-add an artist that was actually deleted.
  • The issue is moderate severity (5/10) with reasonable confidence, so this is likely not merge-blocking, but it can cause confusing stale/incorrect UI state after delete operations.
  • This PR likely becomes safer once delete failure handling is separated from refresh failure handling, so successful deletes are not undone by fetch errors.
  • Pay close attention to components/Artists/DropDown.tsx and components/ArtistSetting/DeleteModal.tsx - rollback is currently coupled to refresh errors, which can resurrect deleted artists.
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/Artists/DropDown.tsx">

<violation number="1" location="components/Artists/DropDown.tsx:23">
P2: `getArtists()` errors will trigger the rollback, which can re-add an artist even after the delete succeeded. Only roll back when the delete fails and handle refresh failures separately to avoid showing stale data.</violation>
</file>

<file name="components/ArtistSetting/DeleteModal.tsx">

<violation number="1" location="components/ArtistSetting/DeleteModal.tsx:38">
P2: `getArtists()` shares the same catch as the delete call, so a refresh failure rolls back to `previousArtists` even if the delete already succeeded. Handle refresh errors separately so you don’t resurrect a deleted artist in the UI.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files (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/useDeleteArtist.ts">

<violation number="1" location="hooks/useDeleteArtist.ts:33">
P2: If `onSuccess` throws, the catch block rolls back the optimistic removal even though the server-side delete already succeeded. Move `options?.onSuccess?.()` after the first try-catch to match the stated intent of only rolling back on delete API failure.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment on lines +33 to +39
options?.onSuccess?.();
} catch (error) {
setArtists(previousArtists);
toast.error(error instanceof Error ? error.message : "Failed to delete artist");
return;
}

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: If onSuccess throws, the catch block rolls back the optimistic removal even though the server-side delete already succeeded. Move options?.onSuccess?.() after the first try-catch to match the stated intent of only rolling back on delete API failure.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At hooks/useDeleteArtist.ts, line 33:

<comment>If `onSuccess` throws, the catch block rolls back the optimistic removal even though the server-side delete already succeeded. Move `options?.onSuccess?.()` after the first try-catch to match the stated intent of only rolling back on delete API failure.</comment>

<file context>
@@ -0,0 +1,50 @@
+      }
+
+      await deleteArtist(accessToken, artistId);
+      options?.onSuccess?.();
+    } catch (error) {
+      setArtists(previousArtists);
</file context>
Suggested change
options?.onSuccess?.();
} catch (error) {
setArtists(previousArtists);
toast.error(error instanceof Error ? error.message : "Failed to delete artist");
return;
}
} catch (error) {
setArtists(previousArtists);
toast.error(error instanceof Error ? error.message : "Failed to delete artist");
return;
}
options?.onSuccess?.();
Fix with Cubic

@sweetmantech sweetmantech merged commit 74245c3 into test Apr 10, 2026
4 checks passed
@sweetmantech sweetmantech deleted the codex/artist-delete-endpoint-chat branch April 10, 2026 03:02
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.

2 participants