Skip to content

fix(whatsapp): stabilize auth state and reconcile local runtime after CLI login - #67815

Merged
mcaxtr merged 9 commits into
mainfrom
fix/whatsapp-auth-barriers
Apr 19, 2026
Merged

mcaxtr merged 9 commits into
mainfrom
fix/whatsapp-auth-barriers

Conversation

@mcaxtr

@mcaxtr mcaxtr commented Apr 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Describe the problem and fix in 2–5 bullets:

  • Problem: WhatsApp auth handling still mixed durability, backup recovery, and auth-derived decision reads across session.ts, auth-store.ts, and adjacent monitor/setup/status paths.
  • Problem: when a local gateway was already running, successful openclaw channels login flows could save auth on disk without restarting the live channel runtime owned by that gateway.
  • Why it matters: queued or interrupted creds.json saves could leave later reads and retries acting on unstable auth state, and local CLI login could appear successful while the running gateway channel stayed stopped.
  • What changed: this PR adds a dedicated WhatsApp creds persistence seam, makes ordinary auth reads non-destructive, threads an explicit linked / not-linked / unstable auth state through WhatsApp runtime/setup/status/health/login flows, and adds a generic channels.start gateway handoff so local CLI login can reconcile the running gateway runtime immediately.
  • What did NOT change (scope boundary): this does not replace Baileys useMultiFileAuthState or add an auth-dir watcher/reloader; it hardens the existing auth model and adds an explicit runtime-start handoff instead.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause (if applicable)

  • Root cause: WhatsApp auth persistence and auth-derived reads were split across multiple helpers without a single durability/barrier contract, so reads and retries could observe auth state while queued saves were still stabilizing.
  • Root cause: local CLI login was an auth-only flow in src/cli/channel-auth.ts, while the already-running gateway owned channel lifecycle, so successful local login did not automatically restart the runtime for channels that needed it.
  • Missing detection / guardrail: ordinary auth reads were allowed to be destructive, sensitive auth reads outside reconnect/bootstrap were not consistently behind the creds flush barrier, and there was no narrow gateway control-plane handoff for post-login runtime start.
  • Contributing context (if known): #63577 addressed the atomic write boundary, but the follow-up read-path and retry-path hardening was still missing; the running-gateway reconcile gap was separate and existed on the CLI login path.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file:
    • extensions/whatsapp/src/auth-store.test.ts
    • extensions/whatsapp/src/session.test.ts
    • extensions/whatsapp/src/channel.setup.test.ts
    • extensions/whatsapp/src/login-qr.test.ts
    • extensions/whatsapp/src/login.test.ts
    • extensions/whatsapp/src/connection-controller.test.ts
    • extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts
    • src/gateway/server-methods/channels.start.test.ts
    • src/gateway/server-methods/web.start.test.ts
    • src/gateway/server.auth.compat-baseline.test.ts
    • src/infra/channel-summary.test.ts
    • src/commands/health.test.ts
  • Scenario the test should lock in: ordinary reads do not restore from backup, sensitive auth reads wait on the queued-save barrier or surface explicit unstable state, WhatsApp login/retry/setup/status flows handle unstable auth consistently, and local CLI login can restart the running gateway runtime through the new handoff without regressing the direct-local backend auth path.
  • Why this is the smallest reliable guardrail: the regressions live at the WhatsApp auth seam, its immediate status/login consumers, and the gateway handoff seam, so focused plugin and gateway seam tests cover the behavior directly without a broader end-to-end harness.
  • Existing test that already covers this (if any): reconnect drain coverage existed in extensions/whatsapp/src/connection-controller.test.ts.
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

  • WhatsApp auth reads stop silently restoring from backup during normal operation.
  • Setup/login/monitor/status/health paths can now show auth stabilizing instead of disagreeing about linked vs not linked while queued creds saves are still settling.
  • Backup-backed login recovery no longer falls through to a fake QR timeout path.
  • On a running local gateway, successful local CLI login can now immediately restart the live channel runtime instead of requiring a separate restart path.
  • Explicit logout continues to clear requested auth state even when auth reads are unstable.

Diagram (if applicable)

Before:
[queued creds save] -> [ordinary read or retry path] -> [reads unstable state or mutates from backup]
[local CLI login] -> [auth saved on disk] -> [running gateway channel may remain stopped]

After:
[queued creds save] -> [barriered sensitive read or pure ordinary read] -> [stable decision or explicit unstable/retry path]
[local CLI login] -> [auth saved on disk] -> [channels.start handoff] -> [running gateway channel reconciled]

Security Impact (required)

  • New permissions/capabilities? (Yes)
  • Secrets/tokens handling changed? (Yes)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation:
    • This changes how WhatsApp auth artifacts are read and written on disk. Risk is limited to the existing WhatsApp auth directory; mitigation is tighter atomic write behavior, non-destructive ordinary reads, and focused regression coverage.
    • This also adds a new gateway runtime-start handoff path (channels.start) used by local CLI login. The branch keeps that path behind the existing local gateway auth model and includes compat/regression coverage for the direct-local backend handshake path.

