dsh-split-workspace 0.9.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -75,7 +75,7 @@ window.__ModuleLoader__.load({
75
75
  // ---------------------------------------------------------------------
76
76
 
77
77
  const PLUGIN_ID = "dsh-split-workspace";
78
- const PLUGIN_VERSION = "0.9.0";
78
+ const PLUGIN_VERSION = "0.11.1";
79
79
  const LOG_PREFIX = "[dsh-split-workspace]";
80
80
  const TREE_KEY = "dsh.split-workspace.tree.v1";
81
81
  const OPEN_KEY = "dsh.split-workspace.open.v2";
@@ -90,22 +90,6 @@ window.__ModuleLoader__.load({
90
90
  const SEEN_VERSION_KEY = "dsh.split-workspace.seen-version.v1";
91
91
  const UPDATE_DISMISSED_KEY = "dsh.split-workspace.update-dismissed.v1";
92
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
- }
109
93
  function readChipPos() {
110
94
  const raw = storageGet(CHIP_KEY);
111
95
  if (!raw) return null;
@@ -574,6 +558,11 @@ window.__ModuleLoader__.load({
574
558
  countSuffix: " panes",
575
559
  queuedBadge: "queued",
576
560
  helpTitle: "Split view — shortcuts and help",
561
+ helpShotsTitle: "Where things are",
562
+ helpShotMenu: "Right-click a conversation → Split plugin",
563
+ helpShotFooter: "Split button menu (bottom-left)",
564
+ helpShotSettings: "Settings → Split workspace",
565
+ helpShotZoom: "Click to enlarge",
577
566
  helpOpen: "Split view help",
578
567
  helpClose: "Close",
579
568
  helpShortcuts: "Shortcuts",
@@ -624,10 +613,35 @@ window.__ModuleLoader__.load({
624
613
  floatDocked: "Docked to the split view",
625
614
  floatClosed: "Floating window closed",
626
615
  floatHint: "Drag the title bar to move · drag an edge to resize",
627
- helpFloat: "Right-click a conversation → Enter floating window detaches it into a movable window; Dock to split puts it back.",
628
- menuSystemWindow: "Open in system window",
629
- systemWindowOpened: "Opened in a separate system window",
630
- systemWindowFailed: "Could not open a system window",
616
+ helpFloat: "Right-click a conversation → Split plugin → Enter floating window detaches it into a movable window; Dock to split puts it back.",
617
+ helpIndependent: "Right-click a conversation → Split plugin → Enter independent window / Enter system window. The independent window is an app-internal single-conversation window; the system window (macOS) is a real OS window with no left sidebar and the stock right sidebar. Neither opens a browser.",
618
+ menuSystemWindow: "Open in independent window",
619
+ systemWindowOpened: "Opened in an independent window",
620
+ systemWindowFailed: "Could not open the independent window",
621
+ systemWindowOpening: "Opening the system window…",
622
+ systemWindowClosing: "Closing the system window…",
623
+ systemWindowNativeOpened: "Entered the system window",
624
+ systemWindowNativeClosed: "System window closed",
625
+ systemWindowUnsupported: "The native system window needs macOS + DSH Desktop. Use Enter independent window instead.",
626
+ menuGroup: "Split plugin",
627
+ menuIndependentOpen: "Enter independent window",
628
+ menuIndependentClose: "Exit independent window",
629
+ menuNativeOpen: "Enter system window",
630
+ menuNativeClose: "Exit system window",
631
+ independentMinimize: "Minimize",
632
+ independentRestore: "Restore window",
633
+ independentClose: "Close window",
634
+ settingsNav: "Split workspace",
635
+ settingsHeading: "Split workspace",
636
+ settingsDesc: "Unlimited native panes, floating windows and app-internal independent windows. These settings apply to the whole plugin.",
637
+ settingsStatus: "Status",
638
+ settingsVersion: "Version",
639
+ settingsPanes: "Panes",
640
+ settingsPending: "Pending split",
641
+ settingsFloats: "Floating windows",
642
+ settingsPerformance: "Performance mode",
643
+ settingsPerformanceDesc: "Reduces animations and background observers, and skips the drag-preview thumbnail.",
644
+ settingsActions: "Actions",
631
645
  standaloneFullscreen: "Fullscreen",
632
646
  performanceMode: "Performance mode",
633
647
  performanceOn: "Performance mode on — animations and background observers are reduced",
@@ -699,6 +713,11 @@ window.__ModuleLoader__.load({
699
713
  countSuffix: " 个面板",
700
714
  queuedBadge: "条排队",
701
715
  helpTitle: "分屏视图 — 快捷键与帮助",
716
+ helpShotsTitle: "界面指引",
717
+ helpShotMenu: "右键会话 → 分屏插件",
718
+ helpShotFooter: "左下角分屏按钮菜单",
719
+ helpShotSettings: "设置 → 分屏工作区",
720
+ helpShotZoom: "点击查看大图",
702
721
  helpOpen: "分屏帮助",
703
722
  helpClose: "关闭",
704
723
  helpShortcuts: "快捷键",
@@ -749,10 +768,35 @@ window.__ModuleLoader__.load({
749
768
  floatDocked: "已回到分屏",
750
769
  floatClosed: "浮窗已关闭",
751
770
  floatHint: "拖动标题栏移动 · 拖动边缘调整大小",
752
- helpFloat: "右键会话 → 进入浮窗,可把该会话变成独立浮窗;浮窗标题栏的“回到分屏”可放回分屏。",
753
- menuSystemWindow: "在系统窗口打开",
754
- systemWindowOpened: "已在独立系统窗口中打开",
755
- systemWindowFailed: "无法打开系统窗口",
771
+ helpFloat: "右键会话 → 分屏插件 → 进入浮窗,可把该会话变成独立浮窗;浮窗标题栏的“回到分屏”可放回分屏。",
772
+ helpIndependent: "右键会话 → 分屏插件 → 进入独立窗口 / 进入系统窗口。独立窗口在应用内单独显示该会话(关闭 / 最小化 / 最大化 / 全屏);系统窗口(macOS)是真正的操作系统窗口,不显示左侧栏、保留右侧栏。两者都不依赖浏览器。",
773
+ menuSystemWindow: "在独立窗口打开",
774
+ systemWindowOpened: "已在独立窗口中打开",
775
+ systemWindowFailed: "无法打开独立窗口",
776
+ systemWindowOpening: "正在打开系统窗口…",
777
+ systemWindowClosing: "正在关闭系统窗口…",
778
+ systemWindowNativeOpened: "已进入系统窗口",
779
+ systemWindowNativeClosed: "已关闭系统窗口",
780
+ systemWindowUnsupported: "系统窗口仅支持 macOS 桌面版;可改用“进入独立窗口”。",
781
+ menuGroup: "分屏插件",
782
+ menuIndependentOpen: "进入独立窗口",
783
+ menuIndependentClose: "退出独立窗口",
784
+ menuNativeOpen: "进入系统窗口",
785
+ menuNativeClose: "退出系统窗口",
786
+ independentMinimize: "最小化",
787
+ independentRestore: "恢复窗口",
788
+ independentClose: "关闭窗口",
789
+ settingsNav: "分屏工作区",
790
+ settingsHeading: "分屏工作区",
791
+ settingsDesc: "无限原生窗格、浮窗与应用内独立窗口。这里的设置对整个插件生效。",
792
+ settingsStatus: "状态",
793
+ settingsVersion: "版本",
794
+ settingsPanes: "窗格",
795
+ settingsPending: "待分屏",
796
+ settingsFloats: "浮窗",
797
+ settingsPerformance: "性能模式",
798
+ settingsPerformanceDesc: "减少动画与后台观察器,并跳过拖动缩略图预览。",
799
+ settingsActions: "操作",
756
800
  standaloneFullscreen: "全屏",
757
801
  performanceMode: "性能模式",
758
802
  performanceOn: "性能模式已开启:动画与后台观察器已精简",
@@ -930,6 +974,50 @@ window.__ModuleLoader__.load({
930
974
  .dsv-fallback-label { white-space: nowrap; }
931
975
  html[data-dsv-performance="1"] .dsv-fallback-launcher { box-shadow: none; }
932
976
 
977
+ /* ---- settings page (0.10.0): the same controls as the footer menu,
978
+ contributed to the system Settings panel through settings.section. ---- */
979
+ .dsv-settings {
980
+ display: flex; flex-direction: column; gap: 14px;
981
+ padding: 2px 2px 28px;
982
+ color: var(--dsw-alias-label-primary);
983
+ font-family: var(--dsw-font-family, system-ui, sans-serif);
984
+ }
985
+ .dsv-settings-desc { font-size: 12px; line-height: 19px; color: var(--dsw-alias-label-tertiary); }
986
+ .dsv-settings-group {
987
+ display: flex; flex-direction: column;
988
+ border: 1px solid var(--dsw-alias-border-l2); border-radius: 12px;
989
+ background: var(--dsw-alias-bg-layer-1, var(--dsw-alias-bg-base));
990
+ padding: 4px 14px;
991
+ }
992
+ .dsv-settings-group-title {
993
+ margin: 0; padding: 10px 0 6px;
994
+ font-size: 12px; font-weight: 600; line-height: 18px;
995
+ color: var(--dsw-alias-label-secondary);
996
+ }
997
+ .dsv-settings-row {
998
+ display: flex; align-items: center; gap: 12px; min-height: 44px;
999
+ padding: 6px 0; border-top: 1px solid color-mix(in srgb, var(--dsw-alias-border-l2) 62%, transparent);
1000
+ }
1001
+ .dsv-settings-group-title + .dsv-settings-row { border-top: 0; }
1002
+ .dsv-settings-label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
1003
+ .dsv-settings-row-label { flex: 1; min-width: 0; font-size: 13px; line-height: 20px; }
1004
+ .dsv-settings-value {
1005
+ flex: none; max-width: 52%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
1006
+ font-size: 12px; line-height: 19px; color: var(--dsw-alias-label-tertiary);
1007
+ }
1008
+ .dsv-settings-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 0 12px; }
1009
+ .dsv-settings-btn {
1010
+ height: 30px; padding: 0 12px; border-radius: 8px;
1011
+ border: 1px solid var(--dsw-alias-border-l2); background: transparent;
1012
+ color: var(--dsw-alias-label-primary); font-family: inherit; font-size: 12px;
1013
+ cursor: pointer;
1014
+ }
1015
+ .dsv-settings-btn:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
1016
+ .dsv-settings-btn:disabled { opacity: 0.42; cursor: default; }
1017
+ .dsv-settings-btn.accent { background: var(--dsw-static-deepseek-500); border-color: transparent; color: #fff; }
1018
+ .dsv-settings-btn.accent:hover:not(:disabled) { background: var(--dsw-static-deepseek-500); filter: brightness(1.05); }
1019
+ .dsv-settings-btn.danger { color: #e5484d; }
1020
+
933
1021
  /* ---- 0.5.0 launcher: the sidebar footer menu and the multi-select
934
1022
  "add split" dialog. Both mount through the shell overlay seat, so they
935
1023
  are never clipped by the sidebar column or the split overlay. ---- */
@@ -961,7 +1049,7 @@ window.__ModuleLoader__.load({
961
1049
  @keyframes dsv-launcher-in { from { opacity: 0; transform: translateY(4px); } }
962
1050
 
963
1051
  .dsv-modal-backdrop {
964
- position: fixed; inset: 0; z-index: 150;
1052
+ position: fixed; inset: 0; z-index: 2147483002;
965
1053
  display: flex; align-items: center; justify-content: center;
966
1054
  background: rgba(0, 0, 0, 0.32);
967
1055
  animation: dsv-fade-in 0.12s ease-out;
@@ -1092,10 +1180,9 @@ window.__ModuleLoader__.load({
1092
1180
  @media (prefers-reduced-motion: reduce) {
1093
1181
  .dsv-float-window { animation: none; transition: none; }
1094
1182
  }
1095
- /* ---- standalone system window (hash dsvWindow=<id>): one conversation
1096
- fills the whole page, rendered into the separate OS/browser window the
1097
- Host route opened. The window chrome (close/minimize/zoom/fullscreen)
1098
- is the native window's own. ---- */
1183
+ /* ---- independent window: one conversation fills the surface, rendered
1184
+ inside the in-app window frame with its own close / minimize /
1185
+ maximize / fullscreen controls. ---- */
1099
1186
  html[data-dsv-standalone] { overflow: hidden; }
1100
1187
  html[data-dsv-standalone] body { overflow: hidden; }
1101
1188
  .dsv-standalone {
@@ -1113,6 +1200,38 @@ window.__ModuleLoader__.load({
1113
1200
  flex: 1; min-width: 0; min-height: 0;
1114
1201
  border: 0; border-radius: 0; box-shadow: none;
1115
1202
  }
1203
+
1204
+ /* ---- independent window (0.10.0): a first-class in-app window for one
1205
+ conversation. DSH exposes no plugin-facing BrowserWindow API, so this
1206
+ replaces the old browser window with an application surface. ---- */
1207
+ .dsv-app-window-layer {
1208
+ position: fixed; inset: 0; z-index: 999;
1209
+ display: flex; align-items: center; justify-content: center;
1210
+ background: color-mix(in srgb, #000 18%, transparent);
1211
+ }
1212
+ .dsv-app-window {
1213
+ position: relative; overflow: hidden;
1214
+ width: min(1120px, calc(100vw - 96px));
1215
+ height: min(780px, calc(100vh - 96px));
1216
+ min-width: 0; min-height: 0;
1217
+ border: 1px solid var(--dsw-alias-border-l2); border-radius: 14px;
1218
+ background: var(--dsw-alias-bg-base);
1219
+ box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28), 0 4px 12px rgba(0, 0, 0, 0.12);
1220
+ }
1221
+ .dsv-app-window.maximized {
1222
+ width: 100vw; height: 100vh; border: 0; border-radius: 0; box-shadow: none;
1223
+ }
1224
+ .dsv-app-window .dsv-standalone-embedded {
1225
+ position: absolute; inset: 0; z-index: auto;
1226
+ }
1227
+ .dsv-app-window-chip { left: 16px; right: auto; bottom: 16px; z-index: 1200; }
1228
+ .dsv-app-window-chip .dsv-chip-text {
1229
+ max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
1230
+ }
1231
+ html[data-dsv-performance="1"] .dsv-app-window { box-shadow: none; }
1232
+ @media (max-width: 900px) {
1233
+ .dsv-app-window { width: 100vw; height: 100vh; border: 0; border-radius: 0; }
1234
+ }
1116
1235
  .dsv-standalone .dsv-pane-header { height: 40px; }
1117
1236
  /* One title per pane: the pane header owns it. The stock header keeps its
1118
1237
  view tabs and action rows but not its breadcrumb; the slim header's own
@@ -2010,7 +2129,7 @@ window.__ModuleLoader__.load({
2010
2129
  .dsv-help-title { font-size: 13px; font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
2011
2130
  /* fixed variant: used by the inactive "could not start" chip path, where
2012
2131
  the plugin overlay (the card's normal containing block) is not rendered */
2013
- .dsv-help-card-fixed { position: fixed; bottom: 56px; z-index: 95; }
2132
+ .dsv-help-card-fixed { position: fixed; bottom: 56px; z-index: 2147482999; }
2014
2133
  .dsv-help-row { display: flex; gap: 10px; padding: 2px 0; }
2015
2134
  .dsv-help-keys {
2016
2135
  flex: none; min-width: 150px; font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
@@ -2018,6 +2137,37 @@ window.__ModuleLoader__.load({
2018
2137
  }
2019
2138
  .dsv-help-body { color: var(--dsw-alias-label-secondary); white-space: pre-wrap; overflow-wrap: anywhere; }
2020
2139
  .dsv-help-actions { display: flex; gap: 8px; margin-top: 10px; }
2140
+ /* help-card screenshots: a wider, scrollable card with three thumbnails;
2141
+ clicking one opens a viewport-level lightbox. No transform on the card,
2142
+ so the fixed lightbox is not trapped in a transformed containing block. */
2143
+ .dsv-help-card {
2144
+ left: 0; right: 0; margin-left: auto; margin-right: auto; transform: none;
2145
+ width: min(680px, calc(100% - 32px));
2146
+ max-height: min(78vh, 760px); overflow: auto; overscroll-behavior: contain;
2147
+ }
2148
+ .dsv-help-section-title { margin-top: 10px; font-size: 12px; font-weight: 600; }
2149
+ .dsv-help-shots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 6px; }
2150
+ .dsv-help-shot {
2151
+ margin: 0; padding: 0; border: 1px solid var(--dsw-alias-border-l2); border-radius: 10px;
2152
+ overflow: hidden; background: var(--dsw-alias-bg-base); cursor: zoom-in;
2153
+ }
2154
+ .dsv-help-shot:hover { border-color: var(--dsw-static-deepseek-500); }
2155
+ .dsv-help-shot img {
2156
+ display: block; width: 100%; height: 124px; object-fit: contain; object-position: top center;
2157
+ background: var(--dsw-alias-bg-layer-1);
2158
+ }
2159
+ .dsv-help-shot figcaption {
2160
+ font-size: 10px; line-height: 14px; padding: 4px 6px;
2161
+ color: var(--dsw-alias-label-tertiary); text-align: center;
2162
+ }
2163
+ .dsv-help-lightbox {
2164
+ position: fixed; inset: 0; z-index: 2147483000; display: flex; align-items: center; justify-content: center;
2165
+ padding: 24px; background: rgba(0, 0, 0, 0.62); cursor: zoom-out;
2166
+ }
2167
+ .dsv-help-lightbox img {
2168
+ max-width: min(92vw, 1200px); max-height: 86vh; border-radius: 12px;
2169
+ box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35); background: var(--dsw-alias-bg-base); cursor: default;
2170
+ }
2021
2171
  .dsv-pane-error {
2022
2172
  flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center;
2023
2173
  justify-content: center; gap: 8px; padding: 20px; text-align: center;
@@ -2091,6 +2241,25 @@ window.__ModuleLoader__.load({
2091
2241
  .dsv-update-chip-btn.accent { background: var(--dsw-static-deepseek-500); border-color: transparent; color: #fff; }
2092
2242
  .dsv-update-chip-btn:hover { background: var(--dsw-alias-interactive-bg-hover); }
2093
2243
  html[data-dsv-performance="1"] .dsv-update-chip { box-shadow: none; }
2244
+
2245
+ /* Native system window (0.11.0): the OS window shows one conversation.
2246
+ The left sidebar is removed; the right sidebar and every other column
2247
+ stay exactly as the stock layout renders them. The frame's first grid
2248
+ track is also zeroed by the client boot (React owns that inline style). */
2249
+ html[data-dsv-system-window="1"] [data-slot="sidebar"],
2250
+ html[data-dsv-system-window="1"] [data-side="sidebar"],
2251
+ html[data-dsv-system-window="1"] [data-shell-leading],
2252
+ html[data-dsv-system-window="1"] [data-sidebar-mask] {
2253
+ display: none !important;
2254
+ }
2255
+ html[data-dsv-system-window="1"] .dsv-footer-btn,
2256
+ html[data-dsv-system-window="1"] .dsv-fallback-launcher,
2257
+ html[data-dsv-system-window="1"] .dsv-app-window-layer,
2258
+ html[data-dsv-system-window="1"] .dsv-chip,
2259
+ html[data-dsv-system-window="1"] .dsv-update-chip,
2260
+ html[data-dsv-system-window="1"] .dsv-toast {
2261
+ display: none !important;
2262
+ }
2094
2263
  `;
2095
2264
 
2096
2265
  function insertStyle(css) {
@@ -2183,6 +2352,57 @@ window.__ModuleLoader__.load({
2183
2352
  try { window.localStorage.removeItem(key); return true; } catch { return false; }
2184
2353
  }
2185
2354
 
2355
+ // ---------------------------------------------------------------------
2356
+ // public diagnostics global (one fresh object per bundle execution)
2357
+ //
2358
+ // `window.__dshSplitWorkspace` outlives the bundle that created it: DSH
2359
+ // swaps a rebuilt client bundle into the running page (client HMR `rebuilt`
2360
+ // frame) and a disable / enable cycle re-creates the entry without reloading
2361
+ // the page. The next factory execution therefore used to inherit the
2362
+ // previous one's descriptors — and the read-only `__test` seam is
2363
+ // non-configurable, so re-defining it on the inherited object threw
2364
+ // `TypeError: Cannot redefine property: __test`. That exception aborted the
2365
+ // whole factory: the footer button, the session menus and the Settings page
2366
+ // stayed missing (DSH listed the entry as a failed page synchronization)
2367
+ // until the user reloaded the page or restarted DSH. A fresh object per
2368
+ // execution makes every definition legal again and also stops a replacement
2369
+ // from publishing closures that belong to the previous bundle (health(),
2370
+ // retry(), __test helpers, …). Nothing inside the plugin reads the global,
2371
+ // so swapping the identity is safe.
2372
+ // ---------------------------------------------------------------------
2373
+
2374
+ /** The API object of THIS bundle execution. */
2375
+ let publicApiGlobal = null;
2376
+
2377
+ function pluginPublicApi() {
2378
+ if (publicApiGlobal === null) {
2379
+ publicApiGlobal = {};
2380
+ window.__dshSplitWorkspace = publicApiGlobal;
2381
+ }
2382
+ return publicApiGlobal;
2383
+ }
2384
+
2385
+ /** Define one member of the public global; a diagnostics seam must never
2386
+ take the plugin down, so a refused definition is only a warning. */
2387
+ function definePublicMember(key, descriptor) {
2388
+ const target = pluginPublicApi();
2389
+ if (Object.prototype.hasOwnProperty.call(target, key)) return false;
2390
+ try {
2391
+ Object.defineProperty(target, key, Object.assign({
2392
+ configurable: false,
2393
+ enumerable: false,
2394
+ writable: false,
2395
+ }, descriptor));
2396
+ return true;
2397
+ } catch (error) {
2398
+ try {
2399
+ const message = error !== null && error !== undefined && error.message !== undefined ? error.message : error;
2400
+ console.warn(LOG_PREFIX + " diagnostics seam '" + key + "' kept from the previous bundle: " + String(message));
2401
+ } catch {}
2402
+ return false;
2403
+ }
2404
+ }
2405
+
2186
2406
  /** Host release from the boot graph the web frontend injects:
2187
2407
  window.__DSH_BOOT__ = { release: { version, commit }, … }. */
2188
2408
  function readHostRelease() {
@@ -2241,6 +2461,10 @@ window.__ModuleLoader__.load({
2241
2461
  minimized: readMinimized(),
2242
2462
  performance: readPerformanceMode(),
2243
2463
  updateReady: null,
2464
+ // One conversation in an in-app independent window. DSH Desktop has no
2465
+ // plugin-facing BrowserWindow API, so this replaces the old browser
2466
+ // window with a first-class surface inside the application.
2467
+ appWindow: null,
2244
2468
  };
2245
2469
  const runtimeListeners = new Set();
2246
2470
  function runtimeSnapshot() {
@@ -2266,6 +2490,9 @@ window.__ModuleLoader__.load({
2266
2490
  notifyRuntime();
2267
2491
  return runtimeState;
2268
2492
  }
2493
+ /** The same runtime state as a store object, for context-menu observes. */
2494
+ const runtimeStore = { getSnapshot: runtimeSnapshot, subscribe: runtimeSubscribe };
2495
+
2269
2496
  /** The plugin's own state store as a hook (safe before apply() runs). */
2270
2497
  function useRuntime() {
2271
2498
  return React.useSyncExternalStore(runtimeSubscribe, runtimeSnapshot, runtimeSnapshot);
@@ -2441,6 +2668,7 @@ window.__ModuleLoader__.load({
2441
2668
  panes: (() => { try { return treeStore.leafIds().length; } catch { return 0; } })(),
2442
2669
  floats: (() => { try { return floatStore.ids(); } catch { return []; } })(),
2443
2670
  floatLayerMounted: floatLayerMounted,
2671
+ appWindow: runtimeState.appWindow === null ? null : Object.assign({}, runtimeState.appWindow),
2444
2672
  blockedReason: (() => { try { return blockedReason(); } catch { return "unknown"; } })(),
2445
2673
  failures: runtimeState.failures,
2446
2674
  lastError: runtimeState.lastError,
@@ -3316,6 +3544,7 @@ window.__ModuleLoader__.load({
3316
3544
  detached first so the same conversation is never hosted twice. */
3317
3545
  function floatSession(sessionId) {
3318
3546
  if (!isValidSessionId(sessionId)) return false;
3547
+ closeAppWindowFor(sessionId);
3319
3548
  prepareExplicitSplit();
3320
3549
  if (floatStore.has(sessionId)) {
3321
3550
  floatStore.focus(sessionId);
@@ -3385,44 +3614,18 @@ window.__ModuleLoader__.load({
3385
3614
  } catch {}
3386
3615
  }
3387
3616
 
3388
- /** Ask the Host for the authenticated standalone URL and open it as a real
3389
- separate window. In Desktop the app's window-open handler forwards
3390
- http/https to the system browser (the only OS window a renderer plugin
3391
- can create here); in Web mode `window.open` opens a browser window.
3392
- A blank window is pre-opened in Web mode so the async Host round-trip
3393
- cannot lose the user-gesture popup permission. */
3617
+ /** Open one conversation in the in-app independent window.
3618
+ DSH Desktop exposes no BrowserWindow API to plugins and denies
3619
+ window.open, so a real OS window is impossible here. The independent
3620
+ window is a first-class surface inside the application (no browser
3621
+ dependency): close / minimize / maximize-restore / fullscreen, and the
3622
+ same native conversation component. */
3394
3623
  function openSystemWindow(sessionId) {
3395
3624
  if (!isValidSessionId(sessionId)) return Promise.resolve(false);
3396
- let preopened = null;
3397
- if (typeof window.dshDesktop === "undefined") {
3398
- try { preopened = window.open("", "_blank"); } catch { preopened = null; }
3399
- }
3400
- const fail = () => {
3401
- try { if (preopened !== null && preopened.closed !== true) preopened.close(); } catch {}
3402
- showPaneToast(t("systemWindowFailed"), true);
3403
- return false;
3404
- };
3405
- return fetch("/dsv/system-window", {
3406
- method: "POST",
3407
- headers: { "content-type": "application/json" },
3408
- body: JSON.stringify({ sessionId }),
3409
- }).then((response) => (response.ok ? response.json().catch(() => null) : null)).then((payload) => {
3410
- if (payload === null || payload === undefined || payload.ok !== true
3411
- || typeof payload.url !== "string" || payload.url === "") return fail();
3412
- try {
3413
- detachSessionForSystemWindow(sessionId);
3414
- if (preopened !== null && preopened.closed !== true) {
3415
- try { preopened.opener = null; } catch {}
3416
- preopened.location.href = payload.url;
3417
- } else {
3418
- window.open(payload.url, "_blank", "noopener,noreferrer");
3419
- }
3420
- showPaneToast(t("systemWindowOpened"), true);
3421
- return true;
3422
- } catch {
3423
- return fail();
3424
- }
3425
- }).catch(() => fail());
3625
+ detachSessionForSystemWindow(sessionId);
3626
+ const opened = openAppWindow(sessionId);
3627
+ if (opened === true) showPaneToast(t("systemWindowOpened"), true);
3628
+ return Promise.resolve(opened === true);
3426
3629
  }
3427
3630
 
3428
3631
  let floatLayerMounted = false;
@@ -5286,7 +5489,7 @@ window.__ModuleLoader__.load({
5286
5489
  elected, or an entry elected without a store face. Diagnostics only —
5287
5490
  nothing in the render path reads it. */
5288
5491
  const composerChainDebug = { last: null, slots: null };
5289
- window.__dshSplitWorkspace = Object.assign(window.__dshSplitWorkspace || {}, { composerChain: composerChainDebug });
5492
+ Object.assign(pluginPublicApi(), { composerChain: composerChainDebug });
5290
5493
 
5291
5494
  /** Probe both slot-ledger surfaces for the keys this plugin consumes.
5292
5495
  `entries()` is the raw registration view (chain keys consume every
@@ -9162,7 +9365,7 @@ window.__ModuleLoader__.load({
9162
9365
  return zone.side === "before" ? { top: 4, left: 4, right: 4, height: "50%" } : { bottom: 4, left: 4, right: 4, height: "50%" };
9163
9366
  }
9164
9367
 
9165
- function PaneFrame({ sessionId, session, summary, focused, chrome, onFocus, onClose, pickerFor, floating, standalone }) {
9368
+ function PaneFrame({ sessionId, session, summary, focused, chrome, onFocus, onClose, pickerFor, floating, standalone, appWindow, appWindowMaximized }) {
9166
9369
  const runtime = useRuntime();
9167
9370
  const performanceMode = runtime.performance === true;
9168
9371
  const maximized = runtime.maximized === sessionId;
@@ -9590,7 +9793,16 @@ window.__ModuleLoader__.load({
9590
9793
  }
9591
9794
  } catch {}
9592
9795
  };
9593
- const actionButtons = standalone === true
9796
+ const actionButtons = appWindow === true
9797
+ ? [
9798
+ actionButton("copy", t("copy"), "⧉", doCopy),
9799
+ actionButton("help", t("helpOpen"), "?", doHelp),
9800
+ actionButton("fullscreen", t("standaloneFullscreen"), "⛶", doFullscreen),
9801
+ actionButton("minimize", t("independentMinimize"), "—", minimizeAppWindow),
9802
+ actionButton("maximize", appWindowMaximized === true ? t("restore") : t("maximize"), appWindowMaximized === true ? "⤡" : "⤢", toggleMaximizeAppWindow),
9803
+ actionButton("close", t("independentClose"), h(CloseIcon, { size: 14 }), closeAppWindow),
9804
+ ]
9805
+ : standalone === true
9594
9806
  ? [
9595
9807
  actionButton("copy", t("copy"), "⧉", doCopy),
9596
9808
  actionButton("help", t("helpOpen"), "?", doHelp),
@@ -9780,7 +9992,14 @@ window.__ModuleLoader__.load({
9780
9992
  onPointerUp: floating === true ? endFloatGesture : undefined,
9781
9993
  onPointerCancel: floating === true ? endFloatGesture : undefined,
9782
9994
  title: floating === true ? t("floatHint") : title,
9783
- onDoubleClick: floating === true ? undefined : standalone === true
9995
+ onDoubleClick: floating === true ? undefined : appWindow === true
9996
+ ? (event) => {
9997
+ const target = event.target;
9998
+ if (target !== null && target !== undefined && typeof target.closest === "function"
9999
+ && target.closest("button,input,.dsv-pane-title-text") !== null) return;
10000
+ toggleMaximizeAppWindow();
10001
+ }
10002
+ : standalone === true
9784
10003
  ? (event) => {
9785
10004
  const target = event.target;
9786
10005
  if (target !== null && target !== undefined && typeof target.closest === "function"
@@ -9868,7 +10087,14 @@ window.__ModuleLoader__.load({
9868
10087
  className: "dsv-pane-menu",
9869
10088
  onPointerDown: (event) => event.stopPropagation(),
9870
10089
  },
9871
- ...(standalone === true ? [
10090
+ ...(appWindow === true ? [
10091
+ menuItem("copy", t("copy"), () => { setMenuOpen(false); doCopy(); }),
10092
+ menuItem("help", t("helpOpen"), () => { setMenuOpen(false); doHelp(); }),
10093
+ menuItem("fullscreen", t("standaloneFullscreen"), () => { setMenuOpen(false); doFullscreen(); }),
10094
+ menuItem("minimize", t("independentMinimize"), () => { setMenuOpen(false); minimizeAppWindow(); }),
10095
+ menuItem("maximize", appWindowMaximized === true ? t("restore") : t("maximize"), () => { setMenuOpen(false); toggleMaximizeAppWindow(); }),
10096
+ menuItem("close", t("independentClose"), () => { setMenuOpen(false); closeAppWindow(); }, true),
10097
+ ] : standalone === true ? [
9872
10098
  menuItem("copy", t("copy"), () => { setMenuOpen(false); doCopy(); }),
9873
10099
  menuItem("help", t("helpOpen"), () => { setMenuOpen(false); doHelp(); }),
9874
10100
  menuItem("fullscreen", t("standaloneFullscreen"), () => { setMenuOpen(false); doFullscreen(); }),
@@ -9916,6 +10142,8 @@ window.__ModuleLoader__.load({
9916
10142
  && a.chrome === b.chrome
9917
10143
  && a.floating === b.floating
9918
10144
  && a.standalone === b.standalone
10145
+ && a.appWindow === b.appWindow
10146
+ && a.appWindowMaximized === b.appWindowMaximized
9919
10147
  && summaryShallowEqual(a.summary, b.summary),
9920
10148
  );
9921
10149
 
@@ -9930,7 +10158,7 @@ window.__ModuleLoader__.load({
9930
10158
  return dir === "h" ? { width: basis, height: "100%" } : { height: basis, width: "100%" };
9931
10159
  }
9932
10160
 
9933
- function RenderLeaf({ id, chrome, generation, floating, standalone }) {
10161
+ function RenderLeaf({ id, chrome, generation, floating, standalone, appWindow, appWindowMaximized }) {
9934
10162
  const state = useTree();
9935
10163
  const sessions = useSessionsList();
9936
10164
  const liveSummary = sessions !== null && sessions !== undefined && sessions.byId !== undefined ? sessions.byId[id] : undefined;
@@ -9952,13 +10180,15 @@ window.__ModuleLoader__.load({
9952
10180
  chrome: chrome !== false,
9953
10181
  floating: floating === true,
9954
10182
  standalone: standalone === true,
10183
+ appWindow: appWindow === true,
10184
+ appWindowMaximized: appWindowMaximized === true,
9955
10185
  focused: floating !== true && standalone !== true && state.focus === id,
9956
10186
  onFocus: floating === true ? (sid) => { floatStore.focus(sid); } : (sid) => treeStore.setFocus(sid),
9957
10187
  // Teardown is NOT done here any more: treeStore.commit schedules the
9958
10188
  // departed leaf for disposal and ChatPane releases on unmount, so every
9959
10189
  // leaf-mutation path (✕, sidebar swap, closeFocused, movePane) is
9960
10190
  // covered by the same idempotent path.
9961
- onClose: floating === true ? () => closeFloatWindow(id) : (sid) => closePaneAnimated(sid),
10191
+ onClose: floating === true ? () => closeFloatWindow(id) : appWindow === true ? () => closeAppWindow() : (sid) => closePaneAnimated(sid),
9962
10192
  pickerFor: floating === true || standalone === true ? () => {} : (...args) => togglePicker(...args),
9963
10193
  }));
9964
10194
  }
@@ -10449,7 +10679,7 @@ window.__ModuleLoader__.load({
10449
10679
  session-hotkeys side hides the whole workspace shell (persisted, with a
10450
10680
  restore affordance) and the tree comes back intact on restore.
10451
10681
  Returns null when there is no pane to close. */
10452
- window.__dshSplitWorkspace = Object.assign(window.__dshSplitWorkspace || {}, {
10682
+ Object.assign(pluginPublicApi(), {
10453
10683
  split(sessionId) {
10454
10684
  return safeCall("split()", () => {
10455
10685
  if (typeof sessionId !== "string" || sessionId === "") return null;
@@ -10550,10 +10780,30 @@ window.__ModuleLoader__.load({
10550
10780
  floats() {
10551
10781
  return safeCall("floats()", () => floatStore.ids(), []);
10552
10782
  },
10553
- /** Open one conversation in a separate system window (Host-backed URL). */
10783
+ /** Open one conversation in the app-internal independent window. */
10554
10784
  openSystemWindow(sessionId) {
10555
10785
  return safeCall("openSystemWindow()", () => openSystemWindow(sessionId), false);
10556
10786
  },
10787
+ /** Alias for openSystemWindow: independent of any browser window. */
10788
+ openIndependentWindow(sessionId) {
10789
+ return safeCall("openIndependentWindow()", () => openSystemWindow(sessionId), false);
10790
+ },
10791
+ /** Open one conversation in a real OS window (macOS native window). */
10792
+ openNativeWindow(sessionId) {
10793
+ return safeCall("openNativeWindow()", () => requestSystemWindow(sessionId, "open"), false);
10794
+ },
10795
+ /** Close the native OS window currently showing one conversation. */
10796
+ closeNativeWindow(sessionId) {
10797
+ return safeCall("closeNativeWindow()", () => requestSystemWindow(sessionId, "close"), false);
10798
+ },
10799
+ /** Session ids whose native OS window is currently open. */
10800
+ nativeWindows() {
10801
+ return safeCall("nativeWindows()", () => nativeWindowStore.getSnapshot().slice(), []);
10802
+ },
10803
+ /** Current independent-window state ({ id, minimized, maximized } or null). */
10804
+ appWindow() {
10805
+ return safeCall("appWindow()", () => (runtimeState.appWindow === null ? null : Object.assign({}, runtimeState.appWindow)), null);
10806
+ },
10557
10807
  /** Toggle performance mode (persisted; reduces animations/observers). */
10558
10808
  setPerformanceMode(flag) {
10559
10809
  return safeCall("setPerformanceMode()", () => setPerformanceMode(flag !== false), false);
@@ -10614,7 +10864,7 @@ window.__ModuleLoader__.load({
10614
10864
  });
10615
10865
  // Live service seam (diagnostics only): lets the maintainer inspect the
10616
10866
  // right-sidebar controller and the shell layout while split view runs.
10617
- Object.defineProperty(window.__dshSplitWorkspace, "__svc", {
10867
+ definePublicMember("__svc", {
10618
10868
  value: Object.freeze({
10619
10869
  ctxAlive: () => pluginCtx !== null && pluginCtx !== undefined,
10620
10870
  names() {
@@ -10630,8 +10880,11 @@ window.__ModuleLoader__.load({
10630
10880
  configurable: true,
10631
10881
  });
10632
10882
  // Read-only test seam: production calls the very same functions, so the
10633
- // logic under test is the logic that runs on the user's host.
10634
- Object.defineProperty(window.__dshSplitWorkspace, "__test", {
10883
+ // logic under test is the logic that runs on the user's host. It is
10884
+ // deliberately non-configurable; the fresh per-execution API object (see
10885
+ // pluginPublicApi) is what keeps a live bundle replacement from throwing
10886
+ // `Cannot redefine property`.
10887
+ definePublicMember("__test", {
10635
10888
  value: Object.freeze({
10636
10889
  frameColumns,
10637
10890
  selectFrameColumns,
@@ -10659,8 +10912,6 @@ window.__ModuleLoader__.load({
10659
10912
  COLUMN_MIN_HEIGHT,
10660
10913
  TESTED_RELEASES: TESTED_RELEASES.slice(),
10661
10914
  }),
10662
- enumerable: false,
10663
- writable: false,
10664
10915
  configurable: false,
10665
10916
  });
10666
10917
 
@@ -11585,11 +11836,45 @@ window.__ModuleLoader__.load({
11585
11836
  );
11586
11837
  }
11587
11838
 
11839
+ /** Screenshots shown in the help card. The Host serves them from
11840
+ docs/screenshots under /dsv/help/, so the same relative URL works in
11841
+ the Desktop shell and the Web client. */
11842
+ const HELP_SHOTS = [
11843
+ { id: "session-menu", src: "/dsv/help/session-menu.png", label: "helpShotMenu" },
11844
+ { id: "footer-menu", src: "/dsv/help/footer-menu.png", label: "helpShotFooter" },
11845
+ { id: "settings", src: "/dsv/help/settings.png", label: "helpShotSettings" },
11846
+ ];
11847
+
11848
+ /** Full-size screenshot opened from a help thumbnail. */
11849
+ function HelpShotLightbox({ shot, onClose }) {
11850
+ React.useEffect(() => {
11851
+ const onKeyDown = (event) => {
11852
+ if (event.key !== "Escape") return;
11853
+ event.preventDefault();
11854
+ event.stopPropagation();
11855
+ onClose();
11856
+ };
11857
+ document.addEventListener("keydown", onKeyDown, true);
11858
+ return () => document.removeEventListener("keydown", onKeyDown, true);
11859
+ }, [onClose]);
11860
+ return h("div", {
11861
+ className: "dsv-help-lightbox",
11862
+ role: "dialog",
11863
+ "aria-modal": "true",
11864
+ "aria-label": t(shot.label),
11865
+ "data-plugin": PLUGIN_ID,
11866
+ onClick: onClose,
11867
+ },
11868
+ h("img", { src: shot.src, alt: t(shot.label), draggable: false, onClick: (event) => event.stopPropagation() }),
11869
+ );
11870
+ }
11871
+
11588
11872
  /** The one help card: opened by the pane header "?" and by the blocked
11589
11873
  chip. Lives inside the plugin overlay when active (fixed variant for the
11590
11874
  inactive chip path). */
11591
11875
  function HelpCard({ fixed }) {
11592
11876
  const help = helpText();
11877
+ const [shot, setShot] = React.useState(null);
11593
11878
  return h("div", {
11594
11879
  className: "dsv-help-card" + (fixed === true ? " dsv-help-card-fixed" : ""),
11595
11880
  role: "dialog",
@@ -11612,6 +11897,18 @@ window.__ModuleLoader__.load({
11612
11897
  h("span", { className: "dsv-help-body" }, item.action),
11613
11898
  )),
11614
11899
  h("div", { className: "dsv-help-body", style: { marginTop: "6px" } }, t("helpGestures")),
11900
+ h("div", { className: "dsv-help-body", style: { marginTop: "6px" } }, t("helpIndependent")),
11901
+ h("div", { className: "dsv-help-section-title" }, t("helpShotsTitle")),
11902
+ h("div", { className: "dsv-help-shots" }, HELP_SHOTS.map((item) => h("figure", {
11903
+ key: item.id,
11904
+ className: "dsv-help-shot",
11905
+ title: t("helpShotZoom"),
11906
+ onClick: () => setShot(item),
11907
+ },
11908
+ h("img", { src: item.src, alt: t(item.label), loading: "lazy", draggable: false }),
11909
+ h("figcaption", null, t(item.label)),
11910
+ ))),
11911
+ shot !== null ? h(HelpShotLightbox, { shot, onClose: () => setShot(null) }) : null,
11615
11912
  h("div", { className: "dsv-help-body", style: { marginTop: "6px" } }, t("helpDisable")),
11616
11913
  h("div", { className: "dsv-help-body", style: { marginTop: "2px" } }, t("helpDiagnostics")),
11617
11914
  h("div", { className: "dsv-help-body", style: { marginTop: "2px" } }, t("helpRestart")),
@@ -11856,24 +12153,19 @@ window.__ModuleLoader__.load({
11856
12153
 
11857
12154
  function SplitWorkspaceSeat(props) {
11858
12155
  const runtime = useRuntime();
11859
- // A standalone system window renders ONLY its conversation: no split
11860
- // workspace, no floats, no launcher. WorkspaceApp still mounts (hidden,
11861
- // inactive) because it publishes the root standard faces the pane host
11862
- // needs.
11863
- const standaloneId = standaloneSessionId();
11864
- if (standaloneId !== null) {
11865
- try { document.documentElement.setAttribute("data-dsv-standalone", "1"); } catch {}
11866
- const standaloneProps = Object.assign({}, props, { dsvStandalone: true });
11867
- return h(React.Fragment, null,
11868
- h(WorkspaceBoundary, { key: "workspace-" + runtime.epoch }, h(WorkspaceApp, standaloneProps)),
11869
- h(WorkspaceBoundary, { key: "standalone-" + runtime.epoch }, h(StandaloneSessionWindow, { sessionId: standaloneId })),
11870
- );
11871
- }
12156
+ const appWindowState = runtime.appWindow;
12157
+ const appWindowOpen = appWindowState !== null && appWindowState !== undefined && appWindowState.minimized !== true;
11872
12158
  return h(React.Fragment, null,
11873
- h(WorkspaceBoundary, { key: "workspace-" + runtime.epoch }, h(WorkspaceApp, props)),
12159
+ h(WorkspaceBoundary, { key: "workspace-" + runtime.epoch },
12160
+ h(WorkspaceApp, Object.assign({}, props, { dsvAppWindowOpen: appWindowOpen }))),
11874
12161
  h(PluginChrome, null),
11875
12162
  h(WorkspaceBoundary, { key: "floats-" + runtime.epoch }, h(FloatLayer, null)),
11876
12163
  h(SplitLauncherLayer, null),
12164
+ h(AppWindowChip, null),
12165
+ h(AppWindowLayer, null),
12166
+ // The settings page and the help action can open the card without a
12167
+ // live split; the pane/overlay path only renders it while active.
12168
+ runtime.helpOpen === true && runtime.active !== true ? h(HelpCard, { fixed: true }) : null,
11877
12169
  h(UpdateNotice, null),
11878
12170
  );
11879
12171
  }
@@ -11907,10 +12199,10 @@ window.__ModuleLoader__.load({
11907
12199
  // The activation gate: >=2 panes AND the kill switch/safe mode allow it.
11908
12200
  // Everything below keys off this — observers, DOM scraping, the overlay.
11909
12201
  const minimized = runtime.minimized === true;
11910
- // A standalone system window never activates the split overlay: its whole
11911
- // page is owned by StandaloneSessionWindow.
11912
- const standaloneWindow = props.dsvStandalone === true;
11913
- const active = standaloneWindow !== true && leaves.length >= 2
12202
+ // An independent window owns the screen while it is open; keep the
12203
+ // split tree (and its observers) quiet underneath.
12204
+ const appWindowOpen = props.dsvAppWindowOpen === true;
12205
+ const active = appWindowOpen !== true && leaves.length >= 2
11914
12206
  && runtime.enabled === true && runtime.safeMode !== true;
11915
12207
  const [picker, setPicker] = React.useState(pickerRequest);
11916
12208
  const [bounds, setBounds] = React.useState({ left: 0, right: 0, top: 0, bottom: 0, ok: false });
@@ -12864,6 +13156,7 @@ window.__ModuleLoader__.load({
12864
13156
  for (const id of Array.isArray(ids) ? ids : []) {
12865
13157
  if (!isValidSessionId(id) || ordered.indexOf(id) !== -1) continue;
12866
13158
  if (floatStore.has(id)) floatStore.remove(id);
13159
+ closeAppWindowFor(id);
12867
13160
  ordered.push(id);
12868
13161
  }
12869
13162
  if (ordered.length < 2) {
@@ -12884,6 +13177,7 @@ window.__ModuleLoader__.load({
12884
13177
  function addSessionToSplit(sessionId) {
12885
13178
  if (!isValidSessionId(sessionId)) return false;
12886
13179
  if (floatStore.has(sessionId)) floatStore.remove(sessionId);
13180
+ closeAppWindowFor(sessionId);
12887
13181
  const leaves = treeStore.leafIds();
12888
13182
  if (leaves.indexOf(sessionId) !== -1) {
12889
13183
  try { treeStore.setFocus(sessionId); } catch {}
@@ -13031,6 +13325,7 @@ window.__ModuleLoader__.load({
13031
13325
  chipDismissed: false,
13032
13326
  tipVisible: false,
13033
13327
  helpOpen: false,
13328
+ appWindow: null,
13034
13329
  });
13035
13330
  const resetEpoch = runtimeState.epoch;
13036
13331
  try {
@@ -13069,6 +13364,64 @@ window.__ModuleLoader__.load({
13069
13364
  }
13070
13365
  }
13071
13366
 
13367
+ /** Rows for one conversation: one "分屏插件" first-level group whose
13368
+ second level holds the split-membership toggle and the three window
13369
+ surfaces. Every entry is a single Enter/Exit toggle that mirrors its
13370
+ live state: split tree / pending pick, float store, app-window runtime
13371
+ store, and the Host-tracked native window list. */
13372
+ function sessionMenuActions(id) {
13373
+ const inSplit = treeStore.leafIds().indexOf(id) !== -1;
13374
+ const pending = pendingSplitStore.has(id);
13375
+ const splitMember = inSplit || pending;
13376
+ const floating = floatStore.has(id);
13377
+ const appWindow = appWindowSnapshot();
13378
+ const independent = appWindow !== null && appWindow.id === id;
13379
+ const nativeWindow = nativeWindowStore.has(id);
13380
+ return [
13381
+ {
13382
+ id: "split-plugin",
13383
+ label: t("menuGroup"),
13384
+ separatorBefore: true,
13385
+ children: [
13386
+ {
13387
+ // 加入分屏 / 退出分屏 is now one toggle: a member (split pane or
13388
+ // pending pick) exits, everything else joins.
13389
+ id: "split",
13390
+ label: t(splitMember ? "exitSplit" : "menuAddToSplit"),
13391
+ run: () => {
13392
+ if (splitMember) removeSessionFromSplit(id);
13393
+ else if (floatStore.has(id)) dockFloatToSplit(id);
13394
+ else addSessionToSplit(id);
13395
+ },
13396
+ },
13397
+ {
13398
+ id: "float",
13399
+ label: t(floating ? "menuFloatClose" : "menuFloatOpen"),
13400
+ run: () => {
13401
+ if (floatStore.has(id)) closeFloatWindow(id);
13402
+ else floatSession(id);
13403
+ },
13404
+ },
13405
+ {
13406
+ id: "independent",
13407
+ label: t(independent ? "menuIndependentClose" : "menuIndependentOpen"),
13408
+ failureLabel: t("systemWindowFailed"),
13409
+ run: () => {
13410
+ if (independent) closeAppWindowFor(id);
13411
+ else openAppWindow(id);
13412
+ },
13413
+ },
13414
+ {
13415
+ id: "native",
13416
+ label: t(nativeWindow ? "menuNativeClose" : "menuNativeOpen"),
13417
+ failureLabel: t("systemWindowFailed"),
13418
+ run: () => requestSystemWindow(id, nativeWindow ? "close" : "open"),
13419
+ },
13420
+ ],
13421
+ },
13422
+ ];
13423
+ }
13424
+
13072
13425
  /** Contribute 加入分屏 / 退出分屏 to the stock session context menu. The
13073
13426
  service is looked up lazily: a host without ui-context-menu simply does
13074
13427
  not get the rows (nothing else changes). */
@@ -13088,43 +13441,13 @@ window.__ModuleLoader__.load({
13088
13441
  id: "split-workspace.session",
13089
13442
  target: "session",
13090
13443
  order: 350,
13091
- observe: () => [treeStore, pendingSplitStore, floatStore],
13444
+ observe: () => [treeStore, pendingSplitStore, floatStore, runtimeStore, nativeWindowStore],
13092
13445
  resolve: (target) => {
13093
13446
  const id = target !== null && target !== undefined ? target.sessionId : undefined;
13094
13447
  if (!isValidSessionId(id)) return [];
13095
- const inSplit = treeStore.leafIds().indexOf(id) !== -1;
13096
- const pending = pendingSplitStore.has(id);
13097
- const floating = floatStore.has(id);
13098
- return [
13099
- {
13100
- id: "add",
13101
- label: t("menuAddToSplit"),
13102
- disabled: inSplit || pending,
13103
- run: () => { if (floatStore.has(id)) dockFloatToSplit(id); else addSessionToSplit(id); },
13104
- },
13105
- {
13106
- id: "remove",
13107
- label: t("exitSplit"),
13108
- disabled: !inSplit && !pending,
13109
- run: () => { removeSessionFromSplit(id); },
13110
- },
13111
- {
13112
- id: "float",
13113
- label: t(floating ? "menuFloatClose" : "menuFloatOpen"),
13114
- separatorBefore: true,
13115
- run: () => {
13116
- if (floatStore.has(id)) closeFloatWindow(id);
13117
- else floatSession(id);
13118
- },
13119
- },
13120
- {
13121
- id: "system",
13122
- label: t("menuSystemWindow"),
13123
- separatorBefore: true,
13124
- failureLabel: t("systemWindowFailed"),
13125
- run: () => openSystemWindow(id),
13126
- },
13127
- ];
13448
+ // Refresh the Host-tracked native-window list before building
13449
+ // the rows, so a window closed outside DSH already shows Enter.
13450
+ return nativeWindowStore.refresh().then(() => sessionMenuActions(id)).catch(() => []);
13128
13451
  },
13129
13452
  });
13130
13453
  } catch (error) {
@@ -13402,10 +13725,83 @@ window.__ModuleLoader__.load({
13402
13725
  desktopShell()
13403
13726
  ? row("restart", "⏻", t("restartApp"), () => { closeLauncher(); openRestartDialog(); })
13404
13727
  : null,
13728
+ row("help", "?", t("helpOpen"), () => { closeLauncher(); openHelp(); }),
13405
13729
  row("reset", "↺", t("menuResetSplit"), () => { closeLauncher(); resetSplitEnvironment(); }, { danger: true }),
13406
13730
  );
13407
13731
  }
13408
13732
 
13733
+ /** Settings → Split workspace page: the same controls as the footer menu,
13734
+ reachable from the system Settings panel as well. */
13735
+ function SettingsSection(props) {
13736
+ const runtime = useRuntime();
13737
+ const tree = useTree();
13738
+ const pending = usePendingSplit();
13739
+ const floats = useFloats();
13740
+ const leaves = tree.root === null ? [] : leafOf(tree.root, []);
13741
+ const active = leaves.length >= 2;
13742
+ const appWindow = runtime.appWindow;
13743
+ const closeThen = (fn) => {
13744
+ try { if (props !== null && props !== undefined && typeof props.close === "function") props.close(); } catch {}
13745
+ try { fn(); } catch {}
13746
+ };
13747
+ const value = (text) => h("span", { className: "dsv-settings-value" }, text);
13748
+ const row = (key, label, content) => h("div", { key, className: "dsv-settings-row" },
13749
+ h("span", { className: "dsv-settings-row-label" }, label),
13750
+ content,
13751
+ );
13752
+ const button = (key, label, onClick, options) => h("button", {
13753
+ key,
13754
+ type: "button",
13755
+ className: "dsv-settings-btn"
13756
+ + (options !== undefined && options.accent === true ? " accent" : "")
13757
+ + (options !== undefined && options.danger === true ? " danger" : ""),
13758
+ disabled: options !== undefined && options.disabled === true,
13759
+ onClick: options !== undefined && options.disabled === true ? undefined : onClick,
13760
+ }, label);
13761
+ return h("div", { className: "dsv-settings", "data-plugin": PLUGIN_ID },
13762
+ h("div", { className: "dsv-settings-desc" }, t("settingsDesc")),
13763
+ h("section", { className: "dsv-settings-group" },
13764
+ h("h3", { className: "dsv-settings-group-title" }, t("settingsStatus")),
13765
+ row("version", t("settingsVersion"), value("v" + PLUGIN_VERSION)),
13766
+ row("panes", t("settingsPanes"), value(String(leaves.length))),
13767
+ row("pending", t("settingsPending"), value(String(pending.length))),
13768
+ row("floats", t("settingsFloats"), value(String(floats.windows.length))),
13769
+ appWindow !== null && appWindow !== undefined
13770
+ ? row("appwindow", t("menuSystemWindow"), value(appWindow.id))
13771
+ : null,
13772
+ ),
13773
+ h("section", { className: "dsv-settings-group" },
13774
+ h("h3", { className: "dsv-settings-group-title" }, t("settingsPerformance")),
13775
+ h("div", { className: "dsv-settings-row" },
13776
+ h("div", { className: "dsv-settings-label" },
13777
+ h("span", null, t("settingsPerformance")),
13778
+ h("span", { className: "dsv-settings-value" }, t("settingsPerformanceDesc")),
13779
+ ),
13780
+ button("performance", runtime.performance === true ? t("performanceOn") : t("performanceOff"),
13781
+ () => setPerformanceMode(runtime.performance !== true),
13782
+ { accent: runtime.performance === true }),
13783
+ ),
13784
+ ),
13785
+ h("section", { className: "dsv-settings-group" },
13786
+ h("h3", { className: "dsv-settings-group-title" }, t("settingsActions")),
13787
+ h("div", { className: "dsv-settings-actions" },
13788
+ button("add", t("menuAddSplit"), () => closeThen(() => openAddSplitDialog("footer")), { accent: true }),
13789
+ button("exit", t("exitSplit"), () => { try { exitWorkspace(); } catch {} }, { disabled: !active }),
13790
+ button("minimize", t("menuMinimizeSplit"), () => { try { minimizeWorkspace(); } catch {} }, { disabled: !active || runtime.minimized === true }),
13791
+ button("refresh", t("refreshInterface"), () => { try { location.reload(); } catch {} }),
13792
+ desktopShell()
13793
+ ? button("restart", t("restartApp"), () => closeThen(() => openRestartDialog()))
13794
+ : null,
13795
+ appWindow !== null && appWindow !== undefined
13796
+ ? button("closeappwindow", t("independentClose"), () => closeThen(() => closeAppWindow()))
13797
+ : null,
13798
+ button("help", t("helpOpen"), () => closeThen(() => setRuntime({ helpOpen: true }))),
13799
+ button("reset", t("menuResetSplit"), () => { try { resetSplitEnvironment(); } catch {} }, { danger: true }),
13800
+ ),
13801
+ ),
13802
+ );
13803
+ }
13804
+
13409
13805
  /** Fallback entry point when the stock sidebar footer does not render this
13410
13806
  plugin's action (collapsed/absent sidebar, a layout that replaces the
13411
13807
  footer, or an older host whose footer slot is empty). The launcher menu
@@ -13511,6 +13907,8 @@ window.__ModuleLoader__.load({
13511
13907
  const floats = useFloats();
13512
13908
  const windows = floats.windows;
13513
13909
  const count = windows.length;
13910
+ const appWindow = runtime.appWindow;
13911
+ const appWindowOpen = appWindow !== null && appWindow !== undefined && appWindow.minimized !== true;
13514
13912
  React.useEffect(() => {
13515
13913
  if (runtime.enabled !== true || count === 0) return undefined;
13516
13914
  floatLayerMounted = true;
@@ -13542,7 +13940,7 @@ window.__ModuleLoader__.load({
13542
13940
  }
13543
13941
  };
13544
13942
  }, [count, runtime.performance]);
13545
- if (runtime.enabled !== true || count === 0) return null;
13943
+ if (runtime.enabled !== true || count === 0 || appWindowOpen) return null;
13546
13944
  // Stacking is a z-index swap, never a DOM reorder: moving a live editor
13547
13945
  // subtree (keyed React children) would blur the composer.
13548
13946
  const ranks = new Map();
@@ -13565,7 +13963,72 @@ window.__ModuleLoader__.load({
13565
13963
 
13566
13964
  /** Whole-page view used inside a standalone system window: one native
13567
13965
  conversation, native window controls, no split / floats / launcher. */
13568
- function StandaloneSessionWindow({ sessionId }) {
13966
+ // ---------------------------------------------------------------------
13967
+ // independent window (0.10.0)
13968
+ //
13969
+ // DSH Desktop exposes no plugin-facing BrowserWindow API: the main window
13970
+ // denies window.open, and a Host plugin runs in a Node child process. The
13971
+ // old "system window" therefore had to open the default browser. This
13972
+ // surface replaces it with a first-class window inside the application:
13973
+ // one native conversation, close / minimize / maximize-restore /
13974
+ // fullscreen controls, no browser dependency. It covers the app while
13975
+ // open and collapses to a restore chip when minimized.
13976
+ // ---------------------------------------------------------------------
13977
+
13978
+ function appWindowSnapshot() {
13979
+ const state = runtimeState.appWindow;
13980
+ return state === null || state === undefined ? null : state;
13981
+ }
13982
+
13983
+ /** Replace the browser window with the in-app independent window. */
13984
+ function openAppWindow(sessionId) {
13985
+ if (!isValidSessionId(sessionId)) return false;
13986
+ try { closeLauncher(); } catch {}
13987
+ try { if (floatStore.has(sessionId)) floatStore.remove(sessionId); } catch {}
13988
+ pendingSplitStore.remove(sessionId);
13989
+ setRuntime({ appWindow: { id: sessionId, minimized: false, maximized: false } });
13990
+ return true;
13991
+ }
13992
+
13993
+ /** Close the independent window for one session (a different window stays). */
13994
+ function closeAppWindowFor(sessionId) {
13995
+ const state = appWindowSnapshot();
13996
+ if (state === null || state.id !== sessionId) return false;
13997
+ return closeAppWindow();
13998
+ }
13999
+
14000
+ /** Close the independent window and return to the main conversation view. */
14001
+ function closeAppWindow() {
14002
+ const state = appWindowSnapshot();
14003
+ if (state === null) return false;
14004
+ setRuntime({ appWindow: null });
14005
+ try { openSessionInMainView(state.id); } catch {}
14006
+ return true;
14007
+ }
14008
+
14009
+ function minimizeAppWindow() {
14010
+ const state = appWindowSnapshot();
14011
+ if (state === null || state.minimized === true) return false;
14012
+ setRuntime({ appWindow: Object.assign({}, state, { minimized: true }) });
14013
+ return true;
14014
+ }
14015
+
14016
+ function restoreAppWindow() {
14017
+ const state = appWindowSnapshot();
14018
+ if (state === null || state.minimized !== true) return false;
14019
+ setRuntime({ appWindow: Object.assign({}, state, { minimized: false }) });
14020
+ return true;
14021
+ }
14022
+
14023
+ function toggleMaximizeAppWindow() {
14024
+ const state = appWindowSnapshot();
14025
+ if (state === null) return false;
14026
+ setRuntime({ appWindow: Object.assign({}, state, { maximized: state.maximized !== true, minimized: false }) });
14027
+ return true;
14028
+ }
14029
+
14030
+ /** One native conversation filling the independent window. */
14031
+ function IndependentSessionWindow({ sessionId, embedded }) {
13569
14032
  const runtime = useRuntime();
13570
14033
  const sessions = useSessionsList();
13571
14034
  const summary = sessions !== null && sessions !== undefined && sessions.byId !== undefined
@@ -13575,11 +14038,13 @@ window.__ModuleLoader__.load({
13575
14038
  ? (summary.displayTitle || summary.title || sessionId)
13576
14039
  : sessionId;
13577
14040
  React.useEffect(() => {
14041
+ const previous = document.title;
13578
14042
  try { document.title = title + " — DeepSeek Harness"; } catch {}
14043
+ return () => { try { document.title = previous; } catch {} };
13579
14044
  }, [title]);
13580
14045
  // The DOM session-list source normally observes only while a split is
13581
- // live. This page is a one-conversation workspace, so keep it warm for
13582
- // the title and the re-hosted header.
14046
+ // live. This surface is a one-conversation workspace, so keep it warm
14047
+ // for the title and the re-hosted header.
13583
14048
  React.useEffect(() => {
13584
14049
  const source = sessionsListSource;
13585
14050
  if (source === undefined || source === null || typeof source.setActive !== "function") return undefined;
@@ -13589,14 +14054,293 @@ window.__ModuleLoader__.load({
13589
14054
  try { source.setActive(false); } catch {}
13590
14055
  };
13591
14056
  }, []);
14057
+ const state = appWindowSnapshot();
13592
14058
  return h("div", {
13593
- className: "dsv-standalone",
14059
+ className: "dsv-standalone" + (embedded === true ? " dsv-standalone-embedded" : ""),
13594
14060
  "data-dsv-standalone-window": sessionId,
13595
14061
  },
13596
- h(RenderLeaf, { id: sessionId, chrome: true, generation: runtime.generation, standalone: true }),
14062
+ h(RenderLeaf, {
14063
+ id: sessionId,
14064
+ chrome: true,
14065
+ generation: runtime.generation,
14066
+ standalone: true,
14067
+ appWindow: embedded === true,
14068
+ appWindowMaximized: state !== null && state.maximized === true,
14069
+ }),
14070
+ );
14071
+ }
14072
+
14073
+ /** Window layer, rendered from the always-mounted shell overlay seat. */
14074
+ function AppWindowLayer() {
14075
+ const runtime = useRuntime();
14076
+ const state = runtime.appWindow;
14077
+ if (runtime.enabled !== true) return null;
14078
+ if (state === null || state === undefined || state.minimized === true) return null;
14079
+ return h("div", {
14080
+ className: "dsv-app-window-layer",
14081
+ "data-plugin": PLUGIN_ID,
14082
+ },
14083
+ h("div", {
14084
+ className: "dsv-app-window" + (state.maximized === true ? " maximized" : ""),
14085
+ "data-dsv-app-window": state.id,
14086
+ },
14087
+ h(IndependentSessionWindow, { sessionId: state.id, embedded: true }),
14088
+ ),
14089
+ );
14090
+ }
14091
+
14092
+ /** Restore chip shown while the independent window is minimized. */
14093
+ function AppWindowChip() {
14094
+ const runtime = useRuntime();
14095
+ const sessions = useSessionsList();
14096
+ const state = runtime.appWindow;
14097
+ if (state === null || state === undefined || state.minimized !== true) return null;
14098
+ const summary = sessions !== null && sessions !== undefined && sessions.byId !== undefined
14099
+ ? sessions.byId[state.id]
14100
+ : undefined;
14101
+ const title = summary !== null && summary !== undefined
14102
+ ? (summary.displayTitle || summary.title || state.id)
14103
+ : state.id;
14104
+ return h("div", {
14105
+ className: "dsv-chip dsv-app-window-chip",
14106
+ "data-plugin": PLUGIN_ID,
14107
+ role: "status",
14108
+ },
14109
+ h("span", { className: "dsv-chip-text", title }, title),
14110
+ h("button", { type: "button", className: "dsv-chip-btn accent", onClick: restoreAppWindow }, t("independentRestore")),
14111
+ h("button", {
14112
+ type: "button", className: "dsv-chip-btn icon",
14113
+ title: t("independentClose"), "aria-label": t("independentClose"),
14114
+ onClick: closeAppWindow,
14115
+ }, "×"),
13597
14116
  );
13598
14117
  }
13599
14118
 
14119
+ // ---------------------------------------------------------------------
14120
+ // native system window (0.11.0)
14121
+ //
14122
+ // DSH Desktop has no plugin-facing BrowserWindow API, so the Host opens the
14123
+ // closest native equivalent: a real OS window (macOS AppKit NSWindow with a
14124
+ // WKWebView, driven by osascript) that loads the Host's authenticated web
14125
+ // client. The URL carries a hash marker, and this client boot turns that
14126
+ // page into a one-conversation window: no left sidebar, the requested
14127
+ // conversation active, and every other column (the right sidebar included)
14128
+ // left to the stock shell.
14129
+ // ---------------------------------------------------------------------
14130
+
14131
+ const SYSTEM_WINDOW_HASH = "#dsv-system-window=";
14132
+
14133
+ /** The session id carried by the native window URL hash, if any. */
14134
+ function systemWindowSessionId() {
14135
+ try {
14136
+ const hash = String(window.location.hash || "");
14137
+ if (!hash.startsWith(SYSTEM_WINDOW_HASH)) return null;
14138
+ const value = decodeURIComponent(hash.slice(SYSTEM_WINDOW_HASH.length).split("&")[0] || "");
14139
+ return isValidSessionId(value) ? value : null;
14140
+ } catch {
14141
+ return null;
14142
+ }
14143
+ }
14144
+
14145
+ /** Zero the sidebar grid track while keeping the solved centre and
14146
+ right-sidebar tracks. AppFrame writes the whole track list as an inline
14147
+ React style, so only the first track is rewritten. */
14148
+ function zeroSystemWindowSidebarTrack() {
14149
+ try {
14150
+ const root = document.querySelector('[data-slot="root"]');
14151
+ if (root === null || root === undefined) return false;
14152
+ let frame = null;
14153
+ for (const element of root.querySelectorAll("div[style]")) {
14154
+ if (element.style !== undefined && element.style.gridTemplateColumns !== "") {
14155
+ frame = element;
14156
+ break;
14157
+ }
14158
+ }
14159
+ if (frame === null) return false;
14160
+ const value = String(frame.style.gridTemplateColumns || "");
14161
+ if (value === "" || value.startsWith("0px ")) return true;
14162
+ frame.style.gridTemplateColumns = "0px " + value.replace(/^\s*\S+\s+/, "");
14163
+ return true;
14164
+ } catch {
14165
+ return false;
14166
+ }
14167
+ }
14168
+
14169
+ /** Re-zero the track whenever React re-solves the columns (right sidebar
14170
+ toggles, window resize, drawer mode). */
14171
+ function watchSystemWindowLayout() {
14172
+ let observer = null;
14173
+ let timer = 0;
14174
+ const attach = () => {
14175
+ const root = document.querySelector('[data-slot="root"]');
14176
+ if (root === null || root === undefined) return false;
14177
+ try {
14178
+ observer = new MutationObserver(() => { zeroSystemWindowSidebarTrack(); });
14179
+ observer.observe(root, { attributes: true, subtree: true, attributeFilter: ["style"] });
14180
+ } catch {}
14181
+ zeroSystemWindowSidebarTrack();
14182
+ return true;
14183
+ };
14184
+ if (!attach()) {
14185
+ let tries = 0;
14186
+ timer = window.setInterval(() => {
14187
+ tries += 1;
14188
+ if (attach() || tries >= 40) {
14189
+ window.clearInterval(timer);
14190
+ timer = 0;
14191
+ }
14192
+ }, 250);
14193
+ }
14194
+ return () => {
14195
+ if (observer !== null) {
14196
+ try { observer.disconnect(); } catch {}
14197
+ }
14198
+ if (timer !== 0) {
14199
+ try { window.clearInterval(timer); } catch {}
14200
+ }
14201
+ };
14202
+ }
14203
+
14204
+ /** Activate the requested conversation once the stock shell is ready. The
14205
+ web client boots a fresh session first, so retry until the main view
14206
+ actually shows the requested id. */
14207
+ function activateSystemWindowSession(sessionId) {
14208
+ let tries = 0;
14209
+ const attempt = () => {
14210
+ tries += 1;
14211
+ if (currentSessionId() === sessionId) return;
14212
+ openSessionInMainView(sessionId);
14213
+ if (tries >= 12) return;
14214
+ window.setTimeout(attempt, 350);
14215
+ };
14216
+ window.setTimeout(attempt, 200);
14217
+ }
14218
+
14219
+ /** Boot hook: returns a disposer only in a native system window. */
14220
+ function bootSystemWindow() {
14221
+ const sessionId = systemWindowSessionId();
14222
+ if (sessionId === null) return null;
14223
+ try { document.documentElement.dataset.dsvSystemWindow = "1"; } catch {}
14224
+ const disposeLayout = watchSystemWindowLayout();
14225
+ activateSystemWindowSession(sessionId);
14226
+ return disposeLayout;
14227
+ }
14228
+
14229
+ // The Host owns the system windows. This store mirrors their session ids
14230
+ // so the session menu can offer Enter / Exit; it polls only while a menu
14231
+ // observes it, and every open/close updates it optimistically.
14232
+ const nativeWindowStore = (() => {
14233
+ let sessions = [];
14234
+ const listeners = new Set();
14235
+ let timer = 0;
14236
+ let inflight = null;
14237
+ const emit = () => {
14238
+ for (const listener of [...listeners]) {
14239
+ try { listener(); } catch {}
14240
+ }
14241
+ };
14242
+ const publish = (value) => {
14243
+ const next = [];
14244
+ for (const id of Array.isArray(value) ? value : []) {
14245
+ if (isValidSessionId(id) && next.indexOf(id) === -1) next.push(id);
14246
+ }
14247
+ const same = next.length === sessions.length && next.every((id, index) => sessions[index] === id);
14248
+ if (same) return;
14249
+ sessions = next;
14250
+ emit();
14251
+ };
14252
+ /** Fetch the Host's window list; concurrent callers share one request.
14253
+ The returned promise always settles, so the menu never hangs. */
14254
+ const read = () => {
14255
+ if (inflight !== null) return inflight;
14256
+ inflight = Promise.resolve().then(() => {
14257
+ try {
14258
+ return fetch("/dsv/system-window", {
14259
+ method: "GET",
14260
+ cache: "no-store",
14261
+ headers: { "x-dsv-system-window": "1" },
14262
+ }).then((response) => response.json().catch(() => null)).then((payload) => {
14263
+ if (payload !== null && payload !== undefined && payload.ok === true && Array.isArray(payload.sessions)) {
14264
+ publish(payload.sessions);
14265
+ }
14266
+ }).catch(() => {});
14267
+ } catch {
14268
+ return undefined;
14269
+ }
14270
+ }).finally(() => { inflight = null; });
14271
+ return inflight;
14272
+ };
14273
+ return {
14274
+ getSnapshot: () => sessions,
14275
+ subscribe(listener) {
14276
+ if (typeof listener !== "function") return () => {};
14277
+ listeners.add(listener);
14278
+ if (listeners.size === 1) {
14279
+ read();
14280
+ timer = window.setInterval(read, 2000);
14281
+ }
14282
+ return () => {
14283
+ listeners.delete(listener);
14284
+ if (listeners.size === 0 && timer !== 0) {
14285
+ try { window.clearInterval(timer); } catch {}
14286
+ timer = 0;
14287
+ }
14288
+ };
14289
+ },
14290
+ has: (id) => sessions.indexOf(id) !== -1,
14291
+ markOpen(id) {
14292
+ if (!isValidSessionId(id) || sessions.indexOf(id) !== -1) return;
14293
+ sessions = sessions.concat([id]);
14294
+ emit();
14295
+ },
14296
+ markClosed(id) {
14297
+ if (sessions.indexOf(id) === -1) return;
14298
+ sessions = sessions.filter((entry) => entry !== id);
14299
+ emit();
14300
+ },
14301
+ refresh: () => read(),
14302
+ };
14303
+ })();
14304
+
14305
+ /** Host action: open or close the native (OS) window for one conversation. */
14306
+ function requestSystemWindow(sessionId, mode) {
14307
+ if (!isValidSessionId(sessionId)) return false;
14308
+ const closing = mode === "close";
14309
+ if (!desktopShell()) {
14310
+ showPaneToast(t("systemWindowUnsupported"), true);
14311
+ return false;
14312
+ }
14313
+ showPaneToast(t(closing ? "systemWindowClosing" : "systemWindowOpening"), true);
14314
+ try {
14315
+ fetch("/dsv/system-window", {
14316
+ method: "POST",
14317
+ headers: { "content-type": "application/json", "x-dsv-system-window": "1" },
14318
+ body: JSON.stringify({ sessionId, action: closing ? "close" : "open" }),
14319
+ cache: "no-store",
14320
+ }).then((response) => response.json().catch(() => null)).then((payload) => {
14321
+ if (payload !== null && payload !== undefined && payload.ok === true) {
14322
+ if (closing) {
14323
+ nativeWindowStore.markClosed(sessionId);
14324
+ showPaneToast(t("systemWindowNativeClosed"), true);
14325
+ } else {
14326
+ nativeWindowStore.markOpen(sessionId);
14327
+ showPaneToast(t("systemWindowNativeOpened"), true);
14328
+ }
14329
+ return;
14330
+ }
14331
+ const code = payload !== null && payload !== undefined ? payload.error : undefined;
14332
+ showPaneToast(t(code === "unsupported-platform" || code === "not-desktop"
14333
+ ? "systemWindowUnsupported"
14334
+ : "systemWindowFailed"), true);
14335
+ }).catch(() => {
14336
+ showPaneToast(t("systemWindowFailed"), true);
14337
+ });
14338
+ } catch {
14339
+ showPaneToast(t("systemWindowFailed"), true);
14340
+ return false;
14341
+ }
14342
+ return true;
14343
+ }
13600
14344
  function restoreSplit() {
13601
14345
  try {
13602
14346
  const tree = treeStore.getSnapshot();
@@ -13660,6 +14404,25 @@ window.__ModuleLoader__.load({
13660
14404
  const slots = ctx.get("slots");
13661
14405
  if (slots === undefined) return;
13662
14406
  appliedOnce = true;
14407
+ try {
14408
+ install(ctx, slots);
14409
+ } catch (error) {
14410
+ // DSH retries a failed client entry by re-running apply() on the SAME
14411
+ // module exports (the fiber restart does not re-materialize the
14412
+ // bundle), so keeping the once-guard set here would turn a single setup
14413
+ // throw into a plugin that never mounts again — no footer button, no
14414
+ // session menus, no Settings section, until the page is reloaded. That
14415
+ // is the "restart DSH to get the menus back" symptom. Clearing the flag
14416
+ // lets the next retry rebuild everything; whatever this attempt already
14417
+ // registered is disposed with the failed fiber.
14418
+ appliedOnce = false;
14419
+ throw error;
14420
+ }
14421
+ }
14422
+
14423
+ /** Everything one successful apply() installs. Kept separate from the
14424
+ once-guard so a failed setup can clear it before DSH retries. */
14425
+ function install(ctx, slots) {
13663
14426
  const locale = ctx.get("locale");
13664
14427
  pluginCtx = ctx;
13665
14428
  sessionsService = ctx.get("sessions");
@@ -13719,6 +14482,11 @@ window.__ModuleLoader__.load({
13719
14482
 
13720
14483
  ctx.effect(() => insertStyle(DSV_CSS), "dsh-split-workspace: stylesheet");
13721
14484
 
14485
+ // A native system window boots this same client on the plain web origin.
14486
+ // Remove the left sidebar, keep the stock right sidebar, and activate the
14487
+ // conversation named by the URL hash. No-op in every other window.
14488
+ ctx.effect(bootSystemWindow, "dsh-split-workspace: system window");
14489
+
13722
14490
  // Performance mode is a CSS class on <html>; mirror the persisted flag
13723
14491
  // on every apply so a reload keeps it.
13724
14492
  ctx.effect(() => {
@@ -13862,7 +14630,7 @@ window.__ModuleLoader__.load({
13862
14630
  activationMarked = false;
13863
14631
  failureWindow.length = 0;
13864
14632
  failureLog.clear();
13865
- setRuntime({ active: false, geometryBlocked: false, helpOpen: false, tipVisible: false });
14633
+ setRuntime({ active: false, geometryBlocked: false, helpOpen: false, tipVisible: false, appWindow: null });
13866
14634
  appliedOnce = false;
13867
14635
  },
13868
14636
  "dsh-split-workspace: service cleanup",
@@ -13882,6 +14650,21 @@ window.__ModuleLoader__.load({
13882
14650
  h(FooterSplitButton),
13883
14651
  ),
13884
14652
  );
14653
+ // A second entry point in the system Settings panel. The slot is
14654
+ // declared by the settings shell; injection waits until it exists.
14655
+ slots.inject("settings.section", () =>
14656
+ slots.register({
14657
+ name: "settings.section",
14658
+ id: "split-workspace",
14659
+ order: 40,
14660
+ label: () => t("settingsNav"),
14661
+ }, (props) => h(SettingsSection, props)),
14662
+ );
14663
+ slots.inject("settings.section.icon", () =>
14664
+ slots.register({ name: "settings.section.icon", id: "split-workspace" }, (props) =>
14665
+ h(SplitIconV, { size: props !== null && props !== undefined && typeof props.size === "number" ? props.size : 16 }),
14666
+ ),
14667
+ );
13885
14668
  }
13886
14669
 
13887
14670
  // dsh 0.1.5: client services (sessions/locale) are provided asynchronously