dsh-split-workspace 0.11.1 → 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.1";
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
  //
@@ -2460,12 +2772,25 @@ window.__ModuleLoader__.load({
2460
2772
  maximized: null,
2461
2773
  minimized: readMinimized(),
2462
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,
2463
2782
  updateReady: null,
2464
2783
  // One conversation in an in-app independent window. DSH Desktop has no
2465
2784
  // plugin-facing BrowserWindow API, so this replaces the old browser
2466
2785
  // window with a first-class surface inside the application.
2467
2786
  appWindow: null,
2468
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
+
2469
2794
  const runtimeListeners = new Set();
2470
2795
  function runtimeSnapshot() {
2471
2796
  return runtimeState;
@@ -2519,6 +2844,16 @@ window.__ModuleLoader__.load({
2519
2844
  showPaneToast(t(next ? "performanceOn" : "performanceOff"), true);
2520
2845
  return next;
2521
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
+ }
2522
2857
 
2523
2858
  /** True only when the workspace may take over the viewport at all. The
2524
2859
  `geometryBlocked` flag closes the diagnosis's "invisible active" hole:
@@ -2662,8 +2997,12 @@ window.__ModuleLoader__.load({
2662
2997
  enabled: runtimeState.enabled,
2663
2998
  safeMode: runtimeState.safeMode,
2664
2999
  active: runtimeState.active,
3000
+ panelSelected: splitPanelActive(),
3001
+ panelWarm: runtimeState.panelWarm === true,
3002
+ canvasRepairs: runtimeState.canvasRepairs,
2665
3003
  minimized: runtimeState.minimized === true,
2666
3004
  performance: runtimeState.performance === true,
3005
+ resizeFreeze: resizeFreezeOn(),
2667
3006
  geometryBlocked: runtimeState.geometryBlocked === true,
2668
3007
  panes: (() => { try { return treeStore.leafIds().length; } catch { return 0; } })(),
2669
3008
  floats: (() => { try { return floatStore.ids(); } catch { return []; } })(),
@@ -2744,6 +3083,7 @@ window.__ModuleLoader__.load({
2744
3083
  try { leaves = treeStore.leafIds().length; } catch { return "unknown"; }
2745
3084
  if (leaves < 2) return "no-split";
2746
3085
  if (runtimeState.minimized === true) return "minimized";
3086
+ if (runtimeState.panelWarm === true) return "panel";
2747
3087
  if (runtimeState.active !== true || runtimeState.geometry.ok !== true) return "geometry";
2748
3088
  return null;
2749
3089
  }
@@ -8269,6 +8609,10 @@ window.__ModuleLoader__.load({
8269
8609
  };
8270
8610
  const tick = () => {
8271
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; }
8272
8616
  apply();
8273
8617
  if (stableCount >= 2) { settleTicks = 0; raf = 0; return; }
8274
8618
  if (settleTicks > 0) { settleTicks -= 1; raf = requestAnimationFrame(tick); }
@@ -8287,8 +8631,10 @@ window.__ModuleLoader__.load({
8287
8631
  mutation.observe(pane, { childList: true, subtree: true, attributes: true, attributeFilter: ["data-composer-card", "data-dsv-composer-card"] });
8288
8632
  }
8289
8633
  const perfTimer = performanceMode ? window.setInterval(schedule, 1500) : 0;
8634
+ const offSettle = onLayoutSettle(schedule);
8290
8635
  raf = requestAnimationFrame(tick);
8291
8636
  return () => {
8637
+ offSettle();
8292
8638
  if (raf !== 0) cancelAnimationFrame(raf);
8293
8639
  observer.disconnect();
8294
8640
  if (mutation !== null) mutation.disconnect();
@@ -8318,14 +8664,18 @@ window.__ModuleLoader__.load({
8318
8664
  const inner = innerRef.current;
8319
8665
  if (row === null || inner === null || typeof ResizeObserver !== "function") return;
8320
8666
  const measure = () => {
8321
- if (inLiveReflow(row)) return;
8667
+ if (inLiveReflow(row) || layoutBusy()) return;
8322
8668
  setOverflown(row.scrollWidth > row.clientWidth + 1);
8323
8669
  };
8324
8670
  measure();
8325
8671
  const observer = new ResizeObserver(measure);
8326
8672
  observer.observe(row);
8327
8673
  observer.observe(inner);
8328
- return () => observer.disconnect();
8674
+ const offSettle = onLayoutSettle(measure);
8675
+ return () => {
8676
+ offSettle();
8677
+ observer.disconnect();
8678
+ };
8329
8679
  // `entries`, not `entries.length`: the cells re-render with new text
8330
8680
  // (a growing tok/s or token count) without changing the cell COUNT, and
8331
8681
  // the overflow flag has to follow that or a longer value stays clipped
@@ -9386,18 +9736,57 @@ window.__ModuleLoader__.load({
9386
9736
  const shortRef = React.useRef(false);
9387
9737
  React.useEffect(() => {
9388
9738
  const el = frameRef.current;
9389
- 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
+ };
9390
9760
  const observer = new ResizeObserver((entries) => {
9391
9761
  if (inLiveReflow(el)) return;
9392
9762
  for (const entry of entries) {
9393
9763
  const w = Math.round(entry.contentRect.width);
9394
9764
  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 }));
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 };
9397
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();
9398
9780
  });
9399
9781
  observer.observe(el);
9400
- 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
+ };
9401
9790
  }, []);
9402
9791
  const narrow = paneSize.w > 0 && paneSize.w < 560;
9403
9792
  // Below this width the six header actions no longer fit: collapse them
@@ -9463,6 +9852,9 @@ window.__ModuleLoader__.load({
9463
9852
  // and passes are capped to ~12/s per pane so a streaming burst cannot
9464
9853
  // turn layout reads into per-commit work (S4).
9465
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;
9466
9858
  const now = Date.now();
9467
9859
  if (now - lastMeasureAt < 80) return;
9468
9860
  lastMeasureAt = now;
@@ -9582,14 +9974,21 @@ window.__ModuleLoader__.load({
9582
9974
  const mutation = !performanceMode && typeof MutationObserver === "function" ? new MutationObserver(schedule) : null;
9583
9975
  if (mutation !== null) mutation.observe(frame, { childList: true, subtree: true });
9584
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);
9585
9981
  schedule();
9586
9982
  return () => {
9983
+ offSettle();
9587
9984
  if (raf !== 0) cancelAnimationFrame(raf);
9588
9985
  observer.disconnect();
9589
9986
  if (mutation !== null) mutation.disconnect();
9590
9987
  if (perfTimer !== 0) window.clearInterval(perfTimer);
9591
9988
  };
9592
- }, [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]);
9593
9992
  // a composer is never narrower than this — narrower "boxes" are
9594
9993
  // transient seats, not the real input; fall back to stock geometry
9595
9994
  const cardBoxSane = cardBox !== null && cardBox.right - cardBox.left >= 160;
@@ -10242,6 +10641,10 @@ window.__ModuleLoader__.load({
10242
10641
  min: Math.max(0.04, MIN_PANE_PX / Math.max(1, total)),
10243
10642
  };
10244
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);
10245
10648
  try {
10246
10649
  event.currentTarget.setPointerCapture(event.pointerId);
10247
10650
  } catch {}
@@ -10262,6 +10665,7 @@ window.__ModuleLoader__.load({
10262
10665
  if (dragRef.current === null || dragRef.current.pointerId !== event.pointerId) return;
10263
10666
  dragRef.current = null;
10264
10667
  setActive(false);
10668
+ markDividerDrag(false);
10265
10669
  treeStore.persistNow();
10266
10670
  if (event.currentTarget.hasPointerCapture(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);
10267
10671
  };
@@ -10812,6 +11216,13 @@ window.__ModuleLoader__.load({
10812
11216
  performanceMode() {
10813
11217
  return safeCall("performanceMode()", () => performanceModeOn(), false);
10814
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
+ },
10815
11226
  /** Reload the page to pick up an updated client bundle (same as Ctrl+R). */
10816
11227
  reloadClient() {
10817
11228
  return safeCall("reloadClient()", () => { try { location.reload(); } catch {} return true; }, false);
@@ -11954,20 +12365,28 @@ window.__ModuleLoader__.load({
11954
12365
  return { left, top, width, height };
11955
12366
  }
11956
12367
 
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. */
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. */
11961
12374
  function MinimizedChip() {
11962
12375
  const MARGIN = 18;
11963
12376
  const ref = React.useRef(null);
11964
12377
  const dragRef = React.useRef(null);
11965
12378
  const defaultPos = () => {
11966
- try { safeRemove(CHIP_KEY); } catch {}
11967
12379
  const work = chipWorkRect();
11968
12380
  const el = ref.current;
11969
12381
  const width = el ? el.offsetWidth : 229;
11970
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
+ }
11971
12390
  return {
11972
12391
  x: work.left + MARGIN,
11973
12392
  y: work.top + work.height - height - MARGIN,
@@ -11976,6 +12395,7 @@ window.__ModuleLoader__.load({
11976
12395
  const [pos, setPos] = React.useState(defaultPos);
11977
12396
  const [dragging, setDragging] = React.useState(false);
11978
12397
 
12398
+
11979
12399
  const clampToWork = React.useCallback((next) => {
11980
12400
  const work = chipWorkRect();
11981
12401
  const el = ref.current;
@@ -11988,6 +12408,9 @@ window.__ModuleLoader__.load({
11988
12408
  }, []);
11989
12409
 
11990
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));
11991
12414
  const onResize = () => setPos((current) => clampToWork(current));
11992
12415
  window.addEventListener("resize", onResize);
11993
12416
  return () => window.removeEventListener("resize", onResize);
@@ -12024,11 +12447,22 @@ window.__ModuleLoader__.load({
12024
12447
  const width = el.offsetWidth;
12025
12448
  const height = el.offsetHeight;
12026
12449
  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));
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);
12032
12466
  };
12033
12467
 
12034
12468
  const style = { left: pos.x + "px", top: pos.y + "px", right: "auto", bottom: "auto" };
@@ -12060,14 +12494,21 @@ window.__ModuleLoader__.load({
12060
12494
  /** Always-mounted overlay-seat chrome: the safe-mode chip (with the tree
12061
12495
  kept), and a "could not start" chip when a persisted split cannot take
12062
12496
  the viewport (geometry fail-closed) — both dismissible and never over
12063
- stock controls. */
12064
- 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 }) {
12065
12500
  const runtime = useRuntime();
12066
12501
  const tree = useTree();
12067
12502
  const leaves = tree.root === null ? 0 : leafOf(tree.root, []).length;
12068
12503
  const wantsActive = runtime.enabled === true && leaves >= 2;
12069
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;
12070
12510
  React.useEffect(() => {
12511
+ if (panelOwnedUi) return undefined;
12071
12512
  if (!wantsActive || runtime.safeMode === true || runtime.active === true) {
12072
12513
  setSettledBlocked(false);
12073
12514
  return undefined;
@@ -12078,7 +12519,8 @@ window.__ModuleLoader__.load({
12078
12519
  return () => {
12079
12520
  try { window.clearTimeout(timer); } catch {}
12080
12521
  };
12081
- }, [wantsActive, runtime.safeMode, runtime.active]);
12522
+ }, [wantsActive, runtime.safeMode, runtime.active, panelOwnedUi]);
12523
+ if (panelOwnedUi) return null;
12082
12524
  if (runtime.enabled !== true) return null;
12083
12525
  if (runtime.minimized === true && wantsActive) {
12084
12526
  return h(MinimizedChip, null);
@@ -12155,10 +12597,18 @@ window.__ModuleLoader__.load({
12155
12597
  const runtime = useRuntime();
12156
12598
  const appWindowState = runtime.appWindow;
12157
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;
12158
12608
  return h(React.Fragment, null,
12159
12609
  h(WorkspaceBoundary, { key: "workspace-" + runtime.epoch },
12160
12610
  h(WorkspaceApp, Object.assign({}, props, { dsvAppWindowOpen: appWindowOpen }))),
12161
- h(PluginChrome, null),
12611
+ h(PluginChrome, { panelOwned }),
12162
12612
  h(WorkspaceBoundary, { key: "floats-" + runtime.epoch }, h(FloatLayer, null)),
12163
12613
  h(SplitLauncherLayer, null),
12164
12614
  h(AppWindowChip, null),
@@ -12170,6 +12620,48 @@ window.__ModuleLoader__.load({
12170
12620
  );
12171
12621
  }
12172
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
+
12173
12665
  function WorkspaceApp(props) {
12174
12666
  // This component IS the plugin's root-scoped seat: `shell.overlay` is
12175
12667
  // declared `kind: list, scope: root`, so the renderer hands it the
@@ -12203,16 +12695,34 @@ window.__ModuleLoader__.load({
12203
12695
  // split tree (and its observers) quiet underneath.
12204
12696
  const appWindowOpen = props.dsvAppWindowOpen === true;
12205
12697
  const active = appWindowOpen !== true && leaves.length >= 2
12206
- && runtime.enabled === true && runtime.safeMode !== true;
12698
+ && runtime.enabled === true && runtime.safeMode !== true && minimized !== true;
12207
12699
  const [picker, setPicker] = React.useState(pickerRequest);
12208
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);
12209
12710
  const geometryWarnedRef = React.useRef(false);
12711
+ const overlayRef = React.useRef(null);
12210
12712
  // B3 "invisible active": the workspace is OPERATIONAL only when it can
12211
12713
  // actually render (>=2 panes AND a confident column measurement). All
12212
12714
  // input/observation paths gate on this, so a persisted split whose
12213
12715
  // geometry fails renders nothing and also does NOT eat Alt+T /
12214
12716
  // Alt+Shift+Arrow (the chrome chip explains the state instead).
12215
- 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;
12216
12726
 
12217
12727
  // The DOM session-list source (0.2.0 path) observes the document only
12218
12728
  // while the workspace is operational — otherwise zero observation cost.
@@ -12230,6 +12740,92 @@ window.__ModuleLoader__.load({
12230
12740
  setRuntime({ active: operational });
12231
12741
  }, [operational]);
12232
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
+
12233
12829
  // One TOC grip per live pane (see tocGripSync): hide the portal copies
12234
12830
  // mounted by the hidden stock view / IM view and keep every pane's grip
12235
12831
  // inside that pane. Portals mount asynchronously, so a body childList
@@ -12273,15 +12869,6 @@ window.__ModuleLoader__.load({
12273
12869
  };
12274
12870
  }, [operational, runtime.performance]);
12275
12871
 
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
12872
  React.useEffect(() => {
12286
12873
  const onPicker = () => setPicker(pickerRequest);
12287
12874
  pickerListeners.add(onPicker);
@@ -12314,12 +12901,53 @@ window.__ModuleLoader__.load({
12314
12901
  // grow over stock UI. A measurement that stops being confident
12315
12902
  // deactivates the workspace (render gate) and the chrome chip says so.
12316
12903
  React.useEffect(() => {
12317
- if (!active || minimized) return undefined;
12904
+ if (!visible) return undefined;
12318
12905
  let raf = 0;
12906
+ let frozen = null;
12319
12907
  const apply = () => {
12320
12908
  raf = 0;
12321
12909
  const next = measureColumnBounds();
12322
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
+ }
12323
12951
  // One warning per unconfident episode (cleared once geometry is
12324
12952
  // back), next to a REAL measurement — the render gate used to warn
12325
12953
  // from the placeholder bounds on every boot.
@@ -12366,25 +12994,34 @@ window.__ModuleLoader__.load({
12366
12994
  }
12367
12995
  }
12368
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
+ });
12369
13003
  window.addEventListener("resize", schedule);
12370
13004
  document.addEventListener("visibilitychange", schedule);
12371
13005
  return () => {
13006
+ offSettle();
12372
13007
  if (raf !== 0) window.cancelAnimationFrame(raf);
12373
13008
  if (observer !== null) {
12374
13009
  try { observer.disconnect(); } catch {}
12375
13010
  }
12376
13011
  if (transitionHost !== null) transitionHost.removeEventListener("transitionend", schedule);
12377
13012
  if (fallbackInterval !== 0) window.clearInterval(fallbackInterval);
13013
+ const overlayEl = overlayRef.current;
13014
+ if (overlayEl !== null) clearCanvasFreeze(overlayEl);
12378
13015
  window.removeEventListener("resize", schedule);
12379
13016
  document.removeEventListener("visibilitychange", schedule);
12380
13017
  };
12381
- }, [active, runtime.performance]);
13018
+ }, [visible, runtime.performance, runtime.resizeFreeze]);
12382
13019
 
12383
13020
  // Crash-loop guard timers: a deliberate activation is persisted BEFORE it
12384
13021
  // can crash; a healthy, responsive workspace clears the counter after
12385
13022
  // HEALTHY_AFTER_MS and refreshes lastHealthyAt at most every 30s.
12386
13023
  React.useEffect(() => {
12387
- if (!active || bounds.ok !== true) return undefined;
13024
+ if (!visible || bounds.ok !== true) return undefined;
12388
13025
  markActivationAttempt();
12389
13026
  const healthyTimer = window.setTimeout(() => { markHealthy(); }, HEALTHY_AFTER_MS);
12390
13027
  const refreshTimer = window.setInterval(() => { refreshHealthy(); }, HEALTHY_REFRESH_MS);
@@ -12392,7 +13029,7 @@ window.__ModuleLoader__.load({
12392
13029
  try { window.clearTimeout(healthyTimer); } catch {}
12393
13030
  try { window.clearInterval(refreshTimer); } catch {}
12394
13031
  };
12395
- }, [active, bounds.ok]);
13032
+ }, [visible, bounds.ok]);
12396
13033
 
12397
13034
  // One-time first-split tip.
12398
13035
  React.useEffect(() => {
@@ -12598,16 +13235,24 @@ window.__ModuleLoader__.load({
12598
13235
  }
12599
13236
  };
12600
13237
 
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;
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;
12607
13251
 
12608
13252
  return h(
12609
13253
  "div",
12610
13254
  {
13255
+ ref: overlayRef,
12611
13256
  className: "dsv-overlay",
12612
13257
  style: { left: bounds.left, right: bounds.right, top: bounds.top, bottom: bounds.bottom },
12613
13258
  tabIndex: -1,
@@ -12629,6 +13274,47 @@ window.__ModuleLoader__.load({
12629
13274
  );
12630
13275
  }
12631
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
+
12632
13318
  // ---------------------------------------------------------------------
12633
13319
  // inactive-mode drag bridge — the split entry point while the overlay is
12634
13320
  // off. Dragging a conversation from the stock sidebar onto the
@@ -12939,6 +13625,32 @@ window.__ModuleLoader__.load({
12939
13625
  try { window.setTimeout(() => { try { rightbarSelfHeal(); } catch {} }, delay === undefined ? 400 : delay); } catch {}
12940
13626
  }
12941
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
+ }
12942
13654
  const finish = () => {
12943
13655
  try { setRuntime({ minimized: true }); writeMinimized(true); } catch {}
12944
13656
  scheduleRightbarHeal(450);
@@ -12958,10 +13670,19 @@ window.__ModuleLoader__.load({
12958
13670
  setRuntime({ minimized: false });
12959
13671
  writeMinimized(false);
12960
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();
12961
13676
  // The stock view owns the rightbar again; repair a stale open/collapse
12962
13677
  // state the split teardown may have left behind.
12963
13678
  scheduleRightbarHeal(450);
12964
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
+ }
12965
13686
  try {
12966
13687
  const overlay = document.querySelector(".dsv-overlay");
12967
13688
  const target = overlay !== null && overlay !== undefined
@@ -13381,6 +14102,7 @@ window.__ModuleLoader__.load({
13381
14102
  {
13382
14103
  id: "split-plugin",
13383
14104
  label: t("menuGroup"),
14105
+ icon: { key: CONTEXT_ICON_PANEL },
13384
14106
  separatorBefore: true,
13385
14107
  children: [
13386
14108
  {
@@ -13388,6 +14110,7 @@ window.__ModuleLoader__.load({
13388
14110
  // pending pick) exits, everything else joins.
13389
14111
  id: "split",
13390
14112
  label: t(splitMember ? "exitSplit" : "menuAddToSplit"),
14113
+ icon: { key: CONTEXT_ICON_SPLIT },
13391
14114
  run: () => {
13392
14115
  if (splitMember) removeSessionFromSplit(id);
13393
14116
  else if (floatStore.has(id)) dockFloatToSplit(id);
@@ -13397,6 +14120,7 @@ window.__ModuleLoader__.load({
13397
14120
  {
13398
14121
  id: "float",
13399
14122
  label: t(floating ? "menuFloatClose" : "menuFloatOpen"),
14123
+ icon: { key: CONTEXT_ICON_FLOAT },
13400
14124
  run: () => {
13401
14125
  if (floatStore.has(id)) closeFloatWindow(id);
13402
14126
  else floatSession(id);
@@ -13405,6 +14129,7 @@ window.__ModuleLoader__.load({
13405
14129
  {
13406
14130
  id: "independent",
13407
14131
  label: t(independent ? "menuIndependentClose" : "menuIndependentOpen"),
14132
+ icon: { key: CONTEXT_ICON_WINDOW },
13408
14133
  failureLabel: t("systemWindowFailed"),
13409
14134
  run: () => {
13410
14135
  if (independent) closeAppWindowFor(id);
@@ -13414,6 +14139,7 @@ window.__ModuleLoader__.load({
13414
14139
  {
13415
14140
  id: "native",
13416
14141
  label: t(nativeWindow ? "menuNativeClose" : "menuNativeOpen"),
14142
+ icon: { key: CONTEXT_ICON_NATIVE },
13417
14143
  failureLabel: t("systemWindowFailed"),
13418
14144
  run: () => requestSystemWindow(id, nativeWindow ? "close" : "open"),
13419
14145
  },
@@ -13490,6 +14216,35 @@ window.__ModuleLoader__.load({
13490
14216
  );
13491
14217
  }
13492
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
+
13493
14248
  /** Multi-select "添加分屏" dialog. Opened from the footer menu, so the
13494
14249
  current members stay selected and can be unchecked (the final selection
13495
14250
  rebuilds the split) or extended with more conversations. */
@@ -13511,29 +14266,9 @@ window.__ModuleLoader__.load({
13511
14266
  }, []);
13512
14267
 
13513
14268
  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
14269
  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));
14270
+ const visible = splitPickableItems(sessions, selected)
14271
+ .filter((item) => needle === "" || item.title.toLowerCase().includes(needle));
13537
14272
 
13538
14273
  const toggle = (id) => setSelected((previous) => (previous.indexOf(id) === -1
13539
14274
  ? previous.concat([id])
@@ -13638,6 +14373,110 @@ window.__ModuleLoader__.load({
13638
14373
  );
13639
14374
  }
13640
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
+
13641
14480
  function SplitLauncherMenu({ request }) {
13642
14481
  const runtime = useRuntime();
13643
14482
  const tree = useTree();
@@ -13723,7 +14562,10 @@ window.__ModuleLoader__.load({
13723
14562
  () => { closeLauncher(); setPerformanceMode(runtime.performance !== true); }),
13724
14563
  row("reload", "↻", t("refreshInterface"), () => { closeLauncher(); try { location.reload(); } catch {} }),
13725
14564
  desktopShell()
13726
- ? 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(); })
13727
14569
  : null,
13728
14570
  row("help", "?", t("helpOpen"), () => { closeLauncher(); openHelp(); }),
13729
14571
  row("reset", "↺", t("menuResetSplit"), () => { closeLauncher(); resetSplitEnvironment(); }, { danger: true }),
@@ -13785,6 +14627,7 @@ window.__ModuleLoader__.load({
13785
14627
  h("section", { className: "dsv-settings-group" },
13786
14628
  h("h3", { className: "dsv-settings-group-title" }, t("settingsActions")),
13787
14629
  h("div", { className: "dsv-settings-actions" },
14630
+ button("panel", t("panelTitle"), () => closeThen(() => selectSplitPanel())),
13788
14631
  button("add", t("menuAddSplit"), () => closeThen(() => openAddSplitDialog("footer")), { accent: true }),
13789
14632
  button("exit", t("exitSplit"), () => { try { exitWorkspace(); } catch {} }, { disabled: !active }),
13790
14633
  button("minimize", t("menuMinimizeSplit"), () => { try { minimizeWorkspace(); } catch {} }, { disabled: !active || runtime.minimized === true }),
@@ -13847,7 +14690,7 @@ window.__ModuleLoader__.load({
13847
14690
  "aria-haspopup": "menu",
13848
14691
  onClick: (event) => openLauncherMenu(event.currentTarget),
13849
14692
  },
13850
- h(SplitIconV, { size: 15 }),
14693
+ h(SplitViewGlyph, { size: 15 }),
13851
14694
  h("span", { className: "dsv-fallback-label" }, t("fallbackLauncher")),
13852
14695
  pending.length > 0 ? h("span", { className: "dsv-footer-badge" }, String(pending.length)) : null,
13853
14696
  );
@@ -13918,6 +14761,9 @@ window.__ModuleLoader__.load({
13918
14761
  React.useEffect(() => {
13919
14762
  if (count === 0) return undefined;
13920
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;
13921
14767
  const work = chipWorkRect();
13922
14768
  for (const win of floatStore.getSnapshot().windows) {
13923
14769
  const next = clampFloatRect(win, work);
@@ -13928,6 +14774,7 @@ window.__ModuleLoader__.load({
13928
14774
  };
13929
14775
  clampAll();
13930
14776
  window.addEventListener("resize", clampAll);
14777
+ const offSettle = onLayoutSettle(clampAll);
13931
14778
  // The column can change without a window resize (right-sidebar open/
13932
14779
  // close, shell layout transitions), so re-clamp on a low-frequency
13933
14780
  // backstop while floats exist. setRect is a no-op when nothing moved.
@@ -13935,6 +14782,7 @@ window.__ModuleLoader__.load({
13935
14782
  const timer = performanceModeOn() ? 0 : window.setInterval(clampAll, 1000);
13936
14783
  return () => {
13937
14784
  window.removeEventListener("resize", clampAll);
14785
+ offSettle();
13938
14786
  if (timer !== 0) {
13939
14787
  try { window.clearInterval(timer); } catch {}
13940
14788
  }
@@ -14342,28 +15190,50 @@ window.__ModuleLoader__.load({
14342
15190
  return true;
14343
15191
  }
14344
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);
14345
15200
  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
15201
  const layout = pluginCtx !== null && pluginCtx !== undefined && typeof pluginCtx.get === "function"
14351
15202
  ? pluginCtx.get("layout")
14352
15203
  : null;
14353
15204
  if (layout !== null && layout !== undefined && typeof layout.selectPanel === "function") {
14354
15205
  layout.selectPanel(null);
14355
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;
14356
15211
  if (sid !== undefined && sid !== null) {
14357
15212
  const workspace = pluginCtx !== null && pluginCtx !== undefined && typeof pluginCtx.get === "function"
14358
15213
  ? pluginCtx.get("uiWorkspace")
14359
15214
  : null;
14360
15215
  if (workspace !== null && workspace !== undefined && typeof workspace.openSession === "function") {
14361
- 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);
14362
15226
  }
14363
15227
  }
14364
15228
  } catch {}
14365
- setRuntime({ minimized: false });
14366
- 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 });
14367
15237
  }
14368
15238
 
14369
15239
  /** Sidebar-footer entry point: opens the split menu (add / exit / minimize
@@ -14389,7 +15259,7 @@ window.__ModuleLoader__.load({
14389
15259
  openLauncherMenu(event.currentTarget);
14390
15260
  },
14391
15261
  },
14392
- h(SplitIconV, { size: 15 }),
15262
+ h(SplitViewGlyph, { size: 15 }),
14393
15263
  pending.length > 0 ? h("span", { className: "dsv-footer-badge" }, String(pending.length)) : null,
14394
15264
  );
14395
15265
  }
@@ -14530,6 +15400,30 @@ window.__ModuleLoader__.load({
14530
15400
  // unload.
14531
15401
  ctx.effect(installSplitSessionMenu, "dsh-split-workspace: session menu");
14532
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
+
14533
15427
  // Right-sidebar repair: the split teardown could leave the sidebar-right
14534
15428
  // store open while its column was closed (the corner button then vanished
14535
15429
  // with no way back) or leave a stock control writing to a seat nobody
@@ -14650,6 +15544,28 @@ window.__ModuleLoader__.load({
14650
15544
  h(FooterSplitButton),
14651
15545
  ),
14652
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
+ );
14653
15569
  // A second entry point in the system Settings panel. The slot is
14654
15570
  // declared by the settings shell; injection waits until it exists.
14655
15571
  slots.inject("settings.section", () =>