Repro + Verification

Environment

  • OS: Linux
  • Runtime/container: Node 22 / pnpm workspace
  • Model/provider: N/A
  • Integration/channel (if any): WhatsApp plus gateway local mode
  • Relevant config (redacted): default WhatsApp auth dir and local gateway config

Steps

  1. Trigger a WhatsApp auth read or retry path while a queued creds save is still stabilizing.
  2. Exercise ordinary auth reads, setup/status reads, and inbox attach/retry/login paths.
  3. Start a local gateway, then run local CLI channel login against a stopped channel runtime.
  4. Verify no backup restore occurs on ordinary reads, unstable auth yields retry-safe behavior instead of destructive conclusions, and the running gateway runtime is reconciled after successful local login.

Expected

  • Ordinary reads stay non-destructive.
  • Sensitive reads wait for the queue or surface an explicit unstable path.
  • Retry/login/setup/status flows do not mis-handle unstable auth state.
  • Local CLI login can restart the already-running local gateway runtime for the logged-in channel.

Actual

  • Verified with focused WhatsApp auth/session/setup/login/monitor coverage and focused gateway handoff coverage after the change.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios:
    • pnpm test extensions/whatsapp/src/auth-store.test.ts extensions/whatsapp/src/channel.setup.test.ts extensions/whatsapp/src/session.test.ts extensions/whatsapp/src/login-qr.test.ts extensions/whatsapp/src/login.test.ts extensions/whatsapp/src/connection-controller.test.ts extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts
    • pnpm test src/gateway/server-methods/channels.start.test.ts src/gateway/server-methods/web.start.test.ts src/gateway/server.auth.compat-baseline.test.ts src/infra/channel-summary.test.ts src/commands/health.test.ts
    • pnpm tsgo
  • Edge cases checked:
    • timeout-backed logout cleanup
    • barriered sensitive reads
    • non-destructive ordinary reads
    • recovered login without QR timeout
    • local gateway runtime reconcile after CLI login
  • What you did not verify:
    • full live WhatsApp linking against a real device with the new handoff path end-to-end

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps:

Risks and Mitigations

  • Risk: barriered auth reads could delay some retry/setup/login paths while queued saves drain.
    • Mitigation: timeout-backed waits, explicit unstable-auth handling, and focused retry/login/setup coverage.
  • Risk: auth-store cleanup behavior changes could remove stale WhatsApp auth state more aggressively.
    • Mitigation: cleanup stays scoped to WhatsApp auth artifacts and is covered by auth-store tests.
  • Risk: the new local CLI-login reconcile path broadens gateway control-plane behavior.
    • Mitigation: the runtime-start surface is explicit, tested, and limited to the existing local gateway auth model used for backend handoff.

@aisle-research-bot

aisle-research-bot Bot commented Apr 16, 2026 •

Copy link
Copy Markdown

🔒 Aisle Security Analysis

We found 2 potential security issue(s) in this PR:

# Severity Title
1 🟠 High Insecure temporary file creation in WhatsApp creds persistence allows symlink clobbering
2 🟠 High Local privilege escalation: backend client can preserve self-declared operator scopes without device identity
1. 🟠 Insecure temporary file creation in WhatsApp creds persistence allows symlink clobbering
Property Value
Severity High
CWE CWE-59
Location extensions/whatsapp/src/creds-persistence.ts:28-33

Description

writeCredsJsonAtomically() creates a predictable temp file path inside authDir and opens it with non-exclusive write flags.

  • The temp file is opened with fs.open(tempPath, "w", 0o600), which follows symlinks and truncates existing files.
  • If an attacker can create/replace tempPath inside authDir (e.g., if authDir is configured to a shared/writable directory, or permissions are weakened), they can point it at an arbitrary target via symlink and cause the process to overwrite/truncate that target when saving creds.
  • randomUUID() reduces guessability but does not eliminate TOCTOU/symlink attacks when the directory is attacker-writable.

Vulnerable code:

const tempPath = path.join(authDir, `.creds.${process.pid}.${randomUUID()}.tmp`);
handle = await fs.open(tempPath, "w", CREDS_FILE_MODE);

Recommendation

Create the temp file with exclusive flags and (where supported) no-follow semantics, and ensure authDir has safe ownership/permissions.

Use O_EXCL / 'wx' at minimum:

import fs from "node:fs/promises";
import { constants as FS } from "node:fs";

const fd = await fs.open(tempPath, FS.O_WRONLY | FS.O_CREAT | FS.O_EXCL | (FS.O_NOFOLLOW ?? 0), CREDS_FILE_MODE);
​// or: await fs.open(tempPath, "wx", CREDS_FILE_MODE)  // (no O_NOFOLLOW)

Additionally:

  • Verify authDir is not world-writable and is owned by the current user (e.g., stat checks) before writing.
  • Consider writing to a securely-created temp directory (e.g., fs.mkdtemp() under a trusted base dir) and then renaming into place.
2. 🟠 Local privilege escalation: backend client can preserve self-declared operator scopes without device identity
Property Value
Severity High
CWE CWE-269
Location src/gateway/server/ws-connection/message-handler.ts:620-636

