dsh-remote-plugin 0.8.0-rc.9 → 0.8.1
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.en.md +4 -2
- package/README.md +4 -2
- package/apk/dsh-remote.apk +0 -0
- package/client.js +96 -115
- package/file-delivery.mjs +84 -0
- package/gateway.cjs +248 -3
- package/index.mjs +594 -52
- package/insights.mjs +33 -2
- package/package.json +4 -2
- package/plugin-center.mjs +14 -1
- package/public/activity.js +8 -3
- package/public/announcements.json +10 -0
- package/public/app.js +65 -20
- package/public/approval-records.js +75 -3
- package/public/build.json +2 -2
- package/public/desktop/desktop.css +10 -2
- package/public/desktop/desktop.html +24 -4
- package/public/desktop/desktop.js +32 -13
- package/public/extensions.css +109 -1
- package/public/extensions.js +116 -7
- package/public/file-inbox.css +66 -0
- package/public/file-inbox.js +289 -0
- package/public/index.html +26 -9
- package/public/insights.css +5 -0
- package/public/insights.js +40 -11
- package/public/md.js +7 -1
- package/public/plugin-center.css +3 -0
- package/public/plugin-center.js +58 -9
- package/public/plugin.js +21 -6
- package/public/session-deck.css +73 -0
- package/public/session-deck.js +180 -0
- package/public/skills.js +16 -5
- package/public/skins/blue-fish/skin.css +39 -0
- package/public/styles.css +22 -2
- package/public/task-board.js +109 -0
- package/public/teams.js +35 -13
- package/public/update.json +12 -12
- package/public/version.json +1 -1
- package/public/workflow.css +6 -12
- package/skills/dsh-remote-doctor/SKILL.md +16 -0
- package/skills/dsh-remote-doctor/references/wiki/README.md +40 -0
- package/skills/dsh-remote-doctor/references/wiki/ai-guide.md +61 -0
- package/skills/dsh-remote-doctor/references/wiki/connection.md +74 -0
- package/skills/dsh-remote-doctor/references/wiki/errors.md +26 -0
- package/skills/dsh-remote-doctor/references/wiki/evidence.md +44 -0
- package/skills/dsh-remote-doctor/references/wiki/files.md +31 -0
- package/skills/dsh-remote-doctor/references/wiki/maintenance.md +30 -0
- package/skills/dsh-remote-doctor/references/wiki/notifications.md +29 -0
- package/skills/dsh-remote-doctor/references/wiki/operations.md +32 -0
- package/skills/dsh-remote-doctor/references/wiki/plugins.md +90 -0
- package/skills/dsh-remote-doctor/references/wiki/sessions.md +45 -0
- package/skills/dsh-remote-doctor/references/wiki/sources.md +27 -0
- package/task-board.mjs +57 -0
package/public/plugin-center.js
CHANGED
|
@@ -4,9 +4,31 @@ window.DshPluginCenter = (() => {
|
|
|
4
4
|
let dialog, connection, snapshot, timer, generation = 0, pending = false, tab = 'installed', offset = 0, searchSequence = 0, detailSequence = 0
|
|
5
5
|
const expandedDetails = new Map()
|
|
6
6
|
const marketCompatibility = new Map()
|
|
7
|
-
let renderedInstalled = '', renderedJobs = '', filter = '', statusFilter = 'all', refreshSequence = 0, trackedOperation = ''
|
|
7
|
+
let renderedInstalled = '', renderedJobs = '', filter = '', statusFilter = 'all', refreshSequence = 0, trackedOperation = '', experimentalExpanded = false
|
|
8
8
|
const labels = { install: '安装', update: '更新', remove: '卸载', restore: '恢复', enable: '启用', disable: '停用', queued: '等待执行', running: '执行中', complete: '已完成', failed: '失败', interrupted: '已中断', active: '运行中', pending: '等待依赖', loading: '加载中', disposed: '未运行', unloading: '卸载中', inactive: '未运行' }
|
|
9
9
|
const stages = { queued: '等待主机启动', backup: '备份配置', snapshot: '备份插件文件', restore: '恢复并校验', 'profile-lock': '检查配置锁', cli: '执行插件命令', verify: '保存并核验', complete: '完成' }
|
|
10
|
+
function compareVersions(left, right) {
|
|
11
|
+
const parse = value => {
|
|
12
|
+
const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.exec(String(value || '').trim())
|
|
13
|
+
if (!match) return null
|
|
14
|
+
const pre = match[4]?.split('.')
|
|
15
|
+
if (pre?.some(value => /^\d+$/.test(value) && value.length > 1 && value[0] === '0')) return null
|
|
16
|
+
return { core: match.slice(1, 4), pre }
|
|
17
|
+
}
|
|
18
|
+
const a = parse(left), b = parse(right)
|
|
19
|
+
if (!a || !b) return null
|
|
20
|
+
const numeric = (x, y) => x.length !== y.length ? Math.sign(x.length - y.length) : x === y ? 0 : x < y ? -1 : 1
|
|
21
|
+
for (let i = 0; i < 3; i++) { const order = numeric(a.core[i], b.core[i]); if (order) return order }
|
|
22
|
+
if (!a.pre || !b.pre) return a.pre ? -1 : b.pre ? 1 : 0
|
|
23
|
+
for (let i = 0; i < Math.max(a.pre.length, b.pre.length); i++) {
|
|
24
|
+
const x = a.pre[i], y = b.pre[i]
|
|
25
|
+
if (x === y) continue
|
|
26
|
+
if (x === undefined || y === undefined) return x === undefined ? -1 : 1
|
|
27
|
+
const nx = /^\d+$/.test(x), ny = /^\d+$/.test(y)
|
|
28
|
+
return nx && ny ? numeric(x, y) : nx !== ny ? nx ? -1 : 1 : x < y ? -1 : 1
|
|
29
|
+
}
|
|
30
|
+
return 0
|
|
31
|
+
}
|
|
10
32
|
function jobProgress(job) {
|
|
11
33
|
const active = ['queued', 'running'].includes(job.phase), now = Date.now()
|
|
12
34
|
const elapsed = Math.max(0, Math.floor(((active ? now : job.endedAt || now) - job.startedAt) / 1000))
|
|
@@ -57,23 +79,42 @@ window.DshPluginCenter = (() => {
|
|
|
57
79
|
if (description) el.append(node('p', description, 'pc-description'))
|
|
58
80
|
return el
|
|
59
81
|
}
|
|
82
|
+
const experimentalPlugin = item => item.name?.startsWith('@deepseek-ai/dsh-experimental-') === true
|
|
83
|
+
const installedPlugin = item => item.managed || item.name === 'dsh-remote-plugin' || experimentalPlugin(item)
|
|
60
84
|
function renderInstalled() {
|
|
61
|
-
const list = dialog.querySelector('.pc-list'), restore = preserveListPosition(list)
|
|
85
|
+
const list = dialog.querySelector('.pc-list'), restore = preserveListPosition(list)
|
|
86
|
+
experimentalExpanded = list.querySelector('.pc-experimental')?.open ?? experimentalExpanded
|
|
87
|
+
list.replaceChildren()
|
|
62
88
|
if (!snapshot) { list.append(node('p', '尚未读取插件状态,请点击刷新。')); return }
|
|
63
|
-
const rows = snapshot.items.filter(item => tab === 'builtin' ? !item
|
|
89
|
+
const rows = snapshot.items.filter(item => tab === 'builtin' ? !installedPlugin(item) : installedPlugin(item))
|
|
64
90
|
.filter(item => [item.name, item.displayName, item.description].join(' ').toLowerCase().includes(filter.toLowerCase()))
|
|
65
91
|
.filter(item => statusFilter === 'all' || (statusFilter === 'enabled' ? item.enabled : !item.enabled))
|
|
66
92
|
if (!rows.length) list.append(node('p', filter || statusFilter !== 'all' ? '没有匹配的插件。' : tab === 'builtin' ? '暂无内置插件。' : '当前主机没有其他已安装插件。第三方插件可按需选择。', 'pc-empty'))
|
|
93
|
+
const experimentalRows = rows.filter(experimentalPlugin)
|
|
94
|
+
const experimental = node('details', null, 'pc-experimental'), experimentalList = node('div', null, 'pc-list pc-experimental-list')
|
|
95
|
+
experimental.open = experimentalExpanded
|
|
96
|
+
experimental.append(node('summary', '实验性插件(' + experimentalRows.length + ')'), experimentalList)
|
|
97
|
+
experimental.addEventListener('toggle', () => {
|
|
98
|
+
if (list.querySelector('.pc-experimental') === experimental) experimentalExpanded = experimental.open
|
|
99
|
+
})
|
|
67
100
|
for (const item of rows) {
|
|
68
101
|
const el = card(item.displayName || item.name, item.description)
|
|
69
102
|
el.append(node('small', item.name, 'pc-package'))
|
|
70
103
|
const meta = node('div', null, 'pc-meta')
|
|
71
104
|
meta.append(node('span', item.version ? 'v' + item.version : item.requested || '内置', 'pc-version'))
|
|
105
|
+
if (experimentalPlugin(item)) meta.append(node('span', '实验性', 'pc-badge'))
|
|
72
106
|
if (!item.bundle || !item.managed || !snapshot.writable) meta.append(node('span', item.enabled ? '配置启用' : '配置停用', 'pc-badge ' + (item.enabled ? 'is-active' : '')))
|
|
73
107
|
const runtime = item.runtime || []
|
|
74
108
|
if (runtime.some(entry => entry.phase === 'failed')) meta.append(node('span', '运行异常', 'pc-badge is-error'))
|
|
75
109
|
else if (runtime.length) meta.append(node('span', `${runtime.filter(entry => entry.phase === 'active').length}/${runtime.length} 组件运行中`, 'pc-badge'))
|
|
76
110
|
el.append(meta)
|
|
111
|
+
for (const diagnostic of window.DshExtensions?.diagnosticsFor?.(snapshot, item, connection) || []) {
|
|
112
|
+
const status = node('p', (window.I18N?.lang === 'en' ? 'Adapter: ' : '适配:') + diagnostic.label, 'pc-adaptation')
|
|
113
|
+
status.dataset.code = diagnostic.code
|
|
114
|
+
const help = node('a', window.I18N?.lang === 'en' ? 'Troubleshooting' : '插件排障文档')
|
|
115
|
+
help.href = diagnostic.helpUrl; help.target = '_blank'; help.rel = 'noopener noreferrer'
|
|
116
|
+
status.append(node('span', ' · '), help); el.append(status)
|
|
117
|
+
}
|
|
77
118
|
const actions = node('div', null, 'pc-card-actions')
|
|
78
119
|
const area = inlineArea(item.name)
|
|
79
120
|
const detail = button('查看详情', () => installedDetails(item, area, detail)); detail.className = 'pc-detail-button'
|
|
@@ -103,8 +144,10 @@ window.DshPluginCenter = (() => {
|
|
|
103
144
|
detail.setAttribute('aria-controls', area.id)
|
|
104
145
|
renderInline(area, detail, item)
|
|
105
146
|
el.append(actions, area)
|
|
106
|
-
|
|
147
|
+
if (experimentalPlugin(item)) experimentalList.append(el)
|
|
148
|
+
else list.append(el)
|
|
107
149
|
}
|
|
150
|
+
if (experimentalRows.length) list.append(experimental)
|
|
108
151
|
const runtime = node('details', null, 'pc-runtime')
|
|
109
152
|
runtime.append(node('summary', '当前进程实际加载状态 (' + snapshot.runtime.length + ')'))
|
|
110
153
|
if (!snapshot.runtimeAvailable) runtime.append(node('p', '此 DSH 版本未提供加载状态'))
|
|
@@ -163,8 +206,13 @@ window.DshPluginCenter = (() => {
|
|
|
163
206
|
input.addEventListener('input', () => { entry.versionDraft = input.value })
|
|
164
207
|
area.append(input, button('查看此版本', () => showDetails(entry.name, input.value.trim(), area, control, true)))
|
|
165
208
|
const row = snapshot?.items.find(row => row.name === item.name), action = row ? 'update' : 'install'
|
|
166
|
-
const
|
|
167
|
-
|
|
209
|
+
const order = row ? compareVersions(item.version, row.version) : null
|
|
210
|
+
const older = row && order !== null && order < 0, uncertain = row && order === null
|
|
211
|
+
if (older) area.append(node('p', '已安装 v' + row.version + ',高于此版本。若确需降级,请指定版本并点击“查看此版本”。', 'pc-detail-notice'))
|
|
212
|
+
else if (uncertain) area.append(node('p', '无法比较已安装版本与此版本;请指定版本后确认切换。', 'pc-detail-notice'))
|
|
213
|
+
const label = row && order === 0 ? '已安装' : older ? '降级至' : uncertain ? '切换至' : labels[action]
|
|
214
|
+
const install = button(label + ' ' + item.version, () => mutate(action, item.name, item.version))
|
|
215
|
+
install.disabled = !item.bundle || item.protected && !(row?.selfUpdate && action === 'update') || !snapshot?.writable || snapshot.busy || pending || row && order === 0 || (older || uncertain) && !entry.version || marketCompatibility.get(item.name + '@' + item.version) === false
|
|
168
216
|
area.append(install)
|
|
169
217
|
readmeControl(area, item)
|
|
170
218
|
}
|
|
@@ -206,7 +254,7 @@ window.DshPluginCenter = (() => {
|
|
|
206
254
|
dialog.querySelector('.pc-status').textContent = snapshot.reason || (snapshot.pendingRestart ? '插件配置已变更,重启 DSH 后生效。' : '安装到当前连接的 DSH 主机。')
|
|
207
255
|
dialog.querySelector('.pc-status').hidden = !snapshot.reason && !snapshot.pendingRestart
|
|
208
256
|
const summary = dialog.querySelector('.pc-summary'); summary.replaceChildren()
|
|
209
|
-
for (const [count, title] of [[snapshot.items.filter(
|
|
257
|
+
for (const [count, title] of [[snapshot.items.filter(installedPlugin).length, '已安装'], [snapshot.items.filter(item => installedPlugin(item) && item.enabled).length, '配置启用']]) {
|
|
210
258
|
const stat = node('span', null, 'pc-stat'); stat.append(node('strong', String(count)), node('span', title)); summary.append(stat)
|
|
211
259
|
}
|
|
212
260
|
if (snapshot.busy) summary.append(node('span', '任务执行中', 'pc-badge'))
|
|
@@ -216,7 +264,8 @@ window.DshPluginCenter = (() => {
|
|
|
216
264
|
if (snapshot.busyReason) progress.append(node('p', snapshot.busyReason))
|
|
217
265
|
if (snapshot.profileLock) progress.append(node('p', snapshot.profileLock.message))
|
|
218
266
|
progress.hidden = !progress.children.length
|
|
219
|
-
const installedKey = JSON.stringify([snapshot.items, snapshot.runtime, snapshot.runtimeAvailable, snapshot.pendingRestart, snapshot.busy, snapshot.writable,
|
|
267
|
+
const installedKey = JSON.stringify([snapshot.items, snapshot.runtime, snapshot.runtimeAvailable, snapshot.pendingRestart, snapshot.busy, snapshot.writable, snapshot.adaptations,
|
|
268
|
+
snapshot.items.flatMap(item => window.DshExtensions?.diagnosticsFor?.(snapshot, item, connection) || []), pending, tab, filter, statusFilter])
|
|
220
269
|
if (['installed', 'builtin'].includes(tab) && installedKey !== renderedInstalled) { renderInstalled(); renderedInstalled = installedKey }
|
|
221
270
|
renderTabs()
|
|
222
271
|
const jobsKey = JSON.stringify(snapshot.operations.map(job => [job, jobProgress(job)]))
|
|
@@ -520,7 +569,7 @@ window.DshPluginCenter = (() => {
|
|
|
520
569
|
})
|
|
521
570
|
;(target || document.body).append(dialog)
|
|
522
571
|
}
|
|
523
|
-
generation++; searchSequence++; detailSequence++; marketCompatibility.clear(); marketIndex = ''; marketCategory = ''; marketSort = ''; fetchedAt = null; offset = 0; connection = config; tab = 'installed'; pending = false; snapshot = null; filter = ''; statusFilter = 'all'; trackedOperation = ''
|
|
572
|
+
generation++; searchSequence++; detailSequence++; marketCompatibility.clear(); marketIndex = ''; marketCategory = ''; marketSort = ''; fetchedAt = null; offset = 0; connection = config; tab = 'installed'; pending = false; snapshot = null; filter = ''; statusFilter = 'all'; trackedOperation = ''; experimentalExpanded = false
|
|
524
573
|
const current = generation
|
|
525
574
|
renderedInstalled = ''; renderedJobs = ''
|
|
526
575
|
dialog.querySelector('.pc-market-tools').hidden = true
|
package/public/plugin.js
CHANGED
|
@@ -55,6 +55,16 @@ function setBusy(value) {
|
|
|
55
55
|
function render(st) {
|
|
56
56
|
latest = st
|
|
57
57
|
setup?.update(st)
|
|
58
|
+
/** 网关解释器来源说明:Windows 上必须位于 DSH 安装目录之外,否则 DSH 更新会被占用。 */
|
|
59
|
+
function runtimeNote(runtime) {
|
|
60
|
+
if (!runtime) return ''
|
|
61
|
+
if (runtime.source === 'unknown') return ' · 网关解释器待确认'
|
|
62
|
+
if (runtime.insideInstallDir) return ' · 网关解释器位于 DSH 安装目录内,DSH 更新可能失败'
|
|
63
|
+
const label = runtime.source === 'env' ? 'DSH_REMOTE_NODE'
|
|
64
|
+
: runtime.source === 'path' ? 'PATH'
|
|
65
|
+
: runtime.source === 'desktop-runtime' ? '内置副本' : runtime.source === 'external' ? '外部 node' : '宿主 node'
|
|
66
|
+
return ' · node ' + (runtime.version || '?') + '(' + label + ')'
|
|
67
|
+
}
|
|
58
68
|
const gateway = st.mode === 'gateway' || st.gatewayRunning === true
|
|
59
69
|
const authError = st.gatewayAuthError || ''
|
|
60
70
|
const healthy = st.mode === 'gateway' && !authError && st.upstream?.reachable === true
|
|
@@ -80,7 +90,10 @@ function render(st) {
|
|
|
80
90
|
$('plugin-toggle-icon')?.setAttribute('data-morph-state', gateway ? 'open' : 'closed')
|
|
81
91
|
$('plugin-toggle')?.classList.toggle('hidden', !installed)
|
|
82
92
|
|
|
83
|
-
text('plugin-version', st.version ? 'v' + st.version : '—')
|
|
93
|
+
text('plugin-version', (st.version ? 'v' + st.version : '—') + runtimeNote(st.gatewayRuntime))
|
|
94
|
+
if ($('plugin-version')) {
|
|
95
|
+
$('plugin-version').title = st.gatewayRuntime?.warning || st.gatewayRuntime?.executable || ''
|
|
96
|
+
}
|
|
84
97
|
text('plugin-gateway-version', gateway ? ('v' + (st.gatewayVersion || st.version || '未知')) : '未运行')
|
|
85
98
|
text('plugin-devices', `${st.onlineCount || 0} / ${st.deviceCount || 0}`)
|
|
86
99
|
text('plugin-host', (st.lanIPs || []).find(x => x && x !== '127.0.0.1') || st.host || '127.0.0.1')
|
|
@@ -188,9 +201,11 @@ $('plugin-primary').addEventListener('click', () => {
|
|
|
188
201
|
else openConsole()
|
|
189
202
|
})
|
|
190
203
|
|
|
191
|
-
|
|
192
|
-
|
|
204
|
+
const panelIsVisible = () => document.visibilityState !== 'hidden'
|
|
205
|
+
if (panelIsVisible()) load()
|
|
206
|
+
setInterval(() => { if (panelIsVisible()) void load() }, 5000)
|
|
193
207
|
$('plugin-usage-refresh').addEventListener('click', loadUsage)
|
|
194
|
-
loadUsage()
|
|
195
|
-
setInterval(() => { if (
|
|
196
|
-
|
|
208
|
+
if (panelIsVisible()) loadUsage()
|
|
209
|
+
setInterval(() => { if (panelIsVisible() && Date.now() - usageLoadedAt >= 30000) void loadUsage() }, 30000)
|
|
210
|
+
const resumePanel = () => { if (panelIsVisible()) { void load(); if (Date.now() - usageLoadedAt >= 30000) void loadUsage() } }
|
|
211
|
+
document.addEventListener('visibilitychange', resumePanel)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/* One visible context card, with the rest suggested by the stacked edges. */
|
|
2
|
+
.session-deck,.session-deck-stage { display:contents; }
|
|
3
|
+
.session-deck[hidden],.session-deck-stage[hidden] { display:none !important; }
|
|
4
|
+
.session-deck[data-mounted] { --deck-card-height:156px; display:block; flex:none; min-width:0; margin:0 0 8px; }
|
|
5
|
+
.ds-view .session-deck[data-mounted] { margin:10px 22px 12px; }
|
|
6
|
+
.session-deck-head { display:flex; align-items:center; gap:6px; min-height:36px; margin-bottom:4px; }
|
|
7
|
+
.session-deck-tabs { display:flex; flex:1; min-width:0; gap:5px; overflow-x:auto; scrollbar-width:none; padding:2px; }
|
|
8
|
+
.session-deck-tabs::-webkit-scrollbar { display:none; }
|
|
9
|
+
.session-deck-tab,.session-deck-control { flex:none; display:inline-flex; align-items:center; justify-content:center; gap:4px; min-height:36px; padding:5px 9px; border:1px solid var(--dsr-line); border-radius:10px; background:var(--dsr-panel); color:var(--dsr-muted); font:inherit; font-size:12px; cursor:pointer; touch-action:manipulation; }
|
|
10
|
+
.session-deck-tab small { min-width:16px; padding:1px 4px; border-radius:6px; background:var(--dsr-bg-2); font-size:10px; }
|
|
11
|
+
.session-deck-tab.needs-action { color:var(--dsr-warning); border-color:var(--dsr-warning-line); }
|
|
12
|
+
.session-deck-tab[aria-pressed="true"] { color:var(--dsr-accent-strong); border-color:var(--dsr-accent-line); background:var(--dsr-accent-soft); font-weight:700; }
|
|
13
|
+
.session-deck-controls { display:flex; align-items:center; flex:none; gap:2px; }
|
|
14
|
+
.session-deck-control { width:30px; padding:2px; font-size:19px; background:transparent; border-color:transparent; }
|
|
15
|
+
.session-deck-position { min-width:28px; text-align:center; color:var(--dsr-muted); font-size:10px; font-variant-numeric:tabular-nums; }
|
|
16
|
+
.session-deck-control:disabled { opacity:.28; cursor:default; }
|
|
17
|
+
.session-deck-tab:focus-visible,.session-deck-control:focus-visible,.session-deck-stage:focus-visible { outline:2px solid var(--dsr-accent); outline-offset:2px; }
|
|
18
|
+
.session-deck[data-mounted] .session-deck-stage { display:block; position:relative; min-width:0; isolation:isolate; touch-action:pan-y pinch-zoom; }
|
|
19
|
+
.session-deck[data-multiple="true"][data-folded="false"] { padding-bottom:8px; }
|
|
20
|
+
.session-deck[data-multiple="true"] .session-deck-stage::before,.session-deck[data-multiple="true"] .session-deck-stage::after { content:""; position:absolute; z-index:-1; inset:7px 7px -4px; border:1px solid var(--dsr-line); border-radius:13px; background:var(--dsr-bg-2); pointer-events:none; }
|
|
21
|
+
.session-deck[data-multiple="true"] .session-deck-stage::before { inset:12px 14px -8px; opacity:.65; }
|
|
22
|
+
.session-deck[data-mounted] #session-cards,.session-deck[data-mounted] .session-attention,.session-deck[data-mounted] #session-pending:not(.hidden),.session-deck[data-mounted] #file-inbox-session:not([hidden]),.session-deck[data-mounted] .session-pending-list,.session-deck[data-mounted] .ds-session-pending-list,.session-deck[data-mounted] #file-inbox-session > .file-inbox-list { display:contents; }
|
|
23
|
+
.session-deck[data-mounted] .session-pending-head,.session-deck[data-mounted] .ds-session-pending-head,.session-deck[data-mounted] #file-inbox-session > .file-inbox-head { display:none; }
|
|
24
|
+
.session-deck[data-mounted] [data-deck-card] { display:none !important; }
|
|
25
|
+
.session-deck[data-mounted] [data-deck-card][data-deck-active] { display:block !important; position:relative; width:100%; min-width:0; max-height:var(--deck-card-height); overflow-y:auto; overscroll-behavior:contain; box-sizing:border-box; margin:0; transform:translateX(var(--deck-drag,0px)); border-radius:13px; scrollbar-width:thin; }
|
|
26
|
+
/* A scroll container terminates touch-action ancestor lookup: include cards and nested scrollers. */
|
|
27
|
+
.session-deck [data-deck-card],.session-deck [data-deck-card] * { touch-action:pan-y pinch-zoom; }
|
|
28
|
+
.session-deck [data-deck-kind="goal"] > .goal-card,.session-deck [data-deck-kind="goal"] > .ds-goal-card { margin:0; box-sizing:border-box; }
|
|
29
|
+
.session-deck[data-mounted] [data-deck-kind="goal"][data-deck-active] { display:flex !important; justify-content:flex-end; }
|
|
30
|
+
.session-deck[data-mounted] [data-deck-card][data-deck-active]:has(details[open]) { max-height:min(48dvh,360px); }
|
|
31
|
+
.session-deck #queue-dock .queue-dock-list,.session-deck #queue-dock .ds-queue-dock-list { max-height:none; }
|
|
32
|
+
.session-deck [data-deck-card] .pc-desc,.session-deck [data-deck-card] .ds-notif-body { max-height:72px; overflow-y:auto; }
|
|
33
|
+
.session-deck .goal-card,.session-deck .ds-goal-card,.session-deck .pending-card,.session-deck .ds-notif-card { padding:10px; }
|
|
34
|
+
.session-deck .goal-obj,.session-deck .ds-goal-obj,.deck-summary-text { display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; font-size:13px; line-height:1.45; overflow-wrap:anywhere; }
|
|
35
|
+
.session-deck .goal-card-head,.session-deck .ds-goal-card-head { margin-bottom:4px; }
|
|
36
|
+
.session-deck .goal-card-head .card-title,.session-deck .ds-goal-card-head .ds-card-title { font-size:11px; color:var(--dsr-muted); text-transform:none; }
|
|
37
|
+
.session-deck .goal-actions,.session-deck .ds-goal-actions { gap:6px; margin-top:6px; align-items:flex-start; }
|
|
38
|
+
.session-deck .goal-actions > [data-goal],.session-deck .ds-goal-actions > [data-goal] { flex:none; min-height:34px; padding:5px 11px; }
|
|
39
|
+
.deck-context-head { display:flex; align-items:center; gap:8px; margin-bottom:4px; color:var(--dsr-muted); font-size:11px; }
|
|
40
|
+
.deck-more { min-width:0; margin:0; font-size:11px; color:var(--dsr-muted); }
|
|
41
|
+
.deck-more > summary { display:flex; align-items:center; justify-content:center; min-height:34px; padding:0 6px; cursor:pointer; color:var(--dsr-muted); list-style:none; }
|
|
42
|
+
.deck-more > summary::-webkit-details-marker { display:none; }
|
|
43
|
+
.deck-more > summary::after { content:'⌄'; margin-left:5px; }
|
|
44
|
+
.deck-more[open] > summary::after { content:'⌃'; }
|
|
45
|
+
.deck-more[open] { flex-basis:100%; order:3; }
|
|
46
|
+
.session-deck .goal-actions > .deck-more,.session-deck .ds-goal-actions > .deck-more { margin-left:auto; }
|
|
47
|
+
.deck-full-content { margin:5px 0 0; max-height:240px; overflow:auto; white-space:pre-wrap; overflow-wrap:anywhere; font:inherit; line-height:1.6; text-align:left; color:var(--dsr-text); }
|
|
48
|
+
.deck-full-content p { margin:4px 0; }
|
|
49
|
+
.deck-task-state { display:inline-block; margin-right:6px; color:var(--dsr-muted); font-size:11px; }
|
|
50
|
+
.deck-review-head { display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:13px; }
|
|
51
|
+
.deck-review-head strong { min-width:0; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
|
|
52
|
+
.deck-review-badge { flex:none; color:var(--dsr-warning); font-size:10px; }
|
|
53
|
+
.deck-review-reason { display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; margin:4px 0; font-size:12px; line-height:1.45; color:var(--dsr-text); overflow-wrap:anywhere; }
|
|
54
|
+
.deck-argument-preview { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--dsr-muted); font-size:11px; line-height:1.5; }
|
|
55
|
+
.deck-review-footer { display:flex; flex-wrap:wrap; align-items:flex-start; gap:6px; margin-top:7px; }
|
|
56
|
+
.deck-review-footer > .deck-more { margin-left:auto; }
|
|
57
|
+
.deck-decision { min-height:36px; padding:5px 11px; border:1px solid var(--dsr-line); border-radius:9px; background:var(--dsr-panel); color:var(--dsr-text); font:inherit; font-size:12px; cursor:pointer; }
|
|
58
|
+
.deck-decision.primary { color:var(--dsr-accent-strong); background:var(--dsr-accent-soft); border-color:var(--dsr-accent-line); }
|
|
59
|
+
.deck-decision:focus-visible,.deck-more > summary:focus-visible { outline:2px solid var(--dsr-accent); outline-offset:2px; }
|
|
60
|
+
.session-deck .question-summary,.session-deck .ds-question-summary { -webkit-line-clamp:2; }
|
|
61
|
+
@media(min-width:900px) {
|
|
62
|
+
.ds-view .session-deck [data-session-approval][data-deck-active]:not(:has(details[open])) { display:grid !important; grid-template-columns:minmax(0,1fr) auto; column-gap:18px; }
|
|
63
|
+
.ds-view .session-deck .deck-review-head,.ds-view .session-deck .deck-review-reason,.ds-view .session-deck .deck-argument-preview { grid-column:1; }
|
|
64
|
+
.ds-view .session-deck .deck-review-footer { grid-column:2; grid-row:1 / 4; align-self:center; margin:0; }
|
|
65
|
+
.ds-view .session-deck .goal-card:not(:has(details[open])),.ds-view .session-deck .ds-goal-card:not(:has(details[open])) { display:grid; grid-template-columns:minmax(0,1fr) auto; column-gap:18px; }
|
|
66
|
+
.ds-view .session-deck .ds-goal-card-head,.ds-view .session-deck .ds-goal-obj { grid-column:1; }
|
|
67
|
+
.ds-view .session-deck .ds-goal-card > .ds-goal-actions { grid-column:2; grid-row:1 / 3; align-self:center; margin:0; }
|
|
68
|
+
.ds-view .session-deck [data-deck-kind="todos"][data-deck-active]:not(:has(details[open])) { display:grid !important; grid-template-columns:minmax(0,1fr) auto; column-gap:18px; }
|
|
69
|
+
.ds-view .session-deck [data-deck-kind="todos"] > .deck-context-head,.ds-view .session-deck [data-deck-kind="todos"] > .deck-summary-text { grid-column:1; }
|
|
70
|
+
.ds-view .session-deck [data-deck-kind="todos"] > .deck-more { grid-column:2; grid-row:1 / 3; align-self:center; }
|
|
71
|
+
}
|
|
72
|
+
.session-deck-sr { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
|
|
73
|
+
@media(max-width:360px) { .session-deck-tab { padding:5px 7px; font-size:11px; } .session-deck-control { width:26px; } }
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/* Conversation context cards. Original nodes and their action handlers stay in place. */
|
|
2
|
+
;(function (root) {
|
|
3
|
+
'use strict'
|
|
4
|
+
const priority = { approval: 0, question: 1, file: 2, queue: 3, goal: 4, todos: 5 }
|
|
5
|
+
function createSelection() {
|
|
6
|
+
let rows = [], selected = '', scope = '', scopeSet = false
|
|
7
|
+
const remembered = new Map()
|
|
8
|
+
return {
|
|
9
|
+
get rows() { return rows }, get index() { return rows.findIndex(row => row.key === selected) },
|
|
10
|
+
sync(next, nextScope) {
|
|
11
|
+
const previousIndex = this.index, previousKind = rows[previousIndex]?.kind, changed = !scopeSet || scope !== nextScope
|
|
12
|
+
if (changed) {
|
|
13
|
+
if (scopeSet && selected) remembered.set(scope, selected)
|
|
14
|
+
while (remembered.size > 12) remembered.delete(remembered.keys().next().value)
|
|
15
|
+
scope = nextScope; scopeSet = true; selected = remembered.get(scope) || ''
|
|
16
|
+
}
|
|
17
|
+
rows = next
|
|
18
|
+
if (!rows.some(row => row.key === selected)) {
|
|
19
|
+
const sameKind = !changed && rows.find(row => row.kind === previousKind)
|
|
20
|
+
const preferred = changed || previousIndex < 0 ? [...rows].sort((a, b) => priority[a.kind] - priority[b.kind])[0] : rows[Math.min(previousIndex, rows.length - 1)]
|
|
21
|
+
selected = (sameKind || preferred)?.key || ''
|
|
22
|
+
}
|
|
23
|
+
return this.index
|
|
24
|
+
},
|
|
25
|
+
select(index) { if (rows.length) selected = rows[Math.max(0, Math.min(index, rows.length - 1))].key; return this.index },
|
|
26
|
+
reset() { rows = []; selected = ''; scope = ''; scopeSet = false; remembered.clear() },
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const text = (zh, en) => root.I18N?.lang === 'en' ? en : zh
|
|
30
|
+
const esc = value => String(value ?? '').replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]))
|
|
31
|
+
const goalState = phase => ({ active: text('进行中', 'In progress'), paused: text('已暂停', 'Paused'), blocked: text('等待处理', 'Blocked'), complete: text('已完成', 'Complete') })[phase] || String(phase || text('状态未知', 'Unknown state'))
|
|
32
|
+
function taskView(items) {
|
|
33
|
+
const done = items.filter(item => item.status === 'completed').length
|
|
34
|
+
return { done, total: items.length, current: items.find(item => item.status === 'in_progress') || items.find(item => item.status !== 'completed') }
|
|
35
|
+
}
|
|
36
|
+
function taskHtml(items) {
|
|
37
|
+
const view = taskView(items), status = value => ({ completed: text('已完成', 'Done'), in_progress: text('进行中', 'In progress'), pending: text('待开始', 'Pending') })[value] || value
|
|
38
|
+
return `<div class="deck-context-head"><strong>${view.done}/${view.total} ${text('已完成', 'done')}</strong></div><div class="deck-summary-text">${view.current ? esc((view.current.status === 'in_progress' ? text('正在:', 'Now: ') : text('下一步:', 'Next: ')) + (view.current.content || text('未命名任务', 'Untitled task'))) : text('全部任务已完成', 'All tasks completed')}</div><details class="deck-more" data-deck-details="tasks"><summary>${text('全部任务', 'All tasks')}</summary><div class="deck-full-content">${items.map(item => `<p><span class="deck-task-state">${esc(status(item.status))}</span>${esc(item.content || '')}</p>`).join('')}</div></details>`
|
|
39
|
+
}
|
|
40
|
+
function approvalHtml(item, fullDetail) {
|
|
41
|
+
const info = root.DshApprovalRecords?.summary(item) || { kind: 'request', text: item.reason || '' }
|
|
42
|
+
const reason = info.kind === 'auto' && root.I18N?.lang !== 'en' ? root.DshApprovalRecords?.chineseReference(info.text) || info.text : info.text
|
|
43
|
+
const permission = info.target ? ({ 'danger-full-access': text('完整访问', 'Full access'), 'workspace-write': text('工作区写入', 'Workspace write'), 'read-only': text('只读', 'Read only') })[info.target] || info.target : ''
|
|
44
|
+
const badge = info.kind === 'auto' ? text('审查未通过', 'Review denied') : info.kind === 'escalation' ? text('申请:', 'Request: ') + permission : ''
|
|
45
|
+
const args = item.arguments
|
|
46
|
+
let preview = ''
|
|
47
|
+
if (args && typeof args === 'object') {
|
|
48
|
+
for (const key of ['command', 'cmd', 'script', 'path', 'file_path', 'url']) if (typeof args[key] === 'string' && args[key]) { preview = (['command', 'cmd', 'script'].includes(key) ? text('命令', 'Command') : key === 'url' ? text('地址', 'URL') : text('路径', 'Path')) + ': ' + args[key]; break }
|
|
49
|
+
} else if (typeof args === 'string') preview = args
|
|
50
|
+
return `<div class="deck-review-head"><strong>${esc(item.toolName || text('工具调用', 'Tool call'))}</strong>${badge ? `<span class="deck-review-badge">${esc(badge)}</span>` : ''}</div><p class="deck-review-reason">${esc(reason || text('主机未提供申请原因', 'The host provided no reason'))}</p>${preview ? `<div class="deck-argument-preview" title="${esc(preview)}">${esc(preview)}</div>` : ''}<div class="deck-review-footer"><button type="button" class="deck-decision primary" data-session-approve="1">${text('允许一次', 'Allow once')}</button><button type="button" class="deck-decision" data-session-approve="0">${text('拒绝', 'Reject')}</button><details class="deck-more" data-deck-details="approval"><summary>${text('完整请求', 'Full request')}</summary><pre class="deck-full-content">${esc(text('工具:', 'Tool: ') + (item.toolName || '') + '\n' + fullDetail)}</pre></details></div>`
|
|
51
|
+
}
|
|
52
|
+
let instance
|
|
53
|
+
function mount(config) {
|
|
54
|
+
if (instance || !root.document) return instance
|
|
55
|
+
const doc = root.document, deck = doc.getElementById('session-deck')
|
|
56
|
+
if (!deck) return
|
|
57
|
+
const stage = deck.querySelector('.session-deck-stage'), sources = ['session-cards', 'queue-dock', 'session-pending', 'file-inbox-session'].map(id => doc.getElementById(id)).filter(Boolean)
|
|
58
|
+
const selection = createSelection(), labels = () => ({ goal: text('目标', 'Goal'), todos: text('任务', 'Tasks'), approval: text('审批', 'Approvals'), question: text('提问', 'Questions'), file: text('文件', 'Files'), queue: text('队列', 'Queue') })
|
|
59
|
+
const make = (tag, cls, value) => { const el = doc.createElement(tag); el.className = cls; if (value != null) el.textContent = value; return el }
|
|
60
|
+
const control = (name, value, fn) => { const el = make('button', 'session-deck-control', value); el.type = 'button'; el.setAttribute('aria-label', name); el.addEventListener('click', fn); return el }
|
|
61
|
+
const header = make('div', 'session-deck-head'), tabs = make('div', 'session-deck-tabs'), controls = make('div', 'session-deck-controls'), count = make('span', 'session-deck-position')
|
|
62
|
+
const notice = make('span', 'session-deck-sr'); notice.setAttribute('role', 'status'); notice.setAttribute('aria-live', 'polite')
|
|
63
|
+
tabs.setAttribute('role', 'group'); tabs.setAttribute('aria-label', text('会话卡片分类', 'Conversation card categories'))
|
|
64
|
+
const previous = control(text('上一张卡片', 'Previous card'), '‹', () => move(-1)), next = control(text('下一张卡片', 'Next card'), '›', () => move(1))
|
|
65
|
+
const fold = control(text('收起卡片', 'Collapse cards'), '⌃', () => { folded = !folded; paint() }); fold.setAttribute('aria-controls', 'session-deck-stage')
|
|
66
|
+
controls.append(previous, count, next, fold); header.append(tabs, controls); deck.prepend(header, notice)
|
|
67
|
+
deck.setAttribute('role', 'region'); deck.setAttribute('aria-label', text('会话卡片,可左右切换', 'Conversation cards, switch left or right')); stage.tabIndex = 0
|
|
68
|
+
let folded = false, lastScope = '', lastTabs = '', destroyed = false, queued = false, gesture = null, suppressClickUntil = 0
|
|
69
|
+
const disclosures = new Map()
|
|
70
|
+
const visibleSource = el => el && !el.hidden && !el.classList.contains('hidden')
|
|
71
|
+
function collect() {
|
|
72
|
+
const rows = []
|
|
73
|
+
const add = (el, kind, id) => rows.push({ el, kind, key: kind + ':' + id })
|
|
74
|
+
const cards = doc.getElementById('session-cards')
|
|
75
|
+
for (const el of cards?.children || []) add(el, el.dataset.deckKind || 'todos', el.dataset.deckKind || 'todos')
|
|
76
|
+
const pending = doc.getElementById('session-pending')
|
|
77
|
+
if (visibleSource(pending)) for (const el of pending.querySelectorAll('[data-session-approval],[data-session-question]')) {
|
|
78
|
+
const approval = el.dataset.sessionApproval
|
|
79
|
+
add(el, approval != null ? 'approval' : 'question', approval ?? el.dataset.sessionQuestion)
|
|
80
|
+
}
|
|
81
|
+
const files = doc.getElementById('file-inbox-session')
|
|
82
|
+
if (visibleSource(files)) for (const el of files.querySelectorAll('[data-transfer-id]')) add(el, 'file', el.dataset.transferId)
|
|
83
|
+
const queue = doc.getElementById('queue-dock')
|
|
84
|
+
if (visibleSource(queue) && queue.children.length) { add(queue, 'queue', 'queue'); rows[rows.length - 1].count = queue.querySelectorAll('[data-queue-steer]').length || 1 }
|
|
85
|
+
return rows
|
|
86
|
+
}
|
|
87
|
+
function refresh() {
|
|
88
|
+
if (destroyed) return
|
|
89
|
+
const context = config.context()
|
|
90
|
+
if (!context.inChat || !context.sessionId) { deck.hidden = true; return }
|
|
91
|
+
const changed = lastScope !== context.sessionId
|
|
92
|
+
if (changed) { folded = false; lastScope = context.sessionId; cancelGesture() }
|
|
93
|
+
const rows = collect(); selection.sync(rows, context.sessionId)
|
|
94
|
+
deck.hidden = !rows.length
|
|
95
|
+
if (rows.length) paint()
|
|
96
|
+
}
|
|
97
|
+
function paint() {
|
|
98
|
+
const rows = selection.rows, index = selection.index, names = labels(), counts = {}
|
|
99
|
+
for (const [i, row] of rows.entries()) {
|
|
100
|
+
row.el.dataset.deckCard = row.key
|
|
101
|
+
row.el.toggleAttribute('data-deck-active', i === index)
|
|
102
|
+
row.el.inert = i !== index || folded
|
|
103
|
+
row.el.setAttribute('aria-hidden', String(i !== index || folded))
|
|
104
|
+
for (const detail of row.el.querySelectorAll('details[data-deck-details]')) detail.open = disclosures.has(lastScope + ':' + row.key + ':' + detail.dataset.deckDetails)
|
|
105
|
+
counts[row.kind] = (counts[row.kind] || 0) + (row.count || 1)
|
|
106
|
+
}
|
|
107
|
+
deck.dataset.folded = String(folded); stage.hidden = folded; deck.dataset.multiple = String(rows.length > 1)
|
|
108
|
+
previous.disabled = index <= 0; next.disabled = index >= rows.length - 1
|
|
109
|
+
count.textContent = rows.length ? (index + 1) + '/' + rows.length : ''
|
|
110
|
+
fold.textContent = folded ? '⌄' : '⌃'; fold.setAttribute('aria-expanded', String(!folded)); fold.setAttribute('aria-label', folded ? text('展开卡片', 'Expand cards') : text('收起卡片', 'Collapse cards'))
|
|
111
|
+
const signature = JSON.stringify([counts, rows[index]?.kind, root.I18N?.lang])
|
|
112
|
+
if (signature !== lastTabs) {
|
|
113
|
+
const focused = tabs.contains(doc.activeElement) ? doc.activeElement?.dataset.deckTab : ''
|
|
114
|
+
tabs.replaceChildren()
|
|
115
|
+
for (const kind of ['approval', 'question', 'file', 'goal', 'todos', 'queue']) if (counts[kind]) {
|
|
116
|
+
const el = control(names[kind], '', () => { folded = false; select(selection.rows.findIndex(row => row.kind === kind)) })
|
|
117
|
+
el.className = 'session-deck-tab' + (priority[kind] < 3 ? ' needs-action' : ''); el.dataset.deckTab = kind
|
|
118
|
+
el.setAttribute('aria-pressed', String(rows[index]?.kind === kind)); el.append(make('span', '', names[kind]))
|
|
119
|
+
if (priority[kind] < 3 || kind === 'queue') el.append(make('small', '', String(counts[kind])))
|
|
120
|
+
tabs.append(el)
|
|
121
|
+
}
|
|
122
|
+
tabs.querySelectorAll('[data-deck-tab]').forEach(el => { if (el.dataset.deckTab === focused) el.focus({ preventScroll: true }) })
|
|
123
|
+
lastTabs = signature
|
|
124
|
+
}
|
|
125
|
+
notice.textContent = Object.entries(counts).filter(([kind]) => priority[kind] < 3).map(([kind, n]) => names[kind] + ' ' + n).join(',')
|
|
126
|
+
}
|
|
127
|
+
function select(index) { cancelGesture(); selection.select(index); paint() }
|
|
128
|
+
function move(delta) { folded = false; select(selection.index + delta) }
|
|
129
|
+
function cancelGesture() { gesture = null; stage.style.removeProperty('--deck-drag') }
|
|
130
|
+
function down(event) {
|
|
131
|
+
if (selection.rows.length < 2 || event.isPrimary === false || event.button > 0 || event.target.closest('input,textarea,select,a,[contenteditable="true"]')) return
|
|
132
|
+
gesture = { id: event.pointerId, x: event.clientX, y: event.clientY, dx: 0, claimed: false }
|
|
133
|
+
}
|
|
134
|
+
function drag(event) {
|
|
135
|
+
if (!gesture || event.pointerId !== gesture.id) return
|
|
136
|
+
const dx = event.clientX - gesture.x, dy = event.clientY - gesture.y
|
|
137
|
+
if (!gesture.claimed) {
|
|
138
|
+
if (Math.abs(dy) > 10 && Math.abs(dy) >= Math.abs(dx)) { cancelGesture(); return }
|
|
139
|
+
if (Math.abs(dx) < 10 || Math.abs(dx) < Math.abs(dy) * 1.2) return
|
|
140
|
+
gesture.claimed = true; stage.setPointerCapture?.(event.pointerId)
|
|
141
|
+
}
|
|
142
|
+
gesture.dx = dx
|
|
143
|
+
if (event.cancelable) event.preventDefault()
|
|
144
|
+
stage.style.setProperty('--deck-drag', Math.max(-72, Math.min(72, dx)) + 'px')
|
|
145
|
+
}
|
|
146
|
+
function up(event) {
|
|
147
|
+
if (!gesture || event.pointerId !== gesture.id) return
|
|
148
|
+
const { dx, claimed } = gesture
|
|
149
|
+
cancelGesture()
|
|
150
|
+
if (stage.hasPointerCapture?.(event.pointerId)) stage.releasePointerCapture(event.pointerId)
|
|
151
|
+
if (claimed) { suppressClickUntil = Date.now() + 400; if (Math.abs(dx) >= 42) move(dx < 0 ? 1 : -1) }
|
|
152
|
+
}
|
|
153
|
+
function click(event) { if (Date.now() < suppressClickUntil) { event.preventDefault(); event.stopPropagation() } }
|
|
154
|
+
function disclosure(event) {
|
|
155
|
+
const detail = event.target, card = detail.closest('[data-deck-card]')
|
|
156
|
+
if (!detail.dataset.deckDetails || !card) return
|
|
157
|
+
const key = lastScope + ':' + card.dataset.deckCard + ':' + detail.dataset.deckDetails
|
|
158
|
+
if (detail.open) disclosures.set(key, true); else disclosures.delete(key)
|
|
159
|
+
while (disclosures.size > 64) disclosures.delete(disclosures.keys().next().value)
|
|
160
|
+
}
|
|
161
|
+
function key(event) {
|
|
162
|
+
if (event.target !== stage && !tabs.contains(event.target)) return
|
|
163
|
+
const index = event.key === 'ArrowLeft' ? selection.index - 1 : event.key === 'ArrowRight' ? selection.index + 1 : event.key === 'Home' ? 0 : event.key === 'End' ? selection.rows.length - 1 : null
|
|
164
|
+
if (index != null) { event.preventDefault(); folded = false; select(index) }
|
|
165
|
+
}
|
|
166
|
+
const observer = new root.MutationObserver(() => { if (!queued) { queued = true; root.queueMicrotask(() => { queued = false; refresh() }) } })
|
|
167
|
+
for (const source of sources) observer.observe(source, { childList: true, subtree: true, attributes: true, attributeFilter: ['hidden', 'class'], characterData: true })
|
|
168
|
+
stage.addEventListener('pointerdown', down); stage.addEventListener('pointermove', drag); stage.addEventListener('pointerup', up); stage.addEventListener('pointercancel', cancelGesture); stage.addEventListener('click', click, true); stage.addEventListener('toggle', disclosure, true); deck.addEventListener('keydown', key)
|
|
169
|
+
deck.dataset.mounted = 'true'
|
|
170
|
+
instance = { refresh, reset() { selection.reset(); disclosures.clear(); lastScope = ''; lastTabs = ''; folded = false; cancelGesture(); deck.hidden = true }, destroy() {
|
|
171
|
+
destroyed = true; observer.disconnect(); cancelGesture(); header.remove(); notice.remove(); delete deck.dataset.mounted
|
|
172
|
+
for (const row of selection.rows) { delete row.el.dataset.deckCard; delete row.el.dataset.deckActive; row.el.inert = false; row.el.removeAttribute('aria-hidden') }
|
|
173
|
+
for (const [name, handler] of [['pointerdown', down], ['pointermove', drag], ['pointerup', up], ['pointercancel', cancelGesture]]) stage.removeEventListener(name, handler)
|
|
174
|
+
stage.removeEventListener('click', click, true); stage.removeEventListener('toggle', disclosure, true); deck.removeEventListener('keydown', key); stage.hidden = false; instance = null
|
|
175
|
+
} }
|
|
176
|
+
refresh(); return instance
|
|
177
|
+
}
|
|
178
|
+
root.DshSessionDeck = { createSelection, goalState, taskView, taskHtml, approvalHtml, mount, refresh: () => instance?.refresh(), reset: () => instance?.reset() }
|
|
179
|
+
if (typeof module !== 'undefined') module.exports = root.DshSessionDeck
|
|
180
|
+
})(typeof window !== 'undefined' ? window : globalThis)
|
package/public/skills.js
CHANGED
|
@@ -39,9 +39,11 @@ window.DshSkillsCenter = (() => {
|
|
|
39
39
|
signal: AbortSignal.any([s.controller.signal, AbortSignal.timeout(25000)]) })
|
|
40
40
|
if (!live(s)) throw new Error('连接已切换,请重新打开技能中心。')
|
|
41
41
|
let data
|
|
42
|
-
try { data = await response.json() } catch { throw new Error('主机 Remote 尚不支持技能中心,请更新主机插件。') }
|
|
42
|
+
try { data = await response.json() } catch { throw Object.assign(new Error('主机 Remote 尚不支持技能中心,请更新主机插件。'), { code: 'unsupported' }) }
|
|
43
43
|
if (!live(s)) throw new Error('连接已切换,请重新打开技能中心。')
|
|
44
|
-
if (!response.ok || data.ok === false || data.available === false)
|
|
44
|
+
if (!response.ok || data.ok === false || data.available === false) {
|
|
45
|
+
throw Object.assign(new Error(errors[data.code] || '请求失败,请检查连接后重试。'), { code: response.status === 401 || response.status === 403 ? 'host-denied' : data.code || (response.status === 404 ? 'not-installed' : 'read-failed') })
|
|
46
|
+
}
|
|
45
47
|
return data
|
|
46
48
|
}
|
|
47
49
|
function renderList(s) {
|
|
@@ -90,6 +92,8 @@ window.DshSkillsCenter = (() => {
|
|
|
90
92
|
try {
|
|
91
93
|
const data = await api(s, '/read?id=' + encodeURIComponent(row.id))
|
|
92
94
|
if (!live(s) || sequence !== s.detailSequence) return
|
|
95
|
+
if (data.content != null && typeof data.content !== 'string') throw Object.assign(new Error(errors.unsupported), { code:'unsupported' })
|
|
96
|
+
window.DshExtensions?.reportAvailability?.(s.connection, 'skills', { ok: true })
|
|
93
97
|
const item = data.item || row
|
|
94
98
|
s.detail.replaceChildren(node('small', sourceNames[item.source] || item.source, 'sc-source'), node('h3', item.name), node('p', item.description || '未提供说明'))
|
|
95
99
|
if (item.whenToUse) s.detail.append(node('h4', '适用场景'), node('p', item.whenToUse))
|
|
@@ -102,7 +106,10 @@ window.DshSkillsCenter = (() => {
|
|
|
102
106
|
s.detail.querySelector('button')?.focus({ preventScroll: true })
|
|
103
107
|
}
|
|
104
108
|
} catch (error) {
|
|
105
|
-
if (live(s) && sequence === s.detailSequence)
|
|
109
|
+
if (live(s) && sequence === s.detailSequence) {
|
|
110
|
+
window.DshExtensions?.reportAvailability?.(s.connection, 'skills', { code: error.code || (error.name === 'TimeoutError' ? 'timeout' : 'read-failed') })
|
|
111
|
+
s.detail.replaceChildren(node('h3', row.name), node('p', error.message), button('重试读取', () => { s.selected = ''; void select(s, row) }))
|
|
112
|
+
}
|
|
106
113
|
if (live(s) && s.dedicated && sequence === s.detailSequence) s.detail.prepend(button('← 返回技能列表', () => back(s)))
|
|
107
114
|
}
|
|
108
115
|
}
|
|
@@ -141,7 +148,8 @@ window.DshSkillsCenter = (() => {
|
|
|
141
148
|
try {
|
|
142
149
|
const data = await api(s, '/list')
|
|
143
150
|
if (!live(s) || sequence !== s.listSequence) return
|
|
144
|
-
if (data.schema !== 1 || !Array.isArray(data.items)) throw new Error(errors.unsupported)
|
|
151
|
+
if (data.schema !== 1 || !Array.isArray(data.items)) throw Object.assign(new Error(errors.unsupported), { code: 'unsupported' })
|
|
152
|
+
window.DshExtensions?.reportAvailability?.(s.connection, 'skills', { ok: true })
|
|
145
153
|
s.items = data.items; s.selected = ''
|
|
146
154
|
const previous = s.sources.value
|
|
147
155
|
s.sources.replaceChildren(node('option', '全部来源'))
|
|
@@ -153,7 +161,10 @@ window.DshSkillsCenter = (() => {
|
|
|
153
161
|
s.detail.replaceChildren(node('h3', '技能详情'), node('p', '选择一个技能,查看适用场景和正文。'))
|
|
154
162
|
renderList(s)
|
|
155
163
|
} catch (error) {
|
|
156
|
-
if (live(s) && sequence === s.listSequence) {
|
|
164
|
+
if (live(s) && sequence === s.listSequence) {
|
|
165
|
+
window.DshExtensions?.reportAvailability?.(s.connection, 'skills', { code: error.code || (error.name === 'TimeoutError' ? 'timeout' : 'read-failed') })
|
|
166
|
+
s.message.textContent = error.message; s.updated.textContent = s.items.length ? '保留上次读取结果' : ''; if (!s.items.length) s.list.replaceChildren()
|
|
167
|
+
}
|
|
157
168
|
} finally { if (live(s) && sequence === s.listSequence) s.reload.disabled = false }
|
|
158
169
|
}
|
|
159
170
|
async function mount(connection, target, options = {}) {
|
|
@@ -403,6 +403,45 @@ html[data-theme="fish"] .nav-home.active .nav-home-orb {
|
|
|
403
403
|
animation: fish-wiggle 3.2s ease-in-out infinite;
|
|
404
404
|
}
|
|
405
405
|
|
|
406
|
+
/* ============ 团队与任务:角色点缀留在标题,阅读区域保持实色 ============ */
|
|
407
|
+
html[data-theme="fish"] :is(.teams-card, .task-card, .ext-toolbar) {
|
|
408
|
+
border-color: #B7D5F1;
|
|
409
|
+
background: #FFFFFF;
|
|
410
|
+
box-shadow: 0 5px 18px rgba(31, 71, 133, .055);
|
|
411
|
+
}
|
|
412
|
+
html[data-theme="fish"] .ext-toolbar {
|
|
413
|
+
background: linear-gradient(145deg, #FFFFFF, #F0F7FF);
|
|
414
|
+
}
|
|
415
|
+
html[data-theme="fish"] :is(.team-member, .team-task, .task-outcomes) {
|
|
416
|
+
background: #F3F8FF;
|
|
417
|
+
border-color: #C7DDF2;
|
|
418
|
+
}
|
|
419
|
+
html[data-theme="fish"] .ext-eyebrow {
|
|
420
|
+
display: flex;
|
|
421
|
+
align-items: center;
|
|
422
|
+
gap: 7px;
|
|
423
|
+
}
|
|
424
|
+
html[data-theme="fish"] .ext-eyebrow::before {
|
|
425
|
+
content: '';
|
|
426
|
+
flex: 0 0 28px;
|
|
427
|
+
width: 28px;
|
|
428
|
+
height: 23px;
|
|
429
|
+
background: url("icon-star.png") center / contain no-repeat;
|
|
430
|
+
pointer-events: none;
|
|
431
|
+
}
|
|
432
|
+
html[data-theme="fish"] .teams-page .ext-eyebrow::before {
|
|
433
|
+
background-image: url("icon-smile.png");
|
|
434
|
+
}
|
|
435
|
+
html[data-theme="fish"] .ext-button-primary {
|
|
436
|
+
background: #E9F0FF;
|
|
437
|
+
border-color: #A7C3EE;
|
|
438
|
+
color: var(--dsr-accent-strong);
|
|
439
|
+
}
|
|
440
|
+
html[data-theme="fish"] .ext-button-primary:hover {
|
|
441
|
+
background: #DCE8FF;
|
|
442
|
+
border-color: var(--dsr-accent);
|
|
443
|
+
}
|
|
444
|
+
|
|
406
445
|
/* ============ 皮肤选择卡:任意主题下都能认出这个角色 ============ */
|
|
407
446
|
.theme-option[data-theme="fish"] {
|
|
408
447
|
border-color: #9AC4F2;
|
package/public/styles.css
CHANGED
|
@@ -74,7 +74,7 @@ button {
|
|
|
74
74
|
}
|
|
75
75
|
.icon-btn svg { width: 19px; height: 19px; display: block; }
|
|
76
76
|
.icon-btn:active { background: var(--dsr-panel-2); }
|
|
77
|
-
/* 顶栏按钮统一:
|
|
77
|
+
/* 顶栏按钮统一: 反馈/插件/连接状态同高同基线;点击状态刷新。 */
|
|
78
78
|
.topbar-btn {
|
|
79
79
|
height: 44px; box-sizing: border-box;
|
|
80
80
|
display: inline-flex; align-items: center; justify-content: center; gap: 6px;
|
|
@@ -83,7 +83,8 @@ button {
|
|
|
83
83
|
.topbar-right .topbar-btn.icon-btn { width: 44px; padding: 0; font-size: 19px; border-radius: 12px; }
|
|
84
84
|
.topbar-right #btn-donate { color: var(--dsr-accent-2); }
|
|
85
85
|
.topbar-right #btn-feedback { color: var(--dsr-info); }
|
|
86
|
-
.topbar-right #btn-
|
|
86
|
+
.topbar-right #btn-plugin-shortcuts { color: var(--dsr-accent-strong); }
|
|
87
|
+
.topbar-right .conn-badge:active { filter: brightness(.92); }
|
|
87
88
|
.topbar-right .topbar-btn.conn-badge { padding: 0 14px; border-radius: 999px; font-size: 12.5px; }
|
|
88
89
|
|
|
89
90
|
/* ---------- 顶栏组切换抽屉 ---------- */
|
|
@@ -646,6 +647,12 @@ body.composer-fullscreen { overflow: hidden; }
|
|
|
646
647
|
.approval-record-badge.pending, .approval-event-badge.pending { color: var(--dsr-warning); border-color: var(--dsr-warning-line); border-style: dashed; }
|
|
647
648
|
.approval-record-reason { display: flex; gap: 6px; font-size: 12px; line-height: 1.5; color: var(--dsr-text); }
|
|
648
649
|
.approval-record-kind { flex: none; font-size: 10.5px; font-weight: 700; color: var(--dsr-muted); border: 1px solid var(--dsr-line); border-radius: 6px; padding: 0 5px; }
|
|
650
|
+
.approval-record-kind { align-self:flex-start; }
|
|
651
|
+
.approval-record-copy { min-width:0; flex:1; overflow-wrap:anywhere; }
|
|
652
|
+
.approval-original { margin-top:6px; color:var(--dsr-muted); font-size:11px; }
|
|
653
|
+
.approval-original summary { cursor:pointer; }
|
|
654
|
+
.approval-original div { margin-top:6px; white-space:pre-wrap; }
|
|
655
|
+
.approval-translation p { white-space:pre-wrap; overflow-wrap:anywhere; }
|
|
649
656
|
.approval-record-why { font-size: 11.5px; line-height: 1.45; color: var(--dsr-muted); }
|
|
650
657
|
.approval-record-meta { font-size: 10.5px; color: var(--dsr-muted); }
|
|
651
658
|
.approval-event { font-size: 12.5px; color: var(--dsr-text); padding: 4px 0; }
|
|
@@ -1204,6 +1211,19 @@ button.overview-attention-item, button.overview-session-item { cursor:pointer; }
|
|
|
1204
1211
|
.announcement-history-item summary small { flex: 0 0 auto; color: var(--dsr-muted); font-size: 11px; font-weight: 400; }
|
|
1205
1212
|
.announcement-history-item .announcement-history-content { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--dsr-line); line-height: 1.65; overflow-wrap: anywhere; word-break: break-word; }
|
|
1206
1213
|
.announcement-history-item .announcement-action { margin-top: 8px; }
|
|
1214
|
+
.announcement-sections { display:grid; gap:9px; margin-top:16px; }
|
|
1215
|
+
.announcement-section { min-width:0; border:1px solid var(--dsr-line); border-radius:12px; background:var(--dsr-panel); }
|
|
1216
|
+
.announcement-section > summary { display:flex; align-items:center; gap:9px; min-height:44px; padding:10px 12px; list-style:none; cursor:pointer; font-size:13px; line-height:1.55; font-weight:650; color:var(--dsr-text); overflow-wrap:anywhere; }
|
|
1217
|
+
.announcement-section > summary::-webkit-details-marker { display:none; }
|
|
1218
|
+
.announcement-section > summary::marker { content:''; }
|
|
1219
|
+
.announcement-section > summary::before { content:'›'; flex:0 0 auto; font-size:20px; line-height:1; color:var(--dsr-accent-strong); }
|
|
1220
|
+
.announcement-section[open] > summary::before { transform:rotate(90deg); }
|
|
1221
|
+
.announcement-section > summary:focus-visible { outline:2px solid var(--dsr-accent); outline-offset:2px; border-radius:10px; }
|
|
1222
|
+
.announcement-section-title { flex:1; min-width:0; }
|
|
1223
|
+
.announcement-section-expand, .announcement-section-collapse { flex:0 0 auto; color:var(--dsr-accent-strong); font-size:11px; font-weight:500; }
|
|
1224
|
+
.announcement-section-collapse, .announcement-section[open] > summary .announcement-section-expand { display:none; }
|
|
1225
|
+
.announcement-section[open] > summary .announcement-section-collapse { display:inline; }
|
|
1226
|
+
.announcement-section-body { padding:0 12px 12px; font-size:13px; line-height:1.75; overflow-wrap:anywhere; word-break:break-word; }
|
|
1207
1227
|
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 3px 0; }
|
|
1208
1228
|
.kv .k { color: var(--dsr-muted); } .kv .v { word-break: break-all; text-align: right; }
|
|
1209
1229
|
|