Skip to content

fix(demo): format session cumulative amount and split channel open UX#8

Merged
coffeexcoin merged 3 commits intomainfrom
coffeexcoin/fix-session-ui-display
Mar 25, 2026
Merged

fix(demo): format session cumulative amount and split channel open UX#8
coffeexcoin merged 3 commits intomainfrom
coffeexcoin/fix-session-ui-display

Conversation

@coffeexcoin
Copy link
Copy Markdown
Collaborator

Summary

  • Format the session cumulative amount display using token decimals (formatUnits with USDC 6 decimals) and prefix with $ — shows $0.001 instead of raw 1000
  • Add onChannelOpened callback to abstractSession client options, called after the on-chain channel open but before voucher signing — supports deferring the voucher via a returned Promise
  • Rework the demo session UI to require two discrete button presses for stream initiation: "Open Channel" (approve + open tx) then "Sign Voucher", instead of firing both signatures in a single click
  • Subsequent voucher requests remain single-click

Test plan

  • Verify cumulative amount displays as $0.001, $0.002, etc. after each session request
  • Verify first session request pauses after channel open and shows "Sign Voucher" button
  • Verify clicking "Sign Voucher" completes the request and shows the response
  • Verify subsequent requests use a single "Send Voucher" button without pause
  • Verify Reset returns to initial state

…open from voucher

Display cumulative amount using formatUnits with USDC_DECIMALS and a $
prefix so the UI shows $0.001 instead of raw 1000.

Add onChannelOpened callback to abstractSession so the demo can pause
between the on-chain channel open and the first voucher signature,
requiring two discrete button presses for stream initiation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 25, 2026

🦋 Changeset detected

Latest commit: 2c0a0ba

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@abstract-foundation/mpp Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 25, 2026

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

Project Deployment Actions Updated (UTC)
mpp-abstract-mpp-demo Ready Ready Preview, Comment Mar 25, 2026 11:18pm

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Mar 25, 2026

PR Summary

Medium Risk
Changes the session client’s channel-open flow by inserting an awaited callback before the first voucher is signed, which can affect request timing and error handling if misused. Demo changes are low risk but exercise this new async path.

Overview
Session client enhancement: abstractSession now accepts an optional onChannelOpened(channelId) callback that runs after the on-chain open completes but before the opening voucher is signed; returning a Promise pauses voucher signing until it resolves.

Demo UX updates: The session demo is reworked into explicit phases so the first interaction becomes two steps ("Open Channel" then "Sign Voucher"), while later payments remain single-click; it also formats the displayed cumulative amount using formatUnits with USDC_DECIMALS and updates the session client wrapper to pass the new option.

Written by Cursor Bugbot for commit 2c0a0ba. This will update automatically on new commits. Configure here.

Add onChannelOpened callback to abstractSession client options to support deferring voucher signing.
@coffeexcoin coffeexcoin merged commit 4f4a2fd into main Mar 25, 2026
6 checks passed
@coffeexcoin coffeexcoin deleted the coffeexcoin/fix-session-ui-display branch March 25, 2026 23:21
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

)
fetchPromiseRef.current = null
})
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

UI freezes on retry after failed voucher signing

Medium Severity

handleOpenChannel assumes onChannelOpened will always fire, but the callback only runs for new channels (inside if (!entry) in session.ts). If the first request opens a channel on-chain and the user then rejects the voucher signature, the channel entry persists in the client's internal channels map while state.channelOpen stays false. On retry, handleOpenChannel fires mppx.fetch again, which takes the "voucher for existing channel" path — onChannelOpened is never called, so the phase never transitions from 'opening' to 'awaitingVoucher', and no handler ever processes the resolved response. The UI gets permanently stuck on the "Opening channel…" spinner.

Additional Locations (1)
Fix in Cursor Fix in Web

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.

1 participant