dsh-split-workspace 0.11.0 → 0.13.2

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.0";
78
+ const PLUGIN_VERSION = "0.13.2";
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",
@@ -672,6 +824,20 @@ window.__ModuleLoader__.load({
672
824
  layoutCount: "窗格",
673
825
  exitSplit: "退出分屏",
674
826
  openSplit: "分屏视图",
827
+ panelTitle: "分屏视图",
828
+ panelPickTitle: "选择要分屏的会话",
829
+ panelPickHint: "至少选择两个会话,确定后立即显示分屏界面。",
830
+ panelPickConfirm: "打开分屏",
831
+ returningTitle: "正在返回会话",
832
+ returningHint: "分屏已最小化,正在切换到会话视图…",
833
+ panelNeedTwo: "至少选择两个会话才能打开分屏视图。",
834
+ panelDisabledTitle: "分屏视图已禁用",
835
+ panelDisabledBody: "启用后可重新打开分屏视图,已保存的布局会保留。",
836
+ panelEnable: "启用分屏视图",
837
+ panelSafeTitle: "分屏在崩溃后已暂停",
838
+ panelSafeBody: "点“重试”可重新打开已保存的布局;期间原生会话视图不受影响。",
839
+ panelNoSessions: "还没有可用的会话。先开始对话,再选择两个进行分屏。",
840
+ panelMinimizeHint: "从底部菜单最小化会回到会话界面。",
675
841
  minimizeSplit: "最小化",
676
842
  rightbar: "右侧栏",
677
843
  rightbarOpen: "打开右侧边栏",
@@ -1370,6 +1536,14 @@ window.__ModuleLoader__.load({
1370
1536
  flex: none; height: 36px; display: flex; align-items: center; gap: 8px;
1371
1537
  padding: 0 4px 0 12px; border-bottom: 1px solid var(--dsw-alias-border-l2);
1372
1538
  cursor: grab; user-select: none;
1539
+ /* The stock conversation stays mounted behind this overlay and its header
1540
+ (class *__header) declares an Electron window-drag region
1541
+ (-webkit-app-region: drag) over the top of the column. Native drag
1542
+ regions swallow clicks BEFORE the DOM, so whenever a covered stock
1543
+ conversation exists — i.e. after restoring a split that was minimized to
1544
+ a conversation — our pane header buttons were click-dead. A no-drag
1545
+ region on our own header subtracts that area again. */
1546
+ -webkit-app-region: no-drag;
1373
1547
  }
1374
1548
  .dsv-pane-header:active { cursor: grabbing; }
1375
1549
  /* Slim header for narrow panes: one 30px row instead of the tall stock
@@ -2177,6 +2351,63 @@ window.__ModuleLoader__.load({
2177
2351
  @media (prefers-reduced-motion: reduce) {
2178
2352
  .dsv-drop-ghost { transition: none; }
2179
2353
  }
2354
+ /* ---- 0.12.0 "分屏视图" main panel -------------------------------------
2355
+ The same pane canvas as the overlay, but hosted in the layout's main
2356
+ column: the panel fills its host (absolute inset 0 inside a relative
2357
+ flex root), so no conversation-column geometry is needed. The picker
2358
+ page reuses the modal card/pick styles with a page-sized shell. ---- */
2359
+ .dsv-panel-root {
2360
+ position: relative; flex: 1; min-width: 0; min-height: 0;
2361
+ display: flex; flex-direction: column;
2362
+ background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary);
2363
+ font-family: var(--dsw-font-family, system-ui, sans-serif);
2364
+ }
2365
+ /* Warm-held canvas: mounted and still laid out, but invisible. Keeping the
2366
+ box in layout is deliberate: showing it again is then a visibility flip
2367
+ (no full re-layout of N conversation trees), which is what makes minimize
2368
+ ⇄ restore and panel ⇄ conversation switches feel instant inside the warm
2369
+ window. It also means a warm split keeps doing layout work for streaming
2370
+ output until the window expires, and then its tree is dropped. */
2371
+ .dsv-overlay.dsv-warm { visibility: hidden !important; }
2372
+ /* Invariant: a canvas that is not warm-held is visible AND clickable. A
2373
+ visible-but-click-through overlay (left behind by an interrupted warm
2374
+ hold or a hot-swapped older instance) is the worst state: the panes paint
2375
+ but every control inside them is dead. visibility:hidden already keeps
2376
+ the warm canvas out of hit-testing, so the warm rule no longer needs
2377
+ pointer-events at all, and this rule re-asserts interactivity whenever the
2378
+ class is gone. */
2379
+ .dsv-overlay:not(.dsv-warm) { visibility: visible !important; pointer-events: auto !important; }
2380
+ /* Belt and braces for the reported symptom: if an ancestor ever ends up with
2381
+ pointer-events:none, the pane header row (where every per-pane action
2382
+ lives) still wins its own hit-testing. */
2383
+ .dsv-overlay:not(.dsv-warm) .dsv-pane-header,
2384
+ .dsv-overlay:not(.dsv-warm) .dsv-pane-header .dsv-pane-btn { pointer-events: auto; }
2385
+ .dsv-panel-picker { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 24px; }
2386
+ .dsv-panel-card { width: min(620px, 100%); max-height: min(640px, 100%); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.16); }
2387
+ .dsv-panel-card-narrow { width: min(460px, 100%); }
2388
+ .dsv-panel-glyph { flex: none; display: grid; place-items: center; width: 22px; height: 22px; color: var(--dsw-static-deepseek-500); }
2389
+ /* Shown for the one/two frames in which the split-view panel has hidden the
2390
+ canvas but is still waiting for the deferred switch to the stock
2391
+ conversation (that switch mounts a whole native conversation). */
2392
+ .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); }
2393
+ .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; }
2394
+ @keyframes dsv-spin { to { transform: rotate(360deg); } }
2395
+ /* While the OS window is being resized, cut every pane transition: the
2396
+ shells' percentage widths already follow the live window edge, and a
2397
+ 180ms width/height transition would chase each resize frame (visible
2398
+ rubber-banding + extra layout per frame). The CSS reflow is the only
2399
+ work left; JS measurement waits for the settle. */
2400
+ html[data-dsv-resizing] .dsv-pane,
2401
+ html[data-dsv-resizing] .dsv-pane-wrap,
2402
+ html[data-dsv-resizing] .dsv-split-wrap,
2403
+ html[data-dsv-resizing] .dsv-split,
2404
+ html[data-dsv-resizing] .dsv-canvas,
2405
+ html[data-dsv-resizing] .dsv-overlay,
2406
+ html[data-dsv-resizing] .dsv-panel-root {
2407
+ transition: none !important;
2408
+ animation: none !important;
2409
+ }
2410
+
2180
2411
  /* ---- performance mode -------------------------------------------------
2181
2412
  One HTML attribute turns off every non-essential paint/animation cost:
2182
2413
  no card shadows, no focus glow, no fade/zoom transitions, no render-loop
@@ -2308,6 +2539,29 @@ window.__ModuleLoader__.load({
2308
2539
  h("rect", { x: 2.5, y: 9.1, width: 11, height: 5.4, rx: 2, stroke: "currentColor", strokeWidth: 1.4, fill: "none" }),
2309
2540
  );
2310
2541
  }
2542
+ /** The split-view identity glyph: two panes with the right one filled.
2543
+ One drawing is reused by the sidebar's "分屏视图" panel row, the
2544
+ bottom-left launcher button, the page itself and the session context
2545
+ menu, so the entry reads as the same thing everywhere. Drawn, not a
2546
+ font character: emoji/symbol codepoints are platform-font dependent
2547
+ (the old "⏻" restart row rendered as a tofu box on Windows). */
2548
+ function SplitViewGlyph({ size, active }) {
2549
+ const s = size || 16;
2550
+ return h(
2551
+ "svg",
2552
+ {
2553
+ viewBox: "0 0 16 16", width: s, height: s, fill: "none",
2554
+ stroke: "currentColor", strokeWidth: 1.4, "aria-hidden": true,
2555
+ },
2556
+ h("rect", { x: 1.8, y: 2, width: 12.4, height: 12, rx: 3 }),
2557
+ h("path", { d: "M8.4 2.6v10.8", strokeLinecap: "round" }),
2558
+ h("rect", {
2559
+ x: 9.7, y: 3.3, width: 3.4, height: 9.4, rx: 1.3,
2560
+ fill: "currentColor", stroke: "none", opacity: active === true ? 0.9 : 0.42,
2561
+ }),
2562
+ );
2563
+ }
2564
+
2311
2565
  /* Close is a plain drawn X. The stock close glyph is not guaranteed to
2312
2566
  exist in every primitives build — a missing primitive falls back to a
2313
2567
  single bullet, which is exactly the "small red dot" the close control
@@ -2326,6 +2580,64 @@ window.__ModuleLoader__.load({
2326
2580
  );
2327
2581
  }
2328
2582
 
2583
+ /** Restart glyph: a circular arrow drawn as SVG. The launcher menu used to
2584
+ render the U+23FB POWER SYMBOL, which is missing from the default
2585
+ Windows CJK font stack and showed as a mojibake/□ box there. */
2586
+ function RestartIcon({ size }) {
2587
+ const s = size || 14;
2588
+ return h(
2589
+ "svg",
2590
+ {
2591
+ viewBox: "0 0 16 16", width: s, height: s, fill: "none",
2592
+ stroke: "currentColor", strokeWidth: 1.5,
2593
+ strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true,
2594
+ },
2595
+ h("path", { d: "M13 8.2A5 5 0 1 1 11.5 3.8" }),
2596
+ h("path", { d: "M13.2 2.2v3.6H9.6" }),
2597
+ );
2598
+ }
2599
+
2600
+ /** Session-context-menu glyphs, all drawn in the same 16px frame and in
2601
+ currentColor so the stock menu's hover/muted colors flow through. */
2602
+ function TwoPaneGlyph({ size }) {
2603
+ const s = size || 14;
2604
+ return h(
2605
+ "svg",
2606
+ { viewBox: "0 0 16 16", width: s, height: s, fill: "none", stroke: "currentColor", strokeWidth: 1.3, "aria-hidden": true },
2607
+ h("rect", { x: 2, y: 2.4, width: 5.2, height: 11.2, rx: 1.8 }),
2608
+ h("rect", { x: 8.8, y: 2.4, width: 5.2, height: 11.2, rx: 1.8 }),
2609
+ );
2610
+ }
2611
+ function FloatPaneGlyph({ size }) {
2612
+ const s = size || 14;
2613
+ return h(
2614
+ "svg",
2615
+ { viewBox: "0 0 16 16", width: s, height: s, fill: "none", stroke: "currentColor", strokeWidth: 1.3, "aria-hidden": true },
2616
+ h("rect", { x: 1.8, y: 2, width: 9, height: 8.4, rx: 1.8, opacity: 0.5 }),
2617
+ 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)" }),
2618
+ );
2619
+ }
2620
+ function WindowGlyph({ size }) {
2621
+ const s = size || 14;
2622
+ return h(
2623
+ "svg",
2624
+ { viewBox: "0 0 16 16", width: s, height: s, fill: "none", stroke: "currentColor", strokeWidth: 1.3, "aria-hidden": true },
2625
+ h("rect", { x: 1.9, y: 2.2, width: 12.2, height: 11.6, rx: 2.2 }),
2626
+ h("path", { d: "M1.9 6h12.2", strokeLinecap: "round" }),
2627
+ h("circle", { cx: 4.2, cy: 4.1, r: 0.65, fill: "currentColor", stroke: "none" }),
2628
+ );
2629
+ }
2630
+ function NativeWindowGlyph({ size }) {
2631
+ const s = size || 14;
2632
+ return h(
2633
+ "svg",
2634
+ { viewBox: "0 0 16 16", width: s, height: s, fill: "none", stroke: "currentColor", strokeWidth: 1.3, "aria-hidden": true },
2635
+ h("rect", { x: 1.6, y: 2.2, width: 12.8, height: 9.2, rx: 2 }),
2636
+ h("path", { d: "M5.4 14h5.2", strokeLinecap: "round" }),
2637
+ h("path", { d: "M8 11.4V14", strokeLinecap: "round" }),
2638
+ );
2639
+ }
2640
+
2329
2641
  // ---------------------------------------------------------------------
