@duanz/pi-d-live 1.1.8 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.ts +5 -4
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -594,12 +594,13 @@ function emit(payload: Record<string, unknown>) {
594
594
  const line = `data: ${JSON.stringify(payload)}\n\n`;
595
595
  const sid = typeof payload.sid === "string" ? payload.sid : "";
596
596
  const unknown = !sid || sid === "default";
597
+ // 只连一个页面时,地址栏的号可能没跟上当前会话(pi-web 切会话不写地址栏),
598
+ // 不再按号挑,直接推给这唯一页面;多页面仍严格按号分流,避免串台。
599
+ const solo = clients.size === 1;
597
600
  for (const c of clients) {
598
- // 只推给「报了号且号对得上」的页面:空号连接(旧版页面)一律不推,
599
- // 否则一个页面会收到所有会话的播报,串到别的会话里。
600
601
  const want = clientSids.get(c) || "";
601
- if (!want) continue;
602
- if (!unknown && want !== sid) {
602
+ if (!want && !solo) continue;
603
+ if (!solo && !unknown && want !== sid) {
603
604
  // 诊断:事件被号不对的连接挡下来时记一条(10 秒最多一条),
604
605
  // 「条子不出现」时能一眼看出是页面连错号还是根本没事件
605
606
  const stamp = Date.now();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duanz/pi-d-live",
3
- "version": "1.1.8",
3
+ "version": "1.1.9",
4
4
  "description": "把模型思考与工具调用实时改写成内心独白,推到 pi-web 界面顶部浮层",
5
5
  "type": "module",
6
6
  "keywords": [