Description

The WebSocket handshake now includes an exception that prevents clearing self-declared scopes when the client is identified as the backend gateway-client in BACKEND mode and considered direct_local.

This creates an authorization/pairing bypass:

  • Input: A connecting client controls connectParams.client.id, connectParams.client.mode, requested scopes, and can omit device.
  • Gate: If the TCP peer is loopback and no proxy headers are present, isLocalClient becomes true (direct_local).
  • Bypass: When shouldSkipLocalBackendSelfPairing() returns true, handleMissingDeviceIdentity() will not clear unbound/self-declared scopes even though no device identity is present.
  • Impact: Any local process that has the shared token/password (or device-token) can spoof client.id=GATEWAY_CLIENT + mode=BACKEND and retain elevated scopes like operator.admin without pairing/device binding, enabling privileged RPC methods.

Vulnerable logic:

if (
  !device &&
  !skipLocalBackendSelfPairing &&
  shouldClearUnboundScopesForMissingDeviceIdentity(...)
) {
  clearUnboundScopes();
}

Combined with:

return (
  params.locality === "direct_local" &&
  !params.hasBrowserOriginHeader &&
  ((params.sharedAuthOk && usesSharedSecretAuth) || usesDeviceTokenAuth)
);

This exception relies on self-declared client identity (connectParams.client.*) rather than a cryptographically bound identity, so it can be spoofed by any loopback client.

Recommendation

Remove or harden the exception so unbound scopes cannot be preserved based on user-declared client metadata.

Options (prefer 1):

  1. Always clear self-declared scopes when device is missing, regardless of client id/mode:
if (!device && shouldClearUnboundScopesForMissingDeviceIdentity(...)) {
  clearUnboundScopes();
}
  1. If an exception is required for in-process coordination, gate it on a non-spoofable signal, e.g.:
  • a separate dedicated auth credential distinct from operator shared secret,
  • a mutually-authenticated local IPC channel instead of WebSocket,
  • or a server-side allowlist tied to a pinned client certificate / unix-domain socket.
  1. At minimum, require both:
  • an authenticated device identity or a dedicated backend-only credential, and
  • server-side enforcement that the connection originates from a protected context (e.g., a Unix socket) rather than simply loopback.

Also consider logging/auditing when a client requests privileged scopes without device identity.


Analyzed PR: #67815 at commit ed8c3a6

Last updated on: 2026-04-19T14:37:21Z

@openclaw-barnacle openclaw-barnacle Bot added channel: whatsapp-web Channel integration: whatsapp-web size: XL maintainer Maintainer-authored PR labels Apr 16, 2026
@greptile-apps

greptile-apps Bot commented Apr 16, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR hardens WhatsApp auth persistence by introducing a dedicated creds-persistence.ts module with fsync-backed atomic writes, making ordinary auth reads non-destructive (backup restore only happens after the save queue drains in createWaSocket), and adding queue-aware barriers to decision-critical auth reads (readWebSelfIdentityForDecision, readWebAuthExistsForDecision). The new WhatsAppWebAuthState union surfaces the "unstable" case explicitly so callers can handle it safely rather than silently observing racy state.

Confidence Score: 5/5

Safe to merge — previous reviewer concerns are resolved and the two remaining findings are both P2 style suggestions.

All findings are P2 or lower: a fragile string-vs-rawState color check in channel-summary.ts and a no-op intermediate variable in channel.ts. Neither affects correctness or user-visible behavior today. The core auth-barrier and atomic-write hardening is sound, test coverage is explicitly listed, and the single-barrier contract in createWaSocket is clean.

src/infra/channel-summary.ts (color mapping uses formatted string; should check raw statusState), extensions/whatsapp/src/channel.ts (redundant statusState variable)

Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/infra/channel-summary.ts
Line: 229-230

Comment:
**Color mapping is coupled to the formatted string**

The check `status === "auth stabilizing"` compares the already-formatted display string returned by `formatChannelStatusState("unstable")`. If that function's output is ever adjusted, the error-color mapping silently falls through to `theme.muted` with no compile-time or test-time warning.

The raw `statusState` variable is already in scope at this point and is the safer thing to check:

```suggestion
        : (statusState === "unstable" || status === "not linked")
          ? theme.error
          : theme.muted;
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: extensions/whatsapp/src/channel.ts
Line: 210

Comment:
**Redundant intermediate variable**

`summaryAuthState === undefined ? undefined : summaryAuthState` is always equal to `summaryAuthState` itself, so this line adds noise without changing behavior. You can drop it and use `summaryAuthState` directly wherever `statusState` appears below (or keep the name and simplify the assignment).

```suggestion
          const statusState = summaryAuthState;
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (2): Last reviewed commit: "WhatsApp: cap unstable auth retries" | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8eccc9418b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread extensions/whatsapp/src/channel.ts Resolved
@mcaxtr
mcaxtr force-pushed the fix/whatsapp-auth-barriers branch from 8eccc94 to 5a9ab7d Compare April 18, 2026 05:28
@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Apr 18, 2026
@mcaxtr

