Skip to content

feat(dashboard): 支持按群配置实时卡片 Pin override - #1155

Merged
deepcoldy merged 16 commits into
deepcoldy:masterfrom
TWT233:feat/dashboard-chat-pin-override
Sep 1, 2026
Merged

deepcoldy merged 16 commits into
deepcoldy:masterfrom
TWT233:feat/dashboard-chat-pin-override

Conversation

@TWT233

@TWT233 TWT233 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

背景

PR #1067 已提供默认关闭的 Bot 级 pinStreamingCard 总开关,以及 per-chat negative override。Bot 级开关已经可以在 Dashboard 的「Bot Defaults → Cards → 置顶当前实时卡片」配置,但群级 override 此前只能通过 /card pin off|on|status 管理。

自动 Pin 的目标是让操作者快速找到并关闭当前活跃会话;如果某个群不适合自动 Pin,可只对该群关闭,而不影响实时卡本身。

改动

  • 在 Group Manage 中按已入群 Bot 展示当前群自动 Pin 开关。
  • 同时展示 Bot 总开关、当前群 override 与最终 effective 状态;总开关关闭时明确提示群级开关不能强制开启。
  • 接通 daemon group row、Dashboard 聚合与按 chatId + appId 代理写入,并在保存后失效群组矩阵缓存。
  • 保存失败时回滚 UI;写入成功但刷新失败时保留已持久化状态,并使用独立 warning 状态提示。
  • 匿名 publicReadOnly 响应继续剥离 Pin 策略字段。

这是 negative override:关闭时只停止该 Bot 在当前群自动 Pin,实时卡仍正常发送;它不能越过 Bot 级总开关强制开启。

UI

Group Manage 中的群级 Pin override

截图由真实 Dashboard 组件和 synthetic fixture 生成,未连接或切换 live daemon。

影响面

  • Dashboard / daemon:新增 chat × bot Pin 状态读取和写入链路。
  • 会话语义:不改变 per-session Pin 生命周期,也不影响实时卡发送、回复或关闭。
  • 公开只读模式:不暴露 Bot / 群级 Pin 配置状态。

验证

  • mise exec [email protected] -- bun vitest run --project unit test/dashboard-ipc.test.ts test/groups-action-helpers.test.ts test/dashboard-chat-pin-route.integration.test.ts test/dashboard-public-redact.test.ts test/dashboard-streaming-card-pin-toggle.test.ts test/dashboard-bot-defaults-cliid.test.ts test/dashboard-aggregator.test.ts:7 个文件,312 passed / 1 skipped。
  • 使用真实中英文 translator 渲染确认:刷新失败保留已保存状态并显示 warning tone,正常保存显示 success tone。
  • mise exec [email protected] -- bun run build:通过。
  • git diff --check origin/master...HEAD:通过。
  • 全量 unit 非门禁运行:20289 passed / 9 failed / 19 skipped;其中 3 个额外时序失败单独复跑通过,剩余失败集中在本机既有的 bwrap/MCP sandbox、symlink canonical path、process comm 与 Grok FD discovery;Grok 同一失败已在当前 origin/master 复现。

Closes #1124

TWT233 and others added 16 commits September 1, 2026 10:35
@TWT233
TWT233 requested a review from deepcoldy as a code owner September 1, 2026 05:11
@TWT233

TWT233 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

