@michengai/dsh-codex-ui 0.2.78 → 0.2.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/client.js +112 -100
  2. package/package.json +7 -7
package/dist/client.js CHANGED
@@ -3107,24 +3107,112 @@ header [data-dcu-title-folder] svg,header [data-dcu-title-more] svg{display:bloc
3107
3107
  const handle = target.closest("[data-side=\"sidebar\"]");
3108
3108
  return handle !== null && String(handle.className).includes("handle");
3109
3109
  }
3110
+ /** 解析宿主 AppFrame 的 grid-template-columns。 */
3111
+ function parseSidebarGrid(value) {
3112
+ const match = /^(\d+(?:\.\d+)?)px\s+(minmax\(0,\s*1fr\))\s+(\d+(?:\.\d+)?)px$/.exec(value.trim());
3113
+ if (match === null) return void 0;
3114
+ return {
3115
+ sidebar: Number(match[1]),
3116
+ middle: match[2],
3117
+ details: Number(match[3])
3118
+ };
3119
+ }
3120
+ /** 折叠列保持原值;默认展开列收到 Codex 宽度,用户再拉宽时只减去默认多出来的部分。 */
3121
+ function slimedSidebarWidth(hostWidth, collapsed) {
3122
+ if (collapsed || hostWidth <= 80) return hostWidth;
3123
+ if (hostWidth <= 280) return 240;
3124
+ return hostWidth - 40;
3125
+ }
3126
+ function slimedGridTemplate(tracks, collapsed) {
3127
+ return `${slimedSidebarWidth(tracks.sidebar, collapsed)}px ${tracks.middle} ${tracks.details}px`;
3128
+ }
3129
+ function findSidebarFrame(root) {
3130
+ const marked = root.querySelector("[data-sidebar-collapsed]");
3131
+ if (marked !== null) return marked;
3132
+ for (const node of root.querySelectorAll("div")) if (parseSidebarGrid(node.style.gridTemplateColumns) !== void 0) return node;
3133
+ }
3134
+ function applySlimSidebar(frame) {
3135
+ if (frame.hasAttribute("data-dragging")) return false;
3136
+ const tracks = parseSidebarGrid(frame.style.gridTemplateColumns);
3137
+ if (tracks === void 0) return false;
3138
+ const collapsed = frame.hasAttribute("data-sidebar-collapsed");
3139
+ const next = slimedGridTemplate(tracks, collapsed);
3140
+ if (frame.style.gridTemplateColumns === next) return false;
3141
+ frame.style.gridTemplateColumns = next;
3142
+ const handle = frame.querySelector("[data-side=\"sidebar\"]");
3143
+ if (handle !== null && !collapsed) handle.style.left = `${slimedSidebarWidth(tracks.sidebar, collapsed)}px`;
3144
+ return true;
3145
+ }
3146
+ function observeSlimSidebar() {
3147
+ if (typeof document === "undefined" || document.body === null) return () => {};
3148
+ let applying = false;
3149
+ let frame;
3150
+ let pending;
3151
+ let frameObserver;
3152
+ const watchFrame = (next) => {
3153
+ if (frame === next) return;
3154
+ frameObserver?.disconnect();
3155
+ frame = next;
3156
+ if (frame === void 0) return;
3157
+ frameObserver = new MutationObserver(schedule);
3158
+ frameObserver.observe(frame, {
3159
+ attributes: true,
3160
+ attributeFilter: [
3161
+ "style",
3162
+ "data-sidebar-collapsed",
3163
+ "data-dragging"
3164
+ ]
3165
+ });
3166
+ };
3167
+ const apply = () => {
3168
+ if (applying) return;
3169
+ applying = true;
3170
+ try {
3171
+ if (frame === void 0 || !frame.isConnected) watchFrame(findSidebarFrame(document));
3172
+ if (frame !== void 0) applySlimSidebar(frame);
3173
+ } finally {
3174
+ applying = false;
3175
+ }
3176
+ };
3177
+ const schedule = () => {
3178
+ if (pending !== void 0) return;
3179
+ pending = window.requestAnimationFrame(() => {
3180
+ pending = void 0;
3181
+ apply();
3182
+ });
3183
+ };
3184
+ apply();
3185
+ const observer = new MutationObserver(() => {
3186
+ if (frame === void 0 || !frame.isConnected) schedule();
3187
+ });
3188
+ observer.observe(document.body, {
3189
+ childList: true,
3190
+ subtree: true
3191
+ });
3192
+ return () => {
3193
+ observer.disconnect();
3194
+ frameObserver?.disconnect();
3195
+ if (pending !== void 0) window.cancelAnimationFrame(pending);
3196
+ };
3197
+ }
3110
3198
  //#endregion
3111
3199
  //#region src/client/CodexSidebar.tsx
3112
3200
  const subscribeEmptyCompanionTabs = () => () => {};
3113
3201
  const getEmptyCompanionTabs = () => EMPTY_COMPANION_TABS;
3114
- const SIDEBAR_COLUMN_TRANSITION_MS = 300;
3202
+ const SIDEBAR_COLLAPSE_SETTLE_MS = 140;
3115
3203
  const stylesheet$3 = `
3116
- .dcu-root{--dcu-font:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI","Microsoft YaHei UI",sans-serif;--dcu-sidebar-primary:#393d3e;--dcu-sidebar-secondary:#676b6c;--dcu-sidebar-tertiary:#9a9f9f;--dcu-sidebar-navigation:#4e5253;--dcu-sidebar-icon:#4e5253;--dcu-sidebar-hover:#dfe8e5;--dcu-sidebar-border:rgba(37,46,41,.10);--dcu-tip-bg:#ffffff;--dcu-tip-shadow:0 10px 32px rgba(31,39,36,.22);height:100%;min-width:0;box-sizing:border-box;display:flex;flex-direction:column;background:#eef7f5;color:var(--dcu-sidebar-primary);font:14px/20px var(--dcu-font)}body[data-ds-dark-theme] .dcu-root{background:#1d2120;--dcu-sidebar-primary:#b9bab9;--dcu-sidebar-secondary:#909191;--dcu-sidebar-tertiary:#666867;--dcu-sidebar-navigation:#b9bab9;--dcu-sidebar-icon:#afafaf;--dcu-sidebar-hover:#303432;--dcu-sidebar-border:rgba(255,255,255,.08);--dcu-tip-bg:#2a2e2c;--dcu-tip-shadow:0 10px 30px rgba(0,0,0,.28)}
3117
- .dcu-expanded-shell{display:flex;min-height:0;flex:1;flex-direction:column;animation:dcu-sidebar-expanded-in 140ms cubic-bezier(.16,1,.3,1)}.dcu-compact-shell{display:none}.dcu-root.dcu-compact .dcu-expanded-shell{display:none}.dcu-root.dcu-compact .dcu-compact-shell{display:flex;min-height:0;flex:1;flex-direction:column;align-items:center;animation:dcu-sidebar-compact-in 120ms ease-out}@keyframes dcu-sidebar-expanded-in{from{opacity:0;transform:translateX(-4px)}to{opacity:1;transform:none}}@keyframes dcu-sidebar-compact-in{from{opacity:0;transform:scale(.96)}to{opacity:1;transform:none}}
3204
+ .dcu-root{--dcu-font:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI","Microsoft YaHei UI",sans-serif;--dcu-sidebar-wide-width:240px;--dcu-sidebar-primary:#393d3e;--dcu-sidebar-secondary:#676b6c;--dcu-sidebar-tertiary:#9a9f9f;--dcu-sidebar-navigation:#4e5253;--dcu-sidebar-icon:#4e5253;--dcu-sidebar-hover:#dfe8e5;--dcu-sidebar-border:rgba(37,46,41,.10);--dcu-tip-bg:#ffffff;--dcu-tip-shadow:0 10px 32px rgba(31,39,36,.22);height:100%;min-width:0;box-sizing:border-box;display:flex;flex-direction:column;overflow:hidden;background:#eef7f5;color:var(--dcu-sidebar-primary);font:14px/20px var(--dcu-font)}body[data-ds-dark-theme] .dcu-root{background:#1d2120;--dcu-sidebar-primary:#b9bab9;--dcu-sidebar-secondary:#909191;--dcu-sidebar-tertiary:#666867;--dcu-sidebar-navigation:#b9bab9;--dcu-sidebar-icon:#afafaf;--dcu-sidebar-hover:#303432;--dcu-sidebar-border:rgba(255,255,255,.08);--dcu-tip-bg:#2a2e2c;--dcu-tip-shadow:0 10px 30px rgba(0,0,0,.28)}
3205
+ .dcu-expanded-shell{display:flex;width:var(--dcu-sidebar-wide-width);min-height:0;flex:1 0 auto;flex-direction:column;transform-origin:left center;transition:opacity 140ms ease-out,transform 180ms cubic-bezier(.16,1,.3,1);animation:dcu-sidebar-expanded-in 180ms cubic-bezier(.16,1,.3,1)}.dcu-compact-shell{display:none;width:56px}.dcu-root.dcu-collapsing .dcu-expanded-shell{opacity:0;transform:translateX(-6px);pointer-events:none}.dcu-root.dcu-compact .dcu-expanded-shell{display:none}.dcu-root.dcu-compact .dcu-compact-shell{display:flex;min-height:0;flex:1;flex-direction:column;align-items:center;animation:dcu-sidebar-compact-in 140ms ease-out}@keyframes dcu-sidebar-expanded-in{from{opacity:0;transform:translateX(-6px)}to{opacity:1;transform:none}}@keyframes dcu-sidebar-compact-in{from{opacity:0;transform:translateX(-4px)}to{opacity:1;transform:none}}
3118
3206
  .dcu-root *{box-sizing:border-box}.dcu-head{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;column-gap:8px;height:60px;padding:8px 8px 8px 12px}.dcu-brand{border:0;background:transparent;color:inherit;padding:0;display:flex;align-items:center;min-width:0;overflow:hidden}.dcu-brand svg{display:block;width:auto;max-width:100%;height:24px;min-width:0}.dcu-head-actions{display:grid;grid-auto-flow:column;grid-auto-columns:28px;align-items:center;column-gap:8px;height:28px}
3119
3207
  .dcu-icon,.dcu-menu button,.dcu-footer-link{appearance:none;border:0;background:transparent;color:inherit;font:inherit;cursor:pointer}.dcu-icon{display:grid;place-items:center;width:36px;height:36px;border-radius:8px;color:var(--dcu-sidebar-icon)}.dcu-head .dcu-icon{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;margin:0;padding:0;border-radius:50%;line-height:0}.dcu-head .dcu-icon svg{display:block;width:16px;height:16px}
3120
3208
  .dcu-icon:hover,.dcu-menu button:hover:not(:disabled),.dcu-footer-link:hover{background:var(--dcu-sidebar-hover);color:var(--dcu-sidebar-primary)}
3121
3209
  .dcu-menu{padding:0 6px 8px;display:grid;gap:2px}.dcu-menu button,.dcu-footer-link{display:grid;grid-template-columns:20px minmax(0,1fr);column-gap:8px;align-items:center;width:100%;min-height:36px;padding:0 4px;border-radius:8px;color:var(--dcu-sidebar-navigation);font-size:14px;line-height:20px;text-align:left;font-weight:400}
3122
3210
  .dcu-menu-icon{display:grid;place-items:center start;width:20px;height:20px}.dcu-menu-icon svg,.dcu-footer-link svg{display:block;width:16px;height:16px;color:var(--dcu-sidebar-icon)}.dcu-menu button:disabled{color:var(--dcu-sidebar-secondary);cursor:default;opacity:1}.dcu-menu button:disabled svg{color:var(--dcu-sidebar-secondary)}
3123
3211
  .dcu-extension-items{display:grid;gap:1px;margin:1px 0 4px 28px}.dcu-extension-items button{min-height:32px;color:var(--dcu-sidebar-secondary);font-size:13px;font-weight:400}
3124
- .dcu-workspaces{display:flex;min-height:0;flex:1;flex-direction:column;margin-top:2px;padding-top:8px;border-top:1px solid var(--dcu-sidebar-border)}.dcu-workspaces.dcu-workspaces-tabs{padding-top:0;border-top:0}.dcu-im-tabs{display:flex;gap:16px;margin:0 8px 12px;padding:0;border-bottom:1px solid var(--dcu-sidebar-border)}.dcu-im-tab{appearance:none;border:0;background:transparent;color:var(--dcu-sidebar-secondary);padding:8px 0 7px;font:14px/22px var(--dcu-font);font-weight:500;cursor:pointer}.dcu-im-tab[data-on=true]{color:var(--dcu-sidebar-primary);font-weight:600;box-shadow:inset 0 -2px 0 currentColor}.dcu-native-workspaces{display:flex;min-height:0;flex:1}.dcu-native-workspaces>*{min-width:0;flex:1}.dcu-native-workspaces .ima-tabs,.dcu-native-workspaces [role=tablist]{display:none!important}.dcu-foot{display:grid;gap:4px;padding:8px 6px 12px;border-top:1px solid var(--dcu-sidebar-border)}.dcu-footer-actions:empty,.dcu-settings-seat:empty{display:none}.dcu-settings-seat>button{width:100%;min-height:36px;padding-left:4px!important;color:var(--dcu-sidebar-navigation);font:14px/20px var(--dcu-font);font-weight:400}.dcu-compact{width:100%;align-items:center;overflow:hidden;padding:10px 0 8px}.dcu-compact-nav{display:flex;flex:1;min-height:0;flex-direction:column;align-items:center;gap:2px;overflow:auto;padding:6px 0}.dcu-compact .dcu-icon{width:36px;height:36px;flex:none}.dcu-compact .dcu-foot{width:36px;margin-top:auto;padding:8px 0;border-top:0}.dcu-compact .dcu-settings-seat{width:36px;overflow:hidden}.dcu-compact .dcu-settings-seat>button{display:grid;place-items:center;width:36px;min-height:36px;padding:0!important;font-size:0!important;line-height:0}.dcu-compact .dcu-settings-seat>button svg{width:16px;height:16px}.dcu-compact .dcu-footer-link{display:flex;justify-content:center;width:36px;padding:0;font-size:0}.dcu-compact .dcu-footer-link svg{width:16px;height:16px}
3212
+ .dcu-workspaces{display:flex;min-height:0;flex:1;flex-direction:column;margin-top:2px;padding-top:8px;border-top:1px solid var(--dcu-sidebar-border)}.dcu-workspaces.dcu-workspaces-tabs{padding-top:0;border-top:0}.dcu-im-tabs{display:flex;gap:16px;margin:0 8px 12px;padding:0;border-bottom:1px solid var(--dcu-sidebar-border)}.dcu-im-tab{appearance:none;border:0;background:transparent;color:var(--dcu-sidebar-secondary);padding:8px 0 7px;font:14px/22px var(--dcu-font);font-weight:500;cursor:pointer}.dcu-im-tab[data-on=true]{color:var(--dcu-sidebar-primary);font-weight:600;box-shadow:inset 0 -2px 0 currentColor}.dcu-native-workspaces{display:flex;min-height:0;flex:1}.dcu-native-workspaces>*{min-width:0;flex:1}.dcu-native-workspaces .ima-tabs,.dcu-native-workspaces [role=tablist]{display:none!important}.dcu-foot{display:grid;width:var(--dcu-sidebar-wide-width);gap:4px;padding:8px 6px 12px;border-top:1px solid var(--dcu-sidebar-border);transition:opacity 120ms ease-out,transform 160ms cubic-bezier(.16,1,.3,1)}.dcu-root.dcu-collapsing>.dcu-foot{opacity:0;transform:translateX(-4px);pointer-events:none}.dcu-footer-actions:empty,.dcu-settings-seat:empty{display:none}.dcu-settings-seat>button{width:100%;min-height:36px;padding-left:4px!important;color:var(--dcu-sidebar-navigation);font:14px/20px var(--dcu-font);font-weight:400}.dcu-compact{width:100%;align-items:flex-start;overflow:hidden;padding:10px 0 8px}.dcu-compact-nav{display:flex;flex:1;min-height:0;flex-direction:column;align-items:center;gap:2px;overflow:auto;padding:6px 0}.dcu-compact .dcu-icon{width:36px;height:36px;flex:none}.dcu-compact .dcu-foot{width:36px;margin-top:auto;margin-left:10px;padding:8px 0;border-top:0}.dcu-compact .dcu-settings-seat{width:36px;overflow:hidden}.dcu-compact .dcu-settings-seat>button{display:grid;place-items:center;width:36px;min-height:36px;padding:0!important;font-size:0!important;line-height:0}.dcu-compact .dcu-settings-seat>button svg{width:16px;height:16px}.dcu-compact .dcu-footer-link{display:flex;justify-content:center;width:36px;padding:0;font-size:0}.dcu-compact .dcu-footer-link svg{width:16px;height:16px}
3125
3213
  .dcu-dependency-notice{margin:0 10px 8px;border:1px solid var(--dcu-sidebar-border);border-radius:8px;padding:8px;color:var(--dcu-sidebar-secondary);font-size:12px;line-height:18px}
3126
3214
  [role="dialog"][aria-labelledby]{width:min(1000px,calc(100vw - 48px));max-width:calc(100vw - 48px);height:min(800px,calc(100vh - 48px))}
3127
- .dcu-search-scrim{position:fixed;z-index:10020;inset:0;display:flex;justify-content:center;align-items:flex-start;padding:72px 20px;background:color-mix(in srgb,#000 48%,transparent);animation:dcu-search-scrim-in 140ms ease-out}.dcu-search-dialog{width:min(560px,100%);max-height:min(640px,calc(100vh - 120px));overflow:auto;border:1px solid var(--dcu-sidebar-border);border-radius:16px;padding:10px;background:var(--dsw-specific-menu);box-shadow:var(--dsw-shadow-lv4);animation:dcu-search-dialog-in 180ms cubic-bezier(.16,1,.3,1)}@keyframes dcu-search-scrim-in{from{opacity:0}to{opacity:1}}@keyframes dcu-search-dialog-in{from{opacity:0;transform:translateY(-6px) scale(.985)}to{opacity:1;transform:none}}.dcu-search-input{margin-bottom:8px}.dcu-search-section{padding:6px 0}.dcu-search-title{padding:0 8px 4px;color:var(--dcu-sidebar-tertiary);font-size:12px;font-weight:600}.dcu-search-row{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:12px;width:100%;min-height:34px;border:0;border-radius:8px;padding:6px 8px;background:transparent;color:var(--dcu-sidebar-primary);font:inherit;text-align:left;cursor:pointer}.dcu-search-row:hover,.dcu-search-row[data-active=true]{background:var(--dcu-sidebar-hover)}.dcu-search-main{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dcu-search-detail{max-width:160px;overflow:hidden;color:var(--dcu-sidebar-tertiary);font-size:12px;text-overflow:ellipsis;white-space:nowrap}.dcu-search-empty{padding:18px 8px;color:var(--dcu-sidebar-tertiary);font-size:13px}@media (prefers-reduced-motion:reduce){.dcu-expanded-shell,.dcu-root.dcu-compact .dcu-compact-shell,.dcu-search-scrim,.dcu-search-dialog{animation:none}}
3215
+ .dcu-search-scrim{position:fixed;z-index:10020;inset:0;display:flex;justify-content:center;align-items:flex-start;padding:72px 20px;background:color-mix(in srgb,#000 48%,transparent);animation:dcu-search-scrim-in 140ms ease-out}.dcu-search-dialog{width:min(560px,100%);max-height:min(640px,calc(100vh - 120px));overflow:auto;border:1px solid var(--dcu-sidebar-border);border-radius:16px;padding:10px;background:var(--dsw-specific-menu);box-shadow:var(--dsw-shadow-lv4);animation:dcu-search-dialog-in 180ms cubic-bezier(.16,1,.3,1)}@keyframes dcu-search-scrim-in{from{opacity:0}to{opacity:1}}@keyframes dcu-search-dialog-in{from{opacity:0;transform:translateY(-6px) scale(.985)}to{opacity:1;transform:none}}.dcu-search-input{margin-bottom:8px}.dcu-search-section{padding:6px 0}.dcu-search-title{padding:0 8px 4px;color:var(--dcu-sidebar-tertiary);font-size:12px;font-weight:600}.dcu-search-row{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:12px;width:100%;min-height:34px;border:0;border-radius:8px;padding:6px 8px;background:transparent;color:var(--dcu-sidebar-primary);font:inherit;text-align:left;cursor:pointer}.dcu-search-row:hover,.dcu-search-row[data-active=true]{background:var(--dcu-sidebar-hover)}.dcu-search-main{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dcu-search-detail{max-width:160px;overflow:hidden;color:var(--dcu-sidebar-tertiary);font-size:12px;text-overflow:ellipsis;white-space:nowrap}.dcu-search-empty{padding:18px 8px;color:var(--dcu-sidebar-tertiary);font-size:13px}@media (prefers-reduced-motion:reduce){.dcu-expanded-shell,.dcu-root.dcu-compact .dcu-compact-shell,.dcu-foot,.dcu-search-scrim,.dcu-search-dialog{animation:none;transition:none}}
3128
3216
  [data-conversation-scroll]{--dsh-chat-content-width:800px;--dsh-composer-card-max-width:calc(var(--dsh-chat-content-width) + 32px);--dsh-composer-side-clearance:24px}[data-conversation-scroll] [data-chat-flow]{gap:20px}[data-conversation-scroll] [data-composer-card]{min-height:96px;padding-top:10px;border-radius:16px;box-shadow:var(--dsw-shadow-lv3);transition:border-color 180ms ease,box-shadow 180ms ease}[data-conversation-scroll] [data-composer-card]:focus-within{border-color:var(--dsw-alias-button-info-fill);box-shadow:0 0 0 2px var(--dsw-static-deepseek-50),var(--dsw-shadow-lv3)}[data-conversation-scroll] [data-input-mirror]{min-height:44px}@media (prefers-reduced-motion:reduce){[data-conversation-scroll] [data-composer-card]{transition:none}}
3129
3217
  `;
3130
3218
  function MenuIcon({ children }) {
@@ -3425,6 +3513,9 @@ header [data-dcu-title-folder] svg,header [data-dcu-title-more] svg{display:bloc
3425
3513
  function CodexSidebar({ collapsed, width, openSession, startSession, toggleSidebar, archiveSession, deleteSession, forkSession, renameSession, openPath, companionSlots, renderSlot, t, useSessions, useWorkspaces }) {
3426
3514
  const compact = collapsed || width < 80;
3427
3515
  const [visualCompact, setVisualCompact] = (0, react.useState)(compact);
3516
+ const [collapsing, setCollapsing] = (0, react.useState)(false);
3517
+ const lastWideWidth = (0, react.useRef)(width >= 80 ? width : 240);
3518
+ if (!compact) lastWideWidth.current = width;
3428
3519
  const settingsSeat = (0, react.useRef)(null);
3429
3520
  const search = (0, react.useRef)(null);
3430
3521
  const toggleSidebarRef = (0, react.useRef)(toggleSidebar);
@@ -3493,18 +3584,25 @@ header [data-dcu-title-folder] svg,header [data-dcu-title-more] svg{display:bloc
3493
3584
  };
3494
3585
  }, [toggleSidebar]);
3495
3586
  (0, react.useLayoutEffect)(() => {
3496
- if (compact) {
3497
- setVisualCompact(true);
3587
+ if (!compact) {
3588
+ setCollapsing(false);
3589
+ setVisualCompact(false);
3590
+ return;
3591
+ }
3592
+ if (visualCompact) {
3593
+ setCollapsing(false);
3498
3594
  return;
3499
3595
  }
3500
- if (!visualCompact) return;
3501
3596
  if (window.matchMedia?.("(prefers-reduced-motion: reduce)").matches === true) {
3502
- setVisualCompact(false);
3597
+ setCollapsing(false);
3598
+ setVisualCompact(true);
3503
3599
  return;
3504
3600
  }
3601
+ setCollapsing(true);
3505
3602
  const timer = window.setTimeout(() => {
3506
- setVisualCompact(false);
3507
- }, SIDEBAR_COLUMN_TRANSITION_MS);
3603
+ setVisualCompact(true);
3604
+ setCollapsing(false);
3605
+ }, SIDEBAR_COLLAPSE_SETTLE_MS);
3508
3606
  return () => {
3509
3607
  window.clearTimeout(timer);
3510
3608
  };
@@ -3513,8 +3611,10 @@ header [data-dcu-title-folder] svg,header [data-dcu-title-more] svg{display:bloc
3513
3611
  wide: true,
3514
3612
  expandSidebar
3515
3613
  }), [expandSidebar, renderSlot]);
