@chatcode/cco-better-sidebar 0.18.0-alpha.4 → 0.18.0-rc.11
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/README.md +24 -5
- package/README_EN.md +24 -5
- package/cordis.patch.yml +6 -5
- package/lib/client-editor.js +10920 -363
- package/lib/client-mermaid.js +10806 -271
- package/lib/client-registry.js +3733 -2150
- package/lib/client-terminal.js +398 -257
- package/lib/client.js +3734 -2151
- package/lib/index.js +264 -46
- package/lib/types/client/LogoutConfirmDialog.d.ts +5 -0
- package/lib/types/client/PluginMarketSettingsSection.d.ts +7 -0
- package/lib/types/client/PluginMarketView.d.ts +7 -0
- package/lib/types/client/PluginProjectPicker.d.ts +13 -0
- package/lib/types/client/api.d.ts +17 -0
- package/lib/types/client/builtins/tabs.d.ts +13 -1
- package/lib/types/client/icons.d.ts +26 -8
- package/lib/types/client/locales.d.ts +39 -0
- package/lib/types/client/plugin-market-catalog.d.ts +25 -0
- package/lib/types/client/service.d.ts +1 -1
- package/lib/types/client/ui-tweaks/archive.d.ts +3 -7
- package/lib/types/client/ui-tweaks/branding.d.ts +1 -1
- package/lib/types/client/ui-tweaks/index.d.ts +3 -3
- package/lib/types/client/ui-tweaks/sidebar-header.d.ts +6 -0
- package/lib/types/client/ui-tweaks/typography.d.ts +9 -0
- package/lib/types/config.d.ts +4 -3
- package/lib/types/context-types.d.ts +12 -14
- package/lib/types/login-page-script.d.ts +2 -0
- package/lib/types/login-route.d.ts +2 -0
- package/lib/types/plugin-market-api.d.ts +5 -0
- package/lib/types/plugin-market-shared.d.ts +59 -0
- package/lib/types/prefs-shared.d.ts +1 -1
- package/lib/types/pty-deps.d.ts +1 -1
- package/lib/types/ui-tweaks/config.d.ts +6 -7
- package/lib/types/ui-tweaks/index.d.ts +2 -3
- package/package.json +2 -2
- package/src/client/AccountMenu.tsx +12 -2
- package/src/client/BrowserView.tsx +1 -1
- package/src/client/DiffTab.tsx +1 -1
- package/src/client/EditorHost.tsx +1 -1
- package/src/client/FileTree.tsx +10 -5
- package/src/client/FreeWindow.tsx +2 -1
- package/src/client/GitView.tsx +7 -3
- package/src/client/LogoutConfirmDialog.tsx +39 -0
- package/src/client/PluginMarketSettingsSection.tsx +55 -0
- package/src/client/PluginMarketView.module.css +50 -0
- package/src/client/PluginMarketView.tsx +243 -0
- package/src/client/PluginProjectPicker.tsx +73 -0
- package/src/client/SideCardSection.tsx +2 -23
- package/src/client/Sidebar.tsx +2 -2
- package/src/client/TabBar.tsx +2 -4
- package/src/client/TextEditor.tsx +2 -1
- package/src/client/TreePanel.tsx +1 -2
- package/src/client/UsageHeatmapSection.tsx +1 -1
- package/src/client/api.ts +9 -0
- package/src/client/builtins/tabs.tsx +25 -5
- package/src/client/builtins/viewers.tsx +2 -1
- package/src/client/icons.tsx +57 -4
- package/src/client/index.tsx +10 -1
- package/src/client/intercept.tsx +1 -1
- package/src/client/locales-ja.ts +39 -0
- package/src/client/locales.ts +118 -1
- package/src/client/md-toc.tsx +1 -1
- package/src/client/mermaid.tsx +2 -1
- package/src/client/open-with-settings.tsx +1 -1
- package/src/client/plugin-market-catalog.ts +90 -0
- package/src/client/service.ts +1 -1
- package/src/client/sidebar.module.css +81 -19
- package/src/client/ui-tweaks/archive.tsx +6 -56
- package/src/client/ui-tweaks/branding.tsx +36 -29
- package/src/client/ui-tweaks/index.tsx +42 -105
- package/src/client/ui-tweaks/sidebar-header.ts +73 -0
- package/src/client/ui-tweaks/typography.ts +38 -0
- package/src/config.ts +22 -2
- package/src/context-types.ts +5 -15
- package/src/index.ts +24 -20
- package/src/login-page-script.ts +107 -0
- package/src/login-route.ts +7 -4
- package/src/plugin-market-api.ts +88 -0
- package/src/plugin-market-shared.ts +30 -0
- package/src/prefs-shared.ts +1 -1
- package/src/pty-deps.ts +2 -2
- package/src/ui-tweaks/config.ts +12 -12
- package/src/ui-tweaks/index.ts +7 -13
|
@@ -11,18 +11,15 @@
|
|
|
11
11
|
* - **恢复** (Restore): remove the session from the archive set — its log and
|
|
12
12
|
* workspace slot are kept, so the conversation reappears in the normal
|
|
13
13
|
* sidebar list.
|
|
14
|
-
* -
|
|
15
|
-
* durable log, workspace accounting, archive-set entry and caches; the list
|
|
16
|
-
* then refreshes so the row (and the session itself) disappear.
|
|
17
|
-
* - **全部恢复 / 全部删除**: the same actions for every archived session.
|
|
14
|
+
* - **全部恢复**: restore every archived session.
|
|
18
15
|
*
|
|
19
16
|
* Live (open/running) sessions are refused by the server; the client maps the
|
|
20
17
|
* `session-live` error code to localized copy.
|
|
21
18
|
* @module dsh-ui-tweaks/client/archive
|
|
22
19
|
*/
|
|
23
20
|
|
|
24
|
-
import {
|
|
25
|
-
import type {
|
|
21
|
+
import { useMemo, useState, useSyncExternalStore } from 'react'
|
|
22
|
+
import type { SessionListState, SessionSummary } from '@deepseek-ai/dsh-api-session-controller/client'
|
|
26
23
|
import type { WorkspaceSnapshot } from '@deepseek-ai/dsh-api-workspace-controller/client'
|
|
27
24
|
import type { SnapshotSelectorHook } from '@deepseek-ai/dsh-client-ui-slots'
|
|
28
25
|
import type { SettingsClient } from './index.tsx'
|
|
@@ -73,12 +70,6 @@ function errorMessage(error: unknown, t: Translate): string {
|
|
|
73
70
|
return error instanceof Error ? error.message : String(error)
|
|
74
71
|
}
|
|
75
72
|
|
|
76
|
-
/** Re-pull the host session list after a permanent delete (the outward
|
|
77
|
-
* ISessions face omits refresh; the concrete runtime provides it). */
|
|
78
|
-
function refreshSessions(sessionsService: ISessions): void {
|
|
79
|
-
void (sessionsService as unknown as { refresh(): Promise<void> }).refresh()
|
|
80
|
-
}
|
|
81
|
-
|
|
82
73
|
/** Workspace display title: the path's last non-empty segment. */
|
|
83
74
|
function basenameOf(path: string | undefined): string {
|
|
84
75
|
if (path === undefined || path === '') return ''
|
|
@@ -143,35 +134,21 @@ interface ArchiveRow {
|
|
|
143
134
|
export interface ArchiveSectionProps {
|
|
144
135
|
controller: SettingsClient
|
|
145
136
|
t: Translate
|
|
146
|
-
sessionsService: ISessions
|
|
147
137
|
/** Framework standard feeds: session list + workspace archive set. */
|
|
148
138
|
useSessions: SnapshotSelectorHook<SessionListState>
|
|
149
139
|
useWorkspaces: SnapshotSelectorHook<WorkspaceSnapshot>
|
|
150
140
|
}
|
|
151
141
|
|
|
152
|
-
export function ArchiveSection({ controller, t,
|
|
142
|
+
export function ArchiveSection({ controller, t, useSessions, useWorkspaces }: ArchiveSectionProps) {
|
|
153
143
|
const settingsState = useSyncExternalStore(controller.subscribe, controller.getSnapshot, controller.getSnapshot)
|
|
154
144
|
const enabled = settingsState.value?.archiveManagerEnabled === true
|
|
155
145
|
const sessions = useSessions(state => state)
|
|
156
146
|
const workspaces = useWorkspaces(state => state)
|
|
157
|
-
const [confirmId, setConfirmId] = useState<string | null>(null)
|
|
158
|
-
const [confirmAll, setConfirmAll] = useState(false)
|
|
159
147
|
const [busy, setBusy] = useState<string | null>(null)
|
|
160
148
|
const [error, setError] = useState<string | null>(null)
|
|
161
149
|
const timeFormatter = useMemo(() => new Intl.RelativeTimeFormat(navigator.language, { numeric: 'auto' }), [])
|
|
162
150
|
const now = Date.now()
|
|
163
151
|
|
|
164
|
-
useEffect(() => {
|
|
165
|
-
if (confirmId === null) return
|
|
166
|
-
const timer = window.setTimeout(() => { setConfirmId(current => (current === confirmId ? null : current)) }, 3000)
|
|
167
|
-
return () => { window.clearTimeout(timer) }
|
|
168
|
-
}, [confirmId])
|
|
169
|
-
useEffect(() => {
|
|
170
|
-
if (!confirmAll) return
|
|
171
|
-
const timer = window.setTimeout(() => { setConfirmAll(false) }, 3000)
|
|
172
|
-
return () => { window.clearTimeout(timer) }
|
|
173
|
-
}, [confirmAll])
|
|
174
|
-
|
|
175
152
|
const rows: ArchiveRow[] = useMemo(() => {
|
|
176
153
|
const byId = sessions.byId
|
|
177
154
|
return workspaces.archivedSessionIds.map(id => ({ id, summary: byId[id] })).sort((a, b) => {
|
|
@@ -181,14 +158,14 @@ export function ArchiveSection({ controller, t, sessionsService, useSessions, us
|
|
|
181
158
|
})
|
|
182
159
|
}, [workspaces.archivedSessionIds, sessions.byId])
|
|
183
160
|
|
|
184
|
-
const run = (key: string, body: unknown
|
|
161
|
+
const run = (key: string, body: unknown): void => {
|
|
185
162
|
setBusy(key)
|
|
186
163
|
setError(null)
|
|
187
164
|
void archiveRequest<ArchiveSnapshot>({
|
|
188
165
|
method: 'POST',
|
|
189
166
|
headers: { 'Content-Type': 'application/json' },
|
|
190
167
|
body: JSON.stringify(body),
|
|
191
|
-
}).
|
|
168
|
+
}).catch((reason: unknown) => {
|
|
192
169
|
setError(errorMessage(reason, t))
|
|
193
170
|
}).finally(() => { setBusy(current => (current === key ? null : current)) })
|
|
194
171
|
}
|
|
@@ -197,28 +174,10 @@ export function ArchiveSection({ controller, t, sessionsService, useSessions, us
|
|
|
197
174
|
run(`restore:${id}`, { action: 'restore', sessionId: id })
|
|
198
175
|
}
|
|
199
176
|
|
|
200
|
-
const remove = (id: string): void => {
|
|
201
|
-
if (confirmId !== id) {
|
|
202
|
-
setConfirmId(id)
|
|
203
|
-
return
|
|
204
|
-
}
|
|
205
|
-
setConfirmId(null)
|
|
206
|
-
run(`delete:${id}`, { action: 'delete', sessionId: id }, () => { refreshSessions(sessionsService) })
|
|
207
|
-
}
|
|
208
|
-
|
|
209
177
|
const restoreAll = (): void => {
|
|
210
178
|
run('restore-all', { action: 'restore-all' })
|
|
211
179
|
}
|
|
212
180
|
|
|
213
|
-
const removeAll = (): void => {
|
|
214
|
-
if (!confirmAll) {
|
|
215
|
-
setConfirmAll(true)
|
|
216
|
-
return
|
|
217
|
-
}
|
|
218
|
-
setConfirmAll(false)
|
|
219
|
-
run('delete-all', { action: 'delete-all' }, () => { refreshSessions(sessionsService) })
|
|
220
|
-
}
|
|
221
|
-
|
|
222
181
|
if (!enabled) {
|
|
223
182
|
return (
|
|
224
183
|
<div className="dut-arc">
|
|
@@ -244,7 +203,6 @@ export function ArchiveSection({ controller, t, sessionsService, useSessions, us
|
|
|
244
203
|
{rows.length > 1 ? (
|
|
245
204
|
<>
|
|
246
205
|
<button type="button" className="dut-arc-btn" disabled={busy !== null} onClick={restoreAll}>{busy === 'restore-all' ? t('archiveRestoring') : t('archiveRestoreAll')}</button>
|
|
247
|
-
<button type="button" className={'dut-arc-btn dut-arc-del' + (confirmAll ? ' dut-arc-confirm' : '')} disabled={busy !== null} onClick={removeAll}>{busy === 'delete-all' ? t('archiveDeleteAll') + '…' : confirmAll ? t('archiveDeleteAll') + '?' : t('archiveDeleteAll')}</button>
|
|
248
206
|
</>
|
|
249
207
|
) : null}
|
|
250
208
|
</div>
|
|
@@ -263,14 +221,6 @@ export function ArchiveSection({ controller, t, sessionsService, useSessions, us
|
|
|
263
221
|
{sub !== '' ? <span className="dut-arc-sub">{sub}</span> : null}
|
|
264
222
|
</div>
|
|
265
223
|
<button type="button" className="dut-arc-btn" disabled={busy !== null} onClick={() => { restore(row.id) }}>{busy === `restore:${row.id}` ? t('archiveRestoring') : t('archiveRestore')}</button>
|
|
266
|
-
<button
|
|
267
|
-
type="button"
|
|
268
|
-
className={'dut-arc-btn dut-arc-del' + (confirmId === row.id ? ' dut-arc-confirm' : '')}
|
|
269
|
-
disabled={busy !== null}
|
|
270
|
-
onClick={() => { remove(row.id) }}
|
|
271
|
-
>
|
|
272
|
-
{busy === `delete:${row.id}` ? t('archiveDelete') + '…' : confirmId === row.id ? t('archiveDelete') + '?' : t('archiveDelete')}
|
|
273
|
-
</button>
|
|
274
224
|
</div>
|
|
275
225
|
)
|
|
276
226
|
})}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { ReactNode } from 'react'
|
|
11
|
+
import { clearSidebarHeader, SIDEBAR_HEADER_CSS, syncSidebarHeader } from './sidebar-header.ts'
|
|
11
12
|
|
|
12
13
|
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
13
14
|
interface SlotMap {
|
|
@@ -29,7 +30,9 @@ export const PROJECT_LOGO_URL = '/_dsh/ui-tweaks/assets/logo.svg'
|
|
|
29
30
|
const PROJECT_NAME = 'ChatCode CLI'
|
|
30
31
|
const HERO_TITLE = '与世界,深一度对话'
|
|
31
32
|
const LEGACY_HOST_BRAND_TEXT = /DSH\s*(?:Local\s*Build|本地构建)|DeepSeek\s*Harness|ChatCode\s*CLI/giu
|
|
32
|
-
const
|
|
33
|
+
const LEGACY_HOST_BRAND_LABEL_TEXT = /^(?:DSH\s*(?:Local\s*Build|本地构建)|ChatCode\s*CLI)$/iu
|
|
34
|
+
const BRAND_SURFACE = '[class*="brandIdentity"],[class*="brandName"],[class*="headline"],.dut-sidebar-brand-name'
|
|
35
|
+
const USER_CONTENT = 'input,textarea,[contenteditable],[role="textbox"],pre,code,script,style'
|
|
33
36
|
const HOST_BUILD_VERSION_TEXT = /^v?\d+\.\d+\.\d+(?:[-+][0-9a-z.-]+)*$/iu
|
|
34
37
|
const HERO_HEADLINE = /探索未至之境/u
|
|
35
38
|
const HERO_PREVIEW_TEXT = /^(?:预览版|Preview)$/iu
|
|
@@ -87,14 +90,11 @@ body:not([data-ds-dark-theme]) .dut-unicom-primary-action:active{transform:trans
|
|
|
87
90
|
hovered, the host owns the complete interaction treatment again. */
|
|
88
91
|
body[data-ds-dark-theme] .dut-unicom-primary-action:not(:hover){background:#9B0B09 !important}
|
|
89
92
|
.dut-project-logo{display:block;object-fit:contain}
|
|
90
|
-
.dut-left-logo{width:
|
|
91
|
-
.dut-brand-title{font-
|
|
92
|
-
.dut-sidebar-logo{width:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
44px knot is not cropped by that host-owned overflow boundary. */
|
|
96
|
-
[class*="brandIdentity"]:has(.dut-sidebar-logo){height:44px !important}
|
|
97
|
-
.dut-sidebar-brand-name{font-size:18px !important;line-height:22px !important;font-weight:600 !important;letter-spacing:0 !important;white-space:nowrap}
|
|
93
|
+
.dut-left-logo{width:24px !important;height:24px !important}
|
|
94
|
+
.dut-brand-title{font:var(--dsw-font-s-strong-14) !important}
|
|
95
|
+
.dut-sidebar-logo{width:24px !important;height:24px !important}
|
|
96
|
+
.dut-sidebar-brand-name{font:var(--dsw-font-s-strong-14) !important;letter-spacing:-.01em !important;white-space:nowrap}
|
|
97
|
+
${SIDEBAR_HEADER_CSS}
|
|
98
98
|
.dut-brand-version{display:none !important}
|
|
99
99
|
.dut-hero-preview{display:none !important}
|
|
100
100
|
.dut-hero-logo{width:60px !important;height:60px !important}
|
|
@@ -104,8 +104,12 @@ body[data-ds-dark-theme] .dut-unicom-primary-action:not(:hover){background:#9B0B
|
|
|
104
104
|
`
|
|
105
105
|
|
|
106
106
|
function hasPrimaryLabel(button: HTMLButtonElement): boolean {
|
|
107
|
+
// Plugin cards own their appearance. Inventory disclosure buttons include
|
|
108
|
+
// descriptions, where words like "install" do not identify a primary action.
|
|
109
|
+
if (button.closest('[data-chatcode-plugin-market], [data-plugin-module]')) return false
|
|
107
110
|
const label = `${button.textContent ?? ''} ${button.getAttribute('aria-label') ?? ''} ${button.title}`.trim().toLowerCase()
|
|
108
|
-
|
|
111
|
+
if (button.classList.contains('dut-sidebar-brand') || button.classList.contains('dut-sidebar-new-session')) return false
|
|
112
|
+
return /(?:^|\s)(send|install)(?:\s|$)|发送|(?:^|\s)安装(?:\s|$)/u.test(label)
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
/** Replace one host SVG while retaining its generated layout class names. */
|
|
@@ -169,17 +173,18 @@ function syncVersionNotice(): void {
|
|
|
169
173
|
dialog.setAttribute('aria-label', notice.title)
|
|
170
174
|
dialog.setAttribute(VERSION_NOTICE_MARKER, '')
|
|
171
175
|
dialog.dataset.dutVersionNoticeLanguage = language
|
|
172
|
-
if (heading !== null) heading.textContent = notice.title
|
|
176
|
+
if (heading !== null && heading.textContent !== notice.title) heading.textContent = notice.title
|
|
173
177
|
const paragraphs = dialog.querySelectorAll<HTMLParagraphElement>('p')
|
|
174
178
|
notice.paragraphs.forEach((text, index) => {
|
|
175
179
|
const paragraph = paragraphs.item(index)
|
|
176
|
-
if (paragraph !== null) paragraph.textContent = text
|
|
180
|
+
if (paragraph !== null && paragraph.textContent !== text) paragraph.textContent = text
|
|
177
181
|
})
|
|
178
182
|
})
|
|
179
183
|
}
|
|
180
184
|
|
|
181
185
|
function syncBranding(): void {
|
|
182
|
-
|
|
186
|
+
const title = document.title.replace(LEGACY_HOST_BRAND_TEXT, PROJECT_NAME)
|
|
187
|
+
if (title !== document.title) document.title = title
|
|
183
188
|
|
|
184
189
|
// The host deliberately renders the blank-session preview badge as a
|
|
185
190
|
// third headline column. ChatCode is the production identity here, so
|
|
@@ -193,25 +198,25 @@ function syncBranding(): void {
|
|
|
193
198
|
|
|
194
199
|
// The sidebar label identifies the precise icon to its left. Process it
|
|
195
200
|
// before the generic text pass so the sibling relationship is still intact.
|
|
196
|
-
document.querySelectorAll<HTMLElement>(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
201
|
+
document.querySelectorAll<HTMLElement>(BRAND_SURFACE).forEach((surface) => {
|
|
202
|
+
surface.querySelectorAll<HTMLElement>('*').forEach((element) => {
|
|
203
|
+
if (element.closest(USER_CONTENT) !== null) return
|
|
204
|
+
if (element.childElementCount !== 0 || !LEGACY_HOST_BRAND_LABEL_TEXT.test(element.textContent?.trim() ?? '')) return
|
|
205
|
+
if (element.textContent !== PROJECT_NAME) element.textContent = PROJECT_NAME
|
|
206
|
+
element.classList.add('dut-brand-title')
|
|
207
|
+
replaceLogoBesideBrandLabel(element)
|
|
208
|
+
hideVersionBesideBrandLabel(element)
|
|
209
|
+
})
|
|
202
210
|
})
|
|
203
211
|
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
node.data = node.data.replace(LEGACY_HOST_BRAND_TEXT, PROJECT_NAME)
|
|
212
|
-
LEGACY_HOST_BRAND_TEXT.lastIndex = 0
|
|
212
|
+
for (const surface of document.querySelectorAll(BRAND_SURFACE)) {
|
|
213
|
+
const walker = document.createTreeWalker(surface, NodeFilter.SHOW_TEXT)
|
|
214
|
+
let node: Text | null
|
|
215
|
+
while ((node = walker.nextNode() as Text | null) !== null) {
|
|
216
|
+
if (node.parentElement?.closest(USER_CONTENT) !== null) continue
|
|
217
|
+
const next = node.data.replace(LEGACY_HOST_BRAND_TEXT, PROJECT_NAME).replace(HERO_HEADLINE, PROJECT_NAME)
|
|
218
|
+
if (next !== node.data) node.data = next
|
|
213
219
|
}
|
|
214
|
-
if (HERO_HEADLINE.test(node.data)) node.data = node.data.replace(HERO_HEADLINE, PROJECT_NAME)
|
|
215
220
|
}
|
|
216
221
|
|
|
217
222
|
// Keep the product name in the sidebar, but use a more expressive headline
|
|
@@ -233,6 +238,7 @@ function syncBranding(): void {
|
|
|
233
238
|
if (svg instanceof SVGElement) replaceHostLogo(svg)
|
|
234
239
|
})
|
|
235
240
|
|
|
241
|
+
syncSidebarHeader()
|
|
236
242
|
document.querySelectorAll<HTMLButtonElement>('button').forEach((button) => {
|
|
237
243
|
button.classList.toggle('dut-unicom-primary-action', hasPrimaryLabel(button))
|
|
238
244
|
})
|
|
@@ -277,6 +283,7 @@ export function installBranding(): () => void {
|
|
|
277
283
|
return () => {
|
|
278
284
|
observer.disconnect()
|
|
279
285
|
if (frame !== undefined) window.cancelAnimationFrame(frame)
|
|
286
|
+
clearSidebarHeader()
|
|
280
287
|
favicon.remove()
|
|
281
288
|
style.remove()
|
|
282
289
|
}
|
|
@@ -36,6 +36,7 @@ import { WhaleIndicator, installWhaleStyles } from './whale.tsx'
|
|
|
36
36
|
import { PreciseCacheHitEntry } from './cachehit.tsx'
|
|
37
37
|
import { installTaskNotifier, previewAlerts, requestNotifyPermission } from './notifier.ts'
|
|
38
38
|
import { HeroProjectLogo, installBranding, ProjectLogoIcon, SidebarProjectLogo, SidebarProjectName } from './branding.tsx'
|
|
39
|
+
import { buildFontCss } from './typography.ts'
|
|
39
40
|
|
|
40
41
|
const NS = 'ui-tweaks'
|
|
41
42
|
const SETTINGS_ROUTE = '/_dsh/ui-tweaks/settings'
|
|
@@ -43,12 +44,12 @@ const SETTINGS_ROUTE = '/_dsh/ui-tweaks/settings'
|
|
|
43
44
|
/** Client context narrowed to the browser sessions face in this combined build. */
|
|
44
45
|
type UITweaksClientContext = ClientContext & { sessions: ISessions }
|
|
45
46
|
|
|
46
|
-
const DEFAULT_FONT_SIZE =
|
|
47
|
+
const DEFAULT_FONT_SIZE = 14
|
|
47
48
|
const MIN_FONT_SIZE = 10
|
|
48
49
|
const MAX_FONT_SIZE = 32
|
|
49
50
|
/** Legacy: code font as a percentage of the message font size (81% = stock 13/16). */
|
|
50
51
|
const DEFAULT_CODE_FONT_SCALE = 81
|
|
51
|
-
/**
|
|
52
|
+
/** Default absolute code-block size, paired with 14px prose. */
|
|
52
53
|
const DEFAULT_CODE_FONT_SIZE = 13
|
|
53
54
|
const MIN_CODE_FONT_SIZE = 8
|
|
54
55
|
const MAX_CODE_FONT_SIZE = 32
|
|
@@ -134,7 +135,7 @@ const en = {
|
|
|
134
135
|
fontSize: 'Message font size',
|
|
135
136
|
fontSizeHint: `Number between ${MIN_FONT_SIZE} and ${MAX_FONT_SIZE}; applies to message text, headings, tables and code.`,
|
|
136
137
|
codeFontSize: 'Code font size',
|
|
137
|
-
codeFontSizeHint: `Absolute code size in px (${MIN_CODE_FONT_SIZE}–${MAX_CODE_FONT_SIZE}); ${DEFAULT_CODE_FONT_SIZE}px is ChatCode CLI's default at a
|
|
138
|
+
codeFontSizeHint: `Absolute code size in px (${MIN_CODE_FONT_SIZE}–${MAX_CODE_FONT_SIZE}); ${DEFAULT_CODE_FONT_SIZE}px is ChatCode CLI's default at a 14px body. Applies to code blocks; inline code follows proportionally.`,
|
|
138
139
|
lineHeight: 'Line spacing',
|
|
139
140
|
lineHeightHint: `Base vertical spacing in px: gaps between message rows (Think ↔ tool cards) and blocks inside one reply, plus text line-height, paragraph and list margins, all scale from it; ${DEFAULT_LINE_HEIGHT} is ChatCode CLI's default.`,
|
|
140
141
|
tableStyle: 'Table style',
|
|
@@ -146,7 +147,7 @@ const en = {
|
|
|
146
147
|
gitBarOn: 'On',
|
|
147
148
|
gitBarOff: 'Off',
|
|
148
149
|
archiveManager: 'Archive manager',
|
|
149
|
-
archiveManagerHint: 'An Archive settings page to
|
|
150
|
+
archiveManagerHint: 'An Archive settings page to view and restore archived sessions.',
|
|
150
151
|
archiveManagerOn: 'On',
|
|
151
152
|
archiveManagerOff: 'Off',
|
|
152
153
|
mcpManager: 'MCP manager',
|
|
@@ -251,7 +252,7 @@ const en = {
|
|
|
251
252
|
archiveCount: 'sessions',
|
|
252
253
|
archiveUnavailable: 'Archive unavailable.',
|
|
253
254
|
archiveLiveError: 'This session is running; close it before permanently deleting it.',
|
|
254
|
-
archiveDisabledHint: 'Archive management is off. Turn it on in 界面调整 (UI Tweaks) to
|
|
255
|
+
archiveDisabledHint: 'Archive management is off. Turn it on in 界面调整 (UI Tweaks) to view and restore archived sessions here.',
|
|
255
256
|
archiveEnable: 'Enable archive management',
|
|
256
257
|
archiveRestored: 'Restored.',
|
|
257
258
|
defaultAction: 'Default',
|
|
@@ -334,7 +335,7 @@ const zh: Record<LocaleKey, string> = {
|
|
|
334
335
|
fontSize: '消息字体大小',
|
|
335
336
|
fontSizeHint: `取值 ${MIN_FONT_SIZE}–${MAX_FONT_SIZE},作用于消息正文、标题、表格与代码。`,
|
|
336
337
|
codeFontSize: '代码字号',
|
|
337
|
-
codeFontSizeHint: `代码绝对字号,取值 ${MIN_CODE_FONT_SIZE}–${MAX_CODE_FONT_SIZE}px;${DEFAULT_CODE_FONT_SIZE}px 为 ChatCode CLI 默认(正文
|
|
338
|
+
codeFontSizeHint: `代码绝对字号,取值 ${MIN_CODE_FONT_SIZE}–${MAX_CODE_FONT_SIZE}px;${DEFAULT_CODE_FONT_SIZE}px 为 ChatCode CLI 默认(正文 14 时)。作用于代码块,行内代码按比例跟随。`,
|
|
338
339
|
lineHeight: '行高',
|
|
339
340
|
lineHeightHint: `回复区垂直间距的基准值:消息之间(如 Think ↔ 工具卡片)、回复内块之间、正文行高、段落与列表边距都按它缩放;取值 ${MIN_LINE_HEIGHT}–${MAX_LINE_HEIGHT}px,${DEFAULT_LINE_HEIGHT} 为 ChatCode CLI 默认。`,
|
|
340
341
|
tableStyle: '表格样式',
|
|
@@ -346,7 +347,7 @@ const zh: Record<LocaleKey, string> = {
|
|
|
346
347
|
gitBarOn: '开启',
|
|
347
348
|
gitBarOff: '关闭',
|
|
348
349
|
archiveManager: '归档管理',
|
|
349
|
-
archiveManagerHint: '
|
|
350
|
+
archiveManagerHint: '在设置中显示「归档」页面:查看和恢复已归档会话。',
|
|
350
351
|
archiveManagerOn: '开启',
|
|
351
352
|
archiveManagerOff: '关闭',
|
|
352
353
|
mcpManager: 'MCP 管理',
|
|
@@ -451,7 +452,7 @@ const zh: Record<LocaleKey, string> = {
|
|
|
451
452
|
archiveCount: '个会话',
|
|
452
453
|
archiveUnavailable: '归档暂不可用。',
|
|
453
454
|
archiveLiveError: '该会话正在运行,无法彻底删除,请先关闭该会话。',
|
|
454
|
-
archiveDisabledHint: '
|
|
455
|
+
archiveDisabledHint: '归档管理尚未开启。在「界面调整」中开启“归档管理”后,可在此查看和恢复已归档会话。',
|
|
455
456
|
archiveEnable: '开启归档管理',
|
|
456
457
|
archiveRestored: '已恢复。',
|
|
457
458
|
defaultAction: '默认',
|
|
@@ -533,11 +534,13 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
|
533
534
|
|
|
534
535
|
function resolveValue(value: TweaksValue | undefined): ResolvedTweaks {
|
|
535
536
|
const fontSize = typeof value?.fontSize === 'number' ? value.fontSize : DEFAULT_FONT_SIZE
|
|
536
|
-
|
|
537
|
-
//
|
|
537
|
+
const codeFontScale = value?.codeFontScale ?? DEFAULT_CODE_FONT_SCALE
|
|
538
|
+
// Explicit code sizing wins; the stock preference keeps readable 13px code.
|
|
538
539
|
const codeFontSize = typeof value?.codeFontSize === 'number'
|
|
539
540
|
? Math.min(MAX_CODE_FONT_SIZE, Math.max(MIN_CODE_FONT_SIZE, value.codeFontSize))
|
|
540
|
-
:
|
|
541
|
+
: codeFontScale === DEFAULT_CODE_FONT_SCALE
|
|
542
|
+
? DEFAULT_CODE_FONT_SIZE
|
|
543
|
+
: Math.max(8, Math.round(fontSize * (13 / 16) * (codeFontScale / DEFAULT_CODE_FONT_SCALE)))
|
|
541
544
|
return {
|
|
542
545
|
fontSize,
|
|
543
546
|
codeFontSize,
|
|
@@ -559,50 +562,6 @@ function resolveValue(value: TweaksValue | undefined): ResolvedTweaks {
|
|
|
559
562
|
}
|
|
560
563
|
}
|
|
561
564
|
|
|
562
|
-
/** Scale one theme px value proportionally to the chosen base size. */
|
|
563
|
-
function rel(base: number, fontSize: number): number {
|
|
564
|
-
return Math.max(8, Math.round((base / DEFAULT_FONT_SIZE) * fontSize))
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
/** Rebuild the markdown font tokens for the chosen base size, keeping the theme faces. */
|
|
568
|
-
function buildFontCss(fontSize: number, lineHeight: number, codeFontSize: number): string {
|
|
569
|
-
const cs = getComputedStyle(document.body)
|
|
570
|
-
const fam = (name: string, fallback: string): string => {
|
|
571
|
-
const value = cs.getPropertyValue(name).trim()
|
|
572
|
-
return value.length > 0 ? value : fallback
|
|
573
|
-
}
|
|
574
|
-
const base = fam('--dsw-font-markdown-base-font-family', '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif')
|
|
575
|
-
const code = fam('--dsw-font-markdown-code-font-family', '"SF Mono", Consolas, monospace')
|
|
576
|
-
const codeBlock = fam('--dsw-font-markdown-code-block-font-family', '"SF Mono", Consolas, monospace')
|
|
577
|
-
|
|
578
|
-
const parts: string[] = []
|
|
579
|
-
// `baseLine` is the token's line-height at the 16px baseline; it scales with
|
|
580
|
-
// both the chosen font size and the 行高 unit, so at the default (16) it
|
|
581
|
-
// reproduces the stock rhythm exactly.
|
|
582
|
-
const token = (shorthand: string, size: number, baseLine: number, family: string): void => {
|
|
583
|
-
const line = Math.max(12, Math.round((baseLine / DEFAULT_FONT_SIZE) * fontSize * (lineHeight / DEFAULT_LINE_HEIGHT)))
|
|
584
|
-
parts.push(`--${shorthand}:${size}px/${line}px ${family}`)
|
|
585
|
-
parts.push(`--${shorthand}-font-size:${size}px`)
|
|
586
|
-
parts.push(`--${shorthand}-line-height:${line}px`)
|
|
587
|
-
}
|
|
588
|
-
// Code fonts hang off the absolute code-block size (stock: 13px at a 16px
|
|
589
|
-
// body), with inline code slightly larger and the small variant slightly
|
|
590
|
-
// smaller, preserving DSH's hierarchy (14/13 and 12/13 of the block).
|
|
591
|
-
const codePx = (blockRatio: number): number => Math.max(8, Math.round(codeFontSize * blockRatio))
|
|
592
|
-
token('dsw-font-markdown-base', fontSize, 28, base)
|
|
593
|
-
token('dsw-font-markdown-base-strong', fontSize, 28, base)
|
|
594
|
-
token('dsw-font-markdown-base-italic', fontSize, 28, base)
|
|
595
|
-
token('dsw-font-markdown-base-strong-italic', fontSize, 28, base)
|
|
596
|
-
token('dsw-font-markdown-h1', rel(24, fontSize), 34, base)
|
|
597
|
-
token('dsw-font-markdown-h2', rel(22, fontSize), 32, base)
|
|
598
|
-
token('dsw-font-markdown-h3', rel(20, fontSize), 30, base)
|
|
599
|
-
token('dsw-font-markdown-h4', fontSize, 28, base)
|
|
600
|
-
token('dsw-font-markdown-code', codePx(14 / 13), 22, code)
|
|
601
|
-
token('dsw-font-markdown-code-block', codePx(1), 22, codeBlock)
|
|
602
|
-
token('dsw-font-markdown-code-block-small', codePx(12 / 13), 18, codeBlock)
|
|
603
|
-
return `body{${parts.join(';')}}`
|
|
604
|
-
}
|
|
605
|
-
|
|
606
565
|
/**
|
|
607
566
|
* Claude Desktop-ish markdown table look: light-gray rounded cell cards with
|
|
608
567
|
* small gaps, no borders. Cells share the theme's inline-code background and
|
|
@@ -610,7 +569,7 @@ function buildFontCss(fontSize: number, lineHeight: number, codeFontSize: number
|
|
|
610
569
|
* renderer, so headers and cells always match.
|
|
611
570
|
*/
|
|
612
571
|
const CLAUDE_TABLE_CSS = `
|
|
613
|
-
div[data-slot="conversation.chat.node"] table{
|
|
572
|
+
div[data-slot="conversation.chat.node"] [class*="_markdown"]:not([data-markdown-variant="compact"]) table{
|
|
614
573
|
border-collapse:separate !important;
|
|
615
574
|
border-spacing:3px !important;
|
|
616
575
|
width:100% !important;
|
|
@@ -621,7 +580,7 @@ div[data-slot="conversation.chat.node"] table{
|
|
|
621
580
|
border:none !important;
|
|
622
581
|
font-size:var(--dsw-font-markdown-base-font-size) !important;
|
|
623
582
|
}
|
|
624
|
-
div[data-slot="conversation.chat.node"] table thead th{
|
|
583
|
+
div[data-slot="conversation.chat.node"] [class*="_markdown"]:not([data-markdown-variant="compact"]) table thead th{
|
|
625
584
|
background:var(--dsw-alias-markdown-inline-code) !important;
|
|
626
585
|
color:inherit !important;
|
|
627
586
|
font-weight:400 !important;
|
|
@@ -630,7 +589,7 @@ div[data-slot="conversation.chat.node"] table thead th{
|
|
|
630
589
|
border:none !important;
|
|
631
590
|
border-radius:6px !important;
|
|
632
591
|
}
|
|
633
|
-
div[data-slot="conversation.chat.node"] table tbody td{
|
|
592
|
+
div[data-slot="conversation.chat.node"] [class*="_markdown"]:not([data-markdown-variant="compact"]) table tbody td{
|
|
634
593
|
background:var(--dsw-alias-markdown-inline-code) !important;
|
|
635
594
|
color:inherit !important;
|
|
636
595
|
font-size:inherit !important;
|
|
@@ -639,8 +598,8 @@ div[data-slot="conversation.chat.node"] table tbody td{
|
|
|
639
598
|
border:none !important;
|
|
640
599
|
border-radius:6px !important;
|
|
641
600
|
}
|
|
642
|
-
div[data-slot="conversation.chat.node"] table code,
|
|
643
|
-
div[data-slot="conversation.chat.node"] table pre{
|
|
601
|
+
div[data-slot="conversation.chat.node"] [class*="_markdown"]:not([data-markdown-variant="compact"]) table code,
|
|
602
|
+
div[data-slot="conversation.chat.node"] [class*="_markdown"]:not([data-markdown-variant="compact"]) table pre{
|
|
644
603
|
background:transparent !important;
|
|
645
604
|
border:none !important;
|
|
646
605
|
box-shadow:none !important;
|
|
@@ -650,52 +609,32 @@ div[data-slot="conversation.chat.node"] table pre{
|
|
|
650
609
|
function buildRuntimeCss(value: ResolvedTweaks): string {
|
|
651
610
|
const rules: string[] = []
|
|
652
611
|
rules.push(buildFontCss(value.fontSize, value.lineHeight, value.codeFontSize))
|
|
653
|
-
//
|
|
654
|
-
// route them through the same base so they follow the fontSize setting too.
|
|
612
|
+
// Sent messages share the reply metrics, including explicit UI Tweaks sizes.
|
|
655
613
|
// `steering` messages are sent while the agent is busy (busyEnter: steer);
|
|
656
614
|
// `[data-pending-steering]` is their in-flight bubble before it becomes durable.
|
|
657
|
-
rules.push(`[data-chat-flow-kind="user"] [class
|
|
658
|
-
//
|
|
659
|
-
//
|
|
660
|
-
|
|
661
|
-
//
|
|
662
|
-
|
|
663
|
-
//
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
// Markdown table cells are pinned by DSH (15px); let every table style follow
|
|
667
|
-
// the fontSize setting as well.
|
|
668
|
-
rules.push(`div[data-slot="conversation.chat.node"] table th,div[data-slot="conversation.chat.node"] table td{font-size:var(--dsw-font-markdown-base-font-size) !important}`)
|
|
669
|
-
// Inline code is pinned by DSH to 0.875em of the surrounding text (it ignores
|
|
670
|
-
// the code token); scale that em by how far the chosen code size sits from
|
|
671
|
-
// the stock ratio (a 13px block at this body size).
|
|
672
|
-
const stockCodeBlock = value.fontSize * (13 / 16)
|
|
615
|
+
rules.push(`[data-chat-flow-kind="user"] [class*="_bubble"],[data-chat-flow-kind="steering"] [class*="_bubble"],[data-pending-steering] [class*="_bubble"]{font-size:var(--dsw-font-markdown-base-font-size) !important;line-height:var(--dsw-font-markdown-base-line-height) !important}`)
|
|
616
|
+
// Current contenteditable composers and older textarea composers inherit
|
|
617
|
+
// one size/leading pair, including placeholders and measurement layers.
|
|
618
|
+
rules.push(`[data-composer-card]{font:var(--dsw-font-markdown-base) !important}`)
|
|
619
|
+
// Tables use the same body size and leading in both table styles.
|
|
620
|
+
rules.push(`div[data-slot="conversation.chat.node"] [class*="_markdown"]:not([data-markdown-variant="compact"]) table th,div[data-slot="conversation.chat.node"] [class*="_markdown"]:not([data-markdown-variant="compact"]) table td{font-size:var(--dsw-font-markdown-base-font-size) !important;line-height:var(--dsw-font-markdown-base-line-height) !important}`)
|
|
621
|
+
// Inline code normally uses 0.92em. Explicit code sizing follows the
|
|
622
|
+
// same ratio relative to the 14px body / 13px code baseline.
|
|
623
|
+
const stockCodeBlock = value.fontSize * (13 / 14)
|
|
673
624
|
if (Math.abs(value.codeFontSize - stockCodeBlock) > 0.5) {
|
|
674
|
-
const em = (0.
|
|
675
|
-
rules.push(`div[data-slot="conversation.chat.node"] div[class*="
|
|
625
|
+
const em = (0.92 * (value.codeFontSize / stockCodeBlock)).toFixed(3)
|
|
626
|
+
rules.push(`div[data-slot="conversation.chat.node"] div[class*="_markdown"]:not([data-markdown-variant="compact"]) :not(pre)>code{font-size:${em}em !important}`)
|
|
676
627
|
}
|
|
677
|
-
//
|
|
678
|
-
// the stock 16px, every vertical spacing scales from it proportionally:
|
|
679
|
-
// ① gaps between message rows (Think ↔ tool cards like pwsh, user ↔
|
|
680
|
-
// assistant) — the chat flow column;
|
|
681
|
-
// ② gaps between content blocks inside one assistant reply (Think ↔ text) —
|
|
682
|
-
// the Assistant Markdown block container (`Sxvs8a_body`, CSS-module
|
|
683
|
-
// hashed, stable within the pinned rc.8 conversation package);
|
|
684
|
-
// ③ the markdown typography rhythm: paragraphs (`p` has a stock `margin:
|
|
685
|
-
// 16px 0` that must be overridden on both axes, not just bottom, or it
|
|
686
|
-
// can never tighten below 16), list margins, list-item gaps (stock 6px),
|
|
687
|
-
// paragraphs inside list items (stock 8px), code blocks, headings and
|
|
688
|
-
// rules — all scaled from the 行高 unit.
|
|
689
|
-
// Text line-height itself scales in buildFontCss above.
|
|
628
|
+
// Custom spacing scales prose without expanding compact thinking.
|
|
690
629
|
if (value.lineHeight !== DEFAULT_LINE_HEIGHT) {
|
|
691
630
|
const n = value.lineHeight
|
|
692
|
-
const md = `div[data-slot="conversation.chat.node"] div[class*="
|
|
693
|
-
const liGap = Math.max(2, Math.round((
|
|
631
|
+
const md = `div[data-slot="conversation.chat.node"] div[class*="_markdown"]:not([data-markdown-variant="compact"])`
|
|
632
|
+
const liGap = Math.max(2, Math.round((4 * n) / DEFAULT_LINE_HEIGHT))
|
|
694
633
|
const liPGap = Math.max(2, Math.round((8 * n) / DEFAULT_LINE_HEIGHT))
|
|
695
|
-
rules.push(`div[data-slot="conversation.view"]
|
|
696
|
-
rules.push(`div[data-slot="conversation.chat.node"]
|
|
697
|
-
rules.push(`${md} p{margin:${n}px 0 !important}`)
|
|
698
|
-
rules.push(`${md} ul,${md} ol{margin:${n}px 0 !important}`)
|
|
634
|
+
rules.push(`div[data-slot="conversation.view"] [data-chat-flow]{gap:${n}px !important}`)
|
|
635
|
+
rules.push(`div[data-slot="conversation.chat.node"] [data-assistant-body]{--dsh-assistant-block-gap:${n}px}`)
|
|
636
|
+
rules.push(`${md} p{margin:${Math.round(0.75 * n)}px 0 !important}`)
|
|
637
|
+
rules.push(`${md} ul,${md} ol{margin:${Math.round(0.75 * n)}px 0 !important}`)
|
|
699
638
|
rules.push(`${md} pre{margin:${n}px 0 !important}`)
|
|
700
639
|
// Code blocks: the pre's inner vertical padding is stock 16px (shiki
|
|
701
640
|
// default); scale it so the block's own height follows 行高 too. Only
|
|
@@ -711,13 +650,11 @@ function buildRuntimeCss(value: ResolvedTweaks): string {
|
|
|
711
650
|
}
|
|
712
651
|
rules.push(`${md} li:not(:first-child){margin-top:${liGap}px !important}`)
|
|
713
652
|
rules.push(`${md} li>p{margin:${liPGap}px 0 !important}`)
|
|
714
|
-
rules.push(`${md} h1,${md} h2,${md} h3{margin:${
|
|
653
|
+
rules.push(`${md} h1,${md} h2,${md} h3{margin:${Math.round(1.5 * n)}px 0 ${Math.round(0.75 * n)}px !important}`)
|
|
715
654
|
rules.push(`${md} h4,${md} h5,${md} h6{margin:${n}px 0 !important}`)
|
|
716
655
|
rules.push(`${md} hr{margin:${2 * n}px 0 !important}`)
|
|
717
656
|
rules.push(`${md} blockquote{margin:${n}px 0 0 !important}`)
|
|
718
|
-
//
|
|
719
|
-
// margin (stock `>*:first-child` / `>*:last-child`), so a message starts
|
|
720
|
-
// and ends tight and the spacing to the next node stays the column gap.
|
|
657
|
+
// Preserve the first and last block's flush edges.
|
|
721
658
|
rules.push(`${md} > :first-child{margin-top:0 !important}`)
|
|
722
659
|
rules.push(`${md} > :last-child{margin-bottom:0 !important}`)
|
|
723
660
|
}
|
|
@@ -1545,7 +1482,7 @@ export function apply(ctx: UITweaksClientContext): void {
|
|
|
1545
1482
|
ctx.effect(() => installHeroChip(controller, t), 'dsh-ui-tweaks: hero branch chip')
|
|
1546
1483
|
|
|
1547
1484
|
// Archive manager: a Settings section ("归档") that lists archived sessions
|
|
1548
|
-
// and can restore
|
|
1485
|
+
// and can restore them. Registered only while the
|
|
1549
1486
|
// archiveManagerEnabled toggle in the UI Tweaks section is on, so the nav
|
|
1550
1487
|
// row appears / disappears live with the switch (the settings shell
|
|
1551
1488
|
// projects its nav from the section ledger).
|
|
@@ -1555,7 +1492,7 @@ export function apply(ctx: UITweaksClientContext): void {
|
|
|
1555
1492
|
order: 50,
|
|
1556
1493
|
label: () => t('archiveNav'),
|
|
1557
1494
|
locale: NS,
|
|
1558
|
-
inject: () => ({ controller, t
|
|
1495
|
+
inject: () => ({ controller, t }),
|
|
1559
1496
|
}, ArchiveSection))
|
|
1560
1497
|
|
|
1561
1498
|
// MCP manager: a Settings section ("MCP 管理") that lists the configured MCP
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/** Compact sidebar chrome; the host retains every button, shortcut and drag surface. */
|
|
2
|
+
export const SIDEBAR_HEADER_CSS = `
|
|
3
|
+
.dut-sidebar-header{height:44px !important;padding:0 4px !important;margin-bottom:8px !important;gap:8px !important}
|
|
4
|
+
.dut-sidebar-brand{min-width:0 !important;background:transparent !important;box-shadow:none !important}
|
|
5
|
+
.dut-sidebar-identity{height:24px !important;gap:8px !important}
|
|
6
|
+
.dut-sidebar-wordmark{font:var(--dsw-font-s-strong-14) !important;letter-spacing:-.01em !important;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
7
|
+
.dut-sidebar-toggle{width:28px !important;height:28px !important;border-radius:8px !important;color:var(--dsw-alias-label-secondary) !important}
|
|
8
|
+
.dut-sidebar-toggle:hover{background:var(--dsw-alias-interactive-bg-hover) !important}
|
|
9
|
+
/* Reuse the original ChatCode primary-action red, scoped to this marked CTA. */
|
|
10
|
+
.dut-sidebar-new-session{height:40px !important;justify-content:flex-start !important;gap:8px !important;margin:0 0 10px !important;padding:8px 10px !important;border:1px solid #9B0B09 !important;border-radius:10px !important;background:linear-gradient(135deg,#9B0B09,#b71916) !important;color:#fff !important;font:var(--dsw-font-s-strong-14) !important;font-weight:600 !important;box-shadow:none !important;transform:none !important}
|
|
11
|
+
.dut-sidebar-new-session:hover{background:linear-gradient(135deg,#b71916,#cf302c) !important}
|
|
12
|
+
.dut-sidebar-new-session:active{background:#9B0B09 !important}
|
|
13
|
+
.dut-sidebar-new-session:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}
|
|
14
|
+
.dut-sidebar-new-session > span:first-child{flex:1;min-width:0;overflow:hidden;mask-image:none !important}
|
|
15
|
+
.dut-sidebar-new-session > span:first-child > span{width:auto !important;justify-content:flex-start !important;gap:8px !important;min-width:0}
|
|
16
|
+
.dut-sidebar-new-session > span:first-child > span > svg{width:16px;height:16px;flex:none;color:inherit}
|
|
17
|
+
.dut-sidebar-new-session > span:first-child > span > span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
18
|
+
.dut-sidebar-new-session > span + span{opacity:1 !important;flex:none;color:color-mix(in srgb,currentColor 75%,transparent);font:var(--dsw-font-xxs-12)}
|
|
19
|
+
/* Temporary navigation-only hide. Remove this block to restore Plugins;
|
|
20
|
+
registrations, settings, installed plugins and other panel entries stay intact. */
|
|
21
|
+
nav:is([aria-label="全局面板"],[aria-label="Global panels"]) > button:is([aria-label="插件"],[aria-label="Plugins"]),
|
|
22
|
+
nav:is([aria-label="全局面板"],[aria-label="Global panels"]):has(> button:is([aria-label="插件"],[aria-label="Plugins"]):only-child){display:none !important}
|
|
23
|
+
`
|
|
24
|
+
|
|
25
|
+
const HEADER_CLASSES = [
|
|
26
|
+
'dut-sidebar-header', 'dut-sidebar-brand', 'dut-sidebar-identity',
|
|
27
|
+
'dut-sidebar-wordmark', 'dut-sidebar-toggle', 'dut-sidebar-new-session',
|
|
28
|
+
] as const
|
|
29
|
+
type HeaderClass = typeof HEADER_CLASSES[number]
|
|
30
|
+
|
|
31
|
+
/** Mark only the expanded brand row and its adjacent native New Session button. */
|
|
32
|
+
export function syncSidebarHeader(): void {
|
|
33
|
+
const desired = new Map<HTMLElement, Set<HeaderClass>>()
|
|
34
|
+
const mark = (element: Element | null | undefined, className: HeaderClass): void => {
|
|
35
|
+
if (!(element instanceof HTMLElement)) return
|
|
36
|
+
const classes = desired.get(element) ?? new Set<HeaderClass>()
|
|
37
|
+
classes.add(className)
|
|
38
|
+
desired.set(element, classes)
|
|
39
|
+
}
|
|
40
|
+
for (const name of document.querySelectorAll<HTMLElement>('.dut-sidebar-brand-name,.dut-brand-title')) {
|
|
41
|
+
const row = name.closest<HTMLElement>('[data-window-drag]')
|
|
42
|
+
const logo = row?.querySelector('.dut-sidebar-logo,.dut-left-logo')
|
|
43
|
+
if (!row || !logo) continue
|
|
44
|
+
const brand = [...row.children].find(child => child.contains(name) && child.contains(logo))
|
|
45
|
+
if (!brand) continue
|
|
46
|
+
mark(row, 'dut-sidebar-header')
|
|
47
|
+
mark(brand, 'dut-sidebar-brand')
|
|
48
|
+
mark(logo.closest('[class*="brandIdentity"]'), 'dut-sidebar-identity')
|
|
49
|
+
mark(name, 'dut-sidebar-wordmark')
|
|
50
|
+
for (const button of row.querySelectorAll('button')) {
|
|
51
|
+
if (!brand.contains(button) && button !== brand) mark(button, 'dut-sidebar-toggle')
|
|
52
|
+
}
|
|
53
|
+
// The host renders this native action directly after the drag row. Do
|
|
54
|
+
// not infer a new action from arbitrary text in another panel or dialog.
|
|
55
|
+
const next = row.nextElementSibling
|
|
56
|
+
if (next instanceof HTMLButtonElement) mark(next, 'dut-sidebar-new-session')
|
|
57
|
+
}
|
|
58
|
+
// A collapsed rail no longer has a wordmark. Remove expanded-only styling
|
|
59
|
+
// without changing the host's rail geometry or its logo/expand interaction.
|
|
60
|
+
for (const className of HEADER_CLASSES) {
|
|
61
|
+
for (const element of document.querySelectorAll<HTMLElement>(`.${className}`)) {
|
|
62
|
+
if (!desired.get(element)?.has(className)) element.classList.remove(className)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
for (const [element, classes] of desired) element.classList.add(...classes)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Restore native header styling when the branding effect is disposed. */
|
|
69
|
+
export function clearSidebarHeader(): void {
|
|
70
|
+
for (const className of HEADER_CLASSES) {
|
|
71
|
+
for (const element of document.querySelectorAll(`.${className}`)) element.classList.remove(className)
|
|
72
|
+
}
|
|
73
|
+
}
|