CI 说明:本 PR 的 build、bun-binary、bun-binary-musl 已通过;bun-test 在 35 个广泛分散、与本改动无关的进程/终端/宿主测试文件上失败,其中包含多个 SIGKILL。当前 master@3b818ff6 的同一 CI 也以几乎相同的 34 个文件失败(run https://github.com/deepcoldy/botmux/actions/runs/33470080480),而本 PR 的 7 文件定向矩阵为 312 passed / 1 skipped。基于同源基线对照,暂不改动 Dashboard 功能代码来追逐该失败。

@deepcoldy deepcoldy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

双审通过(首审 + 复审结论一致:可合、无阻断),维护者已确认合入。

验证摘要:

  • 基于最新 origin/master 建真合并树(非 rebase)复验:改动文件恰好 19 个,无越界;#1158 对 test/dashboard-bot-defaults-layout.test.ts 的修复在合并结果中完整保留。
  • 合并树上 bun run build 通过;相关 10 个测试文件 338 passed / 1 skipped 全绿(含主干新进的 #1158、#1164 各自的测试)。
  • 13 个变异体 11 红;2 个绿经探针证明为惰性编辑(兜底分支不可达、fixture 中两数组恒等),属覆盖形态而非断言失效。
  • 鉴权边界端到端复验:匿名 PUT 在 publicReadOnly 开/关两种模式下均 401;公开模式下 GET /api/groups 返 200 但三个 pin 字段全部脱敏。
  • 新写入路由与 /card pin 复用同一 setChatStreamingCardPin,串行化与实时 reconcile 语义自动继承,两入口不分叉。
  • CI bun-test 红为既有问题(该腿 continue-on-error,唯一门禁 build 绿):同树替换为 master 内容重跑复现同一条失败,与本 PR 无关。

后续建议(不阻断):补一条「无 cookie PUT → 401」的集成用例,把该边界从人工复核转为回归钉住。

@deepcoldy
deepcoldy merged commit 7a2dff1 into deepcoldy:master Sep 1, 2026
3 of 4 checks passed

@DeepColds DeepColds left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

发现两个需要修改的问题:

  1. [阻断] 保存成功后,弹窗中的 effective 状态仍来自旧快照。

GroupPinStreamingCardRow 只在本地更新 checked,但 masterEnabled / effectiveEnabled 始终读取 member;保存后的 onReloadGroups({ force: true }) 虽然更新了页面 snapshot,DialogState 仍持有打开弹窗时的 chat 对象,DialogHost 继续把 props.dialog.chat 传给 ManageDialog。因此 Bot 总开关开启时,把群级 override 从 off 切到 on 后,会同时显示“开关已开 + Saved + This chat does not pin the live card”;反向切换也会显示相反的旧结论,直到关闭并重新打开弹窗。

建议让 manage dialog 按 chatId 从最新 snapshot.chats 解析当前行(找不到时再回退旧对象),或者在 reload 返回后显式同步 dialog 中的 member;并补一条成功保存后断言 detail/effective 文案翻转的测试,现有测试只断言了 checkbox 和 Saved 状态。

  1. [重要] 三个布尔字段被复制到完整 chat × bot 笛卡尔矩阵,包括所有 inChat:false 行,显著放大本来已经很大的 /api/groups 响应。

仓库现有注释记录的实测规模是 1420 群 × 56 bot,完整矩阵约 12.59MB,且 memberBots 已占 12.34MB。当前实现给约 79,520 行都增加 pinStreamingCardMasterEnabled / pinStreamingCardChatEnabled / pinStreamingCardEffectiveEnabled;按紧凑 JSON 估算额外约 8.6MiB。但 Group Manage 只渲染 inChat 的 member,非成员行不需要这些状态。

建议至少对 inChat:false 行省略这三个可选字段;也可以把三个布尔压成更紧凑的状态。请补一个聚合 shape/体积回归测试,避免这个为名称/头像链路专门做过瘦身的接口重新膨胀。

其余代理写入、匿名脱敏、失败回滚及定向测试未发现新的阻断问题。我本地在 PR HEAD 上复跑了提交说明中的 7 个测试文件:312 passed / 1 skipped。

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

🚀 Released in v3.18.12

deepcoldy pushed a commit that referenced this pull request Sep 4, 2026
群管理弹窗在异步操作与快照刷新交叠时的一组边界收敛,是 #1155 的 correctness follow-up。

主要改动:

- 非群成员(inChat:false)的矩阵行省略三个 Pin 状态字段,避免在大型 chat x bot 矩阵中复制无消费价值的数据。
- 群管理弹窗按 chatId 跟随最新快照,同步 Pin 状态、Oncall 字段与可退出成员集合,同时保留用户未提交的草稿。
- 完整快照缓存改为 latest-successful 语义:较晚的失败不再丢弃较早的成功结果。
- 群已从最新列表消失时保留只读展示,但禁用 Pin、Oncall、退出与解散,并在确认回调中阻断。
- Oncall 保存期间锁定开关、工作目录与保存按钮,避免旧的保存结果覆盖期间的新编辑。
- 区分弹窗存活与群可用两种语义:动作前的闸判断群是否仍在,动作后的收尾(读取响应、提示成功、关闭弹窗)只依赖弹窗是否仍挂载。此前二者合一,导致并发刷新落在退群或解散请求飞行中时,成功的操作既不提示也不关闭弹窗。
- 补充群级 Pin 写入的鉴权回归:private 与 publicReadOnly 模式下匿名 PUT 均返回 401 且不转发至 daemon。
- 路由集成测试改用 loopbackFetch 并读取隔离 HOME 中实际落盘的 .dashboard-port,消除端口预留与释放之间的竞态。

影响面限于 Dashboard 群组矩阵响应、群管理弹窗客户端状态与相关测试,不改变 daemon 的 per-chat Pin 配置语义与实时卡生命周期。

验证:tsc 与 build 通过;本 PR 四个测试文件 39 通过;Dashboard 面 101 文件 1945 通过;反变异复核确认修复与新增回归测试均有效(撤回修复、仅撤 toast 侧 guard 的半修形态、撤防陈旧闸、鉴权阳性对照,四项均转红);CI 四项在 head 094c904 全绿。

Follow-up to #1155.
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.

feat(dashboard): 支持按群配置流式卡片 Pin override

3 participants