dsh-multipane 1.1.10 → 1.1.11

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 (3) hide show
  1. package/README.md +6 -0
  2. package/lib/client.js +375 -120
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -162,6 +162,12 @@ node scripts/check-names.cjs # 包名 / 版本 / 冷却豁免三处是否一
162
162
 
163
163
  > 1.0.57–1.1.8 是内部迭代版本,未发布到 npm;1.1.9 是 1.0.56 之后的首个公开发布。
164
164
 
165
+ ### 1.1.11(2026-12-03)
166
+
167
+ - **修「切到全局面板(插件页 / 插件设置页)后右栏仍占位、按钮点不动、关不掉」**(Issue #1,@Free-LZJ):两处原因叠加。① 旧的 `startRightbarKeepOpen()` 每 900ms 检查「store 说展开、列宽却是 0」就补开轨道,这个判据在全局面板下也成立(宿主有意保留 per-session 的 `expanded`,好让切回会话时右栏还开着),于是定时器不停把已经让位的右栏顶回来;② 即使去掉定时器,`dsh-better-sidebar` 这类插件的 keepMounted 面板是 absolute 定位、固定宽度,不跟随轨道收成 0,会留下「占位还在、内容没了、顶部按钮还在但不可点」的壳。现在删掉定时器,改为按会话读写宿主 store;并在切到全局面板时对右栏列加 `visibility:hidden + pointer-events:none + opacity:0 + overflow:hidden` 把原生壳与 keepMounted 面板一起压住,切回会话视图全部还原,右栏原展开状态不变。
168
+ - **修「每栏点『上下文 / 详情』打不开右栏」**(Issue #2,@niiii555):多栏下每栏的右栏展开状态原先只改列宽轨道、不写宿主 per-session store,宿主下一次 `syncPresentation` 读到 `expanded === false` 就把列宽压回 0。现在新增 `isRightbarExpandedFor / writeRightbarExpanded / openRightbarFor / closeRightbarFor`,按本栏会话 id 读写 store,两边同一个状态源。跨会话(本栏不是宿主主视图)时先用 `openSession` 把主视图切过去、订阅 `mounted` 命中再写,另加一次性 600ms 兜底,无常驻轮询。
169
+ - 新增 `ISSUE-2-证据.md`(会话头视图入口缺失的根因与 A/B 实测);`docs/upstream-suggestion-session-header.md` 为发给宿主的改造提案归档(暂不提交上游)。
170
+
165
171
  ### 1.1.10(2026-11-27)
166
172
 
167
173
  - **修「截图 Ctrl+V 粘不进当前栏,或者粘到别的栏」**:多栏把宿主的 `main` 槽整条换成自己的面板后,全页没有按 `occurrence === "main"` 渲染的 composer;宿主的 document 层粘贴路由只认两种人——「最近持有过焦点的 composer」或「`main` 那一个」。于是光标不在输入框里时,截图会落进**上一次点过的那个栏**,或者谁都不认、直接丢弃(光标在输入框里时走编辑器自己的粘贴命令,一切正常,所以这个毛病看起来时好时坏,关掉插件就消失)。
package/lib/client.js CHANGED
@@ -1,4 +1,4 @@
1
- window.__ModuleLoader__.load({
1
+ window.__ModuleLoader__.load({
2
2
  id: "dsh-multipane",
3
3
  factory: (require) => {
4
4
  var module = { exports: {} };
@@ -19,7 +19,7 @@ window.__ModuleLoader__.load({
19
19
  */
20
20
  const PLUGIN_LABEL = "多栏视图";
21
21
  /* 与 package.json 的 version 必须一致(发版时两处同改;check-names.cjs 会校验)。 */
22
- const PLUGIN_VERSION = "1.1.10";
22
+ const PLUGIN_VERSION = "1.1.11";
23
23
  const NPM_LATEST_URL = "https://registry.npmjs.org/dsh-multipane/latest";
24
24
 
25
25
 
@@ -1737,6 +1737,58 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
1737
1737
  } catch {
1738
1738
  /* 忽略 */
1739
1739
  }
1740
+ }
1741
+
1742
+ /**
1743
+ * 切到全局面板(插件页 / 设置页等)时隐藏右栏,切回会话视图恢复。
1744
+ *
1745
+ * 背景(真机实测 2026-12-03):宿主右栏轨道(.mP3x-q_rightbarCol)在
1746
+ * `syncPresentation({shown:false})` 后把列宽收成 0,但已安装的
1747
+ * dsh-better-sidebar 的「开始」等 keepMounted 面板是 **absolute 定位**、
1748
+ * 固定 576px 宽,不跟随轨道收缩 —— 于是插件页上残留「占位还在、
1749
+ * 内容没了、顶部 tab 按钮还在但不可点」的壳(Issue #1 症状 A 的
1750
+ * 真实形态)。宿主原生 tab(对话/轨迹/标卡/上下文/编队)会自己卸载,
1751
+ * 唯独 keepMounted 面板不清场。
1752
+ *
1753
+ * 这里只动**视觉层**:visibility + pointer-events,不卸载 DOM、不动
1754
+ * better-sidebar 的 keepMounted 状态(切回会话后它会原样恢复,
1755
+ * 上次打开的 tab 还在)。不要用 display:none —— 那会改变几何,
1756
+ * 让宿主的 isExpanded() 误判为收起、把 store.expanded 写成 false,
1757
+ * 破坏「切回会话右栏还开着」的既有行为。
1758
+ */
1759
+ function syncRightbarVisibility() {
1760
+ try {
1761
+ const layout = SERVICES.layout ?? service("layout");
1762
+ SERVICES.layout = layout;
1763
+ if (layout === void 0 || layout.panelInfo === void 0) return;
1764
+ const active = layout.panelInfo.getSnapshot()?.activePanelId ?? null;
1765
+ const col = rightbarColumn();
1766
+ if (col === null) return;
1767
+ if (active === null) {
1768
+ /* 会话视图:恢复 */
1769
+ try { col.style.removeProperty("visibility"); } catch { /* 忽略 */ }
1770
+ try { col.style.removeProperty("pointer-events"); } catch { /* 忽略 */ }
1771
+ col.removeAttribute("data-dsv-rightbar-hidden");
1772
+ try { col.style.removeProperty("overflow"); } catch { /* 忽略 */ }
1773
+ try { col.style.removeProperty("opacity"); } catch { /* 忽略 */ }
1774
+ } else {
1775
+ /* 全局面板:隐藏(不止宿主原生壳,还有 keepMounted 面板)
1776
+ ⚠️ 必须加 overflow:hidden:better-sidebar 的 tab 条(iH70Mq_tabHost 系)
1777
+ 在自己 CSS 里显式写了 visibility:visible,后代声明覆盖祖先的 hidden
1778
+ 继承;而它是 absolute 定位、溢出已缩到 0 宽的 col 轨道渲染
1779
+ (面板钉在 x=704 宽 576,col 已移到 x=1280 宽 0)。
1780
+ overflow:hidden 在 col 上会把所有溢出容器的内容直接裁掉,
1781
+ 无论 better-sidebar 怎么覆盖 visibility。展开时 col 宽 576,
1782
+ 内容正好放下,不会裁到正常内容。 */
1783
+ try { col.style.setProperty("overflow", "hidden", "important"); } catch { /* 忽略 */ }
1784
+ try { col.style.setProperty("opacity", "0", "important"); } catch { /* 忽略 */ }
1785
+ try { col.style.setProperty("visibility", "hidden", "important"); } catch { /* 忽略 */ }
1786
+ try { col.style.setProperty("pointer-events", "none", "important"); } catch { /* 忽略 */ }
1787
+ col.setAttribute("data-dsv-rightbar-hidden", "1");
1788
+ }
1789
+ } catch {
1790
+ /* 忽略 */
1791
+ }
1740
1792
  }
1741
1793
  syncSettingsFlag();
1742
1794
  prefs.subscribe(syncSettingsFlag);
@@ -2557,6 +2609,14 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
2557
2609
  /* 会话标题:宿主 lineage 槽渲染不出内容时的兜底(也是正常时期的唯一标题来源)。 */
2558
2610
  .dsv-hostbar-title{font-size:13px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;max-width:260px;opacity:.95}
2559
2611
  .dsv-hostbar [data-slot-place="corner"]{margin-left:2px}
2612
+ /* 「更多操作」按钮(contextMenu.button 工厂画的):对齐宿主自己的 headerMenuButton ——
2613
+ 宿主那条规则是 width:28px / padding:0 / 15px 图标 / color:label-secondary。
2614
+ 不写这段的话它会套用 .dsv-btn 的 20px 高、opacity:.6、font-size:14,看起来比
2615
+ 宿主原版小一圈、也更灰。这里只覆盖尺寸与颜色,不动 .dsv-btn 的交互属性
2616
+ (app-region:no-drag 等仍需保留,否则窗口拖动区会把它吃掉)。 */
2617
+ .dsv-hostbar .dsv-hostbar-menu{width:28px;height:28px;padding:0;opacity:1;font-size:15px;color:var(--dsw-alias-label-secondary,inherit);border-radius:6px}
2618
+ .dsv-hostbar .dsv-hostbar-menu svg{width:15px;height:15px}
2619
+ .dsv-hostbar .dsv-hostbar-menu:hover{background:var(--dsh-hover-bg,rgba(128,128,128,.16))}
2560
2620
  /* ⚠️ 右栏开关常驻:**绝对定位到本栏右上角**,脱离 flex 流。
2561
2621
  原因(2026-11-08 实测):右侧按钮组是 flex:0 0 auto,不会压缩;
2562
2622
  某个栏窄下来时它的内容宽度可以超过整条 hostbar(实测 pane 宽 407,
@@ -4276,6 +4336,14 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
4276
4336
  * the 对话·轨迹·上下文·编队 tab strip. Rendering `conversation.session.header`
4277
4337
  * inside the pane's session scope is what keeps those other plugins working
4278
4338
  * in every pane and every tab; without it a pane loses them entirely.
4339
+ *
4340
+ * ⚠️ 目前**没有调用点**。2026-12-02 实测(0.2.2-rc.1):即使把它挂进
4341
+ * `SessionProvider` 子树,组件也只渲染出一个空 div(height 0、零个视图标签)。
4342
+ * 原因:`conversation.session.header` 条目的 owner props(useConversationViews /
4343
+ * useStore / selectView / setPinned …)是宿主按**条目契约**注入的,不在
4344
+ * HOST_SLOT_PROPS 里,外部拿不到;详见 ISSUE-session-scope.md 的 route 3。
4345
+ * 也就是说 Issue #2 的「缺少会话头」不是漏挂,而是宿主契约不允许,
4346
+ * 需要在宿主侧给非 Conversation 面板一个会话作用域入口才能根治。
4279
4347
  */
4280
4348
  function SessionHead(props) {
4281
4349
  const { sessionId } = props;
@@ -5566,6 +5634,9 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
5566
5634
  showChrome: true,
5567
5635
  sessions,
5568
5636
  SessionProvider,
5637
+ /* 「更多操作」(⋯)的宿主工厂:宿主 ConversationRoot 把它内联画在 headerUtilities 里,
5638
+ 我们用 key=conversation 接管 main 后那棵树不再渲染,需要在这里补画一次。 */
5639
+ renderFactorySlot,
5569
5640
  /* top 模式的切换条交给 HostBar 内部渲染,才能和标题/标准模式/子智能体
5570
5641
  排在同一行;放不下由 HostBar 自己换行。没有 HostBar 时退化成一整行。 */
5571
5642
  viewBar:
@@ -6384,11 +6455,11 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
6384
6455
  而不少按钮的 onClick 第一行就是 `if (!isCurrent()) return;`
6385
6456
  (实测 context-diagnostics 正是如此),于是按钮画得出来、点了完全没反应。
6386
6457
  从用户角度看,这一栏就是在看这个会话,判定它「当前」是合理的。 */
6387
- /* 右侧栏的 ExpandButton 只调 actions.setExpanded(改它自己的 store),
6388
- 但真正撑开右栏列的是 shell 的 layout.panels.openRightbar(track, fullscreen)。
6389
- ⚠️ track 必须传,传 undefined 时 rightbarTrack 为 falsy,列宽直接被算成 0
6390
- —— 实测「按钮点了没反应」就是这个:状态改了,栏还是 0 宽。
6391
- 这里把 actions 包一层:调 setExpanded 的同时打开右栏。 */
6458
+ /* 宿主注入的 actions.setExpanded 写的就是**这个会话自己的 store**,
6459
+ 所以它本身已经是对的:store 一改,宿主的 syncPresentation 就跟着
6460
+ 撑开/收起列宽。这里不再额外调 layout.openRightbar —— 那是第二套状态,
6461
+ 两边各写一次正是「列宽开了、store 说是关的」「下一次 sync 又压回 0」
6462
+ 的成因。只把异常收在一格里,免得一个第三方按钮的参数错误把整栏带走。 */
6392
6463
  if (propsForComponent.actions !== void 0 && typeof propsForComponent.actions === "object") {
6393
6464
  const inner = propsForComponent.actions;
6394
6465
  if (typeof inner.setExpanded === "function") {
@@ -6400,12 +6471,6 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
6400
6471
  } catch (error) {
6401
6472
  console.warn("[split-view] setExpanded 失败:", error);
6402
6473
  }
6403
- try {
6404
- if (value === true) openRightbarCompat(true, false);
6405
- else closeRightbarCompat();
6406
- } catch (error) {
6407
- console.warn("[split-view] 右侧栏开合失败:", error);
6408
- }
6409
6474
  }
6410
6475
  };
6411
6476
  }
@@ -6456,41 +6521,20 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
6456
6521
 
6457
6522
  /* 外面包一层带 id 的容器:出错时能看出是谁,CSS 也能按条目单独调。
6458
6523
  注意必须是 inline-flex 且不改变高度,否则会把 header 拉伸。 */
6459
- /* 上下文诊断这类条目:点下去它会去开右栏 tab,但它只改
6460
- sidebarRight store 的 expanded,**不动 layout 的列宽**。
6461
- 实测结果就是「诊断跑完了、内容也生成了,但右栏列宽 0,
6462
- 面板挤在 0 宽轨道里」→ 用户看到空白。
6463
- 这里在捕获阶段先替它把列宽打开,它后续聚焦 tab 才有地方显示。
6464
- —— 只影响这一个条目,不引入全局同步(全局同步会和宿主的
6465
- syncPresentation 互相覆盖,试过两次都不稳)。 */
6524
+ /* 上下文诊断这类条目:点下去它会去开右栏 tab。它内部按会话做事
6525
+ (request.target.sessionId),并且会自己调 workspace.openSession 把
6526
+ 主视图切过去、再等 sidebarRight.mounted 变成那个会话 —— 所以我们
6527
+ 只需要把**这一栏会话的 store 展开状态**提前写好:store 一变,
6528
+ 宿主的 syncPresentation 就把列宽撑开,诊断的 tab 一生成就有地方显示。
6529
+ 不再单独调 layout.openRightbar:那是第二套状态,两边各写一次会打架。 */
6466
6530
  const needsRightbar = item.entry.options !== void 0 && item.entry.options !== null && item.entry.options.id === "dsh-better-sidebar:context-diagnostics";
6467
6531
  const preOpen = needsRightbar
6468
6532
  ? {
6469
6533
  onClickCapture: () => {
6470
- /* 两件事都要做,缺任何一件诊断都会超时:
6471
- *
6472
- * ① 把宿主「当前会话」切到本栏会话。
6473
- * 上下文诊断内部第一行就是
6474
- * if (right.mounted.getSnapshot() !== request.target.sessionId) return;
6475
- * mounted 来自宿主的「在屏会话」,而多栏下它只认
6476
- * uiSession.adapter.current —— 和我们这一栏的会话没关系。
6477
- * 实测某次启动:mounted=2026f703,两栏分别是 87b7d793 /
6478
- * ad6509d2,**三个都不是同一个**,所以不管点哪栏都超时。
6479
- * replaceMain 是唯一能改它的公开路径(实测 mounted 立刻跟着变)。
6480
- *
6481
- * ② 把右栏列宽打开。诊断只改 store 的 expanded,不动
6482
- * layout 的 track;列宽 0 时面板挤在 0 宽轨道里 → 空白。
6483
- */
6484
6534
  try {
6485
- /* 0.2.2 用 replaceMain,0.2.3 已删(兼容层里自动选路)。 */
6486
- openMainCompat(sessionId);
6535
+ openRightbarFor(sessionId);
6487
6536
  } catch (error) {
6488
- console.warn("[split-view] 诊断前切会话失败:", error);
6489
- }
6490
- try {
6491
- openRightbarCompat(true, false);
6492
- } catch (error) {
6493
- console.warn("[split-view] 诊断前开右栏失败:", error);
6537
+ console.warn("[split-view] 诊断前展开右栏失败:", error);
6494
6538
  }
6495
6539
  }
6496
6540
  }
@@ -6606,6 +6650,205 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
6606
6650
  * · 开:layout.panels.openRightbar(true,false) → 右列 minmax(0px, Npx)
6607
6651
  * 方向按**实际列宽**判断,不信任何 store。状态也从实际列宽读。
6608
6652
  */
6653
+ /**
6654
+ * 右栏列(真正占宽度的那一格)。
6655
+ *
6656
+ * ⚠️ 不要只认哈希类名(`.mP3x-q_rightbarCol` 之流):它是 CSS Modules 的
6657
+ * **构建产物**,由**分发通道**的构建决定,与版本号无关 —— 实测:
6658
+ * · npm 包(web / CLI 宿主,0.2.2-rc.5 与 0.2.3-alpha.2 都一样)→ `pI_x6G_`
6659
+ * · 桌面版 app.asar(0.2.2-rc.5 / 0.2.3-alpha.2)→ `mP3x-q_`
6660
+ * 拿它当唯一判据,换一条通道跑就可能对不上,依赖它的逻辑会静默退化。
6661
+ *
6662
+ * 稳定判据是宿主自己挂的 `data-rightbar-col` 属性 —— AppFrame 的
6663
+ * RightbarColumn 无条件输出,0.2.2-rc.1 / 0.2.2-rc.5 / 0.2.3-alpha.2
6664
+ * 实测都有(桌面版 asar 里命中 4 次)。哈希类名只保留为极旧宿主的兜底。
6665
+ *
6666
+ * 这样包一层还有一个好处:列选择只剩这一个入口,宿主以后换 DOM 时
6667
+ * 只改这一处即可,不会像以前那样在 4 个地方各写一串哈希。
6668
+ */
6669
+ function rightbarColumn() {
6670
+ try {
6671
+ const stable = document.querySelector("[data-rightbar-col]");
6672
+ if (stable !== null) return stable;
6673
+ return document.querySelector(".mP3x-q_rightbarCol");
6674
+ } catch {
6675
+ return null;
6676
+ }
6677
+ }
6678
+
6679
+ /**
6680
+ * 右栏现在是不是**真的看得见**:以列宽为准,列不存在时才退回 store。
6681
+ *
6682
+ * ⚠️ 不能反过来。`sidebarRight.isExpanded()` 读的是 `mountedSurface()`,
6683
+ * 也就是**宿主主视图那个会话的挂载面**;多栏视图下主视图被本插件替换,
6684
+ * 本栏的会话往往压根没有挂载面 → 它恒返回 false。此时列宽明明是 707,
6685
+ * measure() 却判「没开」,点收起就被算成打开,又把它顶开:
6686
+ * 这正是 Issue #1 里「右栏关不掉」的那条路径。
6687
+ *
6688
+ * 所以顺序固定为:先量实际列宽(唯一的事实),列不在时才问 store。
6689
+ * 列不存在(老宿主 / 右栏还未渲染)时行为与改前完全等价。
6690
+ */
6691
+ function rightbarVisible() {
6692
+ try {
6693
+ const col = rightbarColumn();
6694
+ if (col !== null) return col.getBoundingClientRect().width > 1;
6695
+ const right = SERVICES.ctx?.get?.("sidebarRight");
6696
+ return right !== null && right !== void 0 && typeof right.isExpanded === "function" && right.isExpanded() === true;
6697
+ } catch {
6698
+ return false;
6699
+ }
6700
+ }
6701
+
6702
+ /** 右栏控制器(`ctx.sidebarRight`);拿不到就是 null。 */
6703
+ function rightbarController() {
6704
+ try {
6705
+ return SERVICES.ctx?.get?.("sidebarRight") ?? null;
6706
+ } catch {
6707
+ return null;
6708
+ }
6709
+ }
6710
+
6711
+ /**
6712
+ * 读**某个会话自己**的右栏是否展开。
6713
+ *
6714
+ * 宿主把 expanded 记在每个会话的 store 里(`bySession[sid].layout.expanded`),
6715
+ * 而 `controller.isExpanded()` 读的是 `mountedSurface()` —— 也就是**宿主主视图
6716
+ * 那个会话**的挂载面。多栏视图下主视图被本插件替换,本栏会话往往没有挂载面,
6717
+ * 它恒返回 false。所以每栏必须问自己的会话,不能问控制器。
6718
+ *
6719
+ * @param sessionId - 这一栏的会话 id。
6720
+ * @returns 展开为 true;该会话的 store 还没 mint 时返回 false(**不回退**)。
6721
+ */
6722
+ function isRightbarExpandedFor(sessionId) {
6723
+ if (typeof sessionId !== "string" || sessionId === "") return false;
6724
+ const right = rightbarController();
6725
+ if (right === null) return false;
6726
+ try {
6727
+ const surface = right.adopted?.get?.(sessionId)?.store?.getSnapshot?.()?.bySession?.[sessionId];
6728
+ /* 没有这个会话的 surface = 这一栏的会话还没被 seat 挂载,它的右栏必然是收起的。
6729
+ **不要**回退到 controller.isExpanded():那读的是另一个会话的状态,会把
6730
+ 「别人开着」误报成本栏开着,用户点一下反而去关了别人的右栏。 */
6731
+ if (surface === void 0) return false;
6732
+ return surface.layout.expanded === true;
6733
+ } catch {
6734
+ return false;
6735
+ }
6736
+ }
6737
+
6738
+ /**
6739
+ * 把「展开/收起」写进**某个会话自己的 store**。这是唯一正确的写入口。
6740
+ *
6741
+ * 只调 `layout.openRightbar()` 是在改列宽轨道,不改 store;宿主下一次
6742
+ * `syncPresentation`(由该会话 seat 的 useLayoutEffect 驱动)读到
6743
+ * `expanded === false`,就把轨道重新压成 0 —— 这正是
6744
+ * 「诊断跑完、内容都在、列宽却是 0」的成因。写 store 则相反:宿主自己会按
6745
+ * store 撑开轨道,两边是同一个状态源,不会再打架。
6746
+ *
6747
+ * @param sessionId - 要写的会话。
6748
+ * @param expanded - true 展开 / false 收起。
6749
+ * @returns 写成功 true;该会话的 store 还没 mint(seat 没挂载)时 false。
6750
+ */
6751
+ function writeRightbarExpanded(sessionId, expanded) {
6752
+ if (typeof sessionId !== "string" || sessionId === "") return false;
6753
+ const right = rightbarController();
6754
+ if (right === null) return false;
6755
+ let actions = null;
6756
+ try {
6757
+ actions = right.adopted?.get?.(sessionId)?.store?.actions ?? null;
6758
+ } catch {
6759
+ actions = null;
6760
+ }
6761
+ if (actions === null || typeof actions.setExpanded !== "function") return false;
6762
+ try {
6763
+ actions.setExpanded(sessionId, expanded === true);
6764
+ return true;
6765
+ } catch (error) {
6766
+ console.warn("[split-view] 写右栏展开状态失败:", error);
6767
+ return false;
6768
+ }
6769
+ }
6770
+
6771
+ /**
6772
+ * 打开某一栏的右侧边栏。
6773
+ *
6774
+ * 顺序是「先写状态,后撑轨道」:
6775
+ * · 该会话的 store 已经 mint(seat 在屏幕上)→ 只写 expanded=true,
6776
+ * 宿主的 syncPresentation 自己会把列宽撑开,不需要碰 layout;
6777
+ * · 还没 mint(这一栏不是宿主主视图那个会话)→ 先用公开的
6778
+ * `uiWorkspace.openSession` 把主视图切过去,等 `mounted` 变成它,
6779
+ * 它的 seat 随之挂载、store 随之 mint,再写 expanded。
6780
+ *
6781
+ * 等待是**事件驱动**的(订阅 mounted,命中一次就收手),外加一个 600ms 的
6782
+ * 一次性兜底 —— 只在用户主动开右栏时启动,绝不常驻、不反复重试。
6783
+ *
6784
+ * @param sessionId - 这一栏的会话 id。
6785
+ * @returns 立即写成功 true;需要等挂载也返回 true;完全没有会话 false。
6786
+ */
6787
+ function openRightbarFor(sessionId) {
6788
+ if (typeof sessionId !== "string" || sessionId === "") return false;
6789
+ if (writeRightbarExpanded(sessionId, true) === true) return true;
6790
+ const right = rightbarController();
6791
+ /* 先把宿主主视图切到该会话:它的 seat 只有在成为「在屏会话」时才会被渲染,
6792
+ 而 store 恰好是在那个 seat 渲染时 mint 的。 */
6793
+ openMainCompat(sessionId);
6794
+ if (right === null || typeof right.mounted?.subscribe !== "function") {
6795
+ /* 连 mounted 都拿不到:退一步只开轨道,至少这一帧看得见。 */
6796
+ openRightbarCompat(true, false);
6797
+ return false;
6798
+ }
6799
+ let settled = false;
6800
+ let unsubscribe = null;
6801
+ const settle = () => {
6802
+ if (settled === true) return;
6803
+ settled = true;
6804
+ try {
6805
+ unsubscribe?.();
6806
+ } catch {
6807
+ /* 忽略 */
6808
+ }
6809
+ if (writeRightbarExpanded(sessionId, true) === true) return;
6810
+ /* seat 还没 mint 出 store(极窄的时序窗口):只开轨道,下一次它挂载后的
6811
+ syncPresentation 会按 store 自行校正。 */
6812
+ openRightbarCompat(true, false);
6813
+ };
6814
+ try {
6815
+ unsubscribe = right.mounted.subscribe(() => {
6816
+ let mounted = void 0;
6817
+ try {
6818
+ mounted = right.mounted.getSnapshot();
6819
+ } catch {
6820
+ mounted = void 0;
6821
+ }
6822
+ if (mounted === sessionId) settle();
6823
+ });
6824
+ } catch {
6825
+ unsubscribe = null;
6826
+ }
6827
+ /* 一次性兜底,不是常驻轮询:600ms 还没挂上就收手。 */
6828
+ window.setTimeout(settle, 600);
6829
+ return true;
6830
+ }
6831
+
6832
+ /** 收起某一栏的右侧边栏;写不进 store 才退回只收轨道。 */
6833
+ function closeRightbarFor(sessionId) {
6834
+ if (writeRightbarExpanded(sessionId, false) === true) return true;
6835
+ return closeRightbarCompat();
6836
+ }
6837
+
6838
+
6839
+ /**
6840
+ * 宿主现在是不是停在**会话视图**(而不是插件页 / 插件设置页这类全局面板)。
6841
+ *
6842
+ * 判据与宿主 ui-sidebar-right 自己用的完全一致:
6843
+ * const visible = usePanelInfo(info => info.activePanelId === null)
6844
+ * 即 `activePanelId === null` = 会话视图,非 null = 全局面板。
6845
+ * 这个字段在 0.2.2-rc.1 起的 layout.panelInfo 里就有(ILayout.panelInfo),
6846
+ * 不是 0.2.3 独有;本插件 `mirrorSettingsFromPanel()` 也早就读它。
6847
+ *
6848
+ * 拿不到 panelInfo(更老的宿主 / 服务还没起来)时返回 true —— 保持原来的补开行为,
6849
+ * 宁可多补一次,也不要在会话视图里把功能关掉。
6850
+ */
6851
+
6609
6852
  /**
6610
6853
  * 右栏「该开却没开」的兜底(**单向,只补开**)。
6611
6854
  *
@@ -6620,43 +6863,46 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
6620
6863
  * 这里只处理一种情况:**store 说已展开,但列宽是 0** → 补一次 openRightbar。
6621
6864
  * 绝不处理反方向(store 说收起时不去关),所以不会和宿主的收起逻辑打架,
6622
6865
  * 也不会把正在进行的过渡动画拉回去。
6866
+ *
6867
+ * ⚠️ 只在**会话视图**里补开(Issue #1 症状 A,2026-11-16 Free-LZJ / 2026-11-20 niiii555)。
6868
+ * 切到全局面板(插件页 / 插件设置页)时,宿主 RightbarSeat 的 active 变 false,
6869
+ * `syncPresentation({shown:false})` 把右列收成 0。只要 sidebarRight 里
6870
+ * per-session 的 `expanded` 仍为 true(宿主有意保留,切回会话还要开着),
6871
+ * 「store 说展开、列宽却是 0」就会命中这段兜底 → 每 900ms 把右栏顶回来,
6872
+ * 表现就是「全局面板下右栏仍占右列、中间面板被挤到左半」。
6873
+ *
6874
+ * 关于复现的边界(重要,别以后再重新踩一遍):本轮两代宿主(0.2.2-rc.1 /
6875
+ * rc.5 / 0.2.3-alpha.2,npm 与桌面版 asar 都查过)的 RightbarSeat 都是
6876
+ * `shown = active && layout.expanded`、`active = usePanelInfo(info =>
6877
+ * info.activePanelId === null)`,切到全局面板时 `active` 变 false,
6878
+ * `isExpanded()` 也跟着返回 false,兜底的第一道就 return 了 —— 因此本机
6879
+ * 三个宿主采样都没看到回弹。这不等于症状 A 不存在:报告人环境(Windows
6880
+ * 桌面版 0.2.2-rc.1)里选择器是命中的,兜底是活的,只是本地无法重现
6881
+ * 「expanded 仍为 true」那个前置条件。所以这道判断是**按报告人机制写的
6882
+ * 防御**,不能因为本机阴性就删。
6623
6883
  */
6624
- function startRightbarKeepOpen() {
6625
- setInterval(() => {
6626
- try {
6627
- const right = SERVICES.ctx?.get?.("sidebarRight");
6628
- const panels = layoutPanels();
6629
- if (right === void 0 || right === null || panels === void 0 || panels === null) return;
6630
- /* 插件关掉后不再干预宿主的右栏 —— 它自己会管开合。 */
6631
- if (prefs.state.enabled !== true) return;
6632
- if (typeof right.isExpanded !== "function" || right.isExpanded() !== true) return;
6633
- const col = document.querySelector(".mP3x-q_rightbarCol");
6634
- if (col === null) return;
6635
- if (col.getBoundingClientRect().width > 1) return;
6636
- openRightbarCompat(true, false);
6637
- } catch {
6638
- /* 忽略 */
6639
- }
6640
- }, 900);
6641
- }
6642
6884
 
6643
- function RightbarToggle() {
6885
+ /**
6886
+ * 右侧边栏开关(自绘)。
6887
+ *
6888
+ * 宿主原生的 ExpandButton 不能用:它读的 per-session store 与
6889
+ * sidebarRight 控制器写的不是同一实例,展开后 expanded 卡在 true
6890
+ * 不回落,于是「收起之后按钮永久消失」。
6891
+ *
6892
+ * 状态与写入都落在**这一栏自己的会话**的 store 上(见 isRightbarExpandedFor /
6893
+ * openRightbarFor)。宿主的两套东西 —— store 的 layout.expanded 和 layout 的
6894
+ * rightbarTrack —— 从此只有一个真源:store。列宽由宿主的 syncPresentation
6895
+ * 跟着 store 走,不再手动拉轨道,也就不会出现「列宽开了、store 说是关的」
6896
+ * 这种两边打架、下一次 sync 又把列宽压回 0 的局面。
6897
+ *
6898
+ * 按钮的长相(图标 / label / aria-pressed)仍由 rightbarVisible() 的实测列宽
6899
+ * 决定 —— 那是主人已在台式机上验收过的行为,这里一行不动。
6900
+ */
6901
+ function RightbarToggle(props) {
6902
+ const sessionId = props !== void 0 && props !== null && typeof props.sessionId === "string" ? props.sessionId : null;
6644
6903
  const [open, setOpen] = react.useState(false);
6645
6904
  const measure = react.useCallback(() => {
6646
- let next = false;
6647
- try {
6648
- /* 优先问 sidebarRight 控制器:0.2.3 的 isExpanded() 读的是真实挂载面,
6649
- 比找那串随构建变化的哈希类名(.mP3x-q_rightbarCol)可靠。 */
6650
- const right = SERVICES.ctx?.get?.("sidebarRight");
6651
- if (right !== null && right !== void 0 && typeof right.isExpanded === "function") {
6652
- next = right.isExpanded() === true;
6653
- } else {
6654
- const col = document.querySelector(".mP3x-q_rightbarCol");
6655
- next = col !== null && col.getBoundingClientRect().width > 1;
6656
- }
6657
- } catch {
6658
- next = false;
6659
- }
6905
+ const next = rightbarVisible();
6660
6906
  setOpen((prev) => (prev === next ? prev : next));
6661
6907
  return next;
6662
6908
  }, []);
@@ -6687,51 +6933,22 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
6687
6933
  ⚠️ 1.0.58 我一度把点击转交给 0.2.3 新增的「会话面板」开关(栏头那颗
6688
6934
  三横线)。用户实测:点最右这颗,结果去折叠了别的东西 —— 两个面板
6689
6935
  不是一回事(会话面板是浮在对话区右侧的小卡片,右侧边栏是带页签的栏)。
6690
- 这里回到正路:store 的 toggleExpanded 管状态,layout 的
6691
- open/closeRightbar 管列宽轨道;两代接口由兼容层选路。 */
6936
+ 这里回到正路:状态写 store,列宽交给宿主的 syncPresentation。 */
6692
6937
  const isOpen = measure();
6693
6938
  const next = !isOpen;
6694
- const right = (() => {
6695
- try {
6696
- return SERVICES.ctx?.get?.("sidebarRight");
6697
- } catch {
6698
- return void 0;
6699
- }
6700
- })();
6701
- const canToggle = right !== null && right !== void 0 && typeof right.isExpanded === "function" && typeof right.toggleExpanded === "function";
6702
- /* ⚠️ 0.2.3 的顺序坑(用户实测「第一次点只有宽度、里面空白,要点第二次」):
6703
- toggleExpanded() 内部用的是 mountedSurface(),右栏还没展开、没有挂载面时
6704
- 它直接空转。所以开要「先撑轨道、再补状态」,关要「先切状态、再收轨道」。 */
6705
- if (next === true) {
6706
- openRightbarCompat(true, false);
6707
- if (canToggle === true) {
6708
- let tries = 0;
6709
- const ensure = () => {
6710
- tries += 1;
6711
- try {
6712
- if (right.isExpanded() !== true) right.toggleExpanded();
6713
- if (right.isExpanded() === true) return;
6714
- } catch {
6715
- /* 忽略 */
6716
- }
6717
- if (tries < 10) window.setTimeout(ensure, 60);
6718
- };
6719
- window.setTimeout(ensure, 30);
6720
- }
6939
+ if (sessionId !== null) {
6940
+ if (next === true) openRightbarFor(sessionId);
6941
+ else closeRightbarFor(sessionId);
6721
6942
  } else {
6722
- if (canToggle === true) {
6723
- try {
6724
- right.toggleExpanded();
6725
- } catch (error) {
6726
- console.warn("[split-view] 右栏收起失败:", error);
6727
- }
6728
- }
6729
- closeRightbarCompat();
6943
+ /* 拿不到会话 id(空白标签 / 宿主还没给)时的旧路径:只驱动轨道。 */
6944
+ if (next === true) openRightbarCompat(true, false);
6945
+ else closeRightbarCompat();
6730
6946
  }
6731
- if (canToggle !== true && layoutPanels() === null) return;
6732
6947
  setOpen(next);
6733
6948
  window.setTimeout(measure, 500);
6734
6949
  window.setTimeout(measure, 1400);
6950
+ /* 要等主视图切过去那一档(约 300ms)再补测一次。 */
6951
+ window.setTimeout(measure, 2200);
6735
6952
  }
6736
6953
  },
6737
6954
  h(
@@ -6747,7 +6964,7 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
6747
6964
  },
6748
6965
  h("use", { href: "#dsw-icon-panel-left-outline-regular" })
6749
6966
  )
6750
- );
6967
+ );
6751
6968
  }
6752
6969
 
6753
6970
  /**
@@ -6908,7 +7125,7 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
6908
7125
  }
6909
7126
 
6910
7127
  function HostBar(props) {
6911
- const { sessionId, showChrome, sessions, SessionProvider, viewBar, rightAvail, onRightNeed } = props;
7128
+ const { sessionId, showChrome, sessions, SessionProvider, viewBar, rightAvail, onRightNeed, renderFactorySlot } = props;
6912
7129
  const hostBarRef = react.useRef(null);
6913
7130
  const rightRef = react.useRef(null);
6914
7131
  react.useEffect(() => {
@@ -6938,6 +7155,11 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
6938
7155
  h(
6939
7156
  "div",
6940
7157
  { className: "dsv-hostbar-left" },
7158
+ /* lineage(子智能体面包屑):宿主父组件会传 lineageSessionId/displayTitle,
7159
+ 我们同样能从会话列表算出来(本级 = 自己)。层级信息只有宿主内部才有,
7160
+ 所以子智能体那一路仍会自己判定不画;普通会话显示自己的名字。
7161
+ ⚠️ 宿主会话头(对话/轨迹/上下文 视图条)**不在这里**,它需要
7162
+ 宿主按条目契约注入 owner props,外部挂不上去(见 SessionHead 注释)。 */
6941
7163
  h(SlotList, {
6942
7164
  slotName: "conversation.session.header.lineage",
6943
7165
  sessionId,
@@ -6960,7 +7182,38 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
6960
7182
  "div",
6961
7183
  { className: "dsv-hostbar-right", ref: rightRef },
6962
7184
  h(SlotList, { slotName: "conversation.session.header.actions", sessionId, className: "dsv-slotrow", place: "actions" }),
6963
- h(SlotList, { slotName: "conversation.session.header.utilities", sessionId, className: "dsv-slotrow", place: "utilities" })
7185
+ h(SlotList, { slotName: "conversation.session.header.utilities", sessionId, className: "dsv-slotrow", place: "utilities" }),
7186
+ /* 「更多操作」(⋯)—— 宿主把它画在 headerUtilities 里、utilities 槽之后,
7187
+ 是**内联工厂**而不是槽条目:
7188
+ <div class=headerUtilities>
7189
+ {renderSlot('conversation.session.header.utilities', {})}
7190
+ {renderFactorySlot('contextMenu.button', { target:{kind:'sessionHeader',
7191
+ value:{sessionId}}, label: t('header.more'), className: …headerMenuButton, size:'sm' })}
7192
+ </div>
7193
+ 我们用 key=conversation / priority=-1 接管 main 后整棵 ConversationRoot 不再渲染,
7194
+ 这颗按钮就跟着丢了(用户报「开了插件就没⋯」)。这里按同样的参数补画一次。
7195
+ 宿主那个 factory 自己会在「target.kind 没有任何已注册贡献」时 return null
7196
+ (ContextMenuButton 第一行:useRegisteredKinds(kinds => kinds.includes(target.kind))),
7197
+ 所以不用我们判空,也不会有空按钮。
7198
+ ⚠️ 宿主那棵已经不在了,此处不会重复渲染出两颗。 */
7199
+ typeof renderFactorySlot === "function"
7200
+ ? h(
7201
+ /* 包一层带 data-slot-entry 的容器:折叠逻辑(CollapsedActions.collect)
7202
+ 只扫 [data-slot-entry] 来算「一行需要多宽」与决定谁被藏进本插件的「⋯」。
7203
+ 工厂自己只给按钮挂 data-context-menu-trigger,不包这一层就会漏算宽度,
7204
+ 窄栏时这颗按钮会把后面的东西顶出去。
7205
+ label 仍是「更多操作」,isHostMoreLabel() 会认出它并让它常驻可见
7206
+ ——这正是宿主那颗按钮原有的待遇(它的菜单要按锚点 rect 定位,藏着就点不开)。 */
7207
+ "div",
7208
+ { className: "dsv-slotitem", "data-slot-entry": "dsv:contextMenu.button", "data-slot-place": "menu" },
7209
+ renderFactorySlot("contextMenu.button", {
7210
+ target: { kind: "sessionHeader", value: { sessionId } },
7211
+ label: t("更多操作"),
7212
+ className: "dsv-btn dsv-hostbar-menu",
7213
+ size: "sm"
7214
+ })
7215
+ )
7216
+ : null
6964
7217
  ),
6965
7218
  /* corner 槽 = 「展开/收起右侧边栏」的座位(宿主文档原话:这个入口就是
6966
7219
  conversation header 里的 ExpandButton 那一个位置)。
@@ -6970,7 +7223,7 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
6970
7223
  ⚠️ 必须放在 .dsv-hostbar-right **外面**:按钮组会压缩、会裁自己的内容,
6971
7224
  放里面时这颗会被一起裁掉或和相邻按钮重叠(用户实测三个按钮叠在一起)。 */
6972
7225
  h(CollapsedActions, { key: "dsv-collapsed-actions", rightRef, availPx: rightAvail, onNeed: onRightNeed }),
6973
- h("div", { className: "dsv-slotrow", "data-slot-place": "corner" }, h(RightbarToggle, { key: "dsv-rightbar-toggle" }))
7226
+ h("div", { className: "dsv-slotrow", "data-slot-place": "corner" }, h(RightbarToggle, { key: "dsv-rightbar-toggle", sessionId }))
6974
7227
  );
6975
7228
  /* ⚠️ 必须包 SessionProvider:不少 header 组件(尤其是第三方的)
6976
7229
  在点击时读 React Context 拿「当前 session」,不在 provider 里就静默失效
@@ -9329,7 +9582,7 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
9329
9582
  st.done = focusKey;
9330
9583
  return;
9331
9584
  }
9332
- const col = document.querySelector(".mP3x-q_rightbarCol");
9585
+ const col = rightbarColumn();
9333
9586
  /* 优先问 sidebarRight:它才是右侧边栏的真正状态源。 */
9334
9587
  let wasOpen = false;
9335
9588
  try {
@@ -11378,8 +11631,9 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
11378
11631
  }
11379
11632
  })(),
11380
11633
  graph: (typeof window.__dsvGraph === "object" ? window.__dsvGraph : null),
11381
- rows,
11634
+ rows,
11382
11635
  overlays
11636
+ ,
11383
11637
  };
11384
11638
  } catch (error) {
11385
11639
  payload = { at: new Date().toISOString(), seq: sent, error: String((error && error.message) || error) };
@@ -12036,6 +12290,7 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
12036
12290
  stop = layout.panelInfo.subscribe(() => {
12037
12291
  check();
12038
12292
  mirrorSettingsFromPanel();
12293
+ syncRightbarVisibility();
12039
12294
  });
12040
12295
  }
12041
12296
  } catch {
@@ -12043,6 +12298,7 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
12043
12298
  }
12044
12299
  check();
12045
12300
  mirrorSettingsFromPanel();
12301
+ syncRightbarVisibility();
12046
12302
  return () => {
12047
12303
  disposed = true;
12048
12304
  if (timed !== null) clearInterval(timed);
@@ -12073,7 +12329,6 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
12073
12329
  };
12074
12330
  }, "dsh-split-view: one new session per pane");
12075
12331
 
12076
- startRightbarKeepOpen();
12077
12332
  startSidebarMarks();
12078
12333
  startHostWatchdog();
12079
12334
  activateWorkspace(ctx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
- {
1
+ {
2
2
  "name": "dsh-multipane",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "description": "Split the DSH main area into up to four panes, each with its own tab strip, composer and view switcher. Drag a tab to a pane edge to split. Bilingual (zh/en).",
5
5
  "displayName": "多栏视图",
6
6
  "dshhub": {