mcaxtr commented Apr 18, 2026

Copy link
Copy Markdown
Member Author

Rebased this branch onto current main, resolved the rebase conflicts, pushed the rebased branch, and addressed the review-driven regressions in follow-up commits.

What was fixed:

  • Removed the duplicated creds barrier wait before reconnect and login restart so createWaSocket() is the single barrier owner. That avoids compounding the timeout on degraded reconnect paths.
  • Centralized WhatsApp auth state into a shared enum-style read in auth-store.ts and propagated that through runtime status, setup status, and generic renderers. The branch now carries semantic statusState instead of relying on ad hoc linked inference, so timeout reads render consistently as auth stabilizing instead of drifting between linked, not linked, and unstable.
  • Fixed the remaining real reconnect regression in auto-reply/monitor.ts: retryable auth-unstable inbox-attach failures now consume reconnect attempts through the controller and stop cleanly at the configured max instead of retrying forever.

What was not fixed:

  • The Aisle symlink and TOCTOU notes around creds restore and atomic writes were not addressed in this PR. Those are local-filesystem hardening concerns that assume an attacker can already manipulate authDir contents or point config at insecure paths. They are worth considering separately, but they are not the concrete regressions this PR introduced.
  • The Aisle recursive-delete note on logoutWeb() was also not addressed here. That path-trust concern predates this PR: origin/main already allowed deleting the configured auth directory. It should be handled, if desired, as a separate hardening change around constraining allowed auth-dir roots rather than mixed into this auth-persistence regression fix PR.

Verification run locally after the fixes:

  • pnpm test extensions/whatsapp/src/auth-store.test.ts extensions/whatsapp/src/session.test.ts extensions/whatsapp/src/connection-controller.test.ts extensions/whatsapp/src/login-qr.test.ts extensions/whatsapp/src/channel.setup.test.ts extensions/whatsapp/src/setup-surface.test.ts extensions/whatsapp/src/status-issues.test.ts extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts extensions/whatsapp/src/login.coverage.test.ts
  • pnpm test src/infra/channel-summary.test.ts src/commands/health.test.ts
  • Normal pre-commit hook on the last commits also passed, including pnpm tsgo, lint, and both import-cycle checks.

