Skip to content

feat: add cancel/refund flow with contributor-first escrow refund#656

Open
BWM0223 wants to merge 1 commit into
boundlessfi:mainfrom
BWM0223:feat/cancel-refund-flow
Open

feat: add cancel/refund flow with contributor-first escrow refund#656
BWM0223 wants to merge 1 commit into
boundlessfi:mainfrom
BWM0223:feat/cancel-refund-flow

Conversation

@BWM0223

@BWM0223 BWM0223 commented Jun 25, 2026

Copy link
Copy Markdown

Summary

Fixes #634 - FE: Cancel / refund flow

Changes

  • CancelRefundFlow component with 3-step UX: confirm, processing, done
  • Clear refund-order explanation (contributors first, owner residual)
  • Escrow balance display before confirmation
  • Error handling with retry capability
  • Reflects CANCELLED state on completion

Summary by CodeRabbit

  • New Features
    • Added a new multi-step bounty cancellation flow with confirmation, progress, and success states.
    • Users now see a warning before cancelling, including refund ordering details.
    • On success, a completion message and close action are shown.
    • If cancellation fails, an error message is displayed and the user can try again.

@BWM0223 BWM0223 requested a review from 0xdevcollins as a code owner June 25, 2026 05:40
@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

@BWM0223 is attempting to deploy a commit to the Threadflow Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a client-side CancelRefundFlow component for bounty cancellation with typed props, async confirm/processing/done state, error handling, refund-order messaging, and close/confirm actions.

Changes

Cancel refund flow

Layer / File(s) Summary
Props and cancellation state
components/bounty/CancelRefundFlow.tsx
The component defines bounty and callback props, tracks confirm/processing/done state, and handles cancel success and failure transitions.
Step views and export
components/bounty/CancelRefundFlow.tsx
The component renders the step-specific views, including refund-order messaging, escrow counts, and close/confirm actions, and exports the component as default.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped through cancel paths so neat,
The refund flow now skips and leaps to beat.
Confirm, then wait, then done at last,
With bunny cheers and crumbs of cast.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR adds the confirmation UI, but it does not show useEscrowOpRunner integration, CANCELLED state updates, or refund transaction reflection. Wire the cancel action into the bounty UI, run the escrow cancel op through useEscrowOpRunner, and reflect CANCELLED plus the refund transaction.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the new cancel/refund flow and contributor-first escrow refund behavior.
Out of Scope Changes check ✅ Passed The changes stay focused on the cancel/refund flow and do not introduce unrelated functionality.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
components/bounty/CancelRefundFlow.tsx (1)

17-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use a typed const arrow component per project TS/React style.

Lines 17-19 use a function declaration; project guidance asks for const arrow functions with explicit typing.
As per coding guidelines, "**/*.{js,jsx,ts,tsx}: Prefer const arrow functions with explicit type annotations over function declarations".

Suggested refactor
-export function CancelRefundFlow({
+export const CancelRefundFlow = ({
   bountyId, bountyTitle, escrowBalance, contributorCount, onCancel, onClose
-}: CancelRefundFlowProps) {
+}: CancelRefundFlowProps): JSX.Element => {
   const [step, setStep] = useState<"confirm" | "processing" | "done">("confirm");
   const [error, setError] = useState<string | null>(null);
@@
-}
+};
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@components/bounty/CancelRefundFlow.tsx` around lines 17 - 20, The
CancelRefundFlow component is declared as a function declaration, but the
project style requires typed const arrow components. Refactor CancelRefundFlow
to a const arrow function with an explicit component type annotation, keeping
the existing props and internal state logic unchanged so the symbol remains easy
to locate and consistent with the TS/React style used elsewhere.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@components/bounty/CancelRefundFlow.tsx`:
- Around line 29-31: The catch handler in CancelRefundFlow should not use any;
update the catch clause to unknown and narrow the value before reading message.
In the error-handling path around setError and setStep, add a type guard or
instanceof Error check so only Error-like values access message, and keep the
fallback "Cancellation failed" for non-Error cases.

---

Nitpick comments:
In `@components/bounty/CancelRefundFlow.tsx`:
- Around line 17-20: The CancelRefundFlow component is declared as a function
declaration, but the project style requires typed const arrow components.
Refactor CancelRefundFlow to a const arrow function with an explicit component
type annotation, keeping the existing props and internal state logic unchanged
so the symbol remains easy to locate and consistent with the TS/React style used
elsewhere.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 40b431a0-b087-4640-8228-47192486c306

📥 Commits

Reviewing files that changed from the base of the PR and between 2cb7127 and 5a9fb80.

📒 Files selected for processing (1)
  • components/bounty/CancelRefundFlow.tsx

Comment on lines +29 to +31
} catch (e: any) {
setError(e.message ?? "Cancellation failed");
setStep("confirm");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major

Replace any with unknown in error handling.

Line 29 uses any, which violates the type safety guidelines. Update the catch clause to accept unknown and use type narrowing before accessing properties.

Suggested fix
    const handleCancel = async () =&gt; {
      setStep("processing");
      setError(null);
      try {
        await onCancel(bountyId);
        setStep("done");
-     } catch (e: any) {
-       setError(e.message ?? "Cancellation failed");
+     } catch (error: unknown) {
+       const message = error instanceof Error ? error.message : "Cancellation failed";
+       setError(message);
        setStep("confirm");
      }
    };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} catch (e: any) {
setError(e.message ?? "Cancellation failed");
setStep("confirm");
} catch (error: unknown) {
const message = error instanceof Error ? error.message : "Cancellation failed";
setError(message);
setStep("confirm");
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@components/bounty/CancelRefundFlow.tsx` around lines 29 - 31, The catch
handler in CancelRefundFlow should not use any; update the catch clause to
unknown and narrow the value before reading message. In the error-handling path
around setError and setStep, add a type guard or instanceof Error check so only
Error-like values access message, and keep the fallback "Cancellation failed"
for non-Error cases.

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.

FE: Cancel / refund flow

1 participant