From f1a8fdb5c8c1eb6a6d41a825eabf92d080ef3562 Mon Sep 17 00:00:00 2001 From: jelveh Date: Thu, 12 Feb 2026 21:45:03 -0800 Subject: [PATCH] Trigger in-app upgrade flow for app env Handle upgrade flow when running in the app environment by calling await puter.ui.requestUpgrade() in driverCall_. Added app-specific branches in two places where usage/insufficient-funds were previously handled only for web (which showed a web dialog). This ensures the in-app UI is used for upgrade requests and awaits the result. --- src/puter-js/src/lib/utils.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/puter-js/src/lib/utils.js b/src/puter-js/src/lib/utils.js index c817c31ee..2f62b4cce 100644 --- a/src/puter-js/src/lib/utils.js +++ b/src/puter-js/src/lib/utils.js @@ -393,6 +393,8 @@ async function driverCall_ ( if ( lineObject?.error?.code === 'insufficient_funds' || lineObject?.metadata?.usage_limited === true ) { if ( puter.env === 'web' ) { showUsageLimitDialog('You have reached your usage limit for this account.
Please upgrade to continue.'); + } else if ( puter.env === 'app' ) { + await puter.ui.requestUpgrade(); } } // Check for email confirmation required (e.g. AI calls) @@ -484,6 +486,8 @@ async function driverCall_ ( if ( (isInsufficientFunds || isUsageLimited) && puter.env === 'web' ) { showUsageLimitDialog('Your account has not enough funding to complete this request.
Please upgrade to continue.'); + } else if ( (isInsufficientFunds || isUsageLimited) && puter.env === 'app' ) { + await puter.ui.requestUpgrade(); } // Check for email confirmation required (e.g. AI calls) - web only