@michengai/dsh-codex-ui 2.4.7 → 2.4.9

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.4.9] - 2026-11-28
4
+
5
+ - **Fix Sidebar "New Session" Button and Quick Entry Placement When Coexisting with Claude Style (Issue #117)**:
6
+ - Keep the host's native "New Session" button intact whenever `Claude Style` (`body[data-dsh-claude-style]`) is active so its inline action styling no longer hides or crowds out the button label, and automatically restore the flat Codex style as soon as the theme is turned off;
7
+ - Treat the `Claude Style` search entry (`dsh-claude-style.search`) as a fixed pinned entry ordered before "Plugins" while preserving its direct search click handler (automatically restoring it from saved "More" layouts);
8
+ - Known limitation: while coexisting with `Claude Style`, keeping the native "New Session" button disables dragging sidebar panels onto the "New Session" row to pin them to the top; drop panels directly onto the pinned section instead.
9
+
10
+ ## [2.4.8] - 2026-11-28
11
+
12
+ - **Preserve Third-Party New-Session Action Buttons in Sidebar (Issue #116)**:
13
+ - 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;
14
+ - 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.
15
+
3
16
  ## [2.4.7] - 2026-11-25
4
17
 
5
18
  - **Custom Input Width Restored After Restart and Maximize (Issue #115)**:
@@ -1,5 +1,18 @@
1
1
  # 更新日志
2
2
 
3
+ ## [2.4.9] - 2026-11-28
4
+
5
+ - **修复与 Claude Style 共存时侧栏「新会话」按钮异常与快捷入口位置问题(Issue #117)**:
6
+ - 检测到 `Claude Style`(`body[data-dsh-claude-style]`)启用时自动保留宿主原生「新会话」按钮,避免同行主操作标记被替换后造成按钮文字被挤掉或不可见,并在关闭该主题后实时恢复 Codex 扁平样式;
7
+ - 将 `Claude Style` 的搜索入口(`dsh-claude-style.search`)列为常驻固定入口并排在「插件管理」之前,保留其直接触发搜索的交互行为(即使此前被保存在「更多」折叠区也会自动恢复);
8
+ - 已知限制:与 `Claude Style` 共存时因保留宿主原生「新会话」按钮,面板拖拽「拖放至新会话行以置顶」交互暂不可用,请直接拖放至常驻面板区完成置顶排序。
9
+
10
+ ## [2.4.8] - 2026-11-28
11
+
12
+ - **保留侧边栏第三方「新会话」扩展按钮入口(Issue #116)**:
13
+ - 修复开启 Codex UI 后「新会话」行内通过 `sidebar.session.action` 注入的官方扩展按钮(如「DeepSeek 会话导入」)不可见的问题,使其与 Codex 无边框扁平样式并排对齐显示;
14
+ - 在原生扩展接管与低版本宿主降级路径下,均完整保留新建会话快捷键提示、气泡与面板拖拽置顶交互,并放行外部拖拽事件。
15
+
3
16
  ## [2.4.7] - 2026-11-25
4
17
 
5
18
  - **修复自定义输入宽度在重启并最大化后需要切页才恢复的问题(Issue #115)**:
package/lib/client.js CHANGED
@@ -12232,14 +12232,206 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
12232
12232
  };
12233
12233
  }
12234
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
12235
12424
  //#region src/client/sidebar/layout.ts
12236
12425
  /**
12237
12426
  * 侧栏导航布局模型:
12238
12427
  * 只保存「常驻顺序」与「收入更多的顺序」,入口本身仍由宿主注册与渲染。
12239
12428
  * 纯函数,方便单测;不读写 localStorage。
12240
12429
  */
12241
- /** 宿主固定的入口:始终常驻,不参与收纳与拖动。 */
12242
- const FIXED_PANEL_IDS = ["plugins"];
12430
+ /**
12431
+ * 始终常驻的入口;Claude Style 搜索是直接操作,放在面板导航前。
12432
+ * 'dsh-claude-style.search' 源自 dsh-claude-style packages/client/src/features/search/search-trigger.ts (SEARCH_PANEL_ID)。
12433
+ */
12434
+ const FIXED_PANEL_IDS = ["dsh-claude-style.search", "plugins"];
12243
12435
  const SIDEBAR_LAYOUT_KEY = "michengai.codex-ui.sidebar-layout.v1";
12244
12436
  const isStringArray$1 = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
12245
12437
  /** 解析持久化内容;格式不符时返回 undefined,由调用方回退默认布局。 */
@@ -12320,39 +12512,6 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
12320
12512
  //#region src/client/sidebar/SidebarNav.tsx
12321
12513
  const IconBrowse = _deepseek_ai_dsh_client_ui_primitives.IconPluginPinwheelOutlineRegular ?? Blocks;
12322
12514
  const IconCreate = _deepseek_ai_dsh_client_ui_primitives.IconPlusOutlineRegular ?? Plus;
12323
- const IconNewChat = _deepseek_ai_dsh_client_ui_primitives.IconNewChatOutlineMedium ?? _deepseek_ai_dsh_client_ui_primitives.IconNewChatOutlineRegular ?? MessageSquarePlus;
12324
- const Tooltip = _deepseek_ai_dsh_client_ui_primitives.Tooltip;
12325
- const ShortcutKeys = _deepseek_ai_dsh_client_ui_primitives.ShortcutKeys;
12326
- function getNewSessionShortcut() {
12327
- if (typeof document === "undefined") return {};
12328
- const aria = document.querySelector("button[class*=\"newSession\"]")?.getAttribute("aria-keyshortcuts") || void 0;
12329
- if (!aria) return typeof navigator !== "undefined" && /Mac|iPhone|iPod|iPad/i.test(navigator.platform || navigator.userAgent) ? {
12330
- aria: "⌥⌘N",
12331
- keys: [
12332
- "⌥",
12333
- "⌘",
12334
- "N"
12335
- ]
12336
- } : {
12337
- aria: "Ctrl+Alt+N",
12338
- keys: [
12339
- "Ctrl",
12340
- "Alt",
12341
- "N"
12342
- ]
12343
- };
12344
- return {
12345
- aria,
12346
- keys: aria.split("+").map((k) => {
12347
- const lower = k.trim().toLowerCase();
12348
- if (lower === "control") return "Ctrl";
12349
- if (lower === "alt") return "Alt";
12350
- if (lower === "shift") return "Shift";
12351
- if (lower === "meta" || lower === "command") return "⌘";
12352
- return k.trim();
12353
- })
12354
- };
12355
- }
12356
12515
  function resolveSlotLabel(label) {
12357
12516
  if (typeof label === "function") try {
12358
12517
  const res = label();
@@ -12501,20 +12660,13 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
12501
12660
  }
12502
12661
  }, [ctx]);
12503
12662
  const [moreOpen, setMoreOpen] = (0, react.useState)(false);
12504
- const [startingSession, setStartingSession] = (0, react.useState)(false);
12505
- const handleStartSession = (0, react.useCallback)(async () => {
12506
- if (startingSession) return;
12507
- setStartingSession(true);
12508
- try {
12509
- const uiWorkspace = ctx.get?.("uiWorkspace") ?? ctx?.uiWorkspace;
12510
- if (typeof uiWorkspace?.startSession === "function") await Promise.resolve(uiWorkspace.startSession());
12511
- else document.querySelector("button[class*=\"newSession\"]")?.click();
12512
- } catch (err) {
12513
- console.warn("startSession failed:", err);
12514
- } finally {
12515
- setStartingSession(false);
12516
- }
12517
- }, [ctx, startingSession]);
12663
+ const [sessionActionTakenOver, setSessionActionTakenOver] = (0, react.useState)(() => getSessionActionDeclared());
12664
+ (0, react.useEffect)(() => {
12665
+ setSessionActionTakenOver(getSessionActionDeclared());
12666
+ return subscribeSessionActionDeclared(() => {
12667
+ setSessionActionTakenOver(getSessionActionDeclared());
12668
+ });
12669
+ }, []);
12518
12670
  const handleSelectPanel = (0, react.useCallback)((id) => {
12519
12671
  setActivePanelId(id);
12520
12672
  try {
@@ -12547,12 +12699,8 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
12547
12699
  return;
12548
12700
  }
12549
12701
  } catch {}
12550
- handleStartSession();
12551
- }, [
12552
- ctx,
12553
- handleStartSession,
12554
- t
12555
- ]);
12702
+ document.querySelector("button[class*=\"newSession\"]")?.click();
12703
+ }, [ctx, t]);
12556
12704
  const [draggingId, setDraggingId] = (0, react.useState)(null);
