@michengai/dsh-codex-ui 2.4.6 → 2.4.7

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,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.4.7] - 2026-11-25
4
+
5
+ - **Custom Input Width Restored After Restart and Maximize (Issue #115)**:
6
+ - 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;
7
+ - The new-conversation width handles keep working, including on hosts that publish the saved width directly on the message column.
8
+ - **Floating Conversation Header Follows Your Width**:
9
+ - 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.
10
+
3
11
  ## [2.4.6] - 2026-11-25
4
12
 
5
13
  - **Adaptive Auto-Hiding for Unused Default Workspace Section (Issue #114)**:
@@ -1,5 +1,13 @@
1
1
  # 更新日志
2
2
 
3
+ ## [2.4.7] - 2026-11-25
4
+
5
+ - **修复自定义输入宽度在重启并最大化后需要切页才恢复的问题(Issue #115)**:
6
+ - 设置过自定义消息/输入宽度后,重启应用并最大化窗口会立即按保存的宽度显示,不再需要切到其他页面再切回;
7
+ - 新建页的宽度拖拽保持可用,包括宿主直接把保存宽度发布到正文节点上的新版本。
8
+ - **浮动会话顶栏跟随输入宽度**:
9
+ - 开启云母悬浮卡片后,拖宽或收窄输入区时会话顶栏会同步跟随;最大化窗口、切换会话或从整页视图返回后仍保持与正文一致。
10
+
3
11
  ## [2.4.6] - 2026-11-25
4
12
 
5
13
  - **优化工作区分区展示与自适应隐身逻辑(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(--dsh-chat-content-width, var(--dsh-chat-user-width, 640px)) / 2 + 16px)}[data-dcu-width-handle=right]{left:calc(50% + var(--dsh-chat-content-width, var(--dsh-chat-user-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}`;
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 raw = body?.style.getPropertyValue("--dsh-chat-user-width") || getComputedStyle(root).getPropertyValue("--dsh-chat-user-width") || getComputedStyle(root).getPropertyValue("--dsh-chat-content-width");
10837
- return clamp(parseFloat(raw) || 640);
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
- body?.style.setProperty("--dsh-chat-user-width", `${value}px`);
10842
- root.style.setProperty("--dsh-chat-user-width", `${value}px`);
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
- const initialWidth = current();
10851
- body?.style.setProperty("--dsh-chat-user-width", `${initialWidth}px`);
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
- handle.setPointerCapture(event.pointerId);
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("pointerup", (event) => {
10876
- if (!dragging) return;
10877
- publish(initial + (event.clientX - origin) * (side === "right" ? 2 : -2), true);
10878
- dragging = false;
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}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michengai/dsh-codex-ui",
3
- "version": "2.4.6",
3
+ "version": "2.4.7",
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": {