Skip to content

feat: optimistic updates for pause/resume/cancel with rollback - #522

Open
ZacLou wants to merge 2 commits into
conduit-protocol:mainfrom
ZacLou:feat/optimistic-updates-454
Open

feat: optimistic updates for pause/resume/cancel with rollback#522
ZacLou wants to merge 2 commits into
conduit-protocol:mainfrom
ZacLou:feat/optimistic-updates-454

Conversation

@ZacLou

@ZacLou ZacLou commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Addresses #454

Problem

Stream actions (pause/resume/cancel) waited for the full simulate -> sign -> submit -> poll cycle before updating the UI. Users saw a spinner for 10+ seconds with no visual feedback.

Solution

lib/optimistic-updates.ts (new)

Four helper functions:

  • optimisticStreamStatusUpdate(qc, address, newStatus) — updates the stream's cached info and list entry with the new status. Returns a snapshot for rollback.
  • rollbackStreamStatus(qc, address, snapshot) — restores the previous cached value on error.
  • optimisticWithdrawUpdate(qc, address, amount) — reduces the displayed withdrawable balance. Returns snapshot.
  • rollbackWithdraw(qc, address, snapshot) — restores the previous balance on error.

components/stream/StreamActions.tsx

  • run() now accepts an optional optimisticStatus parameter
  • Before the mutation: applies the optimistic update and saves a snapshot
  • On success: invalidates queries to refetch fresh data (existing behavior)
  • On error: rolls back the optimistic update from the snapshot
  • Pause passes 'paused', resume passes 'active', cancel passes 'cancelled'

Behavior

  1. User clicks Pause -> UI immediately shows 'paused' status
  2. Transaction submits in background
  3. On success: queries refetch with confirmed on-chain state
  4. On error: UI rolls back to previous status, error message shown

Files changed

  • lib/optimistic-updates.ts (new)
  • components/stream/StreamActions.tsx (run function + button handlers)

ZacLou and others added 2 commits September 5, 2026 23:56
…it-protocol#454)

Applies immediate cache updates when the user clicks pause, resume, or
cancel so the UI reflects the expected state before the transaction
confirms. Rolls back on error.

- lib/optimistic-updates.ts: optimisticStreamStatusUpdate,
  rollbackStreamStatus, optimisticWithdrawUpdate, rollbackWithdraw
- StreamActions.run() now accepts optimisticStatus parameter
- Pause passes 'paused', resume passes 'active', cancel passes 'cancelled'
- On error, snapshot is restored and queries invalidated for refetch

Addresses conduit-protocol#454
@ZacLou
ZacLou force-pushed the feat/optimistic-updates-454 branch from ef4105a to d6867b8 Compare September 5, 2026 15:56
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