@codex review
@greptile review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5a9ab7d64e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread extensions/whatsapp/src/auth-store.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 189ec86935

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread extensions/whatsapp/src/login-qr.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 177c8069f1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread extensions/whatsapp/src/login-qr.ts Resolved
@openclaw-barnacle openclaw-barnacle Bot added app: macos App: macos app: web-ui App: web-ui gateway Gateway runtime labels Apr 18, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0089558d91

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread extensions/whatsapp/src/auth-store.ts Resolved
@mcaxtr
mcaxtr force-pushed the fix/whatsapp-auth-barriers branch from 0089558 to 6a81a5f Compare April 18, 2026 15:02

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6a81a5fa62

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread extensions/whatsapp/src/channel.ts Resolved
@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label Apr 18, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8d8487bff3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/gateway/server-methods/channels.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fb1fcd0375

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread extensions/whatsapp/src/auth-store.ts Resolved
Comment thread extensions/whatsapp/src/login-qr.ts Resolved
@mcaxtr
mcaxtr requested a review from a team as a code owner April 18, 2026 19:53

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e6c740c186

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
… CLI login (openclaw#67815)

* WhatsApp: harden auth persistence and backup recovery

* WhatsApp: model unstable auth state across runtime and setup

* WhatsApp: recover login and monitor startup from unstable auth

* Channels: surface auth stabilizing in status and health

* Gateway protocol: add channels.start surface

* Gateway: reconcile local channel runtime after CLI login

* Channels UI: reflect recovered login start state

* Changelog: note WhatsApp auth stabilization

* Gateway: fix lint in call test
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
… CLI login (openclaw#67815)

* WhatsApp: harden auth persistence and backup recovery

* WhatsApp: model unstable auth state across runtime and setup

* WhatsApp: recover login and monitor startup from unstable auth

* Channels: surface auth stabilizing in status and health

* Gateway protocol: add channels.start surface

* Gateway: reconcile local channel runtime after CLI login

* Channels UI: reflect recovered login start state

* Changelog: note WhatsApp auth stabilization

* Gateway: fix lint in call test
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request May 13, 2026
… CLI login (openclaw#67815)

* WhatsApp: harden auth persistence and backup recovery

* WhatsApp: model unstable auth state across runtime and setup

* WhatsApp: recover login and monitor startup from unstable auth

* Channels: surface auth stabilizing in status and health

* Gateway protocol: add channels.start surface

* Gateway: reconcile local channel runtime after CLI login

* Channels UI: reflect recovered login start state

* Changelog: note WhatsApp auth stabilization

* Gateway: fix lint in call test
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
… CLI login (openclaw#67815)

* WhatsApp: harden auth persistence and backup recovery

* WhatsApp: model unstable auth state across runtime and setup

* WhatsApp: recover login and monitor startup from unstable auth

* Channels: surface auth stabilizing in status and health

* Gateway protocol: add channels.start surface

* Gateway: reconcile local channel runtime after CLI login

* Channels UI: reflect recovered login start state

* Changelog: note WhatsApp auth stabilization

* Gateway: fix lint in call test
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
… CLI login (openclaw#67815)

* WhatsApp: harden auth persistence and backup recovery

* WhatsApp: model unstable auth state across runtime and setup

* WhatsApp: recover login and monitor startup from unstable auth

* Channels: surface auth stabilizing in status and health

* Gateway protocol: add channels.start surface

* Gateway: reconcile local channel runtime after CLI login

* Channels UI: reflect recovered login start state

* Changelog: note WhatsApp auth stabilization

* Gateway: fix lint in call test
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
… CLI login (openclaw#67815)

* WhatsApp: harden auth persistence and backup recovery

* WhatsApp: model unstable auth state across runtime and setup

* WhatsApp: recover login and monitor startup from unstable auth

* Channels: surface auth stabilizing in status and health

* Gateway protocol: add channels.start surface

* Gateway: reconcile local channel runtime after CLI login

* Channels UI: reflect recovered login start state

* Changelog: note WhatsApp auth stabilization

* Gateway: fix lint in call test
Heetisk pushed a commit to Heetisk/openclaw that referenced this pull request Sep 28, 2026
… CLI login (openclaw#67815)

* WhatsApp: harden auth persistence and backup recovery

* WhatsApp: model unstable auth state across runtime and setup

* WhatsApp: recover login and monitor startup from unstable auth

* Channels: surface auth stabilizing in status and health

* Gateway protocol: add channels.start surface

* Gateway: reconcile local channel runtime after CLI login

* Channels UI: reflect recovered login start state

* Changelog: note WhatsApp auth stabilization

* Gateway: fix lint in call test
steipete added a commit that referenced this pull request Oct 15, 2026
Remove a test-only config cache-reset wrapper, duplicate internal selection
and channel-support checks, an unused session-file metadata fallback, and
duplicate usage target shapes. Carry transcript delivery facts from their
first parsing pass. Keep all network validation, effect authority, transcript
durability, current update policy and standalone session memory machinery.

Best-effort tradeoffs accepted:
- Internal agent updates trust the selection-shape check at their sole
  production caller, agents.update. The duplicate originated in the Models
  agent-selection feature #150224; the same boundary check still rejects
  invalid user input. Live runtime choice validation stays at the effect.
- Channel start support is checked once at the synchronous request boundary.
  The inner check from #67815 / #167159 cannot observe a different plugin
  without unsupported synchronous mutation; the boundary guard remains.
- Workspace-root readers require caller-prepared metadata: both production
  consumers already provide it. The unused fallback from #161747 is deleted,
  not the Phase E backend or any factory. A future invalid internal caller
  gets a clear error instead of starting another metadata read.
- Update handlers trust the required getRuntimeConfig contract instead of
  falling back to a global schedule for an invalid context. Keep #158301's
  real scheduler-policy incident fix and its post-await current-config read.
- Usage summaries trust the canonical required target identity from #169660;
  the first-instance fallback served no production caller. The integration
  fixture now supplies that identity with all original assertions retained.

No public schema/config/SDK/protocol or persisted shape changes. The config
tests call the same canonical invalidators directly; no coverage is removed.

Follow-up removes 54 net production lines; branch total removes 154. Targeted
types (including MCP consumers), retained-file type-aware lint, formatting,
zero runtime import cycles, suppression audit and independent P2 review pass.
Gateway behavioral suites remain incomplete after a loaded-host startup run
was stopped at about ten minutes (exit 143). The prior full static-graph gap
remains pending for the coordinator bundle; no new production edge is added.
steipete added a commit that referenced this pull request Oct 15, 2026
…-5 bundle A) (#172989)

* refactor(ui): remove unused page plumbing and duplicate presentation work

Fold sole-caller Config and Cron adapters into their existing owners, reuse
canonical controller types, and remove unused request arguments and login
selection options. Adopt the complete background mutation receipt instead of
rereading the write; keep authoritative preflight and live ownership checks.

Best-effort tradeoffs accepted: a later background edit in another browser is
reflected by normal preference events or refresh, not an unconditional read of
our own successful write. The introducing feature PR #168301 does not identify
a human incident requiring that reread. Settled rendering and public contracts
are unchanged; both shipping renderer paths remain intact.

* refactor(ui): consolidate presentation helpers and cached preview inputs

Share point-menu trigger attributes and deletion-first LCS traversal. Remove
an obsolete empty-badge predicate, a one-caller loading facade, and redundant
whole-map translation fallback. Preserve both active Lit and Solid paths,
positioning formulas, diff work budgets, visible text, and rendering.

Best-effort tradeoffs accepted:
- Trust successful synchronous Web Storage writes instead of reading them back.
  Introducing PR #162428 supplied synthetic storage failures, not a human
  incident where successful setItem silently failed. Nonconforming Storage
  replacements may miss a cache publication until the next refresh.
- Trust immutable message/tool-card identities for cached source previews.
  PR #148431's in-place mutation assertions were synthetic; production owners
  publish replacement snapshots. Unsupported in-place mutation may leave a
  decoration stale until replacement. Run/frame/origin and external source
  validation remain unchanged.

Net production reduction: 76 lines; tests: 20 lines removed, only synthetic
same-object mutation assertions. Kept config coercion tied to human Safari
report #13348, along with security, durability, ordinary navigation ownership,
and all active migration paths.

Focused proof: 73 boot/cache/diff tests, 82 menu tests, 46 badge/assistant tests,
20 i18n tests, 8 browser details tests, 3 lint-suppression tests; UI typecheck,
formatting, stylesheet lint and CSS declaration parity passed.

Known inherited local check failure: environment-variable count is 455 against
budget 454, independently reproduced against clean HEAD/index. Its counted
source roots exclude UI. No budget or unrelated source changes made.

* refactor(ui): remove obsolete presentation compatibility and styling

Use the native Popover capability required by the Control UI bootstrap
instead of retaining old-engine in-flow fallbacks. Keep native overlay
occlusion and all real connection/navigation ownership.

Remove retired sidebar style hooks and share identical question-panel
declarations. Supported browsers render identically; no user-visible
copy, feature, renderer selection, config, protocol, or storage change.

Best-effort tradeoffs accepted

- Old engines without Popover support, or invalid direct popover mounts,
  no longer receive an in-flow menu fallback. The fallback came from
  #105598 as generic compatibility, not a human incident; #168595 made
  native Popover support a required bootstrap capability. Invalid direct
  mounts now fail clearly rather than silently changing layering.

Deeper coverage and retained candidates are recorded in the requested
task-local y03 ledger for coordinator bundling.

Branch total: 123 net production LOC removed (+114/-237), excluding tests,
fixtures, generated files and declarations. Below the 500-line campaign
floor after the deeper components/app/lib/styles and lead-owned owner pass;
push branch-only for bundling.

* refactor(gateway): reuse server method owners

Consolidate duplicate catalog response handling,
optional catalog reads, pairing resolution, requester assertions and system
agent transcript persistence. Carry prepared pairing and actor facts instead
of probing or re-reading them. Remove redundant cache-generation and internal
receipt checks; retain security, durability, pagination and resource bounds.

Best-effort tradeoffs accepted:
- Pairing captures its selected adapter once. Repeated internal checks added
  by #112401 guarded hypothetical in-place plugin mutation, not a reported
  incident. Such a mutation now leaves this request on its selected adapter;
  later requests discover the current registration.
- Channel identity RPCs trust the canonical mutation result instead of
  repeating the action/kind assertion introduced in #161284. No human incident
  justified the redundant adapter assertion; live mutation authority remains
  with the state owner.

No user-facing feature, protocol/config/persistence shape, schema, dependency,
test coverage or standalone session memory backend changes.

Net production reduction: 100 lines (179 added / 279 deleted).
Type-aware lint, targeted production types, formatting, runtime cycles (zero),
SDK surface, suppression audit and independent P2 review pass. Gateway focused
suites and the full static import graph remain incomplete on the loaded host;
retain these proof gaps for the coordinator bundle rather than claiming green.

* refactor(gateway): trust prepared server method inputs

Remove a test-only config cache-reset wrapper, duplicate internal selection
and channel-support checks, an unused session-file metadata fallback, and
duplicate usage target shapes. Carry transcript delivery facts from their
first parsing pass. Keep all network validation, effect authority, transcript
durability, current update policy and standalone session memory machinery.

Best-effort tradeoffs accepted:
- Internal agent updates trust the selection-shape check at their sole
  production caller, agents.update. The duplicate originated in the Models
  agent-selection feature #150224; the same boundary check still rejects
  invalid user input. Live runtime choice validation stays at the effect.
- Channel start support is checked once at the synchronous request boundary.
  The inner check from #67815 / #167159 cannot observe a different plugin
  without unsupported synchronous mutation; the boundary guard remains.
- Workspace-root readers require caller-prepared metadata: both production
  consumers already provide it. The unused fallback from #161747 is deleted,
  not the Phase E backend or any factory. A future invalid internal caller
  gets a clear error instead of starting another metadata read.
- Update handlers trust the required getRuntimeConfig contract instead of
  falling back to a global schedule for an invalid context. Keep #158301's
  real scheduler-policy incident fix and its post-await current-config read.
- Usage summaries trust the canonical required target identity from #169660;
  the first-instance fallback served no production caller. The integration
  fixture now supplies that identity with all original assertions retained.

No public schema/config/SDK/protocol or persisted shape changes. The config
tests call the same canonical invalidators directly; no coverage is removed.

Follow-up removes 54 net production lines; branch total removes 154. Targeted
types (including MCP consumers), retained-file type-aware lint, formatting,
zero runtime import cycles, suppression audit and independent P2 review pass.
Gateway behavioral suites remain incomplete after a loaded-host startup run
was stopped at about ten minutes (exit 143). The prior full static-graph gap
remains pending for the coordinator bundle; no new production edge is added.

* refactor(ui): consolidate page lifecycle and config plumbing

Reuse the existing controller host, subscription and plugin-icon owners;
share cloud-worker config edit wiring and Usage query comparisons. Remove
the unused Usage detail predicate and duplicate model loading flag.

Retire the Web Awesome-era picker hiding fence now that native Popover
owns generation-bound close completion. Keep both rendering paths,
draft recovery, user-intent checks and dispatch-time write authority.
Settled rendering is unchanged. Net production reduction: 210 lines.

Best-effort tradeoffs accepted:
- Failed channel artwork retries on the next channel refresh rather than
  a queued trailing ensure. #131511 was a synthetic ordering regression;
  the human-reported owning-plugin bug #144152 remains covered.
- Picker triggers may reopen during closing. #126032's fence came from
  CI/synthetic overlap, not a human incident; #171441 transferred lifecycle
  ownership to native Popover, which ignores superseded completions.

Focused proof: 281 tests passed, including Chromium/WebKit overlay lifecycle
and responsive placement controls. Independent P0-P2 review: scoped-clean.
Final UI production and UI-pages test typechecks passed; suppression tests 3/3.
Scoped lint passed after a mechanical no-lonely-if fix.
Runtime and static import cycles: zero. No visual or locale changes.
The global environment-name budget is inherited at 455/454 on both the
untouched base and origin/main; none of its counted source roots changed.

* refactor(ui): remove unused new-session hiding selector

* refactor(gateway): retain legacy catalog and update handler contracts

Withdraw two wave-5 cleanups after focused CI failures and bounded isolated replay. Preserve the existing scalar-read concurrency and update-status handler contract. Tighten task-suggestions assertion allowance to match the cleaned source.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…-5 bundle A) (openclaw#172989)

* refactor(ui): remove unused page plumbing and duplicate presentation work

Fold sole-caller Config and Cron adapters into their existing owners, reuse
canonical controller types, and remove unused request arguments and login
selection options. Adopt the complete background mutation receipt instead of
rereading the write; keep authoritative preflight and live ownership checks.

Best-effort tradeoffs accepted: a later background edit in another browser is
reflected by normal preference events or refresh, not an unconditional read of
our own successful write. The introducing feature PR openclaw#168301 does not identify
a human incident requiring that reread. Settled rendering and public contracts
are unchanged; both shipping renderer paths remain intact.

* refactor(ui): consolidate presentation helpers and cached preview inputs

Share point-menu trigger attributes and deletion-first LCS traversal. Remove
an obsolete empty-badge predicate, a one-caller loading facade, and redundant
whole-map translation fallback. Preserve both active Lit and Solid paths,
positioning formulas, diff work budgets, visible text, and rendering.

Best-effort tradeoffs accepted:
- Trust successful synchronous Web Storage writes instead of reading them back.
  Introducing PR openclaw#162428 supplied synthetic storage failures, not a human
  incident where successful setItem silently failed. Nonconforming Storage
  replacements may miss a cache publication until the next refresh.
- Trust immutable message/tool-card identities for cached source previews.
  PR openclaw#148431's in-place mutation assertions were synthetic; production owners
  publish replacement snapshots. Unsupported in-place mutation may leave a
  decoration stale until replacement. Run/frame/origin and external source
  validation remain unchanged.

Net production reduction: 76 lines; tests: 20 lines removed, only synthetic
same-object mutation assertions. Kept config coercion tied to human Safari
report openclaw#13348, along with security, durability, ordinary navigation ownership,
and all active migration paths.

Focused proof: 73 boot/cache/diff tests, 82 menu tests, 46 badge/assistant tests,
20 i18n tests, 8 browser details tests, 3 lint-suppression tests; UI typecheck,
formatting, stylesheet lint and CSS declaration parity passed.

Known inherited local check failure: environment-variable count is 455 against
budget 454, independently reproduced against clean HEAD/index. Its counted
source roots exclude UI. No budget or unrelated source changes made.

* refactor(ui): remove obsolete presentation compatibility and styling

Use the native Popover capability required by the Control UI bootstrap
instead of retaining old-engine in-flow fallbacks. Keep native overlay
occlusion and all real connection/navigation ownership.

Remove retired sidebar style hooks and share identical question-panel
declarations. Supported browsers render identically; no user-visible
copy, feature, renderer selection, config, protocol, or storage change.

Best-effort tradeoffs accepted

- Old engines without Popover support, or invalid direct popover mounts,
  no longer receive an in-flow menu fallback. The fallback came from
  openclaw#105598 as generic compatibility, not a human incident; openclaw#168595 made
  native Popover support a required bootstrap capability. Invalid direct
  mounts now fail clearly rather than silently changing layering.

Deeper coverage and retained candidates are recorded in the requested
task-local y03 ledger for coordinator bundling.

Branch total: 123 net production LOC removed (+114/-237), excluding tests,
fixtures, generated files and declarations. Below the 500-line campaign
floor after the deeper components/app/lib/styles and lead-owned owner pass;
push branch-only for bundling.

* refactor(gateway): reuse server method owners

Consolidate duplicate catalog response handling,
optional catalog reads, pairing resolution, requester assertions and system
agent transcript persistence. Carry prepared pairing and actor facts instead
of probing or re-reading them. Remove redundant cache-generation and internal
receipt checks; retain security, durability, pagination and resource bounds.

Best-effort tradeoffs accepted:
- Pairing captures its selected adapter once. Repeated internal checks added
  by openclaw#112401 guarded hypothetical in-place plugin mutation, not a reported
  incident. Such a mutation now leaves this request on its selected adapter;
  later requests discover the current registration.
- Channel identity RPCs trust the canonical mutation result instead of
  repeating the action/kind assertion introduced in openclaw#161284. No human incident
  justified the redundant adapter assertion; live mutation authority remains
  with the state owner.

No user-facing feature, protocol/config/persistence shape, schema, dependency,
test coverage or standalone session memory backend changes.

Net production reduction: 100 lines (179 added / 279 deleted).
Type-aware lint, targeted production types, formatting, runtime cycles (zero),
SDK surface, suppression audit and independent P2 review pass. Gateway focused
suites and the full static import graph remain incomplete on the loaded host;
retain these proof gaps for the coordinator bundle rather than claiming green.

* refactor(gateway): trust prepared server method inputs

Remove a test-only config cache-reset wrapper, duplicate internal selection
and channel-support checks, an unused session-file metadata fallback, and
duplicate usage target shapes. Carry transcript delivery facts from their
first parsing pass. Keep all network validation, effect authority, transcript
durability, current update policy and standalone session memory machinery.

Best-effort tradeoffs accepted:
- Internal agent updates trust the selection-shape check at their sole
  production caller, agents.update. The duplicate originated in the Models
  agent-selection feature openclaw#150224; the same boundary check still rejects
  invalid user input. Live runtime choice validation stays at the effect.
- Channel start support is checked once at the synchronous request boundary.
  The inner check from openclaw#67815 / openclaw#167159 cannot observe a different plugin
  without unsupported synchronous mutation; the boundary guard remains.
- Workspace-root readers require caller-prepared metadata: both production
  consumers already provide it. The unused fallback from openclaw#161747 is deleted,
  not the Phase E backend or any factory. A future invalid internal caller
  gets a clear error instead of starting another metadata read.
- Update handlers trust the required getRuntimeConfig contract instead of
  falling back to a global schedule for an invalid context. Keep openclaw#158301's
  real scheduler-policy incident fix and its post-await current-config read.
- Usage summaries trust the canonical required target identity from openclaw#169660;
  the first-instance fallback served no production caller. The integration
  fixture now supplies that identity with all original assertions retained.

No public schema/config/SDK/protocol or persisted shape changes. The config
tests call the same canonical invalidators directly; no coverage is removed.

Follow-up removes 54 net production lines; branch total removes 154. Targeted
types (including MCP consumers), retained-file type-aware lint, formatting,
zero runtime import cycles, suppression audit and independent P2 review pass.
Gateway behavioral suites remain incomplete after a loaded-host startup run
was stopped at about ten minutes (exit 143). The prior full static-graph gap
remains pending for the coordinator bundle; no new production edge is added.

* refactor(ui): consolidate page lifecycle and config plumbing

Reuse the existing controller host, subscription and plugin-icon owners;
share cloud-worker config edit wiring and Usage query comparisons. Remove
the unused Usage detail predicate and duplicate model loading flag.

Retire the Web Awesome-era picker hiding fence now that native Popover
owns generation-bound close completion. Keep both rendering paths,
draft recovery, user-intent checks and dispatch-time write authority.
Settled rendering is unchanged. Net production reduction: 210 lines.

Best-effort tradeoffs accepted:
- Failed channel artwork retries on the next channel refresh rather than
  a queued trailing ensure. openclaw#131511 was a synthetic ordering regression;
  the human-reported owning-plugin bug openclaw#144152 remains covered.
- Picker triggers may reopen during closing. openclaw#126032's fence came from
  CI/synthetic overlap, not a human incident; openclaw#171441 transferred lifecycle
  ownership to native Popover, which ignores superseded completions.

Focused proof: 281 tests passed, including Chromium/WebKit overlay lifecycle
and responsive placement controls. Independent P0-P2 review: scoped-clean.
Final UI production and UI-pages test typechecks passed; suppression tests 3/3.
Scoped lint passed after a mechanical no-lonely-if fix.
Runtime and static import cycles: zero. No visual or locale changes.
The global environment-name budget is inherited at 455/454 on both the
untouched base and origin/main; none of its counted source roots changed.

* refactor(ui): remove unused new-session hiding selector

* refactor(gateway): retain legacy catalog and update handler contracts

Withdraw two wave-5 cleanups after focused CI failures and bounded isolated replay. Preserve the existing scalar-read concurrency and update-status handler contract. Tighten task-suggestions assertion allowance to match the cleaned source.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos app: web-ui App: web-ui channel: whatsapp-web Channel integration: whatsapp-web cli CLI command changes commands Command implementations gateway Gateway runtime maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant