dsh-multipane 1.0.52 → 1.0.54
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/LICENSE +21 -21
- package/README.en.md +6 -0
- package/README.md +12 -0
- package/cordis.patch.yml +11 -11
- package/lib/client.js +392 -18
- package/lib/index.js +99 -3
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 weiaisuyan
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 weiaisuyan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
CHANGED
|
@@ -161,6 +161,12 @@ node scripts/check-names.cjs # package name / version / release-age allowanc
|
|
|
161
161
|
|
|
162
162
|
## Changelog
|
|
163
163
|
|
|
164
|
+
### 1.0.54 (2026-11-19)
|
|
165
|
+
|
|
166
|
+
- **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.
|
|
167
|
+
- **One new session per pane.** Before creating, the tab-strip "+" and the sidebar New Session entry look for an existing blank tab in the current pane and switch to it instead of creating another.
|
|
168
|
+
- **Fix stats showing inside every pane as well as the bottom bar.** `dsh-cost-meter` renamed its composer stats row, so the plugin's old `.cm-stat-dock` lookup stopped finding it: the row was neither docked into the status bar nor hidden in the panes. It now locates the host's stable `[data-composer-dock]` row (with the old class as a fallback), so these numbers appear only in the bottom status bar; the cost-details and context-usage buttons stay clickable.
|
|
169
|
+
|
|
164
170
|
### 1.0.51 (2026-11-11)
|
|
165
171
|
|
|
166
172
|
- **The rail's hide threshold is now a setting.** A new card in Settings → UI elements, "Hide the turn rail in narrow panes", adds a 0-600px slider (default 240px, `0` = never hide). The 240px cutoff used to be hard-coded, so a narrow pane always lost the rail and there was no way to change it.
|
package/README.md
CHANGED
|
@@ -160,6 +160,18 @@ node scripts/check-names.cjs # 包名 / 版本 / 冷却豁免三处是否一
|
|
|
160
160
|
|
|
161
161
|
## 更新记录
|
|
162
162
|
|
|
163
|
+
### 1.0.54(2026-11-19)
|
|
164
|
+
|
|
165
|
+
- **修「新会话在别的栏里开着,侧栏却没了」**:DSH 的会话列表只保留「当前主会话」那一个空白新会话,插件把焦点切到另一栏时,宿主主会话跟着换,左栏那个还没发消息的新会话就被列表过滤掉了。现在只要空白新会话还开在任意一栏的标签里,插件就在显示层把它按普通行补回侧栏(标题仍是「新会话」,不显示时间与悬浮操作,右键 / 双击重命名 / 拖拽这些原生空白行没有的交互也保持关闭);它收到第一条消息、被关掉、或插件停用后立刻恢复原生行为。只改显示快照,不碰宿主的会话状态、主会话选择与保留计数;新会话页的 hero 布局(输入框居中)按真实 blank 计算,不会因为这次投影而沉底。
|
|
166
|
+
- **每栏最多一个新会话**:标签条「+」和侧栏「新建会话」在创建前先看当前栏有没有空白会话,有就直接切过去,不再重复创建。
|
|
167
|
+
- **修「底栏统计在每栏里也显示一份」**:`dsh-cost-meter` 的输入框统计行换了类名,插件原来靠 `.cm-stat-dock` 找它,找不到就不再把它搬进底栏、也不再隐藏各栏里的副本。现在改用宿主稳定的 `[data-composer-dock]` 定位(旧类保留回退),这些数据只出现在底部状态栏;费用明细 / 上下文占用等按钮仍然可点。
|
|
168
|
+
|
|
169
|
+
### 1.0.53(2026-11-12)
|
|
170
|
+
|
|
171
|
+
- **修「更新完 App 崩一下」**:以前替换插件目录是「先 `rm -rf` 再整目录复制」,复制期间那个目录根本不存在。宿主随时会来读 `client.js` —— 15 个插件的 `client.js` 被打进同一个 `plugins/??…` 合并请求,只要有一个文件读不到,整包就 failed to load,全部插件一起不激活,宿主判 `web boot` 失败并崩溃(2026-11-12 11:13 实测日志:`web boot: 15 entries did not activate`)。现在先把新版本铺到同级临时目录,再「旧目录 rename 挪开 → 新目录 rename 就位」,空窗从整次复制缩到两次 syscall;换名失败会把旧目录放回原位,不留半截安装
|
|
172
|
+
- **账本自愈**:插件加载时若发现「装着的版本 ≠ lockfile 写的版本」,自动向 registry 取该版本的 integrity,把 `package.json` 与 `pnpm-lock.yaml` 对齐(不 await 网络,全程 try/catch)。历史上用旧自更新装上的副本、被中断的更新、从备份恢复的副本,都会在下次启动时自己修好,不用再去点一次市场更新
|
|
173
|
+
- 1.0.52 的账本同步继续保留:自更新与市场更新两条路都落到同一个一致状态
|
|
174
|
+
|
|
163
175
|
### 1.0.52(2026-11-12)
|
|
164
176
|
|
|
165
177
|
- **修「明明更新过,进设置页还提示新版本」**:设置页那个更新按钮只把文件覆盖进 `node_modules\dsh-multipane`,而 profile 的 `package.json` 与 `pnpm-lock.yaml` 里还钉着旧版本号。之后只要在这个 profile 里装/卸**任何**别的插件(pnpm 一跑),它就会按 lockfile 把这个目录重铺回旧版本 —— 用户看到的就是「更新成功了,提示还在」。实测:1.0.51 装上后 9:09 确实在跑,9:42 装了另一个插件,目录又变回 1.0.37
|
package/cordis.patch.yml
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# dsh-split-view bundle patch.
|
|
2
|
-
#
|
|
3
|
-
# Installing this package through the official CLI
|
|
4
|
-
# dsh plugin --profile desktop add file:<path-to-this-directory>
|
|
5
|
-
# reconciles `dsh.profile.bundles` against installed packages and appends
|
|
6
|
-
# `dsh-split-view` to the bundle stack; the profile boot then merges this patch
|
|
7
|
-
# (a single `insert` of the plugin row).
|
|
8
|
-
- insert:
|
|
9
|
-
- id: split-view
|
|
10
|
-
name: 'dsh-multipane'
|
|
11
|
-
label: '多栏视图'
|
|
1
|
+
# dsh-split-view bundle patch.
|
|
2
|
+
#
|
|
3
|
+
# Installing this package through the official CLI
|
|
4
|
+
# dsh plugin --profile desktop add file:<path-to-this-directory>
|
|
5
|
+
# reconciles `dsh.profile.bundles` against installed packages and appends
|
|
6
|
+
# `dsh-split-view` to the bundle stack; the profile boot then merges this patch
|
|
7
|
+
# (a single `insert` of the plugin row).
|
|
8
|
+
- insert:
|
|
9
|
+
- id: split-view
|
|
10
|
+
name: 'dsh-multipane'
|
|
11
|
+
label: '多栏视图'
|
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.
|
|
20
|
+
const PLUGIN_VERSION = "1.0.54";
|
|
21
21
|
const NPM_LATEST_URL = "https://registry.npmjs.org/dsh-multipane/latest";
|
|
22
22
|
|
|
23
23
|
|
|
@@ -1593,6 +1593,10 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1593
1593
|
try {
|
|
1594
1594
|
for (const row of document.querySelectorAll("[data-dsv-row]")) row.removeAttribute("data-dsv-row");
|
|
1595
1595
|
for (const row of document.querySelectorAll("[data-dsv-pulse]")) row.removeAttribute("data-dsv-pulse");
|
|
1596
|
+
for (const row of document.querySelectorAll("[data-dsv-pane-blank]")) {
|
|
1597
|
+
row.removeAttribute("data-dsv-pane-blank");
|
|
1598
|
+
unguardPaneBlankRow(row);
|
|
1599
|
+
}
|
|
1596
1600
|
for (const row of document.querySelectorAll('[data-row-key^="session:"]')) {
|
|
1597
1601
|
for (const cls of Array.from(row.classList)) {
|
|
1598
1602
|
if (cls.endsWith("_selected")) row.classList.remove(cls);
|
|
@@ -1609,6 +1613,11 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1609
1613
|
* 删掉它会让正开着的设置页闪一帧白板,重新启用也要等下一拍才补回来。
|
|
1610
1614
|
*/
|
|
1611
1615
|
function clearAllDsvState() {
|
|
1616
|
+
try {
|
|
1617
|
+
syncPaneBlankRows(null, true);
|
|
1618
|
+
} catch {
|
|
1619
|
+
/* 服务可能已经拆了 */
|
|
1620
|
+
}
|
|
1612
1621
|
try {
|
|
1613
1622
|
const style = document.getElementById(STYLE_ID);
|
|
1614
1623
|
if (style !== null) style.remove();
|
|
@@ -1705,6 +1714,225 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1705
1714
|
}
|
|
1706
1715
|
}
|
|
1707
1716
|
|
|
1717
|
+
/* ── 新会话行保活(2026-11-19)────────────────────────────────
|
|
1718
|
+
宿主只渲染「当前主会话」那一个空白 New Session 行:侧栏的
|
|
1719
|
+
sessionVisible() 写死了 `session.blank && session.id !== current → 不显示`。
|
|
1720
|
+
多栏里一个空白新会话被切到后台后,焦点栏一换、宿主 mainSessionId 跟着换,
|
|
1721
|
+
它就会从侧栏消失 —— 虽然它还开在某一栏的标签里(用户实测)。
|
|
1722
|
+
|
|
1723
|
+
做法:只在**显示层**把「还开着但不是当前」的空白会话投影成普通行
|
|
1724
|
+
(blank=false,标题仍是「新会话」),让宿主的侧栏把它画出来;收到第一条
|
|
1725
|
+
消息 / 被关掉 / 变成当前会话 / 插件停用后还原。真实 blank、retention、
|
|
1726
|
+
标题都不改。
|
|
1727
|
+
|
|
1728
|
+
⚠️ 这个投影会让宿主的会话页从 hero 变成 active(输入框从中间沉到底部)。
|
|
1729
|
+
本插件自己渲染 conversation.content 并传 phase,所以下面的 Pane / 标签
|
|
1730
|
+
用 isPaneBlankRow() 读「真实 blank」来算 hero,不受投影影响 —— 这样侧栏
|
|
1731
|
+
行还在,新会话页仍然是居中的 hero。 */
|
|
1732
|
+
const PANE_BLANK_MARK = Symbol.for("dsh-split-view:pane-blank");
|
|
1733
|
+
const paneBlankOriginals = new Map();
|
|
1734
|
+
const paneBlankShown = new Set();
|
|
1735
|
+
const paneBlankGuards = new WeakMap();
|
|
1736
|
+
|
|
1737
|
+
/** 当前各栏里的会话:焦点栏激活标签 + 所有打开着的标签。 */
|
|
1738
|
+
function paneSessionsOf(state) {
|
|
1739
|
+
const panes = Array.isArray(state?.panes) ? state.panes : [];
|
|
1740
|
+
const focusPane = panes.find((pane) => pane.id === state?.focusPaneId) ?? panes[0];
|
|
1741
|
+
const focusTab = focusPane === void 0 ? void 0 : focusPane.tabs.find((tab) => tab.id === focusPane.activeTabId) ?? focusPane.tabs[0];
|
|
1742
|
+
const focusSession = typeof focusTab?.sessionId === "string" && focusTab.sessionId !== "" ? focusTab.sessionId : null;
|
|
1743
|
+
const open = new Set();
|
|
1744
|
+
for (const pane of panes) {
|
|
1745
|
+
for (const tab of pane.tabs) {
|
|
1746
|
+
if (typeof tab.sessionId === "string" && tab.sessionId !== "") open.add(tab.sessionId);
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
return { focusSession, open };
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
/** 宿主判定的「当前主会话」= 第一个带 mainView 保留的会话(与宿主同一规则)。 */
|
|
1753
|
+
function hostMainSessionId(byId) {
|
|
1754
|
+
for (const id of Object.keys(byId ?? {})) {
|
|
1755
|
+
const row = byId[id];
|
|
1756
|
+
if (row !== void 0 && row !== null && (row.retainedBy?.mainView ?? 0) > 0) return id;
|
|
1757
|
+
}
|
|
1758
|
+
return null;
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
function hasOwn(target, key) {
|
|
1762
|
+
return Object.prototype.hasOwnProperty.call(target, key);
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
/**
|
|
1766
|
+
* 这个会话**真实**是不是空白新会话。
|
|
1767
|
+
*
|
|
1768
|
+
* 行上的 blank 可能被本插件投影成 false(为了让侧栏显示它),
|
|
1769
|
+
* 但会话页的 hero 布局必须按真实值算 —— 否则新会话页的输入框会在
|
|
1770
|
+
* 「中间」和「下面」之间跳。投影前把真实值记在 paneBlankOriginals 里。
|
|
1771
|
+
*/
|
|
1772
|
+
function isPaneBlankRow(row, id) {
|
|
1773
|
+
if (row?.blank === true) return true;
|
|
1774
|
+
const stored = paneBlankOriginals.get(id);
|
|
1775
|
+
return stored?.blank === true;
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
/**
|
|
1779
|
+
* 某一栏里已经打开的空白新会话标签;没有返回 null。
|
|
1780
|
+
*
|
|
1781
|
+
* 用户口径(2026-11-19):每栏最多一个新会话。标签条上的「+」和侧栏
|
|
1782
|
+
* 「新建会话」在创建前都先看这一栏有没有空白会话,有就直接切过去。
|
|
1783
|
+
*/
|
|
1784
|
+
function blankTabInPane(paneId) {
|
|
1785
|
+
const state = window.__dsvState ?? readState();
|
|
1786
|
+
const panes = Array.isArray(state?.panes) ? state.panes : [];
|
|
1787
|
+
const pane = panes.find((candidate) => candidate.id === paneId) ?? panes.find((candidate) => candidate.id === state?.focusPaneId) ?? panes[0];
|
|
1788
|
+
if (pane === void 0) return null;
|
|
1789
|
+
let byId = {};
|
|
1790
|
+
try {
|
|
1791
|
+
byId = resolveSessions()?.list?.getSnapshot?.()?.byId ?? {};
|
|
1792
|
+
} catch {
|
|
1793
|
+
byId = {};
|
|
1794
|
+
}
|
|
1795
|
+
for (const tab of pane.tabs) {
|
|
1796
|
+
if (tab.sessionId === null) return tab;
|
|
1797
|
+
const id = tab.sessionId;
|
|
1798
|
+
if (typeof id === "string" && isPaneBlankRow(byId[id], id)) return tab;
|
|
1799
|
+
}
|
|
1800
|
+
return null;
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
/**
|
|
1804
|
+
* 把「还开着、但宿主会隐藏的空白会话」补成普通行显示。
|
|
1805
|
+
* @param state 多栏状态(null = 只做还原)
|
|
1806
|
+
* @param force 忽略启用开关(插件卸载 / 停用时强制还原)
|
|
1807
|
+
*/
|
|
1808
|
+
function syncPaneBlankRows(state, force) {
|
|
1809
|
+
const sessions = resolveSessions();
|
|
1810
|
+
const list = sessions?.list;
|
|
1811
|
+
let snap;
|
|
1812
|
+
try {
|
|
1813
|
+
snap = list?.getSnapshot?.();
|
|
1814
|
+
} catch {
|
|
1815
|
+
snap = void 0;
|
|
1816
|
+
}
|
|
1817
|
+
const byId = snap?.byId;
|
|
1818
|
+
if (byId === void 0 || byId === null || typeof list.set !== "function") return;
|
|
1819
|
+
const enabled = force === true ? false : prefs.state.enabled === true;
|
|
1820
|
+
const { focusSession, open } = enabled === true ? paneSessionsOf(state) : { focusSession: null, open: new Set() };
|
|
1821
|
+
const mainId = hostMainSessionId(byId);
|
|
1822
|
+
const label = t("新会话");
|
|
1823
|
+
/* 排序完全交还给宿主:插件不改 updatedAt、不碰置顶集合。
|
|
1824
|
+
位置之所以稳定,是因为这一行**始终**按普通行投影(激活与否都一样),
|
|
1825
|
+
宿主就用同一个规则给它排序 —— 不会再出现「激活时在置顶之前、
|
|
1826
|
+
切走后掉到置顶之后」的跳动。 */
|
|
1827
|
+
const wanted = new Set();
|
|
1828
|
+
/* 启动恢复期(宿主还没选定主会话)不要插手:宿主会用 summary.blank
|
|
1829
|
+
决定「直接恢复」还是「按预设重开空白会话」,我们先把它投影成普通会话
|
|
1830
|
+
会让它走错分支。等 mainView 出现后下一拍再补。 */
|
|
1831
|
+
if (enabled === true && mainId !== null) {
|
|
1832
|
+
for (const id of open) {
|
|
1833
|
+
const row = byId[id];
|
|
1834
|
+
if (row === void 0 || row === null) continue;
|
|
1835
|
+
if (row[PANE_BLANK_MARK] !== true) {
|
|
1836
|
+
/* 宿主已经不再把它当新会话(首条消息已发出 / 本来就不是)→ 永久放手 */
|
|
1837
|
+
if (row.blank !== true) {
|
|
1838
|
+
paneBlankOriginals.delete(id);
|
|
1839
|
+
continue;
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
/* 焦点栏的当前标签也要投影:宿主把「空白会话」放在置顶行**之前**、
|
|
1843
|
+
普通行**之后**,只投影后台那个会让行位置随激活状态跳。
|
|
1844
|
+
统一按普通行呈现,位置就固定了(有置顶行时在置顶之后,没有时第一)。
|
|
1845
|
+
会话页的 hero 由 isPaneBlankRow 按真实 blank 计算,不受影响。 */
|
|
1846
|
+
wanted.add(id);
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
const nextById = { ...byId };
|
|
1850
|
+
let changed = false;
|
|
1851
|
+
for (const id of wanted) {
|
|
1852
|
+
const row = byId[id];
|
|
1853
|
+
if (row === void 0) continue;
|
|
1854
|
+
if (row[PANE_BLANK_MARK] === true) {
|
|
1855
|
+
if (row.title !== label || row.displayTitle !== label) {
|
|
1856
|
+
nextById[id] = { ...row, title: label, displayTitle: label };
|
|
1857
|
+
changed = true;
|
|
1858
|
+
}
|
|
1859
|
+
continue;
|
|
1860
|
+
}
|
|
1861
|
+
paneBlankOriginals.set(id, {
|
|
1862
|
+
blank: row.blank === true,
|
|
1863
|
+
title: row.title,
|
|
1864
|
+
hasTitle: hasOwn(row, "title"),
|
|
1865
|
+
displayTitle: row.displayTitle,
|
|
1866
|
+
hasDisplayTitle: hasOwn(row, "displayTitle")
|
|
1867
|
+
});
|
|
1868
|
+
nextById[id] = { ...row, blank: false, title: label, displayTitle: label, [PANE_BLANK_MARK]: true };
|
|
1869
|
+
changed = true;
|
|
1870
|
+
}
|
|
1871
|
+
for (const id of Array.from(paneBlankOriginals.keys())) {
|
|
1872
|
+
if (wanted.has(id)) continue;
|
|
1873
|
+
const row = byId[id];
|
|
1874
|
+
const stored = paneBlankOriginals.get(id);
|
|
1875
|
+
paneBlankOriginals.delete(id);
|
|
1876
|
+
if (row === void 0 || row === null || row[PANE_BLANK_MARK] !== true) continue;
|
|
1877
|
+
const restored = { ...row, blank: stored?.blank === true };
|
|
1878
|
+
delete restored[PANE_BLANK_MARK];
|
|
1879
|
+
if (stored?.hasTitle === true) restored.title = stored.title;
|
|
1880
|
+
else delete restored.title;
|
|
1881
|
+
if (stored?.hasDisplayTitle === true) restored.displayTitle = stored.displayTitle;
|
|
1882
|
+
else delete restored.displayTitle;
|
|
1883
|
+
nextById[id] = restored;
|
|
1884
|
+
changed = true;
|
|
1885
|
+
}
|
|
1886
|
+
let applied = true;
|
|
1887
|
+
if (changed === true) {
|
|
1888
|
+
try {
|
|
1889
|
+
list.set({ ...snap, byId: nextById });
|
|
1890
|
+
} catch (error) {
|
|
1891
|
+
applied = false;
|
|
1892
|
+
console.warn("[split-view] 新会话行保活失败:", error);
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
paneBlankShown.clear();
|
|
1896
|
+
if (applied === true) {
|
|
1897
|
+
for (const id of paneBlankOriginals.keys()) {
|
|
1898
|
+
const row = nextById[id];
|
|
1899
|
+
if (row !== void 0 && row[PANE_BLANK_MARK] === true) paneBlankShown.add(id);
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
/* 原生空白行没有右键菜单 / 双击重命名 / 拖拽;投影行只是「补显示」,
|
|
1905
|
+
这几类交互也一并挡掉,行为与原生一致。捕获阶段拦截,宿主 React 的
|
|
1906
|
+
根委托就不会收到事件。 */
|
|
1907
|
+
function guardPaneBlankRow(row) {
|
|
1908
|
+
if (paneBlankGuards.has(row)) return;
|
|
1909
|
+
const stop = (event) => {
|
|
1910
|
+
event.preventDefault();
|
|
1911
|
+
event.stopPropagation();
|
|
1912
|
+
};
|
|
1913
|
+
const guard = { contextmenu: stop, dblclick: stop, dragstart: stop };
|
|
1914
|
+
for (const type of Object.keys(guard)) row.addEventListener(type, guard[type], true);
|
|
1915
|
+
paneBlankGuards.set(row, guard);
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
function unguardPaneBlankRow(row) {
|
|
1919
|
+
const guard = paneBlankGuards.get(row);
|
|
1920
|
+
if (guard === void 0) return;
|
|
1921
|
+
for (const type of Object.keys(guard)) row.removeEventListener(type, guard[type], true);
|
|
1922
|
+
paneBlankGuards.delete(row);
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
/** 在侧栏行上标出「投影行」,供 CSS 隐藏行尾时间 / 悬浮操作。 */
|
|
1926
|
+
function paintPaneBlankRow(row, id) {
|
|
1927
|
+
if (paneBlankShown.has(id)) {
|
|
1928
|
+
if (row.getAttribute("data-dsv-pane-blank") !== "1") row.setAttribute("data-dsv-pane-blank", "1");
|
|
1929
|
+
guardPaneBlankRow(row);
|
|
1930
|
+
} else {
|
|
1931
|
+
if (row.getAttribute("data-dsv-pane-blank") !== null) row.removeAttribute("data-dsv-pane-blank");
|
|
1932
|
+
unguardPaneBlankRow(row);
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1708
1936
|
function paintSidebarRows(state) {
|
|
1709
1937
|
const sessions = resolveSessions();
|
|
1710
1938
|
let snap;
|
|
@@ -1751,6 +1979,8 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1751
1979
|
row.setAttribute("data-dsv-row", mark);
|
|
1752
1980
|
}
|
|
1753
1981
|
applyPulseAttr(row, mark, id);
|
|
1982
|
+
/* 新会话投影行:保留原生空白行的外观与交互边界。 */
|
|
1983
|
+
paintPaneBlankRow(row, id);
|
|
1754
1984
|
const hostSelected = row.className.split(/\s+/).some((c) => c.endsWith("_selected"));
|
|
1755
1985
|
if (mark === "focus" && !hostSelected) {
|
|
1756
1986
|
const base = row.className.split(/\s+/).find((c) => c.endsWith("_sessionRow"));
|
|
@@ -1785,6 +2015,11 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1785
2015
|
/* 插件关掉后必须**停手并清掉标记**,否则会话列表还带着插件的高亮,
|
|
1786
2016
|
但主区域已经还给宿主了 —— 两边对不上,用户看起来就是「关不掉」。 */
|
|
1787
2017
|
if (prefs.state.enabled !== true) {
|
|
2018
|
+
try {
|
|
2019
|
+
syncPaneBlankRows(null, true);
|
|
2020
|
+
} catch {
|
|
2021
|
+
/* 忽略 */
|
|
2022
|
+
}
|
|
1788
2023
|
/* 停用后跑的这一支:行标记每拍都清(宿主重渲染会重建行),
|
|
1789
2024
|
会话列表立刻回到官方样式;样式表本身**不能删** ——
|
|
1790
2025
|
设置页可能正开着,删了就会闪一帧白板,重新启用也得等下一拍。 */
|
|
@@ -1798,7 +2033,9 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1798
2033
|
return;
|
|
1799
2034
|
}
|
|
1800
2035
|
try {
|
|
1801
|
-
|
|
2036
|
+
const state = window.__dsvState ?? readState();
|
|
2037
|
+
syncPaneBlankRows(state);
|
|
2038
|
+
paintSidebarRows(state);
|
|
1802
2039
|
} catch {
|
|
1803
2040
|
/* 忽略 */
|
|
1804
2041
|
}
|
|
@@ -1814,6 +2051,32 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1814
2051
|
}
|
|
1815
2052
|
}
|
|
1816
2053
|
globalThis.__dsvMarksTimer = setInterval(tick, 700);
|
|
2054
|
+
/* 宿主每次重渲染会话列表都会把行换回原生形态(空白会话 = 置顶槽位)。
|
|
2055
|
+
只靠 700ms 轮询补投影,中间那一拍用户能看到行在置顶之前闪一下。
|
|
2056
|
+
订阅列表,让补投影和宿主的这次更新落在同一个任务里。 */
|
|
2057
|
+
if (globalThis.__dsvMarksUnsub !== void 0) {
|
|
2058
|
+
try {
|
|
2059
|
+
globalThis.__dsvMarksUnsub();
|
|
2060
|
+
} catch {
|
|
2061
|
+
/* 忽略 */
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
globalThis.__dsvMarksUnsub = void 0;
|
|
2065
|
+
try {
|
|
2066
|
+
const sessions = resolveSessions();
|
|
2067
|
+
if (sessions?.list !== void 0 && typeof sessions.list.subscribe === "function") {
|
|
2068
|
+
globalThis.__dsvMarksUnsub = sessions.list.subscribe(() => {
|
|
2069
|
+
if (prefs.state.enabled !== true) return;
|
|
2070
|
+
try {
|
|
2071
|
+
syncPaneBlankRows(window.__dsvState ?? readState());
|
|
2072
|
+
} catch {
|
|
2073
|
+
/* 忽略 */
|
|
2074
|
+
}
|
|
2075
|
+
});
|
|
2076
|
+
}
|
|
2077
|
+
} catch {
|
|
2078
|
+
/* 拿不到列表订阅就退回轮询 */
|
|
2079
|
+
}
|
|
1817
2080
|
/* 即时:宿主重渲染侧栏、行节点被重建时,新节点上没有标记 ——
|
|
1818
2081
|
在同一个微任务里补,用户看不到裸形态那一帧。
|
|
1819
2082
|
只观察 childList(节点增删);**不观察 attributes**:
|
|
@@ -1846,6 +2109,13 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1846
2109
|
const runningIdsRef = react.useRef(new Set());
|
|
1847
2110
|
react.useEffect(() => {
|
|
1848
2111
|
const compute = () => {
|
|
2112
|
+
/* 先把「还开着的新会话」补进侧栏列表:焦点栏一换,宿主就会
|
|
2113
|
+
把另一栏那个空白会话过滤掉,这一步在每次重算时都补回来。 */
|
|
2114
|
+
try {
|
|
2115
|
+
syncPaneBlankRows(state);
|
|
2116
|
+
} catch {
|
|
2117
|
+
/* 忽略 */
|
|
2118
|
+
}
|
|
1849
2119
|
/* 本轮是否改动了 statusStore —— 改了就要通知 React 重渲染。 */
|
|
1850
2120
|
let changed = false;
|
|
1851
2121
|
const runningIds = (() => {
|
|
@@ -1912,6 +2182,7 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1912
2182
|
row.setAttribute("data-dsv-row", mark);
|
|
1913
2183
|
}
|
|
1914
2184
|
applyPulseAttr(row, mark, id);
|
|
2185
|
+
paintPaneBlankRow(row, id);
|
|
1915
2186
|
/* 同时挂上宿主自己的 selected class —— 它本来就有
|
|
1916
2187
|
`.sessionRow.selected{background:var(--dsw-alias-interactive-bg-hover)}` 这条规则,
|
|
1917
2188
|
只是插件接管 selectPanel 后不再有人加这个 class。用宿主的规则更贴合原生观感。 */
|
|
@@ -2185,6 +2456,9 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
2185
2456
|
/* 已打开但**没有显示**(在标签里、不是当前激活标签):与「打开显示」同一套底色/文字,
|
|
2186
2457
|
只是默认不画左竖线 —— 一眼能分出"这个开过但没在屏幕上"。 */
|
|
2187
2458
|
[data-row-key^="session:"][data-dsv-row="open-hidden"]{background-clip:border-box!important;background-origin:border-box!important;background-color:var(--dsv-row-open-bg,rgba(167,170,175,.06))!important;background-image:var(--dsv-row-hidden-bar,none)!important;box-shadow:none!important;font-weight:400}
|
|
2459
|
+
/* 新会话投影行:外观与原生「新会话」行一致 —— 不显示行尾时间 / 悬浮操作。 */
|
|
2460
|
+
[data-row-key^="session:"][data-dsv-pane-blank="1"] [class*="_rowResting"],
|
|
2461
|
+
[data-row-key^="session:"][data-dsv-pane-blank="1"] [class*="_rowActions"]{display:none!important}
|
|
2188
2462
|
/* 未打开的会话行(也就是绝大多数普通行):**一点都不要动**。
|
|
2189
2463
|
以前这里是 [data-row-key^="session:"]:not([data-dsv-row]) *{opacity:.50},
|
|
2190
2464
|
等于给所有普通行盖了一层蒙版 —— 置顶的行看不见、鼠标悬浮出来的操作按钮也看不见。
|
|
@@ -4485,7 +4759,7 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
4485
4759
|
/* 每个标签的标题:渲染进标签和「算宽度」共用同一份结果(否则两处逻辑会漂) */
|
|
4486
4760
|
const tabLabels = pane.tabs.map((tab) => {
|
|
4487
4761
|
const row = tab.sessionId === null ? void 0 : rowMap.get(tab.sessionId);
|
|
4488
|
-
return tab.sessionId === null || row
|
|
4762
|
+
return tab.sessionId === null || isPaneBlankRow(row, tab.sessionId)
|
|
4489
4763
|
? t("新会话")
|
|
4490
4764
|
: row === void 0
|
|
4491
4765
|
? t("已失效会话")
|
|
@@ -4743,7 +5017,7 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
4743
5017
|
const active = pane.tabs.find((tab) => tab.id === pane.activeTabId) ?? pane.tabs[0];
|
|
4744
5018
|
const sessionId = active?.sessionId ?? null;
|
|
4745
5019
|
const row = sessionId === null ? void 0 : rowMap.get(sessionId);
|
|
4746
|
-
const hero = row === void 0 || row
|
|
5020
|
+
const hero = row === void 0 || isPaneBlankRow(row, sessionId);
|
|
4747
5021
|
/* 常驻槽位里「哪一个可见」:优先 activeTabId,找不到就退回第一个标签;
|
|
4748
5022
|
空栏(无标签)时用哨兵 "__blank" 对应下面渲染的空白槽,避免整栏被隐藏。 */
|
|
4749
5023
|
const slotActiveId = active?.id ?? "__blank";
|
|
@@ -4945,7 +5219,7 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
4945
5219
|
(pane.tabs.length > 0 ? pane.tabs : [{ id: "__blank", sessionId: null }]).map((tab) => {
|
|
4946
5220
|
const tabSessionId = tab.sessionId ?? null;
|
|
4947
5221
|
const tabRow = tabSessionId === null ? void 0 : rowMap.get(tabSessionId);
|
|
4948
|
-
const tabHero = tabRow === void 0 || tabRow
|
|
5222
|
+
const tabHero = tabRow === void 0 || isPaneBlankRow(tabRow, tabSessionId);
|
|
4949
5223
|
const tabActive = tab.id === slotActiveId;
|
|
4950
5224
|
return h(
|
|
4951
5225
|
"div",
|
|
@@ -5069,6 +5343,26 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
5069
5343
|
);
|
|
5070
5344
|
}
|
|
5071
5345
|
|
|
5346
|
+
/* 宿主统计行(输入框上方那一排:费用 / 上下文)的定位。
|
|
5347
|
+
2026-11-19:新宿主给 composer dock 容器加了 `data-composer-dock`,
|
|
5348
|
+
而 cost-meter 的输入框按钮类名从旧的 `.cm-stat-dock` 换成了 `.cm-dp`。
|
|
5349
|
+
以前插件只认 `.cm-stat-dock`,找不到行 → 底栏退回兜底统计,
|
|
5350
|
+
各栏自己的原生行也没被隐藏,于是每栏一份 + 底栏一份(用户截图)。
|
|
5351
|
+
现在优先用宿主稳定的 `[data-composer-dock]` 整行;旧宿主没有这个属性时
|
|
5352
|
+
再退回旧类的「上两级」定位。 */
|
|
5353
|
+
function dockRowsIn(scope) {
|
|
5354
|
+
const rows = [];
|
|
5355
|
+
for (const root of Array.from(scope.querySelectorAll("[data-composer-dock]"))) {
|
|
5356
|
+
if (rows.indexOf(root) < 0) rows.push(root);
|
|
5357
|
+
}
|
|
5358
|
+
if (rows.length > 0) return rows;
|
|
5359
|
+
for (const dock of Array.from(scope.querySelectorAll(".cm-stat-dock"))) {
|
|
5360
|
+
const row = dock.parentElement?.parentElement ?? null;
|
|
5361
|
+
if (row !== null && rows.indexOf(row) < 0) rows.push(row);
|
|
5362
|
+
}
|
|
5363
|
+
return rows;
|
|
5364
|
+
}
|
|
5365
|
+
|
|
5072
5366
|
/**
|
|
5073
5367
|
* Moves the FOCUSED pane's real composer dock row (`.GRgSLq_dock`: 轮步・tok/s、
|
|
5074
5368
|
* 费用明细、缓存命中、上下文已用%、本会话费用…) into the workspace status bar,
|
|
@@ -5149,9 +5443,8 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
5149
5443
|
(display:none),它们各自带一份统计行,扫全栏会误把它们当成
|
|
5150
5444
|
「宿主重建的新行」,于是底栏数据每轮来回跳。 */
|
|
5151
5445
|
const scope = pane.querySelector('.dsv-tab-slot[data-active="1"]') ?? pane;
|
|
5152
|
-
for (const
|
|
5153
|
-
|
|
5154
|
-
if (row === null || row === keep) continue;
|
|
5446
|
+
for (const row of dockRowsIn(scope)) {
|
|
5447
|
+
if (row === keep) continue;
|
|
5155
5448
|
if (host.contains(row)) continue;
|
|
5156
5449
|
if (row.style.display !== "none") row.style.display = "none";
|
|
5157
5450
|
}
|
|
@@ -5171,9 +5464,8 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
5171
5464
|
const focusedPaneEl = Array.from(document.querySelectorAll(".dsv-pane")).find((p) => p.getAttribute("data-focus") === "1") ?? null;
|
|
5172
5465
|
if (focusedPaneEl === null) return null;
|
|
5173
5466
|
const focused = focusedPaneEl.querySelector('.dsv-tab-slot[data-active="1"]') ?? focusedPaneEl;
|
|
5174
|
-
for (const
|
|
5175
|
-
|
|
5176
|
-
if (row === null || host.contains(row)) continue;
|
|
5467
|
+
for (const row of dockRowsIn(focused)) {
|
|
5468
|
+
if (host.contains(row)) continue;
|
|
5177
5469
|
if (moved !== null && row === moved.node) continue;
|
|
5178
5470
|
return row;
|
|
5179
5471
|
}
|
|
@@ -5218,11 +5510,7 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
5218
5510
|
const scope = pane.querySelector('.dsv-tab-slot[data-active="1"]') ?? pane;
|
|
5219
5511
|
// 同一栏里也可能出现多行(宿主重建后新旧并存):只留第一行做焦点行,
|
|
5220
5512
|
// 其余全部隐藏,绝不把第二行搬进底栏。
|
|
5221
|
-
const rows =
|
|
5222
|
-
for (const dock of Array.from(scope.querySelectorAll(".cm-stat-dock"))) {
|
|
5223
|
-
const row = dock.parentElement?.parentElement ?? null;
|
|
5224
|
-
if (row !== null && rows.indexOf(row) < 0) rows.push(row);
|
|
5225
|
-
}
|
|
5513
|
+
const rows = dockRowsIn(scope);
|
|
5226
5514
|
for (const row of rows) {
|
|
5227
5515
|
if (focusedPane && target === null) target = row;
|
|
5228
5516
|
else if (row.style.display !== "none") row.style.display = "none";
|
|
@@ -8746,7 +9034,42 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
8746
9034
|
bridge.openTab = (sessionId) => {
|
|
8747
9035
|
bridge.routing = true;
|
|
8748
9036
|
try {
|
|
8749
|
-
setState((prev) =>
|
|
9037
|
+
setState((prev) => {
|
|
9038
|
+
/* 每栏最多一个新会话:这一栏已经有空白标签时,不再加第二个空白标签
|
|
9039
|
+
(宿主新建/复用了别的空白会话也一样)。如果请求的会话已经
|
|
9040
|
+
以标签形式开着就直接切过去,否则切到这一栏现有的空白标签。 */
|
|
9041
|
+
const pane = prev.panes.find((candidate) => candidate.id === prev.focusPaneId) ?? prev.panes[0];
|
|
9042
|
+
if (pane !== void 0) {
|
|
9043
|
+
let byId = {};
|
|
9044
|
+
try {
|
|
9045
|
+
byId = resolveSessions()?.list?.getSnapshot?.()?.byId ?? {};
|
|
9046
|
+
} catch {
|
|
9047
|
+
byId = {};
|
|
9048
|
+
}
|
|
9049
|
+
/* 只有「新进来的也是空白会话」才合并到本栏已有的空白标签;
|
|
9050
|
+
带 prompt 的新建(blank=false)是真实会话,必须照常开成新标签,
|
|
9051
|
+
否则用户刚发出的内容会看不到。 */
|
|
9052
|
+
const incoming = byId[sessionId];
|
|
9053
|
+
const incomingBlank = incoming === void 0 || incoming === null || isPaneBlankRow(incoming, sessionId);
|
|
9054
|
+
const existing = incomingBlank === true
|
|
9055
|
+
? pane.tabs.find((tab) => {
|
|
9056
|
+
if (tab.sessionId === null) return true;
|
|
9057
|
+
const id = tab.sessionId;
|
|
9058
|
+
return typeof id === "string" && isPaneBlankRow(byId[id], id);
|
|
9059
|
+
})
|
|
9060
|
+
: void 0;
|
|
9061
|
+
if (existing !== void 0) {
|
|
9062
|
+
const same = pane.tabs.find((tab) => tab.sessionId === sessionId);
|
|
9063
|
+
const target = same ?? existing;
|
|
9064
|
+
return {
|
|
9065
|
+
...prev,
|
|
9066
|
+
focusPaneId: pane.id,
|
|
9067
|
+
panes: prev.panes.map((item) => (item.id === pane.id ? { ...item, activeTabId: target.id } : item))
|
|
9068
|
+
};
|
|
9069
|
+
}
|
|
9070
|
+
}
|
|
9071
|
+
return openSession(prev, sessionId, "tab");
|
|
9072
|
+
});
|
|
8750
9073
|
} finally {
|
|
8751
9074
|
bridge.routing = false;
|
|
8752
9075
|
}
|
|
@@ -9017,6 +9340,16 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
9017
9340
|
新会话的 id 由 installCreateHook 捕获、再由 selectPanel 钩子
|
|
9018
9341
|
foldNewSession 开成新标签 —— 与侧栏新建完全同一条路径。 */
|
|
9019
9342
|
newTab: (paneId) => {
|
|
9343
|
+
/* 每栏最多一个新会话:这一栏已经有空白标签就直接激活,不再创建。 */
|
|
9344
|
+
const existing = blankTabInPane(paneId);
|
|
9345
|
+
if (existing !== null) {
|
|
9346
|
+
apply((prev) => ({
|
|
9347
|
+
...prev,
|
|
9348
|
+
focusPaneId: paneId,
|
|
9349
|
+
panes: prev.panes.map((pane) => (pane.id === paneId ? { ...pane, activeTabId: existing.id } : pane))
|
|
9350
|
+
}));
|
|
9351
|
+
return;
|
|
9352
|
+
}
|
|
9020
9353
|
apply((prev) => ({ ...prev, focusPaneId: paneId }));
|
|
9021
9354
|
const workspace = resolveWorkspaceService();
|
|
9022
9355
|
if (workspace !== void 0 && typeof workspace.startSession === "function") {
|
|
@@ -10187,12 +10520,53 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
10187
10520
|
};
|
|
10188
10521
|
}, "dsh-split-view: dangling panel guard");
|
|
10189
10522
|
|
|
10523
|
+
/* 侧栏「新建会话」按钮走的是宿主 uiWorkspace.startSession;在每栏
|
|
10524
|
+
已经有一个空白会话时拦住它,改为激活那一栏现有的空白标签 ——
|
|
10525
|
+
与标签条「+」同一条规则(每栏最多一个新会话)。
|
|
10526
|
+
只拦「无参数 / 空 options」的普通新建;带 prompt 或指定 workspace
|
|
10527
|
+
的调用原样放行。 */
|
|
10528
|
+
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
|
+
};
|
|
10554
|
+
return () => {
|
|
10555
|
+
try {
|
|
10556
|
+
uiWorkspace.startSession = base;
|
|
10557
|
+
delete uiWorkspace[MARK];
|
|
10558
|
+
} catch {
|
|
10559
|
+
/* 忽略 */
|
|
10560
|
+
}
|
|
10561
|
+
};
|
|
10562
|
+
}, "dsh-split-view: one new session per pane");
|
|
10563
|
+
|
|
10190
10564
|
startRightbarKeepOpen();
|
|
10191
10565
|
startSidebarMarks();
|
|
10192
10566
|
activateWorkspace(ctx);
|
|
10193
10567
|
|
|
10194
10568
|
try {
|
|
10195
|
-
window.__dsv = { ctx, services: SERVICES, bridge, drag, prefs, pendingNew, statusStore, statusSave };
|
|
10569
|
+
window.__dsv = { ctx, services: SERVICES, bridge, drag, prefs, pendingNew, statusStore, statusSave, paneBlank: { sync: syncPaneBlankRows, shown: paneBlankShown, originals: paneBlankOriginals } };
|
|
10196
10570
|
} catch {
|
|
10197
10571
|
/* no window (non-web host) */
|
|
10198
10572
|
}
|
package/lib/index.js
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
* integrity, and writes neither when either edit cannot be proven exact.
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
|
-
import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
33
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
34
34
|
import { execFile } from "node:child_process";
|
|
35
35
|
import { createHash } from "node:crypto";
|
|
36
36
|
import { homedir } from "node:os";
|
|
@@ -244,6 +244,73 @@ function lockEditProblems(before, after, version) {
|
|
|
244
244
|
return problems;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Ask the registry for the integrity of one published version.
|
|
249
|
+
*
|
|
250
|
+
* The lockfile entry needs the sha512 of the tarball. Guessing it (or keeping the
|
|
251
|
+
* previous version's string) makes pnpm reject the package as tampered with, so
|
|
252
|
+
* when this lookup fails the caller simply does not touch the bookkeeping.
|
|
253
|
+
*
|
|
254
|
+
* @param {string} version published version
|
|
255
|
+
* @returns {Promise<string>} integrity string, or "" when unavailable
|
|
256
|
+
*/
|
|
257
|
+
async function fetchIntegrity(version) {
|
|
258
|
+
try {
|
|
259
|
+
if (typeof fetch !== "function") return "";
|
|
260
|
+
const response = await fetch("https://registry.npmjs.org/" + PKG_NAME + "/" + version, { cache: "no-store" });
|
|
261
|
+
if (response.ok !== true) return "";
|
|
262
|
+
const data = await response.json();
|
|
263
|
+
const value = data && data.dist && data.dist.integrity;
|
|
264
|
+
return typeof value === "string" ? value : "";
|
|
265
|
+
} catch {
|
|
266
|
+
return "";
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Make the profile's bookkeeping agree with the copy that is actually installed.
|
|
272
|
+
*
|
|
273
|
+
* The update route writes both files, but it can only do that for updates it
|
|
274
|
+
* performs itself. A copy that arrived any other way — an older self-update that
|
|
275
|
+
* predates the bookkeeping sync, a restored backup, an interrupted run — leaves a
|
|
276
|
+
* profile whose lockfile still names the previous version, and the next `pnpm
|
|
277
|
+
* install` (installing or removing ANY other plugin) then rolls this one back.
|
|
278
|
+
* That is the exact symptom users report as "I updated it, the prompt came back".
|
|
279
|
+
*
|
|
280
|
+
* So on load, if the installed version and the lockfile disagree, settle it. Every
|
|
281
|
+
* path is guarded and the run is fire-and-forget: plugin loading never waits on
|
|
282
|
+
* the network, and a failure leaves the profile exactly as it was.
|
|
283
|
+
*
|
|
284
|
+
* @returns {Promise<void>} resolves when the check is done
|
|
285
|
+
*/
|
|
286
|
+
async function ensureBookkeepingMatchesInstalled() {
|
|
287
|
+
try {
|
|
288
|
+
const version = readOwnVersion();
|
|
289
|
+
if (version === "") return;
|
|
290
|
+
const root = join(homedir(), ".dsh", "profiles");
|
|
291
|
+
if (!existsSync(root)) return;
|
|
292
|
+
for (const profile of ["desktop", "web"]) {
|
|
293
|
+
try {
|
|
294
|
+
const dir = join(root, profile);
|
|
295
|
+
const lockPath = join(dir, "pnpm-lock.yaml");
|
|
296
|
+
if (!existsSync(lockPath)) continue;
|
|
297
|
+
const lock = readFileSync(lockPath, "utf8");
|
|
298
|
+
const importerRe = new RegExp("\\n( " + escapeRegex(PKG_NAME) + ":\\n specifier: )([^\\n]*)(\\n version: )([^\\n]*)");
|
|
299
|
+
const hit = lock.match(importerRe);
|
|
300
|
+
if (hit === null) continue;
|
|
301
|
+
if (hit[4].trim().split("(")[0] === version) continue;
|
|
302
|
+
const integrity = await fetchIntegrity(version);
|
|
303
|
+
if (integrity === "") continue;
|
|
304
|
+
syncDependencyBookkeeping(dir, version, integrity);
|
|
305
|
+
} catch {
|
|
306
|
+
/* 单个 profile 失败不影响另一个,也不影响插件加载 */
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
} catch {
|
|
310
|
+
/* 绝不因为这里失败而挡住插件加载 */
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
247
314
|
/**
|
|
248
315
|
* Try every profile that exists on this machine (desktop is what the app uses,
|
|
249
316
|
* web is used by headless checks). Unknown layouts are skipped silently.
|
|
@@ -323,11 +390,33 @@ function installFromRegistry(profileDir, version) {
|
|
|
323
390
|
if (got !== version) return { ok: false, message: "包内版本是 " + got + ",不是 " + version };
|
|
324
391
|
/* integrity 要从解压前的 tgz 算,解压完 staging 就删了。 */
|
|
325
392
|
const integrity = integrityOfFile(tarball);
|
|
393
|
+
/* 新版本先铺进目标同级的临时目录:同盘才能 rename(跨盘 rename 会退化成整次复制)。
|
|
394
|
+
然后「旧目录改名挪开 → 新目录改名就位」两步换掉正式目录,空窗只剩两次 syscall。
|
|
395
|
+
这一步是必须的:宿主随时可能来读 client.js —— 15 个插件的 client.js 被打进同一个
|
|
396
|
+
`plugins/??…` 合并请求,复制期间只要有文件读不到,整包就 failed to load,全部插件
|
|
397
|
+
一起不激活。2026-11-12 11:13 那次 web boot 崩溃就是这么来的(rm 完还没复制完)。 */
|
|
398
|
+
const staged = target + ".next-" + process.pid;
|
|
399
|
+
const retired = target + ".old-" + process.pid;
|
|
400
|
+
rmSync(staged, { recursive: true, force: true });
|
|
401
|
+
rmSync(retired, { recursive: true, force: true });
|
|
402
|
+
cpSync(unpacked, staged, { recursive: true });
|
|
326
403
|
if (existsSync(target)) {
|
|
327
404
|
cpSync(target, backup, { recursive: true });
|
|
328
405
|
}
|
|
329
|
-
|
|
330
|
-
|
|
406
|
+
try {
|
|
407
|
+
if (existsSync(target)) renameSync(target, retired);
|
|
408
|
+
renameSync(staged, target);
|
|
409
|
+
} catch (error) {
|
|
410
|
+
/* 换名失败:把旧目录放回原位,再如实报错,绝不留半截安装 */
|
|
411
|
+
try {
|
|
412
|
+
if (!existsSync(target) && existsSync(retired)) renameSync(retired, target);
|
|
413
|
+
} catch {
|
|
414
|
+
/* 放不回就只能靠外层从 backup 回滚 */
|
|
415
|
+
}
|
|
416
|
+
rmSync(staged, { recursive: true, force: true });
|
|
417
|
+
return { ok: false, message: "替换目录失败:" + String((error && error.message) || error) };
|
|
418
|
+
}
|
|
419
|
+
rmSync(retired, { recursive: true, force: true });
|
|
331
420
|
rmSync(staging, { recursive: true, force: true });
|
|
332
421
|
rmSync(backup, { recursive: true, force: true });
|
|
333
422
|
/* 文件就位只是前半笔账,还要让 profile 的 package.json / pnpm-lock 也指到新版本,
|
|
@@ -378,6 +467,13 @@ export function apply(ctx) {
|
|
|
378
467
|
} catch {
|
|
379
468
|
/* 忽略 */
|
|
380
469
|
}
|
|
470
|
+
/* 账本自愈:装在盘上的版本与 lockfile 说的不一致时,启动后自己对齐一次。
|
|
471
|
+
不 await —— 插件加载不允许等网络。 */
|
|
472
|
+
try {
|
|
473
|
+
ensureBookkeepingMatchesInstalled().catch(() => {});
|
|
474
|
+
} catch {
|
|
475
|
+
/* 忽略 */
|
|
476
|
+
}
|
|
381
477
|
try {
|
|
382
478
|
ctx.inject(["webServer"], (host) => {
|
|
383
479
|
const profileDirOf = () => join(homedir(), ".dsh", "profiles", "desktop");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-multipane",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.54",
|
|
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": {
|