dsh-multipane 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +23 -10
  2. package/lib/client.js +375 -61
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # dsh-split-view
1
+ # dsh-multipane(多栏视图)
2
2
 
3
3
  Hermes 式多栏工作区,接管 DSH 主区:每栏一条自己的标签条、拖拽分栏、可关闭,最多四栏。
4
4
 
@@ -6,18 +6,22 @@ Hermes 式多栏工作区,接管 DSH 主区:每栏一条自己的标签条
6
6
 
7
7
  需要 DSH `0.2.1-rc.5` 及以上。装完**重启 DSH** 才会生效。
8
8
 
9
+ > **名字必须三处一致**:`package.json` 的 `name`、`cordis.patch.yml` 的 `name`、`lib/client.js` 里的模块 `id`
10
+ > 三者要完全相同,否则 DSH 会静默不加载(控制台报 `import failed` / `duplicate factory registration`)。
11
+ > 所以本项目**不做发布期改名**,本地开发名和 npm 包名就是同一个 `dsh-multipane`。
12
+
9
13
  ### 方式一(推荐):npm
10
14
 
11
15
  在 DSH「设置 → 添加插件」里粘贴包名:
12
16
 
13
17
  ```
14
- @weiaisuyansjd/dsh-split-view
18
+ dsh-multipane
15
19
  ```
16
20
 
17
21
  或者命令行:
18
22
 
19
23
  ```sh
20
- npx @deepseek-ai/dsh plugin --profile desktop add @weiaisuyansjd/dsh-split-view
24
+ npx @deepseek-ai/dsh plugin --profile desktop add dsh-multipane
21
25
  ```
22
26
 
23
27
  npm 走公共 registry,有国内镜像可用,比 GitHub 稳。
@@ -30,24 +34,31 @@ npm 走公共 registry,有国内镜像可用,比 GitHub 稳。
30
34
  npx @deepseek-ai/dsh plugin --profile desktop add github:weiaisuyan/dsh-split-view
31
35
  ```
32
36
 
33
- ### ⚠️ 不要和 npm 上的 `dsh-split-view` 混装
37
+ 仓库名仍是 `dsh-split-view`,但包名取自 `package.json`,装下来同样叫 `dsh-multipane`。
38
+
39
+ ### ⚠️ 别和作者 luckybilly 的 `dsh-split-view` 同时启用
34
40
 
35
- npm 上有一个**同名不同源**的插件 `dsh-split-view`(作者 luckybilly),它也是给 DSH 做多会话分屏的,但实现路线完全不同(每栏跑一个 iframe 客户端)。两者装名会撞车:
41
+ npm 上另有一个插件 `dsh-split-view`(作者 luckybilly),也是给 DSH 做多会话分屏,实现路线完全不同(每栏跑一个 iframe 客户端)。
36
42
 
37
43
  | 来源 | 安装名 |
38
44
  | --- | --- |
39
- | 本插件(npm) | `@weiaisuyansjd/dsh-split-view` |
40
- | 本插件(GitHub 直装) | `dsh-split-view`(取自仓库 package.json) |
45
+ | 本插件(npm / GitHub 装法都一样) | `dsh-multipane` |
41
46
  | 另一个作者的插件 | `dsh-split-view` |
42
47
 
43
- 也就是说 **GitHub 直装的版本和 luckybilly 那个包同名**。两个都装会互相覆盖,表现出来是「插件时有时无、改了没反应」。装之前先确认机器上没有另一个 `dsh-split-view`。
48
+ 两者**名字不同、不会互相覆盖**,但都在抢主区,同时启用会互相打架(栏结构错乱、设置页串台)。只留一个,装前先确认:
49
+
50
+ ```sh
51
+ npx @deepseek-ai/dsh plugin list | grep split-view
52
+ ```
53
+
54
+ 如果你装过本插件的旧版本(`@weiaisuyansjd/dsh-split-view`,或 GitHub 直装的 `dsh-split-view`),先按下面的命令卸掉再装新版。
44
55
 
45
56
  ### 卸载
46
57
 
47
58
  ```sh
48
- # npm 装的
59
+ npx @deepseek-ai/dsh plugin --profile desktop remove dsh-multipane
60
+ # 旧版本(如果装过)
49
61
  npx @deepseek-ai/dsh plugin --profile desktop remove @weiaisuyansjd/dsh-split-view
