Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

docs: record the onboarding-modal language dependency and the disconnected action gap

Yudhi Armyndharisa67d7a7705eb
diff --git a/dashboard/src/utils/sessionActions.ts b/dashboard/src/utils/sessionActions.ts
index 1e88bc474..8ea4ebcf9 100644
--- a/dashboard/src/utils/sessionActions.ts
+++ b/dashboard/src/utils/sessionActions.ts
@@ -5,13 +5,22 @@ import type { Session } from '../services/api.ts';
// Statuses in which the API has an engine loaded for the session. This is the single source of truth
// for the engine-backed actions — Stop, Unlink, and Force-Kill — because they share one precondition:
-// something live to act on. Keeping them on one set is what stops a card from offering an action the
-// API rejects, and, just as importantly, from offering Start to a session that is already started (the
-// API answers 400 and the page then opens a QR modal that can never resolve).
+// something live to act on. Keeping them on one set is what stops a card in one of these states from
+// offering an action the API rejects, and from offering Start to a session that is already started
+// (the API answers 400 and the page then opens a QR modal that can never resolve).
//
// `authenticating` and `action_required` belong here: both hold a live engine — the whatsapp-web.js
// adapter can sit in `authenticating` for 90 seconds, and `action_required` means the engine is
// running but something needs a human. Without them a card in either state offered only Start.
+//
+// KNOWN GAP (pre-existing, needs a server-side signal to close): `disconnected` is deliberately NOT
+// here even though it can hold a live engine. handleEngineDisconnected writes DISCONNECTED and
+// schedules a reconnect WITHOUT evicting the engine, so one stays registered for the whole backoff —
+// and start() rejects with 400 "already started" while it is. But a session stopped via stop() is
+// also `disconnected` and has no engine, and that one legitimately needs Start. The two are
+// indistinguishable from status alone, so listing it here would break the stop/start path to fix the
+// backoff path. Closing this properly needs the session payload to expose whether an engine is
+// loaded; until then Stop over the API is the escape hatch for a session wedged mid-backoff.
const STARTED_STATUSES = new Set([
'initializing',
'connecting',
diff --git a/docs/12-troubleshooting-faq.md b/docs/12-troubleshooting-faq.md
index eb3c944c8..817303a92 100644
--- a/docs/12-troubleshooting-faq.md
+++ b/docs/12-troubleshooting-faq.md
@@ -474,6 +474,21 @@ acknowledged before the companion device is allowed to stay linked. The adapter
and only gives up after five clicks that fail to land — at that point a human must click through it
once, so the session stops instead of being silently unlinked by WhatsApp about five minutes later.
+> **If the modal is not in English:** the detector matches the English button label (`Continue`) and
+> heading ("What's new"). The language WhatsApp Web renders in follows the browser locale, which OpenWA
+> does not set, so it is whatever the browser the container launches defaults to
+> (`PUPPETEER_EXECUTABLE_PATH` — Chrome for Testing on amd64, Debian's `chromium` on arm64). You can
+> pin it yourself by appending `--lang=en-US` to `PUPPETEER_ARGS` — that variable **replaces** the
+> default list rather than adding to it, so repeat the existing flags too (dropping `--no-sandbox` in
+> a container stops Chromium launching at all). If your deployment does get a
+> localised modal, it is **not** auto-dismissed and the session never reaches `action_required` —
+> instead it links normally, then drops to `disconnected` with reason `LOGOUT` a few minutes later and
+> the device disappears from the phone's Linked devices list. Because that path wipes the stored
+> credentials, the automatic reconnect comes back with a fresh QR on its own, so the session is
+> usually already sitting at `qr_ready` rather than needing a manual start. Acknowledge the modal once
+> in a browser signed in as that account, then scan the QR. It does not recur — the modal is shown
+> once per account.
+
**Fix:** acknowledge the modal once (open WhatsApp Web in the account holder's own browser and click
through the "What's new" screen), **then restart the session** (`POST /sessions/:id/stop` →
`POST /sessions/:id/start`). Acknowledging alone does not return the session to `ready` — the status
diff --git a/src/engine/adapters/whatsapp-web-js.adapter.ts b/src/engine/adapters/whatsapp-web-js.adapter.ts
index caaf61780..02eed4893 100644
--- a/src/engine/adapters/whatsapp-web-js.adapter.ts
+++ b/src/engine/adapters/whatsapp-web-js.adapter.ts
@@ -323,6 +323,18 @@ const ONBOARDING_MODAL_MAX_DISMISS_CLICKS = 5;
* "Continue", sitting within a few levels of an element that also carries the heading, is a shape the
* chat list does not produce. The ancestor walk is bounded for the same reason: matching against
* `<body>` would just be the loose text test again.
+ *
+ * ENGLISH-ONLY, by decision: both the button label and the heading are matched as English strings, so
+ * this only works while WhatsApp Web renders the modal in English. That language follows the browser
+ * locale — which nothing here sets (no `--lang` in the launch args, no `Accept-Language` override), so
+ * it is whatever the browser this deployment launches defaults to (`PUPPETEER_EXECUTABLE_PATH`, or
+ * Puppeteer's bundled Chromium when that is unset), NOT something derived from the linked account.
+ * Against a localised modal this returns `{modalPresent:false}` on every tick it runs: it is never
+ * dismissed and the watcher never escalates — it just ages out at the lifetime cap — so that
+ * deployment keeps the pre-#982 behaviour. Failing silent is
+ * deliberate — the alternative is carrying WhatsApp's translation table for two strings it controls,
+ * and a looser match (any visible button inside a dialog-ish container) would take healthy sessions
+ * out of READY, which is strictly worse than not fixing the modal. Limitation is in the CHANGELOG.
*/
export function probeOnboardingModal(): { modalPresent: boolean; dismissed: boolean } {
const isVisible = (el: Element): boolean => {