2330
2642
  // safety layer (1.6.0)
2331
2643
  //
@@ -2352,6 +2664,57 @@ window.__ModuleLoader__.load({
2352
2664
  try { window.localStorage.removeItem(key); return true; } catch { return false; }
2353
2665
  }
2354
2666
 
2667
+ // ---------------------------------------------------------------------
2668
+ // public diagnostics global (one fresh object per bundle execution)
2669
+ //
2670
+ // `window.__dshSplitWorkspace` outlives the bundle that created it: DSH
2671
+ // swaps a rebuilt client bundle into the running page (client HMR `rebuilt`
2672
+ // frame) and a disable / enable cycle re-creates the entry without reloading
2673
+ // the page. The next factory execution therefore used to inherit the
2674
+ // previous one's descriptors — and the read-only `__test` seam is
2675
+ // non-configurable, so re-defining it on the inherited object threw
2676
+ // `TypeError: Cannot redefine property: __test`. That exception aborted the
2677
+ // whole factory: the footer button, the session menus and the Settings page
2678
+ // stayed missing (DSH listed the entry as a failed page synchronization)
2679
+ // until the user reloaded the page or restarted DSH. A fresh object per
2680
+ // execution makes every definition legal again and also stops a replacement
2681
+ // from publishing closures that belong to the previous bundle (health(),
2682
+ // retry(), __test helpers, …). Nothing inside the plugin reads the global,
2683
+ // so swapping the identity is safe.
2684
+ // ---------------------------------------------------------------------
2685
+
2686
+ /** The API object of THIS bundle execution. */
2687
+ let publicApiGlobal = null;
2688
+
2689
+ function pluginPublicApi() {
2690
+ if (publicApiGlobal === null) {
2691
+ publicApiGlobal = {};
2692
+ window.__dshSplitWorkspace = publicApiGlobal;
2693
+ }
2694
+ return publicApiGlobal;
2695
+ }
2696
+
2697
+ /** Define one member of the public global; a diagnostics seam must never
2698
+ take the plugin down, so a refused definition is only a warning. */
2699
+ function definePublicMember(key, descriptor) {
2700
+ const target = pluginPublicApi();
2701
+ if (Object.prototype.hasOwnProperty.call(target, key)) return false;
2702
+ try {
2703
+ Object.defineProperty(target, key, Object.assign({
2704
+ configurable: false,
2705
+ enumerable: false,
2706
+ writable: false,
2707
+ }, descriptor));
2708
+ return true;
2709
+ } catch (error) {
2710
+ try {
2711
+ const message = error !== null && error !== undefined && error.message !== undefined ? error.message : error;
2712
+ console.warn(LOG_PREFIX + " diagnostics seam '" + key + "' kept from the previous bundle: " + String(message));
2713
+ } catch {}
2714
+ return false;
2715
+ }
2716
+ }
2717
+
2355
2718
  /** Host release from the boot graph the web frontend injects:
2356
2719
  window.__DSH_BOOT__ = { release: { version, commit }, … }. */
2357
2720
  function readHostRelease() {
@@ -2409,12 +2772,25 @@ window.__ModuleLoader__.load({
2409
2772
  maximized: null,
2410
2773
  minimized: readMinimized(),
2411
2774
  performance: readPerformanceMode(),
2775
+ resizeFreeze: readResizeFreeze(),
2776
+ // The canvas is mounted but hidden for a short warm window while the
2777
+ // split is minimized / another panel owns the column. Diagnostics only.
2778
+ panelWarm: false,
2779
+ // Number of times the canvas showed up in a dead (not hit-testable)
2780
+ // state after a restore and had to be repaired. Should stay 0.
2781
+ canvasRepairs: 0,
2412
2782
  updateReady: null,
2413
2783
  // One conversation in an in-app independent window. DSH Desktop has no
2414
2784
  // plugin-facing BrowserWindow API, so this replaces the old browser
2415
2785
  // window with a first-class surface inside the application.
2416
2786
  appWindow: null,
2417
2787
  };
2788
+ // True while the split-view panel is minimizing itself: its page stays
2789
+ // mounted for a couple of frames (the column switch is deferred so the
2790
+ // click paints first), and its "selecting the panel restores the split"
2791
+ // effect must not undo that minimize in the meantime.
2792
+ let splitPanelMinimizeInFlight = false;
2793
+
2418
2794
  const runtimeListeners = new Set();
2419
2795
  function runtimeSnapshot() {
2420
2796
  return runtimeState;
@@ -2468,6 +2844,16 @@ window.__ModuleLoader__.load({
2468
2844
  showPaneToast(t(next ? "performanceOn" : "performanceOff"), true);
2469
2845
  return next;
2470
2846
  }
2847
+ /** Toggle the live-resize canvas freeze (performance-mode refinement). */
2848
+ function setResizeFreeze(value) {
2849
+ const next = value === true;
2850
+ writeResizeFreeze(next);
2851
+ setRuntime({ resizeFreeze: next });
2852
+ return next;
2853
+ }
2854
+ function resizeFreezeOn() {
2855
+ return runtimeState.resizeFreeze !== false;
2856
+ }
2471
2857
 
2472
2858
  /** True only when the workspace may take over the viewport at all. The
2473
2859
  `geometryBlocked` flag closes the diagnosis's "invisible active" hole:
@@ -2611,8 +2997,12 @@ window.__ModuleLoader__.load({
2611
2997
  enabled: runtimeState.enabled,
2612
2998
  safeMode: runtimeState.safeMode,
2613
2999
  active: runtimeState.active,
3000
+ panelSelected: splitPanelActive(),
3001
+ panelWarm: runtimeState.panelWarm === true,
3002
+ canvasRepairs: runtimeState.canvasRepairs,
2614
3003
  minimized: runtimeState.minimized === true,
2615
3004
  performance: runtimeState.performance === true,
3005
+ resizeFreeze: resizeFreezeOn(),
2616
3006
  geometryBlocked: runtimeState.geometryBlocked === true,
2617
3007
  panes: (() => { try { return treeStore.leafIds().length; } catch { return 0; } })(),
2618
3008
  floats: (() => { try { return floatStore.ids(); } catch { return []; } })(),
@@ -2693,6 +3083,7 @@ window.__ModuleLoader__.load({
2693
3083
  try { leaves = treeStore.leafIds().length; } catch { return "unknown"; }
2694
3084
  if (leaves < 2) return "no-split";
2695
3085
  if (runtimeState.minimized === true) return "minimized";
3086
+ if (runtimeState.panelWarm === true) return "panel";
2696
3087
  if (runtimeState.active !== true || runtimeState.geometry.ok !== true) return "geometry";
2697
3088
  return null;
2698
3089
  }
@@ -5438,7 +5829,7 @@ window.__ModuleLoader__.load({
5438
5829
  elected, or an entry elected without a store face. Diagnostics only —
5439
5830
  nothing in the render path reads it. */
5440
5831
  const composerChainDebug = { last: null, slots: null };
5441
- window.__dshSplitWorkspace = Object.assign(window.__dshSplitWorkspace || {}, { composerChain: composerChainDebug });
5832
+ Object.assign(pluginPublicApi(), { composerChain: composerChainDebug });
5442
5833
 
5443
5834
  /** Probe both slot-ledger surfaces for the keys this plugin consumes.
5444
5835
  `entries()` is the raw registration view (chain keys consume every
@@ -8218,6 +8609,10 @@ window.__ModuleLoader__.load({
8218
8609
  };
8219
8610
  const tick = () => {
8220
8611
  if (inLiveReflow(pane)) { settleTicks = 0; raf = 0; return; }
8612
+ // While the window resizes / a divider drags every frame moves the
8613
+ // pane edge; skip the forced-layout pass per frame and let the
8614
+ // settle listener below run it once at the end of the gesture.
8615
+ if (layoutBusy()) { settleTicks = SETTLE_TICKS; raf = 0; return; }
8221
8616
  apply();
8222
8617
  if (stableCount >= 2) { settleTicks = 0; raf = 0; return; }
8223
8618
  if (settleTicks > 0) { settleTicks -= 1; raf = requestAnimationFrame(tick); }
@@ -8236,8 +8631,10 @@ window.__ModuleLoader__.load({
8236
8631
  mutation.observe(pane, { childList: true, subtree: true, attributes: true, attributeFilter: ["data-composer-card", "data-dsv-composer-card"] });
8237
8632
  }
8238
8633
  const perfTimer = performanceMode ? window.setInterval(schedule, 1500) : 0;
8634
+ const offSettle = onLayoutSettle(schedule);
8239
8635
  raf = requestAnimationFrame(tick);
8240
8636
  return () => {
8637
+ offSettle();
8241
8638
  if (raf !== 0) cancelAnimationFrame(raf);
8242
8639
  observer.disconnect();
8243
8640
  if (mutation !== null) mutation.disconnect();
@@ -8267,14 +8664,18 @@ window.__ModuleLoader__.load({
8267
8664
  const inner = innerRef.current;
8268
8665
  if (row === null || inner === null || typeof ResizeObserver !== "function") return;
8269
8666
  const measure = () => {
8270
- if (inLiveReflow(row)) return;
8667
+ if (inLiveReflow(row) || layoutBusy()) return;
8271
8668
  setOverflown(row.scrollWidth > row.clientWidth + 1);
8272
8669
  };
8273
8670
  measure();
8274
8671
  const observer = new ResizeObserver(measure);
8275
8672
  observer.observe(row);
8276
8673
  observer.observe(inner);
8277
- return () => observer.disconnect();
8674
+ const offSettle = onLayoutSettle(measure);
8675
+ return () => {
8676
+ offSettle();
8677
+ observer.disconnect();
8678
+ };
8278
8679
  // `entries`, not `entries.length`: the cells re-render with new text
8279
8680
  // (a growing tok/s or token count) without changing the cell COUNT, and
8280
8681
  // the overflow flag has to follow that or a longer value stays clipped
@@ -9335,18 +9736,57 @@ window.__ModuleLoader__.load({
9335
9736
  const shortRef = React.useRef(false);
9336
9737
  React.useEffect(() => {
9337
9738
  const el = frameRef.current;
9338
- if (el === null || typeof ResizeObserver !== "function") return;
9739
+ if (el === null || typeof ResizeObserver !== "function") return undefined;
9740
+ // 0.12.0: commit the pane box at most once per resize gesture. Each
9741
+ // commit re-renders the pane (header + re-hosted native conversation)
9742
+ // and re-runs the composer measurement; doing that for every live
9743
+ // window-resize frame is what made resizing feel janky even in
9744
+ // performance mode. The box is held while the layout is busy and read
9745
+ // once when the gesture settles.
9746
+ let pending = null;
9747
+ let raf = 0;
9748
+ const apply = () => {
9749
+ raf = 0;
9750
+ if (pending === null) return;
9751
+ const next = pending;
9752
+ pending = null;
9753
+ shortRef.current = next.h < 280 ? true : next.h > 340 ? false : shortRef.current;
9754
+ setPaneSize((prev) => (prev.w === next.w && prev.h === next.h ? prev : { w: next.w, h: next.h }));
9755
+ };
9756
+ const schedule = () => {
9757
+ if (raf !== 0) return;
9758
+ raf = window.requestAnimationFrame(apply);
9759
+ };
9339
9760
  const observer = new ResizeObserver((entries) => {
9340
9761
  if (inLiveReflow(el)) return;
9341
9762
  for (const entry of entries) {
9342
9763
  const w = Math.round(entry.contentRect.width);
9343
9764
  const h = Math.round(entry.contentRect.height);
9344
- shortRef.current = h < 280 ? true : h > 340 ? false : shortRef.current;
9345
- setPaneSize((prev) => (prev.w === w && prev.h === h ? prev : { w, h }));
9765
+ // A warm-hidden canvas (display:none) reports a zero box; keep the
9766
+ // last real geometry so restoring it needs no header/composer churn.
9767
+ if (w < 2 || h < 2) continue;
9768
+ pending = { w, h };
9346
9769
  }
9770
+ if (layoutBusy()) return;
9771
+ schedule();
9772
+ });
9773
+ const offSettle = onLayoutSettle(() => {
9774
+ try {
9775
+ const rect = el.getBoundingClientRect();
9776
+ if (rect.width <= 2 || rect.height <= 2) return;
9777
+ pending = { w: Math.round(rect.width), h: Math.round(rect.height) };
9778
+ } catch { return; }
9779
+ apply();
9347
9780
  });
9348
9781
  observer.observe(el);
9349
- return () => observer.disconnect();
9782
+ return () => {
9783
+ offSettle();
9784
+ if (raf !== 0) {
9785
+ try { window.cancelAnimationFrame(raf); } catch {}
9786
+ raf = 0;
9787
+ }
9788
+ observer.disconnect();
9789
+ };
9350
9790
  }, []);
9351
9791
  const narrow = paneSize.w > 0 && paneSize.w < 560;
9352
9792
  // Below this width the six header actions no longer fit: collapse them
@@ -9412,6 +9852,9 @@ window.__ModuleLoader__.load({
9412
9852
  // and passes are capped to ~12/s per pane so a streaming burst cannot
9413
9853
  // turn layout reads into per-commit work (S4).
9414
9854
  if (typeof document.visibilityState === "string" && document.visibilityState === "hidden") return;
9855
+ // A live resized window changes the box on every frame; measure once
9856
+ // when the gesture settles instead (see onLayoutSettle below).
9857
+ if (layoutBusy()) return;
9415
9858
  const now = Date.now();
9416
9859
  if (now - lastMeasureAt < 80) return;
9417
9860
  lastMeasureAt = now;
@@ -9531,14 +9974,21 @@ window.__ModuleLoader__.load({
9531
9974
  const mutation = !performanceMode && typeof MutationObserver === "function" ? new MutationObserver(schedule) : null;
9532
9975
  if (mutation !== null) mutation.observe(frame, { childList: true, subtree: true });
9533
9976
  const perfTimer = performanceMode ? window.setInterval(schedule, 1500) : 0;
9977
+ // One measure after a window resize / divider drag settles: the effect
9978
+ // stays mounted across width changes (no per-frame teardown), and the
9979
+ // learned card box is refreshed from the final geometry.
9980
+ const offSettle = onLayoutSettle(schedule);
9534
9981
  schedule();
9535
9982
  return () => {
9983
+ offSettle();
9536
9984
  if (raf !== 0) cancelAnimationFrame(raf);
9537
9985
  observer.disconnect();
9538
9986
  if (mutation !== null) mutation.disconnect();
9539
9987
  if (perfTimer !== 0) window.clearInterval(perfTimer);
9540
9988
  };
9541
- }, [paneSize.w, composerMode, performanceMode]);
9989
+ // No paneSize dependency: the observer + settle listener re-measure; the
9990
+ // old dependency re-created every observer on each resize frame.
9991
+ }, [composerMode, performanceMode]);
9542
9992
  // a composer is never narrower than this — narrower "boxes" are
9543
9993
  // transient seats, not the real input; fall back to stock geometry
9544
9994
  const cardBoxSane = cardBox !== null && cardBox.right - cardBox.left >= 160;
@@ -10191,6 +10641,10 @@ window.__ModuleLoader__.load({
10191
10641
  min: Math.max(0.04, MIN_PANE_PX / Math.max(1, total)),
10192
10642
  };
10193
10643
  setActive(true);
10644
+ // Pane boxes follow the pointer every move; mark the gesture so the
10645
+ // per-pane observers defer their measurement/derived state to the
10646
+ // release (the layout still tracks the pointer frame by frame).
10647
+ markDividerDrag(true);
10194
10648
  try {
10195
10649
  event.currentTarget.setPointerCapture(event.pointerId);
10196
10650
  } catch {}
@@ -10211,6 +10665,7 @@ window.__ModuleLoader__.load({
10211
10665
  if (dragRef.current === null || dragRef.current.pointerId !== event.pointerId) return;
10212
10666
  dragRef.current = null;
10213
10667
  setActive(false);
10668
+ markDividerDrag(false);
10214
10669
  treeStore.persistNow();
10215
10670
  if (event.currentTarget.hasPointerCapture(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);
10216
10671
  };
@@ -10628,7 +11083,7 @@ window.__ModuleLoader__.load({
10628
11083
  session-hotkeys side hides the whole workspace shell (persisted, with a
10629
11084
  restore affordance) and the tree comes back intact on restore.
10630
11085
  Returns null when there is no pane to close. */
10631
- window.__dshSplitWorkspace = Object.assign(window.__dshSplitWorkspace || {}, {
11086
+ Object.assign(pluginPublicApi(), {
10632
11087
  split(sessionId) {
10633
11088
  return safeCall("split()", () => {
10634
11089
  if (typeof sessionId !== "string" || sessionId === "") return null;
@@ -10761,6 +11216,13 @@ window.__ModuleLoader__.load({
10761
11216
  performanceMode() {
10762
11217
  return safeCall("performanceMode()", () => performanceModeOn(), false);
10763
11218
  },
11219
+ /** Toggle the live-resize canvas freeze (performance-mode refinement). */
11220
+ setResizeFreeze(flag) {
11221
+ return safeCall("setResizeFreeze()", () => setResizeFreeze(flag !== false), false);
11222
+ },
11223
+ resizeFreeze() {
11224
+ return safeCall("resizeFreeze()", () => resizeFreezeOn(), true);
11225
+ },
10764
11226
  /** Reload the page to pick up an updated client bundle (same as Ctrl+R). */
10765
11227
  reloadClient() {
10766
11228
  return safeCall("reloadClient()", () => { try { location.reload(); } catch {} return true; }, false);
@@ -10813,7 +11275,7 @@ window.__ModuleLoader__.load({
10813
11275
  });
10814
11276
  // Live service seam (diagnostics only): lets the maintainer inspect the
10815
11277
  // right-sidebar controller and the shell layout while split view runs.
10816
- Object.defineProperty(window.__dshSplitWorkspace, "__svc", {
11278
+ definePublicMember("__svc", {
10817
11279
  value: Object.freeze({
10818
11280
  ctxAlive: () => pluginCtx !== null && pluginCtx !== undefined,
10819
11281
  names() {
@@ -10829,8 +11291,11 @@ window.__ModuleLoader__.load({
10829
11291
  configurable: true,
10830
11292
  });
10831
11293
  // Read-only test seam: production calls the very same functions, so the
10832
- // logic under test is the logic that runs on the user's host.
10833
- Object.defineProperty(window.__dshSplitWorkspace, "__test", {
11294
+ // logic under test is the logic that runs on the user's host. It is
11295
+ // deliberately non-configurable; the fresh per-execution API object (see
11296
+ // pluginPublicApi) is what keeps a live bundle replacement from throwing
11297
+ // `Cannot redefine property`.
11298
+ definePublicMember("__test", {
10834
11299
  value: Object.freeze({
10835
11300
  frameColumns,
10836
11301
  selectFrameColumns,
@@ -10858,8 +11323,6 @@ window.__ModuleLoader__.load({
10858
11323
  COLUMN_MIN_HEIGHT,
10859
11324
  TESTED_RELEASES: TESTED_RELEASES.slice(),
10860
11325
  }),
10861
- enumerable: false,
10862
- writable: false,
10863
11326
  configurable: false,
10864
11327
  });
10865
11328
 
@@ -11902,20 +12365,28 @@ window.__ModuleLoader__.load({
11902
12365
  return { left, top, width, height };
11903
12366
  }
11904
12367
 
11905
- /** Draggable, edge-snapping restore chip shown while the split is
11906
- minimized. It is confined to the conversation workspace (never the
11907
- sidebar or the macOS traffic-light corner) and defaults to the
11908
- workspace's bottom-left every time the split is minimized. */
12368
+ /** Draggable restore chip shown while the split is minimized. It is
12369
+ confined to the conversation workspace (never the sidebar or the macOS
12370
+ traffic-light corner), can be dropped anywhere, and snaps to the NEAREST
12371
+ EDGE on release — the position along that edge is kept, so it can sit
12372
+ anywhere on any edge instead of only in the four corners. The chosen
12373
+ position persists across minimize cycles. */
11909
12374
  function MinimizedChip() {
11910
12375
  const MARGIN = 18;
11911
12376
  const ref = React.useRef(null);
11912
12377
  const dragRef = React.useRef(null);
11913
12378
  const defaultPos = () => {
11914
- try { safeRemove(CHIP_KEY); } catch {}
11915
12379
  const work = chipWorkRect();
11916
12380
  const el = ref.current;
11917
12381
  const width = el ? el.offsetWidth : 229;
11918
12382
  const height = el ? el.offsetHeight : 42;
12383
+ const saved = readChipPos();
12384
+ if (saved !== null) {
12385
+ return {
12386
+ x: Math.min(Math.max(saved.x, work.left + MARGIN), Math.max(work.left + MARGIN, work.left + work.width - width - MARGIN)),
12387
+ y: Math.min(Math.max(saved.y, work.top + MARGIN), Math.max(work.top + MARGIN, work.top + work.height - height - MARGIN)),
12388
+ };
12389
+ }
11919
12390
  return {
11920
12391
  x: work.left + MARGIN,
11921
12392
  y: work.top + work.height - height - MARGIN,
@@ -11924,6 +12395,7 @@ window.__ModuleLoader__.load({
11924
12395
  const [pos, setPos] = React.useState(defaultPos);
11925
12396
  const [dragging, setDragging] = React.useState(false);
11926
12397
 
12398
+
11927
12399
  const clampToWork = React.useCallback((next) => {
11928
12400
  const work = chipWorkRect();
11929
12401
  const el = ref.current;
@@ -11936,6 +12408,9 @@ window.__ModuleLoader__.load({
11936
12408
  }, []);
11937
12409
 
11938
12410
  React.useEffect(() => {
12411
+ // Bring a restored position back inside the current work area after the
12412
+ // layout has been measured (the first render may predate it).
12413
+ setPos((current) => clampToWork(current));
11939
12414
  const onResize = () => setPos((current) => clampToWork(current));
11940
12415
  window.addEventListener("resize", onResize);
11941
12416
  return () => window.removeEventListener("resize", onResize);
@@ -11972,11 +12447,22 @@ window.__ModuleLoader__.load({
11972
12447
  const width = el.offsetWidth;
11973
12448
  const height = el.offsetHeight;
11974
12449
  const base = drag.last !== null ? drag.last : { x: el.offsetLeft, y: el.offsetTop };
11975
- const snapped = {
11976
- x: base.x + width / 2 < work.left + work.width / 2 ? work.left + MARGIN : work.left + work.width - width - MARGIN,
11977
- y: base.y + height / 2 < work.top + work.height / 2 ? work.top + MARGIN : work.top + work.height - height - MARGIN,
11978
- };
11979
- setPos(clampToWork(snapped));
12450
+ // Snap to the nearest EDGE only. The coordinate along that edge keeps
12451
+ // the drop position, so the chip can rest anywhere on any edge — not
12452
+ // just in the four corners.
12453
+ const leftDist = base.x - work.left;
12454
+ const rightDist = work.left + work.width - (base.x + width);
12455
+ const topDist = base.y - work.top;
12456
+ const bottomDist = work.top + work.height - (base.y + height);
12457
+ const nearest = Math.min(leftDist, rightDist, topDist, bottomDist);
12458
+ const snapped = { x: base.x, y: base.y };
12459
+ if (nearest === leftDist) snapped.x = work.left + MARGIN;
12460
+ else if (nearest === rightDist) snapped.x = work.left + work.width - width - MARGIN;
12461
+ else if (nearest === topDist) snapped.y = work.top + MARGIN;
12462
+ else snapped.y = work.top + work.height - height - MARGIN;
12463
+ const next = clampToWork(snapped);
12464
+ setPos(next);
12465
+ writeChipPos(next);
11980
12466
  };
11981
12467
 
11982
12468
  const style = { left: pos.x + "px", top: pos.y + "px", right: "auto", bottom: "auto" };
@@ -12008,14 +12494,21 @@ window.__ModuleLoader__.load({
12008
12494
  /** Always-mounted overlay-seat chrome: the safe-mode chip (with the tree
12009
12495
  kept), and a "could not start" chip when a persisted split cannot take
12010
12496
  the viewport (geometry fail-closed) — both dismissible and never over
12011
- stock controls. */
12012
- function PluginChrome() {
12497
+ stock controls. While the split-view panel owns the main column this
12498
+ chrome steps aside: the panel page renders its own state card. */
12499
+ function PluginChrome({ panelOwned }) {
12013
12500
  const runtime = useRuntime();
12014
12501
  const tree = useTree();
12015
12502
  const leaves = tree.root === null ? 0 : leafOf(tree.root, []).length;
12016
12503
  const wantsActive = runtime.enabled === true && leaves >= 2;
12017
12504
  const [settledBlocked, setSettledBlocked] = React.useState(false);
12505
+ // Unconditional hooks above; the panel-owned gate belongs here, after
12506
+ // them. An early return before useState/useEffect violated the hooks
12507
+ // order when the split-view panel was selected (React error #300: the
12508
+ // overlay slot entry crashed but still rendered).
12509
+ const panelOwnedUi = panelOwned === true;
12018
12510
  React.useEffect(() => {
12511
+ if (panelOwnedUi) return undefined;
12019
12512
  if (!wantsActive || runtime.safeMode === true || runtime.active === true) {
12020
12513
  setSettledBlocked(false);
12021
12514
  return undefined;
@@ -12026,7 +12519,8 @@ window.__ModuleLoader__.load({
12026
12519
  return () => {
12027
12520
  try { window.clearTimeout(timer); } catch {}
12028
12521
  };
12029
- }, [wantsActive, runtime.safeMode, runtime.active]);
12522
+ }, [wantsActive, runtime.safeMode, runtime.active, panelOwnedUi]);
12523
+ if (panelOwnedUi) return null;
12030
12524
  if (runtime.enabled !== true) return null;
12031
12525
  if (runtime.minimized === true && wantsActive) {
12032
12526
  return h(MinimizedChip, null);
@@ -12103,10 +12597,18 @@ window.__ModuleLoader__.load({
12103
12597
  const runtime = useRuntime();
12104
12598
  const appWindowState = runtime.appWindow;
12105
12599
  const appWindowOpen = appWindowState !== null && appWindowState !== undefined && appWindowState.minimized !== true;
12600
+ // The canvas ALWAYS lives here, the single live pane tree. Selecting the
12601
+ // "分屏视图" panel must not move it (the panel page below is empty and the
12602
+ // overlay covers exactly that column), otherwise every panel ⇄ split
12603
+ // switch would tear down and re-create N native conversations.
12604
+ const activePanelId = typeof props.usePanelInfo === "function"
12605
+ ? props.usePanelInfo((info) => (info !== null && info !== undefined ? info.activePanelId : null))
12606
+ : null;
12607
+ const panelOwned = activePanelId === SPLIT_PANEL_ID;
12106
12608
  return h(React.Fragment, null,
12107
12609
  h(WorkspaceBoundary, { key: "workspace-" + runtime.epoch },
12108
12610
  h(WorkspaceApp, Object.assign({}, props, { dsvAppWindowOpen: appWindowOpen }))),
12109
- h(PluginChrome, null),
12611
+ h(PluginChrome, { panelOwned }),
12110
12612
  h(WorkspaceBoundary, { key: "floats-" + runtime.epoch }, h(FloatLayer, null)),
12111
12613
  h(SplitLauncherLayer, null),
12112
12614
  h(AppWindowChip, null),
@@ -12118,6 +12620,48 @@ window.__ModuleLoader__.load({
12118
12620
  );
12119
12621
  }
12120
12622
 
12623
+ // ---- live window-resize canvas freeze (0.12.0) -------------------------
12624
+ // Every pane re-hosts the stock conversation view; those components
12625
+ // re-measure their own scrollers on every size change, so a live window
12626
+ // resize used to re-layout and re-measure N conversations on every frame
12627
+ // (the trace showed style-recalc + per-frame chat ticks as the dominant
12628
+ // cost, in performance mode too). Keeping the canvas's inner layout frozen
12629
+ // at the gesture-start size and scaling the rendered layer to the live
12630
+ // window edge removes that per-frame work: the transform is a compositor
12631
+ // operation, and one real relayout happens at settle. Tradeoff: text is
12632
+ // scaled (slightly stretched) for the duration of the drag and crisps up
12633
+ // when it ends.
12634
+ function clearCanvasFreeze(el) {
12635
+ if (el === null || el === undefined) return;
12636
+ try {
12637
+ el.style.transform = "";
12638
+ el.style.transformOrigin = "";
12639
+ el.style.width = "";
12640
+ el.style.height = "";
12641
+ el.style.right = "";
12642
+ el.style.bottom = "";
12643
+ el.style.willChange = "";
12644
+ } catch {}
12645
+ }
12646
+ /** Keep a frozen inner box but present it at the live target box. */
12647
+ function applyCanvasFreeze(el, frozenW, frozenH, targetW, targetH, left, top) {
12648
+ if (frozenW <= 2 || frozenH <= 2 || targetW <= 2 || targetH <= 2) return false;
12649
+ try {
12650
+ el.style.left = left + "px";
12651
+ el.style.top = top + "px";
12652
+ el.style.right = "auto";
12653
+ el.style.bottom = "auto";
12654
+ el.style.width = frozenW + "px";
12655
+ el.style.height = frozenH + "px";
12656
+ el.style.transformOrigin = "0 0";
12657
+ // Promote the frozen layer once per gesture: the per-frame scale is a
12658
+ // compositor transform, not a repaint of the conversation text.
12659
+ el.style.willChange = "transform";
12660
+ el.style.transform = "scale(" + (targetW / frozenW) + "," + (targetH / frozenH) + ")";
12661
+ return true;
12662
+ } catch { return false; }
12663
+ }
12664
+
12121
12665
  function WorkspaceApp(props) {
12122
12666
  // This component IS the plugin's root-scoped seat: `shell.overlay` is
12123
12667
  // declared `kind: list, scope: root`, so the renderer hands it the
@@ -12151,16 +12695,34 @@ window.__ModuleLoader__.load({
12151
12695
  // split tree (and its observers) quiet underneath.
12152
12696
  const appWindowOpen = props.dsvAppWindowOpen === true;
12153
12697
  const active = appWindowOpen !== true && leaves.length >= 2
12154
- && runtime.enabled === true && runtime.safeMode !== true;
12698
+ && runtime.enabled === true && runtime.safeMode !== true && minimized !== true;
12155
12699
  const [picker, setPicker] = React.useState(pickerRequest);
12156
12700
  const [bounds, setBounds] = React.useState({ left: 0, right: 0, top: 0, bottom: 0, ok: false });
12701
+ // Warm hold (0.13.0): the overlay canvas is the ONE live pane tree. When
12702
+ // the split is minimized, or another global panel (Plugins, Settings, …)
12703
+ // takes the main column, or the "分屏视图" panel is merely selected, the
12704
+ // canvas hides WITHOUT unmounting for WARM_HIDE_MS. Remounting N native
12705
+ // conversations (session retain, editor guards, transcript views) was the
12706
+ // latency behind every panel ⇄ split and minimize ⇄ restore switch; after
12707
+ // the warm window the tree is dropped so a long-hidden split stops
12708
+ // streaming in the background.
12709
+ const [warmCold, setWarmCold] = React.useState(false);
12157
12710
  const geometryWarnedRef = React.useRef(false);
12711
+ const overlayRef = React.useRef(null);
12158
12712
  // B3 "invisible active": the workspace is OPERATIONAL only when it can
12159
12713
  // actually render (>=2 panes AND a confident column measurement). All
12160
12714
  // input/observation paths gate on this, so a persisted split whose
12161
12715
  // geometry fails renders nothing and also does NOT eat Alt+T /
12162
12716
  // Alt+Shift+Arrow (the chrome chip explains the state instead).
12163
- const operational = active && bounds.ok === true && minimized !== true;
12717
+ // The split-view main panel is NOT a foreign panel: the canvas covers
12718
+ // exactly that column, so selecting it must not step aside.
12719
+ const otherPanelActive = activePanelId !== null && activePanelId !== undefined
12720
+ && activePanelId !== SPLIT_PANEL_ID;
12721
+ const visible = active === true && otherPanelActive !== true;
12722
+ const warmEligible = appWindowOpen !== true && leaves.length >= 2
12723
+ && runtime.enabled === true && runtime.safeMode !== true;
12724
+ const warmHold = warmEligible === true && warmCold !== true && visible !== true;
12725
+ const operational = visible && bounds.ok === true;
12164
12726
 
12165
12727
  // The DOM session-list source (0.2.0 path) observes the document only
12166
12728
  // while the workspace is operational — otherwise zero observation cost.
@@ -12178,6 +12740,92 @@ window.__ModuleLoader__.load({
12178
12740
  setRuntime({ active: operational });
12179
12741
  }, [operational]);
12180
12742
 
12743
+ // Surface the warm-hold state for health()/diagnostics.
12744
+ React.useEffect(() => {
12745
+ setRuntime({ panelWarm: warmHold === true });
12746
+ }, [warmHold]);
12747
+
12748
+ // Warm-hold timer: start it when the canvas becomes hidden and drop the
12749
+ // tree (cold) once the window expires; any show resets it.
12750
+ React.useEffect(() => {
12751
+ if (warmEligible !== true || visible === true) {
12752
+ if (warmCold !== false) setWarmCold(false);
12753
+ return undefined;
12754
+ }
12755
+ if (warmCold === true) return undefined;
12756
+ const timer = window.setTimeout(() => setWarmCold(true), WARM_HIDE_MS);
12757
+ return () => {
12758
+ try { window.clearTimeout(timer); } catch {}
12759
+ };
12760
+ }, [warmEligible, visible, warmCold]);
12761
+
12762
+ // Invariant: a canvas that (re)appears must be hit-testable. A warm hold
12763
+ // that never fully cleared, a window-resize freeze interrupted by a
12764
+ // minimize, an interrupted pane drag or a hot-swapped older instance can
12765
+ // leave interaction styles behind so that the panes paint but every
12766
+ // control inside them — most visibly the pane header buttons — is dead
12767
+ // after "restore split". Repair once, one frame after the canvas shows,
12768
+ // and count it in health().canvasRepairs (should stay 0).
12769
+ React.useEffect(() => {
12770
+ if (visible !== true) return undefined;
12771
+ let raf = 0;
12772
+ try {
12773
+ raf = window.requestAnimationFrame(() => {
12774
+ raf = 0;
12775
+ const el = overlayRef.current;
12776
+ if (el === null || el === undefined || !el.isConnected) return;
12777
+ let repaired = false;
12778
+ try {
12779
+ if (el.style.transform !== "" || el.style.width !== "") {
12780
+ // A freeze survived the hidden phase: drop it and re-write the
12781
+ // real box (React may skip style writes it believes unchanged).
12782
+ clearCanvasFreeze(el);
12783
+ const box = measureColumnBounds();
12784
+ if (box !== null && box !== undefined && box.ok === true) {
12785
+ el.style.left = box.left + "px";
12786
+ el.style.right = box.right + "px";
12787
+ el.style.top = box.top + "px";
12788
+ el.style.bottom = box.bottom + "px";
12789
+ }
12790
+ repaired = true;
12791
+ }
12792
+ const computed = window.getComputedStyle(el);
12793
+ if (computed.pointerEvents === "none" || computed.visibility === "hidden") {
12794
+ el.style.setProperty("pointer-events", "auto", "important");
12795
+ el.style.setProperty("visibility", "visible", "important");
12796
+ repaired = true;
12797
+ }
12798
+ for (const header of el.querySelectorAll(".dsv-pane-header")) {
12799
+ if (window.getComputedStyle(header).pointerEvents === "none") {
12800
+ header.style.setProperty("pointer-events", "auto", "important");
12801
+ repaired = true;
12802
+ }
12803
+ }
12804
+ // A pane whose drag-to-reflow was interrupted keeps the inline
12805
+ // pointer-events:none / opacity:0 and stays dead to the mouse.
12806
+ if (reflowState.active !== true && reflowState.settling !== true) {
12807
+ for (const source of el.querySelectorAll("[data-dsv-source]")) {
12808
+ source.removeAttribute("data-dsv-source");
12809
+ if (source.style !== null && source.style !== undefined) {
12810
+ source.style.pointerEvents = "";
12811
+ source.style.opacity = "";
12812
+ }
12813
+ repaired = true;
12814
+ }
12815
+ }
12816
+ } catch {}
12817
+ if (repaired) {
12818
+ try { setRuntime({ canvasRepairs: runtimeState.canvasRepairs + 1 }); } catch {}
12819
+ }
12820
+ });
12821
+ } catch {}
12822
+ return () => {
12823
+ if (raf !== 0) {
12824
+ try { window.cancelAnimationFrame(raf); } catch {}
12825
+ }
12826
+ };
12827
+ }, [visible]);
12828
+
12181
12829
  // One TOC grip per live pane (see tocGripSync): hide the portal copies
12182
12830
  // mounted by the hidden stock view / IM view and keep every pane's grip
12183
12831
  // inside that pane. Portals mount asynchronously, so a body childList
@@ -12221,15 +12869,6 @@ window.__ModuleLoader__.load({
12221
12869
  };
12222
12870
  }, [operational, runtime.performance]);
12223
12871
 
12224
- // A plugin/skills/settings panel replaces the whole main view. The split
12225
- // overlay would cover it, so step aside automatically and keep the tree;
12226
- // the restore chip brings the split back.
12227
- React.useEffect(() => {
12228
- if (!active || minimized) return;
12229
- if (activePanelId === null || activePanelId === undefined) return;
12230
- minimizeWorkspace();
12231
- }, [active, minimized, activePanelId]);
12232
-
12233
12872
  React.useEffect(() => {
12234
12873
  const onPicker = () => setPicker(pickerRequest);
12235
12874
  pickerListeners.add(onPicker);
@@ -12262,12 +12901,53 @@ window.__ModuleLoader__.load({
12262
12901
  // grow over stock UI. A measurement that stops being confident
12263
12902
  // deactivates the workspace (render gate) and the chrome chip says so.
12264
12903
  React.useEffect(() => {
12265
- if (!active || minimized) return undefined;
12904
+ if (!visible) return undefined;
12266
12905
  let raf = 0;
12906
+ let frozen = null;
12267
12907
  const apply = () => {
12268
12908
  raf = 0;
12269
12909
  const next = measureColumnBounds();
12270
12910
  noteGeometry(next);
12911
+ const overlayEl = overlayRef.current;
12912
+ // Freeze is a fluidity-first tradeoff (scaled text while dragging),
12913
+ // so it belongs to performance mode; normal mode keeps transitions
12914
+ // and a true per-frame reflow.
12915
+ if (overlayEl !== null && runtime.performance === true && runtime.resizeFreeze !== false && windowResizing()) {
12916
+ // Live resize: hold the pane layout at the gesture-start size and
12917
+ // scale the rendered layer to the current column box. No setBounds
12918
+ // here — React must not rewrite the insets mid-gesture.
12919
+ if (frozen !== null && (frozen.left !== next.left || frozen.top !== next.top)) {
12920
+ // The sidebar moved (auto-collapse breakpoint): rebase.
12921
+ clearCanvasFreeze(overlayEl);
12922
+ frozen = null;
12923
+ }
12924
+ if (frozen === null) {
12925
+ let rect = null;
12926
+ try { rect = overlayEl.getBoundingClientRect(); } catch {}
12927
+ if (rect !== null && rect.width > 2 && rect.height > 2) {
12928
+ frozen = { w: Math.round(rect.width), h: Math.round(rect.height), left: next.left, top: next.top };
12929
+ }
12930
+ }
12931
+ if (frozen !== null && next.ok) {
12932
+ const targetW = window.innerWidth - next.left - next.right;
12933
+ const targetH = window.innerHeight - next.top - next.bottom;
12934
+ if (applyCanvasFreeze(overlayEl, frozen.w, frozen.h, targetW, targetH, next.left, next.top)) return;
12935
+ }
12936
+ } else if (frozen !== null) {
12937
+ // Gesture over: drop the freeze AND write the final box directly.
12938
+ // React may skip a style write it believes is unchanged, and the
12939
+ // freeze left inline values (right/bottom/transform) behind.
12940
+ clearCanvasFreeze(overlayEl);
12941
+ frozen = null;
12942
+ if (overlayEl !== null) {
12943
+ try {
12944
+ overlayEl.style.left = next.left + "px";
12945
+ overlayEl.style.right = next.right + "px";
12946
+ overlayEl.style.top = next.top + "px";
12947
+ overlayEl.style.bottom = next.bottom + "px";
12948
+ } catch {}
12949
+ }
12950
+ }
12271
12951
  // One warning per unconfident episode (cleared once geometry is
12272
12952
  // back), next to a REAL measurement — the render gate used to warn
12273
12953
  // from the placeholder bounds on every boot.
@@ -12314,25 +12994,34 @@ window.__ModuleLoader__.load({
12314
12994
  }
12315
12995
  }
12316
12996
  } catch {}
12997
+ const offSettle = onLayoutSettle(() => {
12998
+ // Gesture over: the scheduled apply below drops the freeze and writes
12999
+ // the final box in the same frame, so the canvas never spends a
13000
+ // frame at the intermediate "explicit width cleared" state.
13001
+ schedule();
13002
+ });
12317
13003
  window.addEventListener("resize", schedule);
12318
13004
  document.addEventListener("visibilitychange", schedule);
12319
13005
  return () => {
13006
+ offSettle();
12320
13007
  if (raf !== 0) window.cancelAnimationFrame(raf);
12321
13008
  if (observer !== null) {
12322
13009
  try { observer.disconnect(); } catch {}
12323
13010
  }
12324
13011
  if (transitionHost !== null) transitionHost.removeEventListener("transitionend", schedule);
12325
13012
  if (fallbackInterval !== 0) window.clearInterval(fallbackInterval);
13013
+ const overlayEl = overlayRef.current;
13014
+ if (overlayEl !== null) clearCanvasFreeze(overlayEl);
12326
13015
  window.removeEventListener("resize", schedule);
12327
13016
  document.removeEventListener("visibilitychange", schedule);
12328
13017
  };
12329
- }, [active, runtime.performance]);
13018
+ }, [visible, runtime.performance, runtime.resizeFreeze]);
12330
13019
 
12331
13020
  // Crash-loop guard timers: a deliberate activation is persisted BEFORE it
12332
13021
  // can crash; a healthy, responsive workspace clears the counter after
12333
13022
  // HEALTHY_AFTER_MS and refreshes lastHealthyAt at most every 30s.
12334
13023
  React.useEffect(() => {
12335
- if (!active || bounds.ok !== true) return undefined;
13024
+ if (!visible || bounds.ok !== true) return undefined;
12336
13025
  markActivationAttempt();
12337
13026
  const healthyTimer = window.setTimeout(() => { markHealthy(); }, HEALTHY_AFTER_MS);
12338
13027
  const refreshTimer = window.setInterval(() => { refreshHealthy(); }, HEALTHY_REFRESH_MS);
@@ -12340,7 +13029,7 @@ window.__ModuleLoader__.load({
12340
13029
  try { window.clearTimeout(healthyTimer); } catch {}
12341
13030
  try { window.clearInterval(refreshTimer); } catch {}
12342
13031
  };
12343
- }, [active, bounds.ok]);
13032
+ }, [visible, bounds.ok]);
12344
13033
 
12345
13034
  // One-time first-split tip.
12346
13035
  React.useEffect(() => {
@@ -12546,16 +13235,24 @@ window.__ModuleLoader__.load({
12546
13235
  }
12547
13236
  };
12548
13237
 
12549
- // Render gates (after every hook): inactive/safe-mode/kill-switch →
12550
- // nothing; unconfident geometry → nothing. Both fail toward the stock
12551
- // view, never toward a wrong overlay.
12552
- if (!active) return null;
12553
- if (minimized) return null;
12554
- if (!bounds.ok) return null;
13238
+ // Render gates (after every hook). Hidden states keep the canvas mounted
13239
+ // (warm hold) so the expensive pane tree is reused on the way back; only
13240
+ // a cold hold / disabled / <2 panes / independent window unmounts it.
13241
+ if (visible !== true) {
13242
+ if (warmHold !== true || bounds.ok !== true) return null;
13243
+ return h("div", {
13244
+ ref: overlayRef,
13245
+ className: "dsv-overlay dsv-warm",
13246
+ style: { left: bounds.left, right: bounds.right, top: bounds.top, bottom: bounds.bottom },
13247
+ "aria-hidden": "true",
13248
+ }, h(WorkspaceBody, { generation }));
13249
+ }
13250
+ if (bounds.ok !== true) return null;
12555
13251
 
12556
13252
  return h(
12557
13253
  "div",
12558
13254
  {
13255
+ ref: overlayRef,
12559
13256
  className: "dsv-overlay",
12560
13257
  style: { left: bounds.left, right: bounds.right, top: bounds.top, bottom: bounds.bottom },
12561
13258
  tabIndex: -1,
@@ -12577,6 +13274,47 @@ window.__ModuleLoader__.load({
12577
13274
  );
12578
13275
  }
12579
13276
 
13277
+ /** The "分屏视图" main-panel page. The live canvas is the shell.overlay
13278
+ workspace, which stays mounted across panel ⇄ conversation switches so the
13279
+ native pane tree is never re-created for a mere navigation; this page is
13280
+ only the page state — the inline add-split picker while fewer than two
13281
+ conversations are staged, and an empty column the canvas covers once the
13282
+ split exists. */
13283
+ function SplitPanelView() {
13284
+ const runtime = useRuntime();
13285
+ const state = useTree();
13286
+ // Selecting the panel is also the restore affordance for a minimized
13287
+ // split: clear the flag so the (warm, still mounted) canvas shows again.
13288
+ React.useEffect(() => {
13289
+ if (runtime.minimized !== true || splitPanelMinimizeInFlight === true) return;
13290
+ try {
13291
+ setRuntime({ minimized: false });
13292
+ writeMinimized(false);
13293
+ } catch {}
13294
+ }, [runtime.minimized]);
13295
+ const leaves = state.root === null ? [] : leafOf(state.root, []);
13296
+ const splitReady = leaves.length >= 2 && runtime.enabled === true && runtime.safeMode !== true;
13297
+ // Panel-minimize: the canvas is already hidden and the column switch to a
13298
+ // native conversation is deferred one task (that mount costs ~0.5s). Paint
13299
+ // this card in the gap so the click never leaves a frozen blank column.
13300
+ if (splitReady && runtime.minimized === true) {
13301
+ return h("div", { className: "dsv-panel-picker", "data-plugin": PLUGIN_ID },
13302
+ h("div", { className: "dsv-modal dsv-panel-card dsv-panel-card-narrow" },
13303
+ h("div", { className: "dsv-modal-head" },
13304
+ h("span", { className: "dsv-panel-glyph", "aria-hidden": "true" }, h(SplitViewGlyph, { size: 18 })),
13305
+ h("span", { className: "dsv-modal-title" }, t("returningTitle")),
13306
+ ),
13307
+ h("div", { className: "dsv-panel-loading" },
13308
+ h("span", { className: "dsv-panel-spinner", "aria-hidden": "true" }),
13309
+ h("span", null, t("returningHint")),
13310
+ ),
13311
+ ),
13312
+ );
13313
+ }
13314
+ return h("div", { className: "dsv-panel-root", "data-plugin": PLUGIN_ID },
13315
+ splitReady ? null : h(PanelSplitPicker, null));
13316
+ }
13317
+
12580
13318
  // ---------------------------------------------------------------------
12581
13319
  // inactive-mode drag bridge — the split entry point while the overlay is
12582
13320
  // off. Dragging a conversation from the stock sidebar onto the
@@ -12887,6 +13625,32 @@ window.__ModuleLoader__.load({
12887
13625
  try { window.setTimeout(() => { try { rightbarSelfHeal(); } catch {} }, delay === undefined ? 400 : delay); } catch {}
12888
13626
  }
12889
13627
  function minimizeWorkspace() {
13628
+ // While the split-view panel owns the main column, "minimize" means
13629
+ // "step back to the conversation": hide the split and return the column
13630
+ // to the stock conversation view in the same commit (the panel is
13631
+ // leaving, so there is no overlay to fade).
13632
+ if (splitPanelActive()) {
13633
+ splitPanelMinimizeInFlight = true;
13634
+ try { setRuntime({ minimized: true }); writeMinimized(true); } catch {}
13635
+ // Leaving the plugin page for the stock conversation mounts a whole
13636
+ // native conversation synchronously (~0.5s on a live desktop). Run it
13637
+ // as its own task so the click paints immediately: the canvas hides and
13638
+ // the chip + "returning to the conversation" card appear first; only
13639
+ // then does the column switch (and its mount) block.
13640
+ const switchPanel = () => {
13641
+ try { leaveSplitPanel(); } catch {}
13642
+ splitPanelMinimizeInFlight = false;
13643
+ scheduleRightbarHeal(450);
13644
+ };
13645
+ try {
13646
+ window.requestAnimationFrame(() => {
13647
+ window.requestAnimationFrame(switchPanel);
13648
+ });
13649
+ } catch {
13650
+ switchPanel();
13651
+ }
13652
+ return;
13653
+ }
12890
13654
  const finish = () => {
12891
13655
  try { setRuntime({ minimized: true }); writeMinimized(true); } catch {}
12892
13656
  scheduleRightbarHeal(450);
@@ -12906,10 +13670,19 @@ window.__ModuleLoader__.load({
12906
13670
  setRuntime({ minimized: false });
12907
13671
  writeMinimized(false);
12908
13672
  } catch {}
13673
+ // Exiting from the split-view panel returns the main column to the
13674
+ // stock conversation view instead of leaving an empty picker page.
13675
+ leaveSplitPanel();
12909
13676
  // The stock view owns the rightbar again; repair a stale open/collapse
12910
13677
  // state the split teardown may have left behind.
12911
13678
  scheduleRightbarHeal(450);
12912
13679
  };
13680
+ // The panel page leaves with its own router switch; fading the canvas
13681
+ // first would only delay the return to the conversation.
13682
+ if (splitPanelActive()) {
13683
+ finish();
13684
+ return;
13685
+ }
12913
13686
  try {
12914
13687
  const overlay = document.querySelector(".dsv-overlay");
12915
13688
  const target = overlay !== null && overlay !== undefined
@@ -13329,6 +14102,7 @@ window.__ModuleLoader__.load({
13329
14102
  {
13330
14103
  id: "split-plugin",
13331
14104
  label: t("menuGroup"),
14105
+ icon: { key: CONTEXT_ICON_PANEL },
13332
14106
  separatorBefore: true,
13333
14107
  children: [
13334
14108
  {
@@ -13336,6 +14110,7 @@ window.__ModuleLoader__.load({
13336
14110
  // pending pick) exits, everything else joins.
13337
14111
  id: "split",
13338
14112
  label: t(splitMember ? "exitSplit" : "menuAddToSplit"),
14113
+ icon: { key: CONTEXT_ICON_SPLIT },
13339
14114
  run: () => {
13340
14115
  if (splitMember) removeSessionFromSplit(id);
13341
14116
  else if (floatStore.has(id)) dockFloatToSplit(id);
@@ -13345,6 +14120,7 @@ window.__ModuleLoader__.load({
13345
14120
  {
13346
14121
  id: "float",
13347
14122
  label: t(floating ? "menuFloatClose" : "menuFloatOpen"),
14123
+ icon: { key: CONTEXT_ICON_FLOAT },
13348
14124
  run: () => {
13349
14125
  if (floatStore.has(id)) closeFloatWindow(id);
13350
14126
  else floatSession(id);
@@ -13353,6 +14129,7 @@ window.__ModuleLoader__.load({
13353
14129
  {
13354
14130
  id: "independent",
13355
14131
  label: t(independent ? "menuIndependentClose" : "menuIndependentOpen"),
14132
+ icon: { key: CONTEXT_ICON_WINDOW },
13356
14133
  failureLabel: t("systemWindowFailed"),
13357
14134
  run: () => {
13358
14135
  if (independent) closeAppWindowFor(id);
@@ -13362,6 +14139,7 @@ window.__ModuleLoader__.load({
13362
14139
  {
13363
14140
  id: "native",
13364
14141
  label: t(nativeWindow ? "menuNativeClose" : "menuNativeOpen"),
14142
+ icon: { key: CONTEXT_ICON_NATIVE },
13365
14143
  failureLabel: t("systemWindowFailed"),
13366
14144
  run: () => requestSystemWindow(id, nativeWindow ? "close" : "open"),
13367
14145
  },
@@ -13438,6 +14216,35 @@ window.__ModuleLoader__.load({
13438
14216
  );
13439
14217
  }
13440
14218
 
14219
+ /** The pickable-conversation roster shared by the modal "添加分屏" dialog
14220
+ and the split-view panel's inline picker: real, non-blank, non-subagent
14221
+ chat sessions plus any already-selected id that dropped out of the live
14222
+ list (so it can still be unchecked). */
14223
+ function splitPickableItems(sessions, selected) {
14224
+ const items = [];
14225
+ const seen = new Set();
14226
+ if (sessions !== null && sessions !== undefined && Array.isArray(sessions.ids)) {
14227
+ for (const id of sessions.ids) {
14228
+ const summary = sessions.byId ? sessions.byId[id] : undefined;
14229
+ if (summary === undefined || summary === null) continue;
14230
+ if (summary.parentId !== undefined) continue;
14231
+ if (summary.origin === "subagent" || summary.blank === true) continue;
14232
+ if (id.indexOf("session-") !== 0) continue;
14233
+ seen.add(id);
14234
+ items.push({ id, summary, title: summary.displayTitle || summary.title || id });
14235
+ }
14236
+ }
14237
+ for (const id of Array.isArray(selected) ? selected : []) {
14238
+ if (seen.has(id)) continue;
14239
+ seen.add(id);
14240
+ items.push({ id, summary: null, title: id });
14241
+ }
14242
+ // Same ordering as the stock conversation list: most recently updated
14243
+ // first, re-sorted from the live snapshot while the picker is open.
14244
+ items.sort((a, b) => (Number(b.summary && b.summary.updatedAt) || 0) - (Number(a.summary && a.summary.updatedAt) || 0));
14245
+ return items;
14246
+ }
14247
+
13441
14248
  /** Multi-select "添加分屏" dialog. Opened from the footer menu, so the
13442
14249
  current members stay selected and can be unchecked (the final selection
13443
14250
  rebuilds the split) or extended with more conversations. */
@@ -13459,29 +14266,9 @@ window.__ModuleLoader__.load({
13459
14266
  }, []);
13460
14267
 
13461
14268
  const pendingIds = pendingSplitStore.ids();
13462
- const items = [];
13463
- const seen = new Set();
13464
- if (sessions !== null && sessions !== undefined && Array.isArray(sessions.ids)) {
13465
- for (const id of sessions.ids) {
13466
- const summary = sessions.byId ? sessions.byId[id] : undefined;
13467
- if (summary === undefined || summary === null) continue;
13468
- if (summary.parentId !== undefined) continue;
13469
- if (summary.origin === "subagent" || summary.blank === true) continue;
13470
- if (id.indexOf("session-") !== 0) continue;
13471
- seen.add(id);
13472
- items.push({ id, summary, title: summary.displayTitle || summary.title || id });
13473
- }
13474
- }
13475
- // A pane session the list no longer carries (archived/hidden) must stay
13476
- // visible, otherwise it could never be unchecked.
13477
- for (const id of selected) {
13478
- if (seen.has(id)) continue;
13479
- seen.add(id);
13480
- items.push({ id, summary: null, title: id });
13481
- }
13482
14269
  const needle = query.trim().toLowerCase();
13483
- const visible = items.filter((item) => needle === "" || item.title.toLowerCase().includes(needle));
13484
- visible.sort((a, b) => (Number(b.summary && b.summary.updatedAt) || 0) - (Number(a.summary && a.summary.updatedAt) || 0));
14270
+ const visible = splitPickableItems(sessions, selected)
14271
+ .filter((item) => needle === "" || item.title.toLowerCase().includes(needle));
13485
14272
 
13486
14273
  const toggle = (id) => setSelected((previous) => (previous.indexOf(id) === -1
13487
14274
  ? previous.concat([id])
@@ -13586,6 +14373,110 @@ window.__ModuleLoader__.load({
13586
14373
  );
13587
14374
  }
13588
14375
 
14376
+ /** The split-view panel's own page while it cannot show the canvas yet.
14377
+ Three states share one card shell: the kill switch is off (offer Enable),
14378
+ the crash guard paused the split (offer Retry), or fewer than two
14379
+ conversations are staged (the multi-select picker). Confirming the
14380
+ picker with two or more conversations builds the split immediately, so
14381
+ the panel turns into the canvas without leaving the page. */
14382
+ function PanelSplitPicker() {
14383
+ const runtime = useRuntime();
14384
+ const sessions = useSessionsList();
14385
+ const tree = useTree();
14386
+ const treeLeaves = tree === null || tree === undefined || tree.root === null ? [] : leafOf(tree.root, []);
14387
+ const initial = treeLeaves.length > 0 ? treeLeaves.slice() : pendingSplitStore.ids().slice();
14388
+ const [selected, setSelected] = React.useState(initial);
14389
+ const [query, setQuery] = React.useState("");
14390
+ const pendingIds = pendingSplitStore.ids();
14391
+ const items = splitPickableItems(sessions, selected);
14392
+ React.useEffect(() => {
14393
+ try {
14394
+ if (sessionsListSource !== undefined && sessionsListSource !== null
14395
+ && typeof sessionsListSource.refresh === "function") sessionsListSource.refresh();
14396
+ } catch {}
14397
+ }, []);
14398
+ const card = (titleText, bodyText, action, options) => h("div", { className: "dsv-panel-picker", "data-plugin": PLUGIN_ID },
14399
+ h("div", { className: "dsv-modal dsv-panel-card dsv-panel-card-narrow" },
14400
+ h("div", { className: "dsv-modal-head" },
14401
+ h("span", { className: "dsv-panel-glyph", "aria-hidden": "true" }, h(SplitViewGlyph, { size: 18 })),
14402
+ h("span", { className: "dsv-modal-title" }, titleText),
14403
+ ),
14404
+ bodyText !== null && bodyText !== undefined ? h("div", { className: "dsv-modal-hint" }, bodyText) : null,
14405
+ action !== null && action !== undefined
14406
+ ? h("div", { className: "dsv-modal-foot" },
14407
+ h("span", { className: "dsv-modal-count" }, options !== undefined && options.note !== undefined ? options.note : ""),
14408
+ h("button", { type: "button", className: "dsv-modal-btn accent", onClick: action.run }, action.label),
14409
+ )
14410
+ : null,
14411
+ ),
14412
+ );
14413
+ if (runtime.enabled !== true) {
14414
+ return card(t("panelDisabledTitle"), t("panelDisabledBody"), {
14415
+ label: t("panelEnable"),
14416
+ run: () => { try { setEnabled(true); } catch {} },
14417
+ });
14418
+ }
14419
+ if (runtime.safeMode === true) {
14420
+ return card(t("panelSafeTitle"), t("panelSafeBody"), {
14421
+ label: t("retryLabel"),
14422
+ run: () => { try { retryWorkspace(); } catch {} },
14423
+ });
14424
+ }
14425
+ const needle = query.trim().toLowerCase();
14426
+ const visible = items.filter((item) => needle === "" || item.title.toLowerCase().includes(needle));
14427
+ const toggle = (id) => setSelected((previous) => (previous.indexOf(id) === -1
14428
+ ? previous.concat([id])
14429
+ : previous.filter((value) => value !== id)));
14430
+ const confirm = () => {
14431
+ if (selected.length < 2) {
14432
+ showPaneToast(t("panelNeedTwo"), true);
14433
+ return;
14434
+ }
14435
+ if (!buildSplitFromSessions(selected)) showPaneToast(t("panelNeedTwo"), true);
14436
+ };
14437
+ return h("div", { className: "dsv-panel-picker", "data-plugin": PLUGIN_ID },
14438
+ h("div", { className: "dsv-modal dsv-panel-card" },
14439
+ h("div", { className: "dsv-modal-head" },
14440
+ h("span", { className: "dsv-panel-glyph", "aria-hidden": "true" }, h(SplitViewGlyph, { size: 18 })),
14441
+ h("span", { className: "dsv-modal-title" }, t("panelPickTitle")),
14442
+ ),
14443
+ h("div", { className: "dsv-modal-hint" }, t("panelPickHint")),
14444
+ h("input", {
14445
+ className: "dsv-modal-search",
14446
+ type: "search",
14447
+ placeholder: t("railSearch"),
14448
+ value: query,
14449
+ onChange: (event) => setQuery(event.target.value),
14450
+ }),
14451
+ h("div", { className: "dsv-modal-body" },
14452
+ visible.length === 0 ? h("div", { className: "dsv-pick-empty" }, t("panelNoSessions")) : null,
14453
+ visible.map((item) => h(SplitPickRow, {
14454
+ key: item.id,
14455
+ item: {
14456
+ title: item.title,
14457
+ sub: item.summary !== null && item.summary.cwd !== undefined ? basenameOf(item.summary.cwd) : "",
14458
+ tag: treeLeaves.indexOf(item.id) !== -1
14459
+ ? "addSplitInSplit"
14460
+ : (pendingIds.indexOf(item.id) !== -1 ? "addSplitPending" : null),
14461
+ },
14462
+ checked: selected.indexOf(item.id) !== -1,
14463
+ onToggle: () => toggle(item.id),
14464
+ })),
14465
+ ),
14466
+ h("div", { className: "dsv-modal-foot" },
14467
+ h("span", { className: "dsv-modal-count" },
14468
+ selected.length < 2 ? t("panelNeedTwo") : t("addSplitSelected", { n: selected.length })),
14469
+ h("button", {
14470
+ type: "button",
14471
+ className: "dsv-modal-btn accent",
14472
+ disabled: selected.length < 2,
14473
+ onClick: confirm,
14474
+ }, t("panelPickConfirm")),
14475
+ ),
14476
+ ),
14477
+ );
14478
+ }
14479
+
13589
14480
  function SplitLauncherMenu({ request }) {
13590
14481
  const runtime = useRuntime();
13591
14482
  const tree = useTree();
@@ -13671,7 +14562,10 @@ window.__ModuleLoader__.load({
13671
14562
  () => { closeLauncher(); setPerformanceMode(runtime.performance !== true); }),
13672
14563
  row("reload", "↻", t("refreshInterface"), () => { closeLauncher(); try { location.reload(); } catch {} }),
13673
14564
  desktopShell()
13674
- ? row("restart", "⏻", t("restartApp"), () => { closeLauncher(); openRestartDialog(); })
14565
+ // Drawn SVG, not the U+23FB power symbol: that codepoint is missing
14566
+ // from the default CJK font stack on Windows and rendered as a
14567
+ // mojibake box in the launcher menu.
14568
+ ? row("restart", h(RestartIcon, { size: 15 }), t("restartApp"), () => { closeLauncher(); openRestartDialog(); })
13675
14569
  : null,
13676
14570
  row("help", "?", t("helpOpen"), () => { closeLauncher(); openHelp(); }),
13677
14571
  row("reset", "↺", t("menuResetSplit"), () => { closeLauncher(); resetSplitEnvironment(); }, { danger: true }),
@@ -13733,6 +14627,7 @@ window.__ModuleLoader__.load({
13733
14627
  h("section", { className: "dsv-settings-group" },
13734
14628
  h("h3", { className: "dsv-settings-group-title" }, t("settingsActions")),
13735
14629
  h("div", { className: "dsv-settings-actions" },
14630
+ button("panel", t("panelTitle"), () => closeThen(() => selectSplitPanel())),
13736
14631
  button("add", t("menuAddSplit"), () => closeThen(() => openAddSplitDialog("footer")), { accent: true }),
13737
14632
  button("exit", t("exitSplit"), () => { try { exitWorkspace(); } catch {} }, { disabled: !active }),
13738
14633
  button("minimize", t("menuMinimizeSplit"), () => { try { minimizeWorkspace(); } catch {} }, { disabled: !active || runtime.minimized === true }),
@@ -13795,7 +14690,7 @@ window.__ModuleLoader__.load({
13795
14690
  "aria-haspopup": "menu",
13796
14691
  onClick: (event) => openLauncherMenu(event.currentTarget),
13797
14692
  },
13798
- h(SplitIconV, { size: 15 }),
14693
+ h(SplitViewGlyph, { size: 15 }),
13799
14694
  h("span", { className: "dsv-fallback-label" }, t("fallbackLauncher")),
13800
14695
  pending.length > 0 ? h("span", { className: "dsv-footer-badge" }, String(pending.length)) : null,
13801
14696
  );
@@ -13866,6 +14761,9 @@ window.__ModuleLoader__.load({
13866
14761
  React.useEffect(() => {
13867
14762
  if (count === 0) return undefined;
13868
14763
  const clampAll = () => {
14764
+ // Window resizes clamp once at settle (the settle listener below);
14765
+ // this path used to re-measure the column on every resize frame.
14766
+ if (layoutBusy()) return;
13869
14767
  const work = chipWorkRect();
13870
14768
  for (const win of floatStore.getSnapshot().windows) {
13871
14769
  const next = clampFloatRect(win, work);
@@ -13876,6 +14774,7 @@ window.__ModuleLoader__.load({
13876
14774
  };
13877
14775
  clampAll();
13878
14776
  window.addEventListener("resize", clampAll);
14777
+ const offSettle = onLayoutSettle(clampAll);
13879
14778
  // The column can change without a window resize (right-sidebar open/
13880
14779
  // close, shell layout transitions), so re-clamp on a low-frequency
13881
14780
  // backstop while floats exist. setRect is a no-op when nothing moved.
@@ -13883,6 +14782,7 @@ window.__ModuleLoader__.load({
13883
14782
  const timer = performanceModeOn() ? 0 : window.setInterval(clampAll, 1000);
13884
14783
  return () => {
13885
14784
  window.removeEventListener("resize", clampAll);
14785
+ offSettle();
13886
14786
  if (timer !== 0) {
13887
14787
  try { window.clearInterval(timer); } catch {}
13888
14788
  }
@@ -14290,28 +15190,50 @@ window.__ModuleLoader__.load({
14290
15190
  return true;
14291
15191
  }
14292
15192
  function restoreSplit() {
15193
+ // Show the canvas FIRST: while the pane tree is warm-held, unminimizing is
15194
+ // just a visibility flip. The old order ran layout.selectPanel() and a full
15195
+ // native conversation switch (uiWorkspace.openSession) before the state
15196
+ // update, so the user waited through that switch for a view the canvas
15197
+ // immediately covers anyway.
15198
+ setRuntime({ minimized: false });
15199
+ writeMinimized(false);
14293
15200
  try {
14294
- const tree = treeStore.getSnapshot();
14295
- const sid = tree !== null && tree !== undefined
14296
- ? (tree.focus !== null && tree.focus !== undefined ? tree.focus : treeStore.leafIds()[0])
14297
- : undefined;
14298
15201
  const layout = pluginCtx !== null && pluginCtx !== undefined && typeof pluginCtx.get === "function"
14299
15202
  ? pluginCtx.get("layout")
14300
15203
  : null;
14301
15204
  if (layout !== null && layout !== undefined && typeof layout.selectPanel === "function") {
14302
15205
  layout.selectPanel(null);
14303
15206
  }
15207
+ const tree = treeStore.getSnapshot();
15208
+ const sid = tree !== null && tree !== undefined
15209
+ ? (tree.focus !== null && tree.focus !== undefined ? tree.focus : treeStore.leafIds()[0])
15210
+ : undefined;
14304
15211
  if (sid !== undefined && sid !== null) {
14305
15212
  const workspace = pluginCtx !== null && pluginCtx !== undefined && typeof pluginCtx.get === "function"
14306
15213
  ? pluginCtx.get("uiWorkspace")
14307
15214
  : null;
14308
15215
  if (workspace !== null && workspace !== undefined && typeof workspace.openSession === "function") {
14309
- workspace.openSession(sid);
15216
+ // Align the covered stock view a moment later, and skip it when it
15217
+ // already shows that conversation. It stays invisible under the
15218
+ // canvas, so a native session switch there must never gate the
15219
+ // restore itself.
15220
+ window.setTimeout(() => {
15221
+ try {
15222
+ if (currentSessionId() === sid) return;
15223
+ workspace.openSession(sid);
15224
+ } catch {}
15225
+ }, 150);
14310
15226
  }
14311
15227
  }
14312
15228
  } catch {}
14313
- setRuntime({ minimized: false });
14314
- writeMinimized(false);
15229
+ }
15230
+
15231
+ /** The sidebar's "分屏视图" row glyph; the sidebar renders it at its own
15232
+ icon size and tells it whether this panel is the selected one. */
15233
+ function SplitNavIcon(props) {
15234
+ const size = props !== null && props !== undefined && typeof props.size === "number" ? props.size : 18;
15235
+ const active = props !== null && props !== undefined && props.active === true;
15236
+ return h(SplitViewGlyph, { size, active });
14315
15237
  }
14316
15238
 
14317
15239
  /** Sidebar-footer entry point: opens the split menu (add / exit / minimize
@@ -14337,7 +15259,7 @@ window.__ModuleLoader__.load({
14337
15259
  openLauncherMenu(event.currentTarget);
14338
15260
  },
14339
15261
  },
14340
- h(SplitIconV, { size: 15 }),
15262
+ h(SplitViewGlyph, { size: 15 }),
14341
15263
  pending.length > 0 ? h("span", { className: "dsv-footer-badge" }, String(pending.length)) : null,
14342
15264
  );
14343
15265
  }
@@ -14352,6 +15274,25 @@ window.__ModuleLoader__.load({
14352
15274
  const slots = ctx.get("slots");
14353
15275
  if (slots === undefined) return;
14354
15276
  appliedOnce = true;
15277
+ try {
15278
+ install(ctx, slots);
15279
+ } catch (error) {
15280
+ // DSH retries a failed client entry by re-running apply() on the SAME
15281
+ // module exports (the fiber restart does not re-materialize the
15282
+ // bundle), so keeping the once-guard set here would turn a single setup
15283
+ // throw into a plugin that never mounts again — no footer button, no
15284
+ // session menus, no Settings section, until the page is reloaded. That
15285
+ // is the "restart DSH to get the menus back" symptom. Clearing the flag
15286
+ // lets the next retry rebuild everything; whatever this attempt already
15287
+ // registered is disposed with the failed fiber.
15288
+ appliedOnce = false;
15289
+ throw error;
15290
+ }
15291
+ }
15292
+
15293
+ /** Everything one successful apply() installs. Kept separate from the
15294
+ once-guard so a failed setup can clear it before DSH retries. */
15295
+ function install(ctx, slots) {
14355
15296
  const locale = ctx.get("locale");
14356
15297
  pluginCtx = ctx;
14357
15298
  sessionsService = ctx.get("sessions");
@@ -14459,6 +15400,30 @@ window.__ModuleLoader__.load({
14459
15400
  // unload.
14460
15401
  ctx.effect(installSplitSessionMenu, "dsh-split-workspace: session menu");
14461
15402
 
15403
+ // 0.12.0: drawn icons for the session context menu's "分屏插件" group and
15404
+ // its four rows. The context menu resolves each action's icon key
15405
+ // through its inline keyed icon slot; the rows keep their stock text and
15406
+ // hover states, they just gain a glyph in front.
15407
+ const contextIcons = [
15408
+ [CONTEXT_ICON_PANEL, () => h(SplitViewGlyph, { size: 15, active: true })],
15409
+ [CONTEXT_ICON_SPLIT, () => h(TwoPaneGlyph, { size: 15 })],
15410
+ [CONTEXT_ICON_FLOAT, () => h(FloatPaneGlyph, { size: 15 })],
15411
+ [CONTEXT_ICON_WINDOW, () => h(WindowGlyph, { size: 15 })],
15412
+ [CONTEXT_ICON_NATIVE, () => h(NativeWindowGlyph, { size: 15 })],
15413
+ ];
15414
+ for (const entry of contextIcons) {
15415
+ const key = entry[0];
15416
+ const Icon = entry[1];
15417
+ slots.inject("contextMenu.icon", () =>
15418
+ slots.register({ name: "contextMenu.icon", key }, Icon),
15419
+ );
15420
+ }
15421
+
15422
+ // Zero-cost when idle: marks the "layout is changing" window so the
15423
+ // per-pane observers can skip intermediate resize frames and measure
15424
+ // once when the window stops moving (0.12.0 resize responsiveness).
15425
+ ctx.effect(installWindowResizeTracker, "dsh-split-workspace: window resize tracker");
15426
+
14462
15427
  // Right-sidebar repair: the split teardown could leave the sidebar-right
14463
15428
  // store open while its column was closed (the corner button then vanished
14464
15429
  // with no way back) or leave a stock control writing to a seat nobody
@@ -14579,6 +15544,28 @@ window.__ModuleLoader__.load({
14579
15544
  h(FooterSplitButton),
14580
15545
  ),
14581
15546
  );
15547
+ // 0.12.0: the "分屏视图" sidebar entry — a global panel row next to the
15548
+ // stock "插件" row (same sidebar.panellist list) plus the main panel it
15549
+ // selects. The row id and the main key MUST match: the row IS the panel
15550
+ // selector, and the layout resolves the main slot by that key.
15551
+ slots.inject("sidebar.panellist", () =>
15552
+ slots.register({
15553
+ name: "sidebar.panellist",
15554
+ id: SPLIT_PANEL_ID,
15555
+ // Directly below the stock "插件" row (order 0), above the other
15556
+ // customizable panels, so the entry sits at the top of the nav.
15557
+ order: 5,
15558
+ label: () => t("panelTitle"),
15559
+ locale: "splitView",
15560
+ }, SplitNavIcon),
15561
+ );
15562
+ slots.inject("main", () =>
15563
+ slots.register({
15564
+ name: "main",
15565
+ key: SPLIT_PANEL_ID,
15566
+ locale: "splitView",
15567
+ }, (props) => h(SplitPanelView, props)),
15568
+ );
14582
15569
  // A second entry point in the system Settings panel. The slot is
14583
15570
  // declared by the settings shell; injection waits until it exists.
14584
15571
  slots.inject("settings.section", () =>