Skip to content

chore: sync test → main (Privy auth for task delete)#1733

Merged
sweetmantech merged 1 commit intomainfrom
test
May 6, 2026
Merged

chore: sync test → main (Privy auth for task delete)#1733
sweetmantech merged 1 commit intomainfrom
test

Conversation

@sweetmantech
Copy link
Copy Markdown
Collaborator

@sweetmantech sweetmantech commented May 6, 2026

Summary

Test plan

  • E2E tested on the deployed preview with Chrome DevTools MCP — DELETE https://test-recoup-api.vercel.app/api/tasks returns 200 with Privy Bearer auth (results)

Summary by cubic

Enforces Privy-authenticated task deletion and removes the legacy local delete route. Deletions now call /api/tasks with a Bearer token and provide clearer errors.

  • Refactors
    • useDeleteScheduledAction: gets an access token from @privy-io/react-auth and passes it to deleteTask.
    • deleteTask: sends Authorization Bearer to ${getClientApiBaseUrl()}/api/tasks; throws on non-ok responses or when API returns status: "error".
    • Removed app/api/scheduled-actions/delete/route.ts and the local fallback logic.
    • Added unit tests for success and error cases.

Written for commit 8d57493. Summary will update on new commits.

* feat: integrate Privy authentication for task deletion

- Updated `useDeleteScheduledAction` to include Privy authentication, requiring an access token for task deletion.
- Modified `deleteTask` function to accept an access token and handle API requests accordingly, improving security and error handling.
- Enhanced error messages for better user feedback during deletion failures.

* feat: enhance task deletion error handling and local fallback

- Introduced a constant for the sign-in error message in `useDeleteScheduledAction` for improved consistency.
- Updated error handling in `deleteTask` to check for a "Schedule not found" error and fallback to a local delete endpoint.
- Added a test case to verify the fallback behavior when the scheduler indicates that a task is not found.

* fix: improve error handling in task deletion process

- Enhanced the `deleteTaskFromDatabase` function to throw an error with detailed HTTP status and message when the delete request fails.
- Updated the `deleteTask` function to handle "Schedule not found" errors by attempting a local delete fallback.
- Added test cases to verify the new error handling and fallback behavior for task deletion.

* feat: integrate Privy authentication for task deletion in TaskDetailsDialog and TaskCard

- Added Privy authentication to conditionally render delete buttons in TaskDetailsDialogActionButtons and TaskCard components.
- Updated useDeleteScheduledAction to check for user authentication before allowing task deletion.
- Refactored deleteTask function to improve error handling and ensure proper authentication flow during deletion.

* refactor: simplify TaskDetailsDialogActionButtons by using custom hook

- Replaced inline logic with a custom hook `useTaskDetailsDialogActionButtons` to manage state and actions for task details.
- Removed unnecessary props and improved button disable logic based on editing permissions.
- Streamlined the component structure for better readability and maintainability.

* refactor: enhance TaskDetailsDialogActionButtons and useTaskDetailsDialogActionButtons

- Converted TaskDetailsDialogActionButtons to a functional component with improved prop handling.
- Streamlined the useTaskDetailsDialogActionButtons hook by consolidating error handling and removing unnecessary variables.
- Added a constant for the sign-in error message in useDeleteScheduledAction to improve consistency in error feedback.
- Improved readability and maintainability of both components through structural changes.

* refactor: remove legacy scheduled actions delete route and related fallback logic

- Deleted the scheduled actions delete API route as it is no longer needed.
- Removed associated fallback logic in the deleteTask function that handled "Schedule not found" errors.
- Updated tests to reflect the removal of the fallback behavior for task deletion.

* refactor: update error handling in useDeleteScheduledAction for unauthenticated attempts

- Replaced the sign-in error message constant with a new sentinel for unauthenticated delete attempts.
- Improved error handling to throw the new error message when deletion is attempted without authentication.
- Enhanced logging and user feedback for deletion failures while maintaining existing functionality.

* refactor: consolidate TaskDetailsDialogActionButtons and remove custom hook

- Refactored TaskDetailsDialogActionButtons to directly handle task actions, eliminating the use of the custom hook `useTaskDetailsDialogActionButtons`.
- Improved prop handling and error management for task updates and deletions.
- Streamlined button rendering logic by removing conditional rendering based on authentication, simplifying the component structure.
- Updated the delete action to ensure proper error handling and user feedback during task deletion.

* refactor: update TaskDetailsDialogActionButtons to use Privy authentication and streamline task actions

- Refactored TaskDetailsDialogActionButtons to utilize Privy for authentication, conditionally rendering the delete button based on user authentication status.
- Consolidated task action handlers into a custom hook, improving code organization and readability.
- Enhanced prop handling by importing types directly from the mutation handlers, simplifying the component's interface.
- Updated error handling in useDeleteScheduledAction to throw a specific error for unauthenticated delete attempts, improving clarity in error management.

* refactor: streamline TaskDetailsDialogActionButtons and remove custom hook

- Refactored TaskDetailsDialogActionButtons to directly manage task actions, eliminating the custom hook for improved clarity and maintainability.
- Enhanced prop handling by defining the interface directly within the component, simplifying the structure.
- Updated task action handlers to provide better error handling and user feedback during task updates and deletions.
- Removed legacy code related to Privy authentication, ensuring a more straightforward implementation of task actions.

* revert: drop unrelated cosmetic changes from TaskDetailsDialogActionButtons

The Privy auth integration lives in useDeleteScheduledAction.ts and deleteTask.ts
— this file doesn't need touching. Reverting to test removes formatting noise
(inlined objects/JSX, removed intermediate vars, exported interface) and the
redundant `disabled={isLoading || !canEdit}` (the parent already gates rendering
on canEdit at TaskDetailsDialog.tsx:72).

---------

Co-authored-by: Sweets Sweetman <sweetmantech@gmail.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 6, 2026

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

Project Deployment Actions Updated (UTC)
chat Building Building Preview May 6, 2026 10:55pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 6, 2026

Warning

Rate limit exceeded

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

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ 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: dbce1bc4-4ce0-43e7-8ac8-629b10d355e6

📥 Commits

Reviewing files that changed from the base of the PR and between a6be108 and 8d57493.

⛔ Files ignored due to path filters (2)
  • lib/tasks/__tests__/deleteTask.errors.test.ts is excluded by !**/*.test.* and included by lib/**
  • lib/tasks/__tests__/deleteTask.test.ts is excluded by !**/*.test.* and included by lib/**
📒 Files selected for processing (3)
  • app/api/scheduled-actions/delete/route.ts
  • hooks/useDeleteScheduledAction.ts
  • lib/tasks/deleteTask.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test

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.

@sweetmantech sweetmantech merged commit 4d180dc into main May 6, 2026
2 of 3 checks passed
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.

No issues found across 5 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Modifies task deletion logic, removes a local fallback, and introduces Privy auth dependency. This changes error handling and could affect data integrity if the new API path fails.

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