Skip to content

fix(qr): replace qrcode-terminal with qrcode-tui - #65969

Merged
vincentkoc merged 7 commits into
mainfrom
fix/qr-qrcode-tui-shared
Apr 23, 2026
Merged

vincentkoc merged 7 commits into
mainfrom
fix/qr-qrcode-tui-shared

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Apr 13, 2026 •

Copy link
Copy Markdown
Member

Summary

  • AI-assisted: yes (Codex); locally verified with the commands listed below.
  • Problem: OpenClaw still depended on qrcode-terminal directly in the CLI and bundled plugins, and the shared PNG QR path deep-imported qrcode-terminal vendor internals.
  • Why it matters: that package is stale, already triggered Node compatibility fallout in [Bug]: main branch build error #48035, and kept Docker smoke/tests validating the wrong runtime seam.
  • What changed: swapped CLI, WhatsApp, Feishu, and shared QR image generation over to @vincentkoc/qrcode-tui; removed the old type shim and dependency edges; added a host-owned media-runtime QR terminal seam so plugins no longer reach into the external package directly; updated the Docker QR smoke/docs/tests to exercise the maintained package.
  • What did NOT change (scope boundary): this does not add new QR product features like file output or an HTTP endpoint for onboarding; it only rewires the existing QR surfaces to the new package.

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: OpenClaw had three QR surfaces tied to qrcode-terminal: direct terminal rendering in CLI/plugin code, deep vendor imports for PNG generation, and a Docker smoke that only proved the stale package could still load.
  • Missing detection / guardrail: the repo had no guardrail ensuring QR flows use one maintained package seam end-to-end.
  • Contributing context (if known): fix(cli): patch qrcode-terminal octal escapes for Node 25 compatibility (#48035) #48418 patched qrcode-terminal for newer Node parsing instead of removing the stale dependency from the product 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: src/cli/qr-cli.test.ts, extensions/whatsapp/src/login.test.ts, extensions/whatsapp/src/session.test.ts, extensions/feishu/src/setup-surface.test.ts, src/docker-build-cache.test.ts
  • Scenario the test should lock in: QR CLI, plugin QR login/setup flows, and the Docker import smoke all resolve the maintained QR package through the intended host seam instead of qrcode-terminal or vendor internals.
  • Why this is the smallest reliable guardrail: the failure mode lived at the package seam and runtime ownership boundary, not in QR algorithm output.
  • Existing test that already covers this (if any): extensions/feishu/src/setup-surface.test.ts already covers the Feishu setup surface that calls into printQrCode.
  • If no new test is added, why not: no dedicated live scan test was added in this branch.

User-visible / Behavior Changes

  • None for product behavior.
  • Maintainers and Docker smoke now validate @vincentkoc/qrcode-tui instead of qrcode-terminal.

Diagram (if applicable)

Before:
[CLI / WhatsApp / Feishu] -> [qrcode-terminal]
[shared PNG QR helper] -> [qrcode-terminal vendor internals]
[Docker smoke] -> [import qrcode-terminal]

After:
[CLI] -> [src/media/qr-terminal.ts] -> [@vincentkoc/qrcode-tui]
[plugins] -> [plugin-local qr-terminal.ts] -> [openclaw/plugin-sdk/media-runtime] -> [src/media/qr-terminal.ts]
[shared PNG QR helper] -> [@vincentkoc/qrcode-tui]
[Docker smoke] -> [import @vincentkoc/qrcode-tui]

Security Impact (required)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: Node 25 locally, Docker smoke fixture updated for repo-supported Node runtimes
  • Model/provider: N/A
  • Integration/channel (if any): CLI, WhatsApp, Feishu
  • Relevant config (redacted): N/A

Steps

  1. Replace the stale QR dependency with @vincentkoc/qrcode-tui across the CLI, plugin, and shared QR runtime seams.
  2. Route plugin terminal QR rendering back through openclaw/plugin-sdk/media-runtime via tiny plugin-local barrels.
  3. Update package manifests/lockfile and switch the Docker smoke from qrcode-terminal import to the maintained package.
  4. Run scoped tests, pnpm build, and pnpm check.

Expected

  • QR rendering paths work without qrcode-terminal or vendor deep-imports.
  • Plugins consume the QR terminal helper through the host runtime seam.
  • Build/check stay green.
  • Docker QR smoke validates the maintained package seam.

Actual

  • All listed verification steps passed locally.

Evidence

Attach at least one:

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

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: pnpm test src/cli/qr-cli.test.ts extensions/whatsapp/src/login.test.ts extensions/whatsapp/src/session.test.ts extensions/feishu/src/setup-surface.test.ts; pnpm test src/docker-build-cache.test.ts -t "copies manifests before install in the qr-import image"; pnpm build; pnpm check
  • Edge cases checked: CLI QR rendering path, WhatsApp terminal QR path, shared PNG QR output signature, Feishu setup seam, Docker QR smoke fixture, public SDK build/export pass
  • What you did not verify: a full live QR scan on device in this branch

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.

If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.

Compatibility / Migration

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

Risks and Mitigations

  • Risk: terminal output from the new package could differ slightly from qrcode-terminal in whitespace or compactness.
    • Mitigation: scoped CLI/WhatsApp tests cover the rendering seam and the product only depends on scanability, not exact string snapshots.
  • Risk: newly published @vincentkoc/qrcode-tui is now part of the runtime/install graph.
    • Mitigation: root manifest and lockfile are updated together, plugin code routes through the host seam, and Docker/build/check all ran against the published package.

@vincentkoc vincentkoc self-assigned this Apr 13, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: whatsapp-web Channel integration: whatsapp-web cli CLI command changes scripts Repository scripts docker Docker and sandbox tooling channel: feishu Channel integration: feishu size: S maintainer Maintainer-authored PR labels Apr 13, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review April 13, 2026 14:06
@vincentkoc

Copy link
Copy Markdown
Member Author

Additional context for reviewers:

  • @vincentkoc/qrcode-tui@0.2.1 is already published on npm and is the package this PR wires into OpenClaw.
  • The first commit does the dependency swap and smoke/test updates.
  • The second commit intentionally cleans the boundary back up so Feishu/WhatsApp consume QR terminal rendering through openclaw/plugin-sdk/media-runtime instead of importing the external package directly.
  • Local verification on this branch passed:
    • pnpm test src/cli/qr-cli.test.ts extensions/whatsapp/src/login.test.ts extensions/whatsapp/src/session.test.ts extensions/feishu/src/setup-surface.test.ts
    • pnpm test src/docker-build-cache.test.ts -t "copies manifests before install in the qr-import image"
    • pnpm build
    • pnpm check

The remaining wait right now is GitHub Actions queue time on the PR-side runs.

@greptile-apps

greptile-apps Bot commented Apr 13, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces qrcode-terminal with @vincentkoc/qrcode-tui across CLI, WhatsApp, Feishu, and shared PNG QR paths, and introduces a host-owned media-runtime seam so plugins route terminal QR rendering through the Plugin SDK instead of importing the external package directly.

  • Supply chain concern: @vincentkoc/qrcode-tui is authored by the PR author (vincentkoc), who retains publish access. The ^0.2.1 range means future releases would be pulled in without a separate review. Reviewers should confirm npm 2FA and consider pinning to an exact version.
  • Boundary violation in test: The new guard test in extensions/whatsapp/src/login.test.ts reads and asserts the source contents of src/media/qr-image.ts — a core file — from an extension test, violating the documented extension/core boundary. It should move to a co-located core test.

Confidence Score: 4/5

Not safe to merge without addressing the self-authored dependency governance question and moving the boundary-violating guard test to core.

Two P1 findings: the PR author adding their own npm package under a semver range (supply chain concern requiring explicit team sign-off), and an extension test asserting core source file contents in violation of the documented extension/core boundary. The code structure is otherwise clean and the seam design is sound.

package.json (self-authored dependency, version range), extensions/whatsapp/src/login.test.ts (boundary-crossing guard test)

Security Review

  • Self-authored runtime dependency (package.json): @vincentkoc/qrcode-tui is published by the PR author (vincentkoc). The ^0.2.1 range allows automatic patch/minor updates controlled exclusively by the PR author. Reviewers should confirm npm 2FA, exact-version pinning policy, and whether this dependency was separately security-reviewed before merging.

Comments Outside Diff (1)

  1. package.json, line 1 (link)

    P1 security Self-authored dependency introduces supply chain risk

    @vincentkoc/qrcode-tui is authored and published on npm by vincentkoc, who is also the author of this PR. The ^0.2.1 semver range means any future patch or minor release pushed to this package would be pulled in automatically on the next install — without a separate PR or review. Reviewers should treat this as a supply chain governance decision: the PR author has unilateral publish access to a transitive runtime dependency being added here. Pinning to an exact version ("0.2.1" instead of "^0.2.1") would reduce the blast radius of an unreviewed future publish, and the team should verify npm 2FA and publication policy on this package before merging.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: package.json
    Line: 1
    
    Comment:
    **Self-authored dependency introduces supply chain risk**
    
    `@vincentkoc/qrcode-tui` is authored and published on npm by `vincentkoc`, who is also the author of this PR. The `^0.2.1` semver range means any future patch or minor release pushed to this package would be pulled in automatically on the next install — without a separate PR or review. Reviewers should treat this as a supply chain governance decision: the PR author has unilateral publish access to a transitive runtime dependency being added here. Pinning to an exact version (`"0.2.1"` instead of `"^0.2.1"`) would reduce the blast radius of an unreviewed future publish, and the team should verify npm 2FA and publication policy on this package before merging.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: package.json
Line: 1

Comment:
**Self-authored dependency introduces supply chain risk**

`@vincentkoc/qrcode-tui` is authored and published on npm by `vincentkoc`, who is also the author of this PR. The `^0.2.1` semver range means any future patch or minor release pushed to this package would be pulled in automatically on the next install — without a separate PR or review. Reviewers should treat this as a supply chain governance decision: the PR author has unilateral publish access to a transitive runtime dependency being added here. Pinning to an exact version (`"0.2.1"` instead of `"^0.2.1"`) would reduce the blast radius of an unreviewed future publish, and the team should verify npm 2FA and publication policy on this package before merging.

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/login.test.ts
Line: 69-74

Comment:
**Extension test policing core source file violates boundary**

This test case reads `src/media/qr-image.ts` by constructing a path relative to `process.cwd()` from inside an extension test file. This crosses two lines: (1) CLAUDE.md forbids extension tests from deep-importing or asserting on core internals (`src/**`), and (2) the `resolve(process.cwd(), "src/media/qr-image.ts")` assumption hard-codes that the test runner's CWD is the repo root — any deviation (running vitest from the extension directory) silently resolves the wrong path and the `expect` passes vacuously on an empty or unrelated file. This guard test belongs in a co-located core test such as `src/media/qr-image.test.ts`.

**Context Used:** CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))

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