12557
12705
  const [dragOver, setDragOver] = (0, react.useState)(null);
12558
12706
  const dragOverRef = (0, react.useRef)(null);
@@ -12566,7 +12714,7 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
12566
12714
  const isDraggingRef = (0, react.useRef)(null);
12567
12715
  useNativeDragAcceptance((0, react.useCallback)(() => Boolean(isDraggingRef.current), []));
12568
12716
  const commitDrop = (0, react.useCallback)((draggedId, zone, target) => {
12569
- if (!draggedId || FIXED_PANEL_IDS.includes(draggedId)) return;
12717
+ if (!draggedId || isFixed(draggedId)) return;
12570
12718
  const currentLayout = layoutRef.current;
12571
12719
  if (target === "__more_trigger__") {
12572
12720
  const next = moveEntry(currentLayout, {
@@ -12603,7 +12751,7 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
12603
12751
  if (zone === "more") setMoreOpen(true);
12604
12752
  }, [persistLayout]);
12605
12753
  const handleDragStart = (0, react.useCallback)((e, id, label) => {
12606
- if (FIXED_PANEL_IDS.includes(id)) {
12754
+ if (isFixed(id)) {
12607
12755
  e.preventDefault();
12608
12756
  return;
12609
12757
  }
@@ -12628,7 +12776,7 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
12628
12776
  e.stopPropagation();
12629
12777
  if (e.dataTransfer) e.dataTransfer.dropEffect = "move";
12630
12778
  const list = zone === "pinned" ? layoutRef.current.pinned : layoutRef.current.more;
12631
- if (targetId === "plugins") {
12779
+ if (isFixed(targetId)) {
12632
12780
  const firstPanel = list[0];
12633
12781
  updateDragOver({
12634
12782
  zone: "pinned",
@@ -12693,82 +12841,52 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
12693
12841
  draggingId,
12694
12842
  handleDragEnd
12695
12843
  ]);
12844
+ (0, react.useEffect)(() => {
12845
+ return registerNewSessionDropHandler({
12846
+ isDragging: () => Boolean(isDraggingRef.current ?? draggingId),
12847
+ onDragOver: () => {
12848
+ const firstPanel = layoutRef.current.pinned[0];
12849
+ updateDragOver({
12850
+ zone: "pinned",
12851
+ target: firstPanel ?? "__end__"
12852
+ });
12853
+ },
12854
+ onDrop: (draggedId) => {
12855
+ const id = draggedId || isDraggingRef.current || draggingId;
12856
+ const firstPanel = layoutRef.current.pinned[0];
12857
+ commitDrop(id, "pinned", firstPanel ?? "__end__");
12858
+ handleDragEnd();
12859
+ }
12860
+ });
12861
+ }, [
12862
+ commitDrop,
12863
+ draggingId,
12864
+ handleDragEnd,
12865
+ updateDragOver
12866
+ ]);
12696
12867
  const panelMap = (0, react.useMemo)(() => new Map(panels.map((p) => [p.id, p])), [panels]);
12697
12868
  const fixedPanels = (0, react.useMemo)(() => FIXED_PANEL_IDS.map((id) => panelMap.get(id)).filter((p) => Boolean(p)), [panelMap]);
12698
12869
  const userPinnedPanels = (0, react.useMemo)(() => layout.pinned.map((id) => panelMap.get(id)).filter((p) => Boolean(p)), [layout.pinned, panelMap]);
12699
12870
  const morePanels = (0, react.useMemo)(() => layout.more.map((id) => panelMap.get(id)).filter((p) => Boolean(p)), [layout.more, panelMap]);
12700
- const newSessionShortcut = (0, react.useMemo)(() => getNewSessionShortcut(), []);
12701
- const newSessionButton = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
12702
- type: "button",
12703
- className: "dcu-sb-row dcu-sb-new-session-row",
12704
- "aria-label": t("sidebar.newSession", "新会话"),
12705
- "aria-keyshortcuts": newSessionShortcut.aria,
12706
- "aria-disabled": startingSession,
12707
- onClick: handleStartSession,
12708
- onKeyDown: (e) => {
12709
- if (e.key === "Enter" || e.key === " ") {
12710
- e.preventDefault();
12711
- handleStartSession();
12712
- }
12713
- },
12714
- children: [
12715
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
12716
- className: "dcu-sb-glyph",
12717
- "aria-hidden": "true",
12718
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconNewChat, { size: 16 })
12719
- }),
12720
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
12721
- className: "dcu-sb-title",
12722
- children: t("sidebar.newSession", "新会话")
12723
- }),
12724
- ShortcutKeys && newSessionShortcut.keys && newSessionShortcut.keys.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
12725
- className: "dcu-sb-shortcut",
12726
- "aria-hidden": "true",
12727
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShortcutKeys, { keys: newSessionShortcut.keys })
12728
- })
12729
- ]
12730
- });
12731
12871
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("nav", {
12732
12872
  className: "dcu-sb-root",
12733
12873
  "data-dcu-sb-root": "true",
12734
12874
  children: [
12735
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
12875
+ !sessionActionTakenOver && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
12736
12876
  className: "dcu-sb-section dcu-sb-new-session-section",
12737
- onDragOver: (e) => {
12738
- if (!(isDraggingRef.current ?? draggingId)) return;
12739
- e.preventDefault();
12740
- e.stopPropagation();
12741
- if (e.dataTransfer) e.dataTransfer.dropEffect = "move";
12742
- const firstPanel = layoutRef.current.pinned[0];
12743
- updateDragOver({
12744
- zone: "pinned",
12745
- target: firstPanel ?? "__end__"
12746
- });
12747
- },
12748
- onDrop: (e) => {
12749
- e.preventDefault();
12750
- e.stopPropagation();
12751
- const id = e.dataTransfer?.getData("application/x-dsh-panel-id") || e.dataTransfer?.getData("text/plain") || isDraggingRef.current || draggingId;
12752
- const firstPanel = layoutRef.current.pinned[0];
12753
- commitDrop(id, "pinned", firstPanel ?? "__end__");
12754
- handleDragEnd();
12755
- },
12756
- children: Tooltip ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tooltip, {
12757
- label: t("sidebar.newSession", "新会话"),
12758
- shortcutKeys: newSessionShortcut.keys,
12759
- delayMs: 500,
12760
- side: "right",
12761
- children: newSessionButton
12762
- }) : newSessionButton
12877
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NewSessionButton, {
12878
+ ctx,
12879
+ label: t("sidebar.newSession", "新会话")
12880
+ })
12763
12881
  }),