50
- # GitHub 装的
51
62
  npx @deepseek-ai/dsh plugin --profile desktop remove dsh-split-view
52
63
  ```
53
64
 
@@ -58,6 +69,8 @@ npx @deepseek-ai/dsh plugin --profile desktop remove dsh-split-view
58
69
  - **npm 装**:重跑一次 `add`(或先 `remove` 再 `add`)
59
70
  - **GitHub 装**:必须 `remove` 后重新 `add`,否则不会拉到新提交
60
71
 
72
+ 升级/换装都不会丢布局:栏、标签、栏宽存在 `localStorage`(键名固定为 `dsh-split-view:*`,与包名无关)。
73
+
61
74
  ## 交互
62
75
 
63
76
  | 动作 | 结果 |
package/lib/client.js CHANGED
@@ -971,6 +971,10 @@ window.__ModuleLoader__.load({
971
971
  .dsv-paneheader[data-drop="1"]{outline:var(--dsv-line-w,2px) dashed var(--dsv-line,#a7aaaf);outline-offset:calc(-1 * var(--dsv-line-w,2px))}
972
972
  .dsv-panes{display:flex;flex-direction:row;flex:1 1 auto;min-width:0;min-height:0;overflow:hidden}
973
973
  .dsv-pane{display:flex;flex-direction:column;min-width:0;min-height:0;position:relative;overflow:hidden;background:var(--dsh-surface-color,transparent);padding-top:calc(var(--dsv-head-h,45px) - var(--dsv-host-offset,0px))}
974
+ /* 拖文件时目标栏的高亮。宿主那个全屏「拖到此处添加」遮罩在多栏下会盖住其它栏、
975
+ 让人根本没法选目标栏,所以拖动期间不渲染宿主附件组件,改用这一圈边 + 淡淡底色。 */
976
+ .dsv-pane[data-drop-target="1"]{outline:2px solid var(--dsv-tab-accent,#4a8cf7);outline-offset:-2px}
977
+ .dsv-pane[data-drop-target="1"]::after{content:"";position:absolute;inset:0;z-index:4;pointer-events:none;background:color-mix(in srgb,var(--dsv-tab-accent,#4a8cf7) 8%,transparent)}
974
978
  .dsv-pane[data-drop="1"]{outline:var(--dsv-line-w,2px) dashed var(--dsv-line,#a7aaaf);outline-offset:calc(-1 * var(--dsv-line-w,2px))}
975
979
  .dsv-pane[data-focus="1"] .dsv-tab[data-active="1"]{background:var(--dsh-surface-raised-color,rgba(128,128,128,.14))}
976
980
  .dsv-pane[data-drop-side="left"]{box-shadow:inset var(--dsv-line-w,2px) 0 0 var(--dsv-line,#a7aaaf)}
@@ -2334,6 +2338,222 @@ window.__ModuleLoader__.load({
2334
2338
  delete pane.dataset.drop;
2335
2339
  }
2336
2340
 
2341
+ /**
2342
+ * 侧栏折叠时,标签条左侧必须让出的宿主控件宽度。
2343
+ *
2344
+ * 窗口最顶那一行(y=0~40)左侧是宿主自己画的 caption 控件:「收起/展开侧边栏」按钮、
2345
+ * 折叠时才出现的「新建会话」,以及 Desktop preload 注入的应用菜单
2346
+ * (`[data-windows-menu]`,shadow DOM,`left: var(--dsh-windows-menu-start)`,
2347
+ * 展开 48px / 折叠 84px)。标签条是 `position:fixed` + `z-index:60` 贴在最顶端那一行,
2348
+ * 侧栏一折叠,栏就贴到窗口左缘(left=0),整条铺过去会把它们压在底下——看不见也点不到。
2349
+ *
2350
+ * 让出的宽度按宿主元素实时量,不写常数(宿主换布局、改菜单起点时自动跟随)。
2351
+ * 竖排模式(`.dsv-panes[data-narrow="1"]`)下 header 回到 static、不再覆盖那一行,返回 0。
2352
+ *
2353
+ * @param paneEl - 当前栏的根元素
2354
+ * @returns 需要右移并收窄的像素数;侧栏展开或竖排时返回 0
2355
+ */
2356
+ function paneLeftGuard(paneEl) {
2357
+ const panes = document.querySelector(".dsv-panes");
2358
+ if (panes !== null && panes.getAttribute("data-narrow") === "1") return 0;
2359
+ const rect = paneEl === null || paneEl === void 0 ? null : paneEl.getBoundingClientRect();
2360
+ if (rect === null || !(rect.left <= 8)) return 0;
2361
+ const menu = document.querySelector("[data-windows-menu]");
2362
+ if (menu === null) return 0;
2363
+ return Math.max(0, Math.round(menu.getBoundingClientRect().right) + 8 - rect.left);
2364
+ }
2365
+
2366
+ /* ===== 拖放定向:只让「指针所在那一栏」的 composer 接住掉进来的文件 =====
2367
+ *
2368
+ * 宿主的 ComposerAttachments 每渲染一个实例就往 document 上装一套 dragenter/drop
2369
+ * 监听器,而它的 canAcceptDrop 只看会话自身状态
2370
+ * (!uploadDenied && (subagent===null||continuable) && !locked && !machineBusy && addFiles!==undefined),
2371
+ * 完全不看这一栏是不是用户要放的那一栏。多栏并排时一次 drop 会被 N 个 composer
2372
+ * 全部接住 → 每个栏的草稿里都出现同一个文件。
2373
+ *
2374
+ * 这里注册宿主的 `conversation.input.attachments` 槽位(kind:single,可被插件覆盖),
2375
+ * 拖动期间只让落点所在栏渲染宿主原组件,其余栏返回 null —— 它们连监听器都不会装。
2376
+ * 拿不到宿主原组件时(宿主升级改了槽位形状)不注册,行为退回宿主默认,不会更差。 */
2377
+
2378
+ /** 拖动期间落点所在栏的 id;null = 当前没有拖动。 */
2379
+ let DROP_PANE_ID = null;
2380
+ /** 是否正在拖文件(决定「宿主附件组件要不要卸载」和「栏高亮」)。 */
2381
+ let DRAG_ACTIVE = false;
2382
+ /** 落点变化的订阅者(槽位组件用它触发重渲染)。 */
2383
+ const DROP_SUBSCRIBERS = new Set();
2384
+ /** paneId → 该栏 composer 的 onAddFiles(宿主组件卸载前记下来,drop 时直接调)。 */
2385
+ const PANE_INTAKE = new Map();
2386
+ /** 宿主原来的附件组件(覆盖槽位前从注册表里取出来的引用)。 */
2387
+ let HOST_ATTACHMENTS = null;
2388
+ /** 宿主那份注册的注入值(`readFileDrag` 等)—— 直接调用宿主组件的 inject,免得到处找服务。 */
2389
+ let HOST_ATTACH_INJECT = {};
2390
+
2391
+ /** 当前组件树属于哪一栏(Pane 渲染内容时用 Provider 注入)。 */
2392
+ const PaneIdCtx = react.createContext(null);
2393
+
2394
+ /** 通知所有订阅者(槽位组件重渲染)。 */
2395
+ function notifyDropSubscribers() {
2396
+ for (const fn of [...DROP_SUBSCRIBERS]) {
2397
+ try {
2398
+ fn();
2399
+ } catch {
2400
+ /* 单个订阅者出错不影响别的 */
2401
+ }
2402
+ }
2403
+ }
2404
+
2405
+ /**
2406
+ * 开关「正在拖文件」。
2407
+ *
2408
+ * 它和「落点在哪一栏」必须分开:拖到侧栏 / 底栏时落点是 none,但仍然要算「正在拖」,
2409
+ * 否则宿主附件组件会被重新渲染回来、重新装上 document 监听器,文件又会被接受。
2410
+ */
2411
+ function setDragActiveFlag(active) {
2412
+ if (DRAG_ACTIVE === active) return;
2413
+ DRAG_ACTIVE = active;
2414
+ if (active !== true) setDropPaneTarget(null);
2415
+ else notifyDropSubscribers();
2416
+ }
2417
+
2418
+ /** 设置落点栏并打高亮标记(null = 不在任何栏内,清掉全部高亮)。 */
2419
+ function setDropPaneTarget(paneId) {
2420
+ if (DROP_PANE_ID === paneId) return;
2421
+ DROP_PANE_ID = paneId;
2422
+ for (const pane of document.querySelectorAll(".dsv-pane")) {
2423
+ if (paneId !== null && pane.getAttribute("data-pane-id") === paneId) pane.setAttribute("data-drop-target", "1");
2424
+ else pane.removeAttribute("data-drop-target");
2425
+ }
2426
+ notifyDropSubscribers();
2427
+ }
2428
+
2429
+ /** 指针坐标落在哪个 .dsv-pane 上;不在任何栏上返回 null。 */
2430
+ function paneIdAt(x, y) {
2431
+ const el = document.elementFromPoint(x, y);
2432
+ if (el === null || el === void 0 || typeof el.closest !== "function") return null;
2433
+ const pane = el.closest(".dsv-pane");
2434
+ return pane === null ? null : pane.getAttribute("data-pane-id");
2435
+ }
2436
+
2437
+ /** 焦点栏的 id(drop 落在栏外时兜底用它)。 */
2438
+ function focusedPaneId() {
2439
+ const pane = document.querySelector('.dsv-pane[data-focus="1"]');
2440
+ return pane === null ? null : pane.getAttribute("data-pane-id");
2441
+ }
2442
+
2443
+ /** 事件是不是「外部拖进来的文件」。 */
2444
+ function isFileDrag(event) {
2445
+ const dt = event.dataTransfer;
2446
+ if (dt === null || dt === void 0 || dt.types === void 0) return false;
2447
+ return dt.types.includes("Files") || dt.types.includes("application/x-dsh-file");
2448
+ }
2449
+
2450
+ /**
2451
+ * 在 document 捕获阶段接管整条文件拖放链。
2452
+ *
2453
+ * 为什么必须在捕获阶段、且自己派发:宿主的附件组件是「每个 composer 一套 document
2454
+ * 监听器,canAcceptDrop 只看会话自身状态、不看焦点」,多栏下一次 drop 会被 N 栏全接住。
2455
+ * 拖动一开始就把宿主组件全部卸载(见 SplitAttachmentsSlot),这里负责
2456
+ * ① 跟踪落点并高亮目标栏 ② drop 时只把文件交给落点那一栏的 composer。
2457
+ */
2458
+ function installDropPaneTracking() {
2459
+ const onEnter = (event) => {
2460
+ if (!isFileDrag(event)) return;
2461
+ /* 只要带文件进窗口就算「正在拖」—— 先卸载宿主附件组件(连带它的全屏遮罩),
2462
+ 再看落点在哪一栏。 */
2463
+ setDragActiveFlag(true);
2464
+ setDropPaneTarget(paneIdAt(event.clientX, event.clientY));
2465
+ };
2466
+ const onOver = (event) => {
2467
+ if (!isFileDrag(event)) return;
2468
+ const paneId = paneIdAt(event.clientX, event.clientY);
2469
+ if (paneId === null) {
2470
+ /* 侧栏 / 底栏 / 顶部标题栏这些地方**不接受投放**:
2471
+ 不 preventDefault → 浏览器判定这里不是合法投放区(光标显示禁止),
2472
+ drop 根本不会发生。但仍然保持 DRAG_ACTIVE,别让宿主组件回魂。 */
2473
+ if (event.dataTransfer !== null && event.dataTransfer !== void 0) event.dataTransfer.dropEffect = "none";
2474
+ setDropPaneTarget(null);
2475
+ return;
2476
+ }
2477
+ event.preventDefault();
2478
+ if (event.dataTransfer !== null && event.dataTransfer !== void 0) event.dataTransfer.dropEffect = "copy";
2479
+ setDragActiveFlag(true);
2480
+ setDropPaneTarget(paneId);
2481
+ };
2482
+ const onLeave = (event) => {
2483
+ const out =
2484
+ event.clientX <= 0 ||
2485
+ event.clientY <= 0 ||
2486
+ event.clientX >= window.innerWidth ||
2487
+ event.clientY >= window.innerHeight;
2488
+ if (out) setDragActiveFlag(false);
2489
+ };
2490
+ const onEnd = () => setDragActiveFlag(false);
2491
+ const onDrop = (event) => {
2492
+ if (!isFileDrag(event)) return;
2493
+ const paneId = paneIdAt(event.clientX, event.clientY);
2494
+ const files = [...(event.dataTransfer?.files ?? [])];
2495
+ setDragActiveFlag(false);
2496
+ /* 只接受落在栏内的投放。落在侧栏 / 底栏(正常不会有 drop 事件)一律丢弃,
2497
+ 不做「兜底给焦点栏」—— 用户要的是「只能拖到显示区」。 */
2498
+ if (paneId === null || files.length === 0) return;
2499
+ event.preventDefault();
2500
+ event.stopPropagation();
2501
+ const intake = PANE_INTAKE.get(paneId);
2502
+ if (typeof intake !== "function") return;
2503
+ try {
2504
+ intake(files);
2505
+ } catch (error) {
2506
+ console.warn("[split-view] 投放文件到目标栏失败:", error);
2507
+ }
2508
+ };
2509
+ document.addEventListener("dragenter", onEnter, true);
2510
+ document.addEventListener("dragover", onOver, true);
2511
+ document.addEventListener("dragleave", onLeave, true);
2512
+ document.addEventListener("drop", onDrop, true);
2513
+ window.addEventListener("dragend", onEnd, true);
2514
+ return () => {
2515
+ document.removeEventListener("dragenter", onEnter, true);
2516
+ document.removeEventListener("dragover", onOver, true);
2517
+ document.removeEventListener("dragleave", onLeave, true);
2518
+ document.removeEventListener("drop", onDrop, true);
2519
+ window.removeEventListener("dragend", onEnd, true);
2520
+ setDragActiveFlag(false);
2521
+ };
2522
+ }
2523
+
2524
+ /**
2525
+ * 宿主 `conversation.input.attachments` 槽位的替代实现。
2526
+ *
2527
+ * · 平时:原样渲染宿主组件(附件栏、缩略图、上传进度都不变)。
2528
+ * · 拖文件期间:整栏返回 null —— 宿主的全屏遮罩就是它自己画的,留着会盖住其它栏、
2529
+ * 让人根本没法选目标栏;这时改用栏级高亮(data-drop-target)。
2530
+ * · 无论渲染与否,都把本栏的 onAddFiles 记进 PANE_INTAKE,drop 落到本栏时才有一份可调用的入口。
2531
+ */
2532
+ function SplitAttachmentsSlot(props) {
2533
+ const paneId = react.useContext(PaneIdCtx);
2534
+ const [dragState, setLocalDragState] = react.useState({ active: DRAG_ACTIVE, pane: DROP_PANE_ID });
2535
+ react.useEffect(() => {
2536
+ const fn = () => setLocalDragState({ active: DRAG_ACTIVE, pane: DROP_PANE_ID });
2537
+ DROP_SUBSCRIBERS.add(fn);
2538
+ fn();
2539
+ return () => {
2540
+ DROP_SUBSCRIBERS.delete(fn);
2541
+ };
2542
+ }, []);
2543
+ react.useEffect(() => {
2544
+ if (paneId === null || paneId === void 0) return;
2545
+ const intake = props.onAddFiles;
2546
+ PANE_INTAKE.set(paneId, intake);
2547
+ return () => {
2548
+ if (PANE_INTAKE.get(paneId) === intake) PANE_INTAKE.delete(paneId);
2549
+ };
2550
+ }, [paneId, props.onAddFiles]);
2551
+ const Host = HOST_ATTACHMENTS;
2552
+ if (Host === null || Host === void 0) return null;
2553
+ if (dragState.active === true) return null;
2554
+ return h(Host, { ...HOST_ATTACH_INJECT, ...props });
2555
+ }
2556
+
2337
2557
  /**
2338
2558
  * One tab in the shared strip. Middle-click and double-click both close it,
2339
2559
  * which is what the Hermes-style workflow expects.
@@ -2475,8 +2695,10 @@ window.__ModuleLoader__.load({
2475
2695
  const cs = getComputedStyle(node);
2476
2696
  const inner = node.clientWidth - (parseFloat(cs.paddingLeft) || 0) - (parseFloat(cs.paddingRight) || 0);
2477
2697
  /* pane 本身没有 padding(padding 在 header 上),所以这里不额外扣。
2478
- header 的左右 padding 与 + 按钮宽度统一在下面 stripW 里扣。 */
2479
- setHeadW(Math.max(0, Math.round(inner)));
2698
+ header 的左右 padding 与 + 按钮宽度统一在下面 stripW 里扣。
2699
+ 侧栏折叠时标签条要整体右移让出宿主左上控件,可用宽度同步扣掉那一份;
2700
+ 用 paneEl 而不是 node 量,避免拿已经右移过的 header 反复叠算。 */
2701
+ setHeadW(Math.max(0, Math.round(inner) - (paneEl === null ? 0 : paneLeftGuard(paneEl))));
2480
2702
  };
2481
2703
  read();
2482
2704
  const observer = typeof ResizeObserver === "function" ? new ResizeObserver(read) : null;
@@ -2516,8 +2738,13 @@ window.__ModuleLoader__.load({
2516
2738
  if (paneEl === null) return;
2517
2739
  const sync = () => {
2518
2740
  const rect = paneEl.getBoundingClientRect();
2519
- const left = `${Math.round(rect.left)}px`;
2520
- const width = `${Math.round(rect.width)}px`;
2741
+ /* 侧栏折叠时栏贴到窗口左缘(left=0),但窗口最顶那一行左边还有宿主的控件:
2742
+ 收起/展开侧边栏、折叠时的「新建会话」、应用/编辑菜单([data-windows-menu])。
2743
+ 标签条是 fixed + z-index:60,从 0 铺过去会把它们整个盖住(看不见也点不到)。
2744
+ 这里整体右移并等比收窄,把那一小块还给宿主;侧栏展开/竖排时 guard=0,行为不变。 */
2745
+ const guard = paneLeftGuard(paneEl);
2746
+ const left = `${Math.round(rect.left + guard)}px`;
2747
+ const width = `${Math.max(0, Math.round(rect.width) - guard)}px`;
2521
2748
  if (head.style.left !== left) head.style.left = left;
2522
2749
  if (head.style.width !== width) head.style.width = width;
2523
2750
  };
@@ -2602,6 +2829,14 @@ window.__ModuleLoader__.load({
2602
2829
  actions.setHover(null);
2603
2830
  },
2604
2831
  onDrop: (event) => {
2832
+ /* 外部文件拖拽(我们自己的标签/会话都不在拖):**原样放行**。
2833
+ 宿主的 @deepseek-ai/dsh-client-ui-attachment 在 document 上挂了
2834
+ dragenter/drop 监听,靠 dragDepth 计数器控制「拖到此处添加」遮罩;
2835
+ drop 是外部拖拽唯一能把它归零的时刻(window 的 dragend 只对页面内
2836
+ 发起的拖拽触发)。这里一旦 stopPropagation,宿主收不到 drop →
2837
+ 计数器永久卡住 → 遮罩常驻且界面没有任何退出入口。
2838
+ 标签/会话的正常拖拽照旧走下面的 preventDefault + stopPropagation。 */
2839
+ if (drag.sessionId === null && drag.tab === null) return;
2605
2840
  event.preventDefault();
2606
2841
  event.stopPropagation();
2607
2842
  if (drag.tab !== null && drag.tab.paneId === pane.id) {
@@ -2869,6 +3104,9 @@ window.__ModuleLoader__.load({
2869
3104
  actions.setHover(null);
2870
3105
  },
2871
3106
  onDrop: (event) => {
3107
+ /* 同 PaneHeader:外部文件拖拽一律放行,让宿主的 document 级 drop
3108
+ 收到并重置 dragDepth(否则「拖到此处添加」遮罩永久常驻)。 */
3109
+ if (drag.sessionId === null && drag.tab === null) return;
2872
3110
  event.preventDefault();
2873
3111
  event.stopPropagation();
2874
3112
  if (event.target instanceof Element && event.target.closest(".dsv-paneheader") !== null) return;
@@ -2921,16 +3159,21 @@ window.__ModuleLoader__.load({
2921
3159
  h(
2922
3160
  "div",
2923
3161
  { className: "dsv-body" },
2924
- h(TabContentMemo, {
2925
- key: `${active?.id ?? "none"}::${sessionId ?? "blank"}`,
2926
- sessionId,
2927
- hero,
2928
- sessions,
2929
- renderFactorySlot,
2930
- SessionProvider,
2931
- renderSlot,
2932
- viewBarOn: viewBar.enabled === true
2933
- })
3162
+ /* 把「这一栏的 id」注入组件树:宿主的附件槽位组件靠它判断自己属于哪一栏。 */
3163
+ h(
3164
+ PaneIdCtx.Provider,
3165
+ { value: pane.id },
3166
+ h(TabContentMemo, {
3167
+ key: `${active?.id ?? "none"}::${sessionId ?? "blank"}`,
3168
+ sessionId,
3169
+ hero,
3170
+ sessions,
3171
+ renderFactorySlot,
3172
+ SessionProvider,
3173
+ renderSlot,
3174
+ viewBarOn: viewBar.enabled === true
3175
+ })
3176
+ )
2934
3177
  ),
2935
3178
  /* bottom 模式不再画在栏内底部 —— 它由 StatusBar 挂到底栏左边
2936
3179
  (用户要求:切换条在底部时搬到最底那行的左侧,统计信息挪右边)。 */
@@ -6130,58 +6373,129 @@ window.__ModuleLoader__.load({
6130
6373
  syncSettingsFlag();
6131
6374
  SERVICES.ctx = ctx;
6132
6375
 
6376
+ /* 拖放定向:接管宿主的 `conversation.input.attachments` 槽位。
6377
+ 拿得到宿主原组件才接管;拿不到(宿主升级改了槽位形状)就不注册,
6378
+ 行为退回宿主默认(多栏拖文件仍会加到每一栏),不会更差。 */
6379
+ ctx.effect(() => {
6380
+ let stopTracking = null;
6381
+ let disposeSlot = null;
6382
+ /* 真正接管。宿主那个槽位可能比本插件晚注册,所以「读 entry + 注册」必须
6383
+ 放在 inject 回调里等它就绪,不能在 effect 顶层直接读。 */
6384
+ const attach = () => {
6385
+ if (disposeSlot !== null) return;
6386
+ const slots = service("slots");
6387
+ const entry = (slots?.entries?.("conversation.input.attachments") ?? [])[0];
6388
+ if (entry === void 0 || typeof entry.component !== "function") return;
6389
+ HOST_ATTACHMENTS = entry.component;
6390
+ /* 宿主那份注册带 inject(readFileDrag 等),直接调它拿到注入值,
6391
+ 包一层再传给原组件,免得自己去找这些服务。 */
6392
+ try {
6393
+ HOST_ATTACH_INJECT = typeof entry.inject === "function" ? entry.inject() ?? {} : {};
6394
+ } catch {
6395
+ HOST_ATTACH_INJECT = {};
6396
+ }
6397
+ if (stopTracking === null) stopTracking = installDropPaneTracking();
6398
+ /* single 槽必须指定不同的 priority 才能顶掉已有的注册(数值最低者渲染);
6399
+ 宿主那份是 priority 0,所以这里用 -1。 */
6400
+ disposeSlot = slots.register(
6401
+ { name: "conversation.input.attachments", priority: -1, locale: "conversation" },
6402
+ SplitAttachmentsSlot
6403
+ );
6404
+ };
6405
+ let sub = null;
6406
+ try {
6407
+ sub = ctx.slots.inject("conversation.input.attachments", attach);
6408
+ } catch (error) {
6409
+ console.warn("[split-view] 附件槽位 inject 失败:", error);
6410
+ }
6411
+ /* 槽位若已就绪,inject 可能已同步回调;再补一次幂等尝试。 */
6412
+ try {
6413
+ attach();
6414
+ } catch (error) {
6415
+ console.warn("[split-view] 接管附件槽位失败,拖放定向未启用:", error);
6416
+ }
6417
+ if (disposeSlot === null) {
6418
+ console.warn("[split-view] 未找到宿主附件槽位组件,拖放定向未启用(多栏拖文件仍会加到每一栏)");
6419
+ }
6420
+ return () => {
6421
+ if (stopTracking !== null) {
6422
+ try {
6423
+ stopTracking();
6424
+ } catch {
6425
+ /* 忽略 */
6426
+ }
6427
+ }
6428
+ if (typeof sub === "function") {
6429
+ try {
6430
+ sub();
6431
+ } catch {
6432
+ /* 忽略 */
6433
+ }
6434
+ }
6435
+ if (disposeSlot !== null) {
6436
+ try {
6437
+ disposeSlot();
6438
+ } catch {
6439
+ /* 忽略 */
6440
+ }
6441
+ }
6442
+ HOST_ATTACHMENTS = null;
6443
+ HOST_ATTACH_INJECT = {};
6444
+ };
6445
+ }, "dsh-split-view: attachments drop routing");
6446
+
6133
6447
  /* 把「锁定标签」作为一项贡献进宿主的**会话右键菜单**。
6134
6448
  标签上右键 → 打开的就是宿主这份菜单(open 见 TabItem),所以标签右键与侧栏会话行右键
6135
6449
  看到的是同一套项:置顶 / 重命名 / 分叉 / 归档 / 复制会话 ID…(全部由宿主注册表提供,
6136
6450
  官方以后新增项自动出现,我们只加「锁定标签」这一条)。
6137
6451
  resolve 在 React 之外被调用 → 只能通过 LIVE_STATE / LIVE_APPLY 读状态、写状态。 */
6138
- ctx.effect(() => {
6139
- let sub = null;
6140
- try {
6141
- /* Cordis 运行时依赖声明:回调里的 inner ctx 才有权访问 contextMenus。
6142
- 顺手把服务引用存 MENUS,供标签右键直接 open 宿主菜单。 */
6143
- sub = ctx.inject(["contextMenus"], (inner) => {
6144
- MENUS = inner.contextMenus;
6145
- try {
6146
- inner.contextMenus.register({
6147
- id: "session.dsv-tab-lock",
6148
- target: "session",
6149
- order: 900,
6150
- resolve: (value) => {
6151
- const sessionId = value !== null && value !== void 0 ? value.sessionId : void 0;
6152
- const state = LIVE_STATE;
6153
- if (typeof sessionId !== "string" || state === null) return [];
6154
- const hit = findSession(state, sessionId);
6155
- if (hit === void 0) return [];
6156
- const locked = hit.tab.locked === true;
6157
- return [
6158
- {
6159
- id: "dsv-tab-lock",
6160
- label: locked ? "解锁标签" : "锁定标签",
6161
- separatorBefore: true,
6162
- run: () => {
6163
- if (typeof LIVE_APPLY !== "function") return;
6164
- LIVE_APPLY((prev) => toggleLockTab(prev, hit.pane.id, hit.tab.id));
6165
- }
6166
- }
6167
- ];
6168
- }
6169
- });
6170
- } catch (error) {
6171
- console.warn("[split-view] 注册会话菜单项失败:", error);
6172
- }
6173
- });
6174
- } catch (error) {
6175
- console.warn("[split-view] contextMenus 注入失败:", error);
6176
- }
6177
- return () => {
6178
- MENUS = null;
6179
- try {
6180
- if (sub !== null && typeof sub.dispose === "function") sub.dispose();
6181
- } catch {
6182
- /* 忽略 */
6183
- }
6184
- };
6452
+ ctx.effect(() => {
6453
+ let sub = null;
6454
+ try {
6455
+ /* Cordis 运行时依赖声明:回调里的 inner ctx 才有权访问 contextMenus。
6456
+ 顺手把服务引用存 MENUS,供标签右键直接 open 宿主菜单。 */
6457
+ sub = ctx.inject(["contextMenus"], (inner) => {
6458
+ MENUS = inner.contextMenus;
6459
+ try {
6460
+ inner.contextMenus.register({
6461
+ id: "session.dsv-tab-lock",
6462
+ target: "session",
6463
+ order: 900,
6464
+ resolve: (value) => {
6465
+ const sessionId = value !== null && value !== void 0 ? value.sessionId : void 0;
6466
+ const state = LIVE_STATE;
6467
+ if (typeof sessionId !== "string" || state === null) return [];
6468
+ const hit = findSession(state, sessionId);
6469
+ if (hit === void 0) return [];
6470
+ const locked = hit.tab.locked === true;
6471
+ return [
6472
+ {
6473
+ id: "dsv-tab-lock",
6474
+ label: locked ? "解锁标签" : "锁定标签",
6475
+ separatorBefore: true,
6476
+ run: () => {
6477
+ if (typeof LIVE_APPLY !== "function") return;
6478
+ LIVE_APPLY((prev) => toggleLockTab(prev, hit.pane.id, hit.tab.id));
6479
+ }
6480
+ }
6481
+ ];
6482
+ }
6483
+ });
6484
+ } catch (error) {
6485
+ console.warn("[split-view] 注册会话菜单项失败:", error);
6486
+ }
6487
+ });
6488
+ } catch (error) {
6489
+ console.warn("[split-view] contextMenus 注入失败:", error);
6490
+ }
6491
+ return () => {
6492
+ MENUS = null;
6493
+ try {
6494
+ if (sub !== null && typeof sub.dispose === "function") sub.dispose();
6495
+ } catch {
6496
+ /* 忽略 */
6497
+ }
6498
+ };
6185
6499
  }, "dsh-split-view: tab lock session menu");
6186
6500
  SERVICES.sessions = service("sessions");
6187
6501
  SERVICES.layout = service("layout");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-multipane",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Hermes-style tabbed workspace for the DSH main area: drag sessions in, split into up to four columns, close tabs.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",