3614
+ const sidebarStyle = { "--dcu-sidebar-wide-width": `${lastWideWidth.current}px` };
3516
3615
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("aside", {
3517
- className: `dcu-root${visualCompact ? " dcu-compact" : ""}`,
3616
+ className: `dcu-root${visualCompact ? " dcu-compact" : ""}${collapsing ? " dcu-collapsing" : ""}`,
3617
+ style: sidebarStyle,
3518
3618
  "aria-label": t("sidebar.label"),
3519
3619
  children: [
3520
3620
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: stylesheet$3 }),
@@ -4407,94 +4507,6 @@ header [data-dcu-title-folder] svg,header [data-dcu-title-more] svg{display:bloc
4407
4507
  if (frame !== void 0) window.cancelAnimationFrame(frame);
4408
4508
  };
4409
4509
  }
4410
- /** 解析宿主 AppFrame 的 grid-template-columns。 */
4411
- function parseSidebarGrid(value) {
4412
- const match = /^(\d+(?:\.\d+)?)px\s+(minmax\(0,\s*1fr\))\s+(\d+(?:\.\d+)?)px$/.exec(value.trim());
4413
- if (match === null) return void 0;
4414
- return {
4415
- sidebar: Number(match[1]),
4416
- middle: match[2],
4417
- details: Number(match[3])
4418
- };
4419
- }
4420
- /** 折叠列保持原值;默认展开列收到 Codex 宽度,用户再拉宽时只减去默认多出来的部分。 */
4421
- function slimedSidebarWidth(hostWidth, collapsed) {
4422
- if (collapsed || hostWidth <= 80) return hostWidth;
4423
- if (hostWidth <= 280) return 240;
4424
- return hostWidth - 40;
4425
- }
4426
- function slimedGridTemplate(tracks, collapsed) {
4427
- return `${slimedSidebarWidth(tracks.sidebar, collapsed)}px ${tracks.middle} ${tracks.details}px`;
4428
- }
4429
- function findSidebarFrame(root) {
4430
- const marked = root.querySelector("[data-sidebar-collapsed]");
4431
- if (marked !== null) return marked;
4432
- for (const node of root.querySelectorAll("div")) if (parseSidebarGrid(node.style.gridTemplateColumns) !== void 0) return node;
4433
- }
4434
- function applySlimSidebar(frame) {
4435
- if (frame.hasAttribute("data-dragging")) return false;
4436
- const tracks = parseSidebarGrid(frame.style.gridTemplateColumns);
4437
- if (tracks === void 0) return false;
4438
- const collapsed = frame.hasAttribute("data-sidebar-collapsed");
4439
- const next = slimedGridTemplate(tracks, collapsed);
4440
- if (frame.style.gridTemplateColumns === next) return false;
4441
- frame.style.gridTemplateColumns = next;
4442
- const handle = frame.querySelector("[data-side=\"sidebar\"]");
4443
- if (handle !== null && !collapsed) handle.style.left = `${slimedSidebarWidth(tracks.sidebar, collapsed)}px`;
4444
- return true;
4445
- }
4446
- function observeSlimSidebar() {
4447
- if (typeof document === "undefined" || document.body === null) return () => {};
4448
- let applying = false;
4449
- let frame;
4450
- let pending;
4451
- let frameObserver;
4452
- const watchFrame = (next) => {
4453
- if (frame === next) return;
4454
- frameObserver?.disconnect();
4455
- frame = next;
4456
- if (frame === void 0) return;
4457
- frameObserver = new MutationObserver(schedule);
4458
- frameObserver.observe(frame, {
4459
- attributes: true,
4460
- attributeFilter: [
4461
- "style",
4462
- "data-sidebar-collapsed",
4463
- "data-dragging"
4464
- ]
4465
- });
4466
- };
4467
- const apply = () => {
4468
- if (applying) return;
4469
- applying = true;
4470
- try {
4471
- if (frame === void 0 || !frame.isConnected) watchFrame(findSidebarFrame(document));
4472
- if (frame !== void 0) applySlimSidebar(frame);
4473
- } finally {
4474
- applying = false;
4475
- }
4476
- };
4477
- const schedule = () => {
4478
- if (pending !== void 0) return;
4479
- pending = window.requestAnimationFrame(() => {
4480
- pending = void 0;
4481
- apply();
4482
- });
4483
- };
4484
- apply();
4485
- const observer = new MutationObserver(() => {
4486
- if (frame === void 0 || !frame.isConnected) schedule();
4487
- });
4488
- observer.observe(document.body, {
4489
- childList: true,
4490
- subtree: true
4491
- });
4492
- return () => {
4493
- observer.disconnect();
4494
- frameObserver?.disconnect();
4495
- if (pending !== void 0) window.cancelAnimationFrame(pending);
4496
- };
4497
- }
4498
4510
  //#endregion
