@tutti-os/workbench-surface 0.0.9 → 0.0.11

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.
@@ -62,6 +62,7 @@ var tuttiI18nModule2 = createScopedLocaleObjectsI18nModuleManifest2({
62
62
  });
63
63
  var workbenchMissionControlEn = {
64
64
  layoutSelectionHint: "Select multiple windows to arrange",
65
+ noAvailableLayout: "No layout fits the selected windows",
65
66
  presets: {
66
67
  balanced: "Balanced layout",
67
68
  column: "Vertical equal layout",
@@ -70,6 +71,7 @@ var workbenchMissionControlEn = {
70
71
  };
71
72
  var workbenchMissionControlZhCN = {
72
73
  layoutSelectionHint: "\u8BF7\u9009\u62E9\u591A\u4E2A\u4F60\u8981\u6574\u7406\u5E03\u5C40\u7684\u7A97\u53E3",
74
+ noAvailableLayout: "\u5F53\u524D\u6CA1\u6709\u53EF\u7528\u5E03\u5C40",
73
75
  presets: {
74
76
  balanced: "\u667A\u80FD\u5747\u8861\u5E03\u5C40",
75
77
  column: "\u5782\u76F4\u7B49\u5206\u5E03\u5C40",
@@ -187,4 +189,4 @@ export {
187
189
  workbenchHostI18nResources,
188
190
  createWorkbenchHostI18nRuntime
189
191
  };
190
- //# sourceMappingURL=chunk-QZ3DIAZK.js.map
192
+ //# sourceMappingURL=chunk-64XVF4I6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/react/workbenchWindowI18n.ts","../src/mission-control/workbenchMissionControlI18n.ts","../src/host/workbenchHostI18n.ts"],"sourcesContent":["import {\n createScopedLocaleObjectsI18nModuleManifest,\n createI18nRuntime,\n createScopedI18nRuntime,\n type I18nDictionary,\n type I18nRuntime\n} from \"@tutti-os/ui-i18n-runtime\";\n\ntype WorkbenchWindowChromeI18nLocale = \"en\" | \"zh-CN\";\nexport const workbenchWindowChromeI18nNamespace = \"workbenchWindowChrome\";\nexport const tuttiI18nModule = createScopedLocaleObjectsI18nModuleManifest({\n localeObjectByLocale: {\n en: \"workbenchWindowChromeEn\",\n \"zh-CN\": \"workbenchWindowChromeZhCN\"\n },\n name: \"workbench-window-chrome\",\n namespace: \"workbenchWindowChrome\",\n sourceRoot: \"packages/workbench/surface/src\"\n});\n\nconst workbenchWindowChromeEn = {\n enterFullscreen: \"Full Screen\",\n exitFullscreen: \"Exit Full Screen\"\n} as const satisfies I18nDictionary;\n\nconst workbenchWindowChromeZhCN = {\n enterFullscreen: \"全屏\",\n exitFullscreen: \"取消全屏\"\n} as const satisfies I18nDictionary;\n\nexport type WorkbenchWindowChromeI18nKey = keyof typeof workbenchWindowChromeEn;\n\nexport type WorkbenchWindowChromeI18nRuntime =\n I18nRuntime<WorkbenchWindowChromeI18nKey>;\n\nconst workbenchWindowChromeDefaults: Record<\n WorkbenchWindowChromeI18nLocale,\n I18nDictionary\n> = {\n en: workbenchWindowChromeEn,\n \"zh-CN\": workbenchWindowChromeZhCN\n};\n\nexport const workbenchWindowChromeI18nResources: Record<\n WorkbenchWindowChromeI18nLocale,\n I18nDictionary\n> = {\n en: {\n [workbenchWindowChromeI18nNamespace]: workbenchWindowChromeDefaults.en\n },\n \"zh-CN\": {\n [workbenchWindowChromeI18nNamespace]: workbenchWindowChromeDefaults[\"zh-CN\"]\n }\n};\n\nconst defaultWorkbenchWindowChromeI18n = createI18nRuntime({\n dictionaries: [workbenchWindowChromeI18nResources.en]\n});\n\nexport function createWorkbenchWindowChromeI18nRuntime(\n runtime: I18nRuntime<string> | undefined\n): WorkbenchWindowChromeI18nRuntime {\n return createScopedI18nRuntime<WorkbenchWindowChromeI18nKey>(\n runtime ?? defaultWorkbenchWindowChromeI18n,\n workbenchWindowChromeI18nNamespace\n );\n}\n","import {\n createScopedLocaleObjectsI18nModuleManifest,\n createI18nRuntime,\n createScopedI18nRuntime,\n type I18nDictionary,\n type I18nRuntime\n} from \"@tutti-os/ui-i18n-runtime\";\n\ntype WorkbenchMissionControlI18nLocale = \"en\" | \"zh-CN\";\n\nexport const workbenchMissionControlI18nNamespace = \"workbenchMissionControl\";\n\nexport const tuttiI18nModule = createScopedLocaleObjectsI18nModuleManifest({\n localeObjectByLocale: {\n en: \"workbenchMissionControlEn\",\n \"zh-CN\": \"workbenchMissionControlZhCN\"\n },\n name: \"workbench-mission-control\",\n namespace: \"workbenchMissionControl\",\n sourceRoot: \"packages/workbench/surface/src\"\n});\n\nconst workbenchMissionControlEn = {\n layoutSelectionHint: \"Select multiple windows to arrange\",\n noAvailableLayout: \"No layout fits the selected windows\",\n presets: {\n balanced: \"Balanced layout\",\n column: \"Vertical equal layout\",\n row: \"Horizontal equal layout\"\n }\n} as const satisfies I18nDictionary;\n\nconst workbenchMissionControlZhCN = {\n layoutSelectionHint: \"请选择多个你要整理布局的窗口\",\n noAvailableLayout: \"当前没有可用布局\",\n presets: {\n balanced: \"智能均衡布局\",\n column: \"垂直等分布局\",\n row: \"水平等分布局\"\n }\n} as const satisfies I18nDictionary;\n\nexport type WorkbenchMissionControlI18nKey =\n | \"layoutSelectionHint\"\n | \"noAvailableLayout\"\n | \"presets.balanced\"\n | \"presets.column\"\n | \"presets.row\";\n\nexport type WorkbenchMissionControlI18nRuntime =\n I18nRuntime<WorkbenchMissionControlI18nKey>;\n\nconst workbenchMissionControlDefaults: Record<\n WorkbenchMissionControlI18nLocale,\n I18nDictionary\n> = {\n en: workbenchMissionControlEn,\n \"zh-CN\": workbenchMissionControlZhCN\n};\n\nexport const workbenchMissionControlI18nResources: Record<\n WorkbenchMissionControlI18nLocale,\n I18nDictionary\n> = {\n en: {\n [workbenchMissionControlI18nNamespace]: workbenchMissionControlDefaults.en\n },\n \"zh-CN\": {\n [workbenchMissionControlI18nNamespace]:\n workbenchMissionControlDefaults[\"zh-CN\"]\n }\n};\n\nconst defaultWorkbenchMissionControlI18n = createI18nRuntime({\n dictionaries: [workbenchMissionControlI18nResources.en]\n});\n\nexport function createWorkbenchMissionControlI18nRuntime(\n runtime: I18nRuntime<string> | undefined\n): WorkbenchMissionControlI18nRuntime {\n return createScopedI18nRuntime<WorkbenchMissionControlI18nKey>(\n runtime ?? defaultWorkbenchMissionControlI18n,\n workbenchMissionControlI18nNamespace\n );\n}\n","import {\n createScopedLocaleObjectsI18nModuleManifest,\n createI18nRuntime,\n createScopedI18nRuntime,\n type I18nDictionary,\n type I18nRuntime\n} from \"@tutti-os/ui-i18n-runtime\";\n\ntype WorkbenchHostI18nLocale = \"en\" | \"zh-CN\";\nexport const workbenchHostI18nNamespace = \"workbenchHost\";\nexport const tuttiI18nModule = createScopedLocaleObjectsI18nModuleManifest({\n localeObjectByLocale: {\n en: \"workbenchHostEn\",\n \"zh-CN\": \"workbenchHostZhCN\"\n },\n name: \"workbench-host\",\n namespace: \"workbenchHost\",\n sourceRoot: \"packages/workbench/surface/src\"\n});\n\nconst workbenchHostEn = {\n actions: {\n close: \"Close\",\n minimize: \"Minimize\"\n },\n closeWindow: \"Close {{title}}\",\n dockLabel: \"Workbench dock\",\n launch: \"Open {{title}}\",\n minimizedWindows: \"Minimized windows\",\n newWindow: \"New window\",\n scrollDockDown: \"Scroll dock down\",\n scrollDockLeft: \"Scroll dock left\",\n scrollDockRight: \"Scroll dock right\",\n scrollDockUp: \"Scroll dock up\",\n windowStatus: {\n active: \"Active\",\n minimized: \"Minimized\",\n open: \"Open\"\n }\n} as const satisfies I18nDictionary;\n\nconst workbenchHostZhCN = {\n actions: {\n close: \"关闭\",\n minimize: \"最小化\"\n },\n closeWindow: \"关闭 {{title}}\",\n dockLabel: \"工作台程序坞\",\n launch: \"打开 {{title}}\",\n minimizedWindows: \"已最小化窗口\",\n newWindow: \"新建窗口\",\n scrollDockDown: \"向下滚动程序坞\",\n scrollDockLeft: \"向左滚动程序坞\",\n scrollDockRight: \"向右滚动程序坞\",\n scrollDockUp: \"向上滚动程序坞\",\n windowStatus: {\n active: \"当前窗口\",\n minimized: \"已最小化\",\n open: \"已打开\"\n }\n} as const satisfies I18nDictionary;\n\nexport type WorkbenchHostI18nKey =\n | \"actions.close\"\n | \"actions.minimize\"\n | \"closeWindow\"\n | \"dockLabel\"\n | \"launch\"\n | \"minimizedWindows\"\n | \"newWindow\"\n | \"scrollDockDown\"\n | \"scrollDockLeft\"\n | \"scrollDockRight\"\n | \"scrollDockUp\"\n | \"windowStatus.active\"\n | \"windowStatus.minimized\"\n | \"windowStatus.open\";\n\nexport type WorkbenchHostI18nRuntime = I18nRuntime<WorkbenchHostI18nKey>;\n\nconst workbenchHostDefaults: Record<WorkbenchHostI18nLocale, I18nDictionary> = {\n en: workbenchHostEn,\n \"zh-CN\": workbenchHostZhCN\n};\n\nexport const workbenchHostI18nResources = {\n en: {\n [workbenchHostI18nNamespace]: workbenchHostDefaults.en\n },\n \"zh-CN\": {\n [workbenchHostI18nNamespace]: workbenchHostDefaults[\"zh-CN\"]\n }\n} as const satisfies Record<WorkbenchHostI18nLocale, I18nDictionary>;\n\nconst defaultWorkbenchHostI18n = createI18nRuntime({\n dictionaries: [workbenchHostI18nResources.en]\n});\n\nexport function createWorkbenchHostI18nRuntime(\n runtime: I18nRuntime<string> | undefined\n): WorkbenchHostI18nRuntime {\n return createScopedI18nRuntime<WorkbenchHostI18nKey>(\n runtime ?? defaultWorkbenchHostI18n,\n workbenchHostI18nNamespace\n );\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAGA,IAAM,qCAAqC;AAC3C,IAAM,kBAAkB,4CAA4C;AAAA,EACzE,sBAAsB;AAAA,IACpB,IAAI;AAAA,IACJ,SAAS;AAAA,EACX;AAAA,EACA,MAAM;AAAA,EACN,WAAW;AAAA,EACX,YAAY;AACd,CAAC;AAED,IAAM,0BAA0B;AAAA,EAC9B,iBAAiB;AAAA,EACjB,gBAAgB;AAClB;AAEA,IAAM,4BAA4B;AAAA,EAChC,iBAAiB;AAAA,EACjB,gBAAgB;AAClB;AAOA,IAAM,gCAGF;AAAA,EACF,IAAI;AAAA,EACJ,SAAS;AACX;AAEO,IAAM,qCAGT;AAAA,EACF,IAAI;AAAA,IACF,CA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CAAC;AAEM,SAAS,+BACd,SAC0B;AAC1B,SAAOC;AAAA,IACL,WAAW;AAAA,IACX;AAAA,EACF;AACF;","names":["createScopedLocaleObjectsI18nModuleManifest","createI18nRuntime","createScopedI18nRuntime","tuttiI18nModule","createScopedLocaleObjectsI18nModuleManifest","createI18nRuntime","createScopedI18nRuntime","tuttiI18nModule"]}
@@ -3,7 +3,7 @@ import { I18nRuntime, I18nDictionary } from '@tutti-os/ui-i18n-runtime';
3
3
 
4
4
  type WorkbenchMissionControlI18nLocale = "en" | "zh-CN";
5
5
  declare const workbenchMissionControlI18nNamespace = "workbenchMissionControl";
6
- type WorkbenchMissionControlI18nKey = "layoutSelectionHint" | "presets.balanced" | "presets.column" | "presets.row";
6
+ type WorkbenchMissionControlI18nKey = "layoutSelectionHint" | "noAvailableLayout" | "presets.balanced" | "presets.column" | "presets.row";
7
7
  type WorkbenchMissionControlI18nRuntime = I18nRuntime<WorkbenchMissionControlI18nKey>;
8
8
  declare const workbenchMissionControlI18nResources: Record<WorkbenchMissionControlI18nLocale, I18nDictionary>;
9
9
  declare function createWorkbenchMissionControlI18nRuntime(runtime: I18nRuntime<string> | undefined): WorkbenchMissionControlI18nRuntime;
@@ -8,7 +8,7 @@ import {
8
8
  workbenchMissionControlI18nResources,
9
9
  workbenchWindowChromeI18nNamespace,
10
10
  workbenchWindowChromeI18nResources
11
- } from "../chunk-QZ3DIAZK.js";
11
+ } from "../chunk-64XVF4I6.js";
12
12
  export {
13
13
  createWorkbenchHostI18nRuntime,
14
14
  createWorkbenchMissionControlI18nRuntime,
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  workbenchHostI18nResources,
6
6
  workbenchWindowChromeI18nNamespace,
7
7
  workbenchWindowChromeI18nResources
8
- } from "./chunk-QZ3DIAZK.js";
8
+ } from "./chunk-64XVF4I6.js";
9
9
 
10
10
  // src/store/commands.ts
11
11
  function createWorkbenchCommands(store) {
@@ -390,7 +390,7 @@ function getBalancedLayoutFrames(itemCount, frame, constraints) {
390
390
  return getGridLayoutFrames(itemCount, 2, frame, constraints);
391
391
  }
392
392
  if (itemCount >= 4) {
393
- return getGridLayoutFrames(itemCount, 2, frame, constraints);
393
+ return getBestBalancedGridLayoutFrames(itemCount, frame, constraints);
394
394
  }
395
395
  const gap = WORKBENCH_LAYOUT_PRESET_GAP_PX;
396
396
  const primaryWidth = Math.floor((frame.width - gap) * 0.58);
@@ -425,6 +425,26 @@ function getBalancedLayoutFrames(itemCount, frame, constraints) {
425
425
  }
426
426
  return frames;
427
427
  }
428
+ function getBestBalancedGridLayoutFrames(itemCount, frame, constraints) {
429
+ let best = null;
430
+ for (let columns = 2; columns <= itemCount; columns += 1) {
431
+ const rows = Math.ceil(itemCount / columns);
432
+ const frames = getGridLayoutFrames(itemCount, columns, frame, constraints);
433
+ if (!frames) {
434
+ continue;
435
+ }
436
+ const candidate = {
437
+ columns,
438
+ emptySlots: rows * columns - itemCount,
439
+ frames,
440
+ shapeDistance: Math.abs(columns - rows)
441
+ };
442
+ if (!best || candidate.shapeDistance < best.shapeDistance || candidate.shapeDistance === best.shapeDistance && candidate.emptySlots < best.emptySlots || candidate.shapeDistance === best.shapeDistance && candidate.emptySlots === best.emptySlots && candidate.columns < best.columns) {
443
+ best = candidate;
444
+ }
445
+ }
446
+ return best?.frames ?? null;
447
+ }
428
448
  function getSingleColumnLayoutFrames(itemCount, frame, constraints) {
429
449
  const verticalGap = WORKBENCH_LAYOUT_PRESET_GAP_PX * Math.max(0, itemCount - 1);
430
450
  const cellHeight = Math.floor((frame.height - verticalGap) / itemCount);
@@ -1035,6 +1055,9 @@ import {
1035
1055
  function shouldShowWorkbenchMissionControlLayoutHint(selectedCount) {
1036
1056
  return selectedCount < 2;
1037
1057
  }
1058
+ function shouldShowWorkbenchMissionControlNoAvailableLayoutMessage(selectedCount, hasUsablePreset) {
1059
+ return selectedCount >= 2 && !hasUsablePreset;
1060
+ }
1038
1061
  function shouldShowWorkbenchMissionControlLayoutPreset(selectedCount, preset) {
1039
1062
  if (selectedCount === 2) {
1040
1063
  return preset.kind !== "balanced";
@@ -1099,6 +1122,16 @@ function WorkbenchMissionControlOverlay({
1099
1122
  option.preset
1100
1123
  )
1101
1124
  );
1125
+ const showLayoutSelectionHint = shouldShowWorkbenchMissionControlLayoutHint(
1126
+ state.selectedCount
1127
+ );
1128
+ const hasUsableLayoutPreset = layoutPresets.some(
1129
+ (option) => state.canUsePreset(option.preset)
1130
+ );
1131
+ const showNoAvailableLayoutMessage = shouldShowWorkbenchMissionControlNoAvailableLayoutMessage(
1132
+ state.selectedCount,
1133
+ hasUsableLayoutPreset
1134
+ );
1102
1135
  useLayoutEffect(() => {
1103
1136
  const element = layoutDockContentRef.current;
1104
1137
  if (!element) {
@@ -1107,7 +1140,13 @@ function WorkbenchMissionControlOverlay({
1107
1140
  const computedStyle = window.getComputedStyle(element.parentElement);
1108
1141
  const horizontalChrome = Number.parseFloat(computedStyle.paddingLeft) + Number.parseFloat(computedStyle.paddingRight) + Number.parseFloat(computedStyle.borderLeftWidth) + Number.parseFloat(computedStyle.borderRightWidth);
1109
1142
  setLayoutDockWidth(element.scrollWidth + horizontalChrome);
1110
- }, [i18n, layoutPresets.length, state.selectedCount]);
1143
+ }, [
1144
+ i18n,
1145
+ layoutPresets.length,
1146
+ showLayoutSelectionHint,
1147
+ showNoAvailableLayoutMessage,
1148
+ state.selectedCount
1149
+ ]);
1111
1150
  return /* @__PURE__ */ jsx(
1112
1151
  "div",
1113
1152
  {
@@ -1124,9 +1163,7 @@ function WorkbenchMissionControlOverlay({
1124
1163
  {
1125
1164
  ref: layoutDockContentRef,
1126
1165
  className: "workbench-mission-control__layout-dock-content",
1127
- children: shouldShowWorkbenchMissionControlLayoutHint(
1128
- state.selectedCount
1129
- ) ? /* @__PURE__ */ jsx("span", { className: "workbench-mission-control__layout-hint", children: i18n.t("layoutSelectionHint") }) : /* @__PURE__ */ jsx("div", { className: "flex items-end gap-2", children: layoutPresets.map((option) => {
1166
+ children: showLayoutSelectionHint ? /* @__PURE__ */ jsx("span", { className: "workbench-mission-control__layout-hint", children: i18n.t("layoutSelectionHint") }) : showNoAvailableLayoutMessage ? /* @__PURE__ */ jsx("span", { className: "workbench-mission-control__layout-hint", children: i18n.t("noAvailableLayout") }) : /* @__PURE__ */ jsx("div", { className: "flex items-end gap-2", children: layoutPresets.map((option) => {
1130
1167
  const canApply = state.canApplyPreset(option.preset);
1131
1168
  const LayoutIcon = option.icon;
1132
1169
  return /* @__PURE__ */ jsx(
@@ -5444,7 +5481,7 @@ function logWorkbenchHostDebug(event, debugDiagnostics, payload) {
5444
5481
  }
5445
5482
 
5446
5483
  // src/host/useWorkbenchHostSurfaceRenderers.tsx
5447
- import { useCallback as useCallback11, useMemo as useMemo6 } from "react";
5484
+ import { Component, useCallback as useCallback11, useMemo as useMemo6 } from "react";
5448
5485
 
5449
5486
  // src/host/WorkbenchHostDock.tsx
5450
5487
  import {
@@ -6118,6 +6155,40 @@ function useMinimizedDockStackPromotion(slots) {
6118
6155
  return { promotedNodeId, stackDispatching };
6119
6156
  }
6120
6157
 
6158
+ // src/host/minimizedDockRestoreIntent.ts
6159
+ function resolveWorkbenchMinimizedDockRestoreIntent(input) {
6160
+ const { source } = input;
6161
+ switch (source.kind) {
6162
+ case "node-slot": {
6163
+ const slot = input.slots.find(
6164
+ (slot2) => slot2.anchorKey === source.anchorKey
6165
+ );
6166
+ if (slot?.kind !== "node" || slot.node.id !== input.nodeId) {
6167
+ return null;
6168
+ }
6169
+ return {
6170
+ anchorKey: slot.anchorKey,
6171
+ kind: "node-slot",
6172
+ nodeId: input.nodeId
6173
+ };
6174
+ }
6175
+ case "stack-popup-card": {
6176
+ const slot = input.slots.find(
6177
+ (slot2) => slot2.anchorKey === source.stackAnchorKey
6178
+ );
6179
+ if (slot?.kind !== "stack" || !slot.nodes.some((node) => node.id === input.nodeId)) {
6180
+ return null;
6181
+ }
6182
+ return {
6183
+ anchorKey: slot.anchorKey,
6184
+ kind: "stack-popup-card",
6185
+ nodeId: input.nodeId,
6186
+ stackAnchorKey: slot.anchorKey
6187
+ };
6188
+ }
6189
+ }
6190
+ }
6191
+
6121
6192
  // src/host/WorkbenchHostDockPopup.tsx
6122
6193
  import {
6123
6194
  forwardRef,
@@ -7272,6 +7343,10 @@ function WorkbenchHostDock({
7272
7343
  clearTimeout(timer);
7273
7344
  collapsingMinimizedLaunchTimerRef.current.delete(anchorKey);
7274
7345
  }
7346
+ const slotElement = slotRefs.current.get(anchorKey);
7347
+ slotElement?.removeAttribute("data-collapsing");
7348
+ slotElement?.style.removeProperty("--desktop-dock-collapse-inline-size");
7349
+ slotElement?.style.removeProperty("--desktop-dock-collapse-block-size");
7275
7350
  setCollapsingMinimizedLaunchAnchorKeys((current) => {
7276
7351
  if (!current.has(anchorKey)) {
7277
7352
  return current;
@@ -7637,7 +7712,8 @@ function WorkbenchHostDock({
7637
7712
  ]
7638
7713
  );
7639
7714
  const runDockMinimizedLaunchAfterCollapse = useCallback10(
7640
- (anchorKey, launch) => {
7715
+ (intent, launch) => {
7716
+ const { anchorKey } = intent;
7641
7717
  beginDockMinimizedInteraction(anchorKey);
7642
7718
  setCollapsingMinimizedLaunchAnchorKeys((current) => {
7643
7719
  const next = new Set(current);
@@ -7645,10 +7721,17 @@ function WorkbenchHostDock({
7645
7721
  return next;
7646
7722
  });
7647
7723
  scheduleCollapsingMinimizedLaunchClear(anchorKey);
7648
- launch();
7724
+ launch(intent);
7649
7725
  },
7650
7726
  [beginDockMinimizedInteraction, scheduleCollapsingMinimizedLaunchClear]
7651
7727
  );
7728
+ const runDockMinimizedStackLaunch = useCallback10(
7729
+ (intent, launch) => {
7730
+ beginDockMinimizedInteraction();
7731
+ launch(intent);
7732
+ },
7733
+ [beginDockMinimizedInteraction]
7734
+ );
7652
7735
  const handleDockPointerTravel = useCallback10(
7653
7736
  (clientX, clientY) => {
7654
7737
  if (activeHoverPanelRef.current !== null) {
@@ -8273,18 +8356,42 @@ function WorkbenchHostDock({
8273
8356
  title: node.title,
8274
8357
  type: "button",
8275
8358
  onPointerDown: () => {
8276
- beginDockMinimizedInteraction(slot.anchorKey);
8359
+ const restoreIntent = resolveWorkbenchMinimizedDockRestoreIntent({
8360
+ nodeId: node.id,
8361
+ slots: minimizedDockSlots,
8362
+ source: {
8363
+ anchorKey: slot.anchorKey,
8364
+ kind: "node-slot"
8365
+ }
8366
+ });
8367
+ if (restoreIntent?.kind !== "node-slot") {
8368
+ clearCollapsingMinimizedLaunch(slot.anchorKey);
8369
+ return;
8370
+ }
8371
+ beginDockMinimizedInteraction();
8277
8372
  },
8278
8373
  onClick: () => {
8374
+ const restoreIntent = resolveWorkbenchMinimizedDockRestoreIntent({
8375
+ nodeId: node.id,
8376
+ slots: minimizedDockSlots,
8377
+ source: {
8378
+ anchorKey: slot.anchorKey,
8379
+ kind: "node-slot"
8380
+ }
8381
+ });
8382
+ if (restoreIntent?.kind !== "node-slot") {
8383
+ clearCollapsingMinimizedLaunch(slot.anchorKey);
8384
+ return;
8385
+ }
8279
8386
  closePopup();
8280
8387
  runDockMinimizedLaunchAfterCollapse(
8281
- slot.anchorKey,
8282
- () => {
8388
+ restoreIntent,
8389
+ (intent) => {
8283
8390
  context.genie.launchNodeFromAnchor(
8284
- slot.anchorKey,
8285
- node.id,
8391
+ intent.anchorKey,
8392
+ intent.nodeId,
8286
8393
  () => {
8287
- host.focusNode(node.id);
8394
+ host.focusNode(intent.nodeId);
8288
8395
  }
8289
8396
  );
8290
8397
  }
@@ -8555,15 +8662,26 @@ function WorkbenchHostDock({
8555
8662
  },
8556
8663
  onCreateNew: () => void 0,
8557
8664
  onSelectNode: (nodeId) => {
8558
- closePopup();
8559
- const anchorKey = resolveWorkbenchMinimizedDockAnchorKeyForNode({
8665
+ const restoreIntent = resolveWorkbenchMinimizedDockRestoreIntent({
8560
8666
  nodeId,
8561
- slots: minimizedDockSlots
8562
- }) ?? activeMinimizedStackSlot.anchorKey;
8563
- runDockMinimizedLaunchAfterCollapse(anchorKey, () => {
8564
- context.genie.launchNodeFromAnchor(anchorKey, nodeId, () => {
8565
- host.focusNode(nodeId);
8566
- });
8667
+ slots: minimizedDockSlots,
8668
+ source: {
8669
+ kind: "stack-popup-card",
8670
+ stackAnchorKey: activeMinimizedStackSlot.anchorKey
8671
+ }
8672
+ });
8673
+ if (restoreIntent?.kind !== "stack-popup-card") {
8674
+ return;
8675
+ }
8676
+ closePopup();
8677
+ runDockMinimizedStackLaunch(restoreIntent, (intent) => {
8678
+ context.genie.launchNodeFromAnchor(
8679
+ intent.anchorKey,
8680
+ intent.nodeId,
8681
+ () => {
8682
+ host.focusNode(intent.nodeId);
8683
+ }
8684
+ );
8567
8685
  });
8568
8686
  },
8569
8687
  showCreateNew: false,
@@ -9230,14 +9348,62 @@ function WorkbenchHostWindowActions({
9230
9348
  // src/host/useWorkbenchHostSurfaceRenderers.tsx
9231
9349
  import { jsx as jsx12 } from "react/jsx-runtime";
9232
9350
  function useWorkbenchHostSurfaceRenderers(input) {
9233
- const renderBottomChrome = useMemo6(
9234
- () => input.renderBottomChrome ? () => input.renderBottomChrome?.(input.chromeContext) : void 0,
9235
- [input.chromeContext, input.renderBottomChrome]
9236
- );
9237
- const renderTopChrome = useMemo6(
9238
- () => input.renderTopChrome ? () => input.renderTopChrome?.(input.chromeContext) : void 0,
9239
- [input.chromeContext, input.renderTopChrome]
9240
- );
9351
+ const renderBottomChrome = useMemo6(() => {
9352
+ const renderChrome = input.renderBottomChrome;
9353
+ return renderChrome ? () => /* @__PURE__ */ jsx12(
9354
+ WorkbenchHostSurfaceRenderErrorBoundary,
9355
+ {
9356
+ debugDiagnostics: input.debugDiagnostics,
9357
+ details: {
9358
+ chromeSlot: "bottom"
9359
+ },
9360
+ event: "workbench.chrome.render_error",
9361
+ fallbackKind: "bottom-chrome",
9362
+ resetKey: `${input.workspaceId}:bottom-chrome`,
9363
+ workspaceId: input.workspaceId,
9364
+ children: /* @__PURE__ */ jsx12(
9365
+ WorkbenchHostChromeRenderer,
9366
+ {
9367
+ context: input.chromeContext,
9368
+ renderChrome
9369
+ }
9370
+ )
9371
+ }
9372
+ ) : void 0;
9373
+ }, [
9374
+ input.chromeContext,
9375
+ input.debugDiagnostics,
9376
+ input.renderBottomChrome,
9377
+ input.workspaceId
9378
+ ]);
9379
+ const renderTopChrome = useMemo6(() => {
9380
+ const renderChrome = input.renderTopChrome;
9381
+ return renderChrome ? () => /* @__PURE__ */ jsx12(
9382
+ WorkbenchHostSurfaceRenderErrorBoundary,
9383
+ {
9384
+ debugDiagnostics: input.debugDiagnostics,
9385
+ details: {
9386
+ chromeSlot: "top"
9387
+ },
9388
+ event: "workbench.chrome.render_error",
9389
+ fallbackKind: "top-chrome",
9390
+ resetKey: `${input.workspaceId}:top-chrome`,
9391
+ workspaceId: input.workspaceId,
9392
+ children: /* @__PURE__ */ jsx12(
9393
+ WorkbenchHostChromeRenderer,
9394
+ {
9395
+ context: input.chromeContext,
9396
+ renderChrome
9397
+ }
9398
+ )
9399
+ }
9400
+ ) : void 0;
9401
+ }, [
9402
+ input.chromeContext,
9403
+ input.debugDiagnostics,
9404
+ input.renderTopChrome,
9405
+ input.workspaceId
9406
+ ]);
9241
9407
  const captureNodePreviewImage = useCallback11(
9242
9408
  async (node) => {
9243
9409
  const definition = input.nodeDefinitionByType.get(node.data.typeId);
@@ -9272,22 +9438,36 @@ function useWorkbenchHostSurfaceRenderers(input) {
9272
9438
  );
9273
9439
  const renderDock = useCallback11(
9274
9440
  (context) => /* @__PURE__ */ jsx12(
9275
- WorkbenchHostDock,
9441
+ WorkbenchHostSurfaceRenderErrorBoundary,
9276
9442
  {
9277
- captureNodePreviewImage,
9278
- context,
9279
9443
  debugDiagnostics: input.debugDiagnostics,
9280
- dockEntries: input.dockEntries,
9281
- dockPlacement: input.dockPlacement,
9282
- dockPreviewCache: input.dockPreviewCache,
9283
- dockStateSource: input.dockStateSource,
9284
- externalStateSource: input.externalStateSource,
9285
- host: input.hostSession,
9286
- i18n: input.hostI18n,
9287
- nodeDefinitions: input.nodeDefinitionByType,
9288
- onDockEntryAction: input.onDockEntryAction,
9289
- onDockEntryClick: input.onDockEntryClick,
9290
- workspaceId: input.workspaceId
9444
+ details: {
9445
+ dockEntryCount: input.dockEntries.length,
9446
+ dockPlacement: input.dockPlacement ?? null
9447
+ },
9448
+ event: "workbench.dock.render_error",
9449
+ fallbackKind: "dock",
9450
+ resetKey: `${input.workspaceId}:dock`,
9451
+ workspaceId: input.workspaceId,
9452
+ children: /* @__PURE__ */ jsx12(
9453
+ WorkbenchHostDock,
9454
+ {
9455
+ captureNodePreviewImage,
9456
+ context,
9457
+ debugDiagnostics: input.debugDiagnostics,
9458
+ dockEntries: input.dockEntries,
9459
+ dockPlacement: input.dockPlacement,
9460
+ dockPreviewCache: input.dockPreviewCache,
9461
+ dockStateSource: input.dockStateSource,
9462
+ externalStateSource: input.externalStateSource,
9463
+ host: input.hostSession,
9464
+ i18n: input.hostI18n,
9465
+ nodeDefinitions: input.nodeDefinitionByType,
9466
+ onDockEntryAction: input.onDockEntryAction,
9467
+ onDockEntryClick: input.onDockEntryClick,
9468
+ workspaceId: input.workspaceId
9469
+ }
9470
+ )
9291
9471
  }
9292
9472
  ),
9293
9473
  [
@@ -9314,17 +9494,32 @@ function useWorkbenchHostSurfaceRenderers(input) {
9314
9494
  if (!definition) {
9315
9495
  return null;
9316
9496
  }
9317
- return definition.renderBody(
9318
- createWorkbenchHostNodeBodyContext({
9319
- context,
9320
- definition,
9321
- externalStateSource: input.externalStateSource,
9322
- host: input.hostSession,
9323
- workspaceId: input.workspaceId
9324
- })
9497
+ const bodyContext = createWorkbenchHostNodeBodyContext({
9498
+ context,
9499
+ definition,
9500
+ externalStateSource: input.externalStateSource,
9501
+ host: input.hostSession,
9502
+ workspaceId: input.workspaceId
9503
+ });
9504
+ return /* @__PURE__ */ jsx12(
9505
+ WorkbenchHostNodeRenderErrorBoundary,
9506
+ {
9507
+ debugDiagnostics: input.debugDiagnostics,
9508
+ node: context.node,
9509
+ resetKey: `${context.node.id}:${context.node.data.typeId}`,
9510
+ workspaceId: input.workspaceId,
9511
+ children: /* @__PURE__ */ jsx12(
9512
+ WorkbenchHostNodeBodyRenderer,
9513
+ {
9514
+ context: bodyContext,
9515
+ definition
9516
+ }
9517
+ )
9518
+ }
9325
9519
  );
9326
9520
  },
9327
9521
  [
9522
+ input.debugDiagnostics,
9328
9523
  input.externalStateSource,
9329
9524
  input.hostSession,
9330
9525
  input.nodeDefinitionByType,
@@ -9435,6 +9630,114 @@ function useWorkbenchHostSurfaceRenderers(input) {
9435
9630
  windowChromeMode
9436
9631
  };
9437
9632
  }
9633
+ var WorkbenchHostSurfaceRenderErrorBoundary = class extends Component {
9634
+ state = {
9635
+ hasError: false
9636
+ };
9637
+ static getDerivedStateFromError() {
9638
+ return { hasError: true };
9639
+ }
9640
+ componentDidUpdate(previousProps) {
9641
+ if (this.state.hasError && previousProps.resetKey !== this.props.resetKey) {
9642
+ this.setState({ hasError: false });
9643
+ }
9644
+ }
9645
+ componentDidCatch(error, info) {
9646
+ try {
9647
+ const result = this.props.debugDiagnostics?.log?.({
9648
+ details: {
9649
+ ...this.props.details ?? {},
9650
+ componentStack: info.componentStack ?? null,
9651
+ errorMessage: error instanceof Error ? error.message : String(error),
9652
+ errorName: error instanceof Error ? error.name : typeof error,
9653
+ errorStack: error instanceof Error ? error.stack ?? null : null
9654
+ },
9655
+ event: this.props.event,
9656
+ level: "error",
9657
+ source: "workbench-host",
9658
+ workspaceId: this.props.workspaceId
9659
+ });
9660
+ void Promise.resolve(result).catch(() => void 0);
9661
+ } catch {
9662
+ }
9663
+ }
9664
+ render() {
9665
+ if (this.state.hasError) {
9666
+ return /* @__PURE__ */ jsx12(
9667
+ "div",
9668
+ {
9669
+ "data-workbench-surface-render-error": this.props.fallbackKind,
9670
+ style: { height: "100%", width: "100%" }
9671
+ }
9672
+ );
9673
+ }
9674
+ return this.props.children;
9675
+ }
9676
+ };
9677
+ var WorkbenchHostNodeRenderErrorBoundary = class extends Component {
9678
+ state = {
9679
+ hasError: false
9680
+ };
9681
+ static getDerivedStateFromError() {
9682
+ return { hasError: true };
9683
+ }
9684
+ componentDidUpdate(previousProps) {
9685
+ if (this.state.hasError && previousProps.resetKey !== this.props.resetKey) {
9686
+ this.setState({ hasError: false });
9687
+ }
9688
+ }
9689
+ componentDidCatch(error, info) {
9690
+ try {
9691
+ const result = this.props.debugDiagnostics?.log?.({
9692
+ details: {
9693
+ componentStack: info.componentStack ?? null,
9694
+ dockEntryId: this.props.node.data.dockEntryId ?? null,
9695
+ displayMode: this.props.node.displayMode,
9696
+ errorMessage: error instanceof Error ? error.message : String(error),
9697
+ errorName: error instanceof Error ? error.name : typeof error,
9698
+ errorStack: error instanceof Error ? error.stack ?? null : null,
9699
+ frame: this.props.node.frame,
9700
+ instanceId: this.props.node.data.instanceId,
9701
+ instanceKey: this.props.node.data.instanceKey ?? null,
9702
+ isMinimized: this.props.node.isMinimized,
9703
+ launchSource: this.props.node.data.launchSource ?? null,
9704
+ nodeId: this.props.node.id,
9705
+ typeId: this.props.node.data.typeId
9706
+ },
9707
+ event: "workbench.node.render_error",
9708
+ level: "error",
9709
+ source: "workbench-host",
9710
+ workspaceId: this.props.workspaceId
9711
+ });
9712
+ void Promise.resolve(result).catch(() => void 0);
9713
+ } catch {
9714
+ }
9715
+ }
9716
+ render() {
9717
+ if (this.state.hasError) {
9718
+ return /* @__PURE__ */ jsx12(
9719
+ "div",
9720
+ {
9721
+ "data-workbench-node-render-error": "true",
9722
+ style: { height: "100%", width: "100%" }
9723
+ }
9724
+ );
9725
+ }
9726
+ return this.props.children;
9727
+ }
9728
+ };
9729
+ function WorkbenchHostNodeBodyRenderer({
9730
+ context,
9731
+ definition
9732
+ }) {
9733
+ return definition.renderBody(context);
9734
+ }
9735
+ function WorkbenchHostChromeRenderer({
9736
+ context,
9737
+ renderChrome
9738
+ }) {
9739
+ return renderChrome(context);
9740
+ }
9438
9741
 
9439
9742
  // src/host/WorkbenchHost.tsx
9440
9743
  import { jsx as jsx13 } from "react/jsx-runtime";