From 8be6c4d98b56f80a2a2a1d8aabe80fdcc264e2f3 Mon Sep 17 00:00:00 2001 From: ZDDC Date: Sun, 10 May 2026 19:30:36 -0500 Subject: [PATCH] feat(shared): route window.alert() to non-blocking toast MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are 76 alert() call sites across the eight tools — three different ad-hoc error-surfacing patterns (alert, console.error, classifier's own showToast). Touching every site is a sweep with no judgment payoff: every alert is "something went wrong, the user should know," which is exactly what toast at level='error' is for. Shim is one if-block at the bottom of shared/toast.js. It saves the native window.alert as window.alertNative (so any truly modal-blocking call site can opt back in by name), then replaces window.alert with a function that forwards through window.zddc.toast(msg, 'error'). Effect is global — every existing alert in every tool becomes a non-blocking, ARIA-announced (aria-live=assertive) toast that the user can click to dismiss. handler/tables.html refreshed by ./build as a side effect (it bakes the current tables/dist/ into the binary every build). Co-Authored-By: Claude Opus 4.7 (1M context) --- shared/toast.js | 13 +++++++++++++ zddc/internal/handler/tables.html | 15 ++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/shared/toast.js b/shared/toast.js index 6f2a7d6..6e32da1 100644 --- a/shared/toast.js +++ b/shared/toast.js @@ -60,4 +60,17 @@ } window.zddc.toast = toast; + + // Route window.alert() calls into the toast helper. Every tool has + // accumulated some `alert(...)` sites for error reporting; rather + // than touch each one, intercept globally so they're non-blocking + // and ARIA-announced consistently. Native alert is preserved on + // window.alertNative for the rare case where a truly modal block + // is needed (e.g. before navigating away with unsaved changes). + if (typeof window.alert === 'function' && !window.alertNative) { + window.alertNative = window.alert.bind(window); + window.alert = function (msg) { + toast(String(msg == null ? '' : msg), 'error'); + }; + } })(); diff --git a/zddc/internal/handler/tables.html b/zddc/internal/handler/tables.html index 802ece8..a0eebe5 100644 --- a/zddc/internal/handler/tables.html +++ b/zddc/internal/handler/tables.html @@ -1155,7 +1155,7 @@ body.help-open .app-header {
ZDDC Table - v0.0.17-beta · 2026-05-11 · crescent-coast-beam + v0.0.17-alpha · 2026-05-11 00:27:49 · f2af379-dirty
@@ -2232,6 +2232,19 @@ body.help-open .app-header { } window.zddc.toast = toast; + + // Route window.alert() calls into the toast helper. Every tool has + // accumulated some `alert(...)` sites for error reporting; rather + // than touch each one, intercept globally so they're non-blocking + // and ARIA-announced consistently. Native alert is preserved on + // window.alertNative for the rare case where a truly modal block + // is needed (e.g. before navigating away with unsaved changes). + if (typeof window.alert === 'function' && !window.alertNative) { + window.alertNative = window.alert.bind(window); + window.alert = function (msg) { + toast(String(msg == null ? '' : msg), 'error'); + }; + } })(); // shared/nav.js — lateral navigation strip across the four canonical