12764
12882
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12765
12883
  className: "dcu-sb-section dcu-sb-pinned-section",
12766
12884
  "data-zone": "pinned",
12767
12885
  onDragOver: (e) => handleDragOverZone(e, "pinned"),
12768
12886
  onDrop: (e) => handleDropZone(e, "pinned"),
12769
- children: [fixedPanels.map((panel) => {
12887
+ children: [fixedPanels.map((panel, index) => {
12770
12888
  const active = activePanelId === panel.id;
12771
- const isPluginsOverAfter = dragOver?.zone === "pinned" && dragOver.target === "__end__" && userPinnedPanels.length === 0;
12889
+ const showDropAfter = index === fixedPanels.length - 1 && dragOver?.zone === "pinned" && dragOver.target === "__end__" && userPinnedPanels.length === 0;
12772
12890
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
12773
12891
  type: "button",
12774
12892
  className: `dcu-sb-row ${active ? "dcu-sb-row-active" : ""}`,
@@ -12776,15 +12894,9 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
12776
12894
  title: t("sidebar.fixed", "始终常驻"),
12777
12895
  "aria-current": active ? "page" : void 0,
12778
12896
  "data-dcu-panel-id": panel.id,
12779
- "data-drag-over": isPluginsOverAfter ? "after" : void 0,
12897
+ "data-drag-over": showDropAfter ? "after" : void 0,
12780
12898
  draggable: false,
12781
12899
  onClick: () => handleSelectPanel(panel.id),
12782
- onKeyDown: (e) => {
12783
- if (e.key === "Enter" || e.key === " ") {
12784
- e.preventDefault();
12785
- handleSelectPanel(panel.id);
12786
- }
12787
- },
12788
12900
  onDragOver: (e) => handleDragOverRow(e, panel.id, "pinned"),
12789
12901
  onDragLeave: (e) => handleDragLeaveRow(e, panel.id),
12790
12902
  onDrop: (e) => handleDropRow(e, panel.id, "pinned"),
@@ -13015,18 +13127,73 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
13015
13127
  * - 使用 grid-template-rows 实现原位折叠动画;
13016
13128
  * - 原生减弱动画感知支持;
13017
13129
  * - 拖拽放置指示线样式;
13018
- * - 宿主原生 newSession 与 panelList 靶向隐藏。
13130
+ * - 宿主原生 panelList 靶向隐藏;当存在 sidebar.session.action HOC 接管时对齐同行样式,否则兼容隐藏原生 newSession / newSessionRow。
13019
13131
  */
13020
13132
  const SIDEBAR_STYLES_ID = "michengai-codex-ui-sidebar-styles";
13021
13133
  const SIDEBAR_ACTIVE_ATTR = "data-dcu-sidebar-active";
13022
13134
  const SIDEBAR_CSS = `
13023
- /* 仅在展开态隐藏宿主原生 newSession/newSessionRow 和 panelList;折叠收缩态 100% 对齐宿主官方 56px 原生导轨 */
13024
- [${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]) [class*="newSessionRow"],
13025
- [${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]) button[class*="newSession"],
13135
+ /* 仅在展开态隐藏宿主原生 panelList;仅当独立导航容器实际渲染了降级 .dcu-sb-new-session-row 时,才同步隐藏原生 newSession / newSessionRow(保证 HOC 接管态与透传态均可见原生行);折叠收缩态 100% 对齐宿主官方 56px 原生导轨 */
13136
+ [${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]):has(.dcu-sidebar-nav-root .dcu-sb-new-session-row) [class*="newSessionRow"],
13137
+ [${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]):has(.dcu-sidebar-nav-root .dcu-sb-new-session-row) button[class*="newSession"],
13026
13138
  [${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]) nav[class*="panelList"] {
13027
13139
  display: none !important;
13028
13140
  }
13029
13141
 
13142
+ /* 方案 A:HOC 原位接管 newSessionRow 时,对齐 Codex 侧栏行距与扁平胶囊外观 */
13143
+ [${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]) [class*="newSessionRow"]:has(.dcu-sb-new-session-row) {
13144
+ margin-left: 2px;
13145
+ margin-right: 2px;
13146
+ margin-bottom: 2px;
13147
+ gap: 4px;
13148
+ }
13149
+
13150
+ [${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]) [class*="newSessionRow"] .dcu-sb-new-session-row {
13151
+ flex: 1 1 auto;
13152
+ min-width: 0;
13153
+ width: auto;
13154
+ margin: 1px 0;
13155
+ }
13156
+
13157
+ .dcu-sb-new-session-row[aria-disabled="true"] {
13158
+ opacity: 0.6;
13159
+ cursor: progress;
13160
+ }
13161
+
13162
+ /* 统一同行扩展按钮(如会话导入)为 36x36 Codex 扁平悬停胶囊风格,消除白框割裂感 */
13163
+ [${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]) [class*="newSessionRow"]:has(.dcu-sb-new-session-row) button:not(.dcu-sb-new-session-row):not([class*="newSession"]),
13164
+ [${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"]) {
13165
+ box-sizing: border-box;
13166
+ height: 36px;
13167
+ min-height: 36px;
13168
+ max-height: 36px;
13169
+ width: auto;
13170
+ min-width: 36px;
13171
+ padding: 0 9px;
13172
+ margin: 1px 0;
13173
+ border: none;
13174
+ border-radius: var(--dsw-radius-md, 8px);
13175
+ background: transparent;
13176
+ box-shadow: none;
13177
+ color: var(--dsw-alias-label-secondary, var(--dsw-alias-label-primary, inherit));
13178
+ display: inline-flex;
13179
+ align-items: center;
13180
+ justify-content: center;
13181
+ cursor: pointer;
13182
+ transition: background 150ms ease, color 150ms ease;
13183
+ }
13184
+
13185
+ [${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,
13186
+ [${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 {
13187
+ background: var(--dsw-alias-interactive-bg-hover, rgba(255, 255, 255, 0.08));
13188
+ color: var(--dsw-alias-label-primary, inherit);
13189
+ }
13190
+
13191
+ [${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,
13192
+ [${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 {
13193
+ outline: 1.5px solid var(--dsw-alias-brand-primary, #4176e6);
13194
+ outline-offset: -1px;
13195
+ }
13196
+
13030
13197
  /* 折叠收缩态下隐藏自研导航,完全回退展示宿主原生折叠导轨(自带全部图标与完整生态) */
13031
13198
  [${SIDEBAR_ACTIVE_ATTR}][class*="collapsed"] .dcu-sb-root,
13032
13199
  [data-sidebar-collapsed="true"] .dcu-sb-root {
@@ -13326,6 +13493,45 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
13326
13493
  //#endregion
13327
13494
  //#region src/client/sidebar/index.ts
13328
13495
  const CONTAINER_CLASS = "dcu-sidebar-nav-root";
13496
+ /** 上游出处:dsh-claude-style packages/client/src/constants.ts (STYLE_STAMP_ATTR) 写入 document.body 的标记属性。 */
13497
+ const CLAUDE_STYLE_ATTR = "data-dsh-claude-style";
13498
+ function resolveNewSessionLabel(ctx, t) {
13499
+ try {
13500
+ const direct = t?.("sidebar.newSession");
13501
+ if (direct && direct !== "sidebar.newSession") return direct;
13502
+ const bound = ctx.locale?.bind?.(NS)?.("sidebar.newSession");
13503
+ if (bound && bound !== "sidebar.newSession") return bound;
13504
+ } catch {}
13505
+ return "新会话";
13506
+ }
13507
+ function createSessionActionLayer(ctx) {
13508
+ const shouldReplace = () => getSidebarEnabled() && (typeof document === "undefined" || !document.body?.hasAttribute(CLAUDE_STYLE_ATTR));
13509
+ const SessionActionLayer = ({ wide = false, children, t }) => {
13510
+ const [replace, setReplace] = (0, react.useState)(shouldReplace);
13511
+ (0, react.useEffect)(() => {
13512
+ const sync = () => setReplace(shouldReplace());
13513
+ const unsubscribe = subscribeSidebarEnabled(sync);
13514
+ const observer = new MutationObserver(sync);
13515
+ observer.observe(document.body, {
13516
+ attributes: true,
13517
+ attributeFilter: [CLAUDE_STYLE_ATTR]
13518
+ });
13519
+ sync();
13520
+ return () => {
13521
+ observer.disconnect();
13522
+ unsubscribe();
13523
+ };
13524
+ }, []);
13525
+ if (!replace || !wide || !resolveStartSession(ctx)) return react.default.createElement(react.default.Fragment, null, children);
13526
+ return react.default.createElement(NewSessionButton, {
13527
+ ctx,
13528
+ label: resolveNewSessionLabel(ctx, t),
13529
+ ariaHint: extractAriaKeyshortcuts(children),
13530
+ tooltipDisabled: wide
13531
+ });
13532
+ };
13533
+ return SessionActionLayer;
13534
+ }
13329
13535
  /**
13330
13536
  * 校验侧栏子插件是否在 Host 侧启用。
13331
13537
  * 遵循 fail-closed 原则:404、网络失败或未显式 enabled 时视为关闭并回退官方。
@@ -13346,8 +13552,9 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
13346
13552
  /**
13347
13553
  * 挂载并观察侧栏导航增强:
13348
13554
  * - 只有在子插件探活成功时激活;
13349
- * - 在原生 newSession 前挂载唯一的 React 独立导航容器;
13350
- * - 靶向隐藏原生 newSession 与 panelList,绝不删除或克隆宿主 DOM 节点;
13555
+ * - 若宿主声明了 sidebar.session.action HOC,则原位接管新会话按钮为 Codex 扁平风格,保留同行扩展入口,并在其后挂载导航容器;
13556
+ * - 旧宿主未声明 sidebar.session.action 时,在原生 newSession 前挂载导航容器并同步隐藏原生入口;
13557
+ * - 仅靶向隐藏原生 panelList(及无 HOC 接管时的原生 newSession),绝不删除或克隆宿主 DOM 节点;
13351
13558
  * - 观察器仅监听挂载容器的存续,彻底切断 DOM 自触发循环;
13352
13559
  * - 卸载时彻底 unmount React Root、移除样式与标记,原生侧栏无损秒级复原。
13353
13560
  */
@@ -13359,6 +13566,9 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
13359
13566
  let currentSidebarRoot = null;
13360
13567
  let rafPending = false;
13361
13568
  let isEnabled = false;
13569
+ let unsubSessionAction;
13570
+ setSidebarEnabled(false);
13571
+ setSessionActionDeclared(false);
13362
13572
  const teardownMount = () => {
13363
13573
  if (currentContainer) {
13364
13574
  try {
@@ -13372,23 +13582,42 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
13372
13582
  currentSidebarRoot = null;
13373
13583
  }
13374
13584
  };
13585
+ const resolveMountAnchor = (sidebarRoot, target) => {
13586
+ let anchor = target;
13587
+ while (anchor.parentElement && anchor.parentElement !== sidebarRoot) anchor = anchor.parentElement;
13588
+ return anchor.parentElement === sidebarRoot ? anchor : null;
13589
+ };
13375
13590
  const tryMount = () => {
13376
13591
  if (disposed || !isEnabled || typeof document === "undefined") return;
13377
- if (currentContainer && document.contains(currentContainer)) return;
13592
+ if (currentContainer && document.contains(currentContainer)) {
13593
+ if (currentSidebarRoot && currentContainer.parentElement === currentSidebarRoot) {
13594
+ const newSessionEl = currentSidebarRoot.querySelector("[class*=\"newSessionRow\"], button[class*=\"newSession\"]");
13595
+ if (newSessionEl) {
13596
+ const anchor = resolveMountAnchor(currentSidebarRoot, newSessionEl);
13597
+ if (anchor) {
13598
+ const wantAfter = getSessionActionDeclared();
13599
+ if (wantAfter && anchor.nextElementSibling !== currentContainer) currentSidebarRoot.insertBefore(currentContainer, anchor.nextSibling);
13600
+ else if (!wantAfter && currentContainer.nextElementSibling !== anchor) currentSidebarRoot.insertBefore(currentContainer, anchor);
13601
+ }
13602
+ }
13603
+ }
13604
+ return;
13605
+ }
13378
13606
  if (currentContainer) teardownMount();
13379
- const nativeNewSession = document.querySelector("button[class*=\"newSession\"]");
13380
- if (!nativeNewSession) return;
13381
- const sidebarRoot = nativeNewSession.closest("[class*=\"root\"]") || nativeNewSession.parentElement;
13607
+ const nativeSessionEl = document.querySelector("[class*=\"newSessionRow\"], button[class*=\"newSession\"]");
13608
+ const nativePanelList = document.querySelector("nav[class*=\"panelList\"]");
13609
+ const anchorTarget = nativeSessionEl ?? nativePanelList;
13610
+ if (!anchorTarget) return;
13611
+ const sidebarRoot = anchorTarget.closest("[class*=\"root\"]") || anchorTarget.parentElement;
13382
13612
  if (!sidebarRoot) return;
13383
- let mountAnchor = nativeNewSession;
13384
- while (mountAnchor.parentElement && mountAnchor.parentElement !== sidebarRoot) mountAnchor = mountAnchor.parentElement;
13385
- if (mountAnchor.parentElement !== sidebarRoot) return;
13386
- if (!cleanupStyles) cleanupStyles = injectSidebarStyles();
13613
+ const mountAnchor = resolveMountAnchor(sidebarRoot, anchorTarget);
13614
+ if (!mountAnchor) return;
13615
+ const insertBeforeNode = Boolean(nativeSessionEl && getSessionActionDeclared()) ? mountAnchor.nextSibling : mountAnchor;
13387
13616
  const container = document.createElement("div");
13388
13617
  container.className = CONTAINER_CLASS;
13389
13618
  container.setAttribute("data-dcu-managed", "true");
13390
13619
  try {
13391
- sidebarRoot.insertBefore(container, mountAnchor);
13620
+ sidebarRoot.insertBefore(container, insertBeforeNode);
13392
13621
  currentContainer = container;
13393
13622
  (0, react_dom.render)(react.default.createElement(SidebarNav, { ctx }), container);
13394
13623
  sidebarRoot.setAttribute(SIDEBAR_ACTIVE_ATTR, "true");
@@ -13417,8 +13646,11 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
13417
13646
  if (disposed) return;
13418
13647
  if (nextEnabled === isEnabled) return;
13419
13648
  isEnabled = nextEnabled;
13420
- if (isEnabled) tryMount();
13421
- else {
13649
+ setSidebarEnabled(nextEnabled);
13650
+ if (isEnabled) {
13651
+ if (!cleanupStyles) cleanupStyles = injectSidebarStyles();
13652
+ tryMount();
13653
+ } else {
13422
13654
  teardownMount();
13423
13655
  if (cleanupStyles) {
13424
13656
  cleanupStyles();
@@ -13426,6 +13658,29 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
13426
13658
  }
13427
13659
  }
13428
13660
  };
13661
+ if (typeof ctx.slots?.inject === "function" && typeof ctx.slots?.register === "function") {
13662
+ const SessionActionLayer = createSessionActionLayer(ctx);
13663
+ try {
13664
+ const result = ctx.slots.inject("sidebar.session.action", () => {
13665
+ const unregister = ctx.slots.register({
13666
+ name: "sidebar.session.action",
13667
+ id: "codex-ui",
13668
+ order: Number.MAX_SAFE_INTEGER,
13669
+ locale: NS
13670
+ }, SessionActionLayer);
13671
+ setSessionActionDeclared(true);
13672
+ scheduleCheck();
13673
+ return () => {
13674
+ unregister?.();
13675
+ setSessionActionDeclared(false);
13676
+ scheduleCheck();
13677
+ };
13678
+ });
13679
+ if (typeof result === "function") unsubSessionAction = result;
13680
+ } catch {
13681
+ setSessionActionDeclared(false);
13682
+ }
13683
+ }
13429
13684
  sync();
13430
13685
  const onFocus = () => {
13431
13686
  sync();
@@ -13458,6 +13713,10 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
13458
13713
  }
13459
13714
  return () => {
13460
13715
  disposed = true;
13716
+ unsubSessionAction?.();
13717
+ unsubSessionAction = void 0;
13718
+ setSessionActionDeclared(false);
13719
+ setSidebarEnabled(false);
13461
13720
  if (typeof window !== "undefined") window.removeEventListener("focus", onFocus);
13462
13721
  if (observer) {
13463
13722
  observer.disconnect();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michengai/dsh-codex-ui",
3
- "version": "2.4.7",
3
+ "version": "2.4.9",
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",