Skip to content

fix(chat): keep terminal QR codes in extension notices intact (#755) - #1120

Open
agegr wants to merge 1 commit into
mainfrom
fix/notice-qr-code
Open

agegr wants to merge 1 commit into
mainfrom
fix/notice-qr-code

Conversation

@agegr

@agegr agegr commented Oct 8, 2026

Copy link
Copy Markdown
Owner

pi-wechat-assistant's /wechat login builds its QR code with qrcode-terminal's small mode (█ ▀ ▄ and runs of spaces, no ANSI) and sends it through ctx.ui.notify(), which pi-web shows as a toast in NoticeShelf. Three things in the toast's styling garbled it: white-space: pre-line collapsed the runs of spaces, the UI font gave spaces and blocks different widths, and the 1.5 line height opened gaps between rows. pi's TUI shows the same text on a terminal grid, so it lines up there.

  • lib/notice-text.ts (new): splitNoticeText() separates lines containing block elements (U+2580–259F) from the rest of the notice.
  • components/ChatWindow.tsx: those lines render with spaces kept (pre), rows touching (line-height: 1), and Menlo, Consolas, 'DejaVu Sans Mono', monospace (the bundled Noto mono subset has no block glyphs, so spaces and blocks would come from fonts of different widths). Prose in the same notice is unchanged.
  • No extension API change.

Checked by rendering a real qrcode-terminal QR inside the toast markup in headless Chrome: garbled before, a clean code after. Test: lib/notice-text.test.mjs. tsc, eslint, npm test pass.

Left as is: notices still expire after 5 s unless hovered (short for scanning a code); in light mode the code shows inverted, as on a light terminal in pi's TUI.

Closes #755

🤖 Generated with Claude Code

pi-wechat-assistant's /wechat login sends a qrcode-terminal QR code (█ ▀ ▄
and runs of spaces) through ctx.ui.notify(). The toast's pre-line collapsed
the runs of spaces, its UI font gave spaces and blocks different widths and
its 1.5 line height opened gaps between rows, so the code came out garbled.
Lines drawn with block characters now render as pi's TUI shows them: spaces
kept, rows touching, one monospace font for spaces and blocks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

关于webUI界面和WeChat智能体接入的兼容性问题

1 participant