4499
4511
  //#region src/client/conversation-dom.ts
4500
4512
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michengai/dsh-codex-ui",
3
- "version": "0.2.78",
3
+ "version": "0.2.79",
4
4
  "description": "以 Codex 风格重构 DSH Web 侧栏的独立客户端插件",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {
@@ -51,11 +51,6 @@
51
51
  "platform": "web"
52
52
  }
53
53
  },
54
- "scripts": {
55
- "build": "tsc --noEmit && tsdown",
56
- "typecheck": "tsc --noEmit",
57
- "test": "pnpm run typecheck && vitest run tests/client-runtime.integration.spec.ts && tsdown && node tests/run-assertions.mjs"
58
- },
59
54
  "peerDependencies": {
60
55
  "@deepseek-ai/cordis": ">=4.0.1 <5.0.0",
61
56
  "@deepseek-ai/dsh-client-locale": ">=0.1.0-rc.0 <0.2.0",
@@ -101,5 +96,10 @@
101
96
  "tsx": "^4.22.4",
102
97
  "typescript": "^6.0.3",
103
98
  "vitest": "^4.1.8"
99
+ },
100
+ "scripts": {
101
+ "build": "tsc --noEmit && tsdown",
102
+ "typecheck": "tsc --noEmit",
103
+ "test": "pnpm run typecheck && vitest run tests/client-runtime.integration.spec.ts && tsdown && node tests/run-assertions.mjs"
104
104
  }
105
- }
105
+ }