@michengai/dsh-codex-ui 2.4.6 → 2.4.8
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/CHANGELOG.md +14 -0
- package/CHANGELOG.zh-CN.md +14 -0
- package/lib/client.js +551 -151
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.4.8] - 2026-11-28
|
|
4
|
+
|
|
5
|
+
- **Preserve Third-Party New-Session Action Buttons in Sidebar (Issue #116)**:
|
|
6
|
+
- Keep third-party `sidebar.session.action` buttons (such as the official "DeepSeek Chat Import" button) visible side-by-side in the new-session row while preserving the flat borderless Codex new-session button style;
|
|
7
|
+
- Preserve full sidebar shortcut keys, tooltips, and panel drag-to-pin interactions across both hosted and legacy hosts, while letting external drag-and-drop events pass through untouched.
|
|
8
|
+
|
|
9
|
+
## [2.4.7] - 2026-11-25
|
|
10
|
+
|
|
11
|
+
- **Custom Input Width Restored After Restart and Maximize (Issue #115)**:
|
|
12
|
+
- After you set a custom message/input width, restarting the app and maximizing the window now applies that width immediately; switching to another page and back is no longer required;
|
|
13
|
+
- The new-conversation width handles keep working, including on hosts that publish the saved width directly on the message column.
|
|
14
|
+
- **Floating Conversation Header Follows Your Width**:
|
|
15
|
+
- With the mica floating cards turned on, the conversation header now follows the message column when you drag the input area wider or narrower, and keeps matching it after maximizing the window, switching sessions or returning from a full-page view.
|
|
16
|
+
|
|
3
17
|
## [2.4.6] - 2026-11-25
|
|
4
18
|
|
|
5
19
|
- **Adaptive Auto-Hiding for Unused Default Workspace Section (Issue #114)**:
|
package/CHANGELOG.zh-CN.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## [2.4.8] - 2026-11-28
|
|
4
|
+
|
|
5
|
+
- **保留侧边栏第三方「新会话」扩展按钮入口(Issue #116)**:
|
|
6
|
+
- 修复开启 Codex UI 后「新会话」行内通过 `sidebar.session.action` 注入的官方扩展按钮(如「DeepSeek 会话导入」)不可见的问题,使其与 Codex 无边框扁平样式并排对齐显示;
|
|
7
|
+
- 在原生扩展接管与低版本宿主降级路径下,均完整保留新建会话快捷键提示、气泡与面板拖拽置顶交互,并放行外部拖拽事件。
|
|
8
|
+
|
|
9
|
+
## [2.4.7] - 2026-11-25
|
|
10
|
+
|
|
11
|
+
- **修复自定义输入宽度在重启并最大化后需要切页才恢复的问题(Issue #115)**:
|
|
12
|
+
- 设置过自定义消息/输入宽度后,重启应用并最大化窗口会立即按保存的宽度显示,不再需要切到其他页面再切回;
|
|
13
|
+
- 新建页的宽度拖拽保持可用,包括宿主直接把保存宽度发布到正文节点上的新版本。
|
|
14
|
+
- **浮动会话顶栏跟随输入宽度**:
|
|
15
|
+
- 开启云母悬浮卡片后,拖宽或收窄输入区时会话顶栏会同步跟随;最大化窗口、切换会话或从整页视图返回后仍保持与正文一致。
|
|
16
|
+
|
|
3
17
|
## [2.4.6] - 2026-11-25
|
|
4
18
|
|
|
5
19
|
- **优化工作区分区展示与自适应隐身逻辑(Issue #114)**:
|
package/lib/client.js
CHANGED
|
@@ -417,6 +417,92 @@ html[data-dsh-glass] body:not([data-ds-dark-theme]) .dcu-section-card {
|
|
|
417
417
|
};
|
|
418
418
|
}
|
|
419
419
|
//#endregion
|
|
420
|
+
//#region src/client/theme/header-width.ts
|
|
421
|
+
/**
|
|
422
|
+
* 云母浮动顶栏的宽度跟随。
|
|
423
|
+
*
|
|
424
|
+
* 宿主会按保存的偏好与窗口尺寸算出聊天内容宽度,并把结果发布成 CSS 变量:
|
|
425
|
+
* `0.2.2-rc.5` 发布到会话根节点,`0.2.3-alpha.2` 起改成只发布到正文节点,且把相关变量注册为
|
|
426
|
+
* `inherits: false`。浮动顶栏与正文互为兄弟,挂在顶栏上的规则因此拿不到这个值,只能退回到
|
|
427
|
+
* 按列宽估算的兜底宽度 —— 表现就是「拖宽输入区,顶栏不变」。
|
|
428
|
+
*
|
|
429
|
+
* 这里把正文节点上已经解析好的内容宽度提升到会话根节点,命名空间用插件自己的
|
|
430
|
+
* `--dcu-chat-content-width`,绝不改写宿主变量;正文消失或值还不是绝对长度时删除该变量,
|
|
431
|
+
* 让顶栏回到上游兜底规则。
|
|
432
|
+
*/
|
|
433
|
+
const HOST_CONTENT_WIDTH = "--dsh-chat-content-width";
|
|
434
|
+
const HEADER_WIDTH = "--dcu-chat-content-width";
|
|
435
|
+
const ROOT_SELECTOR = "[data-dsh-glass-frame] [data-phase]";
|
|
436
|
+
const BODY_SELECTOR = "[data-conversation-content]";
|
|
437
|
+
/** 只接受宿主已解析成绝对长度的值;`clamp(...)`、`var(...)` 这类未解析文本交给上游兜底。 */
|
|
438
|
+
const ABSOLUTE_LENGTH = /^\d+(\.\d+)?px$/;
|
|
439
|
+
/**
|
|
440
|
+
* 用宏任务合并同一批突变触发,而不是 requestAnimationFrame:
|
|
441
|
+
* Electron 窗口在后台或被遮挡时 rAF 会被暂停,宿主却照常重排(最大化、切换会话都会触发),
|
|
442
|
+
* 依赖 rAF 会让顶栏钉在旧宽度上,正是要修的现象。
|
|
443
|
+
*/
|
|
444
|
+
const nextFrame = (callback) => setTimeout(callback, 0);
|
|
445
|
+
const cancelFrame = (id) => clearTimeout(id);
|
|
446
|
+
function readContentWidth(body) {
|
|
447
|
+
const value = getComputedStyle(body).getPropertyValue(HOST_CONTENT_WIDTH).trim();
|
|
448
|
+
return ABSOLUTE_LENGTH.test(value) ? value : "";
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* 跟随宿主内容宽度,把结果写到会话根节点。
|
|
452
|
+
*
|
|
453
|
+
* @returns 注销函数:断开全部观察器并清掉插件变量。
|
|
454
|
+
*/
|
|
455
|
+
function startGlassHeaderWidthTracker() {
|
|
456
|
+
if (typeof document === "undefined") return () => {};
|
|
457
|
+
const observed = /* @__PURE__ */ new Set();
|
|
458
|
+
const resizeObserver = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(() => schedule());
|
|
459
|
+
let frame;
|
|
460
|
+
let disposed = false;
|
|
461
|
+
const track = (body) => {
|
|
462
|
+
if (resizeObserver === void 0 || observed.has(body)) return;
|
|
463
|
+
observed.add(body);
|
|
464
|
+
resizeObserver.observe(body);
|
|
465
|
+
};
|
|
466
|
+
const sync = () => {
|
|
467
|
+
frame = void 0;
|
|
468
|
+
if (disposed) return;
|
|
469
|
+
for (const root of document.querySelectorAll(ROOT_SELECTOR)) {
|
|
470
|
+
const bodies = Array.from(root.querySelectorAll(BODY_SELECTOR));
|
|
471
|
+
for (const body of bodies) track(body);
|
|
472
|
+
const visible = bodies.map((body) => ({
|
|
473
|
+
body,
|
|
474
|
+
width: body.getBoundingClientRect().width
|
|
475
|
+
})).sort((left, right) => right.width - left.width)[0];
|
|
476
|
+
const width = visible === void 0 ? "" : readContentWidth(visible.body);
|
|
477
|
+
if (width === "") root.style.removeProperty(HEADER_WIDTH);
|
|
478
|
+
else root.style.setProperty(HEADER_WIDTH, width);
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
function schedule() {
|
|
482
|
+
if (disposed || frame !== void 0) return;
|
|
483
|
+
frame = nextFrame(sync);
|
|
484
|
+
}
|
|
485
|
+
const observer = new MutationObserver(schedule);
|
|
486
|
+
observer.observe(document.documentElement, {
|
|
487
|
+
childList: true,
|
|
488
|
+
subtree: true,
|
|
489
|
+
attributes: true,
|
|
490
|
+
attributeFilter: ["data-phase", "style"]
|
|
491
|
+
});
|
|
492
|
+
window.addEventListener("resize", schedule);
|
|
493
|
+
sync();
|
|
494
|
+
return () => {
|
|
495
|
+
disposed = true;
|
|
496
|
+
observer.disconnect();
|
|
497
|
+
resizeObserver?.disconnect();
|
|
498
|
+
observed.clear();
|
|
499
|
+
window.removeEventListener("resize", schedule);
|
|
500
|
+
if (frame !== void 0) cancelFrame(frame);
|
|
501
|
+
frame = void 0;
|
|
502
|
+
for (const root of document.querySelectorAll(ROOT_SELECTOR)) root.style.removeProperty(HEADER_WIDTH);
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
//#endregion
|
|
420
506
|
//#region src/client/theme/glass.ts
|
|
421
507
|
/**
|
|
422
508
|
* 玻璃质感(Glassmorphism)与云母模式(Mica)生命周期管理
|
|
@@ -502,6 +588,15 @@ html[data-dsh-glass] body:not([data-ds-dark-theme]) .dcu-section-card {
|
|
|
502
588
|
-webkit-backdrop-filter: blur(max(var(--dsh-glass-blur, 12px), 12px)) !important;
|
|
503
589
|
}
|
|
504
590
|
|
|
591
|
+
/* 浮动顶栏宽度跟随正文:新宿主(0.2.3 起)把内容宽度注册为不继承、只写在正文节点上,
|
|
592
|
+
顶栏与正文互为兄弟读不到,只能退回按列宽估算的兜底宽度(拖宽输入区时顶栏不变)。
|
|
593
|
+
这里优先读由 header-width 追踪器提升到会话根的绝对宽度,读不到时保持上游兜底不变。
|
|
594
|
+
必须带上 [data-dsh-glass-float] 门控:平铺(compat)模式没有浮动顶栏卡片,这条只改 max-width
|
|
595
|
+
会把宿主原生顶栏夹成内容宽+32 且不居中。折叠侧栏有自己的通栏规则,同样排除。 */
|
|
596
|
+
[data-dsh-glass-float] [data-dsh-glass-frame]:not([data-sidebar-collapsed]) [data-phase] header:not([class*="headerBlank"]):not(.lc-pulse-header):not([class*="lc-"]) {
|
|
597
|
+
max-width: min(calc(var(--dcu-chat-content-width, var(--dsh-chat-user-width, clamp(680px, calc(var(--dsh-conversation-column-width, 1500px) * 0.64), 920px))) + 32px), calc(100% - 32px));
|
|
598
|
+
}
|
|
599
|
+
|
|
505
600
|
/* 防御 dsh-context 编队卡片样式污染(Issue #113):
|
|
506
601
|
.lc-pulse-header 属于编队内容流内部卡片,严禁继承宿主会话顶栏的浮动排版
|
|
507
602
|
(100% 宽 + 居中最大宽 + 卡片描边 + 20px 圆角 + z-index:8 的高层级定位)。
|
|
@@ -587,6 +682,7 @@ html[data-dsh-glass] body:not([data-ds-dark-theme]) .dcu-section-card {
|
|
|
587
682
|
`;
|
|
588
683
|
let styleTag = null;
|
|
589
684
|
let seamDisposer;
|
|
685
|
+
let headerWidthDisposer;
|
|
590
686
|
/**
|
|
591
687
|
* 应用玻璃质感、排版模式与材质预设
|
|
592
688
|
*/
|
|
@@ -622,6 +718,7 @@ html[data-dsh-glass] body:not([data-ds-dark-theme]) .dcu-section-card {
|
|
|
622
718
|
for (const [prop, val] of Object.entries(knobs)) root.style.setProperty(prop, val);
|
|
623
719
|
if (document.body) for (const [prop, val] of Object.entries(knobs)) document.body.style.setProperty(prop, val);
|
|
624
720
|
if (!seamDisposer) seamDisposer = startGlassSeamStamper();
|
|
721
|
+
if (!headerWidthDisposer) headerWidthDisposer = startGlassHeaderWidthTracker();
|
|
625
722
|
ensureGlassFade(!isCompat);
|
|
626
723
|
}
|
|
627
724
|
const FADE_ATTRIBUTE = "data-dsh-glass-fade";
|
|
@@ -664,6 +761,10 @@ html[data-dsh-glass] body:not([data-ds-dark-theme]) .dcu-section-card {
|
|
|
664
761
|
seamDisposer();
|
|
665
762
|
seamDisposer = void 0;
|
|
666
763
|
}
|
|
764
|
+
if (headerWidthDisposer) {
|
|
765
|
+
headerWidthDisposer();
|
|
766
|
+
headerWidthDisposer = void 0;
|
|
767
|
+
}
|
|
667
768
|
if (styleTag && styleTag.parentNode) {
|
|
668
769
|
styleTag.remove();
|
|
669
770
|
styleTag = null;
|
|
@@ -10806,6 +10907,16 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
10806
10907
|
@keyframes dcu-wsp-spin{to{transform:rotate(360deg)}}
|
|
10807
10908
|
@media(prefers-reduced-motion:reduce){.dcu-wsp-spin{animation-duration:2.4s}}
|
|
10808
10909
|
`;
|
|
10910
|
+
/**
|
|
10911
|
+
* 新建页拖柄唯一允许写入的变量。
|
|
10912
|
+
*
|
|
10913
|
+
* 宿主宽度变量(`--dsh-chat-user-width` / `--dsh-chat-content-width`)由 DSH 自己发布:0.2.2-rc.5 发布到
|
|
10914
|
+
* 会话根节点,0.2.3-alpha.2 改为只发布到正文节点并注册为不继承。插件若把值写进这两个变量,行内样式会
|
|
10915
|
+
* 盖住宿主之后的重算;宿主也不会再改写它,于是正文停在旧宽度,直到正文节点重挂(切页)才恢复(Issue #115)。
|
|
10916
|
+
* 因此这里只写插件私有变量,再由新建页样式映射给宿主变量,且映射规则限定在 `[data-phase=hero]` 内 ——
|
|
10917
|
+
* 离开新建页即自动失效,不需要清理时序配合。
|
|
10918
|
+
*/
|
|
10919
|
+
const HERO_WIDTH_VAR = "--dcu-hero-chat-width";
|
|
10809
10920
|
/** 按用户要求用最窄宽度替代宿主自适应默认;已有有效偏好不重置,拖拽起点沿用宿主存储。 */
|
|
10810
10921
|
function initializeComposerWidth(storage) {
|
|
10811
10922
|
const key = "dsh.conversation.contentWidth";
|
|
@@ -10821,7 +10932,7 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
10821
10932
|
function observeHeroWidthHandles(label) {
|
|
10822
10933
|
const mounted = /* @__PURE__ */ new Map();
|
|
10823
10934
|
const style = document.createElement("style");
|
|
10824
|
-
style.textContent = `[data-phase=hero]:has([data-conversation-scroll]){position:relative}[data-dcu-width-handle]{position:absolute;top:0;bottom:0;width:32px;padding:0;border:0;background:transparent;cursor:col-resize;touch-action:none;z-index:100;outline-offset:-5px}[data-dcu-width-handle=left]{right:calc(50% + var(--
|
|
10935
|
+
style.textContent = `[data-phase=hero]:has([data-conversation-scroll]){position:relative}[data-dcu-width-handle]{position:absolute;top:0;bottom:0;width:32px;padding:0;border:0;background:transparent;cursor:col-resize;touch-action:none;z-index:100;outline-offset:-5px}[data-dcu-width-handle=left]{right:calc(50% + var(--dcu-hero-chat-width, 640px) / 2 + 16px)}[data-dcu-width-handle=right]{left:calc(50% + var(--dcu-hero-chat-width, 640px) / 2 + 16px)}[data-dcu-width-handle]::after{content:'';position:absolute;top:calc(var(--dcu-pointer-y,50%) - 50px);height:100px;width:3px;left:14px;border-radius:3px;background:linear-gradient(transparent,var(--dsw-alias-scrollbar-hover-l1,#888),transparent);opacity:0}[data-dcu-width-handle]:hover::after,[data-dcu-width-handle]:focus-visible::after,[data-dcu-width-handle][data-dragging]::after{opacity:1}[data-phase=hero]:has([data-conversation-composer-overlay]) [data-dcu-width-handle]{display:none}`;
|
|
10825
10936
|
document.head.append(style);
|
|
10826
10937
|
const sync = () => {
|
|
10827
10938
|
for (const [root, dispose] of mounted) if (!root.isConnected || root.dataset.phase !== "hero") {
|
|
@@ -10832,25 +10943,30 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
10832
10943
|
if (mounted.has(root) || !root.querySelector("[data-conversation-scroll]")) continue;
|
|
10833
10944
|
const body = root.querySelector("[class*=\"_body\"]:has([data-conversation-scroll])") ?? root.querySelector("[class*=\"_body\"]");
|
|
10834
10945
|
const clamp = (value) => Math.min(Math.max(640, value), Math.max(640, root.clientWidth - 176));
|
|
10946
|
+
const stored = () => {
|
|
10947
|
+
try {
|
|
10948
|
+
return localStorage.getItem("dsh.conversation.contentWidth") ?? void 0;
|
|
10949
|
+
} catch {
|
|
10950
|
+
return;
|
|
10951
|
+
}
|
|
10952
|
+
};
|
|
10835
10953
|
const current = () => {
|
|
10836
|
-
const
|
|
10837
|
-
|
|
10954
|
+
const own = root.style.getPropertyValue(HERO_WIDTH_VAR);
|
|
10955
|
+
const raw = (root.hasAttribute("data-dcu-hero-width") ? "" : body?.style.getPropertyValue("--dsh-chat-user-width") || getComputedStyle(root).getPropertyValue("--dsh-chat-user-width") || getComputedStyle(root).getPropertyValue("--dsh-chat-content-width")) || own || stored();
|
|
10956
|
+
return clamp(Number.parseFloat(raw ?? "") || 640);
|
|
10838
10957
|
};
|
|
10839
10958
|
const publish = (width, save) => {
|
|
10840
10959
|
const value = clamp(width);
|
|
10841
|
-
|
|
10842
|
-
root.
|
|
10843
|
-
root.style.setProperty("--dsh-chat-content-width", `${value}px`);
|
|
10960
|
+
root.style.setProperty(HERO_WIDTH_VAR, `${value}px`);
|
|
10961
|
+
root.dataset.dcuHeroWidth = "";
|
|
10844
10962
|
if (save) try {
|
|
10845
10963
|
localStorage.setItem("dsh.conversation.contentWidth", String(value));
|
|
10846
10964
|
} catch (error) {
|
|
10847
10965
|
console.warn("[codex-ui] 无法保存输入区宽度。", error);
|
|
10848
10966
|
}
|
|
10849
10967
|
};
|
|
10850
|
-
|
|
10851
|
-
|
|
10852
|
-
root.style.setProperty("--dsh-chat-user-width", `${initialWidth}px`);
|
|
10853
|
-
root.style.setProperty("--dsh-chat-content-width", `${initialWidth}px`);
|
|
10968
|
+
publish(current(), false);
|
|
10969
|
+
const abortDrags = [];
|
|
10854
10970
|
const handles = ["left", "right"].map((side) => {
|
|
10855
10971
|
const handle = document.createElement("button");
|
|
10856
10972
|
handle.type = "button";
|
|
@@ -10859,30 +10975,56 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
10859
10975
|
let origin = 0;
|
|
10860
10976
|
let initial = 640;
|
|
10861
10977
|
let dragging = false;
|
|
10978
|
+
let pointerId;
|
|
10979
|
+
let last = 640;
|
|
10980
|
+
const delta = (event) => initial + (event.clientX - origin) * (side === "right" ? 2 : -2);
|
|
10981
|
+
const onWindowMove = (event) => {
|
|
10982
|
+
if (!dragging || event.pointerId !== pointerId) return;
|
|
10983
|
+
if (event.buttons === 0) {
|
|
10984
|
+
publish(last, true);
|
|
10985
|
+
finish();
|
|
10986
|
+
return;
|
|
10987
|
+
}
|
|
10988
|
+
last = delta(event);
|
|
10989
|
+
publish(last, false);
|
|
10990
|
+
};
|
|
10991
|
+
const onWindowEnd = (event) => {
|
|
10992
|
+
if (!dragging || event.pointerId !== pointerId) return;
|
|
10993
|
+
publish(delta(event), true);
|
|
10994
|
+
finish();
|
|
10995
|
+
};
|
|
10996
|
+
const finish = () => {
|
|
10997
|
+
dragging = false;
|
|
10998
|
+
pointerId = void 0;
|
|
10999
|
+
delete handle.dataset.dragging;
|
|
11000
|
+
window.removeEventListener("pointermove", onWindowMove);
|
|
11001
|
+
window.removeEventListener("pointerup", onWindowEnd);
|
|
11002
|
+
window.removeEventListener("pointercancel", finish);
|
|
11003
|
+
};
|
|
11004
|
+
abortDrags.push(finish);
|
|
10862
11005
|
handle.addEventListener("pointerdown", (event) => {
|
|
10863
11006
|
if (event.button !== 0) return;
|
|
10864
11007
|
event.preventDefault();
|
|
10865
11008
|
origin = event.clientX;
|
|
10866
11009
|
initial = current();
|
|
11010
|
+
last = initial;
|
|
10867
11011
|
dragging = true;
|
|
11012
|
+
pointerId = event.pointerId;
|
|
10868
11013
|
handle.dataset.dragging = "";
|
|
10869
|
-
|
|
11014
|
+
try {
|
|
11015
|
+
handle.setPointerCapture(event.pointerId);
|
|
11016
|
+
} catch {}
|
|
11017
|
+
window.addEventListener("pointermove", onWindowMove);
|
|
11018
|
+
window.addEventListener("pointerup", onWindowEnd);
|
|
11019
|
+
window.addEventListener("pointercancel", finish);
|
|
10870
11020
|
});
|
|
10871
11021
|
handle.addEventListener("pointermove", (event) => {
|
|
10872
11022
|
handle.style.setProperty("--dcu-pointer-y", `${event.clientY - handle.getBoundingClientRect().top}px`);
|
|
10873
|
-
if (dragging) publish(initial + (event.clientX - origin) * (side === "right" ? 2 : -2), false);
|
|
10874
11023
|
});
|
|
10875
|
-
handle.addEventListener("
|
|
10876
|
-
if (!dragging) return;
|
|
10877
|
-
publish(
|
|
10878
|
-
|
|
10879
|
-
delete handle.dataset.dragging;
|
|
10880
|
-
handle.releasePointerCapture(event.pointerId);
|
|
10881
|
-
});
|
|
10882
|
-
handle.addEventListener("lostpointercapture", () => {
|
|
10883
|
-
if (dragging) publish(initial, false);
|
|
10884
|
-
dragging = false;
|
|
10885
|
-
delete handle.dataset.dragging;
|
|
11024
|
+
handle.addEventListener("lostpointercapture", (event) => {
|
|
11025
|
+
if (!dragging || event.pointerId !== pointerId) return;
|
|
11026
|
+
publish(last, true);
|
|
11027
|
+
finish();
|
|
10886
11028
|
});
|
|
10887
11029
|
handle.addEventListener("keydown", (event) => {
|
|
10888
11030
|
if (![
|
|
@@ -10898,7 +11040,10 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
10898
11040
|
return handle;
|
|
10899
11041
|
});
|
|
10900
11042
|
mounted.set(root, () => {
|
|
11043
|
+
abortDrags.forEach((stop) => stop());
|
|
10901
11044
|
handles.forEach((handle) => handle.remove());
|
|
11045
|
+
root.style.removeProperty(HERO_WIDTH_VAR);
|
|
11046
|
+
delete root.dataset.dcuHeroWidth;
|
|
10902
11047
|
});
|
|
10903
11048
|
}
|
|
10904
11049
|
};
|
|
@@ -11810,6 +11955,10 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
11810
11955
|
const NEW_CONVERSATION_STYLE = `
|
|
11811
11956
|
[data-phase=hero]:has([data-conversation-scroll]){container:dcu-new-conversation / inline-size}
|
|
11812
11957
|
[data-phase=hero] [class*="_body"]{--dsh-chat-user-width:inherit}
|
|
11958
|
+
/* 必须 !important:0.2.3 宿主在新建页也会把偏好行内发布到正文节点(--dsh-chat-user-width),
|
|
11959
|
+
普通作者规则压不过行内声明,映射会变成死代码(拖了没反应)。important 只在「新建页 + 插件已接管宽度」
|
|
11960
|
+
时生效,离开相位或注销时标记被移除,行内发布重新接管。 */
|
|
11961
|
+
[data-dcu-hero-width][data-phase=hero] [class*="_body"]{--dsh-chat-user-width:var(--dcu-hero-chat-width)!important}
|
|
11813
11962
|
[data-phase=hero] [data-conversation-scroll][class]{--dsh-composer-side-clearance:16px;justify-content:flex-start;scrollbar-gutter:stable both-edges}
|
|
11814
11963
|
[data-phase=hero] [data-composer-seat]{flex:1 0 auto;min-height:100%}
|
|
11815
11964
|
[data-phase=hero] [data-composer-seat]>:has([class*="_composerHero"]){display:flex;flex:1;flex-direction:column}
|
|
@@ -12083,6 +12232,195 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
12083
12232
|
};
|
|
12084
12233
|
}
|
|
12085
12234
|
//#endregion
|
|
12235
|
+
//#region src/client/sidebar/state.ts
|
|
12236
|
+
let sidebarEnabled = false;
|
|
12237
|
+
const sidebarEnabledListeners = /* @__PURE__ */ new Set();
|
|
12238
|
+
function getSidebarEnabled() {
|
|
12239
|
+
return sidebarEnabled;
|
|
12240
|
+
}
|
|
12241
|
+
function setSidebarEnabled(next) {
|
|
12242
|
+
if (sidebarEnabled === next) return;
|
|
12243
|
+
sidebarEnabled = next;
|
|
12244
|
+
for (const listener of sidebarEnabledListeners) listener();
|
|
12245
|
+
}
|
|
12246
|
+
function subscribeSidebarEnabled(listener) {
|
|
12247
|
+
sidebarEnabledListeners.add(listener);
|
|
12248
|
+
return () => {
|
|
12249
|
+
sidebarEnabledListeners.delete(listener);
|
|
12250
|
+
};
|
|
12251
|
+
}
|
|
12252
|
+
let sessionActionDeclared = false;
|
|
12253
|
+
const sessionActionListeners = /* @__PURE__ */ new Set();
|
|
12254
|
+
function getSessionActionDeclared() {
|
|
12255
|
+
return sessionActionDeclared;
|
|
12256
|
+
}
|
|
12257
|
+
function setSessionActionDeclared(next) {
|
|
12258
|
+
if (sessionActionDeclared === next) return;
|
|
12259
|
+
sessionActionDeclared = next;
|
|
12260
|
+
for (const listener of sessionActionListeners) listener();
|
|
12261
|
+
}
|
|
12262
|
+
function subscribeSessionActionDeclared(listener) {
|
|
12263
|
+
sessionActionListeners.add(listener);
|
|
12264
|
+
return () => {
|
|
12265
|
+
sessionActionListeners.delete(listener);
|
|
12266
|
+
};
|
|
12267
|
+
}
|
|
12268
|
+
let newSessionDropHandler = null;
|
|
12269
|
+
function registerNewSessionDropHandler(handler) {
|
|
12270
|
+
newSessionDropHandler = handler;
|
|
12271
|
+
return () => {
|
|
12272
|
+
if (newSessionDropHandler === handler) newSessionDropHandler = null;
|
|
12273
|
+
};
|
|
12274
|
+
}
|
|
12275
|
+
function getNewSessionDropHandler() {
|
|
12276
|
+
return newSessionDropHandler;
|
|
12277
|
+
}
|
|
12278
|
+
//#endregion
|
|
12279
|
+
//#region src/client/sidebar/NewSessionButton.tsx
|
|
12280
|
+
const IconNewChat = _deepseek_ai_dsh_client_ui_primitives.IconNewChatOutlineMedium ?? _deepseek_ai_dsh_client_ui_primitives.IconNewChatOutlineRegular ?? MessageSquarePlus;
|
|
12281
|
+
const Tooltip = _deepseek_ai_dsh_client_ui_primitives.Tooltip;
|
|
12282
|
+
const ShortcutKeys = _deepseek_ai_dsh_client_ui_primitives.ShortcutKeys;
|
|
12283
|
+
function parseAriaShortcutKeys(aria) {
|
|
12284
|
+
return aria.split("+").map((k) => {
|
|
12285
|
+
const lower = k.trim().toLowerCase();
|
|
12286
|
+
if (lower === "control") return "Ctrl";
|
|
12287
|
+
if (lower === "alt") return "Alt";
|
|
12288
|
+
if (lower === "shift") return "Shift";
|
|
12289
|
+
if (lower === "meta" || lower === "command") return "⌘";
|
|
12290
|
+
return k.trim();
|
|
12291
|
+
});
|
|
12292
|
+
}
|
|
12293
|
+
function extractAriaKeyshortcuts(node) {
|
|
12294
|
+
if (!(0, react.isValidElement)(node)) return void 0;
|
|
12295
|
+
const props = node.props;
|
|
12296
|
+
if (typeof props?.["aria-keyshortcuts"] === "string" && props["aria-keyshortcuts"] !== "") return props["aria-keyshortcuts"];
|
|
12297
|
+
return extractAriaKeyshortcuts(props?.children);
|
|
12298
|
+
}
|
|
12299
|
+
function getNewSessionShortcut(ariaHint) {
|
|
12300
|
+
const domAria = typeof document !== "undefined" ? document.querySelector("button[class*=\"newSession\"]")?.getAttribute("aria-keyshortcuts") || void 0 : void 0;
|
|
12301
|
+
const aria = ariaHint || domAria;
|
|
12302
|
+
if (!aria) return typeof navigator !== "undefined" && /Mac|iPhone|iPod|iPad/i.test(navigator.platform || navigator.userAgent) ? {
|
|
12303
|
+
aria: "⌥⌘N",
|
|
12304
|
+
keys: [
|
|
12305
|
+
"⌥",
|
|
12306
|
+
"⌘",
|
|
12307
|
+
"N"
|
|
12308
|
+
]
|
|
12309
|
+
} : {
|
|
12310
|
+
aria: "Ctrl+Alt+N",
|
|
12311
|
+
keys: [
|
|
12312
|
+
"Ctrl",
|
|
12313
|
+
"Alt",
|
|
12314
|
+
"N"
|
|
12315
|
+
]
|
|
12316
|
+
};
|
|
12317
|
+
return {
|
|
12318
|
+
aria,
|
|
12319
|
+
keys: parseAriaShortcutKeys(aria)
|
|
12320
|
+
};
|
|
12321
|
+
}
|
|
12322
|
+
function readShortcutFromCatalog(ctx) {
|
|
12323
|
+
try {
|
|
12324
|
+
const entry = ((ctx.get?.("shortcuts"))?.catalog?.getSnapshot?.())?.find((row) => row.id === "session.new");
|
|
12325
|
+
if (entry && (entry.aria || entry.keys && entry.keys.length > 0)) return {
|
|
12326
|
+
aria: entry.aria,
|
|
12327
|
+
keys: entry.keys ? [...entry.keys] : void 0
|
|
12328
|
+
};
|
|
12329
|
+
} catch {}
|
|
12330
|
+
}
|
|
12331
|
+
/** 解析宿主 uiWorkspace.startSession;供 HOC 闸门与降级点击共用。 */
|
|
12332
|
+
function resolveStartSession(ctx) {
|
|
12333
|
+
try {
|
|
12334
|
+
const uiWorkspace = ctx.get?.("uiWorkspace") ?? ctx?.uiWorkspace;
|
|
12335
|
+
return typeof uiWorkspace?.startSession === "function" ? () => uiWorkspace.startSession() : void 0;
|
|
12336
|
+
} catch {
|
|
12337
|
+
return;
|
|
12338
|
+
}
|
|
12339
|
+
}
|
|
12340
|
+
/** Codex 风格扁平「新会话」行按钮,复用于 sidebar.session.action HOC 与旧宿主降级模式。 */
|
|
12341
|
+
const NewSessionButton = ({ ctx, label, ariaHint, tooltipDisabled = true }) => {
|
|
12342
|
+
const [startingSession, setStartingSession] = (0, react.useState)(false);
|
|
12343
|
+
const [catalogShortcut, setCatalogShortcut] = (0, react.useState)(() => readShortcutFromCatalog(ctx));
|
|
12344
|
+
(0, react.useEffect)(() => {
|
|
12345
|
+
setCatalogShortcut(readShortcutFromCatalog(ctx));
|
|
12346
|
+
try {
|
|
12347
|
+
return (ctx.get?.("shortcuts"))?.catalog?.subscribe?.(() => {
|
|
12348
|
+
setCatalogShortcut(readShortcutFromCatalog(ctx));
|
|
12349
|
+
});
|
|
12350
|
+
} catch {
|
|
12351
|
+
return;
|
|
12352
|
+
}
|
|
12353
|
+
}, [ctx]);
|
|
12354
|
+
const shortcut = (0, react.useMemo)(() => catalogShortcut ?? getNewSessionShortcut(ariaHint), [catalogShortcut, ariaHint]);
|
|
12355
|
+
const handleStartSession = (0, react.useCallback)(async () => {
|
|
12356
|
+
if (startingSession) return;
|
|
12357
|
+
setStartingSession(true);
|
|
12358
|
+
try {
|
|
12359
|
+
const startSession = resolveStartSession(ctx);
|
|
12360
|
+
if (startSession) await Promise.resolve(startSession());
|
|
12361
|
+
else document.querySelector("button[class*=\"newSession\"]")?.click();
|
|
12362
|
+
} catch (err) {
|
|
12363
|
+
console.warn("startSession failed:", err);
|
|
12364
|
+
} finally {
|
|
12365
|
+
setStartingSession(false);
|
|
12366
|
+
}
|
|
12367
|
+
}, [ctx, startingSession]);
|
|
12368
|
+
const button = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
12369
|
+
type: "button",
|
|
12370
|
+
className: "dcu-sb-row dcu-sb-new-session-row",
|
|
12371
|
+
"aria-label": label,
|
|
12372
|
+
"aria-keyshortcuts": shortcut.aria,
|
|
12373
|
+
"aria-disabled": startingSession,
|
|
12374
|
+
onClick: handleStartSession,
|
|
12375
|
+
onKeyDown: (e) => {
|
|
12376
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
12377
|
+
e.preventDefault();
|
|
12378
|
+
handleStartSession();
|
|
12379
|
+
}
|
|
12380
|
+
},
|
|
12381
|
+
onDragOver: (e) => {
|
|
12382
|
+
const handler = getNewSessionDropHandler();
|
|
12383
|
+
if (!handler?.isDragging()) return;
|
|
12384
|
+
e.preventDefault();
|
|
12385
|
+
e.stopPropagation();
|
|
12386
|
+
if (e.dataTransfer) e.dataTransfer.dropEffect = "move";
|
|
12387
|
+
handler.onDragOver();
|
|
12388
|
+
},
|
|
12389
|
+
onDrop: (e) => {
|
|
12390
|
+
const handler = getNewSessionDropHandler();
|
|
12391
|
+
if (!handler?.isDragging()) return;
|
|
12392
|
+
e.preventDefault();
|
|
12393
|
+
e.stopPropagation();
|
|
12394
|
+
const id = e.dataTransfer?.getData("application/x-dsh-panel-id") || e.dataTransfer?.getData("text/plain") || void 0;
|
|
12395
|
+
handler.onDrop(id);
|
|
12396
|
+
},
|
|
12397
|
+
children: [
|
|
12398
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
12399
|
+
className: "dcu-sb-glyph",
|
|
12400
|
+
"aria-hidden": "true",
|
|
12401
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconNewChat, { size: 16 })
|
|
12402
|
+
}),
|
|
12403
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
12404
|
+
className: "dcu-sb-title",
|
|
12405
|
+
children: label
|
|
12406
|
+
}),
|
|
12407
|
+
ShortcutKeys && shortcut.keys && shortcut.keys.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
12408
|
+
className: "dcu-sb-shortcut",
|
|
12409
|
+
"aria-hidden": "true",
|
|
12410
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShortcutKeys, { keys: shortcut.keys })
|
|
12411
|
+
})
|
|
12412
|
+
]
|
|
12413
|
+
});
|
|
12414
|
+
return Tooltip ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tooltip, {
|
|
12415
|
+
label,
|
|
12416
|
+
shortcutKeys: shortcut.keys,
|
|
12417
|
+
delayMs: 500,
|
|
12418
|
+
side: "right",
|
|
12419
|
+
disabled: tooltipDisabled,
|
|
12420
|
+
children: button
|
|
12421
|
+
}) : button;
|
|
12422
|
+
};
|
|
12423
|
+
//#endregion
|
|
12086
12424
|
//#region src/client/sidebar/layout.ts
|
|
12087
12425
|
/**
|
|
12088
12426
|
* 侧栏导航布局模型:
|
|
@@ -12171,39 +12509,6 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
12171
12509
|
//#region src/client/sidebar/SidebarNav.tsx
|
|
12172
12510
|
const IconBrowse = _deepseek_ai_dsh_client_ui_primitives.IconPluginPinwheelOutlineRegular ?? Blocks;
|
|
12173
12511
|
const IconCreate = _deepseek_ai_dsh_client_ui_primitives.IconPlusOutlineRegular ?? Plus;
|
|
12174
|
-
const IconNewChat = _deepseek_ai_dsh_client_ui_primitives.IconNewChatOutlineMedium ?? _deepseek_ai_dsh_client_ui_primitives.IconNewChatOutlineRegular ?? MessageSquarePlus;
|
|
12175
|
-
const Tooltip = _deepseek_ai_dsh_client_ui_primitives.Tooltip;
|
|
12176
|
-
const ShortcutKeys = _deepseek_ai_dsh_client_ui_primitives.ShortcutKeys;
|
|
12177
|
-
function getNewSessionShortcut() {
|
|
12178
|
-
if (typeof document === "undefined") return {};
|
|
12179
|
-
const aria = document.querySelector("button[class*=\"newSession\"]")?.getAttribute("aria-keyshortcuts") || void 0;
|
|
12180
|
-
if (!aria) return typeof navigator !== "undefined" && /Mac|iPhone|iPod|iPad/i.test(navigator.platform || navigator.userAgent) ? {
|
|
12181
|
-
aria: "⌥⌘N",
|
|
12182
|
-
keys: [
|
|
12183
|
-
"⌥",
|
|
12184
|
-
"⌘",
|
|
12185
|
-
"N"
|
|
12186
|
-
]
|
|
12187
|
-
} : {
|
|
12188
|
-
aria: "Ctrl+Alt+N",
|
|
12189
|
-
keys: [
|
|
12190
|
-
"Ctrl",
|
|
12191
|
-
"Alt",
|
|
12192
|
-
"N"
|
|
12193
|
-
]
|
|
12194
|
-
};
|
|
12195
|
-
return {
|
|
12196
|
-
aria,
|
|
12197
|
-
keys: aria.split("+").map((k) => {
|
|
12198
|
-
const lower = k.trim().toLowerCase();
|
|
12199
|
-
if (lower === "control") return "Ctrl";
|
|
12200
|
-
if (lower === "alt") return "Alt";
|
|
12201
|
-
if (lower === "shift") return "Shift";
|
|
12202
|
-
if (lower === "meta" || lower === "command") return "⌘";
|
|
12203
|
-
return k.trim();
|
|
12204
|
-
})
|
|
12205
|
-
};
|
|
12206
|
-
}
|
|
12207
12512
|
function resolveSlotLabel(label) {
|
|
12208
12513
|
if (typeof label === "function") try {
|
|
12209
12514
|
const res = label();
|
|
@@ -12352,20 +12657,13 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
12352
12657
|
}
|
|
12353
12658
|
}, [ctx]);
|
|
12354
12659
|
const [moreOpen, setMoreOpen] = (0, react.useState)(false);
|
|
12355
|
-
const [
|
|
12356
|
-
|
|
12357
|
-
|
|
12358
|
-
|
|
12359
|
-
|
|
12360
|
-
|
|
12361
|
-
|
|
12362
|
-
else document.querySelector("button[class*=\"newSession\"]")?.click();
|
|
12363
|
-
} catch (err) {
|
|
12364
|
-
console.warn("startSession failed:", err);
|
|
12365
|
-
} finally {
|
|
12366
|
-
setStartingSession(false);
|
|
12367
|
-
}
|
|
12368
|
-
}, [ctx, startingSession]);
|
|
12660
|
+
const [sessionActionTakenOver, setSessionActionTakenOver] = (0, react.useState)(() => getSessionActionDeclared());
|
|
12661
|
+
(0, react.useEffect)(() => {
|
|
12662
|
+
setSessionActionTakenOver(getSessionActionDeclared());
|
|
12663
|
+
return subscribeSessionActionDeclared(() => {
|
|
12664
|
+
setSessionActionTakenOver(getSessionActionDeclared());
|
|
12665
|
+
});
|
|
12666
|
+
}, []);
|
|
12369
12667
|
const handleSelectPanel = (0, react.useCallback)((id) => {
|
|
12370
12668
|
setActivePanelId(id);
|
|
12371
12669
|
try {
|
|
@@ -12398,12 +12696,8 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
12398
12696
|
return;
|
|
12399
12697
|
}
|
|
12400
12698
|
} catch {}
|
|
12401
|
-
|
|
12402
|
-
}, [
|
|
12403
|
-
ctx,
|
|
12404
|
-
handleStartSession,
|
|
12405
|
-
t
|
|
12406
|
-
]);
|
|
12699
|
+
document.querySelector("button[class*=\"newSession\"]")?.click();
|
|
12700
|
+
}, [ctx, t]);
|
|
12407
12701
|
const [draggingId, setDraggingId] = (0, react.useState)(null);
|
|
12408
12702
|
const [dragOver, setDragOver] = (0, react.useState)(null);
|
|
12409
12703
|
const dragOverRef = (0, react.useRef)(null);
|
|
@@ -12544,73 +12838,43 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
12544
12838
|
draggingId,
|
|
12545
12839
|
handleDragEnd
|
|
12546
12840
|
]);
|
|
12841
|
+
(0, react.useEffect)(() => {
|
|
12842
|
+
return registerNewSessionDropHandler({
|
|
12843
|
+
isDragging: () => Boolean(isDraggingRef.current ?? draggingId),
|
|
12844
|
+
onDragOver: () => {
|
|
12845
|
+
const firstPanel = layoutRef.current.pinned[0];
|
|
12846
|
+
updateDragOver({
|
|
12847
|
+
zone: "pinned",
|
|
12848
|
+
target: firstPanel ?? "__end__"
|
|
12849
|
+
});
|
|
12850
|
+
},
|
|
12851
|
+
onDrop: (draggedId) => {
|
|
12852
|
+
const id = draggedId || isDraggingRef.current || draggingId;
|
|
12853
|
+
const firstPanel = layoutRef.current.pinned[0];
|
|
12854
|
+
commitDrop(id, "pinned", firstPanel ?? "__end__");
|
|
12855
|
+
handleDragEnd();
|
|
12856
|
+
}
|
|
12857
|
+
});
|
|
12858
|
+
}, [
|
|
12859
|
+
commitDrop,
|
|
12860
|
+
draggingId,
|
|
12861
|
+
handleDragEnd,
|
|
12862
|
+
updateDragOver
|
|
12863
|
+
]);
|
|
12547
12864
|
const panelMap = (0, react.useMemo)(() => new Map(panels.map((p) => [p.id, p])), [panels]);
|
|
12548
12865
|
const fixedPanels = (0, react.useMemo)(() => FIXED_PANEL_IDS.map((id) => panelMap.get(id)).filter((p) => Boolean(p)), [panelMap]);
|
|
12549
12866
|
const userPinnedPanels = (0, react.useMemo)(() => layout.pinned.map((id) => panelMap.get(id)).filter((p) => Boolean(p)), [layout.pinned, panelMap]);
|
|
12550
12867
|
const morePanels = (0, react.useMemo)(() => layout.more.map((id) => panelMap.get(id)).filter((p) => Boolean(p)), [layout.more, panelMap]);
|
|
12551
|
-
const newSessionShortcut = (0, react.useMemo)(() => getNewSessionShortcut(), []);
|
|
12552
|
-
const newSessionButton = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
12553
|
-
type: "button",
|
|
12554
|
-
className: "dcu-sb-row dcu-sb-new-session-row",
|
|
12555
|
-
"aria-label": t("sidebar.newSession", "新会话"),
|
|
12556
|
-
"aria-keyshortcuts": newSessionShortcut.aria,
|
|
12557
|
-
"aria-disabled": startingSession,
|
|
12558
|
-
onClick: handleStartSession,
|
|
12559
|
-
onKeyDown: (e) => {
|
|
12560
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
12561
|
-
e.preventDefault();
|
|
12562
|
-
handleStartSession();
|
|
12563
|
-
}
|
|
12564
|
-
},
|
|
12565
|
-
children: [
|
|
12566
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
12567
|
-
className: "dcu-sb-glyph",
|
|
12568
|
-
"aria-hidden": "true",
|
|
12569
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconNewChat, { size: 16 })
|
|
12570
|
-
}),
|
|
12571
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
12572
|
-
className: "dcu-sb-title",
|
|
12573
|
-
children: t("sidebar.newSession", "新会话")
|
|
12574
|
-
}),
|
|
12575
|
-
ShortcutKeys && newSessionShortcut.keys && newSessionShortcut.keys.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
12576
|
-
className: "dcu-sb-shortcut",
|
|
12577
|
-
"aria-hidden": "true",
|
|
12578
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShortcutKeys, { keys: newSessionShortcut.keys })
|
|
12579
|
-
})
|
|
12580
|
-
]
|
|
12581
|
-
});
|
|
12582
12868
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("nav", {
|
|
12583
12869
|
className: "dcu-sb-root",
|
|
12584
12870
|
"data-dcu-sb-root": "true",
|
|
12585
12871
|
children: [
|
|
12586
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
12872
|
+
!sessionActionTakenOver && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
12587
12873
|
className: "dcu-sb-section dcu-sb-new-session-section",
|
|
12588
|
-
|
|
12589
|
-
|
|
12590
|
-
|
|
12591
|
-
|
|
12592
|
-
if (e.dataTransfer) e.dataTransfer.dropEffect = "move";
|
|
12593
|
-
const firstPanel = layoutRef.current.pinned[0];
|
|
12594
|
-
updateDragOver({
|
|
12595
|
-
zone: "pinned",
|
|
12596
|
-
target: firstPanel ?? "__end__"
|
|
12597
|
-
});
|
|
12598
|
-
},
|
|
12599
|
-
onDrop: (e) => {
|
|
12600
|
-
e.preventDefault();
|
|
12601
|
-
e.stopPropagation();
|
|
12602
|
-
const id = e.dataTransfer?.getData("application/x-dsh-panel-id") || e.dataTransfer?.getData("text/plain") || isDraggingRef.current || draggingId;
|
|
12603
|
-
const firstPanel = layoutRef.current.pinned[0];
|
|
12604
|
-
commitDrop(id, "pinned", firstPanel ?? "__end__");
|
|
12605
|
-
handleDragEnd();
|
|
12606
|
-
},
|
|
12607
|
-
children: Tooltip ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tooltip, {
|
|
12608
|
-
label: t("sidebar.newSession", "新会话"),
|
|
12609
|
-
shortcutKeys: newSessionShortcut.keys,
|
|
12610
|
-
delayMs: 500,
|
|
12611
|
-
side: "right",
|
|
12612
|
-
children: newSessionButton
|
|
12613
|
-
}) : newSessionButton
|
|
12874
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NewSessionButton, {
|
|
12875
|
+
ctx,
|
|
12876
|
+
label: t("sidebar.newSession", "新会话")
|
|
12877
|
+
})
|
|
12614
12878
|
}),
|
|
12615
12879
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
12616
12880
|
className: "dcu-sb-section dcu-sb-pinned-section",
|
|
@@ -12866,18 +13130,73 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
12866
13130
|
* - 使用 grid-template-rows 实现原位折叠动画;
|
|
12867
13131
|
* - 原生减弱动画感知支持;
|
|
12868
13132
|
* - 拖拽放置指示线样式;
|
|
12869
|
-
* - 宿主原生 newSession
|
|
13133
|
+
* - 宿主原生 panelList 靶向隐藏;当存在 sidebar.session.action HOC 接管时对齐同行样式,否则兼容隐藏原生 newSession / newSessionRow。
|
|
12870
13134
|
*/
|
|
12871
13135
|
const SIDEBAR_STYLES_ID = "michengai-codex-ui-sidebar-styles";
|
|
12872
13136
|
const SIDEBAR_ACTIVE_ATTR = "data-dcu-sidebar-active";
|
|
12873
13137
|
const SIDEBAR_CSS = `
|
|
12874
|
-
/* 仅在展开态隐藏宿主原生 newSession/newSessionRow
|
|
12875
|
-
[${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]) [class*="newSessionRow"],
|
|
12876
|
-
[${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]) button[class*="newSession"],
|
|
13138
|
+
/* 仅在展开态隐藏宿主原生 panelList;仅当独立导航容器实际渲染了降级 .dcu-sb-new-session-row 时,才同步隐藏原生 newSession / newSessionRow(保证 HOC 接管态与透传态均可见原生行);折叠收缩态 100% 对齐宿主官方 56px 原生导轨 */
|
|
13139
|
+
[${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]):has(.dcu-sidebar-nav-root .dcu-sb-new-session-row) [class*="newSessionRow"],
|
|
13140
|
+
[${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]):has(.dcu-sidebar-nav-root .dcu-sb-new-session-row) button[class*="newSession"],
|
|
12877
13141
|
[${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]) nav[class*="panelList"] {
|
|
12878
13142
|
display: none !important;
|
|
12879
13143
|
}
|
|
12880
13144
|
|
|
13145
|
+
/* 方案 A:HOC 原位接管 newSessionRow 时,对齐 Codex 侧栏行距与扁平胶囊外观 */
|
|
13146
|
+
[${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]) [class*="newSessionRow"]:has(.dcu-sb-new-session-row) {
|
|
13147
|
+
margin-left: 2px;
|
|
13148
|
+
margin-right: 2px;
|
|
13149
|
+
margin-bottom: 2px;
|
|
13150
|
+
gap: 4px;
|
|
13151
|
+
}
|
|
13152
|
+
|
|
13153
|
+
[${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]) [class*="newSessionRow"] .dcu-sb-new-session-row {
|
|
13154
|
+
flex: 1 1 auto;
|
|
13155
|
+
min-width: 0;
|
|
13156
|
+
width: auto;
|
|
13157
|
+
margin: 1px 0;
|
|
13158
|
+
}
|
|
13159
|
+
|
|
13160
|
+
.dcu-sb-new-session-row[aria-disabled="true"] {
|
|
13161
|
+
opacity: 0.6;
|
|
13162
|
+
cursor: progress;
|
|
13163
|
+
}
|
|
13164
|
+
|
|
13165
|
+
/* 统一同行扩展按钮(如会话导入)为 36x36 Codex 扁平悬停胶囊风格,消除白框割裂感 */
|
|
13166
|
+
[${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]) [class*="newSessionRow"]:has(.dcu-sb-new-session-row) button:not(.dcu-sb-new-session-row):not([class*="newSession"]),
|
|
13167
|
+
[${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]) [class*="newSessionRow"]:has(.dcu-sb-new-session-row) [role="button"]:not(.dcu-sb-new-session-row):not([class*="newSession"]) {
|
|
13168
|
+
box-sizing: border-box;
|
|
13169
|
+
height: 36px;
|
|
13170
|
+
min-height: 36px;
|
|
13171
|
+
max-height: 36px;
|
|
13172
|
+
width: auto;
|
|
13173
|
+
min-width: 36px;
|
|
13174
|
+
padding: 0 9px;
|
|
13175
|
+
margin: 1px 0;
|
|
13176
|
+
border: none;
|
|
13177
|
+
border-radius: var(--dsw-radius-md, 8px);
|
|
13178
|
+
background: transparent;
|
|
13179
|
+
box-shadow: none;
|
|
13180
|
+
color: var(--dsw-alias-label-secondary, var(--dsw-alias-label-primary, inherit));
|
|
13181
|
+
display: inline-flex;
|
|
13182
|
+
align-items: center;
|
|
13183
|
+
justify-content: center;
|
|
13184
|
+
cursor: pointer;
|
|
13185
|
+
transition: background 150ms ease, color 150ms ease;
|
|
13186
|
+
}
|
|
13187
|
+
|
|
13188
|
+
[${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]) [class*="newSessionRow"]:has(.dcu-sb-new-session-row) button:not(.dcu-sb-new-session-row):not([class*="newSession"]):hover,
|
|
13189
|
+
[${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]) [class*="newSessionRow"]:has(.dcu-sb-new-session-row) [role="button"]:not(.dcu-sb-new-session-row):not([class*="newSession"]):hover {
|
|
13190
|
+
background: var(--dsw-alias-interactive-bg-hover, rgba(255, 255, 255, 0.08));
|
|
13191
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
13192
|
+
}
|
|
13193
|
+
|
|
13194
|
+
[${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]) [class*="newSessionRow"]:has(.dcu-sb-new-session-row) button:not(.dcu-sb-new-session-row):not([class*="newSession"]):focus-visible,
|
|
13195
|
+
[${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]) [class*="newSessionRow"]:has(.dcu-sb-new-session-row) [role="button"]:not(.dcu-sb-new-session-row):not([class*="newSession"]):focus-visible {
|
|
13196
|
+
outline: 1.5px solid var(--dsw-alias-brand-primary, #4176e6);
|
|
13197
|
+
outline-offset: -1px;
|
|
13198
|
+
}
|
|
13199
|
+
|
|
12881
13200
|
/* 折叠收缩态下隐藏自研导航,完全回退展示宿主原生折叠导轨(自带全部图标与完整生态) */
|
|
12882
13201
|
[${SIDEBAR_ACTIVE_ATTR}][class*="collapsed"] .dcu-sb-root,
|
|
12883
13202
|
[data-sidebar-collapsed="true"] .dcu-sb-root {
|
|
@@ -13177,6 +13496,34 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
13177
13496
|
//#endregion
|
|
13178
13497
|
//#region src/client/sidebar/index.ts
|
|
13179
13498
|
const CONTAINER_CLASS = "dcu-sidebar-nav-root";
|
|
13499
|
+
function resolveNewSessionLabel(ctx, t) {
|
|
13500
|
+
try {
|
|
13501
|
+
const direct = t?.("sidebar.newSession");
|
|
13502
|
+
if (direct && direct !== "sidebar.newSession") return direct;
|
|
13503
|
+
const bound = ctx.locale?.bind?.(NS)?.("sidebar.newSession");
|
|
13504
|
+
if (bound && bound !== "sidebar.newSession") return bound;
|
|
13505
|
+
} catch {}
|
|
13506
|
+
return "新会话";
|
|
13507
|
+
}
|
|
13508
|
+
function createSessionActionLayer(ctx) {
|
|
13509
|
+
const SessionActionLayer = ({ wide = false, children, t }) => {
|
|
13510
|
+
const [enabled, setEnabled] = (0, react.useState)(() => getSidebarEnabled());
|
|
13511
|
+
(0, react.useEffect)(() => {
|
|
13512
|
+
setEnabled(getSidebarEnabled());
|
|
13513
|
+
return subscribeSidebarEnabled(() => {
|
|
13514
|
+
setEnabled(getSidebarEnabled());
|
|
13515
|
+
});
|
|
13516
|
+
}, []);
|
|
13517
|
+
if (!enabled || !wide || !resolveStartSession(ctx)) return react.default.createElement(react.default.Fragment, null, children);
|
|
13518
|
+
return react.default.createElement(NewSessionButton, {
|
|
13519
|
+
ctx,
|
|
13520
|
+
label: resolveNewSessionLabel(ctx, t),
|
|
13521
|
+
ariaHint: extractAriaKeyshortcuts(children),
|
|
13522
|
+
tooltipDisabled: wide
|
|
13523
|
+
});
|
|
13524
|
+
};
|
|
13525
|
+
return SessionActionLayer;
|
|
13526
|
+
}
|
|
13180
13527
|
/**
|
|
13181
13528
|
* 校验侧栏子插件是否在 Host 侧启用。
|
|
13182
13529
|
* 遵循 fail-closed 原则:404、网络失败或未显式 enabled 时视为关闭并回退官方。
|
|
@@ -13197,8 +13544,9 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
13197
13544
|
/**
|
|
13198
13545
|
* 挂载并观察侧栏导航增强:
|
|
13199
13546
|
* - 只有在子插件探活成功时激活;
|
|
13200
|
-
* -
|
|
13201
|
-
* -
|
|
13547
|
+
* - 若宿主声明了 sidebar.session.action HOC,则原位接管新会话按钮为 Codex 扁平风格,保留同行扩展入口,并在其后挂载导航容器;
|
|
13548
|
+
* - 旧宿主未声明 sidebar.session.action 时,在原生 newSession 前挂载导航容器并同步隐藏原生入口;
|
|
13549
|
+
* - 仅靶向隐藏原生 panelList(及无 HOC 接管时的原生 newSession),绝不删除或克隆宿主 DOM 节点;
|
|
13202
13550
|
* - 观察器仅监听挂载容器的存续,彻底切断 DOM 自触发循环;
|
|
13203
13551
|
* - 卸载时彻底 unmount React Root、移除样式与标记,原生侧栏无损秒级复原。
|
|
13204
13552
|
*/
|
|
@@ -13210,6 +13558,9 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
13210
13558
|
let currentSidebarRoot = null;
|
|
13211
13559
|
let rafPending = false;
|
|
13212
13560
|
let isEnabled = false;
|
|
13561
|
+
let unsubSessionAction;
|
|
13562
|
+
setSidebarEnabled(false);
|
|
13563
|
+
setSessionActionDeclared(false);
|
|
13213
13564
|
const teardownMount = () => {
|
|
13214
13565
|
if (currentContainer) {
|
|
13215
13566
|
try {
|
|
@@ -13223,23 +13574,42 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
13223
13574
|
currentSidebarRoot = null;
|
|
13224
13575
|
}
|
|
13225
13576
|
};
|
|
13577
|
+
const resolveMountAnchor = (sidebarRoot, target) => {
|
|
13578
|
+
let anchor = target;
|
|
13579
|
+
while (anchor.parentElement && anchor.parentElement !== sidebarRoot) anchor = anchor.parentElement;
|
|
13580
|
+
return anchor.parentElement === sidebarRoot ? anchor : null;
|
|
13581
|
+
};
|
|
13226
13582
|
const tryMount = () => {
|
|
13227
13583
|
if (disposed || !isEnabled || typeof document === "undefined") return;
|
|
13228
|
-
if (currentContainer && document.contains(currentContainer))
|
|
13584
|
+
if (currentContainer && document.contains(currentContainer)) {
|
|
13585
|
+
if (currentSidebarRoot && currentContainer.parentElement === currentSidebarRoot) {
|
|
13586
|
+
const newSessionEl = currentSidebarRoot.querySelector("[class*=\"newSessionRow\"], button[class*=\"newSession\"]");
|
|
13587
|
+
if (newSessionEl) {
|
|
13588
|
+
const anchor = resolveMountAnchor(currentSidebarRoot, newSessionEl);
|
|
13589
|
+
if (anchor) {
|
|
13590
|
+
const wantAfter = getSessionActionDeclared();
|
|
13591
|
+
if (wantAfter && anchor.nextElementSibling !== currentContainer) currentSidebarRoot.insertBefore(currentContainer, anchor.nextSibling);
|
|
13592
|
+
else if (!wantAfter && currentContainer.nextElementSibling !== anchor) currentSidebarRoot.insertBefore(currentContainer, anchor);
|
|
13593
|
+
}
|
|
13594
|
+
}
|
|
13595
|
+
}
|
|
13596
|
+
return;
|
|
13597
|
+
}
|
|
13229
13598
|
if (currentContainer) teardownMount();
|
|
13230
|
-
const
|
|
13231
|
-
|
|
13232
|
-
const
|
|
13599
|
+
const nativeSessionEl = document.querySelector("[class*=\"newSessionRow\"], button[class*=\"newSession\"]");
|
|
13600
|
+
const nativePanelList = document.querySelector("nav[class*=\"panelList\"]");
|
|
13601
|
+
const anchorTarget = nativeSessionEl ?? nativePanelList;
|
|
13602
|
+
if (!anchorTarget) return;
|
|
13603
|
+
const sidebarRoot = anchorTarget.closest("[class*=\"root\"]") || anchorTarget.parentElement;
|
|
13233
13604
|
if (!sidebarRoot) return;
|
|
13234
|
-
|
|
13235
|
-
|
|
13236
|
-
|
|
13237
|
-
if (!cleanupStyles) cleanupStyles = injectSidebarStyles();
|
|
13605
|
+
const mountAnchor = resolveMountAnchor(sidebarRoot, anchorTarget);
|
|
13606
|
+
if (!mountAnchor) return;
|
|
13607
|
+
const insertBeforeNode = Boolean(nativeSessionEl && getSessionActionDeclared()) ? mountAnchor.nextSibling : mountAnchor;
|
|
13238
13608
|
const container = document.createElement("div");
|
|
13239
13609
|
container.className = CONTAINER_CLASS;
|
|
13240
13610
|
container.setAttribute("data-dcu-managed", "true");
|
|
13241
13611
|
try {
|
|
13242
|
-
sidebarRoot.insertBefore(container,
|
|
13612
|
+
sidebarRoot.insertBefore(container, insertBeforeNode);
|
|
13243
13613
|
currentContainer = container;
|
|
13244
13614
|
(0, react_dom.render)(react.default.createElement(SidebarNav, { ctx }), container);
|
|
13245
13615
|
sidebarRoot.setAttribute(SIDEBAR_ACTIVE_ATTR, "true");
|
|
@@ -13268,8 +13638,11 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
13268
13638
|
if (disposed) return;
|
|
13269
13639
|
if (nextEnabled === isEnabled) return;
|
|
13270
13640
|
isEnabled = nextEnabled;
|
|
13271
|
-
|
|
13272
|
-
|
|
13641
|
+
setSidebarEnabled(nextEnabled);
|
|
13642
|
+
if (isEnabled) {
|
|
13643
|
+
if (!cleanupStyles) cleanupStyles = injectSidebarStyles();
|
|
13644
|
+
tryMount();
|
|
13645
|
+
} else {
|
|
13273
13646
|
teardownMount();
|
|
13274
13647
|
if (cleanupStyles) {
|
|
13275
13648
|
cleanupStyles();
|
|
@@ -13277,6 +13650,29 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
13277
13650
|
}
|
|
13278
13651
|
}
|
|
13279
13652
|
};
|
|
13653
|
+
if (typeof ctx.slots?.inject === "function" && typeof ctx.slots?.register === "function") {
|
|
13654
|
+
const SessionActionLayer = createSessionActionLayer(ctx);
|
|
13655
|
+
try {
|
|
13656
|
+
const result = ctx.slots.inject("sidebar.session.action", () => {
|
|
13657
|
+
const unregister = ctx.slots.register({
|
|
13658
|
+
name: "sidebar.session.action",
|
|
13659
|
+
id: "codex-ui",
|
|
13660
|
+
order: Number.MAX_SAFE_INTEGER,
|
|
13661
|
+
locale: NS
|
|
13662
|
+
}, SessionActionLayer);
|
|
13663
|
+
setSessionActionDeclared(true);
|
|
13664
|
+
scheduleCheck();
|
|
13665
|
+
return () => {
|
|
13666
|
+
unregister?.();
|
|
13667
|
+
setSessionActionDeclared(false);
|
|
13668
|
+
scheduleCheck();
|
|
13669
|
+
};
|
|
13670
|
+
});
|
|
13671
|
+
if (typeof result === "function") unsubSessionAction = result;
|
|
13672
|
+
} catch {
|
|
13673
|
+
setSessionActionDeclared(false);
|
|
13674
|
+
}
|
|
13675
|
+
}
|
|
13280
13676
|
sync();
|
|
13281
13677
|
const onFocus = () => {
|
|
13282
13678
|
sync();
|
|
@@ -13309,6 +13705,10 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
13309
13705
|
}
|
|
13310
13706
|
return () => {
|
|
13311
13707
|
disposed = true;
|
|
13708
|
+
unsubSessionAction?.();
|
|
13709
|
+
unsubSessionAction = void 0;
|
|
13710
|
+
setSessionActionDeclared(false);
|
|
13711
|
+
setSidebarEnabled(false);
|
|
13312
13712
|
if (typeof window !== "undefined") window.removeEventListener("focus", onFocus);
|
|
13313
13713
|
if (observer) {
|
|
13314
13714
|
observer.disconnect();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@michengai/dsh-codex-ui",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.8",
|
|
4
4
|
"description": "DSH Codex UI — 为 DeepSeek Harness 提供极速历史召回、全屏设置皮肤、原生物理毛玻璃换肤、模块化侧栏与桌面原生窗口菜单 · Input enhancement, settings skin, native glass theme, modular sidebar, and desktop titlebar menu for DSH",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"typecheck": "tsc --noEmit",
|
|
130
130
|
"test": "pnpm run typecheck && vitest run && tsdown && node tests/run-assertions.mjs && pnpm run test:layout && pnpm run test:glass && pnpm run test:settings",
|
|
131
131
|
"test:host": "node scripts/verify-native-settings.mjs",
|
|
132
|
-
"test:layout": "node scripts/verify-new-conversation.mjs && node scripts/verify-hero-width.mjs && node scripts/verify-mobile-web.mjs",
|
|
132
|
+
"test:layout": "node scripts/verify-new-conversation.mjs && node scripts/verify-hero-width.mjs && node scripts/verify-mobile-web.mjs && node scripts/verify-sidebar-action.mjs",
|
|
133
133
|
"test:compat": "node scripts/run-compat-host.mjs",
|
|
134
134
|
"test:fallback-host": "node scripts/verify-plugin-fallback-host.mjs",
|
|
135
135
|
"test:glass": "node scripts/verify-glass-material.mjs",
|