@michengai/dsh-codex-ui 2.4.7 → 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 CHANGED
@@ -1,5 +1,11 @@
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
+
3
9
  ## [2.4.7] - 2026-11-25
4
10
 
5
11
  - **Custom Input Width Restored After Restart and Maximize (Issue #115)**:
@@ -1,5 +1,11 @@
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
+
3
9
  ## [2.4.7] - 2026-11-25
4
10
 
5
11
  - **修复自定义输入宽度在重启并最大化后需要切页才恢复的问题(Issue #115)**:
package/lib/client.js CHANGED
@@ -12232,6 +12232,195 @@ 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
  * 侧栏导航布局模型:
@@ -12320,39 +12509,6 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
12320
12509
  //#region src/client/sidebar/SidebarNav.tsx
12321
12510
  const IconBrowse = _deepseek_ai_dsh_client_ui_primitives.IconPluginPinwheelOutlineRegular ?? Blocks;
12322
12511
  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
12512
  function resolveSlotLabel(label) {
12357
12513
  if (typeof label === "function") try {
12358
12514
  const res = label();
@@ -12501,20 +12657,13 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
12501
12657
  }
12502
12658
  }, [ctx]);
12503
12659
  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]);
12660
+ const [sessionActionTakenOver, setSessionActionTakenOver] = (0, react.useState)(() => getSessionActionDeclared());
12661
+ (0, react.useEffect)(() => {
12662
+ setSessionActionTakenOver(getSessionActionDeclared());
12663
+ return subscribeSessionActionDeclared(() => {
12664
+ setSessionActionTakenOver(getSessionActionDeclared());
12665
+ });
12666
+ }, []);
12518
12667
  const handleSelectPanel = (0, react.useCallback)((id) => {
12519
12668
  setActivePanelId(id);
12520
12669
  try {
@@ -12547,12 +12696,8 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
12547
12696
  return;
12548
12697
  }
12549
12698
  } catch {}
12550
- handleStartSession();
12551
- }, [
12552
- ctx,
12553
- handleStartSession,
12554
- t
12555
- ]);
12699
+ document.querySelector("button[class*=\"newSession\"]")?.click();
12700
+ }, [ctx, t]);
12556
12701
  const [draggingId, setDraggingId] = (0, react.useState)(null);
12557
12702
  const [dragOver, setDragOver] = (0, react.useState)(null);
12558
12703
  const dragOverRef = (0, react.useRef)(null);
@@ -12693,73 +12838,43 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
12693
12838
  draggingId,
12694
12839
  handleDragEnd
12695
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
+ ]);
12696
12864
  const panelMap = (0, react.useMemo)(() => new Map(panels.map((p) => [p.id, p])), [panels]);
12697
12865
  const fixedPanels = (0, react.useMemo)(() => FIXED_PANEL_IDS.map((id) => panelMap.get(id)).filter((p) => Boolean(p)), [panelMap]);
12698
12866
  const userPinnedPanels = (0, react.useMemo)(() => layout.pinned.map((id) => panelMap.get(id)).filter((p) => Boolean(p)), [layout.pinned, panelMap]);
12699
12867
  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
12868
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("nav", {
12732
12869
  className: "dcu-sb-root",
12733
12870
  "data-dcu-sb-root": "true",
12734
12871
  children: [
12735
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
12872
+ !sessionActionTakenOver && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
12736
12873
  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
12874
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NewSessionButton, {
12875
+ ctx,
12876
+ label: t("sidebar.newSession", "新会话")
12877
+ })
12763
12878
  }),
12764
12879
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12765
12880
  className: "dcu-sb-section dcu-sb-pinned-section",
@@ -13015,18 +13130,73 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
13015
13130
  * - 使用 grid-template-rows 实现原位折叠动画;
13016
13131
  * - 原生减弱动画感知支持;
13017
13132
  * - 拖拽放置指示线样式;
13018
- * - 宿主原生 newSession 与 panelList 靶向隐藏。
13133
+ * - 宿主原生 panelList 靶向隐藏;当存在 sidebar.session.action HOC 接管时对齐同行样式,否则兼容隐藏原生 newSession / newSessionRow。
13019
13134
  */
13020
13135
  const SIDEBAR_STYLES_ID = "michengai-codex-ui-sidebar-styles";
13021
13136
  const SIDEBAR_ACTIVE_ATTR = "data-dcu-sidebar-active";
13022
13137
  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"],
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"],
13026
13141
  [${SIDEBAR_ACTIVE_ATTR}]:not([class*="collapsed"]) nav[class*="panelList"] {
13027
13142
  display: none !important;
13028
13143
  }
13029
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
+
13030
13200
  /* 折叠收缩态下隐藏自研导航,完全回退展示宿主原生折叠导轨(自带全部图标与完整生态) */
13031
13201
  [${SIDEBAR_ACTIVE_ATTR}][class*="collapsed"] .dcu-sb-root,
