dsh-agent-control-center 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +116 -0
- package/README.md +217 -83
- package/README.zh.md +159 -58
- package/client.js +7660 -2005
- package/cordis.patch.yml +5 -0
- package/docs/01-CONTRACT.md +3 -2
- package/docs/05-ACCEPTANCE-EVIDENCE.md +81 -0
- package/docs/06-UX-OPTIMIZATION.md +57 -0
- package/docs/07-GUIDE.md +327 -0
- package/docs/08-COMPATIBILITY.md +202 -0
- package/docs/09-ARCHITECTURE.md +333 -0
- package/docs/ROADMAP.md +448 -0
- package/index.js +67 -2
- package/lib/core/cache.js +277 -0
- package/lib/core/compat.js +877 -0
- package/lib/core/errors.js +14 -1
- package/lib/core/http.js +22 -0
- package/lib/core/index.js +53 -2
- package/lib/core/paths.js +6 -0
- package/lib/core/registry.js +21 -5
- package/lib/core/util.js +4 -1
- package/lib/modules/a-agents.js +104 -4
- package/lib/modules/b-tools.js +169 -26
- package/lib/modules/f-diagnostics.js +109 -17
- package/lib/modules/g-templates.js +18 -0
- package/lib/modules/i-recovery.js +84 -23
- package/lib/modules/j-instruction.js +624 -0
- package/lib/modules/k-export.js +540 -0
- package/package.json +1 -1
- package/scripts/release.mjs +81 -0
- package/scripts/verify.mjs +12 -0
- package/src/client/app.js +684 -118
- package/src/client/i18n/agents.js +96 -0
- package/src/client/i18n/common.js +36 -0
- package/src/client/i18n/diagnostics.js +52 -0
- package/src/client/i18n/export.js +174 -0
- package/src/client/i18n/instruction.js +236 -0
- package/src/client/i18n/meta.js +72 -0
- package/src/client/i18n/overview.js +38 -0
- package/src/client/i18n/recovery.js +66 -0
- package/src/client/i18n/sessions.js +64 -0
- package/src/client/i18n/templates.js +88 -0
- package/src/client/i18n/tools.js +96 -0
- package/src/client/i18n/usage.js +42 -0
- package/src/client/kernel.js +327 -40
- package/src/client/pages/agents.js +637 -354
- package/src/client/pages/diagnostics.js +526 -177
- package/src/client/pages/export.js +664 -0
- package/src/client/pages/instruction.js +648 -0
- package/src/client/pages/meta.js +553 -193
- package/src/client/pages/overview.js +255 -34
- package/src/client/pages/recovery.js +332 -131
- package/src/client/pages/sessions.js +470 -307
- package/src/client/pages/templates.js +691 -381
- package/src/client/pages/tools.js +559 -206
- package/src/client/pages/usage.js +235 -57
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
/* Sessions page — the archive-first session manager.
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
1
|
+
/* Sessions page — the archive-first session manager.
|
|
2
|
+
*
|
|
3
|
+
* It lists host sessions through `sessions.list`, filters/groups them locally
|
|
4
|
+
* per page, archives or unarchives the selection through `sessions.archive` /
|
|
5
|
+
* `sessions.unarchive`, and expands a row into a bounded `sessions.detail`
|
|
6
|
+
* panel with a Details and an Activity view. There is deliberately no delete
|
|
7
|
+
* action: the host exposes no public session deletion capability, so the page
|
|
8
|
+
* states that instead of inventing one.
|
|
9
|
+
*
|
|
10
|
+
* Layout: the settings column is ~360px wide, so the session list is a record
|
|
11
|
+
* list (each row is a stacked block with an inline detail panel) rather than a
|
|
12
|
+
* wide table, and the toolbar keeps a fixed row order so switching tabs,
|
|
13
|
+
* views or typing a query never reflows the page. */
|
|
8
14
|
(function sessionsPage() {
|
|
9
15
|
const PAGE_SIZE = 50
|
|
10
16
|
const SEARCH_DEBOUNCE_MS = 250
|
|
@@ -16,43 +22,32 @@
|
|
|
16
22
|
section: { display: 'flex', flexDirection: 'column', gap: 12, padding: '8px 0', fontSize: 13, lineHeight: '22px', color: 'var(--dsw-alias-label-primary, #0f1115)' },
|
|
17
23
|
row: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 8 },
|
|
18
24
|
muted: { color: 'var(--dsw-alias-label-secondary, #61666b)', fontSize: 12 },
|
|
19
|
-
faint: { color: 'var(--dsw-alias-label-tertiary, #81858c)', fontSize:
|
|
25
|
+
faint: { color: 'var(--dsw-alias-label-tertiary, #81858c)', fontSize: 11 },
|
|
20
26
|
mono: { fontFamily: 'var(--ds-font-family-code, ui-monospace, SFMono-Regular, Menlo, monospace)', fontSize: 11, wordBreak: 'break-all' },
|
|
21
|
-
input: {
|
|
22
|
-
flex: '1 1 260px',
|
|
23
|
-
minWidth: 180,
|
|
24
|
-
padding: '5px 8px',
|
|
25
|
-
font: 'inherit',
|
|
26
|
-
color: 'inherit',
|
|
27
|
-
background: 'var(--dsw-alias-settings-card-fill, transparent)',
|
|
28
|
-
border: '1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, .16))',
|
|
29
|
-
borderRadius: 'var(--dsw-radius-sm, 8px)',
|
|
30
|
-
},
|
|
31
|
-
tabs: { display: 'flex', gap: 4, flexWrap: 'wrap' },
|
|
32
|
-
tab: (active) => ({
|
|
33
|
-
padding: '4px 10px',
|
|
34
|
-
font: 'inherit',
|
|
35
|
-
fontSize: 12,
|
|
36
|
-
cursor: 'pointer',
|
|
37
|
-
color: active ? 'var(--dsw-alias-label-primary, #0f1115)' : 'var(--dsw-alias-label-secondary, #61666b)',
|
|
38
|
-
background: active ? 'var(--dsw-alias-interactive-bg-hover, rgba(38, 49, 72, .06))' : 'transparent',
|
|
39
|
-
border: `1px solid ${active ? 'var(--dsw-alias-border-l2, rgba(0, 0, 0, .16))' : 'transparent'}`,
|
|
40
|
-
borderRadius: 'var(--dsw-radius-sm, 8px)',
|
|
41
|
-
fontWeight: active ? 600 : 400,
|
|
42
|
-
}),
|
|
43
27
|
column: { display: 'flex', flexDirection: 'column', gap: 8, minWidth: 0 },
|
|
44
|
-
titleCell: { display: 'flex', flexDirection: 'column', gap: 2, minWidth: 0 },
|
|
45
|
-
titleButton: { padding: 0, border: 'none', background: 'transparent', color: 'inherit', font: 'inherit', textAlign: 'left', cursor: 'pointer', fontWeight: 600, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', maxWidth: '42ch' },
|
|
46
|
-
rowMeta: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 6 },
|
|
47
28
|
badges: { display: 'flex', flexWrap: 'wrap', gap: 4 },
|
|
48
|
-
toolbarSpacer: { flex: '1 1 auto' },
|
|
49
29
|
panelBody: { display: 'flex', flexDirection: 'column', gap: 12 },
|
|
50
30
|
list: { listStyle: 'none', margin: 0, padding: 0, display: 'flex', flexDirection: 'column', gap: 6 },
|
|
51
31
|
listItem: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 6, padding: '4px 0', borderBottom: '1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .04))' },
|
|
52
|
-
|
|
53
|
-
|
|
32
|
+
barTrack: { flex: '1 1 80px', maxWidth: 180, height: 6, borderRadius: 999, background: 'var(--dsw-alias-border-l2, rgba(0,0,0,.1))', overflow: 'hidden' },
|
|
33
|
+
bar: { height: '100%', borderRadius: 999, background: 'var(--dsw-alias-state-business-primary, #4176e6)' },
|
|
54
34
|
noticeList: { margin: '4px 0 0', paddingLeft: 18, fontSize: 12 },
|
|
55
|
-
|
|
35
|
+
sessionRow: {
|
|
36
|
+
display: 'flex',
|
|
37
|
+
flexDirection: 'column',
|
|
38
|
+
gap: 3,
|
|
39
|
+
padding: '8px 10px',
|
|
40
|
+
borderBottom: '0.5px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, .1))',
|
|
41
|
+
},
|
|
42
|
+
statCell: {
|
|
43
|
+
display: 'flex',
|
|
44
|
+
flexDirection: 'column',
|
|
45
|
+
gap: 2,
|
|
46
|
+
padding: '8px 10px',
|
|
47
|
+
border: '.5px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, .1))',
|
|
48
|
+
borderRadius: 'var(--dsw-radius-sm, 8px)',
|
|
49
|
+
},
|
|
50
|
+
clamp: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', maxWidth: '100%' },
|
|
56
51
|
}
|
|
57
52
|
|
|
58
53
|
/** The host does not hand plugins a current-session id; accept one when a
|
|
@@ -79,6 +74,11 @@
|
|
|
79
74
|
return t('sessions.updatedCreated')
|
|
80
75
|
}
|
|
81
76
|
|
|
77
|
+
/** Pick the singular/plural key for a count. @param {number} count @param {string} one @param {string} many */
|
|
78
|
+
function plural(count, one, many) {
|
|
79
|
+
return count === 1 ? one : many
|
|
80
|
+
}
|
|
81
|
+
|
|
82
82
|
/** @param {number | null} value @param {Function} t @returns {string} */
|
|
83
83
|
function sizeText(value, t) {
|
|
84
84
|
return typeof value === 'number' && Number.isFinite(value) ? ACC.fmt.bytes(value) : t('sessions.unknownSize')
|
|
@@ -167,18 +167,36 @@
|
|
|
167
167
|
const archive = props.mode === 'archive'
|
|
168
168
|
return h(
|
|
169
169
|
C.Modal,
|
|
170
|
-
{
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
170
|
+
{
|
|
171
|
+
title: props.t(archive ? 'sessions.archiveConfirmTitle' : 'sessions.unarchiveConfirmTitle'),
|
|
172
|
+
tone: 'warning',
|
|
173
|
+
onClose: props.onCancel,
|
|
174
|
+
footer: h(
|
|
175
|
+
'div',
|
|
176
|
+
{ className: 'acc-row', style: { justifyContent: 'flex-end' } },
|
|
177
|
+
h(C.Btn, { tone: 'ghost', onClick: props.onCancel, disabled: props.busy }, props.t('common.cancel')),
|
|
178
|
+
h(
|
|
179
|
+
C.Btn,
|
|
180
|
+
{ tone: 'primary', onClick: props.onConfirm, disabled: props.busy },
|
|
181
|
+
props.busy
|
|
182
|
+
? props.t('sessions.batchRunning')
|
|
183
|
+
: props.t(
|
|
184
|
+
plural(props.ids.length, archive ? 'sessions.archiveCtaOne' : 'sessions.unarchiveCtaOne', archive ? 'sessions.archiveCtaMany' : 'sessions.unarchiveCtaMany'),
|
|
185
|
+
{ count: props.ids.length },
|
|
186
|
+
),
|
|
187
|
+
),
|
|
188
|
+
),
|
|
189
|
+
},
|
|
190
|
+
h('p', { style: { margin: 0 } }, props.t(plural(props.ids.length, archive ? 'sessions.archiveConfirmOne' : 'sessions.unarchiveConfirmOne', archive ? 'sessions.archiveConfirmMany' : 'sessions.unarchiveConfirmMany'), { count: props.ids.length })),
|
|
191
|
+
h(C.Notice, { tone: 'info' }, props.t(archive ? 'sessions.archiveScope' : 'sessions.unarchiveScope')),
|
|
178
192
|
)
|
|
179
193
|
}
|
|
180
194
|
|
|
181
|
-
/**
|
|
195
|
+
/**
|
|
196
|
+
* Batch result: one line per affected session plus a retry that only resends
|
|
197
|
+
* the failed ids. Nothing is hidden behind a single aggregate number.
|
|
198
|
+
* @param {{ outcome: any, t: Function, busy: boolean, onRetry: Function, onDismiss: Function }} props
|
|
199
|
+
*/
|
|
182
200
|
function BatchOutcome(props) {
|
|
183
201
|
const outcome = props.outcome
|
|
184
202
|
if (outcome === null || outcome === undefined) return null
|
|
@@ -192,28 +210,84 @@
|
|
|
192
210
|
const result = outcome.result || {}
|
|
193
211
|
const ok = typeof result.ok === 'number' ? result.ok : 0
|
|
194
212
|
const failed = typeof result.failed === 'number' ? result.failed : 0
|
|
195
|
-
const
|
|
213
|
+
const results = Array.isArray(result.results) ? result.results : []
|
|
214
|
+
const failures = results.filter((entry) => entry.ok !== true)
|
|
215
|
+
const successes = results.filter((entry) => entry.ok === true)
|
|
196
216
|
return h(
|
|
197
217
|
'div',
|
|
198
|
-
{ style: { display: 'flex', flexDirection: 'column', gap: 6 } },
|
|
218
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: 6 }, role: 'status', 'aria-live': 'polite' },
|
|
199
219
|
h(C.Notice, { tone: failed > 0 ? 'warn' : 'success' }, failed > 0 ? props.t('sessions.resultMixed', { ok, failed }) : props.t('sessions.resultAllOk', { ok })),
|
|
200
|
-
|
|
220
|
+
results.length > 0
|
|
201
221
|
? h(
|
|
202
222
|
'ul',
|
|
203
223
|
{ style: style.noticeList },
|
|
224
|
+
successes.slice(0, FAILURE_LIST_LIMIT).map((entry) =>
|
|
225
|
+
h('li', { key: `ok-${String(entry.id)}` }, h('span', { style: { color: 'var(--acc-success-text, #15803d)' } }, '✓ '), h('span', { style: style.mono }, String(entry.id)), ` · ${props.t('sessions.resultItemOk')}`),
|
|
226
|
+
),
|
|
204
227
|
failures.slice(0, FAILURE_LIST_LIMIT).map((entry) =>
|
|
205
228
|
h(
|
|
206
229
|
'li',
|
|
207
|
-
{ key: String(entry.id) },
|
|
230
|
+
{ key: `fail-${String(entry.id)}` },
|
|
231
|
+
h('span', { style: { color: 'var(--acc-danger-text, #b42318)' } }, '✗ '),
|
|
208
232
|
h('span', { style: style.mono }, String(entry.id)),
|
|
209
233
|
` · ${String(entry.code || 'error')} · ${String(entry.message || '')}`,
|
|
210
234
|
Array.isArray(entry.activity) && entry.activity.length > 0 ? ` · ${entry.activity.join(', ')}` : '',
|
|
211
235
|
),
|
|
212
236
|
),
|
|
237
|
+
results.length > FAILURE_LIST_LIMIT * 2 ? h('li', null, props.t('sessions.resultClipped', { shown: Math.min(results.length, FAILURE_LIST_LIMIT * 2), total: results.length })) : null,
|
|
213
238
|
)
|
|
214
239
|
: null,
|
|
215
240
|
failures.length > 0
|
|
216
|
-
? h(
|
|
241
|
+
? h(
|
|
242
|
+
'div',
|
|
243
|
+
{ className: 'acc-row', style: { gap: 6 } },
|
|
244
|
+
h(C.Btn, { onClick: props.onRetry, disabled: props.busy }, props.busy ? props.t('sessions.batchRunning') : props.t('sessions.retryFailedOnly', { count: failures.length })),
|
|
245
|
+
h(C.Btn, { tone: 'ghost', onClick: props.onDismiss }, props.t('sessions.dismissResult')),
|
|
246
|
+
)
|
|
247
|
+
: h(C.Btn, { tone: 'ghost', onClick: props.onDismiss }, props.t('sessions.dismissResult')),
|
|
248
|
+
)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Collapsed explanation panel: the first screen belongs to the toolbar and the
|
|
253
|
+
* list, so implementation notes and limitations live behind one summary line.
|
|
254
|
+
* @param {{ t: Function, items: string[] }} props
|
|
255
|
+
*/
|
|
256
|
+
function AboutPanel(props) {
|
|
257
|
+
const [open, setOpen] = ACC.useState(false)
|
|
258
|
+
if (props.items.length === 0) return null
|
|
259
|
+
return h(
|
|
260
|
+
'div',
|
|
261
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: '4px' } },
|
|
262
|
+
h(
|
|
263
|
+
'button',
|
|
264
|
+
{
|
|
265
|
+
type: 'button',
|
|
266
|
+
onClick: () => setOpen((value) => !value),
|
|
267
|
+
'aria-expanded': open,
|
|
268
|
+
style: {
|
|
269
|
+
display: 'flex',
|
|
270
|
+
alignItems: 'center',
|
|
271
|
+
gap: '6px',
|
|
272
|
+
padding: 0,
|
|
273
|
+
border: 0,
|
|
274
|
+
background: 'transparent',
|
|
275
|
+
color: 'inherit',
|
|
276
|
+
font: 'inherit',
|
|
277
|
+
fontSize: '11px',
|
|
278
|
+
cursor: 'pointer',
|
|
279
|
+
textAlign: 'left',
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
h('span', { 'aria-hidden': 'true' }, open ? '▾' : '▸'),
|
|
283
|
+
h('span', { className: 'acc-muted' }, `${props.t('sessions.about')} - ${props.t('sessions.aboutSummary')}`),
|
|
284
|
+
),
|
|
285
|
+
open
|
|
286
|
+
? h(
|
|
287
|
+
'ul',
|
|
288
|
+
{ style: { margin: 0, paddingLeft: '18px', display: 'flex', flexDirection: 'column', gap: '2px', fontSize: '11px', color: 'var(--dsw-alias-label-secondary, #61666b)' } },
|
|
289
|
+
props.items.map((text, index) => h('li', { key: String(index) }, text)),
|
|
290
|
+
)
|
|
217
291
|
: null,
|
|
218
292
|
)
|
|
219
293
|
}
|
|
@@ -227,102 +301,94 @@
|
|
|
227
301
|
if (row.running === 'running') badges.push(h(C.Badge, { key: 'running', tone: 'success' }, t('sessions.badgeRunning')))
|
|
228
302
|
else if (row.running === 'idle') badges.push(h(C.Badge, { key: 'idle', tone: 'neutral' }, t('sessions.badgeIdle')))
|
|
229
303
|
else badges.push(h(C.Badge, { key: 'not-live', tone: 'neutral', title: t('sessions.runningSourceNote') }, t('sessions.badgeNotLive')))
|
|
230
|
-
if (row.origin === 'subagent') badges.push(h(C.Badge, { key: 'subagent', tone: 'warn' }, t('sessions.badgeSubagent')))
|
|
231
304
|
if (row.archived === true) badges.push(h(C.Badge, { key: 'archived', tone: 'warn' }, t('sessions.badgeArchived')))
|
|
232
305
|
if (row.pinned === true) badges.push(h(C.Badge, { key: 'pinned', tone: 'neutral' }, t('sessions.badgePinned')))
|
|
233
306
|
return h('div', { style: style.badges }, badges)
|
|
234
307
|
}
|
|
235
308
|
|
|
236
309
|
/**
|
|
237
|
-
* One session
|
|
238
|
-
* rendered directly under
|
|
239
|
-
*
|
|
240
|
-
* @param {{
|
|
310
|
+
* One session row: checkbox + expandable title + facts. The detail panel is
|
|
311
|
+
* rendered directly under its own row, so an expanded session never jumps to
|
|
312
|
+
* the bottom of the list.
|
|
313
|
+
* @param {{ row: any, t: Function, selected: boolean, expanded: boolean, onToggle: Function, onExpand: Function, selectedIds: string[] }} props
|
|
241
314
|
*/
|
|
242
|
-
function
|
|
315
|
+
function SessionRow(props) {
|
|
316
|
+
const row = props.row
|
|
243
317
|
const t = props.t
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
{
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
318
|
+
return h(
|
|
319
|
+
'div',
|
|
320
|
+
{ style: style.sessionRow, 'data-selected': props.selected ? 'true' : 'false' },
|
|
321
|
+
h(
|
|
322
|
+
'div',
|
|
323
|
+
{ className: 'acc-row', style: { gap: '6px', alignItems: 'flex-start' } },
|
|
324
|
+
h('input', {
|
|
250
325
|
type: 'checkbox',
|
|
251
|
-
checked:
|
|
252
|
-
onChange: props.
|
|
253
|
-
'aria-label':
|
|
326
|
+
checked: props.selected,
|
|
327
|
+
onChange: () => props.onToggle(row.id),
|
|
328
|
+
'aria-label': `${t('sessions.colSelect')} ${row.titleAvailable === true && typeof row.title === 'string' ? row.title : row.id}`,
|
|
329
|
+
style: { marginTop: '3px', flex: '0 0 auto' },
|
|
254
330
|
}),
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
'aria-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
'
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
),
|
|
281
|
-
h('div', { style: style.rowMeta }, h('span', { style: style.mono }, String(row.id))),
|
|
282
|
-
h(StatusBadges, { row, t }),
|
|
283
|
-
),
|
|
284
|
-
},
|
|
285
|
-
{
|
|
286
|
-
key: 'workspace',
|
|
287
|
-
label: t('sessions.colWorkspace'),
|
|
288
|
-
render: (row) => (row.workspace !== null && row.workspace !== undefined ? String(row.workspace.title) : t('sessions.ungrouped')),
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
key: 'updated',
|
|
292
|
-
label: t('sessions.colUpdated'),
|
|
293
|
-
render: (row) =>
|
|
331
|
+
h(
|
|
332
|
+
'button',
|
|
333
|
+
{
|
|
334
|
+
type: 'button',
|
|
335
|
+
onClick: () => props.onExpand(row.id),
|
|
336
|
+
'aria-expanded': props.expanded,
|
|
337
|
+
title: row.id,
|
|
338
|
+
'aria-label': `${props.expanded ? t('sessions.collapse') : t('sessions.expand')}: ${row.titleAvailable === true && typeof row.title === 'string' ? row.title : t('sessions.untitled')} (${String(row.id).slice(-8)})`,
|
|
339
|
+
style: {
|
|
340
|
+
flex: '1 1 auto',
|
|
341
|
+
minWidth: 0,
|
|
342
|
+
display: 'flex',
|
|
343
|
+
alignItems: 'baseline',
|
|
344
|
+
gap: '6px',
|
|
345
|
+
padding: 0,
|
|
346
|
+
border: 0,
|
|
347
|
+
background: 'transparent',
|
|
348
|
+
color: 'inherit',
|
|
349
|
+
font: 'inherit',
|
|
350
|
+
fontWeight: 600,
|
|
351
|
+
textAlign: 'left',
|
|
352
|
+
cursor: 'pointer',
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
h('span', { 'aria-hidden': 'true' }, props.expanded ? '▾' : '▸'),
|
|
294
356
|
h(
|
|
295
357
|
'span',
|
|
296
|
-
{
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
{
|
|
302
|
-
key: 'detail',
|
|
303
|
-
label: t('sessions.colDetail'),
|
|
304
|
-
align: 'right',
|
|
305
|
-
render: (row) =>
|
|
306
|
-
h(
|
|
307
|
-
C.Btn,
|
|
308
|
-
{ tone: 'ghost', onClick: () => props.onExpand(row.id), title: props.expandedId === row.id ? t('sessions.collapse') : t('sessions.expand') },
|
|
309
|
-
props.expandedId === row.id ? '▾' : '▸',
|
|
358
|
+
{
|
|
359
|
+
style: { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
|
|
360
|
+
lang: row.titleAvailable === true && typeof row.title === 'string' && ACC.l10n.hasCjk(row.title) ? 'zh' : undefined,
|
|
361
|
+
},
|
|
362
|
+
row.titleAvailable === true && typeof row.title === 'string' ? row.title : t('sessions.untitled'),
|
|
310
363
|
),
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
364
|
+
),
|
|
365
|
+
),
|
|
366
|
+
h(
|
|
367
|
+
'div',
|
|
368
|
+
{ style: { ...style.row, gap: '6px', paddingLeft: '24px' } },
|
|
369
|
+
h(StatusBadges, { row, t }),
|
|
370
|
+
row.origin && row.origin !== 'user' ? h(KindBadge, { kind: row.origin, t }) : null,
|
|
371
|
+
),
|
|
372
|
+
h(
|
|
373
|
+
'div',
|
|
374
|
+
{ style: { ...style.row, gap: '8px', paddingLeft: '24px' } },
|
|
375
|
+
h('span', { style: { ...style.mono, ...style.clamp, maxWidth: '150px' }, title: String(row.id) }, String(row.id)),
|
|
376
|
+
h(
|
|
377
|
+
'span',
|
|
378
|
+
{ style: style.faint, lang: row.workspace && ACC.l10n.hasCjk(row.workspace.title) ? 'zh' : undefined },
|
|
379
|
+
row.workspace !== null && row.workspace !== undefined ? String(row.workspace.title) : t('sessions.ungrouped'),
|
|
380
|
+
),
|
|
381
|
+
h('span', { style: style.faint, title: `${ACC.l10n.dateTime(row.updatedAt, t)} · ${updatedSourceLabel(row.updatedAtSource, t)}` }, ACC.l10n.relTime(row.updatedAt, t)),
|
|
382
|
+
h('span', { style: style.faint }, sizeText(row.sizeBytes, t)),
|
|
383
|
+
),
|
|
384
|
+
props.expanded ? h(DetailPanel, { row, t, onClose: () => props.onExpand(row.id) }) : null,
|
|
320
385
|
)
|
|
321
386
|
}
|
|
322
387
|
|
|
323
388
|
/**
|
|
324
389
|
* Inline detail panel: lazy `sessions.detail` read with Details and Activity
|
|
325
|
-
* views.
|
|
390
|
+
* views. Activity statistics are two-column cards; every block either shows
|
|
391
|
+
* real numbers or its unavailable reason.
|
|
326
392
|
* @param {{ row: any, t: Function, onClose: Function }} props
|
|
327
393
|
*/
|
|
328
394
|
function DetailPanel(props) {
|
|
@@ -330,27 +396,27 @@
|
|
|
330
396
|
const [view, setView] = useState('detail')
|
|
331
397
|
const detailState = ACC.useAsync((context) => ACC.api('sessions.detail', { sessionId: props.row.id }, context), [props.row.id])
|
|
332
398
|
|
|
333
|
-
/** @param {
|
|
334
|
-
function sectionTitle(block, title) {
|
|
335
|
-
return h('div', { style: { fontWeight: 600, marginTop: 4 } }, title, typeof block.total === 'number' ? h('span', { style: style.faint }, ` · ${block.total}`) : null)
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
/** @param {any} block @param {string} title @returns {any} */
|
|
399
|
+
/** @param {any} block @param {string} title */
|
|
339
400
|
function unavailableNotice(block, title) {
|
|
340
401
|
return h(
|
|
341
402
|
C.Notice,
|
|
342
403
|
{ tone: 'warn' },
|
|
343
|
-
`${title}
|
|
404
|
+
`${title}: ${t('common.unavailable')}`,
|
|
405
|
+
ACC.l10n.host('sessions.blockUnavailable', block.reason) ? h('span', null, ` · ${ACC.l10n.host('sessions.blockUnavailable', block.reason)}`) : null,
|
|
406
|
+
ACC.l10n.raw(t('sessions.rawHostText'), block.reason),
|
|
344
407
|
)
|
|
345
408
|
}
|
|
346
409
|
|
|
347
410
|
if (detailState.status === 'loading') return h(C.Loading, { label: t('sessions.detailLoading') })
|
|
348
|
-
if (detailState.status === 'error') {
|
|
349
|
-
return h(C.ErrorBox, { error: detailState.error, onRetry: detailState.reload, label: t('sessions.detailFailed') })
|
|
350
|
-
}
|
|
411
|
+
if (detailState.status === 'error') return h(C.ErrorBox, { error: detailState.error, onRetry: detailState.reload, label: t('sessions.detailFailed') })
|
|
351
412
|
const detail = detailState.data
|
|
352
413
|
if (detail === null || typeof detail !== 'object' || detail.available !== true) {
|
|
353
|
-
return h(
|
|
414
|
+
return h(
|
|
415
|
+
C.Notice,
|
|
416
|
+
{ tone: 'warn' },
|
|
417
|
+
t('sessions.detailUnavailableGeneric'),
|
|
418
|
+
ACC.l10n.raw(t('sessions.rawHostText'), detail && detail.reason ? String(detail.reason) : ''),
|
|
419
|
+
)
|
|
354
420
|
}
|
|
355
421
|
const session = detail.session || {}
|
|
356
422
|
const stats = detail.stats || { available: false, reason: t('common.unknown') }
|
|
@@ -364,12 +430,12 @@
|
|
|
364
430
|
const detailRows = [
|
|
365
431
|
{ label: t('sessions.detailId'), value: h('span', { style: style.mono }, String(session.id || props.row.id)) },
|
|
366
432
|
{ label: t('sessions.detailSize'), value: sizeText(session.sizeBytes, t) },
|
|
433
|
+
{ label: t('sessions.detailEventCount'), value: typeof session.eventCount === 'number' ? String(session.eventCount) : t('sessions.detailEventUnknown') },
|
|
434
|
+
{ label: t('sessions.detailCreated'), value: ACC.l10n.dateTime(session.createdAt, t) },
|
|
367
435
|
{
|
|
368
|
-
label: t('sessions.
|
|
369
|
-
value:
|
|
436
|
+
label: t('sessions.detailUpdated'),
|
|
437
|
+
value: `${ACC.l10n.dateTime(session.updatedAt, t)} (${updatedSourceLabel(session.updatedAtSource, t)})`,
|
|
370
438
|
},
|
|
371
|
-
{ label: t('sessions.detailCreated'), value: ACC.fmt.dateTime(session.createdAt) },
|
|
372
|
-
{ label: t('sessions.detailUpdated'), value: `${ACC.fmt.dateTime(session.updatedAt)}(${updatedSourceLabel(session.updatedAtSource, t)})` },
|
|
373
439
|
{ label: t('sessions.detailWorkspace'), value: session.workspace ? String(session.workspace.title) : t('sessions.ungrouped') },
|
|
374
440
|
{ label: t('sessions.detailCwd'), value: h('span', { style: style.mono }, String(session.cwd || '—')) },
|
|
375
441
|
{ label: t('sessions.detailParent'), value: session.parentSessionId ? h('span', { style: style.mono }, String(session.parentSessionId)) : '—' },
|
|
@@ -377,7 +443,8 @@
|
|
|
377
443
|
{ label: t('sessions.detailFormat'), value: session.formatStatus ? String(session.formatStatus) : '—' },
|
|
378
444
|
]
|
|
379
445
|
|
|
380
|
-
|
|
446
|
+
/** Two-column stat cards for the activity view. */
|
|
447
|
+
const statCards = []
|
|
381
448
|
if (stats.available === true) {
|
|
382
449
|
const numeric = [
|
|
383
450
|
['sessions.statsTurns', stats.turns],
|
|
@@ -391,20 +458,31 @@
|
|
|
391
458
|
['sessions.statsToolErrors', stats.toolErrors],
|
|
392
459
|
]
|
|
393
460
|
for (const [key, value] of numeric) {
|
|
394
|
-
if (typeof value
|
|
461
|
+
if (typeof value !== 'number') continue
|
|
462
|
+
statCards.push(h('div', { key, style: style.statCell }, h('span', { style: style.faint }, t(key)), h('strong', null, ACC.fmt.num(value))))
|
|
395
463
|
}
|
|
396
464
|
const attachments = stats.attachments
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
465
|
+
statCards.push(
|
|
466
|
+
h(
|
|
467
|
+
'div',
|
|
468
|
+
{ key: 'attachments', style: style.statCell },
|
|
469
|
+
h('span', { style: style.faint }, t('sessions.statsAttachments')),
|
|
470
|
+
attachments !== null && typeof attachments === 'object' && attachments.available === true
|
|
471
|
+
? h('strong', null, t('sessions.statsAttachmentsValue', { images: attachments.images, files: attachments.files }))
|
|
472
|
+
: h('span', { style: style.faint }, `${t('common.unavailable')}(${String((attachments && attachments.reason) || '')})`),
|
|
473
|
+
),
|
|
474
|
+
)
|
|
402
475
|
}
|
|
403
476
|
|
|
404
477
|
/** @param {any} block @param {string} title @param {any} body */
|
|
405
478
|
function renderBlock(block, title, body) {
|
|
406
479
|
if (block.available !== true) return unavailableNotice(block, title)
|
|
407
|
-
return h(
|
|
480
|
+
return h(
|
|
481
|
+
'div',
|
|
482
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: 6 } },
|
|
483
|
+
h('div', { style: { fontWeight: 600, fontSize: 12 } }, title, typeof block.total === 'number' ? h('span', { style: style.faint }, ` · ${block.total}`) : null),
|
|
484
|
+
body,
|
|
485
|
+
)
|
|
408
486
|
}
|
|
409
487
|
|
|
410
488
|
const lineageBody = h(
|
|
@@ -429,7 +507,7 @@
|
|
|
429
507
|
'li',
|
|
430
508
|
{ key: `p-${node.id}`, style: style.listItem },
|
|
431
509
|
h(KindBadge, { kind: node.kind, t }),
|
|
432
|
-
h('span',
|
|
510
|
+
h('span', { style: { minWidth: 0, ...style.clamp }, lang: node.title && ACC.l10n.hasCjk(node.title) ? 'zh' : undefined }, node.titleAvailable === true ? String(node.title) : t('sessions.untitled')),
|
|
433
511
|
h('span', { style: style.mono }, String(node.id)),
|
|
434
512
|
h(C.Badge, { tone: node.archived === true ? 'warn' : 'neutral' }, node.archived === true ? t('sessions.badgeArchived') : node.running === 'running' ? t('sessions.badgeRunning') : t('sessions.badgeNotLive')),
|
|
435
513
|
),
|
|
@@ -450,7 +528,7 @@
|
|
|
450
528
|
'li',
|
|
451
529
|
{ key: `c-${node.id}`, style: style.listItem },
|
|
452
530
|
h(KindBadge, { kind: node.kind, t }),
|
|
453
|
-
h('span',
|
|
531
|
+
h('span', { style: { minWidth: 0, ...style.clamp }, lang: node.title && ACC.l10n.hasCjk(node.title) ? 'zh' : undefined }, node.titleAvailable === true ? String(node.title) : t('sessions.untitled')),
|
|
454
532
|
h('span', { style: style.mono }, String(node.id)),
|
|
455
533
|
),
|
|
456
534
|
),
|
|
@@ -473,16 +551,22 @@
|
|
|
473
551
|
? t('sessions.eventScanTruncated', { scanned: scan.scanned, total: scan.eventCount, bound: scan.bound })
|
|
474
552
|
: t('sessions.eventScan', { scanned: scan.scanned, total: scan.eventCount }),
|
|
475
553
|
)
|
|
476
|
-
: h(C.Notice, { tone: 'warn' }, `${t('common.unavailable')}
|
|
477
|
-
lineage.available === true ? h('div', { style: { display: 'flex', flexDirection: 'column', gap: 6 } },
|
|
554
|
+
: h(C.Notice, { tone: 'warn' }, `${t('common.unavailable')}: ${String(scan.reason || '')}`),
|
|
555
|
+
lineage.available === true ? h('div', { style: { display: 'flex', flexDirection: 'column', gap: 6 } }, h('div', { style: { fontWeight: 600, fontSize: 12 } }, t('sessions.lineageTitle')), lineageBody) : unavailableNotice(lineage, t('sessions.lineageTitle')),
|
|
478
556
|
references.available === true ? null : unavailableNotice(references, t('sessions.referencesTitle')),
|
|
479
557
|
)
|
|
480
558
|
|
|
559
|
+
const toolMax = (toolUsage.items || []).reduce((max, item) => (item.count > max ? item.count : max), 1)
|
|
481
560
|
const activityView = h(
|
|
482
561
|
'div',
|
|
483
562
|
{ style: style.panelBody },
|
|
484
563
|
stats.available === true
|
|
485
|
-
? h(
|
|
564
|
+
? h(
|
|
565
|
+
'div',
|
|
566
|
+
{ style: style.column },
|
|
567
|
+
h('div', { style: { fontWeight: 600, fontSize: 12 } }, t('sessions.statsTitle'), h('span', { style: style.faint }, ` · ${t('sessions.statsCardsHint')}`)),
|
|
568
|
+
h('div', { className: 'acc-grid-2' }, statCards),
|
|
569
|
+
)
|
|
486
570
|
: unavailableNotice(stats, t('sessions.statsTitle')),
|
|
487
571
|
stats.source === 'listEvents' ? h(C.Notice, { tone: 'info' }, t('sessions.statsSourceListEvents')) : null,
|
|
488
572
|
stats.source === 'projection' ? h(C.Notice, { tone: 'info' }, t('sessions.statsSourceProjection')) : null,
|
|
@@ -495,16 +579,15 @@
|
|
|
495
579
|
: h(
|
|
496
580
|
'ul',
|
|
497
581
|
{ style: style.list },
|
|
498
|
-
(toolUsage.items || []).map((entry) =>
|
|
499
|
-
|
|
500
|
-
return h(
|
|
582
|
+
(toolUsage.items || []).map((entry) =>
|
|
583
|
+
h(
|
|
501
584
|
'li',
|
|
502
585
|
{ key: String(entry.name), style: style.listItem },
|
|
503
|
-
h('span', { style: { ...style.mono, flex: '0 0 auto' } }, String(entry.name)),
|
|
504
|
-
h('span', { style: style.barTrack }, h('span', { style: { ...style.bar, display: 'block', width: `${Math.max(4, Math.round((entry.count /
|
|
586
|
+
h('span', { style: { ...style.mono, flex: '0 0 auto', maxWidth: '120px', ...style.clamp } }, String(entry.name)),
|
|
587
|
+
h('span', { style: style.barTrack, role: 'img', 'aria-label': `${String(entry.name)}: ${ACC.fmt.num(entry.count)}` }, h('span', { style: { ...style.bar, display: 'block', width: `${Math.max(4, Math.round((entry.count / toolMax) * 100))}%` } })),
|
|
505
588
|
h('span', { style: { flex: '0 0 auto' } }, ACC.fmt.num(entry.count)),
|
|
506
|
-
)
|
|
507
|
-
|
|
589
|
+
),
|
|
590
|
+
),
|
|
508
591
|
toolUsage.truncated === true ? h('div', { style: style.faint }, t('sessions.capTools', { max: 100 })) : null,
|
|
509
592
|
),
|
|
510
593
|
),
|
|
@@ -554,18 +637,39 @@
|
|
|
554
637
|
)
|
|
555
638
|
|
|
556
639
|
return h(
|
|
557
|
-
|
|
558
|
-
{
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
h(C.Btn, { tone: 'ghost', onClick: props.onClose }, t('common.close')),
|
|
640
|
+
'div',
|
|
641
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: 10, marginTop: 6, padding: '10px', border: '.5px solid var(--dsw-alias-border-l2, rgba(0,0,0,.1))', borderRadius: 'var(--dsw-radius-sm, 8px)', background: 'var(--dsw-alias-interactive-bg-hover, rgba(38,49,72,.06))' } },
|
|
642
|
+
h(
|
|
643
|
+
'div',
|
|
644
|
+
{ className: 'acc-row', style: { justifyContent: 'space-between' } },
|
|
645
|
+
h(
|
|
646
|
+
'strong',
|
|
647
|
+
{ style: { minWidth: 0, ...style.clamp } },
|
|
648
|
+
`${t('sessions.detailTitle')} · ${typeof session.title === 'string' ? session.title : t('sessions.untitled')}`,
|
|
567
649
|
),
|
|
568
|
-
|
|
650
|
+
h(C.Btn, { tone: 'ghost', onClick: props.onClose, title: t('sessions.collapse') }, t('common.close')),
|
|
651
|
+
),
|
|
652
|
+
h(
|
|
653
|
+
'div',
|
|
654
|
+
{ className: 'acc-tabs', role: 'tablist', 'aria-label': t('sessions.detailViewAria') },
|
|
655
|
+
[
|
|
656
|
+
{ id: 'detail', label: t('sessions.viewDetail') },
|
|
657
|
+
{ id: 'activity', label: t('sessions.viewActivity') },
|
|
658
|
+
].map((entry) =>
|
|
659
|
+
h(
|
|
660
|
+
'button',
|
|
661
|
+
{
|
|
662
|
+
key: entry.id,
|
|
663
|
+
type: 'button',
|
|
664
|
+
role: 'tab',
|
|
665
|
+
'aria-selected': view === entry.id,
|
|
666
|
+
className: `acc-tab${view === entry.id ? ' is-active' : ''}`,
|
|
667
|
+
onClick: () => setView(entry.id),
|
|
668
|
+
},
|
|
669
|
+
entry.label,
|
|
670
|
+
),
|
|
671
|
+
),
|
|
672
|
+
),
|
|
569
673
|
view === 'detail' ? detailView : activityView,
|
|
570
674
|
)
|
|
571
675
|
}
|
|
@@ -579,7 +683,6 @@
|
|
|
579
683
|
const [expandedGroup, setExpandedGroup] = useState(false)
|
|
580
684
|
const group = props.group
|
|
581
685
|
const shown = expandedGroup ? group.items : group.items.slice(0, GROUP_RENDER_LIMIT)
|
|
582
|
-
const expandedRow = props.expandedId === null ? null : group.items.find((row) => row.id === props.expandedId) || null
|
|
583
686
|
return h(
|
|
584
687
|
C.Card,
|
|
585
688
|
{
|
|
@@ -591,21 +694,22 @@
|
|
|
591
694
|
: h(
|
|
592
695
|
'div',
|
|
593
696
|
{ style: style.column },
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
697
|
+
shown.map((row) =>
|
|
698
|
+
h(SessionRow, {
|
|
699
|
+
key: row.id,
|
|
700
|
+
row,
|
|
701
|
+
t: props.t,
|
|
702
|
+
selected: props.selected.has(row.id),
|
|
703
|
+
expanded: props.expandedId === row.id,
|
|
704
|
+
onToggle: props.onToggle,
|
|
705
|
+
onExpand: props.onExpand,
|
|
706
|
+
}),
|
|
707
|
+
),
|
|
604
708
|
group.items.length > GROUP_RENDER_LIMIT
|
|
605
709
|
? h(
|
|
606
710
|
C.Btn,
|
|
607
711
|
{ tone: 'ghost', onClick: () => setExpandedGroup((value) => !value) },
|
|
608
|
-
expandedGroup ? props.t('sessions.collapse') :
|
|
712
|
+
expandedGroup ? props.t('sessions.collapse') : props.t('sessions.showMoreRows', { shown: shown.length, total: group.items.length }),
|
|
609
713
|
)
|
|
610
714
|
: null,
|
|
611
715
|
),
|
|
@@ -626,6 +730,7 @@
|
|
|
626
730
|
const [busy, setBusy] = useState(false)
|
|
627
731
|
const [outcome, setOutcome] = useState(null)
|
|
628
732
|
const [, setTick] = useState(0)
|
|
733
|
+
const [openGroups, setOpenGroups] = useState({})
|
|
629
734
|
|
|
630
735
|
useEffect(() => {
|
|
631
736
|
const timer = setTimeout(() => setQuery(input.trim()), SEARCH_DEBOUNCE_MS)
|
|
@@ -643,6 +748,7 @@
|
|
|
643
748
|
useEffect(() => {
|
|
644
749
|
setSelected(new Set())
|
|
645
750
|
setExpandedId(null)
|
|
751
|
+
setOutcome(null)
|
|
646
752
|
}, [query, tab])
|
|
647
753
|
|
|
648
754
|
const items = feed.items
|
|
@@ -680,6 +786,7 @@
|
|
|
680
786
|
if (ids.length === 0) return
|
|
681
787
|
setBusy(true)
|
|
682
788
|
setConfirm(null)
|
|
789
|
+
setOutcome(null)
|
|
683
790
|
try {
|
|
684
791
|
const result = await ACC.api(mode === 'archive' ? 'sessions.archive' : 'sessions.unarchive', { ids })
|
|
685
792
|
setOutcome({ mode, result })
|
|
@@ -716,141 +823,196 @@
|
|
|
716
823
|
return [...map.values()].sort((left, right) => right.total - left.total)
|
|
717
824
|
}, [items, feed.meta])
|
|
718
825
|
|
|
719
|
-
const expandedRow = expandedId === null ? null : items.find((row) => row.id === expandedId) || null
|
|
720
|
-
const manualRetryIds = outcome !== null && outcome.result !== undefined ? outcome.result.failedIds : null
|
|
721
826
|
const remaining = Math.max(0, feed.total - items.length)
|
|
827
|
+
const archiveUnavailable = (feed.meta && feed.meta.archive && feed.meta.archive.available === false)
|
|
828
|
+
|| (summary.status === 'ready' && summary.data && summary.data.archive && summary.data.archive.available === false)
|
|
829
|
+
// The module never offers deletion, so the explanation must appear even
|
|
830
|
+
// while the summary request is still loading or has failed.
|
|
831
|
+
const deleteUnavailable = !(summary.status === 'ready' && summary.data && summary.data.delete && summary.data.delete.available === true)
|
|
832
|
+
const searchMode = feed.status === 'ready' && feed.meta && feed.meta.search && feed.meta.search.mode === 'fulltext' ? t('sessions.searchModeFulltext') : t('sessions.searchModeTitleId')
|
|
722
833
|
|
|
723
|
-
|
|
834
|
+
return h(
|
|
724
835
|
'div',
|
|
725
|
-
{ style: style.
|
|
836
|
+
{ style: style.section },
|
|
726
837
|
h(
|
|
727
|
-
|
|
728
|
-
{
|
|
838
|
+
C.Card,
|
|
839
|
+
{ title: t('sessions.listTitle') },
|
|
840
|
+
/* Fixed row order: switching tab/view or typing never reflows this block. */
|
|
729
841
|
h(
|
|
730
842
|
'div',
|
|
731
|
-
{
|
|
732
|
-
h(
|
|
733
|
-
|
|
843
|
+
{ className: 'acc-row', style: { justifyContent: 'space-between' } },
|
|
844
|
+
h(
|
|
845
|
+
'div',
|
|
846
|
+
{ className: 'acc-tabs', role: 'tablist', 'aria-label': t('sessions.tabAria') },
|
|
847
|
+
[
|
|
848
|
+
{ id: 'all', label: t('sessions.tabAll') },
|
|
849
|
+
{ id: 'archived', label: t('sessions.tabArchived') },
|
|
850
|
+
].map((entry) =>
|
|
851
|
+
h(
|
|
852
|
+
'button',
|
|
853
|
+
{
|
|
854
|
+
key: entry.id,
|
|
855
|
+
type: 'button',
|
|
856
|
+
role: 'tab',
|
|
857
|
+
'aria-selected': tab === entry.id,
|
|
858
|
+
className: `acc-tab${tab === entry.id ? ' is-active' : ''}`,
|
|
859
|
+
onClick: () => setTab(entry.id),
|
|
860
|
+
},
|
|
861
|
+
entry.label,
|
|
862
|
+
),
|
|
863
|
+
),
|
|
864
|
+
),
|
|
865
|
+
h(
|
|
866
|
+
'div',
|
|
867
|
+
{ className: 'acc-tabs', role: 'group', 'aria-label': t('sessions.viewAria') },
|
|
868
|
+
[
|
|
869
|
+
{ id: 'flat', label: t('sessions.viewFlat') },
|
|
870
|
+
{ id: 'workspace', label: t('sessions.viewWorkspace') },
|
|
871
|
+
].map((entry) =>
|
|
872
|
+
h(
|
|
873
|
+
'button',
|
|
874
|
+
{
|
|
875
|
+
key: entry.id,
|
|
876
|
+
type: 'button',
|
|
877
|
+
'aria-pressed': view === entry.id,
|
|
878
|
+
className: `acc-tab${view === entry.id ? ' is-active' : ''}`,
|
|
879
|
+
onClick: () => setView(entry.id),
|
|
880
|
+
},
|
|
881
|
+
entry.label,
|
|
882
|
+
),
|
|
883
|
+
),
|
|
884
|
+
),
|
|
734
885
|
),
|
|
735
886
|
h(
|
|
736
887
|
'div',
|
|
737
|
-
{
|
|
738
|
-
h('
|
|
739
|
-
|
|
888
|
+
{ className: 'acc-row' },
|
|
889
|
+
h('input', {
|
|
890
|
+
type: 'search',
|
|
891
|
+
className: 'acc-input acc-grow',
|
|
892
|
+
value: input,
|
|
893
|
+
placeholder: t('sessions.searchPlaceholder'),
|
|
894
|
+
'aria-label': t('sessions.searchAria'),
|
|
895
|
+
onChange: (event) => setInput(event.target.value),
|
|
896
|
+
onKeyDown: (event) => { if (event.key === 'Escape') setInput('') },
|
|
897
|
+
}),
|
|
898
|
+
input.length > 0 ? h(C.Btn, { tone: 'ghost', onClick: () => setInput('') }, t('sessions.searchClear')) : null,
|
|
740
899
|
),
|
|
741
|
-
h('span', { style: style.toolbarSpacer }),
|
|
742
|
-
h('span', { style: style.muted }, t('sessions.selected', { count: selectedIds.length })),
|
|
743
|
-
h(C.Btn, { onClick: () => runBatch(tab === 'archived' ? 'unarchive' : 'archive', selectedIds), disabled: busy || selectedIds.length === 0 || (feed.meta && feed.meta.archive && feed.meta.archive.available === false) }, tab === 'archived' ? t('sessions.unarchiveAction') : t('sessions.archiveAction')),
|
|
744
|
-
h(C.Btn, { tone: 'ghost', onClick: feed.reload, disabled: feed.status === 'loading' }, t('common.refresh')),
|
|
745
|
-
),
|
|
746
|
-
h(
|
|
747
|
-
'div',
|
|
748
|
-
{ style: style.row },
|
|
749
|
-
h('input', {
|
|
750
|
-
type: 'search',
|
|
751
|
-
style: style.input,
|
|
752
|
-
value: input,
|
|
753
|
-
placeholder: t('sessions.searchPlaceholder'),
|
|
754
|
-
'aria-label': t('sessions.searchAria'),
|
|
755
|
-
onChange: (event) => setInput(event.target.value),
|
|
756
|
-
}),
|
|
757
|
-
input.length > 0 ? h(C.Btn, { tone: 'ghost', onClick: () => setInput('') }, t('sessions.searchClear')) : null,
|
|
758
|
-
items.length > 0 ? h(C.Btn, { tone: 'ghost', onClick: () => toggleAll(), disabled: items.length === 0 }, allSelected ? t('sessions.selectNone') : t('sessions.selectAll')) : null,
|
|
759
|
-
),
|
|
760
|
-
h(
|
|
761
|
-
'div',
|
|
762
|
-
{ style: style.row },
|
|
763
900
|
h(
|
|
764
|
-
'
|
|
765
|
-
{
|
|
766
|
-
|
|
901
|
+
'div',
|
|
902
|
+
{ className: 'acc-row', style: { justifyContent: 'space-between', minHeight: '20px' } },
|
|
903
|
+
h(
|
|
904
|
+
'span',
|
|
905
|
+
{ style: style.faint },
|
|
906
|
+
feed.status === 'ready' ? `${t('sessions.loadedCount', { loaded: items.length, total: feed.total })} · ${searchMode}` : t('common.loading'),
|
|
907
|
+
),
|
|
908
|
+
h('span', { style: style.muted }, t('sessions.selected', { count: selectedIds.length })),
|
|
767
909
|
),
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
910
|
+
h(
|
|
911
|
+
'div',
|
|
912
|
+
{ className: 'acc-row', style: { gap: '6px' } },
|
|
913
|
+
items.length > 0 ? h(C.Btn, { tone: 'ghost', onClick: () => toggleAll(), disabled: items.length === 0 }, allSelected ? t('sessions.selectNone') : t('sessions.selectAll')) : null,
|
|
914
|
+
selectedIds.length > 0 ? h(C.Btn, { tone: 'ghost', onClick: () => setSelected(new Set()) }, t('sessions.clearSelection')) : null,
|
|
915
|
+
h(C.Btn, {
|
|
916
|
+
tone: 'primary',
|
|
917
|
+
onClick: () => setConfirm({ mode: tab === 'archived' ? 'unarchive' : 'archive', ids: selectedIds }),
|
|
918
|
+
disabled: busy || selectedIds.length === 0 || archiveUnavailable,
|
|
919
|
+
title: archiveUnavailable ? t('sessions.archiveUnavailableShort') : t('sessions.batchActionHint', { count: selectedIds.length }),
|
|
920
|
+
}, tab === 'archived' ? t('sessions.unarchiveAction') : t('sessions.archiveAction')),
|
|
921
|
+
h(C.Btn, { tone: 'ghost', onClick: feed.reload, disabled: feed.status === 'loading', icon: 'retry', ariaLabel: t('sessions.refreshList') }, t('common.refresh')),
|
|
922
|
+
),
|
|
923
|
+
deleteUnavailable ? h(C.Notice, { tone: 'info' }, t('sessions.deleteNoticeShort')) : null,
|
|
924
|
+
archiveUnavailable
|
|
925
|
+
? h(
|
|
926
|
+
C.Notice,
|
|
927
|
+
{ tone: 'warn' },
|
|
928
|
+
t('sessions.archiveUnavailableGeneric'),
|
|
929
|
+
ACC.l10n.raw(t('sessions.rawHostText'), String((feed.meta && feed.meta.archive && feed.meta.archive.reason) || (summary.data && summary.data.archive && summary.data.archive.reason) || '')),
|
|
930
|
+
)
|
|
771
931
|
: null,
|
|
772
|
-
|
|
932
|
+
h(AboutPanel, {
|
|
933
|
+
t,
|
|
934
|
+
items: [
|
|
935
|
+
deleteUnavailable ? t('sessions.deleteNotice') : '',
|
|
936
|
+
feed.meta && feed.meta.search && feed.meta.search.fulltext && feed.meta.search.fulltext.available === false
|
|
937
|
+
? t('sessions.searchFulltextDisabled')
|
|
938
|
+
: '',
|
|
939
|
+
feed.meta && feed.meta.search && feed.meta.search.titleIndex && feed.meta.search.titleIndex.complete === false && query.length > 0
|
|
940
|
+
? t('sessions.searchCoverage', { covered: feed.meta.search.titleIndex.covered, total: feed.meta.search.titleIndex.total })
|
|
941
|
+
: '',
|
|
942
|
+
currentSessionId.length === 0 ? t('sessions.currentHint') : '',
|
|
943
|
+
t('sessions.sizeGenerationNote'),
|
|
944
|
+
].filter((text) => text.length > 0),
|
|
945
|
+
}),
|
|
946
|
+
h(BatchOutcome, {
|
|
947
|
+
outcome,
|
|
948
|
+
t,
|
|
949
|
+
busy,
|
|
950
|
+
onRetry: () => { if (outcome && outcome.result && Array.isArray(outcome.result.failedIds)) runBatch(outcome.mode, outcome.result.failedIds) },
|
|
951
|
+
onDismiss: () => setOutcome(null),
|
|
952
|
+
}),
|
|
773
953
|
),
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
954
|
+
feed.status === 'loading'
|
|
955
|
+
? h(C.Loading, { label: t('sessions.loading') })
|
|
956
|
+
: feed.status === 'error'
|
|
957
|
+
? h(C.ErrorBox, { error: feed.error, onRetry: feed.reload, label: t('sessions.loadFailed') })
|
|
958
|
+
: items.length === 0
|
|
959
|
+
? (() => {
|
|
960
|
+
const emptyTitle = query.length > 0 ? t('sessions.emptySearch', { query }) : tab === 'archived' ? t('sessions.emptyArchived') : t('sessions.emptyAll')
|
|
961
|
+
const emptyHint = query.length > 0 ? t('sessions.emptySearchHint') : tab === 'archived' ? t('sessions.emptyArchivedHint') : t('sessions.emptyAllHint')
|
|
962
|
+
return h(C.Empty, {
|
|
963
|
+
title: emptyTitle,
|
|
964
|
+
hint: emptyHint,
|
|
965
|
+
icon: 'inbox',
|
|
966
|
+
action: h(
|
|
967
|
+
'div',
|
|
968
|
+
{ className: 'acc-row' },
|
|
969
|
+
h(C.Btn, { onClick: feed.reload, icon: 'retry' }, t('common.refresh')),
|
|
970
|
+
tab === 'archived' ? h(C.Btn, { tone: 'ghost', onClick: () => setTab('all') }, t('sessions.emptyBackToAll')) : null,
|
|
971
|
+
query.length > 0 ? h(C.Btn, { tone: 'ghost', onClick: () => setInput('') }, t('sessions.searchClear')) : null,
|
|
972
|
+
),
|
|
973
|
+
})
|
|
974
|
+
})()
|
|
975
|
+
: view === 'workspace'
|
|
976
|
+
? h(
|
|
977
|
+
'div',
|
|
978
|
+
{ style: style.column },
|
|
979
|
+
groups.map((group) =>
|
|
980
|
+
h(WorkspaceGroup, {
|
|
981
|
+
key: group.id,
|
|
982
|
+
group,
|
|
983
|
+
t,
|
|
984
|
+
selected,
|
|
985
|
+
expandedId,
|
|
986
|
+
onToggle: toggleOne,
|
|
987
|
+
onToggleAll: toggleAll,
|
|
988
|
+
onExpand: toggleExpand,
|
|
989
|
+
}),
|
|
990
|
+
),
|
|
991
|
+
)
|
|
992
|
+
: h(
|
|
993
|
+
'div',
|
|
994
|
+
{ style: { display: 'flex', flexDirection: 'column' } },
|
|
995
|
+
items.map((row) =>
|
|
996
|
+
h(SessionRow, {
|
|
997
|
+
key: row.id,
|
|
998
|
+
row,
|
|
999
|
+
t,
|
|
1000
|
+
selected: selected.has(row.id),
|
|
1001
|
+
expanded: expandedId === row.id,
|
|
1002
|
+
onToggle: toggleOne,
|
|
1003
|
+
onExpand: toggleExpand,
|
|
1004
|
+
}),
|
|
1005
|
+
),
|
|
1006
|
+
),
|
|
1007
|
+
feed.status === 'ready' && items.length > 0
|
|
1008
|
+
? feed.hasMore
|
|
1009
|
+
? h(
|
|
1010
|
+
'div',
|
|
1011
|
+
{ className: 'acc-row', style: { justifyContent: 'center' } },
|
|
1012
|
+
h(C.Btn, { onClick: feed.loadMore, disabled: feed.moreBusy }, feed.moreBusy ? t('sessions.loadingMore') : t('sessions.loadMore', { remaining })),
|
|
1013
|
+
)
|
|
1014
|
+
: h('div', { style: { ...style.faint, textAlign: 'center' } }, t('sessions.allLoaded', { total: feed.total }))
|
|
788
1015
|
: null,
|
|
789
|
-
h(BatchOutcome, { outcome, t, busy, onRetry: () => { if (manualRetryIds !== null) runBatch(outcome.mode, manualRetryIds) } }),
|
|
790
|
-
)
|
|
791
|
-
|
|
792
|
-
if (feed.status === 'loading') return h('div', { style: style.section }, banner, toolbar, h(C.Loading, { label: t('sessions.loading') }))
|
|
793
|
-
if (feed.status === 'error') {
|
|
794
|
-
return h('div', { style: style.section }, banner, toolbar, h(C.ErrorBox, { error: feed.error, onRetry: feed.reload, label: t('sessions.loadFailed') }))
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
if (items.length === 0) {
|
|
798
|
-
const emptyTitle = query.length > 0 ? t('sessions.emptySearch', { query }) : tab === 'archived' ? t('sessions.emptyArchived') : t('sessions.emptyAll')
|
|
799
|
-
const emptyHint = query.length > 0 ? t('sessions.emptySearchHint') : tab === 'archived' ? t('sessions.emptyArchivedHint') : t('sessions.emptyAllHint')
|
|
800
|
-
return h('div', { style: style.section }, banner, toolbar, h(C.Empty, { title: emptyTitle, hint: emptyHint }))
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
const body =
|
|
804
|
-
view === 'workspace'
|
|
805
|
-
? h(
|
|
806
|
-
'div',
|
|
807
|
-
{ style: style.column },
|
|
808
|
-
groups.map((group) =>
|
|
809
|
-
h(WorkspaceGroup, {
|
|
810
|
-
key: group.id,
|
|
811
|
-
group,
|
|
812
|
-
t,
|
|
813
|
-
selected,
|
|
814
|
-
expandedId,
|
|
815
|
-
onToggle: toggleOne,
|
|
816
|
-
onToggleAll: toggleAll,
|
|
817
|
-
onExpand: toggleExpand,
|
|
818
|
-
}),
|
|
819
|
-
),
|
|
820
|
-
feed.hasMore
|
|
821
|
-
? h('div', { style: style.row }, h(C.Btn, { onClick: feed.loadMore, disabled: feed.moreBusy }, feed.moreBusy ? t('sessions.loadingMore') : t('sessions.loadMore', { remaining })))
|
|
822
|
-
: h('div', { style: style.faint }, t('sessions.allLoaded', { total: feed.total })),
|
|
823
|
-
)
|
|
824
|
-
: h(
|
|
825
|
-
'div',
|
|
826
|
-
{ style: style.column },
|
|
827
|
-
h(SessionTable, {
|
|
828
|
-
rows: items,
|
|
829
|
-
t,
|
|
830
|
-
selected,
|
|
831
|
-
expandedId,
|
|
832
|
-
onToggle: toggleOne,
|
|
833
|
-
onToggleAll: () => toggleAll(),
|
|
834
|
-
onExpand: toggleExpand,
|
|
835
|
-
expandedRow,
|
|
836
|
-
}),
|
|
837
|
-
feed.hasMore
|
|
838
|
-
? h('div', { style: style.row }, h(C.Btn, { onClick: feed.loadMore, disabled: feed.moreBusy }, feed.moreBusy ? t('sessions.loadingMore') : t('sessions.loadMore', { remaining })))
|
|
839
|
-
: h('div', { style: style.faint }, t('sessions.allLoaded', { total: feed.total })),
|
|
840
|
-
)
|
|
841
|
-
|
|
842
|
-
return h(
|
|
843
|
-
'div',
|
|
844
|
-
{ style: style.section },
|
|
845
|
-
banner,
|
|
846
|
-
toolbar,
|
|
847
|
-
h(
|
|
848
|
-
'div',
|
|
849
|
-
{ style: style.column },
|
|
850
|
-
h('div', { style: style.row }, h('h3', { style: { margin: 0, fontSize: 13 } }, t('sessions.title')), h('span', { style: style.faint }, t('sessions.description'))),
|
|
851
|
-
h('span', { style: style.faint }, t('sessions.sizeGenerationNote')),
|
|
852
|
-
),
|
|
853
|
-
body,
|
|
854
1016
|
confirm === null
|
|
855
1017
|
? null
|
|
856
1018
|
: h(BatchConfirm, {
|
|
@@ -868,6 +1030,7 @@
|
|
|
868
1030
|
id: 'sessions',
|
|
869
1031
|
titleKey: 'nav.sessions',
|
|
870
1032
|
order: 30,
|
|
1033
|
+
group: 'insight',
|
|
871
1034
|
render: (props) => h(SessionsPage, props),
|
|
872
1035
|
})
|
|
873
1036
|
})()
|