feat(web): zero-input pairing, a real QR, and no scanner or scopes

The console side of ADR 0001: a scanned link pairs itself, the status page
draws the daemon's actual symbol, and the second entry point for pairing
(the in-page camera scanner) is gone.

- `POST /api/v1/pair/redeem` replaced the dual-purpose `/api/v1/pair`; the
  redeem response is parsed strictly as `{token, device}` (the five-layer
  alias fallbacks for `deviceToken`/`payload.device`/… are deleted).
- `features/status/qr.ts` no longer invents "a deterministic fake QR from a
  seed" — it renders `pairCode.qr.rows` module by module (devicePixelRatio
  aware, square, token colours, redraws on theme/resize), and a mint without a
  matrix shows the link instead of a pattern that will not scan.
- `/pair/<CODE>` (daemon 302 or the SPA route) lands on
  `/connect?code=…&auto=1`, which redeems against its own origin with the
  localized device name and then navigates to `next`/`/workspaces`, dropping
  the code from the URL; a rejected code falls back to the prefilled form.
- The camera scanner (`features/connect/scan-dialog.tsx`) and its i18n keys are
  removed: phones scan with the system camera, desktops type the code. Paste a
  `pi2://pair?…` link or `/pair/CODE` still fills the form.
- Scope tracking disappears from the store, API types, device list and pairing
  metadata (`pi2-device-scopes` is no longer written or read).
- Stale default removed: link parsing falls back to the served origin's port,
  then 443/80, instead of a hard-coded 4321.
- `scripts/ui-{fixtures,mock-server,shots}.mjs` follow the new contract
  (mint carries `qr`/`bases`, redeem route, no scopes), so the visual harness
  exercises the real flow.

Verification: web typecheck clean, 299/299 tests, `vite build` green, visual
matrix 24/24 clean, and the i18n catalog has no missing keys.
This commit is contained in:
yuez committed 2026-10-27 10:44:54 +08:00
1 parent a57c874095
commit 3e35fb7ef3
20 files changed
+419 -946

No files matched your search

+4 -30
View File
@@ -413,19 +413,12 @@
"common.stop": "停止",
"connect.addTitle": "连接设置",
"connect.address": "地址",
"connect.aim": "将设备背面对准 pi2 服务器上的二维码",
"connect.backToWorkspaces": "返回工作空间",
"connect.cameraFailed": "无法打开摄像头(可能没有可用设备)。请改用配对链接。",
"connect.cameraPreview": "摄像头预览",
"connect.cameraUnsupported": "当前浏览器不支持摄像头,请改用下方配对链接。",
"connect.cantScan": "无法扫码?粘贴配对链接",
"connect.collapseManual": "收起手动连接",
"connect.confirmTitle": "确认连接",
"connect.connect": "连接",
"connect.connected": "已连接:{name}",
"connect.connecting": "正在连接…",
"connect.defaultDeviceName": "Web 控制台",
"connect.demoScan": "演示:模拟扫码",
"connect.details": "连接详情",
"connect.device": "设备",
"connect.deviceName": "设备名",
@@ -434,13 +427,13 @@
"connect.disconnectText": "将清除此浏览器保存的连接与 Token,需要重新配对才能继续。",
"connect.disconnectTitle": "断开连接",
"connect.disconnected": "已断开连接",
"connect.emptyText": "填写地址,或扫码配对 pi2 服务器后即可开始。",
"connect.emptyText": "填写地址,以及 pi2 服务器上显示的 8 位配对码即可开始。",
"connect.emptyTitle": "连接 pi2 服务器",
"connect.endpoint": "地址",
"connect.expandManual": "展开手动连接",
"connect.failed": "连接失败,请检查地址与配对码",
"connect.featureOne": "工作空间与会话实时同步",
"connect.featureThree": "只读 / 操控 / 应用 分级授权",
"connect.featureThree": "手机扫码即配对,无需配置、无需切换模式",
"connect.featureTwo": "子代理与后台任务一处掌控",
"connect.heroText": "一个浏览器连接一个 pi2 实例,在任意设备上继续你的 Neovim 会话。",
"connect.heroTitle": "连接你的 pi2",
@@ -448,14 +441,10 @@
"connect.hostPlaceholder": "192.168.2.10 或 http://…:4321",
"connect.hostRequired": "请输入服务器地址",
"connect.hostname": "Hostname",
"connect.identify": "识别",
"connect.invalidLink": "无法识别,请粘贴完整的 pi2://pair 链接",
"connect.lastConnected": "最后连接",
"connect.manual": "手动连接",
"connect.name": "名称",
"connect.noAutoDetect": "摄像头已开启。当前浏览器不支持自动识别,请粘贴配对链接。",
"connect.notPairQr": "这不是 pi2 配对二维码,请换一个",
"connect.or": "或",
"connect.os": "系统",
"connect.pairCode": "配对码",
"connect.pairCodeHint": "pi2 服务器上显示的 8 位配对码。",
@@ -467,31 +456,17 @@
"connect.pairHint": "扫描 pi2 服务器显示的配对二维码,识别后需二次确认。",
"connect.pairingAuto": "正在配对这台设备…",
"connect.pairingLink": "配对链接",
"connect.pastePlaceholder": "粘贴 pi2://pair?… 配对链接",
"connect.permissionDenied": "摄像头权限被拒绝。请在浏览器设置中允许访问后重试。",
"connect.pasteHint": "也可以直接粘贴配对链接,省去填写地址与配对码",
"connect.pastePlaceholder": "粘贴 pi2://pair?… 或 /pair/CODE 链接",
"connect.piVersion": "pi 版本",
"connect.pluginVersion": "插件版本",
"connect.port": "端口",
"connect.portInvalid": "端口必须是 1–65535",
"connect.recognized": "已识别二维码",
"connect.reconnect": "重新配对",
"connect.retryCamera": "重试摄像头",
"connect.scan": "扫码配对",
"connect.scanHint": "扫描 pi2 服务器显示的配对二维码,识别后需二次确认。",
"connect.scanLead": "已识别到 pi2 配对信息。请确认二维码来自你信任的设备。",
"connect.scanTitle": "扫码配对",
"connect.scanWarning": "连接后该设备可读写会话并派发子代理。",
"connect.scannedNote": "扫码配对",
"connect.scope.apply": "写入",
"connect.scope.read": "读取",
"connect.scope.steer": "操作",
"connect.scopeHint": "此设备获得的权限:{scope}",
"connect.scopes": "权限",
"connect.secureBadge": "Token 仅保存在本机",
"connect.secureNote": "摄像头需要 HTTPS(或 localhost);Token 仅保存在此浏览器。",
"connect.secureRequired": "摄像头需要 HTTPS(或 localhost)安全环境,请改用下方配对链接。",
"connect.server": "服务器",
"connect.startingCamera": "正在启动摄像头…",
"connect.statePaired": "已连接",
"connect.stateUnpaired": "未连接",
"connect.subtitle": "连接本机 pi2 实例,查看配对与连接信息。",
@@ -658,7 +633,6 @@
"status.tasks": "后台任务",
"status.tasksError": "加载后台任务失败",
"status.title": "服务器状态",
"status.tokenScopes": "Token 权限",
"status.updated": "{time}更新",
"status.uptime": "已运行时长",
"status.workspaces": "工作空间数",