Skip to content

Gateway: fix device pairing when local connection retries with existing non-silent pending request#3744

Open
photon3710 wants to merge 1 commit intoopenclaw:mainfrom
photon3710:fix/webui-pairing-docker
Open

Gateway: fix device pairing when local connection retries with existing non-silent pending request#3744
photon3710 wants to merge 1 commit intoopenclaw:mainfrom
photon3710:fix/webui-pairing-docker

Conversation

@photon3710
Copy link

@photon3710 photon3710 commented Jan 29, 2026

Summary

Fixes a bug where the Control UI dashboard fails to connect with "pairing required" error when a browser reconnects after a failed pairing attempt.

Problem

When a browser connects to the dashboard (e.g., http://127.0.0.1:18789/?token=...), if there's already a pending pairing request with silent: false from a previous connection attempt, subsequent local connection retries would fail because:

  1. requestDevicePairing() returns the existing pending request unchanged
  2. The request remains silent: false, preventing auto-approval
  3. Gateway rejects the connection with "pairing required" before showing the pairing code

This commonly occurs in Docker setups where the initial connection may not be detected as local due to Docker bridge network addressing.

Solution

Update requestDevicePairing() to upgrade existing pending requests to silent: true when a new local connection retries. This allows auto-approval to proceed even if the original request was non-silent.

Changes

  • Core Fix: src/infra/device-pairing.ts - Check if new request is silent: true and update existing pending request
  • Test: src/infra/device-pairing.test.ts - Add test case for silent flag upgrade behavior
  • Docs: docs/gateway/pairing.md - Document the silent flag upgrade behavior
  • Docs: docs/install/docker.md - Add Docker configuration guidance for Control UI access
  • Changelog: Add entry for the fix

Testing

  • ✅ Added unit test verifying silent flag upgrade
  • ✅ Tested with Docker setup: docker compose run --rm moltbot-cli dashboard
  • ✅ Verified dashboard connects successfully after clearing pairing state
  • ✅ Linter passes

AI-Assisted

  • Built with Claude (Cursor IDE)
  • Fully tested with Docker environment
  • Code review performed, root cause analysis confirmed

Related

Addresses the "pairing required" error commonly seen in Docker deployments when accessing the Control UI dashboard.

Greptile Overview

Greptile Summary

This PR fixes a gateway pairing edge case by upgrading an existing pending pairing request to silent: true when a retry comes from a local connection, enabling auto-approval to proceed. It adds a unit test covering the silent-flag upgrade path and updates Docker install docs / compose defaults to help users avoid “pairing required” issues in common Docker bridge setups.

Confidence Score: 2/5

  • Not safe to merge as-is due to likely broken Docker quick-start configuration from env var renames.
  • The core pairing change is small and covered by a targeted test, but the Docker Compose changes appear inconsistent with the existing docker-setup.sh/docs environment variable contract (CLAWDBOT_* vs MOLTBOT_*), which can break the documented onboarding flow and lead to missing tokens or invalid mounts.
  • docker-compose.yml, docs/install/docker.md, docker-setup.sh (not in PR but impacted)

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

- Added a fix for device pairing rejection during local connection retries in the CHANGELOG.
- Included guidance for Docker configuration to bypass device pairing in the installation documentation, detailing the necessary JSON configuration for the Control UI.
@openclaw-barnacle openclaw-barnacle bot added docs Improvements or additions to documentation docker Docker and sandbox tooling labels Jan 29, 2026
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +3 to 4
image: ${MOLTBOT_IMAGE:-moltbot:local}
environment:
Copy link
Contributor

Choose a reason for hiding this comment

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

[P0] docker-setup.sh/docs still export CLAWDBOT_* env vars, but this compose file was switched to MOLTBOT_* names.

As-is, the documented ./docker-setup.sh flow won’t populate ${MOLTBOT_IMAGE} / ${MOLTBOT_GATEWAY_TOKEN} / ${MOLTBOT_CONFIG_DIR} etc., which can lead to empty volume mounts and missing tokens at runtime.

Also appears in docker-compose.yml:7-14,16-28,32,41-42 and is referenced by docs/install/docker.md:35-57 + docker-setup.sh:7,24-33,35-47 (still uses CLAWDBOT_*).

Prompt To Fix With AI
This is a comment left during a code review.
Path: docker-compose.yml
Line: 3:4

Comment:
[P0] `docker-setup.sh`/docs still export `CLAWDBOT_*` env vars, but this compose file was switched to `MOLTBOT_*` names.

As-is, the documented `./docker-setup.sh` flow won’t populate `${MOLTBOT_IMAGE}` / `${MOLTBOT_GATEWAY_TOKEN}` / `${MOLTBOT_CONFIG_DIR}` etc., which can lead to empty volume mounts and missing tokens at runtime.

Also appears in `docker-compose.yml:7-14,16-28,32,41-42` and is referenced by `docs/install/docker.md:35-57` + `docker-setup.sh:7,24-33,35-47` (still uses `CLAWDBOT_*`).

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

Comment on lines +41 to +42
- ${MOLTBOT_CONFIG_DIR}:/home/node/.moltbot
- ${MOLTBOT_WORKSPACE_DIR}:/home/node/moltbot
Copy link
Contributor

Choose a reason for hiding this comment

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

[P1] This service mounts ${MOLTBOT_CONFIG_DIR} / ${MOLTBOT_WORKSPACE_DIR} without defaults, unlike moltbot-gateway.

If users follow the “Quick start” (./docker-setup.sh) or don’t define these vars, docker compose will treat them as empty and fail (invalid spec: :/home/node/.moltbot) or mount an unintended path. Consider adding the same defaults here (or keep variable names consistent with the setup script).

Prompt To Fix With AI
This is a comment left during a code review.
Path: docker-compose.yml
Line: 41:42

Comment:
[P1] This service mounts `${MOLTBOT_CONFIG_DIR}` / `${MOLTBOT_WORKSPACE_DIR}` without defaults, unlike `moltbot-gateway`.

If users follow the “Quick start” (`./docker-setup.sh`) or don’t define these vars, `docker compose` will treat them as empty and fail (`invalid spec: :/home/node/.moltbot`) or mount an unintended path. Consider adding the same defaults here (or keep variable names consistent with the setup script).

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker Docker and sandbox tooling docs Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant