Skip to content

Commit 2df159b

Browse files
robustness: sync badge and status on ready-event error paths in tradeEventCallback (#255)
Two error paths in the 'ready' switch case called showErrorInPanel but did not update the extension badge or popup status: 2. Parsed order array is empty after a 'ready' event Both paths now call setBadge('!', BADGE_COLOR_ERROR) and reportStatus(ERROR) after showErrorInPanel, making them consistent with all other error handling in handleTradeReady and showApiError where every error updates all three surfaces (panel, badge, popup status). Without this fix the badge stayed blank and the popup showed stale status (e.g. 'Active' from the last successful calculation) while the panel displayed an error, leaving the user with a misleading overall state. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 10c7811 commit 2df159b

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

content/main.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,11 @@
682682
// with stale results. Mirrors the same guard used in the 'incomplete' case.
683683
currentRequest++;
684684
showErrorInPanel('Could not detect account number — try refreshing the page.', false);
685+
// Sync badge and popup status so the user sees the error reflected everywhere,
686+
// not just in the injected panel. Mirrors the pattern used in handleTradeReady
687+
// and showApiError where every error path updates all three surfaces.
688+
setBadge('!', BADGE_COLOR_ERROR);
689+
reportStatus(FMC_CONSTANTS.STATUS_STATE.ERROR, { lastError: 'Could not detect account number' });
685690
break;
686691
}
687692
if (event.orders?.length > 0) {
@@ -710,6 +715,10 @@
710715
// Inject the panel and show a meaningful error so the user isn't left wondering.
711716
warn('ready event with empty orders — trade form may be incomplete or in an unexpected format');
712717
showErrorInPanel('Could not parse trade details — verify the form is filled in correctly.', false);
718+
// Sync badge and popup status so the error is visible in all three surfaces,
719+
// consistent with handleTradeReady and showApiError error handling.
720+
setBadge('!', BADGE_COLOR_ERROR);
721+
reportStatus(FMC_CONSTANTS.STATUS_STATE.ERROR, { lastError: 'Could not parse trade details' });
713722
}
714723
break;
715724

0 commit comments

Comments
 (0)