Reviews (1): Last reviewed commit: "docs(plugin-sdk): document QR terminal m..." | Re-trigger Greptile

Comment thread extensions/whatsapp/src/login.test.ts Resolved
@vincentkoc
vincentkoc force-pushed the fix/qr-qrcode-tui-shared branch from 51edaee to 5ff6f74 Compare April 13, 2026 14:20
@vincentkoc

Copy link
Copy Markdown
Member Author

addressed the review follow-ups on 007022b6ca:

  • pinned @vincentkoc/qrcode-tui to exact version 0.2.1 and synced pnpm-lock.yaml
  • moved the QR helper delegation guard out of extensions/whatsapp/src/login.test.ts into new core coverage at src/media/qr-image.test.ts
  • added a small authChoice guard in src/wizard/setup.ts plus regression coverage in src/wizard/setup.test.ts to fix the failing check lane on the PR head

local verification:

  • pnpm test:serial src/media/qr-image.test.ts extensions/whatsapp/src/login.test.ts src/wizard/setup.test.ts
  • pnpm check

@blacksmith-sh

This comment has been minimized.

@vincentkoc
vincentkoc force-pushed the fix/qr-qrcode-tui-shared branch from 007022b to ee2f560 Compare April 16, 2026 18:01

@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: ee2f560927

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/canvas-host/a2ui/.bundle.hash Resolved
@vincentkoc
vincentkoc force-pushed the fix/qr-qrcode-tui-shared branch 2 times, most recently from 54f5dcf to 32eacf3 Compare April 23, 2026 19:25

@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: 32eacf39db

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread extensions/whatsapp/src/qr-terminal.ts Resolved
@vincentkoc
vincentkoc force-pushed the fix/qr-qrcode-tui-shared branch from 32eacf3 to fc72f1e Compare April 23, 2026 19:48
@vincentkoc
vincentkoc merged commit ea25d7e into main Apr 23, 2026
71 checks passed
@vincentkoc
vincentkoc deleted the fix/qr-qrcode-tui-shared branch April 23, 2026 20:06
@vincentkoc vincentkoc mentioned this pull request Apr 23, 2026
8 of 21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu channel: whatsapp-web Channel integration: whatsapp-web cli CLI command changes docker Docker and sandbox tooling docs Improvements or additions to documentation maintainer Maintainer-authored PR scripts Repository scripts size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: main branch build error

1 participant