dsh-split-workspace 0.11.1 → 0.14.0

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/lib/client.js CHANGED
@@ -75,7 +75,7 @@ window.__ModuleLoader__.load({
75
75
  // ---------------------------------------------------------------------
76
76
 
77
77
  const PLUGIN_ID = "dsh-split-workspace";
78
- const PLUGIN_VERSION = "0.11.1";
78
+ const PLUGIN_VERSION = "0.14.0";
79
79
  const LOG_PREFIX = "[dsh-split-workspace]";
80
80
  const TREE_KEY = "dsh.split-workspace.tree.v1";
81
81
  const OPEN_KEY = "dsh.split-workspace.open.v2";
@@ -89,7 +89,137 @@ window.__ModuleLoader__.load({
89
89
  const PERF_KEY = "dsh.split-workspace.performance.v1";
90
90
  const SEEN_VERSION_KEY = "dsh.split-workspace.seen-version.v1";
91
91
  const UPDATE_DISMISSED_KEY = "dsh.split-workspace.update-dismissed.v1";
92
+ const FREEZE_KEY = "dsh.split-workspace.resize-freeze.v1";
92
93
  const UPDATE_POLL_MS = 120000;
94
+ /** Quiet window after the last resize event before pane measurements run. */
95
+ const LAYOUT_SETTLE_MS = 130;
96
+ /** How long a hidden canvas stays mounted before its pane tree is dropped.
97
+ This is what makes panel ⇄ split and minimize ⇄ restore switches reuse
98
+ the live native conversations instead of re-creating them. */
99
+ const WARM_HIDE_MS = 20000;
100
+ /** The main-panel id of the "分屏视图" entry; the sidebar row selects it
101
+ and the layout renders the workspace canvas in the main column. */
102
+ const SPLIT_PANEL_ID = "split-view";
103
+ /** Icon keys for the session context menu's "分屏插件" group and its rows.
104
+ Each key is registered into the context manager's inline icon slot. */
105
+ const CONTEXT_ICON_PANEL = "dsh-split-workspace:panel";
106
+ const CONTEXT_ICON_SPLIT = "dsh-split-workspace:split";
107
+ const CONTEXT_ICON_FLOAT = "dsh-split-workspace:float";
108
+ const CONTEXT_ICON_WINDOW = "dsh-split-workspace:window";
109
+ const CONTEXT_ICON_NATIVE = "dsh-split-workspace:native";
110
+
111
+ // ---- layout-busy tracker (0.12.0 resize responsiveness) ----------------
112
+ // Window resizes and divider drags change every pane's box on every frame.
113
+ // Measuring, re-rendering and re-laying-out the re-hosted native UI for
114
+ // each of those frames is what made live window resizing janky even in
115
+ // performance mode. These helpers let the per-pane observers skip the
116
+ // intermediate frames: they record "busy" from the first event and hand
117
+ // out a single settle callback that runs once, after the last resize /
118
+ // the divider release. The browser still reflows the panes natively (CSS
119
+ // percentages); only the JavaScript measurement and derived state wait.
120
+ let windowResizeAt = 0;
121
+ let windowResizeTimer = 0;
122
+ let dividerDragging = false;
123
+ const layoutSettleListeners = new Set();
124
+ /** True while the OS window is being resized (not a divider drag). */
125
+ function windowResizing() {
126
+ return windowResizeAt !== 0 && Date.now() - windowResizeAt < LAYOUT_SETTLE_MS;
127
+ }
128
+ /** True while the window is being resized OR a divider is being dragged. */
129
+ function layoutBusy() {
130
+ return dividerDragging === true || windowResizing();
131
+ }
132
+ /** Run a callback once after the current resize gesture / divider drag settles. */
133
+ function onLayoutSettle(fn) {
134
+ layoutSettleListeners.add(fn);
135
+ return () => { layoutSettleListeners.delete(fn); };
136
+ }
137
+ function notifyLayoutSettle() {
138
+ for (const fn of [...layoutSettleListeners]) {
139
+ try { fn(); } catch (error) {
140
+ try { console.warn(LOG_PREFIX + " layout-settle listener failed:", String(error).slice(0, 120)); } catch {}
141
+ }
142
+ }
143
+ }
144
+ function markDividerDrag(value) {
145
+ if (dividerDragging === (value === true)) return;
146
+ dividerDragging = value === true;
147
+ if (dividerDragging !== true) notifyLayoutSettle();
148
+ }
149
+ function noteWindowResize() {
150
+ windowResizeAt = Date.now();
151
+ try { document.documentElement.setAttribute("data-dsv-resizing", ""); } catch {}
152
+ if (windowResizeTimer !== 0) {
153
+ try { window.clearTimeout(windowResizeTimer); } catch {}
154
+ windowResizeTimer = 0;
155
+ }
156
+ windowResizeTimer = window.setTimeout(() => {
157
+ windowResizeTimer = 0;
158
+ windowResizeAt = 0;
159
+ try { document.documentElement.removeAttribute("data-dsv-resizing"); } catch {}
160
+ notifyLayoutSettle();
161
+ }, LAYOUT_SETTLE_MS);
162
+ }
163
+ /** Installed with the plugin lifetime; plain listeners so a reload cannot
164
+ stack duplicates. */
165
+ function installWindowResizeTracker() {
166
+ window.addEventListener("resize", noteWindowResize);
167
+ return () => {
168
+ window.removeEventListener("resize", noteWindowResize);
169
+ if (windowResizeTimer !== 0) {
170
+ try { window.clearTimeout(windowResizeTimer); } catch {}
171
+ windowResizeTimer = 0;
172
+ }
173
+ windowResizeAt = 0;
174
+ dividerDragging = false;
175
+ try { document.documentElement.removeAttribute("data-dsv-resizing"); } catch {}
176
+ };
177
+ }
178
+
179
+ // ---- split-view main panel selection (0.12.0) -------------------------
180
+ /** The layout service, read lazily: ui-layout is a core shell service, but
181
+ the plugin must keep working (overlay mode) on a host that lacks it. */
182
+ function layoutService() {
183
+ try {
184
+ return pluginCtx !== null && pluginCtx !== undefined && typeof pluginCtx.get === "function"
185
+ ? (pluginCtx.get("layout") ?? null)
186
+ : null;
187
+ } catch { return null; }
188
+ }
189
+ /** True while the main column shows the plugin's own split-view panel. */
190
+ function splitPanelActive() {
191
+ try {
192
+ const layout = layoutService();
193
+ const info = layout !== null && layout !== undefined && layout.panelInfo !== undefined && layout.panelInfo !== null
194
+ ? (typeof layout.panelInfo.getSnapshot === "function" ? layout.panelInfo.getSnapshot() : null)
195
+ : null;
196
+ return info !== null && info !== undefined && info.activePanelId === SPLIT_PANEL_ID;
197
+ } catch { return false; }
198
+ }
199
+ /** Show the split-view panel in the main column. */
200
+ function selectSplitPanel() {
201
+ try {
202
+ const layout = layoutService();
203
+ if (layout !== null && layout !== undefined && typeof layout.selectPanel === "function") {
204
+ layout.selectPanel(SPLIT_PANEL_ID);
205
+ return true;
206
+ }
207
+ } catch {}
208
+ return false;
209
+ }
210
+ /** Return the main column to the stock conversation view. */
211
+ function leaveSplitPanel() {
212
+ if (!splitPanelActive()) return false;
213
+ try {
214
+ const layout = layoutService();
215
+ if (layout !== null && layout !== undefined && typeof layout.selectPanel === "function") {
216
+ layout.selectPanel(null);
217
+ return true;
218
+ }
219
+ } catch {}
220
+ return false;
221
+ }
222
+
93
223
  function readChipPos() {
94
224
  const raw = storageGet(CHIP_KEY);
95
225
  if (!raw) return null;
@@ -121,6 +251,14 @@ window.__ModuleLoader__.load({
121
251
  function writePerformanceMode(value) {
122
252
  storageSet(PERF_KEY, value === true ? "1" : "0");
123
253
  }
254
+ /** Live-resize canvas freeze (see 12-chrome): ON by default; an explicit
255
+ "0" turns it off for users who prefer a true per-frame reflow. */
256
+ function readResizeFreeze() {
257
+ return storageGet(FREEZE_KEY) !== "0";
258
+ }
259
+ function writeResizeFreeze(value) {
260
+ storageSet(FREEZE_KEY, value === true ? "1" : "0");
261
+ }
124
262
  /* There is exactly one layout policy: AUTO, derived from the pane count.
125
263
  The old per-run mode menu (columns/rows/grid) is gone: it only ever
126
264
  produced a hand-picked arrangement that the next add/close immediately
@@ -517,6 +655,20 @@ window.__ModuleLoader__.load({
517
655
  layoutCount: "panes",
518
656
  exitSplit: "Exit split",
519
657
  openSplit: "Split view",
658
+ panelTitle: "Split view",
659
+ panelPickTitle: "Choose conversations to split",
660
+ panelPickHint: "Select at least two conversations — the split view opens as soon as you confirm.",
661
+ panelPickConfirm: "Open split view",
662
+ returningTitle: "Back to the conversation",
663
+ returningHint: "The split is minimized — switching to the conversation view…",
664
+ panelNeedTwo: "Select at least two conversations to open the split view.",
665
+ panelDisabledTitle: "Split view is disabled",
666
+ panelDisabledBody: "Enable it to open the split view again. Your saved layout is kept.",
667
+ panelEnable: "Enable split view",
668
+ panelSafeTitle: "Split view is paused after a crash",
669
+ panelSafeBody: "Retry to reopen the saved layout; the stock conversation view is untouched meanwhile.",
670
+ panelNoSessions: "No conversations are available yet. Start a conversation first, then pick two to split.",
671
+ panelMinimizeHint: "Minimize from the footer menu returns to the conversation.",
520
672
  minimizeSplit: "Minimize",
521
673
  rightbar: "Right sidebar",
522
674
  rightbarOpen: "Open right sidebar",
@@ -614,7 +766,7 @@ window.__ModuleLoader__.load({
614
766
  floatClosed: "Floating window closed",
615
767
  floatHint: "Drag the title bar to move · drag an edge to resize",
616
768
  helpFloat: "Right-click a conversation → Split plugin → Enter floating window detaches it into a movable window; Dock to split puts it back.",
617
- helpIndependent: "Right-click a conversation → Split plugin → Enter independent window / Enter system window. The independent window is an app-internal single-conversation window; the system window (macOS) is a real OS window with no left sidebar and the stock right sidebar. Neither opens a browser.",
769
+ helpIndependent: "Right-click a conversation → Split plugin → Enter independent window / Enter system window. The independent window is an app-internal single-conversation window; the system window (macOS, or Windows with the WebView2 Runtime) is a real OS window with no left sidebar and the stock right sidebar. Neither opens a browser.",
618
770
  menuSystemWindow: "Open in independent window",
619
771
  systemWindowOpened: "Opened in an independent window",
620
772
  systemWindowFailed: "Could not open the independent window",
@@ -622,7 +774,8 @@ window.__ModuleLoader__.load({
622
774
  systemWindowClosing: "Closing the system window…",
623
775
  systemWindowNativeOpened: "Entered the system window",
624
776
  systemWindowNativeClosed: "System window closed",
625
- systemWindowUnsupported: "The native system window needs macOS + DSH Desktop. Use Enter independent window instead.",
777
+ systemWindowUnsupported: "The native system window needs DSH Desktop on macOS or Windows. Use Enter independent window instead.",
778
+ systemWindowWebView2Missing: "The native system window needs the Microsoft Edge WebView2 Runtime. Install it, then try again, or use Enter independent window.",
626
779
  menuGroup: "Split plugin",
627
780
  menuIndependentOpen: "Enter independent window",
628
781
  menuIndependentClose: "Exit independent window",
@@ -672,6 +825,20 @@ window.__ModuleLoader__.load({
672
825
  layoutCount: "窗格",
673
826
  exitSplit: "退出分屏",
674
827
  openSplit: "分屏视图",
828
+ panelTitle: "分屏视图",
829
+ panelPickTitle: "选择要分屏的会话",
830
+ panelPickHint: "至少选择两个会话,确定后立即显示分屏界面。",
831
+ panelPickConfirm: "打开分屏",
832
+ returningTitle: "正在返回会话",
833
+ returningHint: "分屏已最小化,正在切换到会话视图…",
834
+ panelNeedTwo: "至少选择两个会话才能打开分屏视图。",
835
+ panelDisabledTitle: "分屏视图已禁用",
836
+ panelDisabledBody: "启用后可重新打开分屏视图,已保存的布局会保留。",
837
+ panelEnable: "启用分屏视图",
838
+ panelSafeTitle: "分屏在崩溃后已暂停",
839
+ panelSafeBody: "点“重试”可重新打开已保存的布局;期间原生会话视图不受影响。",
840
+ panelNoSessions: "还没有可用的会话。先开始对话,再选择两个进行分屏。",
841
+ panelMinimizeHint: "从底部菜单最小化会回到会话界面。",
675
842
  minimizeSplit: "最小化",
676
843
  rightbar: "右侧栏",
677
844
  rightbarOpen: "打开右侧边栏",
@@ -769,7 +936,7 @@ window.__ModuleLoader__.load({
769
936
  floatClosed: "浮窗已关闭",
770
937
  floatHint: "拖动标题栏移动 · 拖动边缘调整大小",
771
938
  helpFloat: "右键会话 → 分屏插件 → 进入浮窗,可把该会话变成独立浮窗;浮窗标题栏的“回到分屏”可放回分屏。",
772
- helpIndependent: "右键会话 → 分屏插件 → 进入独立窗口 / 进入系统窗口。独立窗口在应用内单独显示该会话(关闭 / 最小化 / 最大化 / 全屏);系统窗口(macOS)是真正的操作系统窗口,不显示左侧栏、保留右侧栏。两者都不依赖浏览器。",
939
+ helpIndependent: "右键会话 → 分屏插件 → 进入独立窗口 / 进入系统窗口。独立窗口在应用内单独显示该会话(关闭 / 最小化 / 最大化 / 全屏);系统窗口(macOS,或装了 WebView2 运行时的 Windows)是真正的操作系统窗口,不显示左侧栏、保留右侧栏。两者都不依赖浏览器。",
773
940
  menuSystemWindow: "在独立窗口打开",
774
941
  systemWindowOpened: "已在独立窗口中打开",
775
942
  systemWindowFailed: "无法打开独立窗口",
@@ -777,7 +944,8 @@ window.__ModuleLoader__.load({
777
944
  systemWindowClosing: "正在关闭系统窗口…",
778
945
  systemWindowNativeOpened: "已进入系统窗口",
779
946
  systemWindowNativeClosed: "已关闭系统窗口",
780
- systemWindowUnsupported: "系统窗口仅支持 macOS 桌面版;可改用“进入独立窗口”。",
947
+ systemWindowUnsupported: "系统窗口仅支持 DSH 桌面版(macOS / Windows);可改用“进入独立窗口”。",
948
+ systemWindowWebView2Missing: "系统窗口需要 Microsoft Edge WebView2 运行时,请先安装再试;也可改用“进入独立窗口”。",
781
949
  menuGroup: "分屏插件",
782
950
  menuIndependentOpen: "进入独立窗口",
783
951
  menuIndependentClose: "退出独立窗口",
@@ -1370,6 +1538,14 @@ window.__ModuleLoader__.load({
1370
1538
  flex: none; height: 36px; display: flex; align-items: center; gap: 8px;
1371
1539
  padding: 0 4px 0 12px; border-bottom: 1px solid var(--dsw-alias-border-l2);
1372
1540
  cursor: grab; user-select: none;
1541
+ /* The stock conversation stays mounted behind this overlay and its header
1542
+ (class *__header) declares an Electron window-drag region
1543
+ (-webkit-app-region: drag) over the top of the column. Native drag
1544
+ regions swallow clicks BEFORE the DOM, so whenever a covered stock
1545
+ conversation exists — i.e. after restoring a split that was minimized to
1546
+ a conversation — our pane header buttons were click-dead. A no-drag
1547
+ region on our own header subtracts that area again. */
1548
+ -webkit-app-region: no-drag;
1373
1549
  }
1374
1550
  .dsv-pane-header:active { cursor: grabbing; }
1375
1551
  /* Slim header for narrow panes: one 30px row instead of the tall stock
@@ -2177,6 +2353,63 @@ window.__ModuleLoader__.load({
2177
2353
  @media (prefers-reduced-motion: reduce) {
2178
2354
  .dsv-drop-ghost { transition: none; }
2179
2355
  }
2356
+ /* ---- 0.12.0 "分屏视图" main panel -------------------------------------
2357
+ The same pane canvas as the overlay, but hosted in the layout's main
2358
+ column: the panel fills its host (absolute inset 0 inside a relative
2359
+ flex root), so no conversation-column geometry is needed. The picker
2360
+ page reuses the modal card/pick styles with a page-sized shell. ---- */
2361
+ .dsv-panel-root {
2362
+ position: relative; flex: 1; min-width: 0; min-height: 0;
2363
+ display: flex; flex-direction: column;
2364
+ background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary);
2365
+ font-family: var(--dsw-font-family, system-ui, sans-serif);
2366
+ }
2367
+ /* Warm-held canvas: mounted and still laid out, but invisible. Keeping the
2368
+ box in layout is deliberate: showing it again is then a visibility flip
2369
+ (no full re-layout of N conversation trees), which is what makes minimize
2370
+ ⇄ restore and panel ⇄ conversation switches feel instant inside the warm
2371
+ window. It also means a warm split keeps doing layout work for streaming
2372
+ output until the window expires, and then its tree is dropped. */
2373
+ .dsv-overlay.dsv-warm { visibility: hidden !important; }
2374
+ /* Invariant: a canvas that is not warm-held is visible AND clickable. A
2375
+ visible-but-click-through overlay (left behind by an interrupted warm
2376
+ hold or a hot-swapped older instance) is the worst state: the panes paint
2377
+ but every control inside them is dead. visibility:hidden already keeps
2378
+ the warm canvas out of hit-testing, so the warm rule no longer needs
2379
+ pointer-events at all, and this rule re-asserts interactivity whenever the
2380
+ class is gone. */
2381
+ .dsv-overlay:not(.dsv-warm) { visibility: visible !important; pointer-events: auto !important; }
2382
+ /* Belt and braces for the reported symptom: if an ancestor ever ends up with
2383
+ pointer-events:none, the pane header row (where every per-pane action
2384
+ lives) still wins its own hit-testing. */
2385
+ .dsv-overlay:not(.dsv-warm) .dsv-pane-header,
2386
+ .dsv-overlay:not(.dsv-warm) .dsv-pane-header .dsv-pane-btn { pointer-events: auto; }
2387
+ .dsv-panel-picker { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 24px; }
2388
+ .dsv-panel-card { width: min(620px, 100%); max-height: min(640px, 100%); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.16); }
2389
+ .dsv-panel-card-narrow { width: min(460px, 100%); }
2390
+ .dsv-panel-glyph { flex: none; display: grid; place-items: center; width: 22px; height: 22px; color: var(--dsw-static-deepseek-500); }
2391
+ /* Shown for the one/two frames in which the split-view panel has hidden the
2392
+ canvas but is still waiting for the deferred switch to the stock
2393
+ conversation (that switch mounts a whole native conversation). */
2394
+ .dsv-panel-loading { display: flex; align-items: center; gap: 9px; padding: 14px 18px 16px; font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-secondary); }
2395
+ .dsv-panel-spinner { flex: none; width: 13px; height: 13px; border-radius: 50%; border: 1.6px solid color-mix(in srgb, var(--dsw-static-deepseek-500) 35%, transparent); border-top-color: var(--dsw-static-deepseek-500); animation: dsv-spin .7s linear infinite; }
2396
+ @keyframes dsv-spin { to { transform: rotate(360deg); } }
2397
+ /* While the OS window is being resized, cut every pane transition: the
2398
+ shells' percentage widths already follow the live window edge, and a
2399
+ 180ms width/height transition would chase each resize frame (visible
2400
+ rubber-banding + extra layout per frame). The CSS reflow is the only
2401
+ work left; JS measurement waits for the settle. */
2402
+ html[data-dsv-resizing] .dsv-pane,
2403
+ html[data-dsv-resizing] .dsv-pane-wrap,
2404
+ html[data-dsv-resizing] .dsv-split-wrap,
2405
+ html[data-dsv-resizing] .dsv-split,
2406
+ html[data-dsv-resizing] .dsv-canvas,
2407
+ html[data-dsv-resizing] .dsv-overlay,
2408
+ html[data-dsv-resizing] .dsv-panel-root {
2409
+ transition: none !important;
2410
+ animation: none !important;
2411
+ }
2412
+
2180
2413
  /* ---- performance mode -------------------------------------------------
2181
2414
  One HTML attribute turns off every non-essential paint/animation cost:
2182
2415
  no card shadows, no focus glow, no fade/zoom transitions, no render-loop
@@ -2308,6 +2541,29 @@ window.__ModuleLoader__.load({
2308
2541
  h("rect", { x: 2.5, y: 9.1, width: 11, height: 5.4, rx: 2, stroke: "currentColor", strokeWidth: 1.4, fill: "none" }),
2309
2542
  );
2310
2543
  }
2544
+ /** The split-view identity glyph: two panes with the right one filled.
2545
+ One drawing is reused by the sidebar's "分屏视图" panel row, the
2546
+ bottom-left launcher button, the page itself and the session context
2547
+ menu, so the entry reads as the same thing everywhere. Drawn, not a
2548
+ font character: emoji/symbol codepoints are platform-font dependent
2549
+ (the old "⏻" restart row rendered as a tofu box on Windows). */
2550
+ function SplitViewGlyph({ size, active }) {
2551
+ const s = size || 16;
2552
+ return h(
2553
+ "svg",
2554
+ {
2555
+ viewBox: "0 0 16 16", width: s, height: s, fill: "none",
2556
+ stroke: "currentColor", strokeWidth: 1.4, "aria-hidden": true,
2557
+ },
2558
+ h("rect", { x: 1.8, y: 2, width: 12.4, height: 12, rx: 3 }),
2559
+ h("path", { d: "M8.4 2.6v10.8", strokeLinecap: "round" }),
2560
+ h("rect", {
2561
+ x: 9.7, y: 3.3, width: 3.4, height: 9.4, rx: 1.3,
2562
+ fill: "currentColor", stroke: "none", opacity: active === true ? 0.9 : 0.42,
2563
+ }),
2564
+ );
2565
+ }
2566
+
2311
2567
  /* Close is a plain drawn X. The stock close glyph is not guaranteed to
2312
2568
  exist in every primitives build — a missing primitive falls back to a
2313
2569
  single bullet, which is exactly the "small red dot" the close control
@@ -2326,6 +2582,64 @@ window.__ModuleLoader__.load({
2326
2582
  );
2327
2583
  }
2328
2584
 
2585
+ /** Restart glyph: a circular arrow drawn as SVG. The launcher menu used to
2586
+ render the U+23FB POWER SYMBOL, which is missing from the default
2587
+ Windows CJK font stack and showed as a mojibake/□ box there. */
2588
+ function RestartIcon({ size }) {
2589
+ const s = size || 14;
2590
+ return h(
2591
+ "svg",
2592
+ {
2593
+ viewBox: "0 0 16 16", width: s, height: s, fill: "none",
2594
+ stroke: "currentColor", strokeWidth: 1.5,
2595
+ strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true,
2596
+ },
2597
+ h("path", { d: "M13 8.2A5 5 0 1 1 11.5 3.8" }),
2598
+ h("path", { d: "M13.2 2.2v3.6H9.6" }),
2599
+ );
2600
+ }
2601
+
2602
+ /** Session-context-menu glyphs, all drawn in the same 16px frame and in
2603
+ currentColor so the stock menu's hover/muted colors flow through. */
2604
+ function TwoPaneGlyph({ size }) {
2605
+ const s = size || 14;
2606
+ return h(
2607
+ "svg",
2608
+ { viewBox: "0 0 16 16", width: s, height: s, fill: "none", stroke: "currentColor", strokeWidth: 1.3, "aria-hidden": true },
2609
+ h("rect", { x: 2, y: 2.4, width: 5.2, height: 11.2, rx: 1.8 }),
2610
+ h("rect", { x: 8.8, y: 2.4, width: 5.2, height: 11.2, rx: 1.8 }),
2611
+ );
2612
+ }
2613
+ function FloatPaneGlyph({ size }) {
2614
+ const s = size || 14;
2615
+ return h(
2616
+ "svg",
2617
+ { viewBox: "0 0 16 16", width: s, height: s, fill: "none", stroke: "currentColor", strokeWidth: 1.3, "aria-hidden": true },
2618
+ h("rect", { x: 1.8, y: 2, width: 9, height: 8.4, rx: 1.8, opacity: 0.5 }),
2619
+ h("rect", { x: 5.4, y: 5.6, width: 8.8, height: 8.4, rx: 1.8, fill: "var(--dsw-alias-bg-layer-1, transparent)" }),
2620
+ );
2621
+ }
2622
+ function WindowGlyph({ size }) {
2623
+ const s = size || 14;
2624
+ return h(
2625
+ "svg",
2626
+ { viewBox: "0 0 16 16", width: s, height: s, fill: "none", stroke: "currentColor", strokeWidth: 1.3, "aria-hidden": true },
2627
+ h("rect", { x: 1.9, y: 2.2, width: 12.2, height: 11.6, rx: 2.2 }),
2628
+ h("path", { d: "M1.9 6h12.2", strokeLinecap: "round" }),
2629
+ h("circle", { cx: 4.2, cy: 4.1, r: 0.65, fill: "currentColor", stroke: "none" }),
2630
+ );
2631
+ }
2632
+ function NativeWindowGlyph({ size }) {
2633
+ const s = size || 14;
2634
+ return h(
2635
+ "svg",
2636
+ { viewBox: "0 0 16 16", width: s, height: s, fill: "none", stroke: "currentColor", strokeWidth: 1.3, "aria-hidden": true },
2637
+ h("rect", { x: 1.6, y: 2.2, width: 12.8, height: 9.2, rx: 2 }),
2638
+ h("path", { d: "M5.4 14h5.2", strokeLinecap: "round" }),
2639
+ h("path", { d: "M8 11.4V14", strokeLinecap: "round" }),
2640
+ );
2641
+ }
2642
+
2329
2643
  // ---------------------------------------------------------------------
2330
2644
  // safety layer (1.6.0)
2331
2645
  //
@@ -2460,12 +2774,25 @@ window.__ModuleLoader__.load({
2460
2774
  maximized: null,
2461
2775
  minimized: readMinimized(),
2462
2776
  performance: readPerformanceMode(),
2777
+ resizeFreeze: readResizeFreeze(),
2778
+ // The canvas is mounted but hidden for a short warm window while the
2779
+ // split is minimized / another panel owns the column. Diagnostics only.
2780
+ panelWarm: false,
2781
+ // Number of times the canvas showed up in a dead (not hit-testable)
2782
+ // state after a restore and had to be repaired. Should stay 0.
2783
+ canvasRepairs: 0,
2463
2784
  updateReady: null,
2464
2785
  // One conversation in an in-app independent window. DSH Desktop has no
2465
2786
  // plugin-facing BrowserWindow API, so this replaces the old browser
2466
2787
  // window with a first-class surface inside the application.
2467
2788
  appWindow: null,
2468
2789
  };
2790
+ // True while the split-view panel is minimizing itself: its page stays
2791
+ // mounted for a couple of frames (the column switch is deferred so the
2792
+ // click paints first), and its "selecting the panel restores the split"
2793
+ // effect must not undo that minimize in the meantime.
2794
+ let splitPanelMinimizeInFlight = false;
2795
+
2469
2796
  const runtimeListeners = new Set();
2470
2797
  function runtimeSnapshot() {
2471
2798
  return runtimeState;
@@ -2519,6 +2846,16 @@ window.__ModuleLoader__.load({
2519
2846
  showPaneToast(t(next ? "performanceOn" : "performanceOff"), true);
2520
2847
  return next;
2521
2848
  }
2849
+ /** Toggle the live-resize canvas freeze (performance-mode refinement). */
2850
+ function setResizeFreeze(value) {
2851
+ const next = value === true;
2852
+ writeResizeFreeze(next);
2853
+ setRuntime({ resizeFreeze: next });
2854
+ return next;
2855
+ }
2856
+ function resizeFreezeOn() {
2857
+ return runtimeState.resizeFreeze !== false;
2858
+ }
2522
2859
 
2523
2860
  /** True only when the workspace may take over the viewport at all. The
2524
2861
  `geometryBlocked` flag closes the diagnosis's "invisible active" hole:
@@ -2662,8 +2999,12 @@ window.__ModuleLoader__.load({
2662
2999
  enabled: runtimeState.enabled,
2663
3000
  safeMode: runtimeState.safeMode,
2664
3001
  active: runtimeState.active,
3002
+ panelSelected: splitPanelActive(),
3003
+ panelWarm: runtimeState.panelWarm === true,
3004
+ canvasRepairs: runtimeState.canvasRepairs,
2665
3005
  minimized: runtimeState.minimized === true,
2666
3006
  performance: runtimeState.performance === true,
3007
+ resizeFreeze: resizeFreezeOn(),
2667
3008
  geometryBlocked: runtimeState.geometryBlocked === true,
2668
3009
  panes: (() => { try { return treeStore.leafIds().length; } catch { return 0; } })(),
2669
3010
  floats: (() => { try { return floatStore.ids(); } catch { return []; } })(),
@@ -2744,6 +3085,7 @@ window.__ModuleLoader__.load({
2744
3085
  try { leaves = treeStore.leafIds().length; } catch { return "unknown"; }
2745
3086
  if (leaves < 2) return "no-split";
2746
3087
  if (runtimeState.minimized === true) return "minimized";
3088
+ if (runtimeState.panelWarm === true) return "panel";
2747
3089
  if (runtimeState.active !== true || runtimeState.geometry.ok !== true) return "geometry";
2748
3090
  return null;
2749
3091
  }
@@ -8269,6 +8611,10 @@ window.__ModuleLoader__.load({
8269
8611
  };
8270
8612
  const tick = () => {
8271
8613
  if (inLiveReflow(pane)) { settleTicks = 0; raf = 0; return; }
8614
+ // While the window resizes / a divider drags every frame moves the
8615
+ // pane edge; skip the forced-layout pass per frame and let the
8616
+ // settle listener below run it once at the end of the gesture.
8617
+ if (layoutBusy()) { settleTicks = SETTLE_TICKS; raf = 0; return; }
8272
8618
  apply();
8273
8619
  if (stableCount >= 2) { settleTicks = 0; raf = 0; return; }
8274
8620
  if (settleTicks > 0) { settleTicks -= 1; raf = requestAnimationFrame(tick); }
@@ -8287,8 +8633,10 @@ window.__ModuleLoader__.load({
8287
8633
  mutation.observe(pane, { childList: true, subtree: true, attributes: true, attributeFilter: ["data-composer-card", "data-dsv-composer-card"] });
8288
8634
  }
8289
8635
  const perfTimer = performanceMode ? window.setInterval(schedule, 1500) : 0;
8636
+ const offSettle = onLayoutSettle(schedule);
8290
8637
  raf = requestAnimationFrame(tick);
8291
8638
  return () => {
8639
+ offSettle();
8292
8640
  if (raf !== 0) cancelAnimationFrame(raf);
8293
8641
  observer.disconnect();
8294
8642
  if (mutation !== null) mutation.disconnect();
@@ -8318,14 +8666,18 @@ window.__ModuleLoader__.load({
8318
8666
  const inner = innerRef.current;
8319
8667
  if (row === null || inner === null || typeof ResizeObserver !== "function") return;
8320
8668
  const measure = () => {
8321
- if (inLiveReflow(row)) return;
8669
+ if (inLiveReflow(row) || layoutBusy()) return;
8322
8670
  setOverflown(row.scrollWidth > row.clientWidth + 1);
8323
8671
  };
8324
8672
  measure();
8325
8673
  const observer = new ResizeObserver(measure);
8326
8674
  observer.observe(row);
8327
8675
  observer.observe(inner);
8328
- return () => observer.disconnect();
8676
+ const offSettle = onLayoutSettle(measure);
8677
+ return () => {
8678
+ offSettle();
8679
+ observer.disconnect();
8680
+ };
8329
8681
  // `entries`, not `entries.length`: the cells re-render with new text
8330
8682
  // (a growing tok/s or token count) without changing the cell COUNT, and
8331
8683
  // the overflow flag has to follow that or a longer value stays clipped
@@ -9386,18 +9738,57 @@ window.__ModuleLoader__.load({
9386
9738
  const shortRef = React.useRef(false);
9387
9739
  React.useEffect(() => {
9388
9740
  const el = frameRef.current;
9389
- if (el === null || typeof ResizeObserver !== "function") return;
9741
+ if (el === null || typeof ResizeObserver !== "function") return undefined;
9742
+ // 0.12.0: commit the pane box at most once per resize gesture. Each
9743
+ // commit re-renders the pane (header + re-hosted native conversation)
9744
+ // and re-runs the composer measurement; doing that for every live
9745
+ // window-resize frame is what made resizing feel janky even in
9746
+ // performance mode. The box is held while the layout is busy and read
9747
+ // once when the gesture settles.
9748
+ let pending = null;
9749
+ let raf = 0;
9750
+ const apply = () => {
9751
+ raf = 0;
9752
+ if (pending === null) return;
9753
+ const next = pending;
9754
+ pending = null;
9755
+ shortRef.current = next.h < 280 ? true : next.h > 340 ? false : shortRef.current;
9756
+ setPaneSize((prev) => (prev.w === next.w && prev.h === next.h ? prev : { w: next.w, h: next.h }));
9757
+ };
9758
+ const schedule = () => {
9759
+ if (raf !== 0) return;
9760
+ raf = window.requestAnimationFrame(apply);
9761
+ };
9390
9762
  const observer = new ResizeObserver((entries) => {
9391
9763
  if (inLiveReflow(el)) return;
9392
9764
  for (const entry of entries) {
9393
9765
  const w = Math.round(entry.contentRect.width);
9394
9766
  const h = Math.round(entry.contentRect.height);
9395
- shortRef.current = h < 280 ? true : h > 340 ? false : shortRef.current;
9396
- setPaneSize((prev) => (prev.w === w && prev.h === h ? prev : { w, h }));
9767
+ // A warm-hidden canvas (display:none) reports a zero box; keep the
9768
+ // last real geometry so restoring it needs no header/composer churn.
9769
+ if (w < 2 || h < 2) continue;
9770
+ pending = { w, h };
9397
9771
  }
9772
+ if (layoutBusy()) return;
9773
+ schedule();
9774
+ });
9775
+ const offSettle = onLayoutSettle(() => {
9776
+ try {
9777
+ const rect = el.getBoundingClientRect();
9778
+ if (rect.width <= 2 || rect.height <= 2) return;
9779
+ pending = { w: Math.round(rect.width), h: Math.round(rect.height) };
9780
+ } catch { return; }
9781
+ apply();
9398
9782
  });
9399
9783
  observer.observe(el);
9400
- return () => observer.disconnect();
9784
+ return () => {
9785
+ offSettle();
9786
+ if (raf !== 0) {
9787
+ try { window.cancelAnimationFrame(raf); } catch {}
9788
+ raf = 0;
9789
+ }
9790
+ observer.disconnect();
9791
+ };
9401
9792
  }, []);
9402
9793
  const narrow = paneSize.w > 0 && paneSize.w < 560;
9403
9794
  // Below this width the six header actions no longer fit: collapse them
@@ -9463,6 +9854,9 @@ window.__ModuleLoader__.load({
9463
9854
  // and passes are capped to ~12/s per pane so a streaming burst cannot
9464
9855
  // turn layout reads into per-commit work (S4).
9465
9856
  if (typeof document.visibilityState === "string" && document.visibilityState === "hidden") return;
9857
+ // A live resized window changes the box on every frame; measure once
9858
+ // when the gesture settles instead (see onLayoutSettle below).
9859
+ if (layoutBusy()) return;
9466
9860
  const now = Date.now();
9467
9861
  if (now - lastMeasureAt < 80) return;
9468
9862
  lastMeasureAt = now;
@@ -9582,14 +9976,21 @@ window.__ModuleLoader__.load({
9582
9976
  const mutation = !performanceMode && typeof MutationObserver === "function" ? new MutationObserver(schedule) : null;
9583
9977
  if (mutation !== null) mutation.observe(frame, { childList: true, subtree: true });
9584
9978
  const perfTimer = performanceMode ? window.setInterval(schedule, 1500) : 0;
9979
+ // One measure after a window resize / divider drag settles: the effect
9980
+ // stays mounted across width changes (no per-frame teardown), and the
9981
+ // learned card box is refreshed from the final geometry.
9982
+ const offSettle = onLayoutSettle(schedule);
9585
9983
  schedule();
9586
9984
  return () => {
9985
+ offSettle();
9587
9986
  if (raf !== 0) cancelAnimationFrame(raf);
9588
9987
  observer.disconnect();
9589
9988
  if (mutation !== null) mutation.disconnect();
9590
9989
  if (perfTimer !== 0) window.clearInterval(perfTimer);
9591
9990
  };
9592
- }, [paneSize.w, composerMode, performanceMode]);
9991
+ // No paneSize dependency: the observer + settle listener re-measure; the
9992
+ // old dependency re-created every observer on each resize frame.
9993
+ }, [composerMode, performanceMode]);
9593
9994
  // a composer is never narrower than this — narrower "boxes" are
9594
9995
  // transient seats, not the real input; fall back to stock geometry
9595
9996
  const cardBoxSane = cardBox !== null && cardBox.right - cardBox.left >= 160;
@@ -10242,6 +10643,10 @@ window.__ModuleLoader__.load({
10242
10643
  min: Math.max(0.04, MIN_PANE_PX / Math.max(1, total)),
10243
10644
  };
10244
10645
  setActive(true);
10646
+ // Pane boxes follow the pointer every move; mark the gesture so the
10647
+ // per-pane observers defer their measurement/derived state to the
10648
+ // release (the layout still tracks the pointer frame by frame).
10649
+ markDividerDrag(true);
10245
10650
  try {
10246
10651
  event.currentTarget.setPointerCapture(event.pointerId);
10247
10652
  } catch {}
@@ -10262,6 +10667,7 @@ window.__ModuleLoader__.load({
10262
10667
  if (dragRef.current === null || dragRef.current.pointerId !== event.pointerId) return;
10263
10668
  dragRef.current = null;
10264
10669
  setActive(false);
10670
+ markDividerDrag(false);
10265
10671
  treeStore.persistNow();
10266
10672
  if (event.currentTarget.hasPointerCapture(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);
10267
10673
  };
@@ -10812,6 +11218,13 @@ window.__ModuleLoader__.load({
10812
11218
  performanceMode() {
10813
11219
  return safeCall("performanceMode()", () => performanceModeOn(), false);
10814
11220
  },
11221
+ /** Toggle the live-resize canvas freeze (performance-mode refinement). */
11222
+ setResizeFreeze(flag) {
11223
+ return safeCall("setResizeFreeze()", () => setResizeFreeze(flag !== false), false);
11224
+ },
11225
+ resizeFreeze() {
11226
+ return safeCall("resizeFreeze()", () => resizeFreezeOn(), true);
11227
+ },
10815
11228
  /** Reload the page to pick up an updated client bundle (same as Ctrl+R). */
10816
11229
  reloadClient() {
10817
11230
  return safeCall("reloadClient()", () => { try { location.reload(); } catch {} return true; }, false);
@@ -11954,20 +12367,28 @@ window.__ModuleLoader__.load({
11954
12367
  return { left, top, width, height };
11955
12368
  }
11956
12369
 
11957
- /** Draggable, edge-snapping restore chip shown while the split is
11958
- minimized. It is confined to the conversation workspace (never the
11959
- sidebar or the macOS traffic-light corner) and defaults to the
11960
- workspace's bottom-left every time the split is minimized. */
12370
+ /** Draggable restore chip shown while the split is minimized. It is
12371
+ confined to the conversation workspace (never the sidebar or the macOS
12372
+ traffic-light corner), can be dropped anywhere, and snaps to the NEAREST
12373
+ EDGE on release — the position along that edge is kept, so it can sit
12374
+ anywhere on any edge instead of only in the four corners. The chosen
12375
+ position persists across minimize cycles. */
11961
12376
  function MinimizedChip() {
11962
12377
  const MARGIN = 18;
11963
12378
  const ref = React.useRef(null);
11964
12379
  const dragRef = React.useRef(null);
11965
12380
  const defaultPos = () => {
11966
- try { safeRemove(CHIP_KEY); } catch {}
11967
12381
  const work = chipWorkRect();
11968
12382
  const el = ref.current;
11969
12383
  const width = el ? el.offsetWidth : 229;
11970
12384
  const height = el ? el.offsetHeight : 42;
12385
+ const saved = readChipPos();
12386
+ if (saved !== null) {
12387
+ return {
12388
+ x: Math.min(Math.max(saved.x, work.left + MARGIN), Math.max(work.left + MARGIN, work.left + work.width - width - MARGIN)),
12389
+ y: Math.min(Math.max(saved.y, work.top + MARGIN), Math.max(work.top + MARGIN, work.top + work.height - height - MARGIN)),
12390
+ };
12391
+ }
11971
12392
  return {
11972
12393
  x: work.left + MARGIN,
11973
12394
  y: work.top + work.height - height - MARGIN,
@@ -11976,6 +12397,7 @@ window.__ModuleLoader__.load({
11976
12397
  const [pos, setPos] = React.useState(defaultPos);
11977
12398
  const [dragging, setDragging] = React.useState(false);
11978
12399
 
12400
+
11979
12401
  const clampToWork = React.useCallback((next) => {
11980
12402
  const work = chipWorkRect();
11981
12403
  const el = ref.current;
@@ -11988,6 +12410,9 @@ window.__ModuleLoader__.load({
11988
12410
  }, []);
11989
12411
 
11990
12412
  React.useEffect(() => {
12413
+ // Bring a restored position back inside the current work area after the
12414
+ // layout has been measured (the first render may predate it).
12415
+ setPos((current) => clampToWork(current));
11991
12416
  const onResize = () => setPos((current) => clampToWork(current));
11992
12417
  window.addEventListener("resize", onResize);
11993
12418
  return () => window.removeEventListener("resize", onResize);
@@ -12024,11 +12449,22 @@ window.__ModuleLoader__.load({
12024
12449
  const width = el.offsetWidth;
12025
12450
  const height = el.offsetHeight;
12026
12451
  const base = drag.last !== null ? drag.last : { x: el.offsetLeft, y: el.offsetTop };
12027
- const snapped = {
12028
- x: base.x + width / 2 < work.left + work.width / 2 ? work.left + MARGIN : work.left + work.width - width - MARGIN,
12029
- y: base.y + height / 2 < work.top + work.height / 2 ? work.top + MARGIN : work.top + work.height - height - MARGIN,
12030
- };
12031
- setPos(clampToWork(snapped));
12452
+ // Snap to the nearest EDGE only. The coordinate along that edge keeps
12453
+ // the drop position, so the chip can rest anywhere on any edge — not
12454
+ // just in the four corners.
12455
+ const leftDist = base.x - work.left;
12456
+ const rightDist = work.left + work.width - (base.x + width);
12457
+ const topDist = base.y - work.top;
12458
+ const bottomDist = work.top + work.height - (base.y + height);
12459
+ const nearest = Math.min(leftDist, rightDist, topDist, bottomDist);
12460
+ const snapped = { x: base.x, y: base.y };
12461
+ if (nearest === leftDist) snapped.x = work.left + MARGIN;
12462
+ else if (nearest === rightDist) snapped.x = work.left + work.width - width - MARGIN;
12463
+ else if (nearest === topDist) snapped.y = work.top + MARGIN;
12464
+ else snapped.y = work.top + work.height - height - MARGIN;
12465
+ const next = clampToWork(snapped);
12466
+ setPos(next);
12467
+ writeChipPos(next);
12032
12468
  };
12033
12469
 
12034
12470
  const style = { left: pos.x + "px", top: pos.y + "px", right: "auto", bottom: "auto" };
@@ -12060,14 +12496,21 @@ window.__ModuleLoader__.load({
12060
12496
  /** Always-mounted overlay-seat chrome: the safe-mode chip (with the tree
12061
12497
  kept), and a "could not start" chip when a persisted split cannot take
12062
12498
  the viewport (geometry fail-closed) — both dismissible and never over
12063
- stock controls. */
12064
- function PluginChrome() {
12499
+ stock controls. While the split-view panel owns the main column this
12500
+ chrome steps aside: the panel page renders its own state card. */
12501
+ function PluginChrome({ panelOwned }) {
12065
12502
  const runtime = useRuntime();
12066
12503
  const tree = useTree();
12067
12504
  const leaves = tree.root === null ? 0 : leafOf(tree.root, []).length;
12068
12505
  const wantsActive = runtime.enabled === true && leaves >= 2;
12069
12506
  const [settledBlocked, setSettledBlocked] = React.useState(false);
12507
+ // Unconditional hooks above; the panel-owned gate belongs here, after
12508
+ // them. An early return before useState/useEffect violated the hooks
12509
+ // order when the split-view panel was selected (React error #300: the
12510
+ // overlay slot entry crashed but still rendered).
12511
+ const panelOwnedUi = panelOwned === true;
12070
12512
  React.useEffect(() => {
12513
+ if (panelOwnedUi) return undefined;
12071
12514
  if (!wantsActive || runtime.safeMode === true || runtime.active === true) {
12072
12515
  setSettledBlocked(false);
12073
12516
  return undefined;
@@ -12078,7 +12521,8 @@ window.__ModuleLoader__.load({
12078
12521
  return () => {
12079
12522
  try { window.clearTimeout(timer); } catch {}
12080
12523
  };
12081
- }, [wantsActive, runtime.safeMode, runtime.active]);
12524
+ }, [wantsActive, runtime.safeMode, runtime.active, panelOwnedUi]);
12525
+ if (panelOwnedUi) return null;
12082
12526
  if (runtime.enabled !== true) return null;
12083
12527
  if (runtime.minimized === true && wantsActive) {
12084
12528
  return h(MinimizedChip, null);
@@ -12155,10 +12599,18 @@ window.__ModuleLoader__.load({
12155
12599
  const runtime = useRuntime();
12156
12600
  const appWindowState = runtime.appWindow;
12157
12601
  const appWindowOpen = appWindowState !== null && appWindowState !== undefined && appWindowState.minimized !== true;
12602
+ // The canvas ALWAYS lives here, the single live pane tree. Selecting the
12603
+ // "分屏视图" panel must not move it (the panel page below is empty and the
12604
+ // overlay covers exactly that column), otherwise every panel ⇄ split
12605
+ // switch would tear down and re-create N native conversations.
12606
+ const activePanelId = typeof props.usePanelInfo === "function"
12607
+ ? props.usePanelInfo((info) => (info !== null && info !== undefined ? info.activePanelId : null))
12608
+ : null;
12609
+ const panelOwned = activePanelId === SPLIT_PANEL_ID;
12158
12610
  return h(React.Fragment, null,
12159
12611
  h(WorkspaceBoundary, { key: "workspace-" + runtime.epoch },
12160
12612
  h(WorkspaceApp, Object.assign({}, props, { dsvAppWindowOpen: appWindowOpen }))),
12161
- h(PluginChrome, null),
12613
+ h(PluginChrome, { panelOwned }),
12162
12614
  h(WorkspaceBoundary, { key: "floats-" + runtime.epoch }, h(FloatLayer, null)),
12163
12615
  h(SplitLauncherLayer, null),
12164
12616
  h(AppWindowChip, null),
@@ -12170,6 +12622,48 @@ window.__ModuleLoader__.load({
12170
12622
  );
12171
12623
  }
12172
12624
 
12625
+ // ---- live window-resize canvas freeze (0.12.0) -------------------------
12626
+ // Every pane re-hosts the stock conversation view; those components
12627
+ // re-measure their own scrollers on every size change, so a live window
12628
+ // resize used to re-layout and re-measure N conversations on every frame
12629
+ // (the trace showed style-recalc + per-frame chat ticks as the dominant
12630
+ // cost, in performance mode too). Keeping the canvas's inner layout frozen
12631
+ // at the gesture-start size and scaling the rendered layer to the live
12632
+ // window edge removes that per-frame work: the transform is a compositor
12633
+ // operation, and one real relayout happens at settle. Tradeoff: text is
12634
+ // scaled (slightly stretched) for the duration of the drag and crisps up
12635
+ // when it ends.
12636
+ function clearCanvasFreeze(el) {
12637
+ if (el === null || el === undefined) return;
12638
+ try {
12639
+ el.style.transform = "";
12640
+ el.style.transformOrigin = "";
12641
+ el.style.width = "";
12642
+ el.style.height = "";
12643
+ el.style.right = "";
12644
+ el.style.bottom = "";
12645
+ el.style.willChange = "";
12646
+ } catch {}
12647
+ }
12648
+ /** Keep a frozen inner box but present it at the live target box. */
12649
+ function applyCanvasFreeze(el, frozenW, frozenH, targetW, targetH, left, top) {
12650
+ if (frozenW <= 2 || frozenH <= 2 || targetW <= 2 || targetH <= 2) return false;
12651
+ try {
12652
+ el.style.left = left + "px";
12653
+ el.style.top = top + "px";
12654
+ el.style.right = "auto";
12655
+ el.style.bottom = "auto";
12656
+ el.style.width = frozenW + "px";
12657
+ el.style.height = frozenH + "px";
12658
+ el.style.transformOrigin = "0 0";
12659
+ // Promote the frozen layer once per gesture: the per-frame scale is a
12660
+ // compositor transform, not a repaint of the conversation text.
12661
+ el.style.willChange = "transform";
12662
+ el.style.transform = "scale(" + (targetW / frozenW) + "," + (targetH / frozenH) + ")";
12663
+ return true;
12664
+ } catch { return false; }
12665
+ }
12666
+
12173
12667
  function WorkspaceApp(props) {
12174
12668
  // This component IS the plugin's root-scoped seat: `shell.overlay` is
12175
12669
  // declared `kind: list, scope: root`, so the renderer hands it the
@@ -12203,16 +12697,34 @@ window.__ModuleLoader__.load({
12203
12697
  // split tree (and its observers) quiet underneath.
12204
12698
  const appWindowOpen = props.dsvAppWindowOpen === true;
12205
12699
  const active = appWindowOpen !== true && leaves.length >= 2
12206
- && runtime.enabled === true && runtime.safeMode !== true;
12700
+ && runtime.enabled === true && runtime.safeMode !== true && minimized !== true;
12207
12701
  const [picker, setPicker] = React.useState(pickerRequest);
12208
12702
  const [bounds, setBounds] = React.useState({ left: 0, right: 0, top: 0, bottom: 0, ok: false });
12703
+ // Warm hold (0.13.0): the overlay canvas is the ONE live pane tree. When
12704
+ // the split is minimized, or another global panel (Plugins, Settings, …)
12705
+ // takes the main column, or the "分屏视图" panel is merely selected, the
12706
+ // canvas hides WITHOUT unmounting for WARM_HIDE_MS. Remounting N native
12707
+ // conversations (session retain, editor guards, transcript views) was the
12708
+ // latency behind every panel ⇄ split and minimize ⇄ restore switch; after
12709
+ // the warm window the tree is dropped so a long-hidden split stops
12710
+ // streaming in the background.
12711
+ const [warmCold, setWarmCold] = React.useState(false);
12209
12712
  const geometryWarnedRef = React.useRef(false);
12713
+ const overlayRef = React.useRef(null);
12210
12714
  // B3 "invisible active": the workspace is OPERATIONAL only when it can
12211
12715
  // actually render (>=2 panes AND a confident column measurement). All
12212
12716
  // input/observation paths gate on this, so a persisted split whose
12213
12717
  // geometry fails renders nothing and also does NOT eat Alt+T /
12214
12718
  // Alt+Shift+Arrow (the chrome chip explains the state instead).
12215
- const operational = active && bounds.ok === true && minimized !== true;
12719
+ // The split-view main panel is NOT a foreign panel: the canvas covers
12720
+ // exactly that column, so selecting it must not step aside.
12721
+ const otherPanelActive = activePanelId !== null && activePanelId !== undefined
12722
+ && activePanelId !== SPLIT_PANEL_ID;
12723
+ const visible = active === true && otherPanelActive !== true;
12724
+ const warmEligible = appWindowOpen !== true && leaves.length >= 2
12725
+ && runtime.enabled === true && runtime.safeMode !== true;
12726
+ const warmHold = warmEligible === true && warmCold !== true && visible !== true;
12727
+ const operational = visible && bounds.ok === true;
12216
12728
 
12217
12729
  // The DOM session-list source (0.2.0 path) observes the document only
12218
12730
  // while the workspace is operational — otherwise zero observation cost.
@@ -12230,6 +12742,92 @@ window.__ModuleLoader__.load({
12230
12742
  setRuntime({ active: operational });
12231
12743
  }, [operational]);
12232
12744
 
12745
+ // Surface the warm-hold state for health()/diagnostics.
12746
+ React.useEffect(() => {
12747
+ setRuntime({ panelWarm: warmHold === true });
12748
+ }, [warmHold]);
12749
+
12750
+ // Warm-hold timer: start it when the canvas becomes hidden and drop the
12751
+ // tree (cold) once the window expires; any show resets it.
12752
+ React.useEffect(() => {
12753
+ if (warmEligible !== true || visible === true) {
12754
+ if (warmCold !== false) setWarmCold(false);
12755
+ return undefined;
12756
+ }
12757
+ if (warmCold === true) return undefined;
12758
+ const timer = window.setTimeout(() => setWarmCold(true), WARM_HIDE_MS);
12759
+ return () => {
12760
+ try { window.clearTimeout(timer); } catch {}
12761
+ };
12762
+ }, [warmEligible, visible, warmCold]);
12763
+
12764
+ // Invariant: a canvas that (re)appears must be hit-testable. A warm hold
12765
+ // that never fully cleared, a window-resize freeze interrupted by a
12766
+ // minimize, an interrupted pane drag or a hot-swapped older instance can
12767
+ // leave interaction styles behind so that the panes paint but every
12768
+ // control inside them — most visibly the pane header buttons — is dead
12769
+ // after "restore split". Repair once, one frame after the canvas shows,
12770
+ // and count it in health().canvasRepairs (should stay 0).
12771
+ React.useEffect(() => {
12772
+ if (visible !== true) return undefined;
12773
+ let raf = 0;
12774
+ try {
12775
+ raf = window.requestAnimationFrame(() => {
12776
+ raf = 0;
12777
+ const el = overlayRef.current;
12778
+ if (el === null || el === undefined || !el.isConnected) return;
12779
+ let repaired = false;
12780
+ try {
12781
+ if (el.style.transform !== "" || el.style.width !== "") {
12782
+ // A freeze survived the hidden phase: drop it and re-write the
12783
+ // real box (React may skip style writes it believes unchanged).
12784
+ clearCanvasFreeze(el);
12785
+ const box = measureColumnBounds();
12786
+ if (box !== null && box !== undefined && box.ok === true) {
12787
+ el.style.left = box.left + "px";
12788
+ el.style.right = box.right + "px";
12789
+ el.style.top = box.top + "px";
12790
+ el.style.bottom = box.bottom + "px";
12791
+ }
12792
+ repaired = true;
12793
+ }
12794
+ const computed = window.getComputedStyle(el);
12795
+ if (computed.pointerEvents === "none" || computed.visibility === "hidden") {
12796
+ el.style.setProperty("pointer-events", "auto", "important");
12797
+ el.style.setProperty("visibility", "visible", "important");
12798
+ repaired = true;
12799
+ }
12800
+ for (const header of el.querySelectorAll(".dsv-pane-header")) {
12801
+ if (window.getComputedStyle(header).pointerEvents === "none") {
12802
+ header.style.setProperty("pointer-events", "auto", "important");
12803
+ repaired = true;
12804
+ }
12805
+ }
12806
+ // A pane whose drag-to-reflow was interrupted keeps the inline
12807
+ // pointer-events:none / opacity:0 and stays dead to the mouse.
12808
+ if (reflowState.active !== true && reflowState.settling !== true) {
12809
+ for (const source of el.querySelectorAll("[data-dsv-source]")) {
12810
+ source.removeAttribute("data-dsv-source");
12811
+ if (source.style !== null && source.style !== undefined) {
12812
+ source.style.pointerEvents = "";
12813
+ source.style.opacity = "";
12814
+ }
12815
+ repaired = true;
12816
+ }
12817
+ }
12818
+ } catch {}
12819
+ if (repaired) {
12820
+ try { setRuntime({ canvasRepairs: runtimeState.canvasRepairs + 1 }); } catch {}
12821
+ }
12822
+ });
12823
+ } catch {}
12824
+ return () => {
12825
+ if (raf !== 0) {
12826
+ try { window.cancelAnimationFrame(raf); } catch {}
12827
+ }
12828
+ };
12829
+ }, [visible]);
12830
+
12233
12831
  // One TOC grip per live pane (see tocGripSync): hide the portal copies
12234
12832
  // mounted by the hidden stock view / IM view and keep every pane's grip
12235
12833
  // inside that pane. Portals mount asynchronously, so a body childList
@@ -12273,15 +12871,6 @@ window.__ModuleLoader__.load({
12273
12871
  };
12274
12872
  }, [operational, runtime.performance]);
12275
12873
 
12276
- // A plugin/skills/settings panel replaces the whole main view. The split
12277
- // overlay would cover it, so step aside automatically and keep the tree;
12278
- // the restore chip brings the split back.
12279
- React.useEffect(() => {
12280
- if (!active || minimized) return;
12281
- if (activePanelId === null || activePanelId === undefined) return;
12282
- minimizeWorkspace();
12283
- }, [active, minimized, activePanelId]);
12284
-
12285
12874
  React.useEffect(() => {
12286
12875
  const onPicker = () => setPicker(pickerRequest);
12287
12876
  pickerListeners.add(onPicker);
@@ -12314,12 +12903,53 @@ window.__ModuleLoader__.load({
12314
12903
  // grow over stock UI. A measurement that stops being confident
12315
12904
  // deactivates the workspace (render gate) and the chrome chip says so.
12316
12905
  React.useEffect(() => {
12317
- if (!active || minimized) return undefined;
12906
+ if (!visible) return undefined;
12318
12907
  let raf = 0;
12908
+ let frozen = null;
12319
12909
  const apply = () => {
12320
12910
  raf = 0;
12321
12911
  const next = measureColumnBounds();
12322
12912
  noteGeometry(next);
12913
+ const overlayEl = overlayRef.current;
12914
+ // Freeze is a fluidity-first tradeoff (scaled text while dragging),
12915
+ // so it belongs to performance mode; normal mode keeps transitions
12916
+ // and a true per-frame reflow.
12917
+ if (overlayEl !== null && runtime.performance === true && runtime.resizeFreeze !== false && windowResizing()) {
12918
+ // Live resize: hold the pane layout at the gesture-start size and
12919
+ // scale the rendered layer to the current column box. No setBounds
12920
+ // here — React must not rewrite the insets mid-gesture.
12921
+ if (frozen !== null && (frozen.left !== next.left || frozen.top !== next.top)) {
12922
+ // The sidebar moved (auto-collapse breakpoint): rebase.
12923
+ clearCanvasFreeze(overlayEl);
12924
+ frozen = null;
12925
+ }
12926
+ if (frozen === null) {
12927
+ let rect = null;
12928
+ try { rect = overlayEl.getBoundingClientRect(); } catch {}
12929
+ if (rect !== null && rect.width > 2 && rect.height > 2) {
12930
+ frozen = { w: Math.round(rect.width), h: Math.round(rect.height), left: next.left, top: next.top };
12931
+ }
12932
+ }
12933
+ if (frozen !== null && next.ok) {
12934
+ const targetW = window.innerWidth - next.left - next.right;
12935
+ const targetH = window.innerHeight - next.top - next.bottom;
12936
+ if (applyCanvasFreeze(overlayEl, frozen.w, frozen.h, targetW, targetH, next.left, next.top)) return;
12937
+ }
12938
+ } else if (frozen !== null) {
12939
+ // Gesture over: drop the freeze AND write the final box directly.
12940
+ // React may skip a style write it believes is unchanged, and the
12941
+ // freeze left inline values (right/bottom/transform) behind.
12942
+ clearCanvasFreeze(overlayEl);
12943
+ frozen = null;
12944
+ if (overlayEl !== null) {
12945
+ try {
12946
+ overlayEl.style.left = next.left + "px";
12947
+ overlayEl.style.right = next.right + "px";
12948
+ overlayEl.style.top = next.top + "px";
12949
+ overlayEl.style.bottom = next.bottom + "px";
12950
+ } catch {}
12951
+ }
12952
+ }
12323
12953
  // One warning per unconfident episode (cleared once geometry is
12324
12954
  // back), next to a REAL measurement — the render gate used to warn
12325
12955
  // from the placeholder bounds on every boot.
@@ -12366,25 +12996,34 @@ window.__ModuleLoader__.load({
12366
12996
  }
12367
12997
  }
12368
12998
  } catch {}
12999
+ const offSettle = onLayoutSettle(() => {
13000
+ // Gesture over: the scheduled apply below drops the freeze and writes
13001
+ // the final box in the same frame, so the canvas never spends a
13002
+ // frame at the intermediate "explicit width cleared" state.
13003
+ schedule();
13004
+ });
12369
13005
  window.addEventListener("resize", schedule);
12370
13006
  document.addEventListener("visibilitychange", schedule);
12371
13007
  return () => {
13008
+ offSettle();
12372
13009
  if (raf !== 0) window.cancelAnimationFrame(raf);
12373
13010
  if (observer !== null) {
12374
13011
  try { observer.disconnect(); } catch {}
12375
13012
  }
12376
13013
  if (transitionHost !== null) transitionHost.removeEventListener("transitionend", schedule);
12377
13014
  if (fallbackInterval !== 0) window.clearInterval(fallbackInterval);
13015
+ const overlayEl = overlayRef.current;
13016
+ if (overlayEl !== null) clearCanvasFreeze(overlayEl);
12378
13017
  window.removeEventListener("resize", schedule);
12379
13018
  document.removeEventListener("visibilitychange", schedule);
12380
13019
  };
12381
- }, [active, runtime.performance]);
13020
+ }, [visible, runtime.performance, runtime.resizeFreeze]);
12382
13021
 
12383
13022
  // Crash-loop guard timers: a deliberate activation is persisted BEFORE it
12384
13023
  // can crash; a healthy, responsive workspace clears the counter after
12385
13024
  // HEALTHY_AFTER_MS and refreshes lastHealthyAt at most every 30s.
12386
13025
  React.useEffect(() => {
12387
- if (!active || bounds.ok !== true) return undefined;
13026
+ if (!visible || bounds.ok !== true) return undefined;
12388
13027
  markActivationAttempt();
12389
13028
  const healthyTimer = window.setTimeout(() => { markHealthy(); }, HEALTHY_AFTER_MS);
12390
13029
  const refreshTimer = window.setInterval(() => { refreshHealthy(); }, HEALTHY_REFRESH_MS);
@@ -12392,7 +13031,7 @@ window.__ModuleLoader__.load({
12392
13031
  try { window.clearTimeout(healthyTimer); } catch {}
12393
13032
  try { window.clearInterval(refreshTimer); } catch {}
12394
13033
  };
12395
- }, [active, bounds.ok]);
13034
+ }, [visible, bounds.ok]);
12396
13035
 
12397
13036
  // One-time first-split tip.
12398
13037
  React.useEffect(() => {
@@ -12598,16 +13237,24 @@ window.__ModuleLoader__.load({
12598
13237
  }
12599
13238
  };
12600
13239
 
12601
- // Render gates (after every hook): inactive/safe-mode/kill-switch →
12602
- // nothing; unconfident geometry → nothing. Both fail toward the stock
12603
- // view, never toward a wrong overlay.
12604
- if (!active) return null;
12605
- if (minimized) return null;
12606
- if (!bounds.ok) return null;
13240
+ // Render gates (after every hook). Hidden states keep the canvas mounted
13241
+ // (warm hold) so the expensive pane tree is reused on the way back; only
13242
+ // a cold hold / disabled / <2 panes / independent window unmounts it.
13243
+ if (visible !== true) {
13244
+ if (warmHold !== true || bounds.ok !== true) return null;
13245
+ return h("div", {
13246
+ ref: overlayRef,
13247
+ className: "dsv-overlay dsv-warm",
13248
+ style: { left: bounds.left, right: bounds.right, top: bounds.top, bottom: bounds.bottom },
13249
+ "aria-hidden": "true",
13250
+ }, h(WorkspaceBody, { generation }));
13251
+ }
13252
+ if (bounds.ok !== true) return null;
12607
13253
 
12608
13254
  return h(
12609
13255
  "div",
12610
13256
  {
13257
+ ref: overlayRef,
12611
13258
  className: "dsv-overlay",
12612
13259
  style: { left: bounds.left, right: bounds.right, top: bounds.top, bottom: bounds.bottom },
12613
13260
  tabIndex: -1,
@@ -12629,6 +13276,47 @@ window.__ModuleLoader__.load({
12629
13276
  );
12630
13277
  }
12631
13278
 
13279
+ /** The "分屏视图" main-panel page. The live canvas is the shell.overlay
13280
+ workspace, which stays mounted across panel ⇄ conversation switches so the
13281
+ native pane tree is never re-created for a mere navigation; this page is
13282
+ only the page state — the inline add-split picker while fewer than two
13283
+ conversations are staged, and an empty column the canvas covers once the
13284
+ split exists. */
13285
+ function SplitPanelView() {
13286
+ const runtime = useRuntime();
13287
+ const state = useTree();
13288
+ // Selecting the panel is also the restore affordance for a minimized
13289
+ // split: clear the flag so the (warm, still mounted) canvas shows again.
13290
+ React.useEffect(() => {
13291
+ if (runtime.minimized !== true || splitPanelMinimizeInFlight === true) return;
13292
+ try {
13293
+ setRuntime({ minimized: false });
13294
+ writeMinimized(false);
13295
+ } catch {}
13296
+ }, [runtime.minimized]);
13297
+ const leaves = state.root === null ? [] : leafOf(state.root, []);
13298
+ const splitReady = leaves.length >= 2 && runtime.enabled === true && runtime.safeMode !== true;
13299
+ // Panel-minimize: the canvas is already hidden and the column switch to a
13300
+ // native conversation is deferred one task (that mount costs ~0.5s). Paint
13301
+ // this card in the gap so the click never leaves a frozen blank column.
13302
+ if (splitReady && runtime.minimized === true) {
13303
+ return h("div", { className: "dsv-panel-picker", "data-plugin": PLUGIN_ID },
13304
+ h("div", { className: "dsv-modal dsv-panel-card dsv-panel-card-narrow" },
13305
+ h("div", { className: "dsv-modal-head" },
13306
+ h("span", { className: "dsv-panel-glyph", "aria-hidden": "true" }, h(SplitViewGlyph, { size: 18 })),
13307
+ h("span", { className: "dsv-modal-title" }, t("returningTitle")),
13308
+ ),
13309
+ h("div", { className: "dsv-panel-loading" },
13310
+ h("span", { className: "dsv-panel-spinner", "aria-hidden": "true" }),
13311
+ h("span", null, t("returningHint")),
13312
+ ),
13313
+ ),
13314
+ );
13315
+ }
13316
+ return h("div", { className: "dsv-panel-root", "data-plugin": PLUGIN_ID },
13317
+ splitReady ? null : h(PanelSplitPicker, null));
13318
+ }
13319
+
12632
13320
  // ---------------------------------------------------------------------
12633
13321
  // inactive-mode drag bridge — the split entry point while the overlay is
12634
13322
  // off. Dragging a conversation from the stock sidebar onto the
@@ -12939,6 +13627,32 @@ window.__ModuleLoader__.load({
12939
13627
  try { window.setTimeout(() => { try { rightbarSelfHeal(); } catch {} }, delay === undefined ? 400 : delay); } catch {}
12940
13628
  }
12941
13629
  function minimizeWorkspace() {
13630
+ // While the split-view panel owns the main column, "minimize" means
13631
+ // "step back to the conversation": hide the split and return the column
13632
+ // to the stock conversation view in the same commit (the panel is
13633
+ // leaving, so there is no overlay to fade).
13634
+ if (splitPanelActive()) {
13635
+ splitPanelMinimizeInFlight = true;
13636
+ try { setRuntime({ minimized: true }); writeMinimized(true); } catch {}
13637
+ // Leaving the plugin page for the stock conversation mounts a whole
13638
+ // native conversation synchronously (~0.5s on a live desktop). Run it
13639
+ // as its own task so the click paints immediately: the canvas hides and
13640
+ // the chip + "returning to the conversation" card appear first; only
13641
+ // then does the column switch (and its mount) block.
13642
+ const switchPanel = () => {
13643
+ try { leaveSplitPanel(); } catch {}
13644
+ splitPanelMinimizeInFlight = false;
13645
+ scheduleRightbarHeal(450);
13646
+ };
13647
+ try {
13648
+ window.requestAnimationFrame(() => {
13649
+ window.requestAnimationFrame(switchPanel);
13650
+ });
13651
+ } catch {
13652
+ switchPanel();
13653
+ }
13654
+ return;
13655
+ }
12942
13656
  const finish = () => {
12943
13657
  try { setRuntime({ minimized: true }); writeMinimized(true); } catch {}
12944
13658
  scheduleRightbarHeal(450);
@@ -12958,10 +13672,19 @@ window.__ModuleLoader__.load({
12958
13672
  setRuntime({ minimized: false });
12959
13673
  writeMinimized(false);
12960
13674
  } catch {}
13675
+ // Exiting from the split-view panel returns the main column to the
13676
+ // stock conversation view instead of leaving an empty picker page.
13677
+ leaveSplitPanel();
12961
13678
  // The stock view owns the rightbar again; repair a stale open/collapse
12962
13679
  // state the split teardown may have left behind.
12963
13680
  scheduleRightbarHeal(450);
12964
13681
  };
13682
+ // The panel page leaves with its own router switch; fading the canvas
13683
+ // first would only delay the return to the conversation.
13684
+ if (splitPanelActive()) {
13685
+ finish();
13686
+ return;
13687
+ }
12965
13688
  try {
12966
13689
  const overlay = document.querySelector(".dsv-overlay");
12967
13690
  const target = overlay !== null && overlay !== undefined
@@ -13381,6 +14104,7 @@ window.__ModuleLoader__.load({
13381
14104
  {
13382
14105
  id: "split-plugin",
13383
14106
  label: t("menuGroup"),
14107
+ icon: { key: CONTEXT_ICON_PANEL },
13384
14108
  separatorBefore: true,
13385
14109
  children: [
13386
14110
  {
@@ -13388,6 +14112,7 @@ window.__ModuleLoader__.load({
13388
14112
  // pending pick) exits, everything else joins.
13389
14113
  id: "split",
13390
14114
  label: t(splitMember ? "exitSplit" : "menuAddToSplit"),
14115
+ icon: { key: CONTEXT_ICON_SPLIT },
13391
14116
  run: () => {
13392
14117
  if (splitMember) removeSessionFromSplit(id);
13393
14118
  else if (floatStore.has(id)) dockFloatToSplit(id);
@@ -13397,6 +14122,7 @@ window.__ModuleLoader__.load({
13397
14122
  {
13398
14123
  id: "float",
13399
14124
  label: t(floating ? "menuFloatClose" : "menuFloatOpen"),
14125
+ icon: { key: CONTEXT_ICON_FLOAT },
13400
14126
  run: () => {
13401
14127
  if (floatStore.has(id)) closeFloatWindow(id);
13402
14128
  else floatSession(id);
@@ -13405,6 +14131,7 @@ window.__ModuleLoader__.load({
13405
14131
  {
13406
14132
  id: "independent",
13407
14133
  label: t(independent ? "menuIndependentClose" : "menuIndependentOpen"),
14134
+ icon: { key: CONTEXT_ICON_WINDOW },
13408
14135
  failureLabel: t("systemWindowFailed"),
13409
14136
  run: () => {
13410
14137
  if (independent) closeAppWindowFor(id);
@@ -13414,6 +14141,7 @@ window.__ModuleLoader__.load({
13414
14141
  {
13415
14142
  id: "native",
13416
14143
  label: t(nativeWindow ? "menuNativeClose" : "menuNativeOpen"),
14144
+ icon: { key: CONTEXT_ICON_NATIVE },
13417
14145
  failureLabel: t("systemWindowFailed"),
13418
14146
  run: () => requestSystemWindow(id, nativeWindow ? "close" : "open"),
13419
14147
  },
@@ -13490,6 +14218,35 @@ window.__ModuleLoader__.load({
13490
14218
  );
13491
14219
  }
13492
14220
 
14221
+ /** The pickable-conversation roster shared by the modal "添加分屏" dialog
14222
+ and the split-view panel's inline picker: real, non-blank, non-subagent
14223
+ chat sessions plus any already-selected id that dropped out of the live
14224
+ list (so it can still be unchecked). */
14225
+ function splitPickableItems(sessions, selected) {
14226
+ const items = [];
14227
+ const seen = new Set();
14228
+ if (sessions !== null && sessions !== undefined && Array.isArray(sessions.ids)) {
14229
+ for (const id of sessions.ids) {
14230
+ const summary = sessions.byId ? sessions.byId[id] : undefined;
14231
+ if (summary === undefined || summary === null) continue;
14232
+ if (summary.parentId !== undefined) continue;
14233
+ if (summary.origin === "subagent" || summary.blank === true) continue;
14234
+ if (id.indexOf("session-") !== 0) continue;
14235
+ seen.add(id);
14236
+ items.push({ id, summary, title: summary.displayTitle || summary.title || id });
14237
+ }
14238
+ }
14239
+ for (const id of Array.isArray(selected) ? selected : []) {
14240
+ if (seen.has(id)) continue;
14241
+ seen.add(id);
14242
+ items.push({ id, summary: null, title: id });
14243
+ }
14244
+ // Same ordering as the stock conversation list: most recently updated
14245
+ // first, re-sorted from the live snapshot while the picker is open.
14246
+ items.sort((a, b) => (Number(b.summary && b.summary.updatedAt) || 0) - (Number(a.summary && a.summary.updatedAt) || 0));
14247
+ return items;
14248
+ }
14249
+
13493
14250
  /** Multi-select "添加分屏" dialog. Opened from the footer menu, so the
13494
14251
  current members stay selected and can be unchecked (the final selection
13495
14252
  rebuilds the split) or extended with more conversations. */
@@ -13511,29 +14268,9 @@ window.__ModuleLoader__.load({
13511
14268
  }, []);
13512
14269
 
13513
14270
  const pendingIds = pendingSplitStore.ids();
13514
- const items = [];
13515
- const seen = new Set();
13516
- if (sessions !== null && sessions !== undefined && Array.isArray(sessions.ids)) {
13517
- for (const id of sessions.ids) {
13518
- const summary = sessions.byId ? sessions.byId[id] : undefined;
13519
- if (summary === undefined || summary === null) continue;
13520
- if (summary.parentId !== undefined) continue;
13521
- if (summary.origin === "subagent" || summary.blank === true) continue;
13522
- if (id.indexOf("session-") !== 0) continue;
13523
- seen.add(id);
13524
- items.push({ id, summary, title: summary.displayTitle || summary.title || id });
13525
- }
13526
- }
13527
- // A pane session the list no longer carries (archived/hidden) must stay
13528
- // visible, otherwise it could never be unchecked.
13529
- for (const id of selected) {
13530
- if (seen.has(id)) continue;
13531
- seen.add(id);
13532
- items.push({ id, summary: null, title: id });
13533
- }
13534
14271
  const needle = query.trim().toLowerCase();
13535
- const visible = items.filter((item) => needle === "" || item.title.toLowerCase().includes(needle));
13536
- visible.sort((a, b) => (Number(b.summary && b.summary.updatedAt) || 0) - (Number(a.summary && a.summary.updatedAt) || 0));
14272
+ const visible = splitPickableItems(sessions, selected)
14273
+ .filter((item) => needle === "" || item.title.toLowerCase().includes(needle));
13537
14274
 
13538
14275
  const toggle = (id) => setSelected((previous) => (previous.indexOf(id) === -1
13539
14276
  ? previous.concat([id])
@@ -13638,6 +14375,110 @@ window.__ModuleLoader__.load({
13638
14375
  );
13639
14376
  }
13640
14377
 
14378
+ /** The split-view panel's own page while it cannot show the canvas yet.
14379
+ Three states share one card shell: the kill switch is off (offer Enable),
14380
+ the crash guard paused the split (offer Retry), or fewer than two
14381
+ conversations are staged (the multi-select picker). Confirming the
14382
+ picker with two or more conversations builds the split immediately, so
14383
+ the panel turns into the canvas without leaving the page. */
14384
+ function PanelSplitPicker() {
14385
+ const runtime = useRuntime();
14386
+ const sessions = useSessionsList();
14387
+ const tree = useTree();
14388
+ const treeLeaves = tree === null || tree === undefined || tree.root === null ? [] : leafOf(tree.root, []);
14389
+ const initial = treeLeaves.length > 0 ? treeLeaves.slice() : pendingSplitStore.ids().slice();
14390
+ const [selected, setSelected] = React.useState(initial);
14391
+ const [query, setQuery] = React.useState("");
14392
+ const pendingIds = pendingSplitStore.ids();
14393
+ const items = splitPickableItems(sessions, selected);
14394
+ React.useEffect(() => {
14395
+ try {
14396
+ if (sessionsListSource !== undefined && sessionsListSource !== null
14397
+ && typeof sessionsListSource.refresh === "function") sessionsListSource.refresh();
14398
+ } catch {}
14399
+ }, []);
14400
+ const card = (titleText, bodyText, action, options) => h("div", { className: "dsv-panel-picker", "data-plugin": PLUGIN_ID },
14401
+ h("div", { className: "dsv-modal dsv-panel-card dsv-panel-card-narrow" },
14402
+ h("div", { className: "dsv-modal-head" },
14403
+ h("span", { className: "dsv-panel-glyph", "aria-hidden": "true" }, h(SplitViewGlyph, { size: 18 })),
14404
+ h("span", { className: "dsv-modal-title" }, titleText),
14405
+ ),
14406
+ bodyText !== null && bodyText !== undefined ? h("div", { className: "dsv-modal-hint" }, bodyText) : null,
14407
+ action !== null && action !== undefined
14408
+ ? h("div", { className: "dsv-modal-foot" },
14409
+ h("span", { className: "dsv-modal-count" }, options !== undefined && options.note !== undefined ? options.note : ""),
14410
+ h("button", { type: "button", className: "dsv-modal-btn accent", onClick: action.run }, action.label),
14411
+ )
14412
+ : null,
14413
+ ),
14414
+ );
14415
+ if (runtime.enabled !== true) {
14416
+ return card(t("panelDisabledTitle"), t("panelDisabledBody"), {
14417
+ label: t("panelEnable"),
14418
+ run: () => { try { setEnabled(true); } catch {} },
14419
+ });
14420
+ }
14421
+ if (runtime.safeMode === true) {
14422
+ return card(t("panelSafeTitle"), t("panelSafeBody"), {
14423
+ label: t("retryLabel"),
14424
+ run: () => { try { retryWorkspace(); } catch {} },
14425
+ });
14426
+ }
14427
+ const needle = query.trim().toLowerCase();
14428
+ const visible = items.filter((item) => needle === "" || item.title.toLowerCase().includes(needle));
14429
+ const toggle = (id) => setSelected((previous) => (previous.indexOf(id) === -1
14430
+ ? previous.concat([id])
14431
+ : previous.filter((value) => value !== id)));
14432
+ const confirm = () => {
14433
+ if (selected.length < 2) {
14434
+ showPaneToast(t("panelNeedTwo"), true);
14435
+ return;
14436
+ }
14437
+ if (!buildSplitFromSessions(selected)) showPaneToast(t("panelNeedTwo"), true);
14438
+ };
14439
+ return h("div", { className: "dsv-panel-picker", "data-plugin": PLUGIN_ID },
14440
+ h("div", { className: "dsv-modal dsv-panel-card" },
14441
+ h("div", { className: "dsv-modal-head" },
14442
+ h("span", { className: "dsv-panel-glyph", "aria-hidden": "true" }, h(SplitViewGlyph, { size: 18 })),
14443
+ h("span", { className: "dsv-modal-title" }, t("panelPickTitle")),
14444
+ ),
14445
+ h("div", { className: "dsv-modal-hint" }, t("panelPickHint")),
14446
+ h("input", {
14447
+ className: "dsv-modal-search",
14448
+ type: "search",
14449
+ placeholder: t("railSearch"),
14450
+ value: query,
14451
+ onChange: (event) => setQuery(event.target.value),
14452
+ }),
14453
+ h("div", { className: "dsv-modal-body" },
14454
+ visible.length === 0 ? h("div", { className: "dsv-pick-empty" }, t("panelNoSessions")) : null,
14455
+ visible.map((item) => h(SplitPickRow, {
14456
+ key: item.id,
14457
+ item: {
14458
+ title: item.title,
14459
+ sub: item.summary !== null && item.summary.cwd !== undefined ? basenameOf(item.summary.cwd) : "",
14460
+ tag: treeLeaves.indexOf(item.id) !== -1
14461
+ ? "addSplitInSplit"
14462
+ : (pendingIds.indexOf(item.id) !== -1 ? "addSplitPending" : null),
14463
+ },
14464
+ checked: selected.indexOf(item.id) !== -1,
14465
+ onToggle: () => toggle(item.id),
14466
+ })),
14467
+ ),
14468
+ h("div", { className: "dsv-modal-foot" },
14469
+ h("span", { className: "dsv-modal-count" },
14470
+ selected.length < 2 ? t("panelNeedTwo") : t("addSplitSelected", { n: selected.length })),
14471
+ h("button", {
14472
+ type: "button",
14473
+ className: "dsv-modal-btn accent",
14474
+ disabled: selected.length < 2,
14475
+ onClick: confirm,
14476
+ }, t("panelPickConfirm")),
14477
+ ),
14478
+ ),
14479
+ );
14480
+ }
14481
+
13641
14482
  function SplitLauncherMenu({ request }) {
13642
14483
  const runtime = useRuntime();
13643
14484
  const tree = useTree();
@@ -13723,7 +14564,10 @@ window.__ModuleLoader__.load({
13723
14564
  () => { closeLauncher(); setPerformanceMode(runtime.performance !== true); }),
13724
14565
  row("reload", "↻", t("refreshInterface"), () => { closeLauncher(); try { location.reload(); } catch {} }),
13725
14566
  desktopShell()
13726
- ? row("restart", "⏻", t("restartApp"), () => { closeLauncher(); openRestartDialog(); })
14567
+ // Drawn SVG, not the U+23FB power symbol: that codepoint is missing
14568
+ // from the default CJK font stack on Windows and rendered as a
14569
+ // mojibake box in the launcher menu.
14570
+ ? row("restart", h(RestartIcon, { size: 15 }), t("restartApp"), () => { closeLauncher(); openRestartDialog(); })
13727
14571
  : null,
13728
14572
  row("help", "?", t("helpOpen"), () => { closeLauncher(); openHelp(); }),
13729
14573
  row("reset", "↺", t("menuResetSplit"), () => { closeLauncher(); resetSplitEnvironment(); }, { danger: true }),
@@ -13785,6 +14629,7 @@ window.__ModuleLoader__.load({
13785
14629
  h("section", { className: "dsv-settings-group" },
13786
14630
  h("h3", { className: "dsv-settings-group-title" }, t("settingsActions")),
13787
14631
  h("div", { className: "dsv-settings-actions" },
14632
+ button("panel", t("panelTitle"), () => closeThen(() => selectSplitPanel())),
13788
14633
  button("add", t("menuAddSplit"), () => closeThen(() => openAddSplitDialog("footer")), { accent: true }),
13789
14634
  button("exit", t("exitSplit"), () => { try { exitWorkspace(); } catch {} }, { disabled: !active }),
13790
14635
  button("minimize", t("menuMinimizeSplit"), () => { try { minimizeWorkspace(); } catch {} }, { disabled: !active || runtime.minimized === true }),
@@ -13847,7 +14692,7 @@ window.__ModuleLoader__.load({
13847
14692
  "aria-haspopup": "menu",
13848
14693
  onClick: (event) => openLauncherMenu(event.currentTarget),
13849
14694
  },
13850
- h(SplitIconV, { size: 15 }),
14695
+ h(SplitViewGlyph, { size: 15 }),
13851
14696
  h("span", { className: "dsv-fallback-label" }, t("fallbackLauncher")),
13852
14697
  pending.length > 0 ? h("span", { className: "dsv-footer-badge" }, String(pending.length)) : null,
13853
14698
  );
@@ -13918,6 +14763,9 @@ window.__ModuleLoader__.load({
13918
14763
  React.useEffect(() => {
13919
14764
  if (count === 0) return undefined;
13920
14765
  const clampAll = () => {
14766
+ // Window resizes clamp once at settle (the settle listener below);
14767
+ // this path used to re-measure the column on every resize frame.
14768
+ if (layoutBusy()) return;
13921
14769
  const work = chipWorkRect();
13922
14770
  for (const win of floatStore.getSnapshot().windows) {
13923
14771
  const next = clampFloatRect(win, work);
@@ -13928,6 +14776,7 @@ window.__ModuleLoader__.load({
13928
14776
  };
13929
14777
  clampAll();
13930
14778
  window.addEventListener("resize", clampAll);
14779
+ const offSettle = onLayoutSettle(clampAll);
13931
14780
  // The column can change without a window resize (right-sidebar open/
13932
14781
  // close, shell layout transitions), so re-clamp on a low-frequency
13933
14782
  // backstop while floats exist. setRect is a no-op when nothing moved.
@@ -13935,6 +14784,7 @@ window.__ModuleLoader__.load({
13935
14784
  const timer = performanceModeOn() ? 0 : window.setInterval(clampAll, 1000);
13936
14785
  return () => {
13937
14786
  window.removeEventListener("resize", clampAll);
14787
+ offSettle();
13938
14788
  if (timer !== 0) {
13939
14789
  try { window.clearInterval(timer); } catch {}
13940
14790
  }
@@ -14216,14 +15066,233 @@ window.__ModuleLoader__.load({
14216
15066
  window.setTimeout(attempt, 200);
14217
15067
  }
14218
15068
 
15069
+ // ---------------------------------------------------------------------
15070
+ // CSS anchor positioning fallback (native system window only)
15071
+ //
15072
+ // DSH's menus place portaled panels with CSS anchor positioning
15073
+ // (`position-anchor` + `anchor()` insets). Chromium implements it; WebKit /
15074
+ // WKWebView does not, so every dropdown loses its insets and falls back to
15075
+ // `top: 12px; left: 12px` — the top-left corner of the window, on top of the
15076
+ // header. This fallback reproduces the placement from the trigger that
15077
+ // opened the panel, using the placement attributes the stock Menu primitive
15078
+ // already publishes (`data-anchor-side` / `data-anchor-align`) and the
15079
+ // anchor custom properties the model selector keeps inline. It is inert on
15080
+ // engines with real anchor positioning support.
15081
+ // ---------------------------------------------------------------------
15082
+
15083
+ // dsv-anchor-fallback:start — self-contained fallback (WKWebView fixture test).
15084
+ /** True when the engine can lay out `position: fixed` panels from anchors. */
15085
+ function cssAnchorPositioningSupported() {
15086
+ try {
15087
+ return typeof CSS !== "undefined"
15088
+ && typeof CSS.supports === "function"
15089
+ && CSS.supports("position-anchor: --dsv-probe")
15090
+ && CSS.supports("top: anchor(top)");
15091
+ } catch {
15092
+ return false;
15093
+ }
15094
+ }
15095
+
15096
+ // dsv-anchor-math:start — pure placement math (unit-tested in test.mjs).
15097
+ function anchorPanelInsets(anchorRect, viewport, side, align, gap) {
15098
+ const margin = 12;
15099
+ const width = Math.max(0, viewport.width);
15100
+ const height = Math.max(0, viewport.height);
15101
+ const insets = {
15102
+ left: null, right: null, top: null, bottom: null,
15103
+ maxWidth: Math.max(120, width - margin * 2), maxHeight: null,
15104
+ };
15105
+ if (side === "top" || side === "bottom") {
15106
+ const space = side === "top"
15107
+ ? anchorRect.top - gap - margin
15108
+ : height - anchorRect.bottom - gap - margin;
15109
+ insets.maxHeight = Math.max(80, Math.min(space, height - margin * 2));
15110
+ if (side === "top") insets.bottom = height - anchorRect.top + gap;
15111
+ else insets.top = anchorRect.bottom + gap;
15112
+ if (align === "end") insets.right = Math.max(margin, width - anchorRect.right);
15113
+ else insets.left = Math.max(margin, anchorRect.left);
15114
+ return insets;
15115
+ }
15116
+ if (side === "right" || side === "left") {
15117
+ insets.top = Math.max(margin, Math.min(anchorRect.top, height - margin - 80));
15118
+ insets.maxHeight = Math.max(80, height - margin * 2);
15119
+ if (side === "right") insets.left = anchorRect.right + gap;
15120
+ else insets.right = Math.max(margin, width - anchorRect.left + gap);
15121
+ return insets;
15122
+ }
15123
+ return null;
15124
+ }
15125
+ // dsv-anchor-math:end
15126
+
15127
+ /** Apply one computed placement to a portaled panel. */
15128
+ function applyAnchorPanelInsets(panel, anchor, side, align, gap) {
15129
+ const rect = anchor.getBoundingClientRect();
15130
+ if (rect.width <= 0 && rect.height <= 0) return false;
15131
+ const insets = anchorPanelInsets(rect, {
15132
+ width: document.documentElement.clientWidth || window.innerWidth || 0,
15133
+ height: document.documentElement.clientHeight || window.innerHeight || 0,
15134
+ }, side, align, gap);
15135
+ if (insets === null) return false;
15136
+ const style = panel.style;
15137
+ style.position = "fixed";
15138
+ style.top = insets.top === null ? "auto" : insets.top + "px";
15139
+ style.bottom = insets.bottom === null ? "auto" : insets.bottom + "px";
15140
+ style.left = insets.left === null ? "auto" : insets.left + "px";
15141
+ style.right = insets.right === null ? "auto" : insets.right + "px";
15142
+ style.maxHeight = insets.maxHeight + "px";
15143
+ style.maxWidth = insets.maxWidth + "px";
15144
+ try { panel.dataset.dsvAnchorFallback = ""; } catch {}
15145
+ return true;
15146
+ }
15147
+
15148
+ /** The trigger a panel points at, when DSH shares it as a custom property
15149
+ with the trigger (the model selector does: --dsh-model-anchor). */
15150
+ function anchorFromCustomProperty(panel) {
15151
+ if (panel.style === undefined) return null;
15152
+ let name = "";
15153
+ let value = "";
15154
+ for (let index = 0; index < panel.style.length; index += 1) {
15155
+ const property = panel.style.item(index);
15156
+ if (typeof property !== "string" || !property.startsWith("--")) continue;
15157
+ const candidate = String(panel.style.getPropertyValue(property) || "").trim();
15158
+ if (!candidate.startsWith("--")) continue;
15159
+ name = property;
15160
+ value = candidate;
15161
+ break;
15162
+ }
15163
+ if (name === "" || value === "") return null;
15164
+ for (const node of document.querySelectorAll("[style]")) {
15165
+ if (node === panel || panel.contains(node)) continue;
15166
+ if (node.hasAttribute("data-menu-backing")) continue;
15167
+ if (String(node.style.getPropertyValue(name) || "").trim() !== value) continue;
15168
+ const rect = node.getBoundingClientRect();
15169
+ if (rect.width > 0 || rect.height > 0) return node;
15170
+ }
15171
+ return null;
15172
+ }
15173
+
15174
+ /** Re-place stock menus while CSS anchor positioning is unavailable. */
15175
+ function installAnchorFallback() {
15176
+ if (cssAnchorPositioningSupported()) return null;
15177
+ if (document.body === null || document.body === undefined) return null;
15178
+ const state = { target: null, at: 0 };
15179
+ const timers = new Map();
15180
+
15181
+ const remember = (element) => {
15182
+ if (element === null || element === undefined) return;
15183
+ state.target = element;
15184
+ state.at = Date.now();
15185
+ };
15186
+ const buttonFrom = (target) => (target instanceof Element
15187
+ ? target.closest('button, [role="button"], [role="menuitem"], [aria-haspopup]')
15188
+ : null);
15189
+ const onPointerDown = (event) => { remember(buttonFrom(event.target)); };
15190
+ const onPointerOver = (event) => {
15191
+ remember(event.target instanceof Element ? event.target.closest('[aria-haspopup="menu"]') : null);
15192
+ };
15193
+ const onKeyDown = (event) => {
15194
+ if (event.key !== "Enter" && event.key !== " " && event.key !== "Spacebar") return;
15195
+ remember(buttonFrom(event.target));
15196
+ };
15197
+ window.addEventListener("pointerdown", onPointerDown, true);
15198
+ window.addEventListener("pointerover", onPointerOver, true);
15199
+ window.addEventListener("keydown", onKeyDown, true);
15200
+
15201
+ /** A trigger is usable when it is still mounted and has a box. Menu rows
15202
+ stay usable: a submenu anchors to the row that opened it. */
15203
+ const visibleAnchor = (element) => {
15204
+ if (!(element instanceof Element) || element.isConnected !== true) return null;
15205
+ const rect = element.getBoundingClientRect();
15206
+ return rect.width > 0 || rect.height > 0 ? element : null;
15207
+ };
15208
+ const recentAnchor = () => {
15209
+ if (state.target === null || Date.now() - state.at > 4000) return null;
15210
+ return visibleAnchor(state.target);
15211
+ };
15212
+ const activeAnchor = () => {
15213
+ const active = document.activeElement;
15214
+ if (!(active instanceof Element)) return null;
15215
+ // Focus usually moves into the opened menu; a menu row is not a trigger.
15216
+ if (active.closest('[role="menu"], [role="listbox"]') !== null) return null;
15217
+ return visibleAnchor(active.closest('button, [role="button"], [aria-haspopup]') || active);
15218
+ };
15219
+
15220
+ const stop = (panel) => {
15221
+ const timer = timers.get(panel);
15222
+ if (timer === undefined) return;
15223
+ try { window.clearInterval(timer); } catch {}
15224
+ timers.delete(panel);
15225
+ };
15226
+
15227
+ const update = (panel, anchor) => {
15228
+ if (panel.isConnected !== true) { stop(panel); return false; }
15229
+ const current = anchor.isConnected === true ? anchor : (recentAnchor() || activeAnchor());
15230
+ if (current === null) return false;
15231
+ const menu = panel.hasAttribute("data-anchor-side");
15232
+ const side = menu ? (panel.getAttribute("data-anchor-side") || "bottom") : "top";
15233
+ const align = menu ? (panel.getAttribute("data-anchor-align") || "start") : "end";
15234
+ const gap = String(panel.style.getPropertyValue("--dsh-model-anchor") || "") === "" ? 4 : 8;
15235
+ return applyAnchorPanelInsets(panel, current, side, align, gap);
15236
+ };
15237
+
15238
+ const place = (panel) => {
15239
+ if (!(panel instanceof Element) || timers.has(panel)) return false;
15240
+ const menu = panel.hasAttribute("data-anchor-side");
15241
+ const model = panel.style !== undefined
15242
+ && String(panel.style.getPropertyValue("--dsh-model-anchor") || "") !== "";
15243
+ if (!menu && !model) return false;
15244
+ const anchor = anchorFromCustomProperty(panel) || recentAnchor() || activeAnchor();
15245
+ if (anchor === null) return false;
15246
+ update(panel, anchor);
15247
+ timers.set(panel, window.setInterval(() => { update(panel, anchor); }, 150));
15248
+ return true;
15249
+ };
15250
+
15251
+ const observer = new MutationObserver((records) => {
15252
+ for (const record of records) {
15253
+ for (const node of record.addedNodes) {
15254
+ if (!(node instanceof Element)) continue;
15255
+ if (place(node)) continue;
15256
+ for (const panel of node.querySelectorAll("[data-anchor-side]")) place(panel);
15257
+ }
15258
+ for (const node of record.removedNodes) {
15259
+ if (!(node instanceof Element)) continue;
15260
+ stop(node);
15261
+ for (const panel of node.querySelectorAll("[data-anchor-side]")) stop(panel);
15262
+ }
15263
+ }
15264
+ });
15265
+ try {
15266
+ observer.observe(document.body, { childList: true, subtree: false });
15267
+ } catch {
15268
+ return null;
15269
+ }
15270
+
15271
+ return () => {
15272
+ try { observer.disconnect(); } catch {}
15273
+ window.removeEventListener("pointerdown", onPointerDown, true);
15274
+ window.removeEventListener("pointerover", onPointerOver, true);
15275
+ window.removeEventListener("keydown", onKeyDown, true);
15276
+ for (const [, timer] of timers) {
15277
+ try { window.clearInterval(timer); } catch {}
15278
+ }
15279
+ timers.clear();
15280
+ };
15281
+ }
15282
+ // dsv-anchor-fallback:end
15283
+
14219
15284
  /** Boot hook: returns a disposer only in a native system window. */
14220
15285
  function bootSystemWindow() {
14221
15286
  const sessionId = systemWindowSessionId();
14222
15287
  if (sessionId === null) return null;
14223
15288
  try { document.documentElement.dataset.dsvSystemWindow = "1"; } catch {}
14224
15289
  const disposeLayout = watchSystemWindowLayout();
15290
+ const disposeAnchorFallback = installAnchorFallback();
14225
15291
  activateSystemWindowSession(sessionId);
14226
- return disposeLayout;
15292
+ return () => {
15293
+ try { disposeLayout(); } catch {}
15294
+ try { if (typeof disposeAnchorFallback === "function") disposeAnchorFallback(); } catch {}
15295
+ };
14227
15296
  }
14228
15297
 
14229
15298
  // The Host owns the system windows. This store mirrors their session ids
@@ -14329,9 +15398,10 @@ window.__ModuleLoader__.load({
14329
15398
  return;
14330
15399
  }
14331
15400
  const code = payload !== null && payload !== undefined ? payload.error : undefined;
14332
- showPaneToast(t(code === "unsupported-platform" || code === "not-desktop"
15401
+ const failure = code === "unsupported-platform" || code === "not-desktop"
14333
15402
  ? "systemWindowUnsupported"
14334
- : "systemWindowFailed"), true);
15403
+ : (code === "webview2" ? "systemWindowWebView2Missing" : "systemWindowFailed");
15404
+ showPaneToast(t(failure), true);
14335
15405
  }).catch(() => {
14336
15406
  showPaneToast(t("systemWindowFailed"), true);
14337
15407
  });
@@ -14342,28 +15412,50 @@ window.__ModuleLoader__.load({
14342
15412
  return true;
14343
15413
  }
14344
15414
  function restoreSplit() {
15415
+ // Show the canvas FIRST: while the pane tree is warm-held, unminimizing is
15416
+ // just a visibility flip. The old order ran layout.selectPanel() and a full
15417
+ // native conversation switch (uiWorkspace.openSession) before the state
15418
+ // update, so the user waited through that switch for a view the canvas
15419
+ // immediately covers anyway.
15420
+ setRuntime({ minimized: false });
15421
+ writeMinimized(false);
14345
15422
  try {
14346
- const tree = treeStore.getSnapshot();
14347
- const sid = tree !== null && tree !== undefined
14348
- ? (tree.focus !== null && tree.focus !== undefined ? tree.focus : treeStore.leafIds()[0])
14349
- : undefined;
14350
15423
  const layout = pluginCtx !== null && pluginCtx !== undefined && typeof pluginCtx.get === "function"
14351
15424
  ? pluginCtx.get("layout")
14352
15425
  : null;
14353
15426
  if (layout !== null && layout !== undefined && typeof layout.selectPanel === "function") {
14354
15427
  layout.selectPanel(null);
14355
15428
  }
15429
+ const tree = treeStore.getSnapshot();
15430
+ const sid = tree !== null && tree !== undefined
15431
+ ? (tree.focus !== null && tree.focus !== undefined ? tree.focus : treeStore.leafIds()[0])
15432
+ : undefined;
14356
15433
  if (sid !== undefined && sid !== null) {
14357
15434
  const workspace = pluginCtx !== null && pluginCtx !== undefined && typeof pluginCtx.get === "function"
14358
15435
  ? pluginCtx.get("uiWorkspace")
14359
15436
  : null;
14360
15437
  if (workspace !== null && workspace !== undefined && typeof workspace.openSession === "function") {
14361
- workspace.openSession(sid);
15438
+ // Align the covered stock view a moment later, and skip it when it
15439
+ // already shows that conversation. It stays invisible under the
15440
+ // canvas, so a native session switch there must never gate the
15441
+ // restore itself.
15442
+ window.setTimeout(() => {
15443
+ try {
15444
+ if (currentSessionId() === sid) return;
15445
+ workspace.openSession(sid);
15446
+ } catch {}
15447
+ }, 150);
14362
15448
  }
14363
15449
  }
14364
15450
  } catch {}
14365
- setRuntime({ minimized: false });
14366
- writeMinimized(false);
15451
+ }
15452
+
15453
+ /** The sidebar's "分屏视图" row glyph; the sidebar renders it at its own
15454
+ icon size and tells it whether this panel is the selected one. */
15455
+ function SplitNavIcon(props) {
15456
+ const size = props !== null && props !== undefined && typeof props.size === "number" ? props.size : 18;
15457
+ const active = props !== null && props !== undefined && props.active === true;
15458
+ return h(SplitViewGlyph, { size, active });
14367
15459
  }
14368
15460
 
14369
15461
  /** Sidebar-footer entry point: opens the split menu (add / exit / minimize
@@ -14389,7 +15481,7 @@ window.__ModuleLoader__.load({
14389
15481
  openLauncherMenu(event.currentTarget);
14390
15482
  },
14391
15483
  },
14392
- h(SplitIconV, { size: 15 }),
15484
+ h(SplitViewGlyph, { size: 15 }),
14393
15485
  pending.length > 0 ? h("span", { className: "dsv-footer-badge" }, String(pending.length)) : null,
14394
15486
  );
14395
15487
  }
@@ -14530,6 +15622,30 @@ window.__ModuleLoader__.load({
14530
15622
  // unload.
14531
15623
  ctx.effect(installSplitSessionMenu, "dsh-split-workspace: session menu");
14532
15624
 
15625
+ // 0.12.0: drawn icons for the session context menu's "分屏插件" group and
15626
+ // its four rows. The context menu resolves each action's icon key
15627
+ // through its inline keyed icon slot; the rows keep their stock text and
15628
+ // hover states, they just gain a glyph in front.
15629
+ const contextIcons = [
15630
+ [CONTEXT_ICON_PANEL, () => h(SplitViewGlyph, { size: 15, active: true })],
15631
+ [CONTEXT_ICON_SPLIT, () => h(TwoPaneGlyph, { size: 15 })],
15632
+ [CONTEXT_ICON_FLOAT, () => h(FloatPaneGlyph, { size: 15 })],
15633
+ [CONTEXT_ICON_WINDOW, () => h(WindowGlyph, { size: 15 })],
15634
+ [CONTEXT_ICON_NATIVE, () => h(NativeWindowGlyph, { size: 15 })],
15635
+ ];
15636
+ for (const entry of contextIcons) {
15637
+ const key = entry[0];
15638
+ const Icon = entry[1];
15639
+ slots.inject("contextMenu.icon", () =>
15640
+ slots.register({ name: "contextMenu.icon", key }, Icon),
15641
+ );
15642
+ }
15643
+
15644
+ // Zero-cost when idle: marks the "layout is changing" window so the
15645
+ // per-pane observers can skip intermediate resize frames and measure
15646
+ // once when the window stops moving (0.12.0 resize responsiveness).
15647
+ ctx.effect(installWindowResizeTracker, "dsh-split-workspace: window resize tracker");
15648
+
14533
15649
  // Right-sidebar repair: the split teardown could leave the sidebar-right
14534
15650
  // store open while its column was closed (the corner button then vanished
14535
15651
  // with no way back) or leave a stock control writing to a seat nobody
@@ -14650,6 +15766,28 @@ window.__ModuleLoader__.load({
14650
15766
  h(FooterSplitButton),
14651
15767
  ),
14652
15768
  );
15769
+ // 0.12.0: the "分屏视图" sidebar entry — a global panel row next to the
15770
+ // stock "插件" row (same sidebar.panellist list) plus the main panel it
15771
+ // selects. The row id and the main key MUST match: the row IS the panel
15772
+ // selector, and the layout resolves the main slot by that key.
15773
+ slots.inject("sidebar.panellist", () =>
15774
+ slots.register({
15775
+ name: "sidebar.panellist",
15776
+ id: SPLIT_PANEL_ID,
15777
+ // Directly below the stock "插件" row (order 0), above the other
15778
+ // customizable panels, so the entry sits at the top of the nav.
15779
+ order: 5,
15780
+ label: () => t("panelTitle"),
15781
+ locale: "splitView",
15782
+ }, SplitNavIcon),
15783
+ );
15784
+ slots.inject("main", () =>
15785
+ slots.register({
15786
+ name: "main",
15787
+ key: SPLIT_PANEL_ID,
15788
+ locale: "splitView",
15789
+ }, (props) => h(SplitPanelView, props)),
15790
+ );
14653
15791
  // A second entry point in the system Settings panel. The slot is
14654
15792
  // declared by the settings shell; injection waits until it exists.
14655
15793
  slots.inject("settings.section", () =>