@chatcode/cco-better-sidebar 0.18.0-rc.11 → 0.18.0-rc.12
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 +8 -6
- package/README_EN.md +8 -6
- package/lib/client-editor.js +298 -296
- package/lib/client-mermaid.js +296 -296
- package/lib/client-registry.js +838 -601
- package/lib/client-terminal.js +299 -297
- package/lib/client.js +838 -601
- package/lib/index.js +18 -1
- package/lib/types/client/api.d.ts +4 -0
- package/lib/types/client/locales-ja.d.ts +25 -0
- package/lib/types/client/ui-tweaks/archive.d.ts +8 -23
- package/lib/types/client/ui-tweaks/branding.d.ts +1 -1
- package/lib/types/client/ui-tweaks/dom-text.d.ts +2 -0
- package/lib/types/client/ui-tweaks/index.d.ts +10 -2
- package/lib/types/ui-tweaks/config.d.ts +1 -1
- package/package.json +1 -1
- package/src/client/api.ts +3 -0
- package/src/client/locales-ja.ts +26 -0
- package/src/client/ui-tweaks/archive.tsx +118 -90
- package/src/client/ui-tweaks/branding.tsx +85 -24
- package/src/client/ui-tweaks/cachehit.tsx +24 -14
- package/src/client/ui-tweaks/dom-text.ts +12 -0
- package/src/client/ui-tweaks/index.tsx +41 -6
- package/src/index.ts +4 -1
- package/src/ui-tweaks/config.ts +1 -1
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { ReactNode } from 'react'
|
|
11
|
+
import { api } from '../api.ts'
|
|
12
|
+
import { updateTextContent } from './dom-text.ts'
|
|
11
13
|
import { clearSidebarHeader, SIDEBAR_HEADER_CSS, syncSidebarHeader } from './sidebar-header.ts'
|
|
12
14
|
|
|
13
15
|
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
@@ -37,7 +39,12 @@ const HOST_BUILD_VERSION_TEXT = /^v?\d+\.\d+\.\d+(?:[-+][0-9a-z.-]+)*$/iu
|
|
|
37
39
|
const HERO_HEADLINE = /探索未至之境/u
|
|
38
40
|
const HERO_PREVIEW_TEXT = /^(?:预览版|Preview)$/iu
|
|
39
41
|
const FAVICON_MARKER = 'data-dut-project-favicon'
|
|
42
|
+
const SIDEBAR_VERSION_MARKER = 'data-dut-sidebar-version'
|
|
40
43
|
const VERSION_NOTICE_MARKER = 'data-dut-version-notice'
|
|
44
|
+
/** The General Settings "current version" row the plugin moves to the sidebar. */
|
|
45
|
+
const VERSION_ROW_TEXT = /^(?:当前版本|Current version)\s*[::]\s*v?\d/iu
|
|
46
|
+
/** The globally installed CLI version, fetched once from the sidebar host. */
|
|
47
|
+
let sidebarVersion: string | null = null
|
|
41
48
|
const VERSION_NOTICE = {
|
|
42
49
|
en: {
|
|
43
50
|
legacyTitle: 'Internal Testing Notice',
|
|
@@ -80,20 +87,30 @@ export function SidebarProjectName(): ReactNode {
|
|
|
80
87
|
}
|
|
81
88
|
|
|
82
89
|
export const BRANDING_CSS = `
|
|
83
|
-
/*
|
|
84
|
-
other
|
|
85
|
-
menus, the composer, text and shadows) remains owned by the host theme. */
|
|
90
|
+
/* Solid branding is limited to primary actions. Question choices only get a
|
|
91
|
+
faint token-derived tint; other surfaces remain owned by the host theme. */
|
|
86
92
|
body:not([data-ds-dark-theme]) .dut-unicom-primary-action{background:linear-gradient(135deg,#9B0B09,#b71916) !important;border-color:#9B0B09 !important;color:#fff !important;box-shadow:0 7px 18px rgba(155,11,9,.24) !important}
|
|
87
93
|
body:not([data-ds-dark-theme]) .dut-unicom-primary-action:hover{background:linear-gradient(135deg,#b71916,#cf302c) !important;border-color:#b71916 !important;color:#fff !important;box-shadow:0 10px 24px rgba(155,11,9,.30) !important}
|
|
88
94
|
body:not([data-ds-dark-theme]) .dut-unicom-primary-action:active{transform:translateY(1px);box-shadow:0 4px 11px rgba(155,11,9,.22) !important}
|
|
89
95
|
/* In dark mode, alter only the resting background of primary buttons. Once
|
|
90
96
|
hovered, the host owns the complete interaction treatment again. */
|
|
91
97
|
body[data-ds-dark-theme] .dut-unicom-primary-action:not(:hover){background:#9B0B09 !important}
|
|
98
|
+
/* Only the host's question composer, never global radio/checkbox controls.
|
|
99
|
+
Keep normal text, focus rings and disabled behavior; no gradient or shadow. */
|
|
100
|
+
[data-question-key] button:is([role="radio"],[role="checkbox"]):hover:not(:disabled){background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 5%,transparent)}
|
|
101
|
+
[data-question-key] button:is([role="radio"],[role="checkbox"])[aria-checked="true"]{background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 8%,transparent);border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 18%,transparent)}
|
|
102
|
+
[data-question-key] button:is([role="radio"],[role="checkbox"])[aria-checked="true"]:hover:not(:disabled){background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent)}
|
|
92
103
|
.dut-project-logo{display:block;object-fit:contain}
|
|
93
104
|
.dut-left-logo{width:24px !important;height:24px !important}
|
|
105
|
+
/* Legacy host marks remain in React's tree; only their painted appearance changes. */
|
|
106
|
+
svg.dut-project-logo{background:url("${PROJECT_LOGO_URL}") center/contain no-repeat}
|
|
107
|
+
svg.dut-project-logo>*{visibility:hidden}
|
|
94
108
|
.dut-brand-title{font:var(--dsw-font-s-strong-14) !important}
|
|
95
109
|
.dut-sidebar-logo{width:24px !important;height:24px !important}
|
|
96
110
|
.dut-sidebar-brand-name{font:var(--dsw-font-s-strong-14) !important;letter-spacing:-.01em !important;white-space:nowrap}
|
|
111
|
+
/* The version the plugin injects beside the sidebar wordmark. */
|
|
112
|
+
.dut-sidebar-version{margin-left:8px;font-size:12px !important;font-weight:500 !important;line-height:22px !important;color:var(--dsw-alias-label-secondary) !important;letter-spacing:0 !important;white-space:nowrap}
|
|
113
|
+
.dut-version-row-hidden{display:none !important}
|
|
97
114
|
${SIDEBAR_HEADER_CSS}
|
|
98
115
|
.dut-brand-version{display:none !important}
|
|
99
116
|
.dut-hero-preview{display:none !important}
|
|
@@ -107,24 +124,23 @@ function hasPrimaryLabel(button: HTMLButtonElement): boolean {
|
|
|
107
124
|
// Plugin cards own their appearance. Inventory disclosure buttons include
|
|
108
125
|
// descriptions, where words like "install" do not identify a primary action.
|
|
109
126
|
if (button.closest('[data-chatcode-plugin-market], [data-plugin-module]')) return false
|
|
110
|
-
|
|
127
|
+
// User/model text can itself be "Send" or contain "发送". These are choices
|
|
128
|
+
// and transcript disclosures, not submit/install actions, regardless of copy.
|
|
129
|
+
if (button.closest('[data-question-key], [data-tool], [data-variant="think"], [data-disclosure-row]')) return false
|
|
130
|
+
const role = button.getAttribute('role')
|
|
131
|
+
if ((role !== null && role !== 'button') || button.hasAttribute('aria-expanded')) return false
|
|
111
132
|
if (button.classList.contains('dut-sidebar-brand') || button.classList.contains('dut-sidebar-new-session')) return false
|
|
112
|
-
|
|
133
|
+
// Prefer the accessible action name. Never match words inside descriptions,
|
|
134
|
+
// nor concatenate title/text/aria-label into an unbounded substring search.
|
|
135
|
+
const label = (button.getAttribute('aria-label')?.trim() || button.title.trim() || button.textContent || '')
|
|
136
|
+
.replace(/\s+/gu, ' ').trim().toLowerCase()
|
|
137
|
+
return /^(?:发送(?:消息)?|排队发送|插话发送|send(?: message)?|queue message|steer (?:queued )?message|安装|install)$/u.test(label)
|
|
113
138
|
}
|
|
114
139
|
|
|
115
|
-
/**
|
|
116
|
-
function
|
|
140
|
+
/** Restyle a legacy host SVG without replacing the DOM node held by React. */
|
|
141
|
+
function styleHostLogo(svg: SVGElement): void {
|
|
117
142
|
if (svg.classList.contains('dut-project-logo')) return
|
|
118
|
-
|
|
119
|
-
image.className = `${svg.getAttribute('class') ?? ''} dut-project-logo dut-left-logo`.trim()
|
|
120
|
-
image.src = PROJECT_LOGO_URL
|
|
121
|
-
image.alt = ''
|
|
122
|
-
image.setAttribute('aria-hidden', 'true')
|
|
123
|
-
const width = svg.getAttribute('width')
|
|
124
|
-
const height = svg.getAttribute('height')
|
|
125
|
-
if (width !== null) image.setAttribute('width', width)
|
|
126
|
-
if (height !== null) image.setAttribute('height', height)
|
|
127
|
-
svg.replaceWith(image)
|
|
143
|
+
svg.classList.add('dut-project-logo', 'dut-left-logo')
|
|
128
144
|
}
|
|
129
145
|
|
|
130
146
|
/** Locate the mark adjacent to an otherwise unstructured sidebar brand label. */
|
|
@@ -135,12 +151,12 @@ function replaceLogoBesideBrandLabel(label: HTMLElement): void {
|
|
|
135
151
|
]
|
|
136
152
|
for (const candidate of nearby) {
|
|
137
153
|
if (candidate instanceof SVGElement) {
|
|
138
|
-
|
|
154
|
+
styleHostLogo(candidate)
|
|
139
155
|
return
|
|
140
156
|
}
|
|
141
157
|
const svg = candidate?.querySelector('svg')
|
|
142
158
|
if (svg instanceof SVGElement) {
|
|
143
|
-
|
|
159
|
+
styleHostLogo(svg)
|
|
144
160
|
return
|
|
145
161
|
}
|
|
146
162
|
}
|
|
@@ -152,12 +168,40 @@ function hideVersionBesideBrandLabel(label: HTMLElement): void {
|
|
|
152
168
|
if (container === null) return
|
|
153
169
|
for (const sibling of container.children) {
|
|
154
170
|
if (sibling === label || !(sibling instanceof HTMLElement)) continue
|
|
171
|
+
if (sibling.hasAttribute(SIDEBAR_VERSION_MARKER)) continue
|
|
155
172
|
if (!HOST_BUILD_VERSION_TEXT.test(sibling.textContent?.trim() ?? '')) continue
|
|
156
173
|
sibling.classList.add('dut-brand-version')
|
|
157
174
|
sibling.setAttribute('aria-hidden', 'true')
|
|
158
175
|
}
|
|
159
176
|
}
|
|
160
177
|
|
|
178
|
+
/** Insert or update the version span immediately after the sidebar wordmark. */
|
|
179
|
+
function injectSidebarVersion(name: HTMLElement, version: string): void {
|
|
180
|
+
const container = name.parentElement
|
|
181
|
+
if (container === null) return
|
|
182
|
+
for (const sibling of container.children) {
|
|
183
|
+
if (sibling === name || !(sibling instanceof HTMLElement)) continue
|
|
184
|
+
if (!sibling.hasAttribute(SIDEBAR_VERSION_MARKER)) continue
|
|
185
|
+
if (sibling.textContent !== version) sibling.textContent = version
|
|
186
|
+
return
|
|
187
|
+
}
|
|
188
|
+
const span = document.createElement('span')
|
|
189
|
+
span.className = 'dut-sidebar-version'
|
|
190
|
+
span.setAttribute(SIDEBAR_VERSION_MARKER, '')
|
|
191
|
+
span.textContent = version
|
|
192
|
+
name.after(span)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** Hide the General Settings "当前版本" row, now that the sidebar owns it. */
|
|
196
|
+
function hideSettingsVersionRow(): void {
|
|
197
|
+
document.querySelectorAll<HTMLElement>('body *').forEach((row) => {
|
|
198
|
+
if (row.childElementCount !== 0) return
|
|
199
|
+
if (!VERSION_ROW_TEXT.test(row.textContent?.trim() ?? '')) return
|
|
200
|
+
row.classList.add('dut-version-row-hidden')
|
|
201
|
+
row.setAttribute('aria-hidden', 'true')
|
|
202
|
+
})
|
|
203
|
+
}
|
|
204
|
+
|
|
161
205
|
/** Replace the registry build's older upstream notice with ChatCode product copy. */
|
|
162
206
|
function syncVersionNotice(): void {
|
|
163
207
|
document.querySelectorAll<HTMLElement>(
|
|
@@ -173,11 +217,11 @@ function syncVersionNotice(): void {
|
|
|
173
217
|
dialog.setAttribute('aria-label', notice.title)
|
|
174
218
|
dialog.setAttribute(VERSION_NOTICE_MARKER, '')
|
|
175
219
|
dialog.dataset.dutVersionNoticeLanguage = language
|
|
176
|
-
if (heading !== null
|
|
220
|
+
if (heading !== null) updateTextContent(heading, notice.title)
|
|
177
221
|
const paragraphs = dialog.querySelectorAll<HTMLParagraphElement>('p')
|
|
178
222
|
notice.paragraphs.forEach((text, index) => {
|
|
179
223
|
const paragraph = paragraphs.item(index)
|
|
180
|
-
if (paragraph !== null
|
|
224
|
+
if (paragraph !== null) updateTextContent(paragraph, text)
|
|
181
225
|
})
|
|
182
226
|
})
|
|
183
227
|
}
|
|
@@ -202,10 +246,15 @@ function syncBranding(): void {
|
|
|
202
246
|
surface.querySelectorAll<HTMLElement>('*').forEach((element) => {
|
|
203
247
|
if (element.closest(USER_CONTENT) !== null) return
|
|
204
248
|
if (element.childElementCount !== 0 || !LEGACY_HOST_BRAND_LABEL_TEXT.test(element.textContent?.trim() ?? '')) return
|
|
205
|
-
|
|
249
|
+
updateTextContent(element, PROJECT_NAME)
|
|
206
250
|
element.classList.add('dut-brand-title')
|
|
207
251
|
replaceLogoBesideBrandLabel(element)
|
|
208
252
|
hideVersionBesideBrandLabel(element)
|
|
253
|
+
// The sidebar wordmark carries its dedicated slot class; inject the version
|
|
254
|
+
// only there, never onto the hero headline that shares the label text.
|
|
255
|
+
if (element.classList.contains('dut-sidebar-brand-name') && sidebarVersion !== null) {
|
|
256
|
+
injectSidebarVersion(element, sidebarVersion)
|
|
257
|
+
}
|
|
209
258
|
})
|
|
210
259
|
})
|
|
211
260
|
|
|
@@ -226,16 +275,19 @@ function syncBranding(): void {
|
|
|
226
275
|
const title = Array.from(headline?.querySelectorAll<HTMLElement>('*') ?? [])
|
|
227
276
|
.find(element => element.childElementCount === 0 && element.textContent?.trim() === PROJECT_NAME)
|
|
228
277
|
if (title === undefined) return
|
|
229
|
-
title
|
|
278
|
+
updateTextContent(title, HERO_TITLE)
|
|
230
279
|
title.classList.add('dut-hero-title')
|
|
231
280
|
})
|
|
232
281
|
|
|
233
282
|
syncVersionNotice()
|
|
234
283
|
|
|
284
|
+
// The General Settings version row moved to the sidebar; keep it hidden.
|
|
285
|
+
hideSettingsVersionRow()
|
|
286
|
+
|
|
235
287
|
// Older host builds expose a brand-mark wrapper but no text-bearing sibling.
|
|
236
288
|
document.querySelectorAll<HTMLElement>('[class*="brandMark"]').forEach((host) => {
|
|
237
289
|
const svg = host.matches('svg') ? host : host.querySelector('svg')
|
|
238
|
-
if (svg instanceof SVGElement)
|
|
290
|
+
if (svg instanceof SVGElement) styleHostLogo(svg)
|
|
239
291
|
})
|
|
240
292
|
|
|
241
293
|
syncSidebarHeader()
|
|
@@ -278,6 +330,15 @@ export function installBranding(): () => void {
|
|
|
278
330
|
})
|
|
279
331
|
}
|
|
280
332
|
syncBranding()
|
|
333
|
+
// Fetch the installed version asynchronously; once it lands, re-run the
|
|
334
|
+
// pass so the sidebar wordmark gets its version span.
|
|
335
|
+
void api.chatcodeInstalledVersion()
|
|
336
|
+
.then(({ version }) => {
|
|
337
|
+
if (version === null || version === '') return
|
|
338
|
+
sidebarVersion = version
|
|
339
|
+
schedule()
|
|
340
|
+
})
|
|
341
|
+
.catch(() => {})
|
|
281
342
|
const observer = new MutationObserver(schedule)
|
|
282
343
|
observer.observe(document.body, { childList: true, characterData: true, subtree: true })
|
|
283
344
|
return () => {
|
|
@@ -65,8 +65,14 @@ export function PreciseCacheHitEntry({ useProjection }: PreciseCacheHitEntryProp
|
|
|
65
65
|
const bands = document.querySelectorAll<HTMLElement>('[data-slot="conversation.composer.dock"]')
|
|
66
66
|
if (bands.length === 0) return
|
|
67
67
|
|
|
68
|
-
/**
|
|
69
|
-
const patched = new Map<
|
|
68
|
+
/** Preserve host-owned nodes, including icons and React's text-node references. */
|
|
69
|
+
const patched = new Map<Text, { original: string; rewritten: string }>()
|
|
70
|
+
const restore = (node: Text): void => {
|
|
71
|
+
const previous = patched.get(node)
|
|
72
|
+
// React may already have supplied newer copy; cleanup must not undo it.
|
|
73
|
+
if (previous !== undefined && node.data === previous.rewritten) node.data = previous.original
|
|
74
|
+
patched.delete(node)
|
|
75
|
+
}
|
|
70
76
|
|
|
71
77
|
/**
|
|
72
78
|
* Two-decimal share over the raw buckets; null while there is nothing
|
|
@@ -89,21 +95,28 @@ export function PreciseCacheHitEntry({ useProjection }: PreciseCacheHitEntryProp
|
|
|
89
95
|
if (precise === null) {
|
|
90
96
|
// Projection gone (session switch race): undo any rewrite so the
|
|
91
97
|
// stock integer shows again instead of a stale figure.
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
for (const node of patched.keys()) {
|
|
99
|
+
if (el.contains(node)) restore(node)
|
|
100
|
+
}
|
|
95
101
|
continue
|
|
96
102
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
103
|
+
const walker = document.createTreeWalker(el, NodeFilter.SHOW_TEXT)
|
|
104
|
+
let node: Text | null
|
|
105
|
+
while ((node = walker.nextNode() as Text | null) !== null) {
|
|
106
|
+
if (!PERCENT_IN_SPAN_PATTERN.test(node.data)) continue
|
|
107
|
+
const previous = patched.get(node)
|
|
108
|
+
const original = previous !== undefined && node.data === previous.rewritten ? previous.original : node.data
|
|
109
|
+
const rewritten = node.data.replace(PERCENT_IN_SPAN_PATTERN, `${precise}%`)
|
|
110
|
+
patched.set(node, { original, rewritten })
|
|
111
|
+
if (rewritten !== node.data) node.data = rewritten
|
|
112
|
+
}
|
|
100
113
|
}
|
|
101
114
|
}
|
|
102
115
|
}
|
|
103
116
|
|
|
104
117
|
apply()
|
|
105
|
-
//
|
|
106
|
-
//
|
|
118
|
+
// Mutate Text.data only: textContent would remove the host's icon and text
|
|
119
|
+
// children, making a later React commit fail with NotFoundError.
|
|
107
120
|
const observer = new MutationObserver(apply)
|
|
108
121
|
for (const band of bands) {
|
|
109
122
|
observer.observe(band, { childList: true, characterData: true, subtree: true })
|
|
@@ -111,10 +124,7 @@ export function PreciseCacheHitEntry({ useProjection }: PreciseCacheHitEntryProp
|
|
|
111
124
|
return () => {
|
|
112
125
|
observer.disconnect()
|
|
113
126
|
// Toggle-off/unmount must not leave a stale precise figure behind.
|
|
114
|
-
for (const
|
|
115
|
-
if ((el.textContent ?? '') !== original) el.textContent = original
|
|
116
|
-
}
|
|
117
|
-
patched.clear()
|
|
127
|
+
for (const node of patched.keys()) restore(node)
|
|
118
128
|
}
|
|
119
129
|
}, [usage])
|
|
120
130
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Update copy without detaching the text/element nodes owned by the host's React tree. */
|
|
2
|
+
export function updateTextContent(element: Element, value: string): void {
|
|
3
|
+
if (element.textContent === value) return
|
|
4
|
+
const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT)
|
|
5
|
+
let node = walker.nextNode()
|
|
6
|
+
let remaining = value
|
|
7
|
+
while (node !== null) {
|
|
8
|
+
if (node.nodeValue !== remaining) node.nodeValue = remaining
|
|
9
|
+
remaining = ''
|
|
10
|
+
node = walker.nextNode()
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import { useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from 'react'
|
|
11
11
|
import { createPortal } from 'react-dom'
|
|
12
|
+
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
|
12
13
|
import type { ISessions } from '@deepseek-ai/dsh-api-session-controller/client'
|
|
13
14
|
import type { Context as ClientContext } from '../../context-types.ts'
|
|
14
15
|
import type {} from '@deepseek-ai/dsh-client-locale/client'
|
|
@@ -37,6 +38,7 @@ import { PreciseCacheHitEntry } from './cachehit.tsx'
|
|
|
37
38
|
import { installTaskNotifier, previewAlerts, requestNotifyPermission } from './notifier.ts'
|
|
38
39
|
import { HeroProjectLogo, installBranding, ProjectLogoIcon, SidebarProjectLogo, SidebarProjectName } from './branding.tsx'
|
|
39
40
|
import { buildFontCss } from './typography.ts'
|
|
41
|
+
import { uiTweaksArchiveJa } from '../locales-ja.ts'
|
|
40
42
|
|
|
41
43
|
const NS = 'ui-tweaks'
|
|
42
44
|
const SETTINGS_ROUTE = '/_dsh/ui-tweaks/settings'
|
|
@@ -147,7 +149,7 @@ const en = {
|
|
|
147
149
|
gitBarOn: 'On',
|
|
148
150
|
gitBarOff: 'Off',
|
|
149
151
|
archiveManager: 'Archive manager',
|
|
150
|
-
archiveManagerHint: 'An Archive settings page to
|
|
152
|
+
archiveManagerHint: 'An Archive settings page to restore or permanently delete archived sessions.',
|
|
151
153
|
archiveManagerOn: 'On',
|
|
152
154
|
archiveManagerOff: 'Off',
|
|
153
155
|
mcpManager: 'MCP manager',
|
|
@@ -246,13 +248,21 @@ const en = {
|
|
|
246
248
|
archiveEmpty: 'No archived sessions.',
|
|
247
249
|
archiveRestore: 'Restore',
|
|
248
250
|
archiveRestoring: 'Working…',
|
|
251
|
+
archiveConfirmTitle: 'Permanently delete sessions?',
|
|
252
|
+
archiveConfirmDescription: 'Delete {count} session records including owned subagents? This cannot be undone. Independent forks, workspace files and Git data are retained.',
|
|
253
|
+
archiveCancel: 'Cancel',
|
|
249
254
|
archiveDelete: 'Delete',
|
|
250
255
|
archiveDeleteAll: 'Delete all',
|
|
256
|
+
archiveSelectAll: 'Select all',
|
|
257
|
+
archiveSelectedCount: '{count} sessions selected',
|
|
258
|
+
archiveClearSelection: 'Clear selection',
|
|
259
|
+
archiveDeleteSelected: 'Delete selected ({count})',
|
|
260
|
+
archiveDeleteFailed: '{title}: {error}',
|
|
251
261
|
archiveRestoreAll: 'Restore all',
|
|
252
262
|
archiveCount: 'sessions',
|
|
253
263
|
archiveUnavailable: 'Archive unavailable.',
|
|
254
264
|
archiveLiveError: 'This session is running; close it before permanently deleting it.',
|
|
255
|
-
archiveDisabledHint: 'Archive management is off. Turn it on in 界面调整 (UI Tweaks) to
|
|
265
|
+
archiveDisabledHint: 'Archive management is off. Turn it on in 界面调整 (UI Tweaks) to restore or permanently delete archived sessions here.',
|
|
256
266
|
archiveEnable: 'Enable archive management',
|
|
257
267
|
archiveRestored: 'Restored.',
|
|
258
268
|
defaultAction: 'Default',
|
|
@@ -347,7 +357,7 @@ const zh: Record<LocaleKey, string> = {
|
|
|
347
357
|
gitBarOn: '开启',
|
|
348
358
|
gitBarOff: '关闭',
|
|
349
359
|
archiveManager: '归档管理',
|
|
350
|
-
archiveManagerHint: '
|
|
360
|
+
archiveManagerHint: '在设置中显示「归档」页面:恢复或永久删除已归档会话。',
|
|
351
361
|
archiveManagerOn: '开启',
|
|
352
362
|
archiveManagerOff: '关闭',
|
|
353
363
|
mcpManager: 'MCP 管理',
|
|
@@ -446,13 +456,21 @@ const zh: Record<LocaleKey, string> = {
|
|
|
446
456
|
archiveEmpty: '暂无归档会话。',
|
|
447
457
|
archiveRestore: '恢复',
|
|
448
458
|
archiveRestoring: '处理中…',
|
|
459
|
+
archiveConfirmTitle: '永久删除会话?',
|
|
460
|
+
archiveConfirmDescription: '将永久删除共 {count} 条会话记录(含所属子代理),无法撤销。独立分叉、工作区文件与 Git 数据保留。',
|
|
461
|
+
archiveCancel: '取消',
|
|
449
462
|
archiveDelete: '删除',
|
|
450
463
|
archiveDeleteAll: '全部删除',
|
|
464
|
+
archiveSelectAll: '全选',
|
|
465
|
+
archiveSelectedCount: '已选择 {count} 个会话',
|
|
466
|
+
archiveClearSelection: '取消选择',
|
|
467
|
+
archiveDeleteSelected: '删除所选({count})',
|
|
468
|
+
archiveDeleteFailed: '「{title}」:{error}',
|
|
451
469
|
archiveRestoreAll: '全部恢复',
|
|
452
470
|
archiveCount: '个会话',
|
|
453
471
|
archiveUnavailable: '归档暂不可用。',
|
|
454
472
|
archiveLiveError: '该会话正在运行,无法彻底删除,请先关闭该会话。',
|
|
455
|
-
archiveDisabledHint: '
|
|
473
|
+
archiveDisabledHint: '归档管理尚未开启。在「界面调整」中开启“归档管理”后,可在此恢复或永久删除已归档会话。',
|
|
456
474
|
archiveEnable: '开启归档管理',
|
|
457
475
|
archiveRestored: '已恢复。',
|
|
458
476
|
defaultAction: '默认',
|
|
@@ -1395,6 +1413,7 @@ export function apply(ctx: UITweaksClientContext): void {
|
|
|
1395
1413
|
ctx.effect(installArchiveStyles, 'dsh-ui-tweaks: archive styles')
|
|
1396
1414
|
ctx.effect(installMcpStyles, 'dsh-ui-tweaks: mcp styles')
|
|
1397
1415
|
ctx.effect(() => ctx.locale.register(NS, { en, zh }), 'dsh-ui-tweaks: locale')
|
|
1416
|
+
ctx.effect(() => ctx.locale.register(NS, 'ja', uiTweaksArchiveJa), 'dsh-ui-tweaks: archive Japanese locale')
|
|
1398
1417
|
const t = ctx.locale.bind(NS)
|
|
1399
1418
|
|
|
1400
1419
|
const controller = new SettingsClient()
|
|
@@ -1482,7 +1501,7 @@ export function apply(ctx: UITweaksClientContext): void {
|
|
|
1482
1501
|
ctx.effect(() => installHeroChip(controller, t), 'dsh-ui-tweaks: hero branch chip')
|
|
1483
1502
|
|
|
1484
1503
|
// Archive manager: a Settings section ("归档") that lists archived sessions
|
|
1485
|
-
// and
|
|
1504
|
+
// and uses the shared Host operations to restore or delete them. Registered only while the
|
|
1486
1505
|
// archiveManagerEnabled toggle in the UI Tweaks section is on, so the nav
|
|
1487
1506
|
// row appears / disappears live with the switch (the settings shell
|
|
1488
1507
|
// projects its nav from the section ledger).
|
|
@@ -1492,7 +1511,23 @@ export function apply(ctx: UITweaksClientContext): void {
|
|
|
1492
1511
|
order: 50,
|
|
1493
1512
|
label: () => t('archiveNav'),
|
|
1494
1513
|
locale: NS,
|
|
1495
|
-
inject: () => ({ controller, t
|
|
1514
|
+
inject: () => ({ controller, t,
|
|
1515
|
+
restoreSession: async (id: string) => {
|
|
1516
|
+
const service = ctx.workspaces as typeof ctx.workspaces & { unarchiveSession?: (id: SessionId) => Promise<void> }
|
|
1517
|
+
if (service.unarchiveSession === undefined) throw new Error(t('archiveUnavailable'))
|
|
1518
|
+
await service.unarchiveSession(id as SessionId)
|
|
1519
|
+
},
|
|
1520
|
+
previewDeletion: async (id: string) => {
|
|
1521
|
+
const service = ctx.workspaces as typeof ctx.workspaces & { sessionDeletionScope?: (id: SessionId) => Promise<readonly SessionId[]> }
|
|
1522
|
+
if (service.sessionDeletionScope === undefined) throw new Error(t('archiveUnavailable'))
|
|
1523
|
+
return service.sessionDeletionScope(id as SessionId)
|
|
1524
|
+
},
|
|
1525
|
+
deleteSession: async (id: string, scope: readonly string[]) => {
|
|
1526
|
+
const service = ctx.workspaces as typeof ctx.workspaces & { deleteSession?: (id: SessionId, scope: readonly SessionId[]) => Promise<readonly SessionId[]> }
|
|
1527
|
+
if (service.deleteSession === undefined) throw new Error(t('archiveUnavailable'))
|
|
1528
|
+
await service.deleteSession(id as SessionId, scope as readonly SessionId[])
|
|
1529
|
+
},
|
|
1530
|
+
}),
|
|
1496
1531
|
}, ArchiveSection))
|
|
1497
1532
|
|
|
1498
1533
|
// MCP manager: a Settings section ("MCP 管理") that lists the configured MCP
|
package/src/index.ts
CHANGED
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
import { registerTools } from './tools.ts'
|
|
52
52
|
import { AgentOpenRegistry, registerOpenTool, type AgentOpenRequest } from './agent-opens.ts'
|
|
53
53
|
import { CodingPlanCatalogue } from './codingplan.ts'
|
|
54
|
-
import { checkOneUpdate, CHATCODE_UPDATE_PACKAGES, performAllUpdates } from './chatcode-update.ts'
|
|
54
|
+
import { checkOneUpdate, CHATCODE_CLI_PKG, CHATCODE_UPDATE_PACKAGES, installedGlobalVersion, performAllUpdates } from './chatcode-update.ts'
|
|
55
55
|
import { readJsonBody, requireString, SidebarError, writeError, writeJson, writeOk } from './wire.ts'
|
|
56
56
|
import { apply as applyUiTweaksHost } from './ui-tweaks/index.ts'
|
|
57
57
|
import { buildPluginMarketApi } from './plugin-market-api.ts'
|
|
@@ -664,6 +664,9 @@ function buildApi(
|
|
|
664
664
|
'chatcode.start': () => requireChatcodeAuth().startLogin(),
|
|
665
665
|
'chatcode.cancel': payload => requireChatcodeAuth().cancelLogin(requireString(payload, 'sessionId')).then(() => ({ ok: true })),
|
|
666
666
|
'chatcode.logout': () => requireChatcodeAuth().logout().then(() => ({ ok: true })),
|
|
667
|
+
// The globally installed CLI version the sidebar shows beside its wordmark.
|
|
668
|
+
// Reads npm global modules directly (no registry network like chatcode.update.check).
|
|
669
|
+
'chatcode.installed-version': async () => ({ version: await installedGlobalVersion(CHATCODE_CLI_PKG) }),
|
|
667
670
|
// Check both ChatCode packages (web runtime + CLI) against the npm
|
|
668
671
|
// registry and the globally installed version. Runs on the DSH host; a
|
|
669
672
|
// package not globally installed degrades to `current: null`.
|
package/src/ui-tweaks/config.ts
CHANGED
|
@@ -53,7 +53,7 @@ export interface UITweaksConfig {
|
|
|
53
53
|
gitBarEnabled?: boolean
|
|
54
54
|
/**
|
|
55
55
|
* Whether the Archive manager is shown: the "归档" Settings page that lists
|
|
56
|
-
* archived sessions and can restore
|
|
56
|
+
* archived sessions and can restore or confirm permanent deletion through the shared Host. Off by
|
|
57
57
|
* default; users turn it on in Settings.
|
|
58
58
|
*/
|
|
59
59
|
archiveManagerEnabled?: boolean
|