EdgeSpend: Phaze gift card improvements and error resilience#5937
EdgeSpend: Phaze gift card improvements and error resilience#5937
Conversation
Add a secondary "Show Identities" button that opens a text modal displaying all saved Phaze identities (current dataStore and legacy disklet formats) with a copy button for debugging.
Add asTolerantArray helper that skips malformed items instead of throwing on the entire array. Apply it to brand lists and voucher arrays so a single bad entry doesn't break the whole UI. Also add 'failed' to recognized order statuses and make deliveryAddress optional with an empty-string default.
Expose isError/error from useGiftCardProvider so scenes can detect provider initialization failures. On GiftCardListScene, stop clearing orders on API errors (keep last-known-good data visible), pause polling when offline and auto-resume on reconnect, and show an informational warning banner that auto-clears on success. On GiftCardMarketScene, gate the brand query on network connectivity so it auto-retries when online, and show a warning instead of an infinite loader when the initial fetch fails. On GiftCardPurchaseScene, guard against empty delivery addresses and show a warning when the provider fails to initialize.
Add isCreatingOrder to the early-return guard in handleNextPress so a second tap during the brief window before React disables the button cannot trigger duplicate order creation.
Distinguish between awaiting blockchain confirmations (txid exists but no voucher yet), pending voucher delivery, and failed/expired orders. Failed cards are dimmed like redeemed cards.
Display the Phaze quoteId at the top of the kebab menu modal for easier debugging and support reference.
baaedaa to
bc6baf7
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: baaedaa456
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Keep existing cached orders visible — don't clear state on error | ||
| setLoadError(true) |
There was a problem hiding this comment.
Clear displayed orders when account refresh fails
Keeping existing state on fetch failure can expose the previous account’s cards after an account switch. clearOrderCache() only resets module-level caches, but the activeOrders / redeemedOrders React state is not reset when account.id changes, and this catch block now only sets loadError. If the first refresh for the new account fails (for example, network/API failure), the scene can continue rendering stale orders from the prior user session.
Useful? React with 👍 / 👎.
| } | ||
|
|
||
| // Don't attempt API calls while offline | ||
| if (!isConnected) return |
There was a problem hiding this comment.
Exit initial loading state when offline on focus
This early return bypasses loadOrdersFromApi, so its finally (which clears isLoading) never runs. On first entry to the scene (or after cache reset, where loading starts true), visiting while offline leaves an indefinite spinner with no actionable state until connectivity changes, effectively blocking the gift card list offline.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| } | ||
|
|
||
| // Don't attempt API calls while offline | ||
| if (!isConnected) return |
There was a problem hiding this comment.
Infinite loader on first offline visit to list scene
Medium Severity
When the scene is opened for the first time while offline, the early return on !isConnected prevents loadOrdersFromApi from ever being called. Since isLoading is only set to false inside that function's finally block, it remains true and the UI shows FillLoader indefinitely with no offline indication. Before this change, the API call would be attempted, fail, and the finally block would clear isLoading, letting the scene fall through to the "No Gift Cards" or error state.
Additional Locations (2)
| (id, i) => `Identity ${i + 1}:\n${JSON.stringify(id, null, 2)}` | ||
| ) | ||
| .join('\n\n') | ||
| ) |
There was a problem hiding this comment.
Debug modal exposes userApiKey authentication credential in plain text
Low Severity
The handleShowIdentities function uses JSON.stringify on full identity objects (both current StoredIdentity and legacy PhazeUser), which include the userApiKey field — an authentication credential sent as the user-api-key header in Phaze API requests. Since this modal is designed for sharing with support, the credential could leak inadvertently. The userApiKey should be redacted or omitted before display.


CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
none
Description
Context
Asana: "EdgeSpend - Various Improvements/Fixes". Addresses several Phaze gift card UX and robustness issues: identity debugging, cleaner fault tolerance, error resilience across scenes, and card status refinements.
Changes
asTolerantArrayhelper so a single malformed brand or voucher entry doesn't break the entire list. MakesdeliveryAddressoptional and adds'failed'to recognized order statuses.isError/errorfromuseGiftCardProvider. OnGiftCardListScene, stops clearing orders on API errors (keeps last-known-good data), pauses polling when offline, and auto-resumes on reconnect with informational warning banners. OnGiftCardMarketScene, gates brand query on connectivity and shows a warning instead of an infinite loader. OnGiftCardPurchaseScene, guards against empty delivery addresses and shows a warning when the provider fails.isCreatingOrderguard inhandleNextPressto prevent duplicate order creation.Requirements
If you have made any visual changes to the GUI. Make sure you have:
Note
Medium Risk
Touches the gift card purchase and order-status UX flows and relaxes API parsing to tolerate malformed entries, which could affect how orders/brands render and how users proceed through checkout if edge cases are missed.
Overview
Improves EdgeSpend (Phaze) gift card UX and robustness by adding better order state handling, offline/error resilience, and support/debug affordances.
Gift card cards now distinguish
confirmingvspending, support a newfailedstate (including dimming/shimmer behavior), and the menu modal shows the orderquoteIdfor support reference. The list/market/purchase scenes now avoid clearing last-known-good data on refresh failures, pause/auto-resume network polling based on connectivity, surface warning banners on load/refresh errors, and prevent dead-ends in purchase by refetching token lists, blocking double-taps, and validating a non-empty payment address.Phaze API parsing is hardened with a tolerant array cleaner that skips malformed brand/voucher/status items, expands recognized order statuses to include
failed, and makesdeliveryAddressoptional (with explicit handling in the purchase flow).Written by Cursor Bugbot for commit bc6baf7. This will update automatically on new commits. Configure here.