@michengai/dsh-codex-ui 2.0.12 → 2.0.14
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 +15 -0
- package/CHANGELOG.zh-CN.md +15 -0
- package/README.md +4 -3
- package/README.zh-CN.md +4 -3
- package/lib/client.js +1077 -241
- package/lib/composer-plugin.d.mts +2 -6
- package/lib/composer-plugin.mjs +745 -12
- package/lib/desktop-menu-plugin.mjs +1 -1
- package/lib/index.mjs +1 -1
- package/lib/{profile-resolver-B1VNepo_.mjs → profile-resolver-BkTv7lmZ.mjs} +2 -0
- package/lib/session-title-plugin.mjs +6 -0
- package/lib/settings-skin-plugin.mjs +1 -1
- package/lib/sidebar-plugin.mjs +1 -1
- package/lib/theme-plugin.mjs +1 -1
- package/locale/composer/en.json +1 -1
- package/locale/composer/zh.json +1 -1
- package/package.json +31 -29
package/lib/client.js
CHANGED
|
@@ -50,22 +50,55 @@ window.__ModuleLoader__.load({
|
|
|
50
50
|
//#endregion
|
|
51
51
|
//#region src/client/host-icons.ts
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
54
|
-
* 必须动态读取,不能写成静态属性访问,否则旧宿主一加载客户端就会拿到 undefined。
|
|
53
|
+
* 宿主通用矢量安全兜底图标(坚决禁止在模块顶层抛出硬异常导致整个客户端猝死)
|
|
55
54
|
*/
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
55
|
+
function createFallbackIcon(pathData) {
|
|
56
|
+
return function FallbackIcon(props) {
|
|
57
|
+
return react.default.createElement("svg", {
|
|
58
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
59
|
+
width: props.size ?? 16,
|
|
60
|
+
height: props.size ?? 16,
|
|
61
|
+
viewBox: "0 0 16 16",
|
|
62
|
+
fill: "none",
|
|
63
|
+
stroke: "currentColor",
|
|
64
|
+
strokeWidth: 1.5,
|
|
65
|
+
strokeLinecap: "round",
|
|
66
|
+
strokeLinejoin: "round",
|
|
67
|
+
className: props.className
|
|
68
|
+
}, react.default.createElement("path", { d: pathData }));
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const FALLBACK_CHECK = createFallbackIcon("M3 8.5l3.5 3.5 6.5-7");
|
|
72
|
+
const FALLBACK_DOWNLOAD = createFallbackIcon("M8 2v9m0 0l-3-3m3 3l3-3M3 13h10");
|
|
73
|
+
const FALLBACK_LIST_PEN = createFallbackIcon("M3 4h10M3 8h6M3 12h4m6-3l2 2-5 5H9v-2l5-5z");
|
|
74
|
+
const FALLBACK_LOADING = createFallbackIcon("M8 2a6 6 0 1 0 6 6");
|
|
75
|
+
const FALLBACK_REFRESH = createFallbackIcon("M2.5 8a5.5 5.5 0 1 0 1.2-3.4M2.5 3v3h3");
|
|
76
|
+
/**
|
|
77
|
+
* 跨宿主版本图标安全解析器:按候选名依次匹配(新版 → 老版 → Medium/Regular 变体),
|
|
78
|
+
* 全部缺失时才回退到给到的 fallback;没有 fallback 就抛错(由单测保护)。
|
|
79
|
+
* 生产路径的 `hostIcon` 也走这里 —— 只有一套候选顺序,避免「测试改的是导出函数、线上走的是另一套」。
|
|
80
|
+
*/
|
|
81
|
+
function resolveHostIcon(icons, candidates, fallback) {
|
|
82
|
+
for (const name of candidates) {
|
|
83
|
+
const icon = icons[name];
|
|
84
|
+
if (icon !== void 0) return icon;
|
|
85
|
+
}
|
|
86
|
+
if (fallback !== void 0) return fallback;
|
|
87
|
+
throw new Error(`宿主缺少图标 ${candidates[0] ?? "(空候选)"}`);
|
|
88
|
+
}
|
|
89
|
+
function hostIcon(modern, legacy, fallback) {
|
|
90
|
+
return resolveHostIcon(_deepseek_ai_dsh_client_ui_primitives, [
|
|
91
|
+
modern,
|
|
92
|
+
legacy,
|
|
93
|
+
modern.replace("Medium", "Regular"),
|
|
94
|
+
modern.replace("OutlineMedium", "OutlineRegular")
|
|
95
|
+
], fallback);
|
|
96
|
+
}
|
|
97
|
+
const IconCheckOutlineMedium = hostIcon("IconCheckOutlineMedium", "IconCheckOutline16", FALLBACK_CHECK);
|
|
98
|
+
const IconDownloadOutlineMedium = hostIcon("IconDownloadOutlineMedium", "IconDownloadOutline16", FALLBACK_DOWNLOAD);
|
|
99
|
+
const IconListPenOutlineMedium = hostIcon("IconListPenOutlineMedium", "IconListPenOutline16", FALLBACK_LIST_PEN);
|
|
100
|
+
const IconLoadingOutlineMedium = hostIcon("IconLoadingOutlineMedium", "IconLoadingOutline16", FALLBACK_LOADING);
|
|
101
|
+
const IconRefreshOutlineMedium = hostIcon("IconRefreshOutlineMedium", "IconRefreshOutline16", FALLBACK_REFRESH);
|
|
69
102
|
//#endregion
|
|
70
103
|
//#region src/business-api.ts
|
|
71
104
|
const CODEX_UI_API_BASE = "/api/michengai/dsh-codex-ui";
|
|
@@ -75,6 +108,8 @@ window.__ModuleLoader__.load({
|
|
|
75
108
|
dependencies: `${CODEX_UI_API_BASE}/dependencies`,
|
|
76
109
|
settingsSkin: `${CODEX_UI_API_BASE}/settings-skin`,
|
|
77
110
|
composer: `${CODEX_UI_API_BASE}/composer`,
|
|
111
|
+
composerPrediction: `${CODEX_UI_API_BASE}/composer/prediction`,
|
|
112
|
+
composerPredictionStream: `${CODEX_UI_API_BASE}/composer/prediction/stream`,
|
|
78
113
|
sidebar: `${CODEX_UI_API_BASE}/sidebar`,
|
|
79
114
|
sections: `${CODEX_UI_API_BASE}/sections`,
|
|
80
115
|
theme: `${CODEX_UI_API_BASE}/theme`,
|
|
@@ -163,7 +198,7 @@ window.__ModuleLoader__.load({
|
|
|
163
198
|
* (item II — lazy CSS), so editing the stylesheet means editing
|
|
164
199
|
* glass.module.css and rebuilding.
|
|
165
200
|
*/
|
|
166
|
-
const GLASS_CSS_TEXT = "[data-dsh-glass] body{--dsh-glass-card:color-mix(in srgb, var(--dsw-alias-bg-layer-1) calc(52% * var(--dsh-glass-frost,1)), transparent);--dsh-glass-card-raised:color-mix(in srgb, var(--dsw-alias-bg-layer-1) calc(64% * var(--dsh-glass-frost,1)), transparent);--dsh-glass-card-hover:color-mix(in srgb, var(--dsw-alias-bg-layer-1) calc(76% * var(--dsh-glass-frost,1)), transparent);--dsh-glass-rim:color-mix(in srgb, var(--dsw-alias-label-primary) 18%, transparent);--dsh-glass-rim-soft:color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent);--dsh-glass-rim-strong:color-mix(in srgb, var(--dsw-alias-label-primary) 30%, transparent);--dsh-glass-edge:inset 0 1px 0 #ffffff6b;--dsh-glass-drop:0 10px 32px color-mix(in srgb, var(--dsw-alias-bg-mask-2) 38%, transparent);--dsh-glass-input-shadow:0 1px 2px color-mix(in srgb, var(--dsw-alias-bg-mask-2) 65%, transparent), 0 8px 24px color-mix(in srgb, var(--dsw-alias-bg-mask-2) 80%, transparent);--dsh-glass-ground:color-mix(in srgb, color-mix(in srgb, var(--dsw-alias-bg-base), #fff calc(var(--dsh-glass-brightness-white,0) * 100%)), #000 calc(var(--dsh-glass-brightness-black,0) * 100%));--dsh-glass-ambience:calc(1 - var(--dsh-glass-brightness-white,0) - var(--dsh-glass-brightness-black,0));--dsh-glass-wash-tint:#fff;--dsh-glass-wash-mix:22%}[data-dsh-glass] body[data-ds-dark-theme]{--dsh-glass-rim:color-mix(in srgb, var(--dsw-alias-label-primary) 24%, transparent);--dsh-glass-rim-soft:color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);--dsh-glass-rim-strong:color-mix(in srgb, var(--dsw-alias-label-primary) 30%, transparent);--dsh-glass-edge:inset 0 1px 0 #ffffff14;--dsh-glass-drop:0 10px 32px #02060e73;--dsh-glass-input-shadow:0 1px 2px color-mix(in srgb, var(--dsw-alias-bg-mask-2) 65%, transparent), 0 8px 24px color-mix(in srgb, var(--dsw-alias-bg-mask-2) 80%, transparent);--dsh-glass-wash-tint:var(--dsw-alias-bg-layer-1);--dsh-glass-wash-mix:68%}[data-dsh-glass] body,[data-dsh-glass] [data-dsh-glass-ground-sample]{background: radial-gradient(58% 46% at 18% 6%, color-mix(in srgb, var(--dsw-alias-brand-primary-new-colorprimary-new-color) calc(12% * var(--dsh-glass-ambience) * var(--dsh-glass-glow,0)), transparent), transparent 68%), radial-gradient(48% 42% at 86% 14%, color-mix(in srgb, var(--dsw-alias-state-success-tertiary) calc(10% * var(--dsh-glass-ambience) * var(--dsh-glass-glow,0)), transparent), transparent 62%), linear-gradient(165deg, color-mix(in srgb, var(--dsh-glass-ground), var(--dsh-glass-wash-tint) calc(var(--dsh-glass-wash-mix) * var(--dsh-glass-ambience))) 0%, var(--dsh-glass-ground) 55%, color-mix(in srgb, var(--dsh-glass-ground), #000 calc(5% * var(--dsh-glass-ambience))) 100%)}[data-dsh-glass] [data-dsh-glass-frame],[data-dsh-glass] [data-phase],[data-dsh-glass] [data-dsh-glass-details],[data-dsh-glass-float] [data-dsh-glass-frame]>[class*=centerCol]{background:0 0}[data-dsh-glass-float] [data-phase=active] header{z-index:8;position:relative}[data-dsh-glass-float] [class*=banner]{position:static}[data-dsh-glass-float] [data-phase=active] [data-conversation-scroll]{margin-top:-95px;padding-top:107px}[data-dsh-glass] [data-phase] [class*=composerSeat][class*=composerSeat]{background:0 0}[data-dsh-glass] [data-phase] [data-dsh-glass-inputbar]>[class*=dock],[data-dsh-glass] [data-phase] [data-dsh-glass-inputbar]>[data-composer-dock]{position:relative}[data-dsh-glass] [data-phase] [data-dsh-glass-inputbar]>[class*=dock]:before,[data-dsh-glass] [data-phase] [data-dsh-glass-inputbar]>[data-composer-dock]:before{display:none!important;content:none!important}[data-dsh-glass] [data-dsh-glass-fade]{z-index:7;pointer-events:none;backdrop-filter:blur(5px);background:#ffffff2e;height:13px;position:fixed;left:0;right:0}[data-dsh-glass] body[data-ds-dark-theme] [data-dsh-glass-fade]{background:#00000024}[data-dsh-glass] [data-dsh-glass-fade=top]{top:0;-webkit-mask-image:linear-gradient(#000 0%,#0000 100%);mask-image:linear-gradient(#000 0%,#0000 100%)}[data-dsh-glass][data-windows-titlebar] [data-dsh-glass-fade=top]{display:none}[data-dsh-glass] [data-dsh-glass-fade=bottom]{bottom:0;-webkit-mask-image:linear-gradient(#0000 0%,#000 100%);mask-image:linear-gradient(#0000 0%,#000 100%)}[data-dsh-glass-float] [data-menu-material=translucent],[data-dsh-glass-float] [role=menu]:not([data-menu-material]):not([data-menu-material] *),[data-dsh-glass-float] [role=dialog],[data-dsh-glass-float] [role=alert],[data-dsh-glass-float] [data-trigger-menu],[data-dsh-glass-float] [data-dsh-glass-surface]{border-radius:14px}[data-dsh-glass-float] [role=menuitem],[data-dsh-glass-float] [role=tooltip],[data-dsh-glass-float] [class*=pill]{border-radius:8px}[data-dsh-glass-float] button[class*=button]{border-radius:10px}[data-dsh-glass-float] [class*=iconButton],[data-dsh-glass-float] [class*=searchButton]{border-radius:8px}[data-dsh-glass-float] [class*=block]{--dsl-code-block-border-radius:14px;--dsl-diff-radius:14px;--dsl-read-radius:14px;--dsl-terminal-radius:14px;--dsl-web-radius:14px;--dsl-search-radius:14px;border-radius:14px}[data-dsh-glass-float] [data-dsh-glass-add]{background:var(--dsh-glass-card-raised);border:1px solid var(--dsh-glass-rim);box-shadow:var(--dsh-glass-edge);backdrop-filter:blur(var(--dsh-glass-blur,14px))}[data-dsh-glass-float] [data-dsh-glass-add]:hover:not(:disabled){background:var(--dsh-glass-card-hover)}[data-dsh-glass-float] [data-dsh-glass-surface]{background:var(--dsh-glass-card-raised);border:1px solid var(--dsh-glass-rim-soft);box-shadow:var(--dsh-glass-edge);backdrop-filter:blur(var(--dsh-glass-blur,14px))}[data-dsh-glass-float] [data-dsh-glass-surface]:hover:not(:disabled){background:var(--dsh-glass-card-hover)}[data-dsh-glass-float] [data-conversation-scroll] [class*=bubble]{border:1px solid var(--dsh-glass-rim-soft);background:color-mix(in srgb, var(--dsw-alias-bg-layer-1) calc(46% * var(--dsh-glass-frost,1)), transparent);border-radius:14px}[data-dsh-glass-float] [class*=card]{border-radius:14px}[data-dsh-glass-float] [data-reader-reasoning-card]:not([data-overflow=false][data-expanded=false]),[data-dsh-glass-compat] [data-reader-reasoning-card]:not([data-overflow=false][data-expanded=false]){background:color-mix(in srgb, var(--dsw-alias-bg-module-platform) calc(52% * var(--dsh-glass-frost,1)), transparent);border-color:var(--dsh-glass-rim-soft);border-radius:14px}html[data-dsh-glass-float] [data-changed-files],html[data-dsh-glass-float] [data-presented-file]{--changes-fill:var(--dsh-glass-card);--deliverable-fill:var(--dsh-glass-card);border-color:var(--dsh-glass-rim-soft);border-radius:14px}html[data-dsh-glass-float] [data-presented-file],html[data-dsh-glass-float] [data-changed-files]{background:var(--dsh-glass-card)}html[data-dsh-glass-float] [data-changed-files]>:first-child,html[data-dsh-glass-float] [data-changed-files] ul>li>:first-child,html[data-dsh-glass-float] [data-changed-files] ul{background:0 0}html[data-dsh-glass-float] [data-changed-files] ul{border-top:.5px solid var(--dsh-glass-rim-soft)}html[data-dsh-glass-float] [data-changed-files]>:first-child>:first-child,html[data-dsh-glass-float] [data-presented-file]>:first-child{background:var(--dsh-glass-card-raised)}html[data-dsh-glass-float] [data-turn-trigger]{background:var(--dsh-glass-card);border-color:var(--dsh-glass-rim-soft);border-radius:14px}html[data-dsh-glass-float] [data-turn-trigger]:hover{background:var(--dsh-glass-card-hover)}[data-dsh-glass] [data-dsh-glass-settings]{--dsh-glass-settings-raised:calc(38% + 38% * var(--dsh-glass-frost,1));--dsh-glass-settings-soft:calc(30% + 30% * var(--dsh-glass-frost,1));--dsw-alias-bg-module-platform:color-mix(in srgb, var(--dsw-static-neutral-bluish-800) var(--dsh-glass-settings-raised), transparent);--dsw-alias-bg-layer-3:color-mix(in srgb, var(--dsw-static-neutral-bluish-800) var(--dsh-glass-settings-soft), transparent);--dsw-alias-bg-layer-2:color-mix(in srgb, var(--dsw-static-neutral-bluish-850) var(--dsh-glass-settings-raised), transparent);--dsw-alias-bg-layer-1:color-mix(in srgb, var(--dsw-static-neutral-bluish-850) var(--dsh-glass-settings-soft), transparent);--dsw-specific-sidebar-nav-item-active:color-mix(in srgb, var(--dsw-static-neutral-bluish-750) var(--dsh-glass-settings-raised), transparent);--dsw-specific-sidebar-nav-item-hover:color-mix(in srgb, var(--dsw-static-neutral-bluish-850) var(--dsh-glass-settings-soft), transparent)}[data-dsh-glass] body:not([data-ds-dark-theme]) [data-dsh-glass-settings]{--dsw-alias-bg-module-platform:color-mix(in srgb, var(--dsw-static-neutral-bluish-60) var(--dsh-glass-settings-raised), transparent);--dsw-alias-bg-layer-3:color-mix(in srgb, var(--dsw-static-neutral-bluish-00) var(--dsh-glass-settings-soft), transparent);--dsw-alias-bg-layer-2:color-mix(in srgb, var(--dsw-static-neutral-bluish-00) var(--dsh-glass-settings-raised), transparent);--dsw-alias-bg-layer-1:color-mix(in srgb, var(--dsw-static-neutral-bluish-00) var(--dsh-glass-settings-soft), transparent);--dsw-specific-sidebar-nav-item-active:color-mix(in srgb, var(--dsw-static-neutral-bluish-100) var(--dsh-glass-settings-raised), transparent);--dsw-specific-sidebar-nav-item-hover:color-mix(in srgb, var(--dsw-static-neutral-bluish-75) var(--dsh-glass-settings-soft), transparent)}[data-dsh-glass-float] [data-phase] header:not([class*=headerBlank]){width:100%;max-width:min(calc(var(--dsh-chat-user-width,clamp(680px, calc(var(--dsh-conversation-column-width,1500px) * .64), 920px)) + 32px), calc(100% - 32px));border:1px solid var(--dsh-glass-rim);background:var(--dsh-glass-card);box-shadow:var(--dsh-glass-edge), var(--dsh-glass-drop);backdrop-filter:blur(var(--dsh-glass-blur,14px));border-radius:20px;margin:12px auto 0;padding:10px 16px 8px}[data-dsh-glass-float] [data-phase] header:not([class*=headerBlank]):after{display:none}[data-dsh-glass-float] [data-dsh-glass-frame][data-sidebar-collapsed] [data-phase] header:not([class*=headerBlank]){width:auto;max-width:none;margin-left:28px;margin-right:16px}[data-dsh-glass-float] [class*=sidebarCol]{--dsw-specific-sidebar-fill:transparent;z-index:9;border:1px solid var(--dsh-glass-rim-soft);box-shadow:var(--dsh-glass-drop);border-radius:20px;margin:12px;padding:10px 12px 14px;position:relative;overflow:hidden}[data-dsh-glass-float] [class*=sidebarCol]:before{content:\"\";border-radius:inherit;background:var(--dsh-glass-card);box-shadow:var(--dsh-glass-edge);z-index:-1;pointer-events:none;transition:border-radius .15s var(--ds-ease-in-out);position:absolute;inset:0}[data-dsh-glass-float] body{--dsw-specific-sidebar-fill:color-mix(in srgb, var(--dsw-alias-bg-layer-1) calc(52% * var(--dsh-glass-frost,1)), color-mix(in srgb, var(--dsh-glass-ground), var(--dsh-glass-wash-tint) calc(var(--dsh-glass-wash-mix) * var(--dsh-glass-ambience))))!important}[data-dsh-glass-float] [data-dsh-glass-frame][data-sidebar-collapsed] [class*=sidebarCol]{transition:margin .15s var(--ds-ease-in-out), border-radius .15s var(--ds-ease-in-out);border-radius:16px;margin:12px -12px 12px 12px;padding:0}[data-dsh-glass-float] [data-dsh-glass-frame]:not([data-sidebar-collapsed]) [data-dsh-glass-sidebar-root]{width:100%!important}[data-dsh-glass-float] [data-dsh-glass-trajectory]{width:100%!important;max-width:none!important;height:100%!important;margin:0!important;border:none!important;box-shadow:none!important;border-radius:0!important;overflow:hidden}[data-dsh-glass-float] [data-dsh-glass-trajectory] [role=toolbar],[data-dsh-glass-float] [data-dsh-glass-trajectory] section[aria-label=Trajectory\\ timeline]{background:0 0}[data-dsh-glass-float] [data-composer-card],[data-dsh-glass-float] [data-composer-card]:after{border-radius:24px}[data-dsh-glass-float] [data-composer-card]{z-index:8;isolation:isolate;border:1px solid var(--dsh-glass-rim-strong);box-shadow:var(--dsh-glass-input-shadow);background:0 0;position:relative}[data-dsh-glass-float] [data-composer-card]:before{content:\"\";z-index:-1;border-radius:inherit;background:var(--dsh-glass-card);box-shadow:var(--dsh-glass-edge);backdrop-filter:blur(var(--dsh-glass-blur,14px));pointer-events:none;position:absolute;inset:0}[data-dsh-glass-float] [data-dsh-glass-inputbar]:not([class*=hero]):not(:has([data-dsh-glass-stats])){padding-bottom:12px}[data-dsh-glass-float] [role=treeitem][aria-selected=true]{background:var(--dsw-alias-interactive-bg-hover)}[data-dsh-glass-float] button[class*=button]:hover:not(:disabled),[data-dsh-glass-float] [role=menuitem]:hover:not(:disabled){box-shadow:0 0 12px color-mix(in srgb, var(--dsw-alias-brand-primary-new-colorprimary-new-color) 20%, transparent)}[data-dsh-glass-float] [data-menu-material=translucent]:not(:focus-visible){--dsw-menu-surface-fill:var(--dsh-glass-card-raised);--dsw-menu-backdrop-filter:blur(var(--dsh-glass-blur,14px))}[data-dsh-glass-float] body[data-ds-dark-theme] [data-menu-material=translucent]:not(:focus-visible){outline:1px solid var(--dsh-glass-rim-soft);outline-offset:-1px}[data-dsh-glass-float] [role=menu]:not([data-menu-material]):not([data-menu-material] *){background:var(--dsh-glass-card-raised);border:1px solid var(--dsh-glass-rim-soft);backdrop-filter:blur(var(--dsh-glass-blur,14px))}[data-dsh-glass-float] [data-menu-material=translucent]:has([role=group]>[role=menuitemradio]){--dsw-menu-surface-fill:color-mix(in srgb, var(--dsw-alias-bg-layer-2) 70%, transparent)}[data-dsh-glass-float] [data-menu-group]:has(>[role=menuitemradio])>[data-menu-group-heading]{background:var(--dsh-glass-card-raised);backdrop-filter:blur(var(--dsh-glass-blur,14px));border-radius:999px;align-items:center;width:fit-content;margin:3px 0 5px 6px;padding:3px 10px;display:inline-flex}[data-dsh-glass-float] [role=dialog][aria-modal=true]{background:var(--dsh-glass-card-raised);border:1px solid var(--dsh-glass-rim);box-shadow:var(--dsh-glass-edge), var(--dsh-glass-drop);backdrop-filter:blur(var(--dsh-glass-blur,14px));border-radius:20px}[data-dsh-glass] [data-conversation-scroll]{text-shadow:0 0 1px #ffffff80}[data-dsh-glass] body[data-ds-dark-theme] [data-conversation-scroll]{text-shadow:0 0 1px #0006}[data-dsh-glass-float] [data-dsh-glass-inputbar] [data-slot]{color:var(--dsw-alias-label-secondary)}[data-dsh-glass]{--dsh-glass-entry-scale:1}[data-dsh-glass-compat]{--dsh-glass-entry-scale:0}[data-dsh-glass] [data-testid^=view-]{animation:dsh-glass-in calc(.26s * var(--dsh-glass-entry-scale,1)) var(--ds-ease-in-out)}[data-dsh-glass] [data-tool]{animation:dsh-glass-rise calc(.3s * var(--dsh-glass-entry-scale,1)) var(--ds-ease-in-out) both}[data-dsh-glass] [role=dialog]{animation:dsh-glass-dialog-in calc(.24s * var(--dsh-glass-entry-scale,1)) var(--ds-ease-in-out)}@keyframes dsh-glass-in{0%{opacity:0}}@keyframes dsh-glass-rise{0%{opacity:0;transform:translateY(6px)}}@keyframes dsh-glass-dialog-in{0%{opacity:0;transform:translateY(8px)scale(.985)}}[data-dsh-glass] :focus-visible{outline:2px solid color-mix(in srgb, var(--dsw-alias-brand-primary-new-colorprimary-new-color) 85%, transparent);outline-offset:1px}[data-dsh-glass] ::selection{background:color-mix(in srgb, var(--dsw-alias-brand-primary-new-colorprimary-new-color) 35%, transparent)}[data-dsh-glass-compat] [role=menu]:not([data-menu-material]):not([data-menu-material] *),[data-dsh-glass-compat] [class*=popover],[data-dsh-glass-compat] [class*=dropdown]{backdrop-filter:blur(12px)}[data-dsh-glass-compat] [data-menu-material=translucent]:not(:focus-visible){--dsw-menu-surface-fill:var(--dsh-glass-card-raised);--dsw-menu-backdrop-filter:blur(12px)}[data-dsh-glass-compat] [role=menu]:not([data-menu-material]):not([data-menu-material] *),[data-dsh-glass-compat] [class*=popover],[data-dsh-glass-compat] [class*=dropdown]{background:var(--dsh-glass-card-raised)}[data-dsh-glass-compat] [data-composer-card]{isolation:isolate;backdrop-filter:none;background:0 0;position:relative}[data-dsh-glass-compat] [data-composer-card]:before{content:\"\";z-index:-1;border-radius:inherit;background:var(--dsh-glass-card-raised);backdrop-filter:blur(12px);pointer-events:none;position:absolute;inset:0}[data-dsh-glass-compat] [role=menu]:not([data-menu-material]):not([data-menu-material] *):not(:focus-visible),[data-dsh-glass-compat] [data-composer-card]:not(:focus-visible),[data-dsh-glass-compat] [class*=popover]:not(:focus-visible),[data-dsh-glass-compat] [class*=dropdown]:not(:focus-visible){outline:1px solid var(--dsh-glass-rim);outline-offset:-1px}[data-dsh-glass-compat] [role=dialog][aria-modal=true]{background:var(--dsh-glass-card-raised);border:1px solid var(--dsh-glass-rim);box-shadow:var(--dsh-glass-edge), var(--dsh-glass-drop);backdrop-filter:blur(var(--dsh-glass-blur,12px))}@media (prefers-reduced-motion:reduce){[data-dsh-glass] [data-testid^=view-],[data-dsh-glass] [data-tool],[data-dsh-glass] [role=dialog]{animation:none}}";
|
|
201
|
+
const GLASS_CSS_TEXT = "[data-dsh-glass] body{--dsh-glass-card:color-mix(in srgb, var(--dsw-alias-bg-layer-1) calc(52% * var(--dsh-glass-frost,1)), transparent);--dsh-glass-card-raised:color-mix(in srgb, var(--dsw-alias-bg-layer-1) calc(64% * var(--dsh-glass-frost,1)), transparent);--dsh-glass-card-hover:color-mix(in srgb, var(--dsw-alias-bg-layer-1) calc(76% * var(--dsh-glass-frost,1)), transparent);--dsh-glass-rim:color-mix(in srgb, var(--dsw-alias-label-primary) 18%, transparent);--dsh-glass-rim-soft:color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent);--dsh-glass-rim-strong:color-mix(in srgb, var(--dsw-alias-label-primary) 30%, transparent);--dsh-glass-edge:inset 0 1px 0 #ffffff6b;--dsh-glass-drop:0 10px 32px color-mix(in srgb, var(--dsw-alias-bg-mask-2) 38%, transparent);--dsh-glass-input-shadow:0 1px 2px color-mix(in srgb, var(--dsw-alias-bg-mask-2) 65%, transparent), 0 8px 24px color-mix(in srgb, var(--dsw-alias-bg-mask-2) 80%, transparent);--dsh-glass-ground:color-mix(in srgb, color-mix(in srgb, var(--dsw-alias-bg-base), #fff calc(var(--dsh-glass-brightness-white,0) * 100%)), #000 calc(var(--dsh-glass-brightness-black,0) * 100%));--dsh-glass-ambience:calc(1 - var(--dsh-glass-brightness-white,0) - var(--dsh-glass-brightness-black,0));--dsh-glass-wash-tint:#fff;--dsh-glass-wash-mix:22%}[data-dsh-glass] body[data-ds-dark-theme]{--dsh-glass-rim:color-mix(in srgb, var(--dsw-alias-label-primary) 24%, transparent);--dsh-glass-rim-soft:color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);--dsh-glass-rim-strong:color-mix(in srgb, var(--dsw-alias-label-primary) 30%, transparent);--dsh-glass-edge:inset 0 1px 0 #ffffff14;--dsh-glass-drop:0 10px 32px #02060e73;--dsh-glass-input-shadow:0 1px 2px color-mix(in srgb, var(--dsw-alias-bg-mask-2) 65%, transparent), 0 8px 24px color-mix(in srgb, var(--dsw-alias-bg-mask-2) 80%, transparent);--dsh-glass-wash-tint:var(--dsw-alias-bg-layer-1);--dsh-glass-wash-mix:68%}[data-dsh-glass] body,[data-dsh-glass] [data-dsh-glass-ground-sample]{background: radial-gradient(calc(58% * var(--dsh-glass-glow-size,1)) calc(46% * var(--dsh-glass-glow-size,1)) at 18% 6%, color-mix(in srgb, var(--dsw-alias-brand-primary-new-colorprimary-new-color) calc(12% * var(--dsh-glass-ambience) * var(--dsh-glass-glow,0) * var(--dsh-glass-glow-strength,1)), transparent), transparent 68%), radial-gradient(calc(48% * var(--dsh-glass-glow-size,1)) calc(42% * var(--dsh-glass-glow-size,1)) at 86% 14%, color-mix(in srgb, var(--dsw-alias-state-success-tertiary) calc(10% * var(--dsh-glass-ambience) * var(--dsh-glass-glow,0) * var(--dsh-glass-glow-strength,1)), transparent), transparent 62%), linear-gradient(165deg, color-mix(in srgb, var(--dsh-glass-ground), var(--dsh-glass-wash-tint) calc(var(--dsh-glass-wash-mix) * var(--dsh-glass-ambience))) 0%, var(--dsh-glass-ground) 55%, color-mix(in srgb, var(--dsh-glass-ground), #000 calc(5% * var(--dsh-glass-ambience))) 100%)}[data-dsh-glass] [data-dsh-glass-frame],[data-dsh-glass] [data-phase],[data-dsh-glass] [data-dsh-glass-details],[data-dsh-glass-float] [data-dsh-glass-frame]>[class*=centerCol]{background:0 0}[data-dsh-glass-float] [data-phase=active] header{z-index:8;position:relative}[data-dsh-glass-float] [class*=banner]{position:static}[data-dsh-glass-float] [data-phase=active] [data-conversation-scroll]{margin-top:-95px;padding-top:107px}[data-dsh-glass] [data-phase] [class*=composerSeat][class*=composerSeat]{background:0 0}[data-dsh-glass] [data-phase] [data-dsh-glass-inputbar]>[class*=dock],[data-dsh-glass] [data-phase] [data-dsh-glass-inputbar]>[data-composer-dock]{position:relative}[data-dsh-glass] [data-phase] [data-dsh-glass-inputbar]>[class*=dock]:before,[data-dsh-glass] [data-phase] [data-dsh-glass-inputbar]>[data-composer-dock]:before{content:\"\";left:calc(-1 * var(--dsh-composer-side-clearance,16px));right:calc(-1 * var(--dsh-composer-side-clearance,16px));z-index:-1;pointer-events:none;background:color-mix(in srgb, color-mix(in srgb, var(--dsh-glass-ground), #000 calc(5% * var(--dsh-glass-ambience))) calc(70% + 10% * var(--dsh-glass-frost,1)), transparent);height:calc(100% + 12px);backdrop-filter:blur(var(--dsh-glass-blur,14px));position:absolute;bottom:-4px;-webkit-mask-image:linear-gradient(#0000 0,#000 18px);mask-image:linear-gradient(#0000 0,#000 18px)}[data-dsh-glass] [data-dsh-glass-fade]{z-index:7;pointer-events:none;backdrop-filter:blur(5px);background:#ffffff2e;height:13px;position:fixed;left:0;right:0}[data-dsh-glass] body[data-ds-dark-theme] [data-dsh-glass-fade]{background:#00000024}[data-dsh-glass] [data-dsh-glass-fade=top]{top:0;-webkit-mask-image:linear-gradient(#000 0%,#0000 100%);mask-image:linear-gradient(#000 0%,#0000 100%)}[data-dsh-glass][data-windows-titlebar] [data-dsh-glass-fade=top]{display:none}[data-dsh-glass] [data-dsh-glass-fade=bottom]{bottom:0;-webkit-mask-image:linear-gradient(#0000 0%,#000 100%);mask-image:linear-gradient(#0000 0%,#000 100%)}[data-dsh-glass-float] [data-menu-material=translucent],[data-dsh-glass-float] [role=menu]:not([data-menu-material]):not([data-menu-material] *),[data-dsh-glass-float] [role=dialog],[data-dsh-glass-float] [role=alert],[data-dsh-glass-float] [data-trigger-menu],[data-dsh-glass-float] [data-dsh-glass-surface]{border-radius:14px}[data-dsh-glass-float] [role=menuitem],[data-dsh-glass-float] [role=tooltip],[data-dsh-glass-float] [class*=pill]{border-radius:8px}[data-dsh-glass-float] button[class*=button]{border-radius:10px}[data-dsh-glass-float] [class*=iconButton],[data-dsh-glass-float] [class*=searchButton]{border-radius:8px}[data-dsh-glass-float] [class*=block]{--dsl-code-block-border-radius:14px;--dsl-diff-radius:14px;--dsl-read-radius:14px;--dsl-terminal-radius:14px;--dsl-web-radius:14px;--dsl-search-radius:14px;border-radius:14px}[data-dsh-glass-float] [data-dsh-glass-add]{background:var(--dsh-glass-card-raised);border:1px solid var(--dsh-glass-rim);box-shadow:var(--dsh-glass-edge);backdrop-filter:blur(var(--dsh-glass-blur,14px))}[data-dsh-glass-float] [data-dsh-glass-add]:hover:not(:disabled){background:var(--dsh-glass-card-hover)}[data-dsh-glass-float] [data-dsh-glass-surface]{background:var(--dsh-glass-card-raised);border:1px solid var(--dsh-glass-rim-soft);box-shadow:var(--dsh-glass-edge);backdrop-filter:blur(var(--dsh-glass-blur,14px))}[data-dsh-glass-float] [data-dsh-glass-surface]:hover:not(:disabled){background:var(--dsh-glass-card-hover)}[data-dsh-glass-float] [data-conversation-scroll] [class*=bubble]{border:1px solid var(--dsh-glass-rim-soft);background:color-mix(in srgb, var(--dsw-alias-bg-layer-1) calc(46% * var(--dsh-glass-frost,1)), transparent);border-radius:14px}[data-dsh-glass-float] [class*=card]{border-radius:14px}[data-dsh-glass-float] [data-reader-reasoning-card]:not([data-overflow=false][data-expanded=false]),[data-dsh-glass-compat] [data-reader-reasoning-card]:not([data-overflow=false][data-expanded=false]){background:color-mix(in srgb, var(--dsw-alias-bg-module-platform) calc(52% * var(--dsh-glass-frost,1)), transparent);border-color:var(--dsh-glass-rim-soft);border-radius:14px}html[data-dsh-glass-float] [data-changed-files],html[data-dsh-glass-float] [data-presented-file]{--changes-fill:var(--dsh-glass-card);--deliverable-fill:var(--dsh-glass-card);border-color:var(--dsh-glass-rim-soft);border-radius:14px}html[data-dsh-glass-float] [data-presented-file],html[data-dsh-glass-float] [data-changed-files]{background:var(--dsh-glass-card)}html[data-dsh-glass-float] [data-changed-files]>:first-child,html[data-dsh-glass-float] [data-changed-files] ul>li>:first-child,html[data-dsh-glass-float] [data-changed-files] ul{background:0 0}html[data-dsh-glass-float] [data-changed-files] ul{border-top:.5px solid var(--dsh-glass-rim-soft)}html[data-dsh-glass-float] [data-changed-files]>:first-child>:first-child,html[data-dsh-glass-float] [data-presented-file]>:first-child{background:var(--dsh-glass-card-raised)}html[data-dsh-glass-float] [data-turn-trigger]{background:var(--dsh-glass-card);border-color:var(--dsh-glass-rim-soft);border-radius:14px}html[data-dsh-glass-float] [data-turn-trigger]:hover{background:var(--dsh-glass-card-hover)}[data-dsh-glass] [data-dsh-glass-settings]{--dsh-glass-settings-raised:calc(38% + 38% * var(--dsh-glass-frost,1));--dsh-glass-settings-soft:calc(30% + 30% * var(--dsh-glass-frost,1));--dsw-alias-bg-module-platform:color-mix(in srgb, var(--dsw-static-neutral-bluish-800) var(--dsh-glass-settings-raised), transparent);--dsw-alias-bg-layer-3:color-mix(in srgb, var(--dsw-static-neutral-bluish-800) var(--dsh-glass-settings-soft), transparent);--dsw-alias-bg-layer-2:color-mix(in srgb, var(--dsw-static-neutral-bluish-850) var(--dsh-glass-settings-raised), transparent);--dsw-alias-bg-layer-1:color-mix(in srgb, var(--dsw-static-neutral-bluish-850) var(--dsh-glass-settings-soft), transparent);--dsw-specific-sidebar-nav-item-active:color-mix(in srgb, var(--dsw-static-neutral-bluish-750) var(--dsh-glass-settings-raised), transparent);--dsw-specific-sidebar-nav-item-hover:color-mix(in srgb, var(--dsw-static-neutral-bluish-850) var(--dsh-glass-settings-soft), transparent)}[data-dsh-glass] body:not([data-ds-dark-theme]) [data-dsh-glass-settings]{--dsw-alias-bg-module-platform:color-mix(in srgb, var(--dsw-static-neutral-bluish-60) var(--dsh-glass-settings-raised), transparent);--dsw-alias-bg-layer-3:color-mix(in srgb, var(--dsw-static-neutral-bluish-00) var(--dsh-glass-settings-soft), transparent);--dsw-alias-bg-layer-2:color-mix(in srgb, var(--dsw-static-neutral-bluish-00) var(--dsh-glass-settings-raised), transparent);--dsw-alias-bg-layer-1:color-mix(in srgb, var(--dsw-static-neutral-bluish-00) var(--dsh-glass-settings-soft), transparent);--dsw-specific-sidebar-nav-item-active:color-mix(in srgb, var(--dsw-static-neutral-bluish-100) var(--dsh-glass-settings-raised), transparent);--dsw-specific-sidebar-nav-item-hover:color-mix(in srgb, var(--dsw-static-neutral-bluish-75) var(--dsh-glass-settings-soft), transparent)}[data-dsh-glass-float] [data-phase] header:not([class*=headerBlank]){width:100%;margin:var(--dsh-glass-gap,12px) auto 0;max-width:min(calc(var(--dsh-chat-user-width,clamp(680px, calc(var(--dsh-conversation-column-width,1500px) * .64), 920px)) + 32px), calc(100% - 32px));border:1px solid var(--dsh-glass-rim);background:var(--dsh-glass-card);box-shadow:var(--dsh-glass-edge), var(--dsh-glass-drop);backdrop-filter:blur(var(--dsh-glass-blur,14px));border-radius:20px;padding:10px 16px 8px}[data-dsh-glass-float] [data-phase] header:not([class*=headerBlank]):after{display:none}[data-dsh-glass-float] [data-dsh-glass-frame][data-sidebar-collapsed] [data-phase] header:not([class*=headerBlank]){width:auto;margin-left:calc(var(--dsh-glass-gap,12px) + 16px);max-width:none;margin-right:16px}[data-dsh-glass-float] [class*=sidebarCol]{--dsw-specific-sidebar-fill:transparent;z-index:9;margin:var(--dsh-glass-gap,12px);border:1px solid var(--dsh-glass-rim-soft);box-shadow:var(--dsh-glass-drop);border-radius:20px;padding:10px 12px 14px;position:relative;overflow:hidden}[data-dsh-glass-float] [class*=sidebarCol]:before{content:\"\";border-radius:inherit;background:var(--dsh-glass-card);box-shadow:var(--dsh-glass-edge);z-index:-1;pointer-events:none;transition:border-radius .15s var(--ds-ease-in-out);position:absolute;inset:0}[data-dsh-glass-float] body{--dsw-specific-sidebar-fill:color-mix(in srgb, var(--dsw-alias-bg-layer-1) calc(52% * var(--dsh-glass-frost,1)), color-mix(in srgb, var(--dsh-glass-ground), var(--dsh-glass-wash-tint) calc(var(--dsh-glass-wash-mix) * var(--dsh-glass-ambience))))!important}[data-dsh-glass-float] [data-dsh-glass-frame][data-sidebar-collapsed] [class*=sidebarCol]{margin:var(--dsh-glass-gap,12px) calc(-1 * min(var(--dsh-glass-gap,12px), 16px)) var(--dsh-glass-gap,12px) var(--dsh-glass-gap,12px);transition:margin .15s var(--ds-ease-in-out), border-radius .15s var(--ds-ease-in-out);border-radius:16px;padding:0}[data-dsh-glass-float] [data-dsh-glass-frame]:not([data-sidebar-collapsed]) [data-dsh-glass-sidebar-root]{width:100%!important}[data-dsh-glass-float] [data-dsh-glass-trajectory]{margin:8px auto var(--dsh-glass-gap,12px);width:calc(100% - 32px);max-width:min(calc(var(--dsh-chat-user-width,clamp(680px, calc(var(--dsh-conversation-column-width,1500px) * .64), 920px)) + 32px), calc(100% - 32px));height:calc(100% - 8px - var(--dsh-glass-gap,12px));border:1px solid var(--dsh-glass-rim);background:var(--dsh-glass-card);box-shadow:var(--dsh-glass-edge), var(--dsh-glass-drop);border-radius:20px;overflow:hidden}[data-dsh-glass-float] [data-dsh-glass-trajectory] [role=toolbar],[data-dsh-glass-float] [data-dsh-glass-trajectory] section[aria-label=Trajectory\\ timeline]{background:0 0}[data-dsh-glass-float] [data-composer-card],[data-dsh-glass-float] [data-composer-card]:after{border-radius:24px}[data-dsh-glass-float] [data-composer-card]{z-index:8;isolation:isolate;border:1px solid var(--dsh-glass-rim-strong);box-shadow:var(--dsh-glass-input-shadow);background:0 0;position:relative}[data-dsh-glass-float] [data-composer-card]:before{content:\"\";z-index:-1;border-radius:inherit;background:var(--dsh-glass-card);box-shadow:var(--dsh-glass-edge);backdrop-filter:blur(var(--dsh-glass-blur,14px));pointer-events:none;position:absolute;inset:0}[data-dsh-glass-float] [data-dsh-glass-inputbar]:not([class*=hero]):not(:has([data-dsh-glass-stats])){padding-bottom:var(--dsh-glass-gap,12px)}[data-dsh-glass-float] [role=treeitem][aria-selected=true]{background:var(--dsw-alias-interactive-bg-hover)}[data-dsh-glass-float] button[class*=button]:hover:not(:disabled),[data-dsh-glass-float] [role=menuitem]:hover:not(:disabled){box-shadow:0 0 12px color-mix(in srgb, var(--dsw-alias-brand-primary-new-colorprimary-new-color) 20%, transparent)}[data-dsh-glass-float] [data-menu-material=translucent]:not(:focus-visible){--dsw-menu-surface-fill:var(--dsh-glass-card-raised);--dsw-menu-backdrop-filter:blur(var(--dsh-glass-blur,14px))}[data-dsh-glass-float] body[data-ds-dark-theme] [data-menu-material=translucent]:not(:focus-visible){outline:1px solid var(--dsh-glass-rim-soft);outline-offset:-1px}[data-dsh-glass-float] [role=menu]:not([data-menu-material]):not([data-menu-material] *){background:var(--dsh-glass-card-raised);border:1px solid var(--dsh-glass-rim-soft);backdrop-filter:blur(var(--dsh-glass-blur,14px))}[data-dsh-glass-float] [data-menu-material=translucent]:has([role=group]>[role=menuitemradio]){--dsw-menu-surface-fill:color-mix(in srgb, var(--dsw-alias-bg-layer-2) 70%, transparent)}[data-dsh-glass-float] [data-menu-group]:has(>[role=menuitemradio])>[data-menu-group-heading]{background:var(--dsh-glass-card-raised);backdrop-filter:blur(var(--dsh-glass-blur,14px));border-radius:999px;align-items:center;width:fit-content;margin:3px 0 5px 6px;padding:3px 10px;display:inline-flex}[data-dsh-glass-float] [role=presentation]>[role=dialog][aria-modal=true]{isolation:isolate;backdrop-filter:none;border:1px solid var(--dsh-glass-rim);box-shadow:var(--dsh-glass-edge), var(--dsh-glass-drop);background:0 0;border-radius:20px;position:relative}[data-dsh-glass-float] [role=presentation]>[role=dialog][aria-modal=true]:before{content:\"\";z-index:-1;border-radius:inherit;background:var(--dsh-glass-card-raised);backdrop-filter:blur(var(--dsh-glass-blur,14px));pointer-events:none;position:absolute;inset:0}[data-dsh-glass] [data-conversation-scroll]{text-shadow:0 0 1px #ffffff80}[data-dsh-glass] body[data-ds-dark-theme] [data-conversation-scroll]{text-shadow:0 0 1px #0006}[data-dsh-glass-float] [data-dsh-glass-inputbar] [data-slot]{color:var(--dsw-alias-label-secondary)}[data-dsh-glass]{--dsh-glass-entry-scale:1}[data-dsh-glass-compat]{--dsh-glass-entry-scale:0}[data-dsh-glass] [data-testid^=view-]{animation:dsh-glass-in calc(.26s * var(--dsh-glass-entry-scale,1)) var(--ds-ease-in-out)}[data-dsh-glass] [data-tool]{animation:dsh-glass-rise calc(.3s * var(--dsh-glass-entry-scale,1)) var(--ds-ease-in-out) both}[data-dsh-glass] [role=dialog]{animation:dsh-glass-dialog-in calc(.24s * var(--dsh-glass-entry-scale,1)) var(--ds-ease-in-out)}@keyframes dsh-glass-in{0%{opacity:0}}@keyframes dsh-glass-rise{0%{opacity:0;transform:translateY(6px)}}@keyframes dsh-glass-dialog-in{0%{opacity:0}}[data-dsh-glass] :focus-visible{outline:2px solid color-mix(in srgb, var(--dsw-alias-brand-primary-new-colorprimary-new-color) 85%, transparent);outline-offset:1px}[data-dsh-glass] ::selection{background:color-mix(in srgb, var(--dsw-alias-brand-primary-new-colorprimary-new-color) 35%, transparent)}[data-dsh-glass-compat] [role=menu]:not([data-menu-material]):not([data-menu-material] *),[data-dsh-glass-compat] [class*=popover],[data-dsh-glass-compat] [class*=dropdown]{backdrop-filter:blur(12px)}[data-dsh-glass-compat] [data-menu-material=translucent]:not(:focus-visible){--dsw-menu-surface-fill:var(--dsh-glass-card-raised);--dsw-menu-backdrop-filter:blur(12px)}/* 有意移除:平铺玻璃模式下右侧栏外壳的 backdrop-filter 会在展开/全屏切换时造成背景透出、收起后白屏(df5eb68 修复,勿随上游基线同步带回) */[data-dsh-glass-compat] [role=menu]:not([data-menu-material]):not([data-menu-material] *),[data-dsh-glass-compat] [class*=popover],[data-dsh-glass-compat] [class*=dropdown]{background:var(--dsh-glass-card-raised)}[data-dsh-glass-compat] [data-composer-card]{isolation:isolate;backdrop-filter:none;background:0 0;position:relative}[data-dsh-glass-compat] [data-composer-card]:before{content:\"\";z-index:-1;border-radius:inherit;background:var(--dsh-glass-card-raised);backdrop-filter:blur(12px);pointer-events:none;position:absolute;inset:0}[data-dsh-glass-compat] [role=menu]:not([data-menu-material]):not([data-menu-material] *):not(:focus-visible),[data-dsh-glass-compat] [data-composer-card]:not(:focus-visible),[data-dsh-glass-compat] [class*=popover]:not(:focus-visible),[data-dsh-glass-compat] [class*=dropdown]:not(:focus-visible){outline:1px solid var(--dsh-glass-rim);outline-offset:-1px}[data-dsh-glass-compat] [role=presentation]>[role=dialog][aria-modal=true]{isolation:isolate;backdrop-filter:none;border:1px solid var(--dsh-glass-rim);box-shadow:var(--dsh-glass-edge), var(--dsh-glass-drop);background:0 0;position:relative}[data-dsh-glass-compat] [role=presentation]>[role=dialog][aria-modal=true]:before{content:\"\";z-index:-1;border-radius:inherit;background:var(--dsh-glass-card-raised);backdrop-filter:blur(var(--dsh-glass-blur,12px));pointer-events:none;position:absolute;inset:0}[data-dsh-glass-settings] [role=menu]:not([data-menu-material]):not([data-menu-material] *),[data-dsh-glass-settings] .dsm-select-menu{background:color-mix(in srgb, var(--dsh-glass-ground) 92%, transparent);backdrop-filter:blur(12px);box-shadow:var(--dsh-glass-drop)}[data-dsh-glass-settings] .dsm-panel-head{isolation:isolate;outline:1px solid var(--dsh-glass-rim-soft);outline-offset:-1px;background:0 0;border-radius:14px;padding:6px 12px 4px}[data-dsh-glass-settings] .dsm-panel-head:before{content:\"\";z-index:-1;border-radius:inherit;background:color-mix(in srgb, var(--dsh-glass-ground) 78%, transparent);backdrop-filter:blur(12px);pointer-events:none;position:absolute;inset:0}@media (prefers-reduced-motion:reduce){[data-dsh-glass] [data-testid^=view-],[data-dsh-glass] [data-tool],[data-dsh-glass] [role=dialog]{animation:none}}";
|
|
167
202
|
//#endregion
|
|
168
203
|
//#region src/client/theme/glass-seams.ts
|
|
169
204
|
const SEAMS = [
|
|
@@ -341,67 +376,35 @@ window.__ModuleLoader__.load({
|
|
|
341
376
|
border-radius: 0 !important;
|
|
342
377
|
}
|
|
343
378
|
|
|
344
|
-
/*
|
|
345
|
-
[data-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
379
|
+
/* 云母浮动顶栏:浮动排版把滚动内容上提 95px,让它从顶栏下方穿过。
|
|
380
|
+
⚠ 绝对禁止在滚动容器 [data-conversation-scroll] 上使用 mask-image / clip-path 做顶部淡出:
|
|
381
|
+
Chromium 会让被遮罩的元素成为 backdrop root,导致其内部所有 backdrop-filter(输入卡片、
|
|
382
|
+
底部 dock 磨砂幕布)全部失效 —— 实测在真实宿主里把它设成 blur(24px) 后画面几乎没有任何
|
|
383
|
+
变化(拉普拉斯方差仅降 17%),去掉 mask 后同一处方差降 86%,云母输入框恢复正常磨砂。
|
|
384
|
+
这正是「还是透」的真因:兜底模糊一直在,只是被 mask 变成惰性。
|
|
385
|
+
因此顶部遮挡改为与对标插件一致的做法:不给滚动容器加遮罩,只把顶栏自己的磨砂设为下限值,
|
|
386
|
+
让从顶栏背后穿过的正文被磨砂化开。 */
|
|
387
|
+
[data-dsh-glass-float] [data-phase] header:not([class*="headerBlank"]) {
|
|
388
|
+
backdrop-filter: blur(max(var(--dsh-glass-blur, 12px), 12px)) !important;
|
|
389
|
+
-webkit-backdrop-filter: blur(max(var(--dsh-glass-blur, 12px), 12px)) !important;
|
|
354
390
|
}
|
|
355
391
|
|
|
356
|
-
/*
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
--dsh-glass-
|
|
361
|
-
|
|
362
|
-
radial-gradient(48% 42% at 86% 14%, color-mix(in srgb, var(--dsw-alias-state-success-tertiary) calc(10% * var(--dsh-glass-ambience) * var(--dsh-glass-glow,0)), transparent), transparent 62%),
|
|
363
|
-
linear-gradient(165deg, color-mix(in srgb, var(--dsh-glass-ground), var(--dsh-glass-wash-tint) calc(var(--dsh-glass-wash-mix) * var(--dsh-glass-ambience))) 0%, var(--dsh-glass-ground) 55%, color-mix(in srgb, var(--dsh-glass-ground), #000 calc(5% * var(--dsh-glass-ambience))) 100%);
|
|
392
|
+
/* 对齐平铺风格(Compat)防漏字规范:将云母输入框卡片底色提升为高遮蔽度的 card-raised,
|
|
393
|
+
并锁定至少 12px 高斯磨砂,将底层滚动的历史文字彻底化开为淡淡的柔和色块,杜绝锐利笔画穿透叠字 */
|
|
394
|
+
[data-dsh-glass-float] [data-composer-card]::before {
|
|
395
|
+
background: var(--dsh-glass-card-raised) !important;
|
|
396
|
+
backdrop-filter: blur(max(var(--dsh-glass-blur, 12px), 12px)) !important;
|
|
397
|
+
-webkit-backdrop-filter: blur(max(var(--dsh-glass-blur, 12px), 12px)) !important;
|
|
364
398
|
}
|
|
365
399
|
|
|
366
|
-
/*
|
|
367
|
-
向上回看历史时正文会直接穿过输入卡片与底部 dock 区域;参考插件那条 dock 遮罩带又因色差被移除,
|
|
368
|
-
于是两层遮挡同时缺失。这里补回遮挡,拆成「座舱底板 + 上沿渐隐带」两段:
|
|
369
|
-
底板铺与页面底色逐像素一致的底盘(见上),彻底挡住正文且无色带;
|
|
370
|
-
渐隐带用 mask 淡出同一块底盘,高度 16px 是因为实测最后一条消息底部与座舱顶部正好留白 16px,
|
|
371
|
-
只覆盖这段空白,滚到底时不会把最后一条消息一起淡掉。 */
|
|
372
|
-
[data-dsh-glass] [data-phase=active] [class*="composerSeat"][class*="composerSeat"],
|
|
373
|
-
[data-dsh-glass] [data-content-phase=active] [class*="composerSeat"][class*="composerSeat"] {
|
|
374
|
-
background: var(--dsh-glass-ground-layers);
|
|
375
|
-
background-attachment: fixed;
|
|
376
|
-
}
|
|
400
|
+
/* 平铺(compat)模式的卡片材质由上游固定为 12px,这里不再覆盖,避免浓厚预设把 compat 也带成 20px */
|
|
377
401
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
height: 16px;
|
|
385
|
-
z-index: -1;
|
|
386
|
-
pointer-events: none;
|
|
387
|
-
background: var(--dsh-glass-ground-layers);
|
|
388
|
-
background-attachment: fixed;
|
|
389
|
-
-webkit-mask-image: linear-gradient(180deg, transparent 0, #000 100%);
|
|
390
|
-
mask-image: linear-gradient(180deg, transparent 0, #000 100%);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
/* 云母浮动顶栏同一缺陷:浮动排版把滚动内容上提 95px,让它从顶栏下方穿过(padding-top:107px 只保证
|
|
394
|
-
滚到顶部时内容起始于顶栏下方)。而顶栏底色只有 52% × frost(clear 预设仅 8.3%)、blur 为 0,
|
|
395
|
-
于是正文在「窗口顶部 12px 留白」「20px 圆角切角」「顶栏本体」三处都会透出来。
|
|
396
|
-
做法:不动顶栏本身(边框、阴影、磨砂全部保留),而是让滚动内容在顶栏区域内淡出。
|
|
397
|
-
注意 mask 的原点是滚动容器的 border box,不是视口:
|
|
398
|
-
- 容器顶 = 顶栏底边 97px − 95px(margin-top) = 2px
|
|
399
|
-
- 96px → 绝对 y=98,刚好压在顶栏底边 97 之下(alpha=0,顶栏内不留任何正文)
|
|
400
|
-
- 106px → 绝对 y=108,而内容最早从 y=109 开始(容器顶 2 + 宿主 padding-top 107)
|
|
401
|
-
所以渐入既盖满顶栏区域,又不会压暗任何正文。改这两个常量前先重算这三个数。 */
|
|
402
|
-
[data-dsh-glass-float] [data-phase=active] [data-conversation-scroll] {
|
|
403
|
-
-webkit-mask-image: linear-gradient(180deg, transparent 0, transparent 96px, #000 106px);
|
|
404
|
-
mask-image: linear-gradient(180deg, transparent 0, transparent 96px, #000 106px);
|
|
402
|
+
/* dock 磨砂幕布同样只给云母浮动模式加 12px 下限:compat 的 blur 完全交给上游,
|
|
403
|
+
否则 clear 预设(blur:0)会被这条下限悄悄抬到 12px,与「平铺保持原版材质」的约定冲突 */
|
|
404
|
+
[data-dsh-glass-float] [data-dsh-glass-inputbar] > [class*="dock"]::before,
|
|
405
|
+
[data-dsh-glass-float] [data-dsh-glass-inputbar] > [data-composer-dock]::before {
|
|
406
|
+
backdrop-filter: blur(max(var(--dsh-glass-blur, 12px), 12px)) !important;
|
|
407
|
+
-webkit-backdrop-filter: blur(max(var(--dsh-glass-blur, 12px), 12px)) !important;
|
|
405
408
|
}
|
|
406
409
|
|
|
407
410
|
/* 斜杠指令/快捷指令候选面板([data-trigger-menu] / Issue #72):
|
|
@@ -455,6 +458,24 @@ window.__ModuleLoader__.load({
|
|
|
455
458
|
for (const [prop, val] of Object.entries(knobs)) root.style.setProperty(prop, val);
|
|
456
459
|
if (document.body) for (const [prop, val] of Object.entries(knobs)) document.body.style.setProperty(prop, val);
|
|
457
460
|
if (!seamDisposer) seamDisposer = startGlassSeamStamper();
|
|
461
|
+
ensureGlassFade(!isCompat);
|
|
462
|
+
}
|
|
463
|
+
const FADE_ATTRIBUTE = "data-dsh-glass-fade";
|
|
464
|
+
/** 云母模式挂载顶部渐隐条;平铺模式或关闭玻璃时移除 */
|
|
465
|
+
function ensureGlassFade(enabled) {
|
|
466
|
+
if (typeof document === "undefined") return;
|
|
467
|
+
const existing = document.querySelector(`[${FADE_ATTRIBUTE}="top"]`);
|
|
468
|
+
if (!enabled) {
|
|
469
|
+
existing?.remove();
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
if (existing !== null) return;
|
|
473
|
+
const body = document.body;
|
|
474
|
+
if (body === null) return;
|
|
475
|
+
const fade = document.createElement("div");
|
|
476
|
+
fade.setAttribute(FADE_ATTRIBUTE, "top");
|
|
477
|
+
fade.setAttribute("aria-hidden", "true");
|
|
478
|
+
body.appendChild(fade);
|
|
458
479
|
}
|
|
459
480
|
/**
|
|
460
481
|
* 彻底释放玻璃质感、清理 DOM 属性与样式标签
|
|
@@ -465,6 +486,7 @@ window.__ModuleLoader__.load({
|
|
|
465
486
|
root.removeAttribute(GLASS_ATTRIBUTE);
|
|
466
487
|
root.removeAttribute(GLASS_FLOAT_ATTRIBUTE);
|
|
467
488
|
root.removeAttribute(GLASS_COMPAT_ATTRIBUTE);
|
|
489
|
+
ensureGlassFade(false);
|
|
468
490
|
const knobs = [
|
|
469
491
|
"--dsh-glass-blur",
|
|
470
492
|
"--dsh-glass-frost",
|
|
@@ -1847,18 +1869,6 @@ window.__ModuleLoader__.load({
|
|
|
1847
1869
|
border-radius: 0 !important;
|
|
1848
1870
|
}
|
|
1849
1871
|
|
|
1850
|
-
/* 彻底清除输入框底部 dock / stats 区域的半透明灰色脏色块与切线 */
|
|
1851
|
-
[data-dsh-glass] [data-phase] [data-dsh-glass-inputbar] > [class*="dock"]:before,
|
|
1852
|
-
[data-dsh-glass] [data-phase] [data-dsh-glass-inputbar] > [data-composer-dock]:before,
|
|
1853
|
-
[data-dsh-glass] [class*="dock"]:before,
|
|
1854
|
-
[data-dsh-glass] [data-composer-dock]:before {
|
|
1855
|
-
display: none !important;
|
|
1856
|
-
content: none !important;
|
|
1857
|
-
background: transparent !important;
|
|
1858
|
-
backdrop-filter: none !important;
|
|
1859
|
-
-webkit-backdrop-filter: none !important;
|
|
1860
|
-
}
|
|
1861
|
-
|
|
1862
1872
|
/* 斜杠指令/快捷指令候选面板([data-trigger-menu] / Issue #72):
|
|
1863
1873
|
在选用自定义主题时,无论是否开启毛玻璃,提升面板材质浓度,杜绝悬浮在消息流上时的字叠字穿透 */
|
|
1864
1874
|
[data-trigger-menu] {
|
|
@@ -3105,6 +3115,9 @@ html[data-dsh-glass] body:not([data-ds-dark-theme]) .dcu-section-card{background
|
|
|
3105
3115
|
"settings.records": "记录与应用",
|
|
3106
3116
|
"settings.noResults": "没有匹配的设置分类",
|
|
3107
3117
|
"input.historyHint": "↑↓ 翻历史",
|
|
3118
|
+
"input.prediction.tab": "Tab 采纳",
|
|
3119
|
+
"input.prediction.more": "Alt+↓ 切换",
|
|
3120
|
+
"input.prediction.dismiss": "Esc 忽略",
|
|
3108
3121
|
"about.nav": "Codex UI",
|
|
3109
3122
|
"sections.pinned": "置顶",
|
|
3110
3123
|
"sections.default": "项目",
|
|
@@ -3291,6 +3304,9 @@ html[data-dsh-glass] body:not([data-ds-dark-theme]) .dcu-section-card{background
|
|
|
3291
3304
|
"settings.records": "Records and app",
|
|
3292
3305
|
"settings.noResults": "No matching settings categories",
|
|
3293
3306
|
"input.historyHint": "↑↓ History",
|
|
3307
|
+
"input.prediction.tab": "Tab accept",
|
|
3308
|
+
"input.prediction.more": "Alt+↓ cycle",
|
|
3309
|
+
"input.prediction.dismiss": "Esc dismiss",
|
|
3294
3310
|
"about.nav": "Codex UI",
|
|
3295
3311
|
"sections.pinned": "Pinned",
|
|
3296
3312
|
"sections.default": "Projects",
|
|
@@ -4001,29 +4017,29 @@ html[data-platform="darwin"]:not([data-fullscreen]) [data-shortcut-modal="settin
|
|
|
4001
4017
|
height: calc(100vh - var(--dsh-frame-top-clearance, 38px)) !important;
|
|
4002
4018
|
}
|
|
4003
4019
|
|
|
4004
|
-
/*
|
|
4020
|
+
/* 左侧整列侧栏:与首页侧栏严格等宽,底色统合对齐 --dsw-alias-bg-layer-2,杜绝与右侧工作区产生色差断层 */
|
|
4005
4021
|
[data-shortcut-modal="settings"] > nav {
|
|
4006
4022
|
box-sizing: border-box !important;
|
|
4007
4023
|
width: var(--dcu-settings-nav-width, 280px) !important;
|
|
4008
4024
|
min-width: var(--dcu-settings-nav-width, 280px) !important;
|
|
4009
4025
|
max-width: var(--dcu-settings-nav-width, 280px) !important;
|
|
4010
4026
|
flex-shrink: 0 !important;
|
|
4011
|
-
gap:
|
|
4027
|
+
gap: 0 !important;
|
|
4012
4028
|
padding: 16px 12px 24px !important;
|
|
4013
4029
|
border-right: 1px solid var(--dsw-alias-border-l1, rgba(255, 255, 255, 0.08)) !important;
|
|
4014
|
-
background: var(--dsw-
|
|
4030
|
+
background: var(--dsw-alias-bg-layer-2, #18181b) !important;
|
|
4015
4031
|
overflow: hidden !important;
|
|
4016
4032
|
display: flex !important;
|
|
4017
4033
|
flex-direction: column !important;
|
|
4018
4034
|
}
|
|
4019
4035
|
|
|
4020
|
-
/*
|
|
4036
|
+
/* 设置工作台必须使用实色不透明底板,左右两栏整体浑然一体 */
|
|
4021
4037
|
[data-shortcut-modal="settings"] {
|
|
4022
|
-
background: var(--dsw-alias-bg-
|
|
4038
|
+
background: var(--dsw-alias-bg-layer-2, #18181b) !important;
|
|
4023
4039
|
}
|
|
4024
4040
|
|
|
4025
4041
|
[data-shortcut-modal="settings"]:not(:has(> [class*="options"])) > div:not(nav) {
|
|
4026
|
-
background: var(--dsw-alias-bg-
|
|
4042
|
+
background: var(--dsw-alias-bg-layer-2, #18181b) !important;
|
|
4027
4043
|
}
|
|
4028
4044
|
|
|
4029
4045
|
/* 浅色模式全局兜底:浅底高对比度规范,绝不允许残留或回退暗黑色 */
|
|
@@ -4100,7 +4116,7 @@ html[data-dsh-glass-float] [data-shortcut-modal="settings"]:not(:has(> [class*="
|
|
|
4100
4116
|
border-radius: 16px !important;
|
|
4101
4117
|
border: 1px solid var(--dsh-glass-rim-soft, rgba(0, 0, 0, 0.08)) !important;
|
|
4102
4118
|
box-shadow: var(--dsh-glass-drop, 0 8px 24px rgba(0, 0, 0, 0.08)), inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;
|
|
4103
|
-
background: var(--
|
|
4119
|
+
background: var(--dsw-alias-bg-layer-2, var(--dsh-glass-card, #18181b)) !important;
|
|
4104
4120
|
backdrop-filter: blur(var(--dsh-glass-blur, 16px)) !important;
|
|
4105
4121
|
-webkit-backdrop-filter: blur(var(--dsh-glass-blur, 16px)) !important;
|
|
4106
4122
|
overflow: hidden !important;
|
|
@@ -4114,7 +4130,7 @@ html[data-dsh-glass-float] [data-shortcut-modal="settings"]:not(:has(> [class*="
|
|
|
4114
4130
|
border-radius: 16px !important;
|
|
4115
4131
|
border: 1px solid var(--dsh-glass-rim-soft, rgba(0, 0, 0, 0.08)) !important;
|
|
4116
4132
|
box-shadow: var(--dsh-glass-drop, 0 8px 24px rgba(0, 0, 0, 0.08)), inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;
|
|
4117
|
-
background: var(--dsw-alias-bg-layer-1) !important;
|
|
4133
|
+
background: var(--dsw-alias-bg-layer-2, var(--dsw-alias-bg-layer-1, #18181b)) !important;
|
|
4118
4134
|
backdrop-filter: none !important;
|
|
4119
4135
|
-webkit-backdrop-filter: none !important;
|
|
4120
4136
|
overflow: hidden !important;
|
|
@@ -4125,12 +4141,12 @@ html[data-dsh-glass-float] [data-shortcut-modal="settings"]:not(:has(> [class*="
|
|
|
4125
4141
|
height: 48px !important;
|
|
4126
4142
|
min-height: 48px !important;
|
|
4127
4143
|
padding: 0 24px !important;
|
|
4128
|
-
background: var(--dsw-alias-bg-layer-1) !important;
|
|
4144
|
+
background: var(--dsw-alias-bg-layer-2, var(--dsw-alias-bg-layer-1, #18181b)) !important;
|
|
4129
4145
|
}
|
|
4130
4146
|
|
|
4131
4147
|
html[data-dsh-glass-float] [data-shortcut-modal="settings"]:not(:has(> [class*="options"])) > div:not(nav) > :nth-child(2) {
|
|
4132
|
-
padding: 16px
|
|
4133
|
-
background: var(--dsw-alias-bg-layer-1) !important;
|
|
4148
|
+
padding: 16px 32px 48px !important;
|
|
4149
|
+
background: var(--dsw-alias-bg-layer-2, var(--dsw-alias-bg-layer-1, #18181b)) !important;
|
|
4134
4150
|
}
|
|
4135
4151
|
|
|
4136
4152
|
html[data-platform="darwin"] [data-shortcut-modal="settings"] > nav {
|
|
@@ -4403,11 +4419,11 @@ button.dcu-settings-back-btn:hover,
|
|
|
4403
4419
|
min-height: 0 !important;
|
|
4404
4420
|
flex: 1 1 auto !important;
|
|
4405
4421
|
overflow-y: auto !important;
|
|
4406
|
-
padding: 32px 48px
|
|
4422
|
+
padding: 24px 32px 48px !important;
|
|
4407
4423
|
background: var(--dsw-alias-bg-layer-2, #18181b) !important;
|
|
4408
4424
|
display: flex !important;
|
|
4409
4425
|
flex-direction: column !important;
|
|
4410
|
-
align-items:
|
|
4426
|
+
align-items: stretch !important;
|
|
4411
4427
|
}
|
|
4412
4428
|
|
|
4413
4429
|
/* 浅色模式右侧内容区实色与文字按钮高对比度兜底 */
|
|
@@ -4443,7 +4459,9 @@ html[data-ds-theme-source="light"] [data-shortcut-modal="settings"]:not(:has(> [
|
|
|
4443
4459
|
background: var(--dsw-alias-bg-layer-1, #ffffff) !important;
|
|
4444
4460
|
}
|
|
4445
4461
|
|
|
4446
|
-
/*
|
|
4462
|
+
/* 右侧设置区固定宽度规范:卡片先吃满列宽、再被 800px 夹住,左右留白相等(不会出现单侧空洞)。
|
|
4463
|
+
实测(scripts/verify-settings-geometry.mjs,1400px 面板):卡片宽 800px、左右各 260px —
|
|
4464
|
+
即「居中收束」而不是贴左;若要改成贴左,需同时去掉下面的 margin-inline: auto。 */
|
|
4447
4465
|
[data-shortcut-modal="settings"]:not(:has(> [class*="options"])) > div:not(nav) > :nth-child(2) > * {
|
|
4448
4466
|
width: 100% !important;
|
|
4449
4467
|
max-width: 800px !important;
|
|
@@ -4480,10 +4498,10 @@ html[data-ds-theme-source="light"] [data-shortcut-modal="settings"]:not(:has(> [
|
|
|
4480
4498
|
width: var(--dcu-settings-nav-width, 280px) !important;
|
|
4481
4499
|
min-width: var(--dcu-settings-nav-width, 280px) !important;
|
|
4482
4500
|
max-width: var(--dcu-settings-nav-width, 280px) !important;
|
|
4483
|
-
background: var(--dsw-
|
|
4501
|
+
background: var(--dsw-alias-bg-layer-2, #18181b) !important;
|
|
4484
4502
|
border-right: 1px solid var(--dsw-alias-border-l1, rgba(255, 255, 255, 0.08)) !important;
|
|
4485
4503
|
border-bottom: none !important;
|
|
4486
|
-
padding: 16px 12px
|
|
4504
|
+
padding: 16px 12px 8px 12px !important;
|
|
4487
4505
|
margin: 0 !important;
|
|
4488
4506
|
height: auto !important;
|
|
4489
4507
|
flex: none !important;
|
|
@@ -4496,10 +4514,10 @@ html[data-ds-theme-source="light"] [data-shortcut-modal="settings"]:not(:has(> [
|
|
|
4496
4514
|
width: var(--dcu-settings-nav-width, 280px) !important;
|
|
4497
4515
|
min-width: var(--dcu-settings-nav-width, 280px) !important;
|
|
4498
4516
|
max-width: var(--dcu-settings-nav-width, 280px) !important;
|
|
4499
|
-
background: var(--dsw-
|
|
4517
|
+
background: var(--dsw-alias-bg-layer-2, #18181b) !important;
|
|
4500
4518
|
border-right: 1px solid var(--dsw-alias-border-l1, rgba(255, 255, 255, 0.08)) !important;
|
|
4501
4519
|
border-top: none !important;
|
|
4502
|
-
padding: 0 12px 24px !important;
|
|
4520
|
+
padding: 0 12px 24px 12px !important;
|
|
4503
4521
|
margin: 0 !important;
|
|
4504
4522
|
overflow-y: auto !important;
|
|
4505
4523
|
height: 100% !important;
|
|
@@ -4541,13 +4559,13 @@ html[data-ds-theme-source="light"] [data-shortcut-modal="settings"]:not(:has(> [
|
|
|
4541
4559
|
box-sizing: border-box !important;
|
|
4542
4560
|
min-height: 0 !important;
|
|
4543
4561
|
overflow-y: auto !important;
|
|
4544
|
-
padding-top: calc(56px +
|
|
4545
|
-
padding-bottom:
|
|
4546
|
-
padding-inline:
|
|
4562
|
+
padding-top: calc(56px + 20px) !important;
|
|
4563
|
+
padding-bottom: 48px !important;
|
|
4564
|
+
padding-inline: 32px !important;
|
|
4547
4565
|
background: var(--dsw-alias-bg-layer-2, #18181b) !important;
|
|
4548
4566
|
display: flex !important;
|
|
4549
4567
|
flex-direction: column !important;
|
|
4550
|
-
align-items:
|
|
4568
|
+
align-items: stretch !important;
|
|
4551
4569
|
margin: 0 !important;
|
|
4552
4570
|
height: 100% !important;
|
|
4553
4571
|
flex: none !important;
|
|
@@ -4605,12 +4623,13 @@ html[data-dsh-glass-float] [data-shortcut-modal="settings"]:has(> [class*="optio
|
|
|
4605
4623
|
min-width: 0 !important;
|
|
4606
4624
|
max-width: none !important;
|
|
4607
4625
|
margin: 0 !important;
|
|
4626
|
+
padding: 16px 12px 8px 12px !important;
|
|
4608
4627
|
border-right: 1px solid var(--dsh-glass-rim-soft, rgba(0, 0, 0, 0.08)) !important;
|
|
4609
4628
|
border-left: 1px solid var(--dsh-glass-rim-soft, rgba(0, 0, 0, 0.08)) !important;
|
|
4610
4629
|
border-top: 1px solid var(--dsh-glass-rim-soft, rgba(0, 0, 0, 0.08)) !important;
|
|
4611
4630
|
border-bottom: none !important;
|
|
4612
4631
|
border-radius: 16px 16px 0 0 !important;
|
|
4613
|
-
background: var(--dsw-
|
|
4632
|
+
background: var(--dsw-alias-bg-layer-2, #18181b) !important;
|
|
4614
4633
|
backdrop-filter: none !important;
|
|
4615
4634
|
-webkit-backdrop-filter: none !important;
|
|
4616
4635
|
box-shadow: none !important;
|
|
@@ -4621,12 +4640,13 @@ html[data-dsh-glass-float] [data-shortcut-modal="settings"]:has(> [class*="optio
|
|
|
4621
4640
|
min-width: 0 !important;
|
|
4622
4641
|
max-width: none !important;
|
|
4623
4642
|
margin: 0 !important;
|
|
4643
|
+
padding: 0 12px 24px 12px !important;
|
|
4624
4644
|
border-right: 1px solid var(--dsh-glass-rim-soft, rgba(0, 0, 0, 0.08)) !important;
|
|
4625
4645
|
border-left: 1px solid var(--dsh-glass-rim-soft, rgba(0, 0, 0, 0.08)) !important;
|
|
4626
4646
|
border-bottom: 1px solid var(--dsh-glass-rim-soft, rgba(0, 0, 0, 0.08)) !important;
|
|
4627
4647
|
border-top: none !important;
|
|
4628
4648
|
border-radius: 0 0 16px 16px !important;
|
|
4629
|
-
background: var(--dsw-
|
|
4649
|
+
background: var(--dsw-alias-bg-layer-2, #18181b) !important;
|
|
4630
4650
|
backdrop-filter: none !important;
|
|
4631
4651
|
-webkit-backdrop-filter: none !important;
|
|
4632
4652
|
box-shadow: var(--dsh-glass-drop, 0 8px 24px rgba(0, 0, 0, 0.08)) !important;
|
|
@@ -4669,11 +4689,11 @@ html[data-dsh-glass-float] [data-shortcut-modal="settings"]:has(> [class*="optio
|
|
|
4669
4689
|
margin: 0 !important;
|
|
4670
4690
|
border: 1px solid var(--dsh-glass-rim-soft, rgba(0, 0, 0, 0.08)) !important;
|
|
4671
4691
|
border-radius: 16px !important;
|
|
4672
|
-
background: var(--dsw-alias-bg-layer-1) !important;
|
|
4692
|
+
background: var(--dsw-alias-bg-layer-2, var(--dsw-alias-bg-layer-1, #18181b)) !important;
|
|
4673
4693
|
box-shadow: var(--dsh-glass-drop, 0 8px 24px rgba(0, 0, 0, 0.08)), inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;
|
|
4674
|
-
padding-top: calc(56px +
|
|
4694
|
+
padding-top: calc(56px + 20px) !important;
|
|
4675
4695
|
padding-bottom: 48px !important;
|
|
4676
|
-
padding-inline:
|
|
4696
|
+
padding-inline: 32px !important;
|
|
4677
4697
|
}
|
|
4678
4698
|
|
|
4679
4699
|
/* 无论窗口 <=768px 还是处于收起态 [data-sidebar-collapsed],结构尺寸均收敛为 56px 导轨 */
|
|
@@ -5679,9 +5699,18 @@ html[data-dsh-glass-float] [data-shortcut-modal="settings"][data-sidebar-collaps
|
|
|
5679
5699
|
emptyTip.textContent = isZh ? zh["settings.noResults"] : en["settings.noResults"];
|
|
5680
5700
|
navList.appendChild(emptyTip);
|
|
5681
5701
|
}
|
|
5702
|
+
const getNavButtonLabel = (btn) => {
|
|
5703
|
+
const labelEl = btn.querySelector("[class*=\"navLabel\"]");
|
|
5704
|
+
if (labelEl && labelEl.textContent?.trim()) return labelEl.textContent.trim();
|
|
5705
|
+
const textSpan = btn.querySelector("span:not([class*=\"navIcon\"])");
|
|
5706
|
+
if (textSpan && textSpan.textContent?.trim()) return textSpan.textContent.trim();
|
|
5707
|
+
const allSpans = btn.querySelectorAll("span");
|
|
5708
|
+
for (const s of allSpans) if (s.textContent?.trim() && !s.className?.includes("navIcon")) return s.textContent.trim();
|
|
5709
|
+
return btn.textContent?.trim() ?? "";
|
|
5710
|
+
};
|
|
5682
5711
|
const classifyButtons = () => {
|
|
5683
5712
|
navList.querySelectorAll(":scope > button").forEach((btn, index) => {
|
|
5684
|
-
const group = classifySettingsButton(
|
|
5713
|
+
const group = classifySettingsButton(getNavButtonLabel(btn));
|
|
5685
5714
|
const baseOrder = group === "personal" ? 100 : group === "records" ? 300 : 200;
|
|
5686
5715
|
btn.style.setProperty("order", String(baseOrder + 1 + index));
|
|
5687
5716
|
btn.setAttribute("data-dcu-group", group);
|
|
@@ -5693,7 +5722,7 @@ html[data-dsh-glass-float] [data-shortcut-modal="settings"][data-sidebar-collaps
|
|
|
5693
5722
|
const buttons = navList.querySelectorAll(":scope > button");
|
|
5694
5723
|
let totalVisible = 0;
|
|
5695
5724
|
for (const btn of buttons) {
|
|
5696
|
-
const label = (btn
|
|
5725
|
+
const label = getNavButtonLabel(btn).toLowerCase();
|
|
5697
5726
|
if (trimmed === "") {
|
|
5698
5727
|
btn.style.removeProperty("display");
|
|
5699
5728
|
totalVisible += 1;
|
|
@@ -5705,8 +5734,7 @@ html[data-dsh-glass-float] [data-shortcut-modal="settings"][data-sidebar-collaps
|
|
|
5705
5734
|
for (const group of SETTINGS_NAV_GROUPS) {
|
|
5706
5735
|
const header = navList.querySelector(`[data-dcu-group-header="${group.id}"]`);
|
|
5707
5736
|
if (header) {
|
|
5708
|
-
if (
|
|
5709
|
-
else if ([...navList.querySelectorAll(`button[data-dcu-group="${group.id}"]`)].filter((b) => b.style.display !== "none").length > 0) header.style.removeProperty("display");
|
|
5737
|
+
if ([...navList.querySelectorAll(`button[data-dcu-group="${group.id}"]`)].filter((b) => b.style.display !== "none").length > 0) header.style.removeProperty("display");
|
|
5710
5738
|
else header.style.setProperty("display", "none", "important");
|
|
5711
5739
|
}
|
|
5712
5740
|
}
|
|
@@ -5800,6 +5828,36 @@ html[data-dsh-glass-float] [data-shortcut-modal="settings"][data-sidebar-collaps
|
|
|
5800
5828
|
const CODEX_UI_NAV_MARKER = "data-dcu-nav-icon";
|
|
5801
5829
|
const NAV_ROW_SELECTOR = "[role=\"dialog\"] nav button, [data-shortcut-modal=\"settings\"] nav button";
|
|
5802
5830
|
const STYLE_ID$3 = "dcu-settings-nav-icon-style";
|
|
5831
|
+
/** 原生 settings.section.icon 插槽图标组件 */
|
|
5832
|
+
function CodexUiNavIcon({ size = 16 }) {
|
|
5833
|
+
return react.default.createElement("svg", {
|
|
5834
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5835
|
+
viewBox: "0 0 16 16",
|
|
5836
|
+
width: size,
|
|
5837
|
+
height: size,
|
|
5838
|
+
fill: "none",
|
|
5839
|
+
stroke: "currentColor",
|
|
5840
|
+
strokeWidth: 1.3,
|
|
5841
|
+
strokeLinecap: "round",
|
|
5842
|
+
strokeLinejoin: "round"
|
|
5843
|
+
}, react.default.createElement("rect", {
|
|
5844
|
+
x: 1.5,
|
|
5845
|
+
y: 2,
|
|
5846
|
+
width: 13,
|
|
5847
|
+
height: 12,
|
|
5848
|
+
rx: 2
|
|
5849
|
+
}), react.default.createElement("line", {
|
|
5850
|
+
x1: 5.5,
|
|
5851
|
+
y1: 2,
|
|
5852
|
+
x2: 5.5,
|
|
5853
|
+
y2: 14
|
|
5854
|
+
}), react.default.createElement("line", {
|
|
5855
|
+
x1: 5.5,
|
|
5856
|
+
y1: 5.5,
|
|
5857
|
+
x2: 14.5,
|
|
5858
|
+
y2: 5.5
|
|
5859
|
+
}));
|
|
5860
|
+
}
|
|
5803
5861
|
const ICON_MASK_URL = `url("data:image/svg+xml,${encodeURIComponent("<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><rect x=\"1.5\" y=\"2\" width=\"13\" height=\"12\" rx=\"2\" stroke=\"black\" stroke-width=\"1.3\" fill=\"none\"/><line x1=\"5.5\" y1=\"2\" x2=\"5.5\" y2=\"14\" stroke=\"black\" stroke-width=\"1.3\"/><line x1=\"5.5\" y1=\"5.5\" x2=\"14.5\" y2=\"5.5\" stroke=\"black\" stroke-width=\"1.3\"/></svg>")}")`;
|
|
5804
5862
|
const NAV_ICON_CSS = `
|
|
5805
5863
|
[${CODEX_UI_NAV_MARKER}="codex-ui"] > svg { display: none !important; }
|
|
@@ -5830,8 +5888,17 @@ html[data-dsh-glass-float] [data-shortcut-modal="settings"][data-sidebar-collaps
|
|
|
5830
5888
|
const normalized = text.replace(/\s+/g, " ").trim().toLowerCase();
|
|
5831
5889
|
return normalized === getLabel().trim().toLowerCase() || normalized === "codex ui";
|
|
5832
5890
|
}
|
|
5891
|
+
/** 把「Codex UI」设置项按钮切到原生插槽图标之外的自绘 icon(属性标记 + CSS mask)。
|
|
5892
|
+
* 返回值表示「本次调用改动了该按钮的状态」(打上或移除了标记),供调用方做变更统计。 */
|
|
5833
5893
|
function applyNavIcon(button, getLabel) {
|
|
5834
5894
|
if (matchesLabel(button.textContent ?? "", getLabel)) {
|
|
5895
|
+
if (Boolean(button.querySelector?.("span[class*=\"navIcon\"]"))) {
|
|
5896
|
+
if (button.getAttribute("data-dcu-nav-icon") === "codex-ui") {
|
|
5897
|
+
button.removeAttribute(CODEX_UI_NAV_MARKER);
|
|
5898
|
+
return true;
|
|
5899
|
+
}
|
|
5900
|
+
return false;
|
|
5901
|
+
}
|
|
5835
5902
|
if (button.getAttribute("data-dcu-nav-icon") === "codex-ui") return false;
|
|
5836
5903
|
ensureStyle(button.ownerDocument ?? document);
|
|
5837
5904
|
button.setAttribute(CODEX_UI_NAV_MARKER, "codex-ui");
|
|
@@ -6416,6 +6483,686 @@ html[data-dsh-glass-float] [data-shortcut-modal="settings"][data-sidebar-collaps
|
|
|
6416
6483
|
});
|
|
6417
6484
|
}
|
|
6418
6485
|
//#endregion
|
|
6486
|
+
//#region src/client/composer/ComposerPredictionOverlay.tsx
|
|
6487
|
+
/**
|
|
6488
|
+
* Browser half of composer predictions (1:1 完整无损移植自 dsh-composer-predictions 1.2.8 原版源码)
|
|
6489
|
+
* 具备经真机验证的局部坐标测量、ResizeObserver / selectionchange 监听、流式 SSE 消费器与 Tab/Alt 按键拦截
|
|
6490
|
+
*/
|
|
6491
|
+
const h = react.default.createElement;
|
|
6492
|
+
const ENDPOINT = CODEX_UI_API_ENDPOINTS.composerPredictionStream;
|
|
6493
|
+
/** Wait for the settled UI before asking, so a fresh turn is fully committed. */
|
|
6494
|
+
const SETTLE_MS = 600;
|
|
6495
|
+
/** Wait for a typing pause before asking for a continuation. */
|
|
6496
|
+
const TYPE_PAUSE_MS = 500;
|
|
6497
|
+
/** A continuation needs enough text to continue from. */
|
|
6498
|
+
const CONTINUE_MIN_CHARS = 3;
|
|
6499
|
+
/** Ignore the first characters of a streaming answer to avoid flicker. */
|
|
6500
|
+
const STREAM_MIN_CHARS = 3;
|
|
6501
|
+
/** Editor text insets from the resident composer styles. */
|
|
6502
|
+
const EDITOR_INSET_TOP = 4;
|
|
6503
|
+
const EDITOR_INSET_LEFT = 14;
|
|
6504
|
+
const EDITOR_INSET_RIGHT = 8;
|
|
6505
|
+
/** The editable scroll container's right margin, outside the text column. */
|
|
6506
|
+
const EDITOR_SCROLL_MARGIN = 4;
|
|
6507
|
+
const FALLBACK_LINE_HEIGHT = 24;
|
|
6508
|
+
const NO_GHOST = {
|
|
6509
|
+
mode: "next",
|
|
6510
|
+
items: [],
|
|
6511
|
+
index: 0,
|
|
6512
|
+
stream: "",
|
|
6513
|
+
active: false
|
|
6514
|
+
};
|
|
6515
|
+
const NEXT_GHOST_STYLE = {
|
|
6516
|
+
position: "absolute",
|
|
6517
|
+
display: "flex",
|
|
6518
|
+
alignItems: "center",
|
|
6519
|
+
gap: "8px",
|
|
6520
|
+
boxSizing: "border-box",
|
|
6521
|
+
fontFamily: "inherit",
|
|
6522
|
+
fontSize: "inherit",
|
|
6523
|
+
lineHeight: "inherit",
|
|
6524
|
+
color: "var(--dsw-alias-label-caption)",
|
|
6525
|
+
background: "var(--dsw-specific-input-major)",
|
|
6526
|
+
overflow: "hidden",
|
|
6527
|
+
whiteSpace: "nowrap",
|
|
6528
|
+
pointerEvents: "none",
|
|
6529
|
+
userSelect: "none",
|
|
6530
|
+
zIndex: 2
|
|
6531
|
+
};
|
|
6532
|
+
/** The continuation ghost hugs its text and sits where the caret is. */
|
|
6533
|
+
const CONTINUE_GHOST_STYLE = {
|
|
6534
|
+
...NEXT_GHOST_STYLE,
|
|
6535
|
+
gap: "6px",
|
|
6536
|
+
padding: "0 4px",
|
|
6537
|
+
borderRadius: "4px",
|
|
6538
|
+
zIndex: 3
|
|
6539
|
+
};
|
|
6540
|
+
const TEXT_STYLE = {
|
|
6541
|
+
flex: "1 1 auto",
|
|
6542
|
+
minWidth: 0,
|
|
6543
|
+
overflow: "hidden",
|
|
6544
|
+
textOverflow: "ellipsis",
|
|
6545
|
+
whiteSpace: "nowrap",
|
|
6546
|
+
opacity: .9
|
|
6547
|
+
};
|
|
6548
|
+
const CONTINUE_TEXT_STYLE = {
|
|
6549
|
+
...TEXT_STYLE,
|
|
6550
|
+
flex: "0 1 auto"
|
|
6551
|
+
};
|
|
6552
|
+
const KEYCAP_STYLE = {
|
|
6553
|
+
flex: "none",
|
|
6554
|
+
fontSize: "11px",
|
|
6555
|
+
lineHeight: "16px",
|
|
6556
|
+
padding: "0 5px",
|
|
6557
|
+
borderRadius: "4px",
|
|
6558
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
6559
|
+
color: "var(--dsw-alias-label-tertiary)",
|
|
6560
|
+
background: "transparent"
|
|
6561
|
+
};
|
|
6562
|
+
const BADGE_STYLE = {
|
|
6563
|
+
flex: "none",
|
|
6564
|
+
fontSize: "10px",
|
|
6565
|
+
lineHeight: "14px",
|
|
6566
|
+
color: "var(--dsw-alias-label-tertiary)",
|
|
6567
|
+
opacity: .8
|
|
6568
|
+
};
|
|
6569
|
+
/**
|
|
6570
|
+
* Locate the composer card this overlay actually belongs to.
|
|
6571
|
+
*
|
|
6572
|
+
* The seat is rendered inside the resident composer card, so the anchor node
|
|
6573
|
+
* is an ancestor-scoped key: a global `querySelector` would pick whichever
|
|
6574
|
+
* card happens to be first in the document and paint that conversation's
|
|
6575
|
+
* ghost over another one.
|
|
6576
|
+
*/
|
|
6577
|
+
function composerElementsNear(anchor) {
|
|
6578
|
+
if (typeof document === "undefined") return null;
|
|
6579
|
+
if (anchor === null || anchor === void 0 || !anchor.isConnected) return null;
|
|
6580
|
+
const card = anchor.closest("[data-composer-card]");
|
|
6581
|
+
if (card === null) return null;
|
|
6582
|
+
const editor = card.querySelector("[contenteditable=\"true\"]") || card.querySelector("[role=\"textbox\"]");
|
|
6583
|
+
return editor === null ? null : {
|
|
6584
|
+
card,
|
|
6585
|
+
editor
|
|
6586
|
+
};
|
|
6587
|
+
}
|
|
6588
|
+
/** The collapsed selection inside the editor, when it is there at all. */
|
|
6589
|
+
function readCaret(editor) {
|
|
6590
|
+
if (typeof window === "undefined" || typeof document === "undefined") return null;
|
|
6591
|
+
const selection = window.getSelection();
|
|
6592
|
+
if (selection === null || selection.rangeCount === 0) return null;
|
|
6593
|
+
const range = selection.getRangeAt(0);
|
|
6594
|
+
if (range === null || !range.collapsed) return null;
|
|
6595
|
+
if (!editor.contains(range.startContainer)) return null;
|
|
6596
|
+
const prefixRange = document.createRange();
|
|
6597
|
+
prefixRange.selectNodeContents(editor);
|
|
6598
|
+
prefixRange.setEnd(range.startContainer, range.startOffset);
|
|
6599
|
+
const prefix = prefixRange.toString();
|
|
6600
|
+
const rect = caretRect(range);
|
|
6601
|
+
if (rect === null) return null;
|
|
6602
|
+
return {
|
|
6603
|
+
prefix,
|
|
6604
|
+
left: rect.left,
|
|
6605
|
+
top: rect.top,
|
|
6606
|
+
height: rect.height
|
|
6607
|
+
};
|
|
6608
|
+
}
|
|
6609
|
+
function caretRect(range) {
|
|
6610
|
+
let rect = range.getBoundingClientRect();
|
|
6611
|
+
if (rect.width === 0 && rect.height === 0) {
|
|
6612
|
+
const rects = range.getClientRects();
|
|
6613
|
+
if (rects.length > 0) rect = rects[0];
|
|
6614
|
+
}
|
|
6615
|
+
if (rect.width === 0 && rect.height === 0 || rect.top === 0 && rect.left === 0) {
|
|
6616
|
+
const fallback = rectBeforeCaret(range);
|
|
6617
|
+
if (fallback !== null) return fallback;
|
|
6618
|
+
}
|
|
6619
|
+
if (rect.width === 0 && rect.height === 0) return null;
|
|
6620
|
+
return {
|
|
6621
|
+
left: rect.left,
|
|
6622
|
+
top: rect.top,
|
|
6623
|
+
height: rect.height
|
|
6624
|
+
};
|
|
6625
|
+
}
|
|
6626
|
+
/** Measure the character before the caret when the collapsed range is empty. */
|
|
6627
|
+
function rectBeforeCaret(range) {
|
|
6628
|
+
const node = range.startContainer;
|
|
6629
|
+
const offset = range.startOffset;
|
|
6630
|
+
if (typeof Node === "undefined" || node === null || node.nodeType !== Node.TEXT_NODE || offset <= 0) return null;
|
|
6631
|
+
const probe = document.createRange();
|
|
6632
|
+
probe.setStart(node, offset - 1);
|
|
6633
|
+
probe.setEnd(node, offset);
|
|
6634
|
+
const rect = probe.getBoundingClientRect();
|
|
6635
|
+
if (rect.width === 0 && rect.height === 0) return null;
|
|
6636
|
+
return {
|
|
6637
|
+
left: rect.right,
|
|
6638
|
+
top: rect.top,
|
|
6639
|
+
height: rect.height
|
|
6640
|
+
};
|
|
6641
|
+
}
|
|
6642
|
+
/** Whether the caret is at the effective end of the draft. */
|
|
6643
|
+
function caretAtEnd(editor, draft) {
|
|
6644
|
+
const caret = readCaret(editor);
|
|
6645
|
+
if (caret === null) return null;
|
|
6646
|
+
const draftText = collapse(draft.trimEnd());
|
|
6647
|
+
const prefix = collapse(caret.prefix.trimEnd());
|
|
6648
|
+
if (prefix === "") return null;
|
|
6649
|
+
return draftText === prefix ? caret : null;
|
|
6650
|
+
}
|
|
6651
|
+
function collapse(text) {
|
|
6652
|
+
return text.replace(/\s+/gu, " ").trim();
|
|
6653
|
+
}
|
|
6654
|
+
/** A half-typed `/command` or `@reference` is not a message continuation. */
|
|
6655
|
+
function isTriggerToken(draft) {
|
|
6656
|
+
return /(?:^|\s)\/[^\s]*$/u.test(draft) || /(?:^|\s)@"?[^\s]*$/u.test(draft);
|
|
6657
|
+
}
|
|
6658
|
+
/** Show the model's first line while it is still streaming. */
|
|
6659
|
+
function streamingCandidate(stream) {
|
|
6660
|
+
if (stream.trim().length < STREAM_MIN_CHARS) return "";
|
|
6661
|
+
for (const raw of stream.split(/\r?\n/u)) {
|
|
6662
|
+
let line = raw.trim();
|
|
6663
|
+
if (line === "") continue;
|
|
6664
|
+
if (/^none$/iu.test(line)) return "";
|
|
6665
|
+
line = cleanLine(line);
|
|
6666
|
+
if (line === "") continue;
|
|
6667
|
+
return line.length > 240 ? line.slice(0, 240) : line;
|
|
6668
|
+
}
|
|
6669
|
+
return "";
|
|
6670
|
+
}
|
|
6671
|
+
function cleanLine(line) {
|
|
6672
|
+
return line.replace(/^(?:[-*•]|\d+[.)])\s+/u, "").replace(/^["'`\u201c\u201d]+|["'`\u201c\u201d]+$/gu, "").replace(/\s+/gu, " ").trim();
|
|
6673
|
+
}
|
|
6674
|
+
/**
|
|
6675
|
+
* Join a continuation onto the draft without gluing words together.
|
|
6676
|
+
* Avoid repeating a separator already present in the exact draft.
|
|
6677
|
+
*/
|
|
6678
|
+
function joinContinuation(draft, value) {
|
|
6679
|
+
if (draft === "" || value === "") return value;
|
|
6680
|
+
if (/\s$/u.test(draft)) return value.replace(/^\s+/u, "");
|
|
6681
|
+
if (/^\s/u.test(value)) return value;
|
|
6682
|
+
const last = draft.slice(-1);
|
|
6683
|
+
const first = value.slice(0, 1);
|
|
6684
|
+
if (isCjk(last) || isCjk(first)) return value;
|
|
6685
|
+
if (/[([{/\-—"'`]$/u.test(last)) return value;
|
|
6686
|
+
if (/^[,.;:!?)\]}%]/u.test(first)) return value;
|
|
6687
|
+
return ` ${value}`;
|
|
6688
|
+
}
|
|
6689
|
+
function isCjk(character) {
|
|
6690
|
+
return /[\u3040-\u30ff\u3400-\u9fff\uac00-\ud7af]/u.test(character);
|
|
6691
|
+
}
|
|
6692
|
+
function sameBox(left, right) {
|
|
6693
|
+
return left !== null && left !== void 0 && left.top === right.top && left.left === right.left && left.height === right.height && left.right === right.right && left.maxWidth === right.maxWidth;
|
|
6694
|
+
}
|
|
6695
|
+
/** Parse a fully buffered SSE body, for shells that cannot stream fetch bodies. */
|
|
6696
|
+
function parseSseText(text) {
|
|
6697
|
+
const events = [];
|
|
6698
|
+
for (const frame of text.split("\n\n")) for (const line of frame.split("\n")) {
|
|
6699
|
+
if (!line.startsWith("data:")) continue;
|
|
6700
|
+
const payload = line.slice(5).trim();
|
|
6701
|
+
if (payload === "") continue;
|
|
6702
|
+
try {
|
|
6703
|
+
events.push(JSON.parse(payload));
|
|
6704
|
+
} catch {}
|
|
6705
|
+
}
|
|
6706
|
+
return events;
|
|
6707
|
+
}
|
|
6708
|
+
/** Read one SSE body and hand every `data:` payload to the callback. */
|
|
6709
|
+
async function consumeStream(body, signal, onEvent) {
|
|
6710
|
+
const reader = body.getReader();
|
|
6711
|
+
const decoder = new TextDecoder();
|
|
6712
|
+
let buffer = "";
|
|
6713
|
+
let terminal = false;
|
|
6714
|
+
try {
|
|
6715
|
+
for (;;) {
|
|
6716
|
+
const { done, value } = await reader.read();
|
|
6717
|
+
if (done) break;
|
|
6718
|
+
if (signal.aborted) break;
|
|
6719
|
+
buffer += decoder.decode(value, { stream: true });
|
|
6720
|
+
let boundary = buffer.indexOf("\n\n");
|
|
6721
|
+
while (boundary >= 0) {
|
|
6722
|
+
const frame = buffer.slice(0, boundary);
|
|
6723
|
+
buffer = buffer.slice(boundary + 2);
|
|
6724
|
+
for (const line of frame.split("\n")) {
|
|
6725
|
+
if (!line.startsWith("data:")) continue;
|
|
6726
|
+
const payload = line.slice(5).trim();
|
|
6727
|
+
if (payload === "") continue;
|
|
6728
|
+
try {
|
|
6729
|
+
const event = JSON.parse(payload);
|
|
6730
|
+
if (event.type === "done" || event.type === "error") terminal = true;
|
|
6731
|
+
onEvent(event);
|
|
6732
|
+
} catch {}
|
|
6733
|
+
}
|
|
6734
|
+
boundary = buffer.indexOf("\n\n");
|
|
6735
|
+
}
|
|
6736
|
+
}
|
|
6737
|
+
return terminal;
|
|
6738
|
+
} finally {
|
|
6739
|
+
if (signal.aborted) try {
|
|
6740
|
+
await reader.cancel();
|
|
6741
|
+
} catch {}
|
|
6742
|
+
reader.releaseLock();
|
|
6743
|
+
}
|
|
6744
|
+
}
|
|
6745
|
+
function ComposerPredictionOverlay(props) {
|
|
6746
|
+
const { sessionId, useSession, useInput, inputActions, enabled = true, t } = props;
|
|
6747
|
+
const predictionsEnabled = enabled !== false;
|
|
6748
|
+
const draft = useInput ? useInput((state) => state === void 0 ? "" : state.draft || "") : "";
|
|
6749
|
+
const running = useSession ? useSession((state) => state?.running === true) : false;
|
|
6750
|
+
const [ghost, setGhost] = react.default.useState(NO_GHOST);
|
|
6751
|
+
const [box, setBox] = react.default.useState(null);
|
|
6752
|
+
const [compositionEnd, setCompositionEnd] = react.default.useState(0);
|
|
6753
|
+
const anchorRef = react.default.useRef(null);
|
|
6754
|
+
const elements = () => composerElementsNear(anchorRef.current);
|
|
6755
|
+
const abortRef = react.default.useRef(null);
|
|
6756
|
+
const composingRef = react.default.useRef(false);
|
|
6757
|
+
const dismissedRef = react.default.useRef(null);
|
|
6758
|
+
const acceptRef = react.default.useRef(null);
|
|
6759
|
+
const cycleRef = react.default.useRef(null);
|
|
6760
|
+
const currentRef = react.default.useRef("");
|
|
6761
|
+
const request = react.default.useCallback(async (mode, draftText) => {
|
|
6762
|
+
if (sessionId === void 0 || sessionId === null) return;
|
|
6763
|
+
if (typeof document !== "undefined" && document.hidden) return;
|
|
6764
|
+
abortRef.current?.abort();
|
|
6765
|
+
const controller = new AbortController();
|
|
6766
|
+
abortRef.current = controller;
|
|
6767
|
+
setGhost({
|
|
6768
|
+
mode,
|
|
6769
|
+
items: [],
|
|
6770
|
+
index: 0,
|
|
6771
|
+
stream: "",
|
|
6772
|
+
active: true
|
|
6773
|
+
});
|
|
6774
|
+
const settle = (items) => {
|
|
6775
|
+
if (controller.signal.aborted) return;
|
|
6776
|
+
setGhost((previous) => {
|
|
6777
|
+
if (previous.mode !== mode) return previous;
|
|
6778
|
+
if (items.length === 0) return NO_GHOST;
|
|
6779
|
+
return {
|
|
6780
|
+
mode,
|
|
6781
|
+
items,
|
|
6782
|
+
index: 0,
|
|
6783
|
+
stream: "",
|
|
6784
|
+
active: false
|
|
6785
|
+
};
|
|
6786
|
+
});
|
|
6787
|
+
};
|
|
6788
|
+
try {
|
|
6789
|
+
const response = await fetch(ENDPOINT, {
|
|
6790
|
+
method: "POST",
|
|
6791
|
+
headers: {
|
|
6792
|
+
"content-type": "application/json",
|
|
6793
|
+
accept: "text/event-stream"
|
|
6794
|
+
},
|
|
6795
|
+
body: JSON.stringify({
|
|
6796
|
+
sessionId,
|
|
6797
|
+
mode,
|
|
6798
|
+
draft: draftText
|
|
6799
|
+
}),
|
|
6800
|
+
signal: controller.signal
|
|
6801
|
+
});
|
|
6802
|
+
if (!response.ok || controller.signal.aborted) {
|
|
6803
|
+
settle([]);
|
|
6804
|
+
return;
|
|
6805
|
+
}
|
|
6806
|
+
if (!(response.headers.get("content-type") || "").includes("text/event-stream")) {
|
|
6807
|
+
const payload = await response.json().catch(() => null);
|
|
6808
|
+
settle(Array.isArray(payload?.suggestions) ? payload.suggestions.filter((item) => typeof item === "string" && item !== "") : typeof payload?.suggestion === "string" && payload.suggestion !== "" ? [payload.suggestion] : []);
|
|
6809
|
+
return;
|
|
6810
|
+
}
|
|
6811
|
+
if (response.body === null) {
|
|
6812
|
+
const done = parseSseText(await response.text().catch(() => "")).find((event) => event.type === "done");
|
|
6813
|
+
settle(Array.isArray(done?.items) ? done.items.filter((item) => typeof item === "string" && item !== "") : []);
|
|
6814
|
+
return;
|
|
6815
|
+
}
|
|
6816
|
+
if (!await consumeStream(response.body, controller.signal, (event) => {
|
|
6817
|
+
if (controller.signal.aborted) return;
|
|
6818
|
+
if (event.type === "delta" && typeof event.text === "string") setGhost((previous) => previous.active && previous.mode === mode ? {
|
|
6819
|
+
...previous,
|
|
6820
|
+
stream: previous.stream + event.text
|
|
6821
|
+
} : previous);
|
|
6822
|
+
else if (event.type === "done") {
|
|
6823
|
+
const items = Array.isArray(event.items) ? event.items.filter((item) => typeof item === "string" && item !== "") : [];
|
|
6824
|
+
settle(items);
|
|
6825
|
+
} else if (event.type === "error") settle([]);
|
|
6826
|
+
})) settle([]);
|
|
6827
|
+
} catch {
|
|
6828
|
+
if (!controller.signal.aborted) settle([]);
|
|
6829
|
+
}
|
|
6830
|
+
}, [sessionId]);
|
|
6831
|
+
react.default.useEffect(() => {
|
|
6832
|
+
if (predictionsEnabled) return;
|
|
6833
|
+
abortRef.current?.abort();
|
|
6834
|
+
setGhost(NO_GHOST);
|
|
6835
|
+
setBox(null);
|
|
6836
|
+
}, [predictionsEnabled]);
|
|
6837
|
+
react.default.useEffect(() => {
|
|
6838
|
+
const onCompositionStart = () => {
|
|
6839
|
+
composingRef.current = true;
|
|
6840
|
+
abortRef.current?.abort();
|
|
6841
|
+
setGhost(NO_GHOST);
|
|
6842
|
+
setBox(null);
|
|
6843
|
+
};
|
|
6844
|
+
const onCompositionEnd = () => {
|
|
6845
|
+
composingRef.current = false;
|
|
6846
|
+
setCompositionEnd((value) => value + 1);
|
|
6847
|
+
};
|
|
6848
|
+
document.addEventListener("compositionstart", onCompositionStart, true);
|
|
6849
|
+
document.addEventListener("compositionend", onCompositionEnd, true);
|
|
6850
|
+
return () => {
|
|
6851
|
+
document.removeEventListener("compositionstart", onCompositionStart, true);
|
|
6852
|
+
document.removeEventListener("compositionend", onCompositionEnd, true);
|
|
6853
|
+
};
|
|
6854
|
+
}, []);
|
|
6855
|
+
react.default.useEffect(() => {
|
|
6856
|
+
dismissedRef.current = null;
|
|
6857
|
+
abortRef.current?.abort();
|
|
6858
|
+
setGhost(NO_GHOST);
|
|
6859
|
+
setBox(null);
|
|
6860
|
+
return () => abortRef.current?.abort();
|
|
6861
|
+
}, [sessionId]);
|
|
6862
|
+
react.default.useEffect(() => {
|
|
6863
|
+
abortRef.current?.abort();
|
|
6864
|
+
setGhost(NO_GHOST);
|
|
6865
|
+
if (dismissedRef.current !== null && dismissedRef.current.draft !== draft) dismissedRef.current = null;
|
|
6866
|
+
}, [draft]);
|
|
6867
|
+
react.default.useEffect(() => {
|
|
6868
|
+
if (!running) return;
|
|
6869
|
+
abortRef.current?.abort();
|
|
6870
|
+
setGhost(NO_GHOST);
|
|
6871
|
+
dismissedRef.current = null;
|
|
6872
|
+
}, [running]);
|
|
6873
|
+
react.default.useEffect(() => {
|
|
6874
|
+
if (sessionId === void 0 || sessionId === null) return void 0;
|
|
6875
|
+
if (!predictionsEnabled || running || draft !== "") return void 0;
|
|
6876
|
+
if (dismissedRef.current !== null && dismissedRef.current.draft === draft) return void 0;
|
|
6877
|
+
const timer = setTimeout(() => {
|
|
6878
|
+
if (composingRef.current) return;
|
|
6879
|
+
request("next", "");
|
|
6880
|
+
}, SETTLE_MS);
|
|
6881
|
+
return () => clearTimeout(timer);
|
|
6882
|
+
}, [
|
|
6883
|
+
sessionId,
|
|
6884
|
+
running,
|
|
6885
|
+
draft,
|
|
6886
|
+
request,
|
|
6887
|
+
predictionsEnabled,
|
|
6888
|
+
compositionEnd
|
|
6889
|
+
]);
|
|
6890
|
+
react.default.useEffect(() => {
|
|
6891
|
+
if (sessionId === void 0 || sessionId === null) return void 0;
|
|
6892
|
+
if (!predictionsEnabled || draft.trim() === "" || draft.length < CONTINUE_MIN_CHARS) return void 0;
|
|
6893
|
+
if (isTriggerToken(draft)) return void 0;
|
|
6894
|
+
if (dismissedRef.current !== null && dismissedRef.current.draft === draft) return void 0;
|
|
6895
|
+
const timer = setTimeout(() => {
|
|
6896
|
+
if (composingRef.current) return;
|
|
6897
|
+
const found = elements();
|
|
6898
|
+
if (found === null) return;
|
|
6899
|
+
if (caretAtEnd(found.editor, draft) === null) return;
|
|
6900
|
+
request("continue", draft.slice(-4e3));
|
|
6901
|
+
}, TYPE_PAUSE_MS);
|
|
6902
|
+
return () => clearTimeout(timer);
|
|
6903
|
+
}, [
|
|
6904
|
+
sessionId,
|
|
6905
|
+
draft,
|
|
6906
|
+
request,
|
|
6907
|
+
predictionsEnabled,
|
|
6908
|
+
compositionEnd
|
|
6909
|
+
]);
|
|
6910
|
+
react.default.useEffect(() => {
|
|
6911
|
+
const onVisibility = () => {
|
|
6912
|
+
if (!predictionsEnabled || document.hidden) return;
|
|
6913
|
+
if (draft !== "" || running) return;
|
|
6914
|
+
if (currentRef.current !== "" || dismissedRef.current !== null) return;
|
|
6915
|
+
if (sessionId === void 0 || sessionId === null) return;
|
|
6916
|
+
request("next", "");
|
|
6917
|
+
};
|
|
6918
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
6919
|
+
return () => document.removeEventListener("visibilitychange", onVisibility);
|
|
6920
|
+
}, [
|
|
6921
|
+
draft,
|
|
6922
|
+
running,
|
|
6923
|
+
sessionId,
|
|
6924
|
+
request,
|
|
6925
|
+
predictionsEnabled
|
|
6926
|
+
]);
|
|
6927
|
+
const rawCandidate = ghost.items.length > 0 ? ghost.items[Math.min(ghost.index, ghost.items.length - 1)] ?? "" : streamingCandidate(ghost.stream);
|
|
6928
|
+
const current = ghost.mode === "continue" ? joinContinuation(draft, rawCandidate) : rawCandidate;
|
|
6929
|
+
currentRef.current = current;
|
|
6930
|
+
const hasCandidate = current !== "";
|
|
6931
|
+
const visible = predictionsEnabled && current !== "" && box !== null && (ghost.mode === "next" ? draft === "" && !running : draft.trim() !== "" && !isTriggerToken(draft));
|
|
6932
|
+
react.default.useLayoutEffect(() => {
|
|
6933
|
+
if (ghost.mode !== "next") return void 0;
|
|
6934
|
+
const measure = () => {
|
|
6935
|
+
const found = elements();
|
|
6936
|
+
if (found === null) {
|
|
6937
|
+
setBox((previous) => previous === null ? previous : null);
|
|
6938
|
+
return;
|
|
6939
|
+
}
|
|
6940
|
+
const cardRect = found.card.getBoundingClientRect();
|
|
6941
|
+
const editorRect = found.editor.getBoundingClientRect();
|
|
6942
|
+
if (editorRect.width <= 0 || editorRect.height <= 0) {
|
|
6943
|
+
setBox((previous) => previous === null ? previous : null);
|
|
6944
|
+
return;
|
|
6945
|
+
}
|
|
6946
|
+
const computed = window.getComputedStyle(found.editor);
|
|
6947
|
+
const lineHeight = Number.parseFloat(computed.lineHeight);
|
|
6948
|
+
const paddingTop = Number.parseFloat(computed.paddingTop);
|
|
6949
|
+
const paddingLeft = Number.parseFloat(computed.paddingLeft);
|
|
6950
|
+
const topInset = Number.isFinite(paddingTop) ? paddingTop : EDITOR_INSET_TOP;
|
|
6951
|
+
const leftInset = Number.isFinite(paddingLeft) ? paddingLeft : EDITOR_INSET_LEFT;
|
|
6952
|
+
const next = {
|
|
6953
|
+
top: Math.max(0, Math.round(editorRect.top - cardRect.top + topInset)),
|
|
6954
|
+
left: Math.max(0, Math.round(editorRect.left - cardRect.left + leftInset)),
|
|
6955
|
+
right: Math.max(EDITOR_INSET_RIGHT, Math.round(cardRect.right - editorRect.right + EDITOR_SCROLL_MARGIN)),
|
|
6956
|
+
height: Number.isFinite(lineHeight) && lineHeight > 0 ? Math.round(lineHeight) : FALLBACK_LINE_HEIGHT
|
|
6957
|
+
};
|
|
6958
|
+
setBox((previous) => sameBox(previous, next) ? previous : next);
|
|
6959
|
+
};
|
|
6960
|
+
measure();
|
|
6961
|
+
const found = elements();
|
|
6962
|
+
let observer;
|
|
6963
|
+
if (found !== null && typeof ResizeObserver === "function") {
|
|
6964
|
+
observer = new ResizeObserver(measure);
|
|
6965
|
+
observer.observe(found.card);
|
|
6966
|
+
observer.observe(found.editor);
|
|
6967
|
+
}
|
|
6968
|
+
window.addEventListener("resize", measure);
|
|
6969
|
+
return () => {
|
|
6970
|
+
observer?.disconnect();
|
|
6971
|
+
window.removeEventListener("resize", measure);
|
|
6972
|
+
};
|
|
6973
|
+
}, [
|
|
6974
|
+
ghost.mode,
|
|
6975
|
+
draft,
|
|
6976
|
+
sessionId,
|
|
6977
|
+
running,
|
|
6978
|
+
hasCandidate
|
|
6979
|
+
]);
|
|
6980
|
+
react.default.useLayoutEffect(() => {
|
|
6981
|
+
if (ghost.mode !== "continue") return void 0;
|
|
6982
|
+
let frame = 0;
|
|
6983
|
+
const measure = () => {
|
|
6984
|
+
frame = 0;
|
|
6985
|
+
const found = elements();
|
|
6986
|
+
if (found === null) {
|
|
6987
|
+
setBox((previous) => previous === null ? previous : null);
|
|
6988
|
+
return;
|
|
6989
|
+
}
|
|
6990
|
+
const caret = caretAtEnd(found.editor, draft);
|
|
6991
|
+
if (caret === null) {
|
|
6992
|
+
setBox((previous) => previous === null ? previous : null);
|
|
6993
|
+
return;
|
|
6994
|
+
}
|
|
6995
|
+
const editorRect = found.editor.getBoundingClientRect();
|
|
6996
|
+
if (editorRect.width <= 0 || editorRect.height <= 0) {
|
|
6997
|
+
setBox((previous) => previous === null ? previous : null);
|
|
6998
|
+
return;
|
|
6999
|
+
}
|
|
7000
|
+
const cardRect = found.card.getBoundingClientRect();
|
|
7001
|
+
const computed = window.getComputedStyle(found.editor);
|
|
7002
|
+
const lineHeight = Number.parseFloat(computed.lineHeight);
|
|
7003
|
+
const height = Number.isFinite(caret.height) && caret.height > 0 ? Math.round(caret.height) : Number.isFinite(lineHeight) && lineHeight > 0 ? Math.round(lineHeight) : FALLBACK_LINE_HEIGHT;
|
|
7004
|
+
const desired = caret.left - cardRect.left;
|
|
7005
|
+
const left = Math.max(0, desired);
|
|
7006
|
+
const maxWidth = cardRect.right - (cardRect.left + left) - 16;
|
|
7007
|
+
if (maxWidth < 48) {
|
|
7008
|
+
setBox((previous) => previous === null ? previous : null);
|
|
7009
|
+
return;
|
|
7010
|
+
}
|
|
7011
|
+
const top = caret.top - cardRect.top;
|
|
7012
|
+
if (top < 0 || top > cardRect.height - 8) {
|
|
7013
|
+
setBox((previous) => previous === null ? previous : null);
|
|
7014
|
+
return;
|
|
7015
|
+
}
|
|
7016
|
+
const next = {
|
|
7017
|
+
top: Math.round(top),
|
|
7018
|
+
left: Math.round(left),
|
|
7019
|
+
maxWidth: Math.round(maxWidth),
|
|
7020
|
+
height
|
|
7021
|
+
};
|
|
7022
|
+
setBox((previous) => sameBox(previous, next) ? previous : next);
|
|
7023
|
+
};
|
|
7024
|
+
const schedule = () => {
|
|
7025
|
+
if (frame === 0) frame = requestAnimationFrame(measure);
|
|
7026
|
+
};
|
|
7027
|
+
measure();
|
|
7028
|
+
document.addEventListener("selectionchange", schedule);
|
|
7029
|
+
document.addEventListener("scroll", schedule, true);
|
|
7030
|
+
const found = elements();
|
|
7031
|
+
window.addEventListener("resize", schedule);
|
|
7032
|
+
let observer;
|
|
7033
|
+
if (found !== null && typeof ResizeObserver === "function") {
|
|
7034
|
+
observer = new ResizeObserver(schedule);
|
|
7035
|
+
observer.observe(found.card);
|
|
7036
|
+
observer.observe(found.editor);
|
|
7037
|
+
}
|
|
7038
|
+
return () => {
|
|
7039
|
+
if (frame !== 0) cancelAnimationFrame(frame);
|
|
7040
|
+
document.removeEventListener("selectionchange", schedule);
|
|
7041
|
+
document.removeEventListener("scroll", schedule, true);
|
|
7042
|
+
window.removeEventListener("resize", schedule);
|
|
7043
|
+
observer?.disconnect();
|
|
7044
|
+
};
|
|
7045
|
+
}, [
|
|
7046
|
+
ghost.mode,
|
|
7047
|
+
draft,
|
|
7048
|
+
sessionId,
|
|
7049
|
+
running,
|
|
7050
|
+
hasCandidate
|
|
7051
|
+
]);
|
|
7052
|
+
const accept = () => {
|
|
7053
|
+
const value = currentRef.current;
|
|
7054
|
+
if (value === "" || ghost.active) return;
|
|
7055
|
+
const expected = ghost.mode === "continue" ? draft + value : value;
|
|
7056
|
+
dismissedRef.current = { draft: expected };
|
|
7057
|
+
abortRef.current?.abort();
|
|
7058
|
+
setGhost(NO_GHOST);
|
|
7059
|
+
setBox(null);
|
|
7060
|
+
try {
|
|
7061
|
+
if (inputActions.insertText(value, inputActions.captureInsertion()) !== true) return;
|
|
7062
|
+
} catch {
|
|
7063
|
+
return;
|
|
7064
|
+
}
|
|
7065
|
+
try {
|
|
7066
|
+
const found = elements();
|
|
7067
|
+
if (found !== null && !found.card.contains(document.activeElement)) found.editor.focus();
|
|
7068
|
+
} catch {}
|
|
7069
|
+
};
|
|
7070
|
+
acceptRef.current = accept;
|
|
7071
|
+
const cycle = (delta) => {
|
|
7072
|
+
setGhost((previous) => {
|
|
7073
|
+
if (previous.items.length <= 1) return previous;
|
|
7074
|
+
const index = (previous.index + delta + previous.items.length) % previous.items.length;
|
|
7075
|
+
return {
|
|
7076
|
+
...previous,
|
|
7077
|
+
index
|
|
7078
|
+
};
|
|
7079
|
+
});
|
|
7080
|
+
};
|
|
7081
|
+
cycleRef.current = cycle;
|
|
7082
|
+
react.default.useEffect(() => {
|
|
7083
|
+
if (!visible) return void 0;
|
|
7084
|
+
const onKeyDown = (event) => {
|
|
7085
|
+
if (event.defaultPrevented) return;
|
|
7086
|
+
if (event.isComposing === true || event.keyCode === 229) return;
|
|
7087
|
+
const found = elements();
|
|
7088
|
+
if (found === null) return;
|
|
7089
|
+
const target = typeof Node !== "undefined" && event.target instanceof Node ? event.target : null;
|
|
7090
|
+
const inEditor = found.editor.contains(document.activeElement);
|
|
7091
|
+
if (!(found.card.contains(document.activeElement) || target !== null && found.card.contains(target))) return;
|
|
7092
|
+
if (event.key === "Escape") {
|
|
7093
|
+
event.preventDefault();
|
|
7094
|
+
event.stopPropagation();
|
|
7095
|
+
dismissedRef.current = { draft };
|
|
7096
|
+
abortRef.current?.abort();
|
|
7097
|
+
setGhost(NO_GHOST);
|
|
7098
|
+
setBox(null);
|
|
7099
|
+
return;
|
|
7100
|
+
}
|
|
7101
|
+
if (event.altKey && (event.key === "ArrowDown" || event.key === "ArrowUp")) {
|
|
7102
|
+
if (ghost.items.length <= 1) return;
|
|
7103
|
+
event.preventDefault();
|
|
7104
|
+
event.stopPropagation();
|
|
7105
|
+
cycleRef.current?.(event.key === "ArrowDown" ? 1 : -1);
|
|
7106
|
+
return;
|
|
7107
|
+
}
|
|
7108
|
+
if (event.key !== "Tab" || event.shiftKey || event.ctrlKey || event.altKey || event.metaKey) return;
|
|
7109
|
+
if (!inEditor || ghost.active) return;
|
|
7110
|
+
if (ghost.mode === "continue" && caretAtEnd(found.editor, draft) === null) return;
|
|
7111
|
+
event.preventDefault();
|
|
7112
|
+
event.stopPropagation();
|
|
7113
|
+
acceptRef.current?.();
|
|
7114
|
+
};
|
|
7115
|
+
document.addEventListener("keydown", onKeyDown, true);
|
|
7116
|
+
return () => document.removeEventListener("keydown", onKeyDown, true);
|
|
7117
|
+
}, [
|
|
7118
|
+
visible,
|
|
7119
|
+
draft,
|
|
7120
|
+
ghost.items.length,
|
|
7121
|
+
ghost.active,
|
|
7122
|
+
ghost.mode
|
|
7123
|
+
]);
|
|
7124
|
+
const anchor = h("span", {
|
|
7125
|
+
ref: anchorRef,
|
|
7126
|
+
"data-composer-prediction-anchor": "",
|
|
7127
|
+
"aria-hidden": "true",
|
|
7128
|
+
style: { display: "none" }
|
|
7129
|
+
});
|
|
7130
|
+
if (!visible || box === null) return anchor;
|
|
7131
|
+
const continuation = ghost.mode === "continue";
|
|
7132
|
+
const style = continuation ? CONTINUE_GHOST_STYLE : NEXT_GHOST_STYLE;
|
|
7133
|
+
const showKeycap = !ghost.active && (!continuation || (box.maxWidth ?? 0) >= 96);
|
|
7134
|
+
const showBadge = ghost.items.length > 1;
|
|
7135
|
+
return h(react.default.Fragment, null, h("span", {
|
|
7136
|
+
role: "status",
|
|
7137
|
+
"aria-live": "polite",
|
|
7138
|
+
"aria-atomic": "true",
|
|
7139
|
+
style: {
|
|
7140
|
+
position: "absolute",
|
|
7141
|
+
width: 1,
|
|
7142
|
+
height: 1,
|
|
7143
|
+
padding: 0,
|
|
7144
|
+
margin: -1,
|
|
7145
|
+
overflow: "hidden",
|
|
7146
|
+
clipPath: "inset(50%)",
|
|
7147
|
+
whiteSpace: "nowrap"
|
|
7148
|
+
}
|
|
7149
|
+
}, ghost.active ? "" : t("input.prediction.dismiss") || current), h("div", {
|
|
7150
|
+
style: {
|
|
7151
|
+
...style,
|
|
7152
|
+
...box
|
|
7153
|
+
},
|
|
7154
|
+
"aria-hidden": "true",
|
|
7155
|
+
"data-composer-prediction": ghost.mode,
|
|
7156
|
+
title: current
|
|
7157
|
+
}, h("span", { style: continuation ? CONTINUE_TEXT_STYLE : TEXT_STYLE }, current), showBadge ? h("span", {
|
|
7158
|
+
style: BADGE_STYLE,
|
|
7159
|
+
title: t("input.prediction.more")
|
|
7160
|
+
}, `${ghost.index + 1}/${ghost.items.length}`) : null, showKeycap ? h("kbd", {
|
|
7161
|
+
style: KEYCAP_STYLE,
|
|
7162
|
+
title: t("input.prediction.tab")
|
|
7163
|
+
}, "Tab") : null), anchor);
|
|
7164
|
+
}
|
|
7165
|
+
//#endregion
|
|
6419
7166
|
//#region src/client/composer/new-conversation-style.ts
|
|
6420
7167
|
/** 新建页底部输入布局;保留宿主节点、插槽与 active 会话底部信息。 */
|
|
6421
7168
|
const NEW_CONVERSATION_STYLE = `
|
|
@@ -6551,6 +7298,20 @@ html[data-dsh-glass-float] [data-shortcut-modal="settings"][data-sidebar-collaps
|
|
|
6551
7298
|
locale: NS
|
|
6552
7299
|
}, SuggestionsDock));
|
|
6553
7300
|
cleaners.push(unregisterSuggestions);
|
|
7301
|
+
function PredictionSlot(props) {
|
|
7302
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComposerPredictionOverlay, {
|
|
7303
|
+
...props,
|
|
7304
|
+
ctx,
|
|
7305
|
+
t
|
|
7306
|
+
});
|
|
7307
|
+
}
|
|
7308
|
+
const unregisterPrediction = ctx.slots.inject("conversation.input.overlay", () => ctx.slots.register({
|
|
7309
|
+
name: "conversation.input.overlay",
|
|
7310
|
+
id: "codex-ui-composer-prediction",
|
|
7311
|
+
order: 50,
|
|
7312
|
+
locale: NS
|
|
7313
|
+
}, PredictionSlot));
|
|
7314
|
+
cleaners.push(unregisterPrediction);
|
|
6554
7315
|
return () => {
|
|
6555
7316
|
for (const clean of cleaners.reverse()) try {
|
|
6556
7317
|
clean();
|
|
@@ -8262,15 +9023,17 @@ html[data-dsh-glass-float] [data-shortcut-modal="settings"][data-sidebar-collaps
|
|
|
8262
9023
|
.dcu-ws-section-action{width:22px;height:22px;border:0;border-radius:50%;background:transparent;color:inherit;font:inherit;font-size:12px;line-height:1;cursor:pointer;display:grid;place-items:center}
|
|
8263
9024
|
.dcu-ws-section-action:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.16))}
|
|
8264
9025
|
[data-sidebar-collapsed='true'] .dcu-ws-section{display:none !important}
|
|
8265
|
-
|
|
9026
|
+
/* z-index 取宿主顶级浮层的量级:分区标题 ··· 这条路径把面板挂在 body 上,宿主侧边栏/工作区树自己是
|
|
9027
|
+
更大的层级,1000 会让侧边栏的行文字压在面板上(表现为「菜单跑到侧边栏后面」)。
|
|
9028
|
+
面板本体由宿主 MenuSurface 原语渲染(表面 + material 磨砂层),这里只补壳外的几何与文字颜色,
|
|
9029
|
+
不碰填充与模糊——否则会和宿主的 material 叠加成双层,并把它的模糊打成惰性。 */
|
|
9030
|
+
.dcu-ws-section-menu{position:fixed;z-index:2147483000;min-width:144px;max-width:360px;overflow:visible;padding:4px;display:flex;flex-direction:column;gap:0;border:none;border-radius:var(--dsw-radius-lg,14px);box-shadow:var(--dsw-elevation-prominent,0 6px 20px rgba(0,0,0,.45));color:var(--dsw-alias-label-primary,#ededed);isolation:isolate}
|
|
9031
|
+
/* 滚动搬进内层:面板自身必须 overflow:visible,否则下面的 8px 透明桥会被横向裁掉 */
|
|
9032
|
+
.dcu-ws-section-menu-scroll{display:flex;flex-direction:column;gap:0;min-height:0;flex:1 1 auto;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;max-height:inherit}
|
|
8266
9033
|
/* 父菜单与二级菜单之间有一小段空隙:铺一条透明桥,指针穿过去时不会触发离开事件。 */
|
|
8267
9034
|
.dcu-ws-section-menu[data-flyout='true']::before{content:'';position:absolute;top:0;bottom:0;left:-6px;width:8px}
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
.dcu-ws-section-menu .dcu-ws-section-menu-icon:empty{display:none}
|
|
8271
|
-
.dcu-ws-section-menu .dcu-ws-section-menu-label{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
8272
|
-
.dcu-ws-section-menu button:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08))}
|
|
8273
|
-
.dcu-ws-section-menu button[aria-current='true']{color:var(--dsw-alias-state-business-primary,#4176e6)}
|
|
9035
|
+
/* 行样式一律交由宿主类名(克隆行自带),这里不再覆盖 button 的 padding / 圆角 / 字号,
|
|
9036
|
+
否则二级菜单的行与一级菜单的行会出现可见差异。 */
|
|
8274
9037
|
.dcu-ws-section[data-dcu-section-fixed='true']{cursor:default}
|
|
8275
9038
|
/* 跨分区拖拽拦截时以 CSS 隐藏宿主落点线,绝不侵入修改宿主 React 的 DOM className;移回合法区自然恢复 */
|
|
8276
9039
|
body[data-dcu-drag-blocked='true'] [class*="workspaceDropBefore"]::before,
|
|
@@ -8457,6 +9220,12 @@ body[data-dcu-drag-blocked='true'] [class*="dropAfter"]::after{display:none !imp
|
|
|
8457
9220
|
let unsubscribe;
|
|
8458
9221
|
const headers = /* @__PURE__ */ new Map();
|
|
8459
9222
|
let menuHost;
|
|
9223
|
+
/** 取消「分区」行上待触发的收起定时器:指针移到二级菜单上时由面板侧调用。 */
|
|
9224
|
+
let cancelAnchorLeave;
|
|
9225
|
+
/** 取消二级菜单自身待触发的收起定时器:指针移回行上时由行侧调用。 */
|
|
9226
|
+
let cancelPanelLeave;
|
|
9227
|
+
/** 「分区 ›」二级菜单当前是否展开:菜单行会被重新注入,展开态必须按这个标志落到新节点上。 */
|
|
9228
|
+
let assignExpanded = false;
|
|
8460
9229
|
/** 当前二级菜单的锚点(「分区」那一行),悬停重复触发时用来去重。 */
|
|
8461
9230
|
let assignAnchor;
|
|
8462
9231
|
const workspaces = () => {
|
|
@@ -8746,118 +9515,143 @@ body[data-dcu-drag-blocked='true'] [class*="dropAfter"]::after{display:none !imp
|
|
|
8746
9515
|
for (const header of headers.values()) header.remove();
|
|
8747
9516
|
headers.clear();
|
|
8748
9517
|
}
|
|
9518
|
+
/** 清理「内部 pointerout 截断」监听(每次开面板重新挂,closeSectionMenu 里释放)。 */
|
|
9519
|
+
let flyoutExitCleanup;
|
|
9520
|
+
/**
|
|
9521
|
+
* 截断子面板与父菜单之间「同一菜单内部」的 out 事件,避免宿主把跨 React 根的内部移动
|
|
9522
|
+
* 判成离开菜单。真正移出菜单(related 落在菜单外)的事件原样放行。
|
|
9523
|
+
*/
|
|
9524
|
+
function guardFlyoutExit(parentMenu, container) {
|
|
9525
|
+
const inside = (node, root) => node instanceof Node && root.contains(node);
|
|
9526
|
+
const handler = (event) => {
|
|
9527
|
+
const related = event.relatedTarget;
|
|
9528
|
+
if (!(related instanceof Node)) return;
|
|
9529
|
+
if (inside(related, container)) {
|
|
9530
|
+
event.stopPropagation();
|
|
9531
|
+
return;
|
|
9532
|
+
}
|
|
9533
|
+
if (inside(event.target, container) && inside(related, parentMenu)) event.stopPropagation();
|
|
9534
|
+
};
|
|
9535
|
+
parentMenu.addEventListener("pointerout", handler);
|
|
9536
|
+
parentMenu.addEventListener("mouseout", handler);
|
|
9537
|
+
return () => {
|
|
9538
|
+
parentMenu.removeEventListener("pointerout", handler);
|
|
9539
|
+
parentMenu.removeEventListener("mouseout", handler);
|
|
9540
|
+
};
|
|
9541
|
+
}
|
|
8749
9542
|
function closeSectionMenu() {
|
|
8750
|
-
|
|
9543
|
+
flyoutExitCleanup?.();
|
|
9544
|
+
flyoutExitCleanup = void 0;
|
|
9545
|
+
if (menuHost !== void 0) {
|
|
9546
|
+
(0, react_dom.unmountComponentAtNode)(menuHost);
|
|
9547
|
+
menuHost.remove();
|
|
9548
|
+
}
|
|
9549
|
+
assignExpanded = false;
|
|
9550
|
+
assignAnchor?.setAttribute("aria-expanded", "false");
|
|
9551
|
+
cancelPanelLeave = void 0;
|
|
8751
9552
|
menuHost = void 0;
|
|
8752
9553
|
assignAnchor = void 0;
|
|
8753
9554
|
}
|
|
8754
9555
|
/**
|
|
8755
|
-
*
|
|
8756
|
-
*
|
|
8757
|
-
*
|
|
9556
|
+
* 分区自己的菜单面板:直接用宿主原语渲染 —— `MenuSurface`(表面 + material 磨砂层)
|
|
9557
|
+
* 与 `MenuItemButton`(行)。既不手绘控件,也不依赖「页面上已经开着某个宿主菜单」,
|
|
9558
|
+
* 所以冷启动第一次点分区标题的 `···` 同样能弹出来。
|
|
9559
|
+
*
|
|
9560
|
+
* 嵌套在宿主行菜单里时挂进父菜单内部(outside-click 判定视为菜单内部,指针移入不会关父菜单);
|
|
9561
|
+
* 独立打开时挂到 body。
|
|
8758
9562
|
*/
|
|
8759
9563
|
function openHostPanel(anchor, items, flyoutFrom) {
|
|
8760
9564
|
closeSectionMenu();
|
|
8761
9565
|
const parentMenu = flyoutFrom?.isConnected === true ? flyoutFrom : anchor.closest("[role=\"menu\"]");
|
|
8762
|
-
|
|
8763
|
-
|
|
9566
|
+
const { MenuSurface, MenuItemButton } = _deepseek_ai_dsh_client_ui_primitives;
|
|
9567
|
+
if (MenuSurface === void 0 || MenuItemButton === void 0) return;
|
|
9568
|
+
const container = document.createElement("div");
|
|
9569
|
+
container.style.cssText = "position:fixed;left:0;top:0;width:0;height:0;visibility:hidden;z-index:2147483000;margin:0;padding:0;border:0;background:transparent;overflow:visible;inset:auto";
|
|
8764
9570
|
if (parentMenu !== null && parentMenu !== void 0) {
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
|
|
8776
|
-
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
panel.setAttribute("role", "menu");
|
|
8785
|
-
viewport = panel;
|
|
8786
|
-
}
|
|
8787
|
-
const sampleRow = parentMenu?.querySelector("[class*=\"itemWrap\"]") ?? hostMenuRowTemplate;
|
|
8788
|
-
const sampleRef = sampleRow?.querySelector("button[role=\"menuitem\"]") ?? void 0;
|
|
8789
|
-
for (const item of items) {
|
|
8790
|
-
const row = buildMenuRow(sampleRef, item.icon, item.label, "", sampleRow);
|
|
8791
|
-
if (row !== null) {
|
|
8792
|
-
row.querySelector("button")?.addEventListener("click", (event) => {
|
|
8793
|
-
event.preventDefault();
|
|
8794
|
-
event.stopPropagation();
|
|
8795
|
-
item.onSelect();
|
|
8796
|
-
});
|
|
8797
|
-
viewport.appendChild(row);
|
|
8798
|
-
} else {
|
|
8799
|
-
const button = document.createElement("button");
|
|
8800
|
-
button.type = "button";
|
|
8801
|
-
button.setAttribute("role", "menuitem");
|
|
8802
|
-
const icon = document.createElement("span");
|
|
8803
|
-
icon.className = `${MENU_CLASS}-icon`;
|
|
8804
|
-
icon.innerHTML = item.icon;
|
|
8805
|
-
const label = document.createElement("span");
|
|
8806
|
-
label.className = `${MENU_CLASS}-label`;
|
|
8807
|
-
label.textContent = item.label;
|
|
8808
|
-
button.append(icon, label);
|
|
8809
|
-
button.addEventListener("click", (event) => {
|
|
8810
|
-
event.preventDefault();
|
|
8811
|
-
event.stopPropagation();
|
|
9571
|
+
parentMenu.appendChild(container);
|
|
9572
|
+
flyoutExitCleanup?.();
|
|
9573
|
+
flyoutExitCleanup = guardFlyoutExit(parentMenu, container);
|
|
9574
|
+
} else document.body.appendChild(container);
|
|
9575
|
+
(0, react_dom.flushSync)(() => {
|
|
9576
|
+
(0, react_dom.render)((0, react.createElement)(MenuSurface, {
|
|
9577
|
+
role: "menu",
|
|
9578
|
+
"aria-label": text("sections.menu", "分区"),
|
|
9579
|
+
className: MENU_CLASS,
|
|
9580
|
+
"data-dcu-menu-surface": "true",
|
|
9581
|
+
...parentMenu === null || parentMenu === void 0 ? {} : { "data-flyout": "true" }
|
|
9582
|
+
}, (0, react.createElement)("div", { className: `${MENU_CLASS}-scroll` }, items.map((item) => (0, react.createElement)(MenuItemButton, {
|
|
9583
|
+
key: item.label,
|
|
9584
|
+
icon: (0, react.createElement)("span", {
|
|
9585
|
+
style: { display: "inline-flex" },
|
|
9586
|
+
dangerouslySetInnerHTML: { __html: item.icon }
|
|
9587
|
+
}),
|
|
9588
|
+
onSelect: () => {
|
|
9589
|
+
closeSectionMenu();
|
|
8812
9590
|
item.onSelect();
|
|
8813
|
-
}
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
9591
|
+
}
|
|
9592
|
+
}, item.label)))), container);
|
|
9593
|
+
});
|
|
9594
|
+
try {
|
|
9595
|
+
container.setAttribute("popover", "manual");
|
|
9596
|
+
container.showPopover?.();
|
|
9597
|
+
} catch {}
|
|
8817
9598
|
let leaveTimer;
|
|
8818
9599
|
const cancelLeave = () => {
|
|
8819
9600
|
if (leaveTimer === void 0) return;
|
|
8820
9601
|
window.clearTimeout(leaveTimer);
|
|
8821
9602
|
leaveTimer = void 0;
|
|
8822
9603
|
};
|
|
8823
|
-
|
|
8824
|
-
|
|
9604
|
+
cancelPanelLeave = cancelLeave;
|
|
9605
|
+
container.addEventListener("mouseenter", () => {
|
|
9606
|
+
cancelAnchorLeave?.();
|
|
9607
|
+
cancelLeave();
|
|
9608
|
+
});
|
|
9609
|
+
container.addEventListener("mouseleave", () => {
|
|
8825
9610
|
cancelLeave();
|
|
8826
9611
|
leaveTimer = window.setTimeout(() => {
|
|
8827
9612
|
leaveTimer = void 0;
|
|
8828
9613
|
closeSectionMenu();
|
|
8829
9614
|
}, 180);
|
|
8830
9615
|
});
|
|
8831
|
-
|
|
8832
|
-
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
|
|
8837
|
-
|
|
9616
|
+
container.addEventListener("pointerdown", (event) => event.stopPropagation());
|
|
9617
|
+
container.addEventListener("mousedown", (event) => event.stopPropagation());
|
|
9618
|
+
container.addEventListener("keydown", (event) => {
|
|
9619
|
+
const rows = Array.from(container.querySelectorAll("[role=\"menuitem\"]"));
|
|
9620
|
+
if (rows.length === 0) return;
|
|
9621
|
+
if (event.key === "Home" || event.key === "End") {
|
|
9622
|
+
event.preventDefault();
|
|
9623
|
+
event.stopPropagation();
|
|
9624
|
+
rows[event.key === "Home" ? 0 : rows.length - 1]?.focus();
|
|
9625
|
+
return;
|
|
9626
|
+
}
|
|
9627
|
+
if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
|
|
9628
|
+
const index = rows.indexOf(document.activeElement);
|
|
9629
|
+
if (!(event.key === "ArrowDown" ? index === rows.length - 1 : index <= 0)) return;
|
|
9630
|
+
event.preventDefault();
|
|
9631
|
+
event.stopPropagation();
|
|
9632
|
+
});
|
|
9633
|
+
menuHost = container;
|
|
9634
|
+
const surface = container.querySelector("[data-dcu-menu-surface]");
|
|
9635
|
+
if (surface !== null) {
|
|
8838
9636
|
const rect = anchor.getBoundingClientRect();
|
|
8839
|
-
const width =
|
|
8840
|
-
const height =
|
|
8841
|
-
const parentRect = parentMenu.getBoundingClientRect();
|
|
8842
|
-
let left = parentRect.right + 2;
|
|
8843
|
-
if (left + width > window.innerWidth - 10) left = Math.max(10, parentRect.left - width - 4);
|
|
9637
|
+
const width = surface.offsetWidth || 196;
|
|
9638
|
+
const height = surface.offsetHeight || 120;
|
|
8844
9639
|
const maxHeight = Math.max(140, Math.min(360, window.innerHeight - 20));
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
|
|
8849
|
-
|
|
8850
|
-
|
|
8851
|
-
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
|
|
8857
|
-
|
|
8858
|
-
panel.style.top = `${Math.max(8, Math.min(rect.bottom + 4, window.innerHeight - height - 8))}px`;
|
|
9640
|
+
surface.style.maxHeight = `${maxHeight}px`;
|
|
9641
|
+
if (parentMenu !== null && parentMenu !== void 0) {
|
|
9642
|
+
const parentRect = parentMenu.getBoundingClientRect();
|
|
9643
|
+
let left = parentRect.right + 2;
|
|
9644
|
+
if (left + width > window.innerWidth - 10) left = Math.max(10, parentRect.left - width - 4);
|
|
9645
|
+
let top = rect.top - 4;
|
|
9646
|
+
if (top + Math.min(height, maxHeight) > window.innerHeight - 10) top = Math.max(10, window.innerHeight - Math.min(height, maxHeight) - 10);
|
|
9647
|
+
surface.style.left = `${left}px`;
|
|
9648
|
+
surface.style.top = `${top}px`;
|
|
9649
|
+
} else {
|
|
9650
|
+
surface.style.left = `${Math.max(8, Math.min(rect.left + 4, window.innerWidth - width - 8))}px`;
|
|
9651
|
+
surface.style.top = `${Math.max(8, Math.min(rect.bottom + 4, window.innerHeight - height - 8))}px`;
|
|
9652
|
+
}
|
|
8859
9653
|
}
|
|
8860
|
-
|
|
9654
|
+
container.style.visibility = "visible";
|
|
8861
9655
|
}
|
|
8862
9656
|
function openSectionMenu(sectionId, anchor) {
|
|
8863
9657
|
const section = state.sections.find((item) => item.id === sectionId);
|
|
@@ -9064,18 +9858,49 @@ body[data-dcu-drag-blocked='true'] [class*="dropAfter"]::after{display:none !imp
|
|
|
9064
9858
|
document.addEventListener("drop", onWorkspaceDrop, true);
|
|
9065
9859
|
document.addEventListener("dragend", onWorkspaceDragEnd, true);
|
|
9066
9860
|
/**
|
|
9067
|
-
*
|
|
9068
|
-
*
|
|
9069
|
-
|
|
9861
|
+
* 对齐归档管理器规范:从行内操作区精准定位“···”操作菜单触发按钮。
|
|
9862
|
+
* 优先匹配 aria-haspopup="menu",排除星标按钮与新建会话按钮,避免行内按钮顺序变化时误判。
|
|
9863
|
+
*/
|
|
9864
|
+
function isStarButton(btn) {
|
|
9865
|
+
const className = btn.getAttribute("class") ?? "";
|
|
9866
|
+
if (className.includes("dsham_rowStar") || className.includes("star")) return true;
|
|
9867
|
+
if (typeof btn.closest === "function" && Boolean(btn.closest(".dsham_starSlot"))) return true;
|
|
9868
|
+
return false;
|
|
9869
|
+
}
|
|
9870
|
+
/**
|
|
9871
|
+
* 语义不匹配就返回 null(与归档管理器的 `findRowMenuButton` 一致):
|
|
9872
|
+
* 未分组伪工作区的行里 `rowActions` 只有「新建会话」,退回 `buttons[0]` 会把它当成
|
|
9873
|
+
* 菜单锚点,右键/点击时给一个不存在的菜单做注入准备。
|
|
9874
|
+
*/
|
|
9875
|
+
function findRowMenuButton(row) {
|
|
9876
|
+
const actions = row.querySelector("[class*=\"rowActions\"]");
|
|
9877
|
+
if (!actions) return null;
|
|
9878
|
+
const buttons = Array.from(actions.querySelectorAll("button"));
|
|
9879
|
+
if (buttons.length === 0) return null;
|
|
9880
|
+
return buttons.find((btn) => {
|
|
9881
|
+
if (isStarButton(btn)) return false;
|
|
9882
|
+
if (btn.getAttribute("aria-haspopup") === "menu") return true;
|
|
9883
|
+
const label = (btn.getAttribute("aria-label") ?? btn.getAttribute("title") ?? "").toLowerCase();
|
|
9884
|
+
if (/new|create|新建|add|\+|созда/.test(label)) return false;
|
|
9885
|
+
return /action|操作|действи|more|更多|选项|options|menu/.test(label);
|
|
9886
|
+
}) ?? null;
|
|
9887
|
+
}
|
|
9888
|
+
function isRowMenuButton(button, row) {
|
|
9889
|
+
if (findRowMenuButton(row) === button) return true;
|
|
9890
|
+
const label = (button.getAttribute("aria-label") ?? button.getAttribute("title") ?? "").toLowerCase();
|
|
9891
|
+
if (/new|create|新建|add|\+|созда/.test(label)) return false;
|
|
9892
|
+
return /action|操作|действи|more|更多|选项|options|menu/.test(label);
|
|
9893
|
+
}
|
|
9894
|
+
/**
|
|
9895
|
+
* 从触发目标元素反查对应的工作区行节点,严格过滤会话行与菜单内部元素。
|
|
9070
9896
|
*/
|
|
9071
9897
|
function projectRowOfMenuButton(target) {
|
|
9072
|
-
const
|
|
9073
|
-
if (button === null) return null;
|
|
9074
|
-
const row = button.closest("[data-row-key^=\"workspace:\"]");
|
|
9898
|
+
const row = target.closest("[data-row-key]");
|
|
9075
9899
|
if (row === null) return null;
|
|
9076
|
-
|
|
9077
|
-
|
|
9078
|
-
|
|
9900
|
+
if (!(row.getAttribute("data-row-key") ?? "").startsWith("workspace:")) return null;
|
|
9901
|
+
const button = target.closest("button");
|
|
9902
|
+
if (button !== null) return isRowMenuButton(button, row) ? row : null;
|
|
9903
|
+
return row;
|
|
9079
9904
|
}
|
|
9080
9905
|
/**
|
|
9081
9906
|
* 项目行 `···` 一按下就记下目标工作区。
|
|
@@ -9104,8 +9929,25 @@ body[data-dcu-drag-blocked='true'] [class*="dropAfter"]::after{display:none !imp
|
|
|
9104
9929
|
function onClickToPrepareMenu(event) {
|
|
9105
9930
|
if (event.target instanceof Element) prepareMenuInjection(event.target);
|
|
9106
9931
|
}
|
|
9932
|
+
/** 对齐归档管理器规范:支持在工作区行上右键直接唤起操作菜单与分区入口 */
|
|
9933
|
+
function onContextMenuToPrepareMenu(event) {
|
|
9934
|
+
const target = event.target;
|
|
9935
|
+
if (!target) return;
|
|
9936
|
+
if (target.closest("input, textarea, [contenteditable='true']")) return;
|
|
9937
|
+
const row = target.closest("[data-row-key^=\"workspace:\"]");
|
|
9938
|
+
if (!row) return;
|
|
9939
|
+
const clickedButton = target.closest("button");
|
|
9940
|
+
if (clickedButton && !isRowMenuButton(clickedButton, row)) return;
|
|
9941
|
+
if (!findRowMenuButton(row)) return;
|
|
9942
|
+
const id = workspaceIdOfRow(row);
|
|
9943
|
+
if (id) {
|
|
9944
|
+
assigningWorkspaceId = id;
|
|
9945
|
+
injectMenuEntry();
|
|
9946
|
+
}
|
|
9947
|
+
}
|
|
9107
9948
|
document.addEventListener("pointerdown", onPointerdownToPrepareMenu, true);
|
|
9108
9949
|
document.addEventListener("click", onClickToPrepareMenu, true);
|
|
9950
|
+
document.addEventListener("contextmenu", onContextMenuToPrepareMenu, true);
|
|
9109
9951
|
/**
|
|
9110
9952
|
* 用宿主自己的图标组件渲染出静态 SVG。
|
|
9111
9953
|
* 手绘图标在描边粗细、圆角与视觉重心上永远差一档,直接复用宿主原语才能和原生菜单项完全同源。
|
|
@@ -9210,21 +10052,8 @@ body[data-dcu-drag-blocked='true'] [class*="dropAfter"]::after{display:none !imp
|
|
|
9210
10052
|
if (template === void 0) return;
|
|
9211
10053
|
container = menu.firstElementChild ?? menu;
|
|
9212
10054
|
}
|
|
9213
|
-
if (reference !== void 0 && template === void 0) {
|
|
9214
|
-
|
|
9215
|
-
hostMenuClassName = menu.className;
|
|
9216
|
-
hostMenuShellTemplate = menu.cloneNode(false);
|
|
9217
|
-
const viewport = reference.parentElement?.parentElement;
|
|
9218
|
-
hostMenuViewportTemplate = viewport === void 0 || viewport === null ? void 0 : viewport.cloneNode(false);
|
|
9219
|
-
}
|
|
9220
|
-
if (reference !== void 0 && hostMenuRowTemplate === void 0 && !isOwnPanel(reference)) {
|
|
9221
|
-
hostMenuRowTemplate = reference.parentElement?.cloneNode(true);
|
|
9222
|
-
hostMenuSurface = menu;
|
|
9223
|
-
hostMenuClassName = menu.className;
|
|
9224
|
-
hostMenuShellTemplate = menu.cloneNode(false);
|
|
9225
|
-
const viewport = reference.parentElement?.parentElement;
|
|
9226
|
-
hostMenuViewportTemplate = viewport === void 0 || viewport === null ? void 0 : viewport.cloneNode(false);
|
|
9227
|
-
}
|
|
10055
|
+
if (reference !== void 0 && template === void 0) {}
|
|
10056
|
+
if (reference !== void 0 && hostMenuRowTemplate === void 0 && !isOwnPanel(reference)) hostMenuRowTemplate = reference.parentElement?.cloneNode(true);
|
|
9228
10057
|
const workspaceId = assigningWorkspaceId;
|
|
9229
10058
|
if (workspaceId === void 0) return;
|
|
9230
10059
|
const pinned = sectionOf(state, workspaceId) === PINNED_SECTION_ID;
|
|
@@ -9252,16 +10081,21 @@ body[data-dcu-drag-blocked='true'] [class*="dropAfter"]::after{display:none !imp
|
|
|
9252
10081
|
if (sectionRow !== null) {
|
|
9253
10082
|
const anchorButton = sectionRow.querySelector("button");
|
|
9254
10083
|
if (anchorButton !== null) {
|
|
10084
|
+
anchorButton.setAttribute("aria-haspopup", "menu");
|
|
10085
|
+
anchorButton.setAttribute("aria-expanded", assignExpanded ? "true" : "false");
|
|
9255
10086
|
let hoverTimer;
|
|
9256
10087
|
const cancelHover = () => {
|
|
9257
10088
|
if (hoverTimer === void 0) return;
|
|
9258
10089
|
window.clearTimeout(hoverTimer);
|
|
9259
10090
|
hoverTimer = void 0;
|
|
9260
10091
|
};
|
|
10092
|
+
cancelAnchorLeave = cancelHover;
|
|
9261
10093
|
anchorButton.addEventListener("mouseenter", () => {
|
|
9262
10094
|
cancelHover();
|
|
10095
|
+
cancelPanelLeave?.();
|
|
9263
10096
|
hoverTimer = window.setTimeout(() => {
|
|
9264
10097
|
hoverTimer = void 0;
|
|
10098
|
+
if (menuHost !== void 0 && !menuHost.isConnected) closeSectionMenu();
|
|
9265
10099
|
if (menuHost !== void 0 && assignAnchor === anchorButton) return;
|
|
9266
10100
|
openAssignMenu(anchorButton, menu);
|
|
9267
10101
|
}, 90);
|
|
@@ -9292,16 +10126,11 @@ body[data-dcu-drag-blocked='true'] [class*="dropAfter"]::after{display:none !imp
|
|
|
9292
10126
|
}));
|
|
9293
10127
|
}
|
|
9294
10128
|
let assigningWorkspaceId;
|
|
9295
|
-
let hostMenuSurface;
|
|
9296
10129
|
/** 宿主菜单表面与菜单行的克隆模板:分区菜单复用它们,样式才与原生一致。 */
|
|
9297
|
-
let hostMenuClassName;
|
|
9298
10130
|
let hostMenuRowTemplate;
|
|
9299
10131
|
/** 宿主菜单的外壳与内容容器:真正的底色/模糊画在 viewport 上,必须整层复用。 */
|
|
9300
|
-
let hostMenuShellTemplate;
|
|
9301
|
-
let hostMenuViewportTemplate;
|
|
9302
10132
|
let collapsed = readCollapsed();
|
|
9303
10133
|
function openAssignMenu(anchor, parentMenu) {
|
|
9304
|
-
assignAnchor = anchor;
|
|
9305
10134
|
const workspaceId = assigningWorkspaceId;
|
|
9306
10135
|
if (workspaceId === void 0) return;
|
|
9307
10136
|
const current = sectionOf(state, workspaceId);
|
|
@@ -9329,6 +10158,11 @@ body[data-dcu-drag-blocked='true'] [class*="dropAfter"]::after{display:none !imp
|
|
|
9329
10158
|
}
|
|
9330
10159
|
});
|
|
9331
10160
|
openHostPanel(anchor, items, parentMenu);
|
|
10161
|
+
if (menuHost !== void 0) {
|
|
10162
|
+
assignAnchor = anchor;
|
|
10163
|
+
assignExpanded = true;
|
|
10164
|
+
anchor.setAttribute("aria-expanded", "true");
|
|
10165
|
+
}
|
|
9332
10166
|
}
|
|
9333
10167
|
/** 新增项目进入默认分区,删除项目及时裁剪;不改变既有成员的显式归属。 */
|
|
9334
10168
|
function withHostWorkspaces(value, ids) {
|
|
@@ -9387,11 +10221,7 @@ body[data-dcu-drag-blocked='true'] [class*="dropAfter"]::after{display:none !imp
|
|
|
9387
10221
|
const reference = menu?.querySelector("button[role=\"menuitem\"]");
|
|
9388
10222
|
const wrapper = reference?.parentElement;
|
|
9389
10223
|
if (menu === void 0 || reference === void 0 || wrapper === void 0 || wrapper === null) return;
|
|
9390
|
-
menu.className;
|
|
9391
10224
|
hostMenuRowTemplate = wrapper.cloneNode(true);
|
|
9392
|
-
hostMenuShellTemplate = menu.cloneNode(false);
|
|
9393
|
-
const viewport = wrapper.parentElement;
|
|
9394
|
-
hostMenuViewportTemplate = viewport === null ? void 0 : viewport.cloneNode(false);
|
|
9395
10225
|
}
|
|
9396
10226
|
function syncNow() {
|
|
9397
10227
|
if (disposed || syncing) return;
|
|
@@ -9564,6 +10394,7 @@ body[data-dcu-drag-blocked='true'] [class*="dropAfter"]::after{display:none !imp
|
|
|
9564
10394
|
document.removeEventListener("pointerdown", onPointerdownToCloseSectionMenu, true);
|
|
9565
10395
|
document.removeEventListener("pointerdown", onPointerdownToPrepareMenu, true);
|
|
9566
10396
|
document.removeEventListener("click", onClickToPrepareMenu, true);
|
|
10397
|
+
document.removeEventListener("contextmenu", onContextMenuToPrepareMenu, true);
|
|
9567
10398
|
unsubscribe?.();
|
|
9568
10399
|
closeSectionMenu();
|
|
9569
10400
|
flushSectionsSave();
|
|
@@ -10209,6 +11040,11 @@ body[data-dcu-drag-blocked='true'] [class*="dropAfter"]::after{display:none !imp
|
|
|
10209
11040
|
ctx.effect(() => observeComposerEnhancements(ctx), "michengai-codex-ui: composer enhancements");
|
|
10210
11041
|
ctx.effect(() => observeSettingsSkin(), "michengai-codex-ui: official settings skin");
|
|
10211
11042
|
ctx.effect(() => observeSettingsNavIcon(() => t("about.nav")), "michengai-codex-ui: settings nav icon");
|
|
11043
|
+
ctx.slots.inject("settings.section.icon", () => ctx.slots.register({
|
|
11044
|
+
name: "settings.section.icon",
|
|
11045
|
+
id: "codex-ui",
|
|
11046
|
+
locale: NS
|
|
11047
|
+
}, CodexUiNavIcon));
|
|
10212
11048
|
ctx.slots.inject("settings.section", () => ctx.slots.register({
|
|
10213
11049
|
name: "settings.section",
|
|
10214
11050
|
id: "codex-ui",
|