13032
13202
  [data-sidebar-collapsed="true"] .dcu-sb-root {
@@ -13326,6 +13496,34 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
13326
13496
  //#endregion
13327
13497
  //#region src/client/sidebar/index.ts
13328
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
+ }
13329
13527
  /**
13330
13528
  * 校验侧栏子插件是否在 Host 侧启用。
13331
13529
  * 遵循 fail-closed 原则:404、网络失败或未显式 enabled 时视为关闭并回退官方。
@@ -13346,8 +13544,9 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
13346
13544
  /**
13347
13545
  * 挂载并观察侧栏导航增强:
13348
13546
  * - 只有在子插件探活成功时激活;
13349
- * - 在原生 newSession 前挂载唯一的 React 独立导航容器;
13350
- * - 靶向隐藏原生 newSession 与 panelList,绝不删除或克隆宿主 DOM 节点;
13547
+ * - 若宿主声明了 sidebar.session.action HOC,则原位接管新会话按钮为 Codex 扁平风格,保留同行扩展入口,并在其后挂载导航容器;
13548
+ * - 旧宿主未声明 sidebar.session.action 时,在原生 newSession 前挂载导航容器并同步隐藏原生入口;
13549
+ * - 仅靶向隐藏原生 panelList(及无 HOC 接管时的原生 newSession),绝不删除或克隆宿主 DOM 节点;
13351
13550
  * - 观察器仅监听挂载容器的存续,彻底切断 DOM 自触发循环;
13352
13551
  * - 卸载时彻底 unmount React Root、移除样式与标记,原生侧栏无损秒级复原。
13353
13552
  */
@@ -13359,6 +13558,9 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
13359
13558
  let currentSidebarRoot = null;
13360
13559
  let rafPending = false;
13361
13560
  let isEnabled = false;
13561
+ let unsubSessionAction;
13562
+ setSidebarEnabled(false);
13563
+ setSessionActionDeclared(false);
13362
13564
  const teardownMount = () => {
13363
13565
  if (currentContainer) {
13364
13566
  try {
@@ -13372,23 +13574,42 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
13372
13574
  currentSidebarRoot = null;
13373
13575
  }
13374
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
+ };
13375
13582
  const tryMount = () => {
13376
13583
  if (disposed || !isEnabled || typeof document === "undefined") return;
13377
- if (currentContainer && document.contains(currentContainer)) return;
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
+ }
13378
13598
  if (currentContainer) teardownMount();
13379
- const nativeNewSession = document.querySelector("button[class*=\"newSession\"]");
13380
- if (!nativeNewSession) return;
13381
- const sidebarRoot = nativeNewSession.closest("[class*=\"root\"]") || nativeNewSession.parentElement;
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;
13382
13604
  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();
13605
+ const mountAnchor = resolveMountAnchor(sidebarRoot, anchorTarget);
13606
+ if (!mountAnchor) return;
13607
+ const insertBeforeNode = Boolean(nativeSessionEl && getSessionActionDeclared()) ? mountAnchor.nextSibling : mountAnchor;
13387
13608
  const container = document.createElement("div");
13388
13609
  container.className = CONTAINER_CLASS;
13389
13610
  container.setAttribute("data-dcu-managed", "true");
13390
13611
  try {
13391
- sidebarRoot.insertBefore(container, mountAnchor);
13612
+ sidebarRoot.insertBefore(container, insertBeforeNode);
13392
13613
  currentContainer = container;
13393
13614
  (0, react_dom.render)(react.default.createElement(SidebarNav, { ctx }), container);
13394
13615
  sidebarRoot.setAttribute(SIDEBAR_ACTIVE_ATTR, "true");
@@ -13417,8 +13638,11 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
13417
13638
  if (disposed) return;
13418
13639
  if (nextEnabled === isEnabled) return;
13419
13640
  isEnabled = nextEnabled;
13420
- if (isEnabled) tryMount();
13421
- else {
13641
+ setSidebarEnabled(nextEnabled);
13642
+ if (isEnabled) {
13643
+ if (!cleanupStyles) cleanupStyles = injectSidebarStyles();
13644
+ tryMount();
13645
+ } else {
13422
13646
  teardownMount();
13423
13647
  if (cleanupStyles) {
13424
13648
  cleanupStyles();
@@ -13426,6 +13650,29 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
13426
13650
  }
13427
13651
  }
13428
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
+ }
13429
13676
  sync();
13430
13677
  const onFocus = () => {
13431
13678
  sync();
@@ -13458,6 +13705,10 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
13458
13705
  }
13459
13706
  return () => {
13460
13707
  disposed = true;
13708
+ unsubSessionAction?.();
13709
+ unsubSessionAction = void 0;
13710
+ setSessionActionDeclared(false);
13711
+ setSidebarEnabled(false);
13461
13712
  if (typeof window !== "undefined") window.removeEventListener("focus", onFocus);
13462
13713
  if (observer) {
13463
13714
  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.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",