Extension: surface a disconnected-tablet warning instead of silent success

A push can succeed server-side (session created) with nowhere to actually
deliver to — the backend's pushNavigate() already distinguishes this via a
delivered:false return (see device-stream.js), but nothing in the extension
read it: every surface just said "Sent" regardless. Confirmed live on the
dev stack 2026-10-01 — the registered dev tablet hadn't heartbeated in a
month, so a push looked successful but nothing happened. Now every send
path (injected buttons' fast path + manual picker, popup's fast path +
manual picker) shows an amber "tablet isn't connected right now" warning
when delivered is false.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-10-01 12:02:56 +00:00
parent db6ffb7aa4
commit 4aeca15281
3 changed files with 28 additions and 7 deletions

View file

@ -127,7 +127,11 @@ function renderBooking(el, bookingId, devices, defaultDeviceId, baseUrl, apiKey)
if (!msgEl) return; // "Send to a different tablet" was clicked before this resolved
if (result.ok) {
setMsg(msgEl, 'Sent — the tablet should navigate now.', 'ok');
if (result.delivered === false) {
setMsg(msgEl, 'Sent, but that tablet isn’t connected right now — it’ll pick this up if it reconnects.', 'warn');
} else {
setMsg(msgEl, 'Sent — the tablet should navigate now.', 'ok');
}
} else if (result.status === 409) {
// Default went busy in the moment between loading the popup and
// sending — fall back to the manual picker rather than leaving the
@ -172,7 +176,11 @@ function renderPicker(el, bookingId, devices, defaultDeviceId, baseUrl, apiKey,
setMsg(msgEl, 'Sending…', 'warn');
const result = await sendPush(bookingId, deviceSelect.value, baseUrl, apiKey);
if (result.ok) {
setMsg(msgEl, 'Sent — the tablet should navigate now.', 'ok');
if (result.delivered === false) {
setMsg(msgEl, 'Sent, but that tablet isn’t connected right now — it’ll pick this up if it reconnects.', 'warn');
} else {
setMsg(msgEl, 'Sent — the tablet should navigate now.', 'ok');
}
} else if (result.status === 409) {
setMsg(msgEl, result.error || 'That tablet is busy with another guest right now.', 'warn');
} else {
@ -191,7 +199,7 @@ async function sendPush(bookingId, deviceId, baseUrl, apiKey) {
});
const body = await res.json().catch(() => ({}));
if (!res.ok) return { ok: false, status: res.status, error: body.error || `HTTP ${res.status}` };
return { ok: true };
return { ok: true, delivered: body.delivered };
} catch (err) {
return { ok: false, status: 0, error: err.message };
}