Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(wwjs): do not warn about a missing call hook on an unpatched tree

Yudhi Armyndharis4b9ceedbe2c5
diff --git a/dashboard/src/components/chats/ChatThread.tsx b/dashboard/src/components/chats/ChatThread.tsx
index 079e99fe0..7fae3f534 100644
--- a/dashboard/src/components/chats/ChatThread.tsx
+++ b/dashboard/src/components/chats/ChatThread.tsx
@@ -73,9 +73,14 @@ function ChatThread({
// overwrite the first, after which whichever settled first cleared the other's state — re-enabling
// a button whose fetch was still open, and landing a failure marker on the wrong bubble.
const [mediaFetch, setMediaFetch] = useState<Record<string, 'loading' | 'failed'>>({});
- // In-flight / completed taps on inbound prompt buttons. Keyed by waMessageId so a second click
- // on another choice of the same prompt is blocked while one request is open, and after success
- // the whole row stays disabled (WhatsApp treats a prompt as single-choice once answered).
+ // In-flight / completed taps on inbound prompt buttons. Keyed by waMessageId so a second click on
+ // another choice of the same prompt is blocked while one request is open, and after success the
+ // row reads as answered (WhatsApp treats a prompt as single-choice once answered).
+ //
+ // Client-side and per-visit only: this is reset when the active chat changes, and a reload starts
+ // it empty, so an answered prompt becomes clickable again. The engine is the real gate, and a
+ // second click is a second reply to the same prompt, which WhatsApp accepts; persisting the
+ // answered state belongs with the message rather than in this component.
const [buttonClick, setButtonClick] = useState<
Record<string, { loadingId?: string; done?: boolean; selectedId?: string }>
>({});
@@ -173,7 +178,9 @@ function ChatThread({
}, [messagesContainerRef]);
// Reset the jump button whenever the active chat changes: the new chat's content is restored by
- // useChatScrollPosition and our listener will resync on its first scroll tick.
+ // useChatScrollPosition and our listener will resync on its first scroll tick. The prompt-answer
+ // map goes with it: its ids belong to the chat being left, and holding them would disable a
+ // button in the chat being entered if the two ever shared a message id.
useEffect(() => {
setShowJumpToBottom(false);
setButtonClick({});
diff --git a/src/engine/adapters/wwebjs-lifecycle.ts b/src/engine/adapters/wwebjs-lifecycle.ts
index 9a2079af1..e6fd38548 100644
--- a/src/engine/adapters/wwebjs-lifecycle.ts
+++ b/src/engine/adapters/wwebjs-lifecycle.ts
@@ -795,11 +795,18 @@ export class WwebjsLifecycle {
// The session then looks healthy, keeps delivering messages, and reports no call at all. Warn
// once per ready rather than leaving that silent; nothing else changes, since only detection is
// lost. Fire-and-forget: a diagnostic must never delay or fail the promotion to READY.
- void reportMissingCallHook(
- (this.client as unknown as { pupPage?: { evaluate: <T>(fn: () => T) => Promise<T> } } | null)?.pupPage,
- this.host.logger,
- this.host.config.sessionId,
- );
+ //
+ // Skipped on a tree missing the ready-sync patch: without it the session can reach READY while
+ // that same evaluate is still running, so the probe would read a page whose hook simply has not
+ // been installed YET and warn about a problem that does not exist. An unpatched tree already
+ // reports itself at startup, which is the honest signal there.
+ if (!unappliedPatches('wwebjs').includes('patch-wwebjs-ready-sync')) {
+ void reportMissingCallHook(
+ (this.client as unknown as { pupPage?: { evaluate: <T>(fn: () => T) => Promise<T> } } | null)?.pupPage,
+ this.host.logger,
+ this.host.config.sessionId,
+ );
+ }
}
/** The single status-transition funnel: latches disconnectReported, fires the callback, re-emits