dsh-split-workspace 0.4.3 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +310 -4
  2. package/lib/client.js +2010 -84
  3. package/lib/index.js +154 -6
  4. package/package.json +17 -5
package/lib/client.js CHANGED
@@ -1,3 +1,5 @@
1
+ // GENERATED FILE — edit src/client/*.js and run `npm run build`.
2
+ // The sections share one module-loader closure; their order matters.
1
3
  // dsh-split-workspace — browser half (module-loader bundle)
2
4
  //
3
5
  // ARCHITECTURE MAP (top → bottom):
@@ -73,7 +75,7 @@ window.__ModuleLoader__.load({
73
75
  // ---------------------------------------------------------------------
74
76
 
75
77
  const PLUGIN_ID = "dsh-split-workspace";
76
- const PLUGIN_VERSION = "0.4.3";
78
+ const PLUGIN_VERSION = "0.8.0";
77
79
  const LOG_PREFIX = "[dsh-split-workspace]";
78
80
  const TREE_KEY = "dsh.split-workspace.tree.v1";
79
81
  const OPEN_KEY = "dsh.split-workspace.open.v2";
@@ -83,6 +85,27 @@ window.__ModuleLoader__.load({
83
85
  const HINT_KEY = "dsh.split-workspace.hint.v1";
84
86
  const MIN_KEY = "dsh.split-workspace.minimized.v1";
85
87
  const CHIP_KEY = "dsh.split-workspace.chip.v1";
88
+ const FLOAT_KEY = "dsh.split-workspace.float.v1";
89
+ const PERF_KEY = "dsh.split-workspace.performance.v1";
90
+ const SEEN_VERSION_KEY = "dsh.split-workspace.seen-version.v1";
91
+ const UPDATE_DISMISSED_KEY = "dsh.split-workspace.update-dismissed.v1";
92
+ const UPDATE_POLL_MS = 120000;
93
+ /** `#dsvWindow=<sessionId>` marks a standalone system window opened by
94
+ the Host route: that page renders exactly one conversation and nothing
95
+ else (the split workspace and floats are skipped there). Read lazily on
96
+ every seat render: the fragment can be applied after a plugin bundle is
97
+ evaluated on some hosts, so a load-time snapshot is not reliable. */
98
+ function standaloneSessionId() {
99
+ try {
100
+ if (typeof window === "undefined" || window.location === undefined) return null;
101
+ const hash = String(window.location.hash || "");
102
+ if (hash.length < 2) return null;
103
+ const id = new URLSearchParams(hash.slice(1)).get("dsvWindow");
104
+ return id !== null && id !== undefined && id !== "" && isValidSessionId(id) ? id : null;
105
+ } catch {
106
+ return null;
107
+ }
108
+ }
86
109
  function readChipPos() {
87
110
  const raw = storageGet(CHIP_KEY);
88
111
  if (!raw) return null;
@@ -104,6 +127,14 @@ window.__ModuleLoader__.load({
104
127
  function writeMinimized(value) {
105
128
  storageSet(MIN_KEY, value === true ? "1" : "0");
106
129
  }
130
+ /** Performance mode is a persisted, user-visible preference: it trades
131
+ optional observers / animations for responsiveness on slow machines. */
132
+ function readPerformanceMode() {
133
+ return storageGet(PERF_KEY) === "1";
134
+ }
135
+ function writePerformanceMode(value) {
136
+ storageSet(PERF_KEY, value === true ? "1" : "0");
137
+ }
107
138
  /* There is exactly one layout policy: AUTO, derived from the pane count.
108
139
  The old per-run mode menu (columns/rows/grid) is gone: it only ever
109
140
  produced a hand-picked arrangement that the next add/close immediately
@@ -310,7 +341,8 @@ window.__ModuleLoader__.load({
310
341
  if (pane === null && sourceEl.nodeType === 1 && sourceEl.classList && sourceEl.classList.contains("dsv-pane")) pane = sourceEl;
311
342
  }
312
343
  } catch {}
313
- const simpleOnly = typeof window !== "undefined" && window.__DSV_SIMPLE_PREVIEW === true;
344
+ const simpleOnly = (typeof window !== "undefined" && window.__DSV_SIMPLE_PREVIEW === true)
345
+ || performanceModeOn();
314
346
  const realThumb = typeof window !== "undefined" && window.__DSV_REAL_THUMB === true;
315
347
  try {
316
348
  if (simpleOnly !== true && pane !== null && pane !== undefined) {
@@ -480,7 +512,7 @@ window.__ModuleLoader__.load({
480
512
  host); it only gets one console note and a health() flag.
481
513
  0.2.1-rc.2 signed off by the release verifier on the isolated real
482
514
  0.2.1 desktop host (docs/VERIFICATION-2026-10-19.md). */
483
- const TESTED_RELEASES = ["0.2.0-rc.2", "0.2.1-rc.2"];
515
+ const TESTED_RELEASES = ["0.2.0-rc.2", "0.2.1-rc.2", "0.2.2-rc.3"];
484
516
  /** The conversation column must be at least this big to be usable. */
485
517
  const COLUMN_MIN_WIDTH = 360;
486
518
  const COLUMN_MIN_HEIGHT = 240;
@@ -538,7 +570,7 @@ window.__ModuleLoader__.load({
538
570
  helpOpen: "Split view help",
539
571
  helpClose: "Close",
540
572
  helpShortcuts: "Shortcuts",
541
- helpGestures: "Drag a conversation from the sidebar onto the page to start a split. Drag a pane by its header to move it: its slot closes and a dashed hole previews where it will land. Drag the dividers to resize. ✕ closes a pane.",
573
+ helpGestures: "Use the sidebar-footer split menu (Add split / Exit split / Minimize / Reset split) or drag a conversation from the sidebar onto the page to start a split. Right-click a conversation for Add to split / Leave split / Enter floating window; a floating window's Dock to split button puts it back. Drag a pane by its header to move it: its slot closes and a dashed hole previews where it will land. Drag the dividers to resize. ✕ closes a pane.",
542
574
  helpDisable: "Disable split view: run window.__dshSplitWorkspace.setEnabled(false), or set localStorage 'dsh.split-workspace.enabled.v1' to \"0\". Reset the layout: window.__dshSplitWorkspace.reset().",
543
575
  helpDiagnostics: "Diagnostics: window.__dshSplitWorkspace.health() — see the README section “Safety, recovery and diagnostics”.",
544
576
  tipTitle: "Split view is on",
@@ -558,6 +590,48 @@ window.__ModuleLoader__.load({
558
590
  dragHint: "Drop into a pane to split",
559
591
  dragHintPane: "Release to place the pane",
560
592
  pickerEmpty: "No other conversations available",
593
+ menuTitle: "Split view menu",
594
+ menuAddSplit: "Add split",
595
+ menuAddToSplit: "Add to split",
596
+ menuMinimizeSplit: "Minimize split",
597
+ menuResetSplit: "Reset split",
598
+ resetDone: "Split view data cleared — layout, cache and temporary state were removed.",
599
+ pendingAdded: "Added to the pending split. Add one more conversation to start splitting.",
600
+ pendingBadge: "{n} pending",
601
+ addSplitTitle: "Add split",
602
+ addSplitHint: "Select the conversations to split. Unchecking a pane removes it; fewer than two conversations exits split view.",
603
+ addSplitSelected: "{n} selected",
604
+ addSplitConfirm: "OK",
605
+ addSplitCancel: "Cancel",
606
+ addSplitEmpty: "No conversations available",
607
+ addSplitInSplit: "In split",
608
+ addSplitPending: "Pending",
609
+ splitExited: "Split view closed",
610
+ splitLeft: "Left split view",
611
+ menuFloatOpen: "Enter floating window",
612
+ menuFloatClose: "Exit floating window",
613
+ floatDock: "Dock to split",
614
+ floatClose: "Close floating window",
615
+ floatEntered: "Opened in a floating window",
616
+ floatDocked: "Docked to the split view",
617
+ floatClosed: "Floating window closed",
618
+ floatHint: "Drag the title bar to move · drag an edge to resize",
619
+ helpFloat: "Right-click a conversation → Enter floating window detaches it into a movable window; Dock to split puts it back.",
620
+ menuSystemWindow: "Open in system window",
621
+ systemWindowOpened: "Opened in a separate system window",
622
+ systemWindowFailed: "Could not open a system window",
623
+ standaloneFullscreen: "Fullscreen",
624
+ performanceMode: "Performance mode",
625
+ performanceOn: "Performance mode on — animations and background observers are reduced",
626
+ performanceOff: "Performance mode off",
627
+ reloadClient: "Reload interface",
628
+ refreshInterface: "Refresh interface",
629
+ updateReady: "Version {v} is installed — reload to apply",
630
+ updateRestart: "Version {v} is installed — restart DSH to apply",
631
+ reloadNow: "Reload now",
632
+ gotIt: "Got it",
633
+ laterLabel: "Later",
634
+ updatedToast: "Updated to v{v}",
561
635
  };
562
636
  const ZH = {
563
637
  label: "分屏视图",
@@ -612,7 +686,7 @@ window.__ModuleLoader__.load({
612
686
  helpOpen: "分屏帮助",
613
687
  helpClose: "关闭",
614
688
  helpShortcuts: "快捷键",
615
- helpGestures: "从左侧会话列表把对话拖到页面即可开始分屏;拖住面板标题栏可移动面板:原位置收起,虚线空位预览落点。拖动分隔条可调整大小,✕ 关闭面板。",
689
+ helpGestures: "点击侧边栏底部的分屏按钮打开菜单(添加分屏 / 退出分屏 / 最小化分屏 / 重置分屏),或从左侧会话列表把对话拖到页面即可分屏;右键会话可加入 / 退出分屏,也可以“进入浮窗”把会话变成独立浮窗(浮窗标题栏的“回到分屏”可放回)。拖住面板标题栏可移动面板:原位置收起,虚线空位预览落点。拖动分隔条可调整大小,✕ 关闭面板。",
616
690
  helpDisable: "停用分屏:运行 window.__dshSplitWorkspace.setEnabled(false),或将 localStorage 'dsh.split-workspace.enabled.v1' 设为 \"0\"。重置布局:window.__dshSplitWorkspace.reset()。",
617
691
  helpDiagnostics: "诊断:window.__dshSplitWorkspace.health() — 详见 README“安全性、恢复与诊断”。",
618
692
  tipTitle: "分屏视图已开启",
@@ -632,6 +706,48 @@ window.__ModuleLoader__.load({
632
706
  dragHint: "拖入面板即可分屏",
633
707
  dragHintPane: "松开即可放置面板",
634
708
  pickerEmpty: "没有可用的其他会话",
709
+ menuTitle: "分屏菜单",
710
+ menuAddSplit: "添加分屏",
711
+ menuAddToSplit: "加入分屏",
712
+ menuMinimizeSplit: "最小化分屏",
713
+ menuResetSplit: "重置分屏",
714
+ resetDone: "分屏数据已重置 — 布局、缓存与临时状态已清空。",
715
+ pendingAdded: "已加入待分屏,再添加一个会话即可开始分屏。",
716
+ pendingBadge: "{n} 个待分屏",
717
+ addSplitTitle: "添加分屏",
718
+ addSplitHint: "勾选要分屏的会话;取消勾选会移除对应面板,少于两个会话将退出分屏。",
719
+ addSplitSelected: "已选 {n} 个",
720
+ addSplitConfirm: "确定",
721
+ addSplitCancel: "取消",
722
+ addSplitEmpty: "没有可用的会话",
723
+ addSplitInSplit: "分屏中",
724
+ addSplitPending: "待分屏",
725
+ splitExited: "已退出分屏",
726
+ splitLeft: "已退出分屏",
727
+ menuFloatOpen: "进入浮窗",
728
+ menuFloatClose: "退出浮窗",
729
+ floatDock: "回到分屏",
730
+ floatClose: "关闭浮窗",
731
+ floatEntered: "已在浮窗中打开",
732
+ floatDocked: "已回到分屏",
733
+ floatClosed: "浮窗已关闭",
734
+ floatHint: "拖动标题栏移动 · 拖动边缘调整大小",
735
+ helpFloat: "右键会话 → 进入浮窗,可把该会话变成独立浮窗;浮窗标题栏的“回到分屏”可放回分屏。",
736
+ menuSystemWindow: "在系统窗口打开",
737
+ systemWindowOpened: "已在独立系统窗口中打开",
738
+ systemWindowFailed: "无法打开系统窗口",
739
+ standaloneFullscreen: "全屏",
740
+ performanceMode: "性能模式",
741
+ performanceOn: "性能模式已开启:动画与后台观察器已精简",
742
+ performanceOff: "性能模式已关闭",
743
+ reloadClient: "重载界面",
744
+ refreshInterface: "刷新界面",
745
+ updateReady: "已安装 v{v},刷新页面生效",
746
+ updateRestart: "已安装 v{v},请重启 DSH 后生效",
747
+ reloadNow: "刷新页面",
748
+ gotIt: "知道了",
749
+ laterLabel: "稍后",
750
+ updatedToast: "已更新到 v{v}",
635
751
  };
636
752
 
637
753
  /** Fallback translator: every locale wrapper unwraps back to this. */
@@ -756,11 +872,206 @@ window.__ModuleLoader__.load({
756
872
  }
757
873
  .dsv-layout-icon svg { display: block; }
758
874
  .dsv-footer-btn {
875
+ position: relative;
759
876
  display: inline-flex; align-items: center; justify-content: center;
760
877
  width: 28px; height: 28px; padding: 0; border: 0; border-radius: 7px;
761
878
  background: transparent; color: var(--dsw-alias-label-secondary); cursor: pointer;
762
879
  }
763
- .dsv-footer-btn:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
880
+ .dsv-footer-btn:hover,
881
+ .dsv-footer-btn[data-open="true"] { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
882
+ .dsv-footer-btn[data-open="true"] { color: var(--dsw-static-deepseek-500); }
883
+ .dsv-footer-badge {
884
+ position: absolute; top: -3px; right: -3px; min-width: 13px; height: 13px; padding: 0 3px;
885
+ display: inline-flex; align-items: center; justify-content: center;
886
+ border-radius: 999px; background: var(--dsw-static-deepseek-500); color: #fff;
887
+ font-size: 9px; line-height: 1; font-weight: 600; pointer-events: none;
888
+ box-shadow: 0 0 0 1.5px var(--dsw-alias-bg-layer-1, var(--dsw-alias-bg-base));
889
+ }
890
+
891
+ /* ---- 0.5.0 launcher: the sidebar footer menu and the multi-select
892
+ "add split" dialog. Both mount through the shell overlay seat, so they
893
+ are never clipped by the sidebar column or the split overlay. ---- */
894
+ .dsv-launcher-menu {
895
+ position: fixed; z-index: 140; width: 200px; padding: 6px;
896
+ border: 1px solid var(--dsw-alias-border-l2); border-radius: 12px;
897
+ background: var(--dsw-alias-bg-layer-1, var(--dsw-alias-bg-base));
898
+ box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
899
+ color: var(--dsw-alias-label-primary);
900
+ font-family: var(--dsw-font-family, system-ui, sans-serif);
901
+ animation: dsv-launcher-in 0.12s ease-out;
902
+ }
903
+ .dsv-launcher-header {
904
+ padding: 4px 8px 6px; font-size: 11px; line-height: 15px;
905
+ color: var(--dsw-alias-label-tertiary);
906
+ white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
907
+ }
908
+ .dsv-launcher-item {
909
+ display: flex; align-items: center; gap: 8px; width: 100%; height: 32px; padding: 0 8px;
910
+ border: 0; border-radius: 8px; background: transparent; color: inherit;
911
+ font: inherit; font-size: 13px; text-align: left; cursor: pointer;
912
+ }
913
+ .dsv-launcher-item:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
914
+ .dsv-launcher-item:disabled { opacity: 0.42; cursor: default; }
915
+ .dsv-launcher-item.danger { color: #e5484d; }
916
+ .dsv-launcher-item.danger:hover:not(:disabled) { background: color-mix(in srgb, #e5484d 12%, transparent); }
917
+ .dsv-launcher-icon { flex: none; width: 18px; display: grid; place-items: center; font-size: 13px; line-height: 1; opacity: 0.85; }
918
+ .dsv-launcher-separator { height: 1px; margin: 5px 8px; background: var(--dsw-alias-border-l2); }
919
+ @keyframes dsv-launcher-in { from { opacity: 0; transform: translateY(4px); } }
920
+
921
+ .dsv-modal-backdrop {
922
+ position: fixed; inset: 0; z-index: 150;
923
+ display: flex; align-items: center; justify-content: center;
924
+ background: rgba(0, 0, 0, 0.32);
925
+ animation: dsv-fade-in 0.12s ease-out;
926
+ font-family: var(--dsw-font-family, system-ui, sans-serif);
927
+ }
928
+ .dsv-modal {
929
+ width: min(520px, calc(100vw - 32px)); max-height: min(620px, calc(100vh - 64px));
930
+ display: flex; flex-direction: column; overflow: hidden;
931
+ border: 1px solid var(--dsw-alias-border-l2); border-radius: 14px;
932
+ background: var(--dsw-alias-bg-layer-1, var(--dsw-alias-bg-base));
933
+ color: var(--dsw-alias-label-primary);
934
+ box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
935
+ }
936
+ .dsv-modal-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 14px 16px 8px; }
937
+ .dsv-modal-title { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; }
938
+ .dsv-modal-close {
939
+ flex: none; width: 26px; height: 26px; display: grid; place-items: center;
940
+ border: 0; border-radius: 7px; background: transparent;
941
+ color: var(--dsw-alias-label-secondary); font: inherit; font-size: 16px; cursor: pointer;
942
+ }
943
+ .dsv-modal-close:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
944
+ .dsv-modal-hint { flex: none; padding: 0 16px 10px; font-size: 11px; line-height: 16px; color: var(--dsw-alias-label-tertiary); }
945
+ .dsv-modal-search {
946
+ flex: none; margin: 0 16px 10px; height: 30px; padding: 0 10px;
947
+ border-radius: 9px; border: 1px solid var(--dsw-alias-border-l2);
948
+ background: transparent; color: var(--dsw-alias-label-primary);
949
+ font: inherit; font-size: 12px; outline: none;
950
+ }
951
+ .dsv-modal-search:focus { border-color: color-mix(in srgb, var(--dsw-static-deepseek-500) 45%, transparent); }
952
+ .dsv-modal-search::placeholder { color: var(--dsw-alias-label-caption); }
953
+ .dsv-modal-body {
954
+ flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 10px;
955
+ display: flex; flex-direction: column; gap: 2px;
956
+ }
957
+ .dsv-pick-row {
958
+ display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px;
959
+ border: 0; border-radius: 10px; background: transparent; color: inherit;
960
+ font: inherit; text-align: left; cursor: pointer;
961
+ }
962
+ .dsv-pick-row:hover { background: var(--dsw-alias-interactive-bg-hover); }
963
+ .dsv-pick-check {
964
+ flex: none; box-sizing: border-box;
965
+ width: 16px; height: 16px;
966
+ display: grid; place-items: center;
967
+ border: 1.5px solid var(--dsw-alias-border-l2); border-radius: 4px;
968
+ font-size: 11px; line-height: 1; color: #fff; background: transparent;
969
+ }
970
+ .dsv-pick-row[aria-checked="true"] .dsv-pick-check {
971
+ background: var(--dsw-static-deepseek-500); border-color: transparent;
972
+ }
973
+ .dsv-pick-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
974
+ .dsv-pick-title { font-size: 13px; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
975
+ .dsv-pick-sub { font-size: 11px; line-height: 16px; color: var(--dsw-alias-label-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
976
+ .dsv-pick-tag {
977
+ flex: none; padding: 0 6px; border-radius: 999px; font-size: 10px; line-height: 16px;
978
+ color: var(--dsw-static-deepseek-500);
979
+ background: color-mix(in srgb, var(--dsw-static-deepseek-500) 12%, transparent);
980
+ }
981
+ .dsv-pick-empty { padding: 22px 12px; text-align: center; font-size: 12px; color: var(--dsw-alias-label-tertiary); }
982
+ .dsv-modal-foot {
983
+ flex: none; display: flex; align-items: center; gap: 8px;
984
+ padding: 10px 16px 14px; border-top: 1px solid var(--dsw-alias-border-l2);
985
+ }
986
+ .dsv-modal-count { flex: 1; min-width: 0; font-size: 11px; line-height: 16px; color: var(--dsw-alias-label-tertiary); }
987
+ .dsv-modal-btn {
988
+ flex: none; height: 30px; padding: 0 14px; border-radius: 8px;
989
+ border: 1px solid var(--dsw-alias-border-l2); background: transparent;
990
+ color: var(--dsw-alias-label-primary); font: inherit; font-size: 12px; cursor: pointer;
991
+ }
992
+ .dsv-modal-btn:hover { background: var(--dsw-alias-interactive-bg-hover); }
993
+ .dsv-modal-btn.accent { background: var(--dsw-static-deepseek-500); border-color: transparent; color: #fff; }
994
+ .dsv-modal-btn.accent:hover { filter: brightness(1.05); background: var(--dsw-static-deepseek-500); }
995
+ @keyframes dsv-fade-in { from { opacity: 0; } }
996
+ @media (prefers-reduced-motion: reduce) {
997
+ .dsv-launcher-menu, .dsv-modal-backdrop { animation: none; }
998
+ }
999
+ /* ---- 0.6.0 floating windows: a movable/resizable in-app window that
1000
+ hosts ONE native conversation. Floats render from the always-mounted
1001
+ shell.overlay seat, sit above the split overlay, and are mutually
1002
+ exclusive with split panes per session (enter/leave switches modes). ---- */
1003
+ .dsv-float-layer {
1004
+ position: fixed; inset: 0; z-index: 85; pointer-events: none;
1005
+ font-family: var(--dsw-font-family, system-ui, sans-serif);
1006
+ color: var(--dsw-alias-label-primary);
1007
+ }
1008
+ .dsv-float-window {
1009
+ position: fixed; display: flex; flex-direction: column;
1010
+ box-sizing: border-box;
1011
+ min-width: 320px; min-height: 220px; overflow: hidden;
1012
+ border: 1px solid var(--dsw-alias-border-l2); border-radius: 14px;
1013
+ background: var(--dsw-alias-bg-base);
1014
+ box-shadow: 0 18px 48px rgba(15, 23, 42, .22), 0 2px 6px rgba(15, 23, 42, .12);
1015
+ pointer-events: auto;
1016
+ animation: dsv-float-in .16s ease-out;
1017
+ transition: box-shadow .16s ease, border-color .16s ease;
1018
+ --dsh-chat-content-width: 748px;
1019
+ --dsh-composer-card-max-width: calc(var(--dsh-chat-content-width) + 32px);
1020
+ --dsh-composer-side-clearance: 16px;
1021
+ --dsh-composer-dock-inset: 8px;
1022
+ }
1023
+ .dsv-float-window.focused {
1024
+ border-color: color-mix(in srgb, var(--dsw-static-deepseek-500) 32%, var(--dsw-alias-border-l2));
1025
+ box-shadow: 0 0 0 1px color-mix(in srgb, var(--dsw-static-deepseek-500) 28%, transparent),
1026
+ 0 22px 56px rgba(15, 23, 42, .26);
1027
+ }
1028
+ .dsv-float-body { flex: 1; min-height: 0; display: flex; }
1029
+ .dsv-float-body > .dsv-pane { flex: 1; min-width: 0; min-height: 0; }
1030
+ /* The outer window owns the frame: the re-hosted pane drops its card
1031
+ chrome (border/radius/glow) and keeps only its header + content. */
1032
+ .dsv-float-window .dsv-pane,
1033
+ .dsv-float-window .dsv-pane.focused {
1034
+ border: 0; border-radius: 0; box-shadow: none; background: transparent;
1035
+ }
1036
+ .dsv-float-window .dsv-pane-header { height: 34px; border-top-left-radius: 14px; border-top-right-radius: 14px; }
1037
+ .dsv-float-resize { position: absolute; z-index: 2; touch-action: none; }
1038
+ .dsv-float-resize-n, .dsv-float-resize-s { left: 12px; right: 12px; height: 6px; cursor: row-resize; }
1039
+ .dsv-float-resize-n { top: -3px; }
1040
+ .dsv-float-resize-s { bottom: -3px; }
1041
+ .dsv-float-resize-e, .dsv-float-resize-w { top: 12px; bottom: 12px; width: 6px; cursor: col-resize; }
1042
+ .dsv-float-resize-e { right: -3px; }
1043
+ .dsv-float-resize-w { left: -3px; }
1044
+ .dsv-float-resize-ne, .dsv-float-resize-nw, .dsv-float-resize-se, .dsv-float-resize-sw { width: 16px; height: 16px; }
1045
+ .dsv-float-resize-ne { right: -4px; top: -4px; cursor: nesw-resize; }
1046
+ .dsv-float-resize-nw { left: -4px; top: -4px; cursor: nwse-resize; }
1047
+ .dsv-float-resize-se { right: -4px; bottom: -4px; cursor: nwse-resize; }
1048
+ .dsv-float-resize-sw { left: -4px; bottom: -4px; cursor: nesw-resize; }
1049
+ @keyframes dsv-float-in { from { opacity: 0; transform: translateY(6px) scale(.992); } }
1050
+ @media (prefers-reduced-motion: reduce) {
1051
+ .dsv-float-window { animation: none; transition: none; }
1052
+ }
1053
+ /* ---- standalone system window (hash dsvWindow=<id>): one conversation
1054
+ fills the whole page, rendered into the separate OS/browser window the
1055
+ Host route opened. The window chrome (close/minimize/zoom/fullscreen)
1056
+ is the native window's own. ---- */
1057
+ html[data-dsv-standalone] { overflow: hidden; }
1058
+ html[data-dsv-standalone] body { overflow: hidden; }
1059
+ .dsv-standalone {
1060
+ position: fixed; inset: 0; z-index: 1200;
1061
+ display: flex; flex-direction: column; min-width: 0; min-height: 0;
1062
+ background: var(--dsw-alias-bg-base);
1063
+ color: var(--dsw-alias-label-primary);
1064
+ font-family: var(--dsw-font-family, system-ui, sans-serif);
1065
+ --dsh-chat-content-width: 748px;
1066
+ --dsh-composer-card-max-width: calc(var(--dsh-chat-content-width) + 32px);
1067
+ --dsh-composer-side-clearance: 16px;
1068
+ --dsh-composer-dock-inset: 8px;
1069
+ }
1070
+ .dsv-standalone > .dsv-pane {
1071
+ flex: 1; min-width: 0; min-height: 0;
1072
+ border: 0; border-radius: 0; box-shadow: none;
1073
+ }
1074
+ .dsv-standalone .dsv-pane-header { height: 40px; }
764
1075
  /* One title per pane: the pane header owns it. The stock header keeps its
765
1076
  view tabs and action rows but not its breadcrumb; the slim header's own
766
1077
  title span is removed in JSX. */
@@ -1674,6 +1985,70 @@ window.__ModuleLoader__.load({
1674
1985
  @media (prefers-reduced-motion: reduce) {
1675
1986
  .dsv-drop-ghost { transition: none; }
1676
1987
  }
1988
+ /* ---- performance mode -------------------------------------------------
1989
+ One HTML attribute turns off every non-essential paint/animation cost:
1990
+ no card shadows, no focus glow, no fade/zoom transitions, no render-loop
1991
+ animations. JS-side observers are reduced by performanceModeOn() gates. */
1992
+ html[data-dsv-performance="1"] .dsv-pane,
1993
+ html[data-dsv-performance="1"] .dsv-overlay,
1994
+ html[data-dsv-performance="1"] .dsv-float-window,
1995
+ html[data-dsv-performance="1"] .dsv-minimized-chip,
1996
+ html[data-dsv-performance="1"] .dsv-chip,
1997
+ html[data-dsv-performance="1"] .dsv-launcher-menu,
1998
+ html[data-dsv-performance="1"] .dsv-modal,
1999
+ html[data-dsv-performance="1"] .dsv-drop-ghost,
2000
+ html[data-dsv-performance="1"] .dsv-drag-preview {
2001
+ animation: none !important;
2002
+ transition: none !important;
2003
+ }
2004
+ html[data-dsv-performance="1"] .dsv-pane,
2005
+ html[data-dsv-performance="1"] .dsv-float-window,
2006
+ html[data-dsv-performance="1"] .dsv-chip,
2007
+ html[data-dsv-performance="1"] .dsv-launcher-menu,
2008
+ html[data-dsv-performance="1"] .dsv-modal {
2009
+ box-shadow: none !important;
2010
+ }
2011
+ html[data-dsv-performance="1"] .dsv-pane.focused {
2012
+ border-color: var(--dsw-alias-border-l2) !important;
2013
+ box-shadow: none !important;
2014
+ }
2015
+ html[data-dsv-performance="1"] .dsv-pane-wrap,
2016
+ html[data-dsv-performance="1"] .dsv-split-wrap,
2017
+ html[data-dsv-performance="1"] .dsv-divider::after,
2018
+ html[data-dsv-performance="1"] .dsv-pane-btn,
2019
+ html[data-dsv-performance="1"] .dsv-mode-btn {
2020
+ animation: none !important;
2021
+ transition: none !important;
2022
+ }
2023
+ html[data-dsv-performance="1"] .dsv-pane,
2024
+ html[data-dsv-performance="1"] .dsv-float-window {
2025
+ border-radius: 8px;
2026
+ }
2027
+ html[data-dsv-performance="1"] .dsv-think-root[data-state="running"] .dsv-think-row::after,
2028
+ html[data-dsv-performance="1"] .dsv-rowcard-root[data-state="running"] .dsv-rowcard-row::after {
2029
+ animation: none !important;
2030
+ display: none !important;
2031
+ }
2032
+ /* update-ready chip: shown when the on-disk plugin version differs from
2033
+ the client bundle this page loaded. */
2034
+ .dsv-update-chip {
2035
+ position: fixed; right: 16px; bottom: 16px; z-index: 2147483000;
2036
+ display: flex; align-items: center; gap: 8px;
2037
+ padding: 8px 10px 8px 12px; border-radius: 10px;
2038
+ border: 1px solid var(--dsw-alias-border-l2);
2039
+ background: var(--dsw-alias-bg-overlay, var(--dsw-alias-bg-layer-1));
2040
+ color: var(--dsw-alias-label-primary);
2041
+ box-shadow: 0 6px 24px rgba(0, 0, 0, .16);
2042
+ font-family: var(--dsw-font-family, system-ui, sans-serif); font-size: 12px;
2043
+ }
2044
+ .dsv-update-chip-btn {
2045
+ height: 24px; padding: 0 10px; border-radius: 7px; cursor: pointer;
2046
+ border: 1px solid var(--dsw-alias-border-l2); background: transparent;
2047
+ color: var(--dsw-alias-label-primary); font-family: inherit; font-size: 12px;
2048
+ }
2049
+ .dsv-update-chip-btn.accent { background: var(--dsw-static-deepseek-500); border-color: transparent; color: #fff; }
2050
+ .dsv-update-chip-btn:hover { background: var(--dsw-alias-interactive-bg-hover); }
2051
+ html[data-dsv-performance="1"] .dsv-update-chip { box-shadow: none; }
1677
2052
  `;
1678
2053
 
1679
2054
  function insertStyle(css) {
@@ -1822,6 +2197,8 @@ window.__ModuleLoader__.load({
1822
2197
  persistedTree: "unknown",
1823
2198
  maximized: null,
1824
2199
  minimized: readMinimized(),
2200
+ performance: readPerformanceMode(),
2201
+ updateReady: null,
1825
2202
  };
1826
2203
  const runtimeListeners = new Set();
1827
2204
  function runtimeSnapshot() {
@@ -1852,6 +2229,28 @@ window.__ModuleLoader__.load({
1852
2229
  return React.useSyncExternalStore(runtimeSubscribe, runtimeSnapshot, runtimeSnapshot);
1853
2230
  }
1854
2231
 
2232
+ /** Performance mode: one boolean consumed by observers and CSS alike. */
2233
+ function performanceModeOn() {
2234
+ return runtimeState.performance === true;
2235
+ }
2236
+ /** Mirror performance mode onto <html> so the stylesheet can drop
2237
+ animations/shadows without re-rendering every pane. */
2238
+ function applyPerformanceClass() {
2239
+ try {
2240
+ if (typeof document !== "undefined" && document.documentElement !== null) {
2241
+ document.documentElement.setAttribute("data-dsv-performance", performanceModeOn() ? "1" : "0");
2242
+ }
2243
+ } catch {}
2244
+ }
2245
+ function setPerformanceMode(value) {
2246
+ const next = value === true;
2247
+ writePerformanceMode(next);
2248
+ setRuntime({ performance: next });
2249
+ applyPerformanceClass();
2250
+ showPaneToast(t(next ? "performanceOn" : "performanceOff"), true);
2251
+ return next;
2252
+ }
2253
+
1855
2254
  /** True only when the workspace may take over the viewport at all. The
1856
2255
  `geometryBlocked` flag closes the diagnosis's "invisible active" hole:
1857
2256
  a persisted split whose column cannot be measured must NOT eat the
@@ -1995,8 +2394,11 @@ window.__ModuleLoader__.load({
1995
2394
  safeMode: runtimeState.safeMode,
1996
2395
  active: runtimeState.active,
1997
2396
  minimized: runtimeState.minimized === true,
2397
+ performance: runtimeState.performance === true,
1998
2398
  geometryBlocked: runtimeState.geometryBlocked === true,
1999
2399
  panes: (() => { try { return treeStore.leafIds().length; } catch { return 0; } })(),
2400
+ floats: (() => { try { return floatStore.ids(); } catch { return []; } })(),
2401
+ floatLayerMounted: floatLayerMounted,
2000
2402
  blockedReason: (() => { try { return blockedReason(); } catch { return "unknown"; } })(),
2001
2403
  failures: runtimeState.failures,
2002
2404
  lastError: runtimeState.lastError,
@@ -2362,7 +2764,16 @@ window.__ModuleLoader__.load({
2362
2764
  const root = parsed !== null && parsed !== undefined && typeof parsed === "object"
2363
2765
  ? normalizeTree(parsed.root, { depth: 0, seen: new Set(), stats })
2364
2766
  : null;
2365
- if (root !== null) {
2767
+ if (root !== null && leafOf(root, []).length < 2) {
2768
+ // A one-pane tree is not a split. Older builds could persist one
2769
+ // after closing the second-to-last pane; that kept the surviving
2770
+ // conversation tagged "in split" while nothing rendered. Discard it.
2771
+ storageRemove(TREE_KEY);
2772
+ persistedStatus = "absent";
2773
+ try {
2774
+ console.info(LOG_PREFIX + " dropped a persisted one-pane layout on load (a split needs at least two panes).");
2775
+ } catch {}
2776
+ } else if (root !== null) {
2366
2777
  state = { root, focus: null };
2367
2778
  const repaired = stats.duplicates > 0 || stats.depthLimited > 0;
2368
2779
  persistedStatus = repaired ? "repaired" : "ok";
@@ -2410,6 +2821,21 @@ window.__ModuleLoader__.load({
2410
2821
  for (const listener of [...listeners]) listener();
2411
2822
  }
2412
2823
 
2824
+ /** The split ended because fewer than two panes remain. Clear the WHOLE
2825
+ tree (not just the closed pane): a one-pane tree is not a split, and
2826
+ keeping it would leave the surviving conversation tagged "in split"
2827
+ in the context menu / add-split dialog while nothing renders. */
2828
+ function endSplitBecauseTooSmall() {
2829
+ const before = leafOf(state.root, []);
2830
+ state = { root: null, focus: null };
2831
+ for (const id of before) deferPaneDisposeCheck(id);
2832
+ storageRemove(TREE_KEY);
2833
+ setRuntime({ persistedTree: "absent", maximized: null, minimized: false });
2834
+ writeMinimized(false);
2835
+ revision += 1;
2836
+ for (const listener of [...listeners]) listener();
2837
+ }
2838
+
2413
2839
  return {
2414
2840
  getSnapshot: () => state,
2415
2841
  getRevision: () => revision,
@@ -2464,6 +2890,9 @@ window.__ModuleLoader__.load({
2464
2890
  },
2465
2891
  addPane(sessionId) {
2466
2892
  if (!isValidSessionId(sessionId)) return;
2893
+ // A conversation is either a pane or a float, never both: any path
2894
+ // that adds a pane retires its floating window first.
2895
+ try { if (floatStore.has(sessionId)) floatStore.remove(sessionId); } catch {}
2467
2896
  if (findLeafNode(state.root, sessionId) !== null) {
2468
2897
  commit({ root: state.root, focus: sessionId });
2469
2898
  return;
@@ -2501,6 +2930,7 @@ window.__ModuleLoader__.load({
2501
2930
  },
2502
2931
  splitLeaf(leafId, dir, newId, side) {
2503
2932
  if (!isValidSessionId(newId)) return;
2933
+ try { if (floatStore.has(newId)) floatStore.remove(newId); } catch {}
2504
2934
  if (findLeafNode(state.root, newId) !== null) {
2505
2935
  commit({ root: state.root, focus: newId });
2506
2936
  return;
@@ -2514,8 +2944,17 @@ window.__ModuleLoader__.load({
2514
2944
  if (ok) commit({ root: next, focus: newId });
2515
2945
  },
2516
2946
  closeLeaf(id) {
2947
+ const before = leafOf(state.root, []);
2517
2948
  const [next, removed] = removeLeaf(state.root, id);
2518
- if (removed) { commit({ root: next, focus: state.focus }); this.settleAuto(); }
2949
+ if (!removed) return;
2950
+ // Closing the second-to-last pane ends the split: clear every pane
2951
+ // instead of keeping an invisible one-pane tree with stale membership.
2952
+ if (before.length >= 2 && leafOf(next, []).length < 2) {
2953
+ endSplitBecauseTooSmall();
2954
+ return;
2955
+ }
2956
+ commit({ root: next, focus: state.focus });
2957
+ this.settleAuto();
2519
2958
  },
2520
2959
  movePane(srcId, dstId, zone) {
2521
2960
  if (srcId === dstId) return;
@@ -2553,6 +2992,449 @@ window.__ModuleLoader__.load({
2553
2992
 
2554
2993
  const treeStore = createTreeStore();
2555
2994
 
2995
+ // ---------------------------------------------------------------------
2996
+ // pending split + launcher state (0.5.0)
2997
+ //
2998
+ // "Add to split" on a session row is only meaningful once a split exists.
2999
+ // While the workspace is inactive the first pick is parked in this store
3000
+ // (the "pending split") and the SECOND pick starts the split; the footer
3001
+ // button shows the pending count so the parked pick is never invisible.
3002
+ // The launcher store drives the footer menu and the multi-select dialog;
3003
+ // both render through the always-mounted shell overlay seat, so the
3004
+ // sidebar's clipping/stacking can never cut them.
3005
+ // ---------------------------------------------------------------------
3006
+
3007
+ const pendingSplitStore = (() => {
3008
+ let ids = [];
3009
+ const listeners = new Set();
3010
+ const emit = () => {
3011
+ for (const listener of [...listeners]) {
3012
+ try { listener(); } catch {}
3013
+ }
3014
+ };
3015
+ return {
3016
+ getSnapshot: () => ids,
3017
+ subscribe(listener) {
3018
+ if (typeof listener !== "function") return () => {};
3019
+ listeners.add(listener);
3020
+ return () => { listeners.delete(listener); };
3021
+ },
3022
+ has: (id) => ids.indexOf(id) !== -1,
3023
+ /** @returns {boolean} true when the id was newly parked. */
3024
+ add(id) {
3025
+ if (!isValidSessionId(id) || ids.indexOf(id) !== -1) return false;
3026
+ ids = ids.concat([id]);
3027
+ emit();
3028
+ return true;
3029
+ },
3030
+ remove(id) {
3031
+ if (ids.indexOf(id) === -1) return false;
3032
+ ids = ids.filter((entry) => entry !== id);
3033
+ emit();
3034
+ return true;
3035
+ },
3036
+ clear() {
3037
+ if (ids.length === 0) return;
3038
+ ids = [];
3039
+ emit();
3040
+ },
3041
+ size: () => ids.length,
3042
+ ids: () => ids.slice(),
3043
+ };
3044
+ })();
3045
+
3046
+ /** Footer-menu / add-dialog request. `mode`: closed | menu | dialog. */
3047
+ let launcherState = { mode: "closed", rect: null, source: null };
3048
+ const launcherListeners = new Set();
3049
+ function setLauncherState(next) {
3050
+ const same = launcherState.mode === next.mode
3051
+ && launcherState.source === next.source
3052
+ && launcherState.rect === next.rect;
3053
+ if (same) return launcherState;
3054
+ launcherState = next;
3055
+ for (const listener of [...launcherListeners]) {
3056
+ try { listener(); } catch {}
3057
+ }
3058
+ return launcherState;
3059
+ }
3060
+ function useLauncherState() {
3061
+ return React.useSyncExternalStore(
3062
+ (listener) => { launcherListeners.add(listener); return () => { launcherListeners.delete(listener); }; },
3063
+ () => launcherState,
3064
+ () => launcherState,
3065
+ );
3066
+ }
3067
+ function closeLauncher() {
3068
+ setLauncherState({ mode: "closed", rect: null, source: null });
3069
+ }
3070
+ function openLauncherMenu(anchorEl) {
3071
+ let rect = null;
3072
+ try {
3073
+ rect = anchorEl !== null && anchorEl !== undefined && typeof anchorEl.getBoundingClientRect === "function"
3074
+ ? anchorEl.getBoundingClientRect() : null;
3075
+ } catch { rect = null; }
3076
+ setLauncherState({ mode: "menu", rect, source: "footer" });
3077
+ }
3078
+ function openAddSplitDialog(source) {
3079
+ setLauncherState({ mode: "dialog", rect: null, source: source === "footer" ? "footer" : "session" });
3080
+ }
3081
+
3082
+ // ---------------------------------------------------------------------
3083
+ // floating windows (0.6.0)
3084
+ //
3085
+ // DSH has no second native window: the Desktop main window denies
3086
+ // window.open() and the Web client has no per-session deep link, so a
3087
+ // "window" here is an in-app floating surface rendered by the
3088
+ // always-mounted shell.overlay seat. It hosts the SAME native ChatPane the
3089
+ // split re-hosts, and it is mutually exclusive with a split pane for one
3090
+ // session: entering a float detaches the pane, docking it back re-attaches
3091
+ // it. Geometry lives in viewport CSS pixels, persisted under FLOAT_KEY and
3092
+ // clamped to the conversation column on every gesture/resize.
3093
+ // ---------------------------------------------------------------------
3094
+
3095
+ const FLOAT_W = 680;
3096
+ const FLOAT_H = 620;
3097
+ const FLOAT_MIN_W = 320;
3098
+ const FLOAT_MIN_H = 220;
3099
+
3100
+ function readFloatWindows() {
3101
+ const raw = storageGet(FLOAT_KEY);
3102
+ if (!raw) return [];
3103
+ let parsed = null;
3104
+ try { parsed = JSON.parse(raw); } catch { return []; }
3105
+ const list = parsed !== null && parsed !== undefined && Array.isArray(parsed.windows) ? parsed.windows : [];
3106
+ const out = [];
3107
+ for (const entry of list) {
3108
+ if (entry === null || typeof entry !== "object") continue;
3109
+ const id = entry.id;
3110
+ if (!isValidSessionId(id)) continue;
3111
+ if (out.some((win) => win.id === id)) continue;
3112
+ const x = Number(entry.x);
3113
+ const y = Number(entry.y);
3114
+ const w = Number(entry.w);
3115
+ const h = Number(entry.h);
3116
+ const z = Number(entry.z);
3117
+ out.push({
3118
+ id,
3119
+ x: Number.isFinite(x) ? x : 0,
3120
+ y: Number.isFinite(y) ? y : 0,
3121
+ w: Number.isFinite(w) && w >= FLOAT_MIN_W ? w : FLOAT_W,
3122
+ h: Number.isFinite(h) && h >= FLOAT_MIN_H ? h : FLOAT_H,
3123
+ z: Number.isFinite(z) ? z : out.length + 1,
3124
+ });
3125
+ }
3126
+ return out;
3127
+ }
3128
+
3129
+ const floatStore = (() => {
3130
+ let windows = readFloatWindows();
3131
+ let focused = windows.length > 0 ? windows[windows.length - 1].id : null;
3132
+ let persistTimer = 0;
3133
+ const listeners = new Set();
3134
+ let snapshot = Object.freeze({ windows: windows.slice(), focused });
3135
+ const emit = () => {
3136
+ for (const listener of [...listeners]) {
3137
+ try { listener(); } catch {}
3138
+ }
3139
+ };
3140
+ const publish = () => {
3141
+ snapshot = Object.freeze({ windows: windows.slice(), focused });
3142
+ emit();
3143
+ };
3144
+ const write = () => {
3145
+ persistTimer = 0;
3146
+ try { storageSet(FLOAT_KEY, JSON.stringify({ windows })); } catch {}
3147
+ };
3148
+ const schedulePersist = (immediate) => {
3149
+ if (persistTimer !== 0) {
3150
+ try { window.clearTimeout(persistTimer); } catch {}
3151
+ persistTimer = 0;
3152
+ }
3153
+ if (immediate === true) { write(); return; }
3154
+ try { persistTimer = window.setTimeout(write, 200); } catch { write(); }
3155
+ };
3156
+ const find = (id) => windows.find((win) => win.id === id);
3157
+ return {
3158
+ getSnapshot: () => snapshot,
3159
+ subscribe(listener) {
3160
+ if (typeof listener !== "function") return () => {};
3161
+ listeners.add(listener);
3162
+ return () => { listeners.delete(listener); };
3163
+ },
3164
+ ids: () => windows.map((win) => win.id),
3165
+ size: () => windows.length,
3166
+ has: (id) => windows.some((win) => win.id === id),
3167
+ focusedId: () => focused,
3168
+ add(id, rect) {
3169
+ if (!isValidSessionId(id) || windows.some((win) => win.id === id)) return false;
3170
+ const max = windows.reduce((acc, win) => Math.max(acc, win.z), 0);
3171
+ windows = windows.concat([{
3172
+ id,
3173
+ x: rect !== null && rect !== undefined && Number.isFinite(rect.x) ? rect.x : 0,
3174
+ y: rect !== null && rect !== undefined && Number.isFinite(rect.y) ? rect.y : 0,
3175
+ w: rect !== null && rect !== undefined && Number.isFinite(rect.w) ? rect.w : FLOAT_W,
3176
+ h: rect !== null && rect !== undefined && Number.isFinite(rect.h) ? rect.h : FLOAT_H,
3177
+ z: max + 1,
3178
+ }]);
3179
+ focused = id;
3180
+ publish();
3181
+ schedulePersist(false);
3182
+ return true;
3183
+ },
3184
+ remove(id) {
3185
+ const next = windows.filter((win) => win.id !== id);
3186
+ if (next.length === windows.length) return false;
3187
+ windows = next;
3188
+ if (focused === id) {
3189
+ const top = windows.reduce((acc, win) => (acc === null || win.z > acc.z ? win : acc), null);
3190
+ focused = top === null ? null : top.id;
3191
+ }
3192
+ publish();
3193
+ schedulePersist(true);
3194
+ return true;
3195
+ },
3196
+ clear() {
3197
+ const had = windows.length > 0 || focused !== null;
3198
+ windows = [];
3199
+ focused = null;
3200
+ if (had) {
3201
+ publish();
3202
+ schedulePersist(true);
3203
+ }
3204
+ },
3205
+ focus(id) {
3206
+ const target = find(id);
3207
+ if (target === undefined) {
3208
+ focused = null;
3209
+ publish();
3210
+ return;
3211
+ }
3212
+ const max = windows.reduce((acc, win) => Math.max(acc, win.z), 0);
3213
+ if (target.z !== max || focused !== id) {
3214
+ target.z = max + 1;
3215
+ focused = id;
3216
+ publish();
3217
+ schedulePersist(false);
3218
+ }
3219
+ },
3220
+ setRect(id, rect, immediate) {
3221
+ const target = find(id);
3222
+ if (target === undefined) return;
3223
+ if (target.x === rect.x && target.y === rect.y && target.w === rect.w && target.h === rect.h) return;
3224
+ target.x = rect.x;
3225
+ target.y = rect.y;
3226
+ target.w = rect.w;
3227
+ target.h = rect.h;
3228
+ windows = windows.slice();
3229
+ publish();
3230
+ schedulePersist(immediate === true);
3231
+ },
3232
+ persistNow() {
3233
+ if (persistTimer !== 0) {
3234
+ try { window.clearTimeout(persistTimer); } catch {}
3235
+ persistTimer = 0;
3236
+ }
3237
+ write();
3238
+ },
3239
+ };
3240
+ })();
3241
+
3242
+ function useFloats() {
3243
+ return React.useSyncExternalStore(floatStore.subscribe, floatStore.getSnapshot, floatStore.getSnapshot);
3244
+ }
3245
+
3246
+ /** Keep a rect inside the conversation column (the same work area the
3247
+ restore chip uses; falls back to the viewport below the title bar). */
3248
+ function clampFloatRect(rect, work) {
3249
+ const width = Math.max(FLOAT_MIN_W, Math.min(rect.w, Math.max(FLOAT_MIN_W, work.width)));
3250
+ const height = Math.max(FLOAT_MIN_H, Math.min(rect.h, Math.max(FLOAT_MIN_H, work.height)));
3251
+ const x = Math.round(Math.min(Math.max(rect.x, work.left), Math.max(work.left, work.left + work.width - width)));
3252
+ const y = Math.round(Math.min(Math.max(rect.y, work.top), Math.max(work.top, work.top + work.height - height)));
3253
+ return { x, y, w: Math.round(width), h: Math.round(height) };
3254
+ }
3255
+
3256
+ function defaultFloatRect() {
3257
+ const work = chipWorkRect();
3258
+ const w = Math.min(FLOAT_W, Math.max(FLOAT_MIN_W, Math.round(work.width * 0.74)));
3259
+ const h = Math.min(FLOAT_H, Math.max(FLOAT_MIN_H, Math.round(work.height * 0.74)));
3260
+ // Cascade successive windows so a second float never lands exactly on
3261
+ // the first one (the user can still drag them anywhere afterwards).
3262
+ let index = 0;
3263
+ try { index = floatStore.size(); } catch {}
3264
+ const offset = (index % 8) * 28;
3265
+ const x = work.left + Math.round((work.width - w) / 2) + offset;
3266
+ const y = work.top + Math.round(Math.max(0, (work.height - h) * 0.16)) + Math.round(offset * 0.5);
3267
+ return clampFloatRect({ x, y, w, h }, work);
3268
+ }
3269
+
3270
+ /** Enter floating-window mode. A split pane (or a parked pending pick) is
3271
+ detached first so the same conversation is never hosted twice. */
3272
+ function floatSession(sessionId) {
3273
+ if (!isValidSessionId(sessionId)) return false;
3274
+ prepareExplicitSplit();
3275
+ if (floatStore.has(sessionId)) {
3276
+ floatStore.focus(sessionId);
3277
+ return false;
3278
+ }
3279
+ pendingSplitStore.remove(sessionId);
3280
+ try {
3281
+ if (treeStore.leafIds().indexOf(sessionId) !== -1) treeStore.closeLeaf(sessionId);
3282
+ } catch {}
3283
+ try {
3284
+ const remaining = treeStore.leafIds();
3285
+ if (remaining.length > 0 && remaining.length < 2) treeStore.reset();
3286
+ } catch {}
3287
+ floatStore.add(sessionId, defaultFloatRect());
3288
+ showPaneToast(t("floatEntered"), true);
3289
+ return true;
3290
+ }
3291
+
3292
+ /** Close a float without putting it back into the split. */
3293
+ function closeFloatWindow(sessionId, options) {
3294
+ if (!floatStore.has(sessionId)) return false;
3295
+ floatStore.remove(sessionId);
3296
+ if (options === undefined || options.silent !== true) showPaneToast(t("floatClosed"), true);
3297
+ return true;
3298
+ }
3299
+
3300
+ /** Switch one float back to split mode: append it to a live split, or
3301
+ rebuild/start from the pending pick when no split is running yet. */
3302
+ function dockFloatToSplit(sessionId) {
3303
+ if (!isValidSessionId(sessionId)) return false;
3304
+ if (!floatStore.has(sessionId)) return false;
3305
+ floatStore.remove(sessionId);
3306
+ const leaves = treeStore.leafIds();
3307
+ if (leaves.indexOf(sessionId) !== -1) {
3308
+ try { treeStore.setFocus(sessionId); } catch {}
3309
+ return true;
3310
+ }
3311
+ if (leaves.length > 0) {
3312
+ prepareExplicitSplit();
3313
+ unminimizeForSplit();
3314
+ try { treeStore.addPane(sessionId); } catch {}
3315
+ showPaneToast(t("floatDocked"), true);
3316
+ return true;
3317
+ }
3318
+ const pending = pendingSplitStore.ids().filter((id) => id !== sessionId);
3319
+ if (pending.length > 0) {
3320
+ pendingSplitStore.clear();
3321
+ buildSplitFromSessions(pending.concat([sessionId]));
3322
+ showPaneToast(t("floatDocked"), true);
3323
+ return true;
3324
+ }
3325
+ pendingSplitStore.add(sessionId);
3326
+ showPaneToast(t("pendingAdded"), true);
3327
+ return true;
3328
+ }
3329
+
3330
+ /** Leave every in-app surface (split pane, pending pick, float) because the
3331
+ conversation now lives in a separate system window. The split ends
3332
+ through closeLeaf's own too-small rule when only one pane would remain. */
3333
+ function detachSessionForSystemWindow(sessionId) {
3334
+ try { if (floatStore.has(sessionId)) floatStore.remove(sessionId); } catch {}
3335
+ pendingSplitStore.remove(sessionId);
3336
+ try {
3337
+ const leaves = treeStore.leafIds();
3338
+ if (leaves.indexOf(sessionId) !== -1) treeStore.closeLeaf(sessionId);
3339
+ else if (leaves.length > 0 && leaves.length < 2) treeStore.reset();
3340
+ } catch {}
3341
+ }
3342
+
3343
+ /** Ask the Host for the authenticated standalone URL and open it as a real
3344
+ separate window. In Desktop the app's window-open handler forwards
3345
+ http/https to the system browser (the only OS window a renderer plugin
3346
+ can create here); in Web mode `window.open` opens a browser window.
3347
+ A blank window is pre-opened in Web mode so the async Host round-trip
3348
+ cannot lose the user-gesture popup permission. */
3349
+ function openSystemWindow(sessionId) {
3350
+ if (!isValidSessionId(sessionId)) return Promise.resolve(false);
3351
+ let preopened = null;
3352
+ if (typeof window.dshDesktop === "undefined") {
3353
+ try { preopened = window.open("", "_blank"); } catch { preopened = null; }
3354
+ }
3355
+ const fail = () => {
3356
+ try { if (preopened !== null && preopened.closed !== true) preopened.close(); } catch {}
3357
+ showPaneToast(t("systemWindowFailed"), true);
3358
+ return false;
3359
+ };
3360
+ return fetch("/dsv/system-window", {
3361
+ method: "POST",
3362
+ headers: { "content-type": "application/json" },
3363
+ body: JSON.stringify({ sessionId }),
3364
+ }).then((response) => (response.ok ? response.json().catch(() => null) : null)).then((payload) => {
3365
+ if (payload === null || payload === undefined || payload.ok !== true
3366
+ || typeof payload.url !== "string" || payload.url === "") return fail();
3367
+ try {
3368
+ detachSessionForSystemWindow(sessionId);
3369
+ if (preopened !== null && preopened.closed !== true) {
3370
+ try { preopened.opener = null; } catch {}
3371
+ preopened.location.href = payload.url;
3372
+ } else {
3373
+ window.open(payload.url, "_blank", "noopener,noreferrer");
3374
+ }
3375
+ showPaneToast(t("systemWindowOpened"), true);
3376
+ return true;
3377
+ } catch {
3378
+ return fail();
3379
+ }
3380
+ }).catch(() => fail());
3381
+ }
3382
+
3383
+ let floatLayerMounted = false;
3384
+
3385
+ // One gesture at a time (move or resize); the element that captured the
3386
+ // pointer owns it until pointerup/cancel.
3387
+ let floatGesture = null;
3388
+ function beginFloatGesture(sessionId, mode, event) {
3389
+ if (event === null || event === undefined || event.button !== 0) return;
3390
+ const state = floatStore.getSnapshot();
3391
+ const win = state.windows.find((entry) => entry.id === sessionId);
3392
+ if (win === undefined) return;
3393
+ const target = event.target;
3394
+ if (mode === "move" && target !== null && target !== undefined && typeof target.closest === "function"
3395
+ && target.closest("button,input,.dsv-pane-title-text") !== null) return;
3396
+ event.preventDefault();
3397
+ floatGesture = {
3398
+ id: sessionId,
3399
+ mode,
3400
+ pointerId: event.pointerId,
3401
+ sx: event.clientX,
3402
+ sy: event.clientY,
3403
+ start: { x: win.x, y: win.y, w: win.w, h: win.h },
3404
+ work: chipWorkRect(),
3405
+ };
3406
+ floatStore.focus(sessionId);
3407
+ try { event.currentTarget.setPointerCapture(event.pointerId); } catch {}
3408
+ }
3409
+ function moveFloatGesture(event) {
3410
+ const gesture = floatGesture;
3411
+ if (gesture === null || gesture.pointerId !== event.pointerId) return;
3412
+ const dx = event.clientX - gesture.sx;
3413
+ const dy = event.clientY - gesture.sy;
3414
+ let next;
3415
+ if (gesture.mode === "move") {
3416
+ next = { x: gesture.start.x + dx, y: gesture.start.y + dy, w: gesture.start.w, h: gesture.start.h };
3417
+ } else {
3418
+ let left = gesture.start.x;
3419
+ let top = gesture.start.y;
3420
+ let right = gesture.start.x + gesture.start.w;
3421
+ let bottom = gesture.start.y + gesture.start.h;
3422
+ if (gesture.mode.indexOf("e") !== -1) right = Math.max(left + FLOAT_MIN_W, gesture.start.x + gesture.start.w + dx);
3423
+ if (gesture.mode.indexOf("w") !== -1) left = Math.min(right - FLOAT_MIN_W, gesture.start.x + dx);
3424
+ if (gesture.mode.indexOf("s") !== -1) bottom = Math.max(top + FLOAT_MIN_H, gesture.start.y + gesture.start.h + dy);
3425
+ if (gesture.mode.indexOf("n") !== -1) top = Math.min(bottom - FLOAT_MIN_H, gesture.start.y + dy);
3426
+ next = { x: left, y: top, w: right - left, h: bottom - top };
3427
+ }
3428
+ floatStore.setRect(gesture.id, clampFloatRect(next, gesture.work), false);
3429
+ }
3430
+ function endFloatGesture(event) {
3431
+ const gesture = floatGesture;
3432
+ if (gesture === null || (event !== undefined && event.pointerId !== gesture.pointerId)) return;
3433
+ floatGesture = null;
3434
+ try { event.currentTarget.releasePointerCapture(event.pointerId); } catch {}
3435
+ floatStore.persistNow();
3436
+ }
3437
+
2556
3438
  let dragPayload = null; // { kind: 'session' | 'pane', id }
2557
3439
 
2558
3440
  // ---------------------------------------------------------------------
@@ -3900,6 +4782,10 @@ window.__ModuleLoader__.load({
3900
4782
  full-sidebar scan. Emits a fresh snapshot object on real changes so
3901
4783
  React's identity check re-renders consumers. */
3902
4784
  const DOM_LIST_MIN_READ_MS = 200;
4785
+ /** Sidebar scraping cadence; perf mode reads at most once a second. */
4786
+ function domListMinReadMs() {
4787
+ return performanceModeOn() ? 1000 : DOM_LIST_MIN_READ_MS;
4788
+ }
3903
4789
 
3904
4790
  function createDomSessionListSource() {
3905
4791
  let snapshot = readSidebarSessions();
@@ -3926,14 +4812,15 @@ window.__ModuleLoader__.load({
3926
4812
  }
3927
4813
  };
3928
4814
  const maybePublish = () => {
4815
+ const minRead = domListMinReadMs();
3929
4816
  const since = Date.now() - lastReadAt;
3930
- if (since < DOM_LIST_MIN_READ_MS) {
4817
+ if (since < minRead) {
3931
4818
  if (!timerPending) {
3932
4819
  timerPending = true;
3933
4820
  window.setTimeout(() => {
3934
4821
  timerPending = false;
3935
4822
  if (active && listeners.size > 0) publish();
3936
- }, DOM_LIST_MIN_READ_MS - since);
4823
+ }, minRead - since);
3937
4824
  }
3938
4825
  return;
3939
4826
  }
@@ -3987,6 +4874,9 @@ window.__ModuleLoader__.load({
3987
4874
  if (active && listeners.size > 0) attach();
3988
4875
  else if (!active) detach();
3989
4876
  },
4877
+ /** Force one bounded re-read (the add-split dialog opens while the
4878
+ workspace may be inactive, when the observer is detached). */
4879
+ refresh: () => { publish(); },
3990
4880
  subscribe: (listener) => {
3991
4881
  if (listener === undefined || typeof listener !== "function") return () => {};
3992
4882
  listeners.add(listener);
@@ -4904,11 +5794,16 @@ window.__ModuleLoader__.load({
4904
5794
  } catch {}
4905
5795
  }
4906
5796
 
4907
- function showPaneToast(message) {
5797
+ function showPaneToast(message, force) {
4908
5798
  const now = Date.now();
4909
- if (now - paneToastAt < 4000) return;
5799
+ if (force !== true && now - paneToastAt < 4000) return;
4910
5800
  paneToastAt = now;
4911
5801
  try {
5802
+ // One toast at a time: forced action feedback may replace an earlier
5803
+ // one before its 4.2s lifetime ends.
5804
+ for (const previous of document.querySelectorAll(".dsv-toast")) {
5805
+ try { previous.remove(); } catch {}
5806
+ }
4912
5807
  const el = document.createElement("div");
4913
5808
  el.className = "dsv-toast";
4914
5809
  el.setAttribute("role", "status");
@@ -7083,6 +7978,7 @@ window.__ModuleLoader__.load({
7083
7978
  writes would otherwise retrigger the subtree MutationObserver into
7084
7979
  an rAF-loop. */
7085
7980
  function useComposerAlignedRow(rowRef, leftBuffer, rightInset) {
7981
+ const performanceMode = useRuntime().performance === true;
7086
7982
  React.useLayoutEffect(() => {
7087
7983
  const row = rowRef.current;
7088
7984
  if (row === null) return;
@@ -7138,17 +8034,19 @@ window.__ModuleLoader__.load({
7138
8034
  const observer = new ResizeObserver(schedule);
7139
8035
  observer.observe(pane);
7140
8036
  let mutation = null;
7141
- if (typeof MutationObserver === "function") {
8037
+ if (!performanceMode && typeof MutationObserver === "function") {
7142
8038
  mutation = new MutationObserver(schedule);
7143
8039
  mutation.observe(pane, { childList: true, subtree: true, attributes: true, attributeFilter: ["data-composer-card", "data-dsv-composer-card"] });
7144
8040
  }
8041
+ const perfTimer = performanceMode ? window.setInterval(schedule, 1500) : 0;
7145
8042
  raf = requestAnimationFrame(tick);
7146
8043
  return () => {
7147
8044
  if (raf !== 0) cancelAnimationFrame(raf);
7148
8045
  observer.disconnect();
7149
8046
  if (mutation !== null) mutation.disconnect();
8047
+ if (perfTimer !== 0) window.clearInterval(perfTimer);
7150
8048
  };
7151
- }, [leftBuffer, rightInset]);
8049
+ }, [leftBuffer, rightInset, performanceMode]);
7152
8050
  }
7153
8051
 
7154
8052
  function DsvInputDock({ children }) {
@@ -8219,14 +9117,16 @@ window.__ModuleLoader__.load({
8219
9117
  return zone.side === "before" ? { top: 4, left: 4, right: 4, height: "50%" } : { bottom: 4, left: 4, right: 4, height: "50%" };
8220
9118
  }
8221
9119
 
8222
- function PaneFrame({ sessionId, session, summary, focused, chrome, onFocus, onClose, pickerFor }) {
9120
+ function PaneFrame({ sessionId, session, summary, focused, chrome, onFocus, onClose, pickerFor, floating, standalone }) {
8223
9121
  const runtime = useRuntime();
9122
+ const performanceMode = runtime.performance === true;
8224
9123
  const maximized = runtime.maximized === sessionId;
8225
9124
  const [renaming, setRenaming] = React.useState(false);
8226
9125
  const [renameDraft, setRenameDraft] = React.useState("");
8227
9126
  const [zone, setZone] = React.useState(null);
8228
9127
  const [invalidDrop, setInvalidDrop] = React.useState(false);
8229
9128
  const frameRef = React.useRef(null);
9129
+ const headerRef = React.useRef(null);
8230
9130
  const running = summary ? summary.running === true : false;
8231
9131
  const title = summary ? summary.displayTitle || summary.title || sessionId : sessionId;
8232
9132
  const cwd = summary ? basenameOf(summary.cwd) : "";
@@ -8428,15 +9328,20 @@ window.__ModuleLoader__.load({
8428
9328
  };
8429
9329
  const observer = new ResizeObserver(schedule);
8430
9330
  observer.observe(frame);
8431
- const mutation = typeof MutationObserver === "function" ? new MutationObserver(schedule) : null;
9331
+ // Perf mode: the pane subtree mutates on EVERY streaming token, and a
9332
+ // subtree MutationObserver here used to re-measure geometry (forced
9333
+ // layout) for each one. Keep resize-driven measuring + a slow poll.
9334
+ const mutation = !performanceMode && typeof MutationObserver === "function" ? new MutationObserver(schedule) : null;
8432
9335
  if (mutation !== null) mutation.observe(frame, { childList: true, subtree: true });
9336
+ const perfTimer = performanceMode ? window.setInterval(schedule, 1500) : 0;
8433
9337
  schedule();
8434
9338
  return () => {
8435
9339
  if (raf !== 0) cancelAnimationFrame(raf);
8436
9340
  observer.disconnect();
8437
9341
  if (mutation !== null) mutation.disconnect();
9342
+ if (perfTimer !== 0) window.clearInterval(perfTimer);
8438
9343
  };
8439
- }, [paneSize.w, composerMode]);
9344
+ }, [paneSize.w, composerMode, performanceMode]);
8440
9345
  // a composer is never narrower than this — narrower "boxes" are
8441
9346
  // transient seats, not the real input; fall back to stock geometry
8442
9347
  const cardBoxSane = cardBox !== null && cardBox.right - cardBox.left >= 160;
@@ -8631,14 +9536,35 @@ window.__ModuleLoader__.load({
8631
9536
  onClick(event);
8632
9537
  },
8633
9538
  }, glyph);
8634
- const actionButtons = [
8635
- actionButton("maximize", maximized ? t("restore") : t("maximize"), maximized ? "⤡" : "⤢", doMaximize),
8636
- actionButton("copy", t("copy"), "⧉", doCopy),
8637
- actionButton("help", t("helpOpen"), "?", doHelp),
8638
- actionButton("splitRight", t("splitRight"), h(SplitIconV, { size: 15 }), (event) => doSplit("h", event.currentTarget)),
8639
- actionButton("splitDown", t("splitDown"), h(SplitIconH, { size: 15 }), (event) => doSplit("v", event.currentTarget)),
8640
- actionButton("close", t("closePane"), h(CloseIcon, { size: 14 }), doClose),
8641
- ];
9539
+ const doFullscreen = () => {
9540
+ try {
9541
+ if (document.fullscreenElement !== null && document.fullscreenElement !== undefined) {
9542
+ if (typeof document.exitFullscreen === "function") document.exitFullscreen();
9543
+ } else if (typeof document.documentElement.requestFullscreen === "function") {
9544
+ document.documentElement.requestFullscreen();
9545
+ }
9546
+ } catch {}
9547
+ };
9548
+ const actionButtons = standalone === true
9549
+ ? [
9550
+ actionButton("copy", t("copy"), "⧉", doCopy),
9551
+ actionButton("help", t("helpOpen"), "?", doHelp),
9552
+ actionButton("fullscreen", t("standaloneFullscreen"), "⛶", doFullscreen),
9553
+ ]
9554
+ : floating === true
9555
+ ? [
9556
+ actionButton("dock", t("floatDock"), "⇲", () => { dockFloatToSplit(sessionId); }),
9557
+ actionButton("help", t("helpOpen"), "?", doHelp),
9558
+ actionButton("close", t("floatClose"), h(CloseIcon, { size: 14 }), () => { closeFloatWindow(sessionId); }),
9559
+ ]
9560
+ : [
9561
+ actionButton("maximize", maximized ? t("restore") : t("maximize"), maximized ? "⤡" : "⤢", doMaximize),
9562
+ actionButton("copy", t("copy"), "⧉", doCopy),
9563
+ actionButton("help", t("helpOpen"), "?", doHelp),
9564
+ actionButton("splitRight", t("splitRight"), h(SplitIconV, { size: 15 }), (event) => doSplit("h", event.currentTarget)),
9565
+ actionButton("splitDown", t("splitDown"), h(SplitIconH, { size: 15 }), (event) => doSplit("v", event.currentTarget)),
9566
+ actionButton("close", t("closePane"), h(CloseIcon, { size: 14 }), doClose),
9567
+ ];
8642
9568
  const menuItem = (key, label, onClick, danger) => h("button", {
8643
9569
  key,
8644
9570
  type: "button",
@@ -8650,6 +9576,7 @@ window.__ModuleLoader__.load({
8650
9576
  }, label);
8651
9577
 
8652
9578
  const startHeaderDrag = (event) => {
9579
+ if (floating === true) { beginFloatGesture(sessionId, "move", event); return; }
8653
9580
  const target = event.target;
8654
9581
  if (target !== null && target !== undefined && typeof target.closest === "function"
8655
9582
  && target.closest("button,input") !== null) {
@@ -8675,6 +9602,7 @@ window.__ModuleLoader__.load({
8675
9602
  setInvalidDrop(false);
8676
9603
  endDragPreview();
8677
9604
  finishPaneReflowGesture();
9605
+ if (headerRef.current !== null) headerRef.current.draggable = false;
8678
9606
  };
8679
9607
  // A drop outside this pane (or a cancelled drag) never reaches the pane's
8680
9608
  // own onDrop, so clear the refusal wash from the document lifecycle too.
@@ -8790,13 +9718,36 @@ window.__ModuleLoader__.load({
8790
9718
  chrome !== false ? h(
8791
9719
  "div",
8792
9720
  {
8793
- className: "dsv-pane-header", draggable: true, onDragStart: startHeaderDrag, onDragEnd: endHeaderDrag, title,
8794
- onDoubleClick: (event) => {
9721
+ ref: headerRef,
9722
+ className: "dsv-pane-header", draggable: false,
9723
+ onMouseDown: floating === true || standalone === true ? undefined : (event) => {
9724
+ const header = headerRef.current;
9725
+ if (header === null) return;
8795
9726
  const target = event.target;
8796
- if (target !== null && target !== undefined && typeof target.closest === "function"
8797
- && target.closest("button,input,.dsv-pane-title-text") !== null) return;
8798
- setRuntime({ maximized: maximized ? null : sessionId });
9727
+ const interactive = target !== null && target !== undefined && typeof target.closest === "function"
9728
+ && target.closest("button,input,.dsv-pane-title-text") !== null;
9729
+ header.draggable = !interactive;
8799
9730
  },
9731
+ onDragStart: floating === true || standalone === true ? undefined : startHeaderDrag,
9732
+ onDragEnd: floating === true || standalone === true ? undefined : endHeaderDrag,
9733
+ onPointerDown: floating === true ? startHeaderDrag : undefined,
9734
+ onPointerMove: floating === true ? moveFloatGesture : undefined,
9735
+ onPointerUp: floating === true ? endFloatGesture : undefined,
9736
+ onPointerCancel: floating === true ? endFloatGesture : undefined,
9737
+ title: floating === true ? t("floatHint") : title,
9738
+ onDoubleClick: floating === true ? undefined : standalone === true
9739
+ ? (event) => {
9740
+ const target = event.target;
9741
+ if (target !== null && target !== undefined && typeof target.closest === "function"
9742
+ && target.closest("button,input,.dsv-pane-title-text") !== null) return;
9743
+ doFullscreen();
9744
+ }
9745
+ : (event) => {
9746
+ const target = event.target;
9747
+ if (target !== null && target !== undefined && typeof target.closest === "function"
9748
+ && target.closest("button,input,.dsv-pane-title-text") !== null) return;
9749
+ setRuntime({ maximized: maximized ? null : sessionId });
9750
+ },
8800
9751
  },
8801
9752
  // Reserved even when idle: the dot used to appear/disappear and
8802
9753
  // shifted the title's left edge by 15px between panes.
@@ -8872,12 +9823,22 @@ window.__ModuleLoader__.load({
8872
9823
  className: "dsv-pane-menu",
8873
9824
  onPointerDown: (event) => event.stopPropagation(),
8874
9825
  },
8875
- menuItem("maximize", maximized ? t("restore") : t("maximize"), () => { setMenuOpen(false); doMaximize(); }),
8876
- menuItem("copy", t("copy"), () => { setMenuOpen(false); doCopy(); }),
8877
- menuItem("help", t("helpOpen"), () => { setMenuOpen(false); doHelp(); }),
8878
- menuItem("splitRight", t("splitRight"), (event) => { doSplit("h", event.currentTarget); setMenuOpen(false); }),
8879
- menuItem("splitDown", t("splitDown"), (event) => { doSplit("v", event.currentTarget); setMenuOpen(false); }),
8880
- menuItem("close", t("closePane"), () => { setMenuOpen(false); doClose(); }, true),
9826
+ ...(standalone === true ? [
9827
+ menuItem("copy", t("copy"), () => { setMenuOpen(false); doCopy(); }),
9828
+ menuItem("help", t("helpOpen"), () => { setMenuOpen(false); doHelp(); }),
9829
+ menuItem("fullscreen", t("standaloneFullscreen"), () => { setMenuOpen(false); doFullscreen(); }),
9830
+ ] : floating === true ? [
9831
+ menuItem("dock", t("floatDock"), () => { setMenuOpen(false); dockFloatToSplit(sessionId); }),
9832
+ menuItem("help", t("helpOpen"), () => { setMenuOpen(false); doHelp(); }),
9833
+ menuItem("close", t("floatClose"), () => { setMenuOpen(false); closeFloatWindow(sessionId); }, true),
9834
+ ] : [
9835
+ menuItem("maximize", maximized ? t("restore") : t("maximize"), () => { setMenuOpen(false); doMaximize(); }),
9836
+ menuItem("copy", t("copy"), () => { setMenuOpen(false); doCopy(); }),
9837
+ menuItem("help", t("helpOpen"), () => { setMenuOpen(false); doHelp(); }),
9838
+ menuItem("splitRight", t("splitRight"), (event) => { doSplit("h", event.currentTarget); setMenuOpen(false); }),
9839
+ menuItem("splitDown", t("splitDown"), (event) => { doSplit("v", event.currentTarget); setMenuOpen(false); }),
9840
+ menuItem("close", t("closePane"), () => { setMenuOpen(false); doClose(); }, true),
9841
+ ]),
8881
9842
  ) : null,
8882
9843
  zone !== null
8883
9844
  ? h("div", { className: "dsv-drop-ghost", style: ghostStyle(zone) }, h("span", { className: "dsv-drop-label" }, t(zone.label)))
@@ -8908,6 +9869,8 @@ window.__ModuleLoader__.load({
8908
9869
  && a.session === b.session
8909
9870
  && a.focused === b.focused
8910
9871
  && a.chrome === b.chrome
9872
+ && a.floating === b.floating
9873
+ && a.standalone === b.standalone
8911
9874
  && summaryShallowEqual(a.summary, b.summary),
8912
9875
  );
8913
9876
 
@@ -8922,7 +9885,7 @@ window.__ModuleLoader__.load({
8922
9885
  return dir === "h" ? { width: basis, height: "100%" } : { height: basis, width: "100%" };
8923
9886
  }
8924
9887
 
8925
- function RenderLeaf({ id, chrome, generation }) {
9888
+ function RenderLeaf({ id, chrome, generation, floating, standalone }) {
8926
9889
  const state = useTree();
8927
9890
  const sessions = useSessionsList();
8928
9891
  const liveSummary = sessions !== null && sessions !== undefined && sessions.byId !== undefined ? sessions.byId[id] : undefined;
@@ -8942,14 +9905,16 @@ window.__ModuleLoader__.load({
8942
9905
  // A lone pane renders without the pane header, so a single
8943
9906
  // conversation looks exactly like the stock view.
8944
9907
  chrome: chrome !== false,
8945
- focused: state.focus === id,
8946
- onFocus: (sid) => treeStore.setFocus(sid),
9908
+ floating: floating === true,
9909
+ standalone: standalone === true,
9910
+ focused: floating !== true && standalone !== true && state.focus === id,
9911
+ onFocus: floating === true ? (sid) => { floatStore.focus(sid); } : (sid) => treeStore.setFocus(sid),
8947
9912
  // Teardown is NOT done here any more: treeStore.commit schedules the
8948
9913
  // departed leaf for disposal and ChatPane releases on unmount, so every
8949
9914
  // leaf-mutation path (✕, sidebar swap, closeFocused, movePane) is
8950
9915
  // covered by the same idempotent path.
8951
- onClose: (sid) => closePaneAnimated(sid),
8952
- pickerFor: (...args) => togglePicker(...args),
9916
+ onClose: floating === true ? () => closeFloatWindow(id) : (sid) => closePaneAnimated(sid),
9917
+ pickerFor: floating === true || standalone === true ? () => {} : (...args) => togglePicker(...args),
8953
9918
  }));
8954
9919
  }
8955
9920
 
@@ -9470,7 +10435,11 @@ window.__ModuleLoader__.load({
9470
10435
  if (ids.length === 0) return null;
9471
10436
  const id = resolveFocusedSessionId();
9472
10437
  if (id === null || id === undefined) return null;
9473
- if (ids.length === 1) return { exit: true, remaining: 0 };
10438
+ if (ids.length <= 2) {
10439
+ try { treeStore.closeLeaf(id); } catch {}
10440
+ scheduleRightbarHeal(450);
10441
+ return { exit: true, remaining: treeStore.leafIds().length };
10442
+ }
9474
10443
  treeStore.closeLeaf(id);
9475
10444
  return { exit: false, remaining: treeStore.leafIds().length };
9476
10445
  }, null);
@@ -9505,6 +10474,61 @@ window.__ModuleLoader__.load({
9505
10474
  reset() {
9506
10475
  return safeCall("reset()", resetWorkspace, { reset: false });
9507
10476
  },
10477
+ /** Hard reset: also wipes every plugin-owned localStorage/sessionStorage
10478
+ key and the pane runtime caches, so a split can always start again. */
10479
+ resetAll() {
10480
+ return safeCall("resetAll()", resetSplitEnvironment, { reset: false, cleared: 0 });
10481
+ },
10482
+ /** Add one session to the split (or park it in the pending split while
10483
+ the workspace is inactive). */
10484
+ addToSplit(sessionId) {
10485
+ return safeCall("addToSplit()", () => addSessionToSplit(sessionId), false);
10486
+ },
10487
+ /** Remove one session from the split / pending pick. Dropping to one
10488
+ pane exits split mode. */
10489
+ removeFromSplit(sessionId) {
10490
+ return safeCall("removeFromSplit()", () => removeSessionFromSplit(sessionId), false);
10491
+ },
10492
+ /** Enter floating-window mode for one session (detaches a split pane). */
10493
+ float(sessionId) {
10494
+ return safeCall("float()", () => floatSession(sessionId), false);
10495
+ },
10496
+ /** Dock a floating window back into the split (or the pending pick). */
10497
+ dockFloat(sessionId) {
10498
+ return safeCall("dockFloat()", () => dockFloatToSplit(sessionId), false);
10499
+ },
10500
+ /** Close one floating window without docking it. */
10501
+ closeFloat(sessionId) {
10502
+ return safeCall("closeFloat()", () => closeFloatWindow(sessionId), false);
10503
+ },
10504
+ /** Current floating-window ids, in stable creation order. */
10505
+ floats() {
10506
+ return safeCall("floats()", () => floatStore.ids(), []);
10507
+ },
10508
+ /** Open one conversation in a separate system window (Host-backed URL). */
10509
+ openSystemWindow(sessionId) {
10510
+ return safeCall("openSystemWindow()", () => openSystemWindow(sessionId), false);
10511
+ },
10512
+ /** Toggle performance mode (persisted; reduces animations/observers). */
10513
+ setPerformanceMode(flag) {
10514
+ return safeCall("setPerformanceMode()", () => setPerformanceMode(flag !== false), false);
10515
+ },
10516
+ /** Current performance-mode flag. */
10517
+ performanceMode() {
10518
+ return safeCall("performanceMode()", () => performanceModeOn(), false);
10519
+ },
10520
+ /** Reload the page to pick up an updated client bundle (same as Ctrl+R). */
10521
+ reloadClient() {
10522
+ return safeCall("reloadClient()", () => { try { location.reload(); } catch {} return true; }, false);
10523
+ },
10524
+ /** Sessions waiting for a second pick before the split starts. */
10525
+ pending() {
10526
+ return safeCall("pending()", () => pendingSplitStore.ids(), []);
10527
+ },
10528
+ /** Open the add-split dialog programmatically (footer menu equivalent). */
10529
+ openAddSplitDialog() {
10530
+ return safeCall("openAddSplitDialog()", () => { openAddSplitDialog("footer"); return true; }, false);
10531
+ },
9508
10532
  /** Clear crash counters/safe mode and re-activate the kept tree. */
9509
10533
  retry() {
9510
10534
  return safeCall("retry()", retryWorkspace, false);
@@ -9563,6 +10587,9 @@ window.__ModuleLoader__.load({
9563
10587
  frameColumns,
9564
10588
  selectFrameColumns,
9565
10589
  computeColumnBounds,
10590
+ measureColumnBounds,
10591
+ frameChildrenSnapshot,
10592
+ rectSnapshot,
9566
10593
  normalizeTree,
9567
10594
  isValidSessionId,
9568
10595
  noteGeometry,
@@ -9997,6 +11024,7 @@ window.__ModuleLoader__.load({
9997
11024
  }
9998
11025
  function useRightbarOpen() {
9999
11026
  const [open, setOpen] = React.useState(rightbarIsOpen);
11027
+ const performanceMode = useRuntime().performance === true;
10000
11028
  React.useEffect(() => {
10001
11029
  let column = null;
10002
11030
  let observer = null;
@@ -10019,7 +11047,7 @@ window.__ModuleLoader__.load({
10019
11047
  // The column can be created/removed by the stock layout; a cheap
10020
11048
  // low-frequency re-scan re-attaches the observer and catches toggles
10021
11049
  // that did not go through this plugin's button.
10022
- timer = window.setInterval(sync, 800);
11050
+ timer = window.setInterval(sync, performanceMode ? 3500 : 800);
10023
11051
  window.addEventListener("resize", sync);
10024
11052
  return () => {
10025
11053
  window.clearInterval(timer);
@@ -10028,7 +11056,7 @@ window.__ModuleLoader__.load({
10028
11056
  try { observer.disconnect(); } catch {}
10029
11057
  }
10030
11058
  };
10031
- }, []);
11059
+ }, [performanceMode]);
10032
11060
  return open;
10033
11061
  }
10034
11062
  /** Two distinct right-sidebar glyphs: a right chevron while the panel is
@@ -10153,6 +11181,7 @@ window.__ModuleLoader__.load({
10153
11181
  seatObserver: null,
10154
11182
  seatFrame: 0,
10155
11183
  timer: 0,
11184
+ lastSyncAt: 0,
10156
11185
  };
10157
11186
  // Scoped global selectors: prompt-enhancement plugins read the
10158
11187
  // transcript with document.querySelector(All) (dsh-prompt-history's
@@ -10200,6 +11229,13 @@ window.__ModuleLoader__.load({
10200
11229
  if (typeof MutationObserver === "function") {
10201
11230
  state.seatObserver = new MutationObserver(() => {
10202
11231
  if (state.seatFrame !== 0) return;
11232
+ // Perf mode: streaming mutates the overlay continuously. Sync at most
11233
+ // twice a second instead of once per animation frame.
11234
+ if (performanceModeOn()) {
11235
+ const now = Date.now();
11236
+ if (now - state.lastSyncAt < 500) return;
11237
+ state.lastSyncAt = now;
11238
+ }
10203
11239
  const run = () => { state.seatFrame = 0; sync(); };
10204
11240
  state.seatFrame = typeof requestAnimationFrame === "function"
10205
11241
  ? requestAnimationFrame(run)
@@ -10390,11 +11426,29 @@ window.__ModuleLoader__.load({
10390
11426
  return composerAnchorBridge;
10391
11427
  }
10392
11428
 
11429
+ /** Refcounted bridge ownership: the split body and the float layer can
11430
+ both host pane composers, and whichever unmounts last disposes. */
11431
+ let composerAnchorBridgeRefs = 0;
11432
+ function acquireComposerAnchorBridge() {
11433
+ installComposerAnchorBridge();
11434
+ composerAnchorBridgeRefs += 1;
11435
+ let released = false;
11436
+ return () => {
11437
+ if (released) return;
11438
+ released = true;
11439
+ composerAnchorBridgeRefs = Math.max(0, composerAnchorBridgeRefs - 1);
11440
+ if (composerAnchorBridgeRefs === 0 && composerAnchorBridge !== null) {
11441
+ try { composerAnchorBridge.dispose(); } catch {}
11442
+ composerAnchorBridge = null;
11443
+ }
11444
+ };
11445
+ }
11446
+
10393
11447
  const WorkspaceBody = React.memo(function WorkspaceBody({ generation }) {
10394
11448
  const state = useTree();
10395
11449
  React.useLayoutEffect(() => {
10396
- const bridge = installComposerAnchorBridge();
10397
- return () => { bridge.dispose(); };
11450
+ const release = acquireComposerAnchorBridge();
11451
+ return release;
10398
11452
  }, []);
10399
11453
  // A pane add/close/move mounts new composer cards after this commit.
10400
11454
  React.useEffect(() => {
@@ -10693,12 +11747,81 @@ window.__ModuleLoader__.load({
10693
11747
 
10694
11748
  /** The shell.overlay seat component: the workspace (keyed by the retry
10695
11749
  epoch, so Retry remounts a crashed/latched boundary) plus the chrome. */
10696
- function SplitWorkspaceSeat(props) {
10697
- const runtime = useRuntime();
10698
- return h(React.Fragment, null,
10699
- h(WorkspaceBoundary, { key: "workspace-" + runtime.epoch }, h(WorkspaceApp, props)),
10700
- h(PluginChrome, null),
10701
- );
11750
+ /** Update-ready chip: the Host serves the on-disk plugin version, so a
11751
+ running page can notice a freshly installed/updated bundle and reload
11752
+ itself (client-only changes) without a full DSH restart. */
11753
+ function UpdateNotice() {
11754
+ const [ready, setReady] = React.useState(null);
11755
+ React.useEffect(() => {
11756
+ let stopped = false;
11757
+ const check = () => {
11758
+ fetch("/dsv/version", { cache: "no-store" }).then((response) => {
11759
+ if (!response.ok) return null;
11760
+ return response.json().catch(() => null);
11761
+ }).then((payload) => {
11762
+ if (stopped || payload === null || payload === undefined) return;
11763
+ const version = typeof payload.version === "string" ? payload.version : null;
11764
+ if (version === null || version === "" || version === PLUGIN_VERSION) return;
11765
+ if (storageGet(UPDATE_DISMISSED_KEY) === version) return;
11766
+ setReady(version);
11767
+ }).catch(() => {});
11768
+ };
11769
+ const bootTimer = window.setTimeout(check, 4000);
11770
+ const timer = window.setInterval(() => {
11771
+ if (document.visibilityState === "visible") check();
11772
+ }, UPDATE_POLL_MS);
11773
+ return () => {
11774
+ stopped = true;
11775
+ window.clearTimeout(bootTimer);
11776
+ window.clearInterval(timer);
11777
+ };
11778
+ }, []);
11779
+ if (ready === null) return null;
11780
+ const desktop = typeof window !== "undefined" && typeof window.dshDesktop !== "undefined";
11781
+ // DSH Desktop applies profile/plugin changes at startup, so a page reload
11782
+ // cannot pick up a new bundle there; only a restart can. The Web GUI can
11783
+ // apply it with a refresh. Say the right thing instead of offering a
11784
+ // button that silently fails.
11785
+ return h("div", { className: "dsv-update-chip", role: "status" },
11786
+ h("span", null, t(desktop ? "updateRestart" : "updateReady", { v: ready })),
11787
+ desktop ? null : h("button", {
11788
+ type: "button",
11789
+ className: "dsv-update-chip-btn accent",
11790
+ onClick: () => { try { location.reload(); } catch {} },
11791
+ }, t("reloadNow")),
11792
+ h("button", {
11793
+ type: "button",
11794
+ className: "dsv-update-chip-btn",
11795
+ onClick: () => {
11796
+ storageSet(UPDATE_DISMISSED_KEY, ready);
11797
+ setReady(null);
11798
+ },
11799
+ }, t(desktop ? "gotIt" : "laterLabel")),
11800
+ );
11801
+ }
11802
+
11803
+ function SplitWorkspaceSeat(props) {
11804
+ const runtime = useRuntime();
11805
+ // A standalone system window renders ONLY its conversation: no split
11806
+ // workspace, no floats, no launcher. WorkspaceApp still mounts (hidden,
11807
+ // inactive) because it publishes the root standard faces the pane host
11808
+ // needs.
11809
+ const standaloneId = standaloneSessionId();
11810
+ if (standaloneId !== null) {
11811
+ try { document.documentElement.setAttribute("data-dsv-standalone", "1"); } catch {}
11812
+ const standaloneProps = Object.assign({}, props, { dsvStandalone: true });
11813
+ return h(React.Fragment, null,
11814
+ h(WorkspaceBoundary, { key: "workspace-" + runtime.epoch }, h(WorkspaceApp, standaloneProps)),
11815
+ h(WorkspaceBoundary, { key: "standalone-" + runtime.epoch }, h(StandaloneSessionWindow, { sessionId: standaloneId })),
11816
+ );
11817
+ }
11818
+ return h(React.Fragment, null,
11819
+ h(WorkspaceBoundary, { key: "workspace-" + runtime.epoch }, h(WorkspaceApp, props)),
11820
+ h(PluginChrome, null),
11821
+ h(WorkspaceBoundary, { key: "floats-" + runtime.epoch }, h(FloatLayer, null)),
11822
+ h(SplitLauncherLayer, null),
11823
+ h(UpdateNotice, null),
11824
+ );
10702
11825
  }
10703
11826
 
10704
11827
  function WorkspaceApp(props) {
@@ -10730,7 +11853,11 @@ window.__ModuleLoader__.load({
10730
11853
  // The activation gate: >=2 panes AND the kill switch/safe mode allow it.
10731
11854
  // Everything below keys off this — observers, DOM scraping, the overlay.
10732
11855
  const minimized = runtime.minimized === true;
10733
- const active = leaves.length >= 2 && runtime.enabled === true && runtime.safeMode !== true;
11856
+ // A standalone system window never activates the split overlay: its whole
11857
+ // page is owned by StandaloneSessionWindow.
11858
+ const standaloneWindow = props.dsvStandalone === true;
11859
+ const active = standaloneWindow !== true && leaves.length >= 2
11860
+ && runtime.enabled === true && runtime.safeMode !== true;
10734
11861
  const [picker, setPicker] = React.useState(pickerRequest);
10735
11862
  const [bounds, setBounds] = React.useState({ left: 0, right: 0, top: 0, bottom: 0, ok: false });
10736
11863
  const geometryWarnedRef = React.useRef(false);
@@ -10762,7 +11889,7 @@ window.__ModuleLoader__.load({
10762
11889
  // inside that pane. Portals mount asynchronously, so a body childList
10763
11890
  // observer plus a low-frequency re-scan catches new panes.
10764
11891
  React.useEffect(() => {
10765
- if (!operational) {
11892
+ if (!operational || runtime.performance === true) {
10766
11893
  tocGripsRestore();
10767
11894
  return undefined;
10768
11895
  }
@@ -10798,7 +11925,7 @@ window.__ModuleLoader__.load({
10798
11925
  document.body.classList.remove("dsv-layout-previewing");
10799
11926
  tocGripsRestore();
10800
11927
  };
10801
- }, [operational]);
11928
+ }, [operational, runtime.performance]);
10802
11929
 
10803
11930
  // A plugin/skills/settings panel replaces the whole main view. The split
10804
11931
  // overlay would cover it, so step aside automatically and keep the tree;
@@ -10873,7 +12000,7 @@ window.__ModuleLoader__.load({
10873
12000
  // (right sidebar open/close, desktop window resize). A single missed
10874
12001
  // measurement used to leave the whole workspace invisible until the
10875
12002
  // next full reload; this low-frequency backstop re-measures regardless.
10876
- let fallbackInterval = window.setInterval(schedule, 1000);
12003
+ let fallbackInterval = window.setInterval(schedule, runtime.performance === true ? 3500 : 1000);
10877
12004
  let transitionHost = null;
10878
12005
  try {
10879
12006
  const overlayLayer = document.querySelector("[data-shell-overlay]");
@@ -10905,7 +12032,7 @@ window.__ModuleLoader__.load({
10905
12032
  window.removeEventListener("resize", schedule);
10906
12033
  document.removeEventListener("visibilitychange", schedule);
10907
12034
  };
10908
- }, [active]);
12035
+ }, [active, runtime.performance]);
10909
12036
 
10910
12037
  // Crash-loop guard timers: a deliberate activation is persisted BEFORE it
10911
12038
  // can crash; a healthy, responsive workspace clears the counter after
@@ -11038,7 +12165,7 @@ window.__ModuleLoader__.load({
11038
12165
  // stock view) and announce the outcome with a transient toast, so
11039
12166
  // "/compact" is never silent.
11040
12167
  React.useEffect(() => {
11041
- if (!operational) return undefined;
12168
+ if (!operational || runtime.performance === true) return undefined;
11042
12169
  if (typeof MutationObserver !== "function") return undefined;
11043
12170
  const seen = new WeakSet();
11044
12171
  const seenText = new Set();
@@ -11104,7 +12231,7 @@ window.__ModuleLoader__.load({
11104
12231
  return () => {
11105
12232
  try { observer.disconnect(); } catch {}
11106
12233
  };
11107
- }, [operational]);
12234
+ }, [operational, runtime.performance]);
11108
12235
 
11109
12236
  // NOTE: there is deliberately NO "auto-add the current conversation"
11110
12237
  // effect any more. The old one flipped the workspace on at boot —
@@ -11502,6 +12629,15 @@ window.__ModuleLoader__.load({
11502
12629
  }
11503
12630
  function closePaneAnimated(sessionId) {
11504
12631
  if (closingPaneSessions.has(sessionId)) return;
12632
+ // Closing one of the last two panes ends the split. The store clears the
12633
+ // whole tree in that case (see endSplitBecauseTooSmall), so the other
12634
+ // conversation immediately loses its "in split" membership.
12635
+ if (treeStore.leafIds().length <= 2) {
12636
+ try { treeStore.closeLeaf(sessionId); } catch {}
12637
+ scheduleRightbarHeal(450);
12638
+ showPaneToast(t("splitExited"), true);
12639
+ return;
12640
+ }
11505
12641
  const pane = paneElementForSession(sessionId);
11506
12642
  if (pane === null || pane === undefined || prefersReducedMotion()) {
11507
12643
  try { treeStore.closeLeaf(sessionId); } catch {}
@@ -11515,6 +12651,762 @@ window.__ModuleLoader__.load({
11515
12651
  }, 150);
11516
12652
  }
11517
12653
 
12654
+ // ---------------------------------------------------------------------
12655
+ // split launcher + session membership (0.5.0)
12656
+ //
12657
+ // The sidebar footer button opens a small menu (add / exit / minimize /
12658
+ // reset) and the "add split" dialog multi-selects conversations. Both are
12659
+ // rendered from the always-mounted shell.overlay seat, so neither is
12660
+ // clipped by the sidebar column nor covered by the split overlay. The
12661
+ // session-row right-click menu contributes its two membership actions
12662
+ // through the host's contextMenus service, so the stock menu keeps owning
12663
+ // its presentation and the contribution disappears when this plugin
12664
+ // unloads.
12665
+ // ---------------------------------------------------------------------
12666
+
12667
+ function usePendingSplit() {
12668
+ return React.useSyncExternalStore(
12669
+ pendingSplitStore.subscribe,
12670
+ pendingSplitStore.getSnapshot,
12671
+ pendingSplitStore.getSnapshot,
12672
+ );
12673
+ }
12674
+
12675
+ function sameSessionIds(left, right) {
12676
+ if (left.length !== right.length) return false;
12677
+ for (let index = 0; index < left.length; index += 1) {
12678
+ if (left[index] !== right[index]) return false;
12679
+ }
12680
+ return true;
12681
+ }
12682
+
12683
+ /** Aspect ratio of the conversation column; only decides columns vs rows
12684
+ for a two-pane split (the same 1.2 fallback settleAuto uses). */
12685
+ function splitColumnAspect() {
12686
+ try {
12687
+ const bounds = measureColumnBounds();
12688
+ if (bounds !== null && bounds !== undefined && bounds.ok === true) {
12689
+ const width = window.innerWidth - bounds.left - bounds.right;
12690
+ const height = window.innerHeight - bounds.top - bounds.bottom;
12691
+ if (width > 0 && height > 0) return width / height;
12692
+ }
12693
+ } catch {}
12694
+ return 1.2;
12695
+ }
12696
+
12697
+ /** A deliberate split action overrides the soft guards (kill switch and
12698
+ crash-loop safe mode): the user just asked for a split now. */
12699
+ function prepareExplicitSplit() {
12700
+ try {
12701
+ if (runtimeState.enabled !== true) setEnabled(true);
12702
+ if (runtimeState.safeMode === true) retryWorkspace();
12703
+ } catch {}
12704
+ }
12705
+
12706
+ function unminimizeForSplit() {
12707
+ if (runtimeState.minimized !== true) return;
12708
+ try {
12709
+ setRuntime({ minimized: false });
12710
+ writeMinimized(false);
12711
+ } catch {}
12712
+ }
12713
+
12714
+ function openSessionInMainView(sessionId) {
12715
+ try {
12716
+ const workspace = pluginCtx !== null && pluginCtx !== undefined && typeof pluginCtx.get === "function"
12717
+ ? pluginCtx.get("uiWorkspace")
12718
+ : null;
12719
+ if (workspace !== null && workspace !== undefined && typeof workspace.openSession === "function") {
12720
+ workspace.openSession(sessionId);
12721
+ }
12722
+ } catch {}
12723
+ }
12724
+
12725
+ /** Build the split from an ordered session list. Zero/one selection leaves
12726
+ split mode entirely (a one-pane workspace is not a split) and shows the
12727
+ single conversation in the stock main view. */
12728
+ function buildSplitFromSessions(ids) {
12729
+ const ordered = [];
12730
+ for (const id of Array.isArray(ids) ? ids : []) {
12731
+ if (!isValidSessionId(id) || ordered.indexOf(id) !== -1) continue;
12732
+ if (floatStore.has(id)) floatStore.remove(id);
12733
+ ordered.push(id);
12734
+ }
12735
+ if (ordered.length < 2) {
12736
+ try { exitWorkspace(); } catch {}
12737
+ if (ordered.length === 1) openSessionInMainView(ordered[0]);
12738
+ return false;
12739
+ }
12740
+ pendingSplitStore.clear();
12741
+ prepareExplicitSplit();
12742
+ unminimizeForSplit();
12743
+ const root = buildArrangedRoot(ordered, autoLayoutMode(ordered.length, splitColumnAspect()));
12744
+ try { treeStore.replaceRoot(root); } catch {}
12745
+ return true;
12746
+ }
12747
+
12748
+ /** Add one conversation to the split. Inactive: park it in the pending
12749
+ split until a second pick exists. Active: append a pane immediately. */
12750
+ function addSessionToSplit(sessionId) {
12751
+ if (!isValidSessionId(sessionId)) return false;
12752
+ if (floatStore.has(sessionId)) floatStore.remove(sessionId);
12753
+ const leaves = treeStore.leafIds();
12754
+ if (leaves.indexOf(sessionId) !== -1) {
12755
+ try { treeStore.setFocus(sessionId); } catch {}
12756
+ return false;
12757
+ }
12758
+ if (leaves.length > 0) {
12759
+ pendingSplitStore.clear();
12760
+ prepareExplicitSplit();
12761
+ unminimizeForSplit();
12762
+ try { treeStore.addPane(sessionId); } catch {}
12763
+ return true;
12764
+ }
12765
+ pendingSplitStore.add(sessionId);
12766
+ if (pendingSplitStore.size() >= 2) {
12767
+ const ids = pendingSplitStore.ids();
12768
+ pendingSplitStore.clear();
12769
+ buildSplitFromSessions(ids);
12770
+ } else {
12771
+ showPaneToast(t("pendingAdded"), true);
12772
+ }
12773
+ return true;
12774
+ }
12775
+
12776
+ /** Remove one conversation from the split (or from the pending pick).
12777
+ Dropping to one pane exits split mode entirely. */
12778
+ function removeSessionFromSplit(sessionId) {
12779
+ if (!isValidSessionId(sessionId)) return false;
12780
+ if (pendingSplitStore.has(sessionId)) {
12781
+ pendingSplitStore.remove(sessionId);
12782
+ showPaneToast(t("splitLeft"), true);
12783
+ return true;
12784
+ }
12785
+ const leaves = treeStore.leafIds();
12786
+ if (leaves.indexOf(sessionId) === -1) return false;
12787
+ if (leaves.length <= 2) {
12788
+ pendingSplitStore.clear();
12789
+ try { exitWorkspace(); } catch {}
12790
+ showPaneToast(t("splitExited"), true);
12791
+ return true;
12792
+ }
12793
+ closePaneAnimated(sessionId);
12794
+ return true;
12795
+ }
12796
+
12797
+ /** Remove every transient node the plugin may have appended to the body. */
12798
+ function clearTransientSplitDom() {
12799
+ try {
12800
+ for (const selector of [".dsv-toast", ".dsv-drag-preview", ".dsv-drop-ghost", ".dsv-pane-invalid"]) {
12801
+ for (const element of document.querySelectorAll(selector)) {
12802
+ try { element.remove(); } catch {}
12803
+ }
12804
+ }
12805
+ } catch {}
12806
+ try {
12807
+ if (dragImageCanvas !== null && dragImageCanvas !== undefined) dragImageCanvas.remove();
12808
+ } catch {}
12809
+ dragImageCanvas = null;
12810
+ try { endDragPreview(); } catch {}
12811
+ try { document.body.classList.remove("dsv-layout-previewing"); } catch {}
12812
+ try { tocGripsRestore(); } catch {}
12813
+ }
12814
+
12815
+ /** Drop per-pane runtime caches after the reset's unmount had a frame to
12816
+ run its own lifetime cleanup. A broken teardown could otherwise leave a
12817
+ stale retain/editor guard behind and the next split would inherit it. */
12818
+ function clearPaneRuntimeCaches() {
12819
+ try { treeStore.reset(); } catch {}
12820
+ if (composerAnchorBridge !== null) {
12821
+ try { composerAnchorBridge.dispose(); } catch {}
12822
+ composerAnchorBridge = null;
12823
+ }
12824
+ composerAnchorBridgeRefs = 0;
12825
+ for (const reference of paneSessionReferences.values()) {
12826
+ try { if (reference !== null && typeof reference.release === "function") reference.release(); } catch {}
12827
+ }
12828
+ paneSessionReferences.clear();
12829
+ for (const guard of paneEditorGuards.values()) {
12830
+ try { if (guard !== null && typeof guard.dispose === "function") guard.dispose(); } catch {}
12831
+ }
12832
+ paneEditorGuards.clear();
12833
+ for (const timer of paneDisposeChecks.values()) {
12834
+ try { window.clearTimeout(timer); } catch {}
12835
+ }
12836
+ paneDisposeChecks.clear();
12837
+ paneLiveRefs.clear();
12838
+ for (const resolver of sessionFaceResolvers.values()) {
12839
+ try { if (resolver !== null && typeof resolver.dispose === "function") resolver.dispose(); } catch {}
12840
+ }
12841
+ sessionFaceResolvers.clear();
12842
+ paneRetainFailures.clear();
12843
+ for (const unsubscribe of paneTypingUnsubs.values()) {
12844
+ try { unsubscribe(); } catch {}
12845
+ }
12846
+ paneTypingUnsubs.clear();
12847
+ chatScrollMemory.clear();
12848
+ lastSessionSummaries.clear();
12849
+ entryStoreCache.clear();
12850
+ clearEntryInjectCache();
12851
+ paneImageIntake.clear();
12852
+ paneKitWarned.clear();
12853
+ rootPendingBySession.clear();
12854
+ rootPendingListeners.clear();
12855
+ composerModeStore.clear();
12856
+ composerActionsBySession.clear();
12857
+ setActiveComposerPaneId(null);
12858
+ paneToastAt = 0;
12859
+ lastTypedSessionId = null;
12860
+ storageRemove("dsh.split-workspace.last-typed.v1");
12861
+ }
12862
+
12863
+ /** "Reset split": wipe every key this plugin owns (localStorage AND
12864
+ sessionStorage, current and older releases), the persisted tree, the
12865
+ crash guard, the kill switch, minimized/maximized UI state and all
12866
+ transient pane data — so a split can always be started again even after
12867
+ a cache-driven failure. */
12868
+ function resetSplitEnvironment() {
12869
+ const cleared = [];
12870
+ closeLauncher();
12871
+ pendingSplitStore.clear();
12872
+ floatStore.clear();
12873
+ try { window.clearTimeout(minimizeTimer); } catch {}
12874
+ try { window.clearTimeout(exitTimer); } catch {}
12875
+ minimizeTimer = 0;
12876
+ exitTimer = 0;
12877
+ closingPaneSessions.clear();
12878
+ dragPayload = null;
12879
+ externalDragSessionId = null;
12880
+ clearTransientSplitDom();
12881
+ // Layout, safe mode, health counters, geometry block and the retry epoch
12882
+ // (the epoch bump remounts the overlay boundary with clean state).
12883
+ try { resetWorkspace(); } catch {}
12884
+ clearSplitStorage(window.localStorage, cleared);
12885
+ clearSplitStorage(window.sessionStorage, cleared);
12886
+ // resetWorkspace() keeps a kill switch intact; this action is explicitly
12887
+ // "make the split work again", so drop the flag (an absent key means
12888
+ // enabled) and clear the runtime flag below.
12889
+ storageRemove(ENABLED_KEY);
12890
+ setRuntime({
12891
+ enabled: true,
12892
+ safeMode: false,
12893
+ active: false,
12894
+ minimized: false,
12895
+ geometryBlocked: false,
12896
+ maximized: null,
12897
+ chipDismissed: false,
12898
+ tipVisible: false,
12899
+ helpOpen: false,
12900
+ });
12901
+ const resetEpoch = runtimeState.epoch;
12902
+ try {
12903
+ window.setTimeout(() => {
12904
+ // A split started within the grace window owns the caches now.
12905
+ if (runtimeState.epoch !== resetEpoch) return;
12906
+ try {
12907
+ if (treeStore.leafIds().length !== 0) return;
12908
+ clearPaneRuntimeCaches();
12909
+ } catch {}
12910
+ }, 350);
12911
+ } catch { try { clearPaneRuntimeCaches(); } catch {} }
12912
+ showPaneToast(t("resetDone"), true);
12913
+ return { reset: true, cleared: cleared.length };
12914
+ }
12915
+
12916
+ const SPLIT_STORAGE_PREFIX = "dsh.split-workspace.";
12917
+ // User preferences survive "reset split": a hard reset is about the split
12918
+ // environment (layout/caches), not about the performance setting or the
12919
+ // update notices.
12920
+ const PRESERVED_STORAGE_KEYS = new Set([PERF_KEY, SEEN_VERSION_KEY, UPDATE_DISMISSED_KEY]);
12921
+ function clearSplitStorage(storage, cleared) {
12922
+ if (storage === null || storage === undefined) return;
12923
+ const keys = [];
12924
+ try {
12925
+ for (let index = 0; index < storage.length; index += 1) {
12926
+ const key = storage.key(index);
12927
+ if (typeof key === "string" && key.indexOf(SPLIT_STORAGE_PREFIX) === 0 && !PRESERVED_STORAGE_KEYS.has(key)) keys.push(key);
12928
+ }
12929
+ } catch {}
12930
+ for (const key of keys) {
12931
+ try {
12932
+ storage.removeItem(key);
12933
+ cleared.push(key);
12934
+ } catch {}
12935
+ }
12936
+ }
12937
+
12938
+ /** Contribute 加入分屏 / 退出分屏 to the stock session context menu. The
12939
+ service is looked up lazily: a host without ui-context-menu simply does
12940
+ not get the rows (nothing else changes). */
12941
+ function installSplitSessionMenu() {
12942
+ const ctx = pluginCtx;
12943
+ if (ctx === null || ctx === undefined || typeof ctx.get !== "function") return () => {};
12944
+ let timer = 0;
12945
+ let tries = 0;
12946
+ let dispose = null;
12947
+ const attempt = () => {
12948
+ timer = 0;
12949
+ let menus = undefined;
12950
+ try { menus = ctx.get("contextMenus"); } catch {}
12951
+ if (menus !== undefined && menus !== null && typeof menus.register === "function") {
12952
+ try {
12953
+ dispose = menus.register({
12954
+ id: "split-workspace.session",
12955
+ target: "session",
12956
+ order: 350,
12957
+ observe: () => [treeStore, pendingSplitStore, floatStore],
12958
+ resolve: (target) => {
12959
+ const id = target !== null && target !== undefined ? target.sessionId : undefined;
12960
+ if (!isValidSessionId(id)) return [];
12961
+ const inSplit = treeStore.leafIds().indexOf(id) !== -1;
12962
+ const pending = pendingSplitStore.has(id);
12963
+ const floating = floatStore.has(id);
12964
+ return [
12965
+ {
12966
+ id: "add",
12967
+ label: t("menuAddToSplit"),
12968
+ disabled: inSplit || pending,
12969
+ run: () => { if (floatStore.has(id)) dockFloatToSplit(id); else addSessionToSplit(id); },
12970
+ },
12971
+ {
12972
+ id: "remove",
12973
+ label: t("exitSplit"),
12974
+ disabled: !inSplit && !pending,
12975
+ run: () => { removeSessionFromSplit(id); },
12976
+ },
12977
+ {
12978
+ id: "float",
12979
+ label: t(floating ? "menuFloatClose" : "menuFloatOpen"),
12980
+ separatorBefore: true,
12981
+ run: () => {
12982
+ if (floatStore.has(id)) closeFloatWindow(id);
12983
+ else floatSession(id);
12984
+ },
12985
+ },
12986
+ {
12987
+ id: "system",
12988
+ label: t("menuSystemWindow"),
12989
+ separatorBefore: true,
12990
+ failureLabel: t("systemWindowFailed"),
12991
+ run: () => openSystemWindow(id),
12992
+ },
12993
+ ];
12994
+ },
12995
+ });
12996
+ } catch (error) {
12997
+ try { console.warn(LOG_PREFIX + " could not register the session menu contribution:", String(error).slice(0, 160)); } catch {}
12998
+ }
12999
+ return;
13000
+ }
13001
+ if (tries >= 60) return;
13002
+ tries += 1;
13003
+ timer = window.setTimeout(attempt, 250);
13004
+ };
13005
+ attempt();
13006
+ return () => {
13007
+ if (timer !== 0) { try { window.clearTimeout(timer); } catch {} }
13008
+ if (dispose !== null) { try { dispose(); } catch {} }
13009
+ };
13010
+ }
13011
+
13012
+ function SplitPickCheck({ checked }) {
13013
+ return h("span", {
13014
+ className: "dsv-pick-check",
13015
+ "aria-hidden": "true",
13016
+ }, checked ? "✓" : "");
13017
+ }
13018
+
13019
+ function SplitPickRow({ item, checked, onToggle }) {
13020
+ return h("button", {
13021
+ type: "button",
13022
+ role: "checkbox",
13023
+ "aria-checked": checked ? "true" : "false",
13024
+ className: "dsv-pick-row",
13025
+ onClick: onToggle,
13026
+ },
13027
+ h(SplitPickCheck, { checked }),
13028
+ h("span", { className: "dsv-pick-text" },
13029
+ h("span", { className: "dsv-pick-title" }, item.title),
13030
+ item.sub !== "" ? h("span", { className: "dsv-pick-sub" }, item.sub) : null,
13031
+ ),
13032
+ item.tag !== null && item.tag !== undefined ? h("span", { className: "dsv-pick-tag" }, t(item.tag)) : null,
13033
+ );
13034
+ }
13035
+
13036
+ /** Multi-select "添加分屏" dialog. Opened from the footer menu, so the
13037
+ current members stay selected and can be unchecked (the final selection
13038
+ rebuilds the split) or extended with more conversations. */
13039
+ function AddSplitDialog() {
13040
+ const sessions = useSessionsList();
13041
+ const tree = useTree();
13042
+ const treeLeaves = tree.root === null ? [] : leafOf(tree.root, []);
13043
+ const initialSelection = treeLeaves.length >= 2 ? treeLeaves : pendingSplitStore.ids();
13044
+ const [selected, setSelected] = React.useState(() => initialSelection.slice());
13045
+ const [query, setQuery] = React.useState("");
13046
+
13047
+ // The DOM-backed list source observes only while the split is active;
13048
+ // refresh on mount so a picker opened from the stock view is current.
13049
+ React.useEffect(() => {
13050
+ try {
13051
+ if (sessionsListSource !== undefined && sessionsListSource !== null
13052
+ && typeof sessionsListSource.refresh === "function") sessionsListSource.refresh();
13053
+ } catch {}
13054
+ }, []);
13055
+
13056
+ const pendingIds = pendingSplitStore.ids();
13057
+ const items = [];
13058
+ const seen = new Set();
13059
+ if (sessions !== null && sessions !== undefined && Array.isArray(sessions.ids)) {
13060
+ for (const id of sessions.ids) {
13061
+ const summary = sessions.byId ? sessions.byId[id] : undefined;
13062
+ if (summary === undefined || summary === null) continue;
13063
+ if (summary.parentId !== undefined) continue;
13064
+ if (summary.origin === "subagent" || summary.blank === true) continue;
13065
+ if (id.indexOf("session-") !== 0) continue;
13066
+ seen.add(id);
13067
+ items.push({ id, summary, title: summary.displayTitle || summary.title || id });
13068
+ }
13069
+ }
13070
+ // A pane session the list no longer carries (archived/hidden) must stay
13071
+ // visible, otherwise it could never be unchecked.
13072
+ for (const id of selected) {
13073
+ if (seen.has(id)) continue;
13074
+ seen.add(id);
13075
+ items.push({ id, summary: null, title: id });
13076
+ }
13077
+ const needle = query.trim().toLowerCase();
13078
+ const visible = items.filter((item) => needle === "" || item.title.toLowerCase().includes(needle));
13079
+ visible.sort((a, b) => (Number(b.summary && b.summary.updatedAt) || 0) - (Number(a.summary && a.summary.updatedAt) || 0));
13080
+
13081
+ const toggle = (id) => setSelected((previous) => (previous.indexOf(id) === -1
13082
+ ? previous.concat([id])
13083
+ : previous.filter((entry) => entry !== id)));
13084
+
13085
+ const confirm = () => {
13086
+ const ids = selected.slice();
13087
+ closeLauncher();
13088
+ if (ids.length >= 2) {
13089
+ prepareExplicitSplit();
13090
+ unminimizeForSplit();
13091
+ const leavesNow = treeStore.leafIds();
13092
+ const additionsOnly = leavesNow.length >= 2 && ids.length > leavesNow.length
13093
+ && leavesNow.every((id) => ids.indexOf(id) !== -1);
13094
+ if (additionsOnly) {
13095
+ for (const id of ids) {
13096
+ if (leavesNow.indexOf(id) === -1) {
13097
+ try { floatStore.remove(id); } catch {}
13098
+ try { treeStore.addPane(id); } catch {}
13099
+ }
13100
+ }
13101
+ } else if (!sameSessionIds(ids, leavesNow)) {
13102
+ buildSplitFromSessions(ids);
13103
+ }
13104
+ pendingSplitStore.clear();
13105
+ return;
13106
+ }
13107
+ const wasActive = treeStore.leafIds().length >= 2;
13108
+ pendingSplitStore.clear();
13109
+ if (!wasActive) {
13110
+ // Not in split mode yet: one pick becomes the pending split (the
13111
+ // dialog is also a way to stage the first conversation).
13112
+ if (ids.length === 1) {
13113
+ pendingSplitStore.add(ids[0]);
13114
+ showPaneToast(t("pendingAdded"), true);
13115
+ }
13116
+ return;
13117
+ }
13118
+ try { exitWorkspace(); } catch {}
13119
+ if (ids.length === 1) openSessionInMainView(ids[0]);
13120
+ showPaneToast(t("splitExited"), true);
13121
+ };
13122
+
13123
+ return h("div", {
13124
+ className: "dsv-modal-backdrop",
13125
+ onPointerDown: (event) => {
13126
+ if (event.target === event.currentTarget) closeLauncher();
13127
+ },
13128
+ onKeyDown: (event) => {
13129
+ if (event.key !== "Escape") return;
13130
+ event.preventDefault();
13131
+ event.stopPropagation();
13132
+ closeLauncher();
13133
+ },
13134
+ },
13135
+ h("div", {
13136
+ className: "dsv-modal",
13137
+ role: "dialog",
13138
+ "aria-modal": "true",
13139
+ "aria-label": t("addSplitTitle"),
13140
+ },
13141
+ h("div", { className: "dsv-modal-head" },
13142
+ h("span", { className: "dsv-modal-title" }, t("addSplitTitle")),
13143
+ h("button", {
13144
+ type: "button",
13145
+ className: "dsv-modal-close",
13146
+ title: t("addSplitCancel"),
13147
+ "aria-label": t("addSplitCancel"),
13148
+ onClick: closeLauncher,
13149
+ }, "×"),
13150
+ ),
13151
+ h("div", { className: "dsv-modal-hint" }, t("addSplitHint")),
13152
+ h("input", {
13153
+ className: "dsv-modal-search",
13154
+ type: "search",
13155
+ autoFocus: true,
13156
+ placeholder: t("railSearch"),
13157
+ value: query,
13158
+ onChange: (event) => setQuery(event.target.value),
13159
+ }),
13160
+ h("div", { className: "dsv-modal-body" },
13161
+ visible.length === 0 ? h("div", { className: "dsv-pick-empty" }, t("addSplitEmpty")) : null,
13162
+ visible.map((item) => h(SplitPickRow, {
13163
+ key: item.id,
13164
+ item: {
13165
+ title: item.title,
13166
+ sub: item.summary !== null && item.summary.cwd !== undefined ? basenameOf(item.summary.cwd) : "",
13167
+ tag: treeLeaves.indexOf(item.id) !== -1
13168
+ ? "addSplitInSplit"
13169
+ : (pendingIds.indexOf(item.id) !== -1 ? "addSplitPending" : null),
13170
+ },
13171
+ checked: selected.indexOf(item.id) !== -1,
13172
+ onToggle: () => toggle(item.id),
13173
+ })),
13174
+ ),
13175
+ h("div", { className: "dsv-modal-foot" },
13176
+ h("span", { className: "dsv-modal-count" }, t("addSplitSelected", { n: selected.length })),
13177
+ h("button", { type: "button", className: "dsv-modal-btn", onClick: closeLauncher }, t("addSplitCancel")),
13178
+ h("button", { type: "button", className: "dsv-modal-btn accent", onClick: confirm }, t("addSplitConfirm")),
13179
+ ),
13180
+ ),
13181
+ );
13182
+ }
13183
+
13184
+ function SplitLauncherMenu({ request }) {
13185
+ const runtime = useRuntime();
13186
+ const tree = useTree();
13187
+ const pending = usePendingSplit();
13188
+ const ref = React.useRef(null);
13189
+ const [pos, setPos] = React.useState(null);
13190
+ const leaves = tree.root === null ? [] : leafOf(tree.root, []);
13191
+ const active = leaves.length >= 2;
13192
+
13193
+ React.useLayoutEffect(() => {
13194
+ const element = ref.current;
13195
+ if (element === null) return;
13196
+ const width = element.offsetWidth || 200;
13197
+ const height = element.offsetHeight || 210;
13198
+ const rect = request !== null && request !== undefined ? request.rect : null;
13199
+ let left = rect !== null && rect !== undefined ? rect.left : 12;
13200
+ left = Math.min(Math.max(8, left), Math.max(8, window.innerWidth - width - 8));
13201
+ let top;
13202
+ if (rect !== null && rect !== undefined) {
13203
+ top = rect.top - height - 6;
13204
+ if (top < 8) top = Math.min(window.innerHeight - height - 8, rect.bottom + 6);
13205
+ } else {
13206
+ top = window.innerHeight - height - 12;
13207
+ }
13208
+ setPos({ left, top });
13209
+ }, [request]);
13210
+
13211
+ React.useEffect(() => {
13212
+ const onPointerDown = (event) => {
13213
+ const target = event.target;
13214
+ if (target !== null && target !== undefined && typeof target.closest === "function") {
13215
+ try {
13216
+ if (target.closest(".dsv-launcher-menu") !== null) return;
13217
+ if (target.closest(".dsv-footer-btn") !== null) return;
13218
+ } catch {}
13219
+ }
13220
+ closeLauncher();
13221
+ };
13222
+ const onKeyDown = (event) => {
13223
+ if (event.key !== "Escape") return;
13224
+ event.preventDefault();
13225
+ event.stopPropagation();
13226
+ closeLauncher();
13227
+ };
13228
+ document.addEventListener("pointerdown", onPointerDown, true);
13229
+ document.addEventListener("keydown", onKeyDown, true);
13230
+ return () => {
13231
+ document.removeEventListener("pointerdown", onPointerDown, true);
13232
+ document.removeEventListener("keydown", onKeyDown, true);
13233
+ };
13234
+ }, []);
13235
+
13236
+ const row = (key, icon, label, onClick, options) => h("button", {
13237
+ key,
13238
+ type: "button",
13239
+ role: "menuitem",
13240
+ className: "dsv-launcher-item" + (options !== undefined && options.danger === true ? " danger" : ""),
13241
+ disabled: options !== undefined && options.disabled === true,
13242
+ onClick: options !== undefined && options.disabled === true ? undefined : onClick,
13243
+ },
13244
+ h("span", { className: "dsv-launcher-icon", "aria-hidden": "true" }, icon),
13245
+ h("span", null, label),
13246
+ );
13247
+
13248
+ return h("div", {
13249
+ ref,
13250
+ className: "dsv-launcher-menu",
13251
+ role: "menu",
13252
+ "aria-label": t("menuTitle"),
13253
+ style: pos === null ? { left: "-9999px", top: "-9999px" } : pos,
13254
+ },
13255
+ h("div", { className: "dsv-launcher-header" },
13256
+ pending.length > 0 ? t("pendingBadge", { n: pending.length }) : t("menuTitle")),
13257
+ row("add", "+", t("menuAddSplit"), () => { closeLauncher(); openAddSplitDialog(request.source); }),
13258
+ h("div", { key: "separator-top", className: "dsv-launcher-separator" }),
13259
+ row("exit", "✕", t("exitSplit"), () => { closeLauncher(); try { exitWorkspace(); } catch {} }, { disabled: !active }),
13260
+ row("minimize", "—", t("menuMinimizeSplit"), () => { closeLauncher(); try { minimizeWorkspace(); } catch {} }, {
13261
+ disabled: !active || runtime.minimized === true,
13262
+ }),
13263
+ h("div", { key: "separator-bottom", className: "dsv-launcher-separator" }),
13264
+ row("performance", "⚡", t("performanceMode") + (runtime.performance === true ? " ✓" : ""),
13265
+ () => { closeLauncher(); setPerformanceMode(runtime.performance !== true); }),
13266
+ row("reload", "↻", t("refreshInterface"), () => { closeLauncher(); try { location.reload(); } catch {} }),
13267
+ row("reset", "↺", t("menuResetSplit"), () => { closeLauncher(); resetSplitEnvironment(); }, { danger: true }),
13268
+ );
13269
+ }
13270
+
13271
+ /** Always-mounted launcher layer (inside the shell.overlay seat). */
13272
+ function SplitLauncherLayer() {
13273
+ const launcher = useLauncherState();
13274
+ // A split that becomes active through any other entry point (drag,
13275
+ // pane-header picker, external API) retires the pending pick, so the
13276
+ // badge can never promise a pending conversation that is now a pane.
13277
+ React.useEffect(() => treeStore.subscribe(() => {
13278
+ if (treeStore.isActive() && pendingSplitStore.size() > 0) pendingSplitStore.clear();
13279
+ }), []);
13280
+ if (launcher.mode === "menu") return h(SplitLauncherMenu, { request: launcher });
13281
+ if (launcher.mode === "dialog") return h(AddSplitDialog, null);
13282
+ return null;
13283
+ }
13284
+
13285
+
13286
+ /** One floating window: a fixed, movable, resizable frame around the real
13287
+ pane (header + transcript + composer). The pane header is the drag
13288
+ handle; the wrapper draws the window frame and owns the resize edges. */
13289
+ function FloatWindow({ id, x, y, width, height, zIndex, focused }) {
13290
+ const runtime = useRuntime();
13291
+ const style = {
13292
+ left: x + "px", top: y + "px", width: width + "px", height: height + "px",
13293
+ zIndex: zIndex,
13294
+ };
13295
+ return h("div", {
13296
+ className: "dsv-float-window" + (focused ? " focused" : ""),
13297
+ "data-dsv-float": id,
13298
+ style,
13299
+ onPointerDownCapture: () => { try { floatStore.focus(id); } catch {} },
13300
+ },
13301
+ h("div", { className: "dsv-float-body" },
13302
+ h(RenderLeaf, { id, chrome: true, generation: runtime.generation, floating: true })),
13303
+ ["n", "s", "e", "w", "ne", "nw", "se", "sw"].map((dir) => h("div", {
13304
+ key: dir,
13305
+ className: "dsv-float-resize dsv-float-resize-" + dir,
13306
+ "data-dsv-float-resize": dir,
13307
+ onPointerDown: (event) => beginFloatGesture(id, dir, event),
13308
+ onPointerMove: moveFloatGesture,
13309
+ onPointerUp: endFloatGesture,
13310
+ onPointerCancel: endFloatGesture,
13311
+ })),
13312
+ );
13313
+ }
13314
+
13315
+ /** Always-mounted floating layer. It renders above the split overlay and
13316
+ is independent of the split activation gate: one conversation can float
13317
+ with zero panes. The composer bridge is acquired only while at least one
13318
+ window exists, so the inactive plugin still observes nothing. */
13319
+ function FloatLayer() {
13320
+ const runtime = useRuntime();
13321
+ const floats = useFloats();
13322
+ const windows = floats.windows;
13323
+ const count = windows.length;
13324
+ React.useEffect(() => {
13325
+ if (runtime.enabled !== true || count === 0) return undefined;
13326
+ floatLayerMounted = true;
13327
+ const release = acquireComposerAnchorBridge();
13328
+ return () => { floatLayerMounted = false; release(); };
13329
+ }, [runtime.enabled, count === 0]);
13330
+ React.useEffect(() => {
13331
+ if (count === 0) return undefined;
13332
+ const clampAll = () => {
13333
+ const work = chipWorkRect();
13334
+ for (const win of floatStore.getSnapshot().windows) {
13335
+ const next = clampFloatRect(win, work);
13336
+ if (next.x !== win.x || next.y !== win.y || next.w !== win.w || next.h !== win.h) {
13337
+ floatStore.setRect(win.id, next, false);
13338
+ }
13339
+ }
13340
+ };
13341
+ clampAll();
13342
+ window.addEventListener("resize", clampAll);
13343
+ // The column can change without a window resize (right-sidebar open/
13344
+ // close, shell layout transitions), so re-clamp on a low-frequency
13345
+ // backstop while floats exist. setRect is a no-op when nothing moved.
13346
+ // Perf mode keeps only the resize path.
13347
+ const timer = performanceModeOn() ? 0 : window.setInterval(clampAll, 1000);
13348
+ return () => {
13349
+ window.removeEventListener("resize", clampAll);
13350
+ if (timer !== 0) {
13351
+ try { window.clearInterval(timer); } catch {}
13352
+ }
13353
+ };
13354
+ }, [count, runtime.performance]);
13355
+ if (runtime.enabled !== true || count === 0) return null;
13356
+ // Stacking is a z-index swap, never a DOM reorder: moving a live editor
13357
+ // subtree (keyed React children) would blur the composer.
13358
+ const ranks = new Map();
13359
+ windows.slice().sort((a, b) => a.z - b.z).forEach((win, index) => ranks.set(win.id, index + 1));
13360
+ return h("div", {
13361
+ className: "dsv-float-layer",
13362
+ "data-dsv-float-layer": "true",
13363
+ "data-plugin": PLUGIN_ID,
13364
+ }, windows.map((win) => h(FloatWindow, {
13365
+ key: win.id,
13366
+ id: win.id,
13367
+ x: win.x,
13368
+ y: win.y,
13369
+ width: win.w,
13370
+ height: win.h,
13371
+ zIndex: ranks.get(win.id) || 1,
13372
+ focused: floats.focused === win.id,
13373
+ })));
13374
+ }
13375
+
13376
+ /** Whole-page view used inside a standalone system window: one native
13377
+ conversation, native window controls, no split / floats / launcher. */
13378
+ function StandaloneSessionWindow({ sessionId }) {
13379
+ const runtime = useRuntime();
13380
+ const sessions = useSessionsList();
13381
+ const summary = sessions !== null && sessions !== undefined && sessions.byId !== undefined
13382
+ ? sessions.byId[sessionId]
13383
+ : undefined;
13384
+ const title = summary !== null && summary !== undefined
13385
+ ? (summary.displayTitle || summary.title || sessionId)
13386
+ : sessionId;
13387
+ React.useEffect(() => {
13388
+ try { document.title = title + " — DeepSeek Harness"; } catch {}
13389
+ }, [title]);
13390
+ // The DOM session-list source normally observes only while a split is
13391
+ // live. This page is a one-conversation workspace, so keep it warm for
13392
+ // the title and the re-hosted header.
13393
+ React.useEffect(() => {
13394
+ const source = sessionsListSource;
13395
+ if (source === undefined || source === null || typeof source.setActive !== "function") return undefined;
13396
+ try { source.setActive(true); } catch {}
13397
+ try { if (typeof source.refresh === "function") source.refresh(); } catch {}
13398
+ return () => {
13399
+ try { source.setActive(false); } catch {}
13400
+ };
13401
+ }, []);
13402
+ return h("div", {
13403
+ className: "dsv-standalone",
13404
+ "data-dsv-standalone-window": sessionId,
13405
+ },
13406
+ h(RenderLeaf, { id: sessionId, chrome: true, generation: runtime.generation, standalone: true }),
13407
+ );
13408
+ }
13409
+
11518
13410
  function restoreSplit() {
11519
13411
  try {
11520
13412
  const tree = treeStore.getSnapshot();
@@ -11540,35 +13432,32 @@ window.__ModuleLoader__.load({
11540
13432
  writeMinimized(false);
11541
13433
  }
11542
13434
 
11543
- /** Sidebar-footer entry point: start a split with the current session plus
11544
- the next listed session. Drag-to-split remains the primary gesture; this
11545
- makes the feature discoverable without a pane already open. */
11546
- function startSplitFromFooter() {
11547
- try {
11548
- if (treeStore.leafIds().length >= 2) {
11549
- restoreSplit();
11550
- return;
11551
- }
11552
- const list = sessionsListSource;
11553
- const snap = list !== undefined && list !== null && typeof list.getSnapshot === "function" ? list.getSnapshot() : null;
11554
- const ids = snap !== null && snap !== undefined
11555
- ? (Array.isArray(snap.ids) ? snap.ids : Object.keys(snap.byId || {}))
11556
- : [];
11557
- const current = currentSessionId();
11558
- const first = current !== undefined && current !== null ? current : ids[0];
11559
- const second = ids.find((id) => id !== first);
11560
- if (first !== undefined && first !== null) treeStore.addPane(first);
11561
- if (second !== undefined && second !== null) treeStore.addPane(second);
11562
- } catch {}
11563
- }
13435
+ /** Sidebar-footer entry point: opens the split menu (add / exit / minimize
13436
+ / reset). Adding a split from the menu makes the feature discoverable
13437
+ without a pane already open; drag-to-split stays the primary gesture. */
11564
13438
  function FooterSplitButton() {
13439
+ const launcher = useLauncherState();
13440
+ const pending = usePendingSplit();
13441
+ const open = launcher.mode !== "closed";
11565
13442
  return h("button", {
11566
13443
  type: "button",
11567
13444
  className: "dsv-footer-btn",
11568
- title: t("openSplit"),
11569
- "aria-label": t("openSplit"),
11570
- onClick: startSplitFromFooter,
11571
- }, h(SplitIconV, { size: 15 }));
13445
+ title: pending.length > 0 ? t("pendingBadge", { n: pending.length }) : t("menuTitle"),
13446
+ "aria-label": t("menuTitle"),
13447
+ "aria-haspopup": "menu",
13448
+ "aria-expanded": open ? "true" : "false",
13449
+ "data-open": launcher.mode === "menu" ? "true" : "false",
13450
+ onClick: (event) => {
13451
+ if (open) {
13452
+ closeLauncher();
13453
+ return;
13454
+ }
13455
+ openLauncherMenu(event.currentTarget);
13456
+ },
13457
+ },
13458
+ h(SplitIconV, { size: 15 }),
13459
+ pending.length > 0 ? h("span", { className: "dsv-footer-badge" }, String(pending.length)) : null,
13460
+ );
11572
13461
  }
11573
13462
 
11574
13463
  /** True while apply() has installed the plugin; guards double-apply (a
@@ -11640,6 +13529,34 @@ window.__ModuleLoader__.load({
11640
13529
 
11641
13530
  ctx.effect(() => insertStyle(DSV_CSS), "dsh-split-workspace: stylesheet");
11642
13531
 
13532
+ // Performance mode is a CSS class on <html>; mirror the persisted flag
13533
+ // on every apply so a reload keeps it.
13534
+ ctx.effect(() => {
13535
+ applyPerformanceClass();
13536
+ return () => {
13537
+ try { document.documentElement.removeAttribute("data-dsv-performance"); } catch {}
13538
+ };
13539
+ }, "dsh-split-workspace: performance class");
13540
+
13541
+ // Acknowledge the freshly loaded bundle. When the stored version is older
13542
+ // than this client, the user just got an update (usually after a reload
13543
+ // or a DSH restart) — say so once. The update-ready chip covers the
13544
+ // opposite direction: a newer version sitting on disk while this page
13545
+ // still runs the old bundle.
13546
+ ctx.effect(() => {
13547
+ try {
13548
+ const seen = storageGet(SEEN_VERSION_KEY);
13549
+ storageSet(SEEN_VERSION_KEY, PLUGIN_VERSION);
13550
+ if (seen !== null && seen !== undefined && seen !== "" && seen !== PLUGIN_VERSION) {
13551
+ const timer = window.setTimeout(() => {
13552
+ try { showPaneToast(t("updatedToast", { v: PLUGIN_VERSION }), true); } catch {}
13553
+ }, 1400);
13554
+ return () => { try { window.clearTimeout(timer); } catch {} };
13555
+ }
13556
+ } catch {}
13557
+ return () => {};
13558
+ }, "dsh-split-workspace: version notice");
13559
+
11643
13560
  // Global chords (Alt+T, Alt+Shift+Arrows) ride the plugin's OWN
11644
13561
  // lifetime now: the old module-scope listeners stacked on every reload
11645
13562
  // and were never removed.
@@ -11649,6 +13566,12 @@ window.__ModuleLoader__.load({
11649
13566
  // conversation column starts the split.
11650
13567
  ctx.effect(registerDragBridge, "dsh-split-workspace: drag bridge");
11651
13568
 
13569
+ // Session-row context menu contributions (加入分屏 / 退出分屏). The host's
13570
+ // contextMenus service owns the popup; this plugin only contributes
13571
+ // actions, so the stock menu keeps its look and the rows disappear on
13572
+ // unload.
13573
+ ctx.effect(installSplitSessionMenu, "dsh-split-workspace: session menu");
13574
+
11652
13575
  // Right-sidebar repair: the split teardown could leave the sidebar-right
11653
13576
  // store open while its column was closed (the corner button then vanished
11654
13577
  // with no way back) or leave a stock control writing to a seat nobody
@@ -11676,6 +13599,9 @@ window.__ModuleLoader__.load({
11676
13599
 
11677
13600
  ctx.effect(
11678
13601
  () => () => {
13602
+ closeLauncher();
13603
+ pendingSplitStore.clear();
13604
+ try { document.querySelectorAll(".dsv-launcher-menu").forEach((element) => element.remove()); } catch {}
11679
13605
  sessionsService = undefined;
11680
13606
  sessionsListSource = undefined;
11681
13607
  if (domListSourceDispose !== null) {