Skip to content

Add optimistic UI updates for executeSettlement/cancelSettlement in SettlementsPanel #76

Description

@Jagadeeshftw

📌 Description

SettlementsPanel (src/components/SettlementsPanel.tsx) calls executeSettlement/cancelSettlement (src/lib/settlementsApi.ts) and, per the README, reports success/failure via a toast. It's unclear whether the table reflects the new status immediately or waits for a full refetch, which on a slower connection leaves the row showing a stale "pending" status right after the user confirms the action.

🧩 Requirements and context

  • On execute/cancel, optimistically flip the affected row's status locally before the network response returns.
  • On failure, roll back to the previous status and show an error toast (the existing failure-toast behavior).
  • On success, reconcile with the server response in case any other field (e.g. fee) changed.

🛠️ Suggested execution

  • Update SettlementsPanel.tsx's state handling around the executeSettlement/cancelSettlement calls to apply an optimistic update with rollback.
  • Extend src/components/SettlementsPanel.test.tsx with success and failure scenarios asserting the optimistic update and rollback respectively.
  • Apply the same pattern to SettlementDetail.tsx's own execute/cancel actions if it duplicates this logic.

✅ Acceptance criteria

  • Row status updates immediately on confirm, before the network response.
  • A failed request rolls back the optimistic update and shows an error toast.
  • A successful request reconciles with the server's actual response.

🔒 Security notes

No new attack surface; purely a perceived-latency UX improvement backed by the same authoritative server response.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26enhancementNew feature or improvement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions