dsh-multipane 1.0.54 → 1.0.55

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.
package/README.en.md CHANGED
@@ -161,6 +161,11 @@ node scripts/check-names.cjs # package name / version / release-age allowanc
161
161
 
162
162
  ## Changelog
163
163
 
164
+ ### 1.0.55 (2026-11-22)
165
+
166
+ - **Fix duplicate New Session rows when the sidebar button is clicked repeatedly.** The sidebar New Session entry (and Ctrl+N) goes through the host's `uiWorkspace.startSession`. The 1.0.54 guard tried to install itself once at plugin load, but that host service often becomes available later, so the guard was never installed: each click really created or reused a blank session. The plugin did not open it as a tab, but the host still made it the current session, so another "New session" row appeared in the sidebar. The guard now retries until the service is ready (every 700ms, then stops), and when a new blank is merged into the pane's existing blank tab the host's main session is switched back to that existing blank as a second line of defence.
167
+ - Behaviour is unchanged: one new session per pane; prompt-carrying creations and the "close the last tab" replacement flow still create as before.
168
+
164
169
  ### 1.0.54 (2026-11-19)
165
170
 
166
171
  - **Fix "a new session open in another pane disappears from the sidebar".** DSH's session list only keeps the blank New Session row of the *current* main session; switching focus to another pane moves the host's main session, and the untouched new session in the first pane gets filtered out. Now, while a blank session is still open in any pane tab, the plugin projects it into the sidebar as an ordinary row (still titled "New session", with no timestamp or hover actions, and the right-click / double-click rename / drag interactions that native blank rows do not have stay disabled). Once it receives its first message, is closed, or the plugin is disabled, the native blank row returns. Only the display snapshot is touched — the host's session state, main selection and retention counts are left alone; the new-session page still uses its hero layout (composer centred), because the hero flag is computed from the true blank value rather than the projected row.
package/README.md CHANGED
@@ -160,6 +160,11 @@ node scripts/check-names.cjs # 包名 / 版本 / 冷却豁免三处是否一
160
160
 
161
161
  ## 更新记录
162
162
 
163
+ ### 1.0.55(2026-11-22)
164
+
165
+ - **修「连点新建会话,侧栏会多出新会话行」**:侧栏「新建会话」/ Ctrl+N 走的是宿主的 `uiWorkspace.startSession`。上一版的拦截在插件加载时只尝试安装一次,而宿主的这个服务经常晚于插件就绪,拦截没装上,于是每点一次宿主就真的新建/复用一个空白会话;插件虽然没给它开标签,宿主仍把它当成当前会话,侧栏就多出一行「新会话」。现在改为服务就绪后自动重试安装(每 700ms 一次,装好即停),并在「合并到本栏已有空白标签」时把宿主的主会话切回原有空白会话,双保险。
166
+ - 行为不变:每栏仍然最多一个新会话;带 prompt 的新建、「关掉唯一一栏的最后一个标签」的替换流程照常创建。
167
+
163
168
  ### 1.0.54(2026-11-19)
164
169
 
165
170
  - **修「新会话在别的栏里开着,侧栏却没了」**:DSH 的会话列表只保留「当前主会话」那一个空白新会话,插件把焦点切到另一栏时,宿主主会话跟着换,左栏那个还没发消息的新会话就被列表过滤掉了。现在只要空白新会话还开在任意一栏的标签里,插件就在显示层把它按普通行补回侧栏(标题仍是「新会话」,不显示时间与悬浮操作,右键 / 双击重命名 / 拖拽这些原生空白行没有的交互也保持关闭);它收到第一条消息、被关掉、或插件停用后立刻恢复原生行为。只改显示快照,不碰宿主的会话状态、主会话选择与保留计数;新会话页的 hero 布局(输入框居中)按真实 blank 计算,不会因为这次投影而沉底。
package/lib/client.js CHANGED
@@ -17,7 +17,7 @@ window.__ModuleLoader__.load({
17
17
  */
18
18
  const PLUGIN_LABEL = "多栏视图";
19
19
  /* 与 package.json 的 version 必须一致(发版时两处同改;check-names.cjs 会校验)。 */
20
- const PLUGIN_VERSION = "1.0.54";
20
+ const PLUGIN_VERSION = "1.0.55";
21
21
  const NPM_LATEST_URL = "https://registry.npmjs.org/dsh-multipane/latest";
22
22
 
23
23
 
@@ -1775,6 +1775,69 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
1775
1775
  return stored?.blank === true;
1776
1776
  }
1777
1777
 
1778
+ /* uiWorkspace.startSession 的拦截状态。BASE 保存宿主原始方法,
1779
+ 热更新后新模块会以 BASE 为底重新包一层,不会越包越深。 */
1780
+ const START_SESSION_MARK = Symbol.for("dsh-split-view.startSession-guarded");
1781
+ const START_SESSION_BASE = Symbol.for("dsh-split-view.startSession-base");
1782
+ let startSessionGuardOn = false;
1783
+
1784
+ /**
1785
+ * 装上「每栏最多一个新会话」的拦截。
1786
+ *
1787
+ * 返回 true = 已经装上(或本次装上)。宿主服务晚到时会返回 false,
1788
+ * 调用方下一拍再试。
1789
+ */
1790
+ function installStartSessionGuard() {
1791
+ if (startSessionGuardOn === true) return true;
1792
+ let uiWorkspace = null;
1793
+ try {
1794
+ uiWorkspace = SERVICES.ctx?.get?.("uiWorkspace") ?? null;
1795
+ } catch {
1796
+ uiWorkspace = null;
1797
+ }
1798
+ if (uiWorkspace === null || typeof uiWorkspace.startSession !== "function") return false;
1799
+ const base = uiWorkspace[START_SESSION_BASE] ?? uiWorkspace.startSession;
1800
+ uiWorkspace[START_SESSION_BASE] = base;
1801
+ uiWorkspace[START_SESSION_MARK] = true;
1802
+ uiWorkspace.startSession = function (workspaceId, options) {
1803
+ const plain = (workspaceId === void 0 || workspaceId === null)
1804
+ && (options === void 0 || options === null || (typeof options === "object" && Object.keys(options).length === 0));
1805
+ /* pendingReplace.on = 正在「关掉唯一一栏的最后一个标签、换成新会话」:
1806
+ 那次调用必须真的创建会话,不能被我换成「激活现有空白标签」,
1807
+ 否则关闭动作会静默失败。 */
1808
+ if (plain === true && pendingReplace.on !== true && typeof LIVE_APPLY === "function") {
1809
+ const state = window.__dsvState ?? readState();
1810
+ const tab = blankTabInPane(state?.focusPaneId ?? null);
1811
+ if (tab !== null) {
1812
+ const paneId = state?.focusPaneId ?? null;
1813
+ LIVE_APPLY((prev) => ({
1814
+ ...prev,
1815
+ focusPaneId: paneId ?? prev.focusPaneId,
1816
+ panes: prev.panes.map((pane) => (pane.id === (paneId ?? prev.focusPaneId) ? { ...pane, activeTabId: tab.id } : pane))
1817
+ }));
1818
+ return;
1819
+ }
1820
+ }
1821
+ return base.call(uiWorkspace, workspaceId, options);
1822
+ };
1823
+ startSessionGuardOn = true;
1824
+ return true;
1825
+ }
1826
+
1827
+ function uninstallStartSessionGuard() {
1828
+ if (startSessionGuardOn !== true) return;
1829
+ startSessionGuardOn = false;
1830
+ try {
1831
+ const uiWorkspace = SERVICES.ctx?.get?.("uiWorkspace") ?? null;
1832
+ if (uiWorkspace === null) return;
1833
+ const base = uiWorkspace[START_SESSION_BASE];
1834
+ if (typeof base === "function") uiWorkspace.startSession = base;
1835
+ delete uiWorkspace[START_SESSION_MARK];
1836
+ } catch {
1837
+ /* 忽略 */
1838
+ }
1839
+ }
1840
+
1778
1841
  /**
1779
1842
  * 某一栏里已经打开的空白新会话标签;没有返回 null。
1780
1843
  *
@@ -9061,6 +9124,22 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
9061
9124
  if (existing !== void 0) {
9062
9125
  const same = pane.tabs.find((tab) => tab.sessionId === sessionId);
9063
9126
  const target = same ?? existing;
9127
+ /* 宿主刚把 main 切到新建/复用的那个会话上;我们没给它开标签,
9128
+ 那一行会以「原生空白行」留在侧栏。把主会话切回本栏原有的
9129
+ 空白会话,那一行就会随宿主规则消失。 */
9130
+ const keepSession = target.sessionId;
9131
+ if (typeof keepSession === "string" && keepSession !== "") {
9132
+ window.setTimeout(() => {
9133
+ try {
9134
+ const workspace = SERVICES.ctx?.get?.("uiWorkspace");
9135
+ if (workspace !== void 0 && workspace !== null && typeof workspace.replaceMain === "function") {
9136
+ workspace.replaceMain(keepSession, new AbortController().signal, "preserve");
9137
+ }
9138
+ } catch {
9139
+ /* 忽略 */
9140
+ }
9141
+ }, 80);
9142
+ }
9064
9143
  return {
9065
9144
  ...prev,
9066
9145
  focusPaneId: pane.id,
@@ -10525,39 +10604,15 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
10525
10604
  与标签条「+」同一条规则(每栏最多一个新会话)。
10526
10605
  只拦「无参数 / 空 options」的普通新建;带 prompt 或指定 workspace
10527
10606
  的调用原样放行。 */
10607
+ /* 侧栏「新建会话」/ Ctrl+N 走的是宿主 uiWorkspace.startSession。
10608
+ 它可能比本插件晚就绪,所以不能在 apply 时只试一次 —— 装不上就一直重试
10609
+ (startSidebarMarks 每 700ms 会调一次 installStartSessionGuard)。 */
10528
10610
  ctx.effect(() => {
10529
- const uiWorkspace = SERVICES.ctx?.get?.("uiWorkspace");
10530
- if (uiWorkspace === void 0 || uiWorkspace === null || typeof uiWorkspace.startSession !== "function") return;
10531
- const MARK = Symbol.for("dsh-split-view.startSession-guarded");
10532
- if (uiWorkspace[MARK] === true) return;
10533
- const base = uiWorkspace.startSession;
10534
- uiWorkspace[MARK] = true;
10535
- uiWorkspace.startSession = function (workspaceId, options) {
10536
- const plain = (workspaceId === void 0 || workspaceId === null)
10537
- && (options === void 0 || options === null || (typeof options === "object" && Object.keys(options).length === 0));
10538
- /* pendingReplace.on = 正在「关掉唯一一栏的最后一个标签、换成新会话」:
10539
- 那次调用必须真的创建会话,不能被我换成「激活现有空白标签」,
10540
- 否则关闭动作会静默失败。 */
10541
- if (plain === true && pendingReplace.on !== true && typeof LIVE_APPLY === "function") {
10542
- const state = window.__dsvState ?? readState();
10543
- const tab = blankTabInPane(state?.focusPaneId ?? null);
10544
- if (tab !== null) {
10545
- LIVE_APPLY((prev) => ({
10546
- ...prev,
10547
- panes: prev.panes.map((pane) => (pane.id === prev.focusPaneId ? { ...pane, activeTabId: tab.id } : pane))
10548
- }));
10549
- return;
10550
- }
10551
- }
10552
- return base.call(uiWorkspace, workspaceId, options);
10553
- };
10611
+ installStartSessionGuard();
10612
+ const timer = setInterval(() => installStartSessionGuard(), 700);
10554
10613
  return () => {
10555
- try {
10556
- uiWorkspace.startSession = base;
10557
- delete uiWorkspace[MARK];
10558
- } catch {
10559
- /* 忽略 */
10560
- }
10614
+ clearInterval(timer);
10615
+ uninstallStartSessionGuard();
10561
10616
  };
10562
10617
  }, "dsh-split-view: one new session per pane");
10563
10618
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-multipane",
3
- "version": "1.0.54",
3
+ "version": "1.0.55",
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": {