📌 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
🔒 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
📌 Description
SettlementsPanel(src/components/SettlementsPanel.tsx) callsexecuteSettlement/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
🛠️ Suggested execution
SettlementsPanel.tsx's state handling around theexecuteSettlement/cancelSettlementcalls to apply an optimistic update with rollback.src/components/SettlementsPanel.test.tsxwith success and failure scenarios asserting the optimistic update and rollback respectively.SettlementDetail.tsx's own execute/cancel actions if it duplicates this logic.✅ Acceptance criteria
🔒 Security notes
No new attack surface; purely a perceived-latency UX improvement backed by the same authoritative server response.
📋 Guidelines