Skip to content

推送断线超过 2 秒顶上提示连不上、正在重试,连回来收起 - #84

Merged
joesmart merged 4 commits into
mainfrom
joesmart/fix-reconnect-banner
Oct 23, 2026
Merged

joesmart merged 4 commits into
mainfrom
joesmart/fix-reconnect-banner

Conversation

@joesmart

@joesmart joesmart commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

改了什么

  • 推送连接状态进 store:ReadyState.pushLink,字面量联合 "down" | "open"。WebSocket open 置 open,close 置 down,初始 down。
  • 新组件 PushBanner:pushLink 不是 open 且持续超过宽限期(PUSH_GRACE_MS = 2 * reconnectDelay(0),现在是 2 秒),就在顶部显示「连不上服务,正在重试。连上后会补上这段时间的消息」。外层 aria-live="polite" 区域一直挂着,读屏才会念后插进来的字。连回来就收起。
  • 横幅占内容区(对话区加右栏)顶上一行,参与网格布局,把下面的内容往下推,不压住聊天头的「编辑」「分享」。.window 改成两行网格,侧栏跨两行。横幅定高 --control-h-md、不换行,OAuth 和新 Bot 的浮动提示在横幅出现时往下让一个横幅高度,不再重叠。只用设计系统 token。
  • mock 控制面加 POST /api/test/sockets/refuse,拒掉之后的推送握手,让断线能持续下去。

为什么

断线和退避重连期间 HTTP 还通,界面看着是活的,其实收不到推送,用户以为 Bot 没反应。补拉逻辑本来就有(push_reconnected),缺的是让人知道。宽限期跟着首次重连的退避值走,断一下马上连回来的情况不打扰人。

怎么验证

新增 packages/web/e2e/push-banner.spec.ts:

  • 「推送断线超过宽限期,顶上说连不上、正在重试;连回来提示消失,断线期间的消息补拉出来」:在 main 的实现上红(断线超过宽限期就提示 找不到元素),修复后绿。
  • 「推送断一下马上连回来,提示不闪出来」:宽限期的回归守卫。
  • 主用例里加了断言:断线时「编辑」「分享」看得见、点得到,boundingBox 和横幅不相交。
  • 「断线提示和顶上的浮动提示同时出现时各占各的位置,不叠在一起」:OAuth 提示和横幅的 boundingBox 不相交。
  • 这两处新断言在浮层版 CSS 上是红的。
pnpm format:check && pnpm typecheck && pnpm lint      # 通过,lint 0 error
pnpm --filter @baize/web test                          # vitest 48 files / 351 passed;Playwright 456 passed
pnpm --filter @baize/web exec playwright test e2e/push-banner.spec.ts --repeat-each 5   # 15 passed

另外用 Playwright 起 mock 手点了一遍,亮色和暗色都看了,截图没进仓库。

Closes #31

🤖 Generated with Claude Code

https://claude.ai/code/session_01Be3SZps2JjqvyrJ1vbLmni

@joesmart
joesmart force-pushed the joesmart/fix-reconnect-banner branch from 761683e to eeaacc6 Compare October 23, 2026 15:27
@joesmart
joesmart merged commit c6f262d into main Oct 23, 2026
1 check passed
@joesmart
joesmart deleted the joesmart/fix-reconnect-banner branch October 23, 2026 15:28
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.

断线和重连期间界面没有任何提示

1 participant