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
|
@@ -4,9 +4,12 @@
|
|
|
4
4
|
* turn closed by crash repair (`interrupted`), an open raw tail that belongs to
|
|
5
5
|
* no running Agent, or synthetic `TOOL_OUTCOME_UNKNOWN` / `TOOL_NOT_STARTED`
|
|
6
6
|
* tool results. The page never offers a "continue" action: continuing happens in
|
|
7
|
-
* the host's native session UI, and this page only says so.
|
|
7
|
+
* the host's native session UI, and this page only says so — loudly, at the top.
|
|
8
|
+
*
|
|
9
|
+
* Layout: policy banner → scan controls + progress → candidate cards → running
|
|
10
|
+
* sessions and scan errors (collapsible) → capability facts. */
|
|
8
11
|
(function recoveryPage() {
|
|
9
|
-
|
|
12
|
+
const SIGNAL_KEYS = {
|
|
10
13
|
'turn-interrupted': 'recovery.signalTurnInterrupted',
|
|
11
14
|
'turn-open': 'recovery.signalTurnOpen',
|
|
12
15
|
'step-open': 'recovery.signalStepOpen',
|
|
@@ -14,24 +17,27 @@
|
|
|
14
17
|
'tool-not-started': 'recovery.signalNotStarted',
|
|
15
18
|
}
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
const ADVICE_KEYS = {
|
|
18
21
|
'continue-in-native-ui': 'recovery.adviceContinue',
|
|
19
22
|
'check-stalled-turn': 'recovery.adviceStalled',
|
|
20
23
|
'inspect-incomplete-log': 'recovery.adviceIncomplete',
|
|
21
24
|
'verify-tool-outcome': 'recovery.adviceVerifyTools',
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
var MONO_STYLE = { fontFamily: 'var(--ds-font-family-code, ui-monospace, monospace)', fontSize: '11px' }
|
|
26
|
-
var MUTED_STYLE = { color: 'var(--dsw-alias-label-secondary, inherit)' }
|
|
27
|
-
|
|
28
|
-
var LIVENESS_KEYS = {
|
|
27
|
+
const LIVENESS_KEYS = {
|
|
29
28
|
running: 'recovery.livenessRunning',
|
|
30
29
|
idle: 'recovery.livenessIdle',
|
|
31
30
|
'not-live': 'recovery.livenessNotLive',
|
|
32
31
|
unknown: 'recovery.livenessUnknown',
|
|
33
32
|
}
|
|
34
33
|
|
|
34
|
+
const PAGE_ROOT_STYLE = { display: 'flex', flexDirection: 'column', gap: '12px', padding: '8px 0' }
|
|
35
|
+
const STACK_STYLE = { display: 'flex', flexDirection: 'column', gap: '8px' }
|
|
36
|
+
const MONO_STYLE = { fontFamily: 'var(--ds-font-family-code, ui-monospace, monospace)', fontSize: '11px' }
|
|
37
|
+
const MUTED_STYLE = { color: 'var(--dsw-alias-label-secondary, inherit)' }
|
|
38
|
+
const FACT_STYLE = { display: 'flex', flexDirection: 'column', gap: '2px' }
|
|
39
|
+
const FACT_LABEL_STYLE = { color: 'var(--dsw-alias-label-tertiary)', font: '12px/16px var(--dsw-font-family, sans-serif)' }
|
|
40
|
+
|
|
35
41
|
/** @param {unknown} value @param {Function} t @returns {string} */
|
|
36
42
|
function timeText(value, t) {
|
|
37
43
|
if (typeof value !== 'string' || value.length === 0) return String(t('common.unknown'))
|
|
@@ -50,7 +56,7 @@
|
|
|
50
56
|
if (!Array.isArray(tools) || tools.length === 0) return String(t('recovery.noTools'))
|
|
51
57
|
return tools
|
|
52
58
|
.map((tool) => `${tool.name === null || tool.name === undefined ? t('common.unknown') : String(tool.name)} × ${ACC.fmt.num(tool.count)}`)
|
|
53
|
-
.join(',')
|
|
59
|
+
.join(ACC.l10n.lang() === 'en' ? ', ' : ',')
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
/** @param {Record<string, unknown>} item @param {Function} t @returns {string} */
|
|
@@ -73,6 +79,79 @@
|
|
|
73
79
|
}
|
|
74
80
|
}
|
|
75
81
|
|
|
82
|
+
/** Inline copy feedback (the host has no toast service). */
|
|
83
|
+
function CopyButton(props) {
|
|
84
|
+
const [state, setState] = ACC.useState('idle')
|
|
85
|
+
const copy = ACC.useCallback(() => {
|
|
86
|
+
const text = String(props.text || '')
|
|
87
|
+
if (text.length === 0) {
|
|
88
|
+
setState('failed')
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
if (typeof navigator !== 'undefined' && navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
|
|
92
|
+
navigator.clipboard.writeText(text).then(() => setState('done'), () => setState('failed'))
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
setState('failed')
|
|
96
|
+
}, [props.text])
|
|
97
|
+
ACC.useEffect(() => {
|
|
98
|
+
if (state === 'idle') return undefined
|
|
99
|
+
const timer = setTimeout(() => setState('idle'), 1800)
|
|
100
|
+
return () => clearTimeout(timer)
|
|
101
|
+
}, [state])
|
|
102
|
+
const label = state === 'done' ? props.t('recovery.copied') : state === 'failed' ? props.t('recovery.copyFailed') : props.label || props.t('recovery.copy')
|
|
103
|
+
return h(C.Btn, { tone: 'ghost', onClick: copy, title: label, style: { padding: '0 6px' } }, label)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Collapsible block with a real button header (keyboard + ARIA). */
|
|
107
|
+
function Disclosure(props) {
|
|
108
|
+
return h(
|
|
109
|
+
'div',
|
|
110
|
+
{ style: STACK_STYLE },
|
|
111
|
+
h(
|
|
112
|
+
'button',
|
|
113
|
+
{
|
|
114
|
+
type: 'button',
|
|
115
|
+
onClick: props.onToggle,
|
|
116
|
+
'aria-expanded': props.open,
|
|
117
|
+
style: {
|
|
118
|
+
display: 'flex',
|
|
119
|
+
alignItems: 'center',
|
|
120
|
+
gap: '6px',
|
|
121
|
+
padding: '2px 0',
|
|
122
|
+
border: 0,
|
|
123
|
+
background: 'transparent',
|
|
124
|
+
color: 'inherit',
|
|
125
|
+
font: 'inherit',
|
|
126
|
+
cursor: 'pointer',
|
|
127
|
+
textAlign: 'left',
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
h('span', { 'aria-hidden': 'true' }, props.open ? '▾' : '▸'),
|
|
131
|
+
h('span', { style: MUTED_STYLE }, props.label),
|
|
132
|
+
),
|
|
133
|
+
props.open ? props.children : null,
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Prominent "detect only" banner: this page cannot and will not resume. */
|
|
138
|
+
function PolicyBanner(props) {
|
|
139
|
+
const { t } = props
|
|
140
|
+
return h(
|
|
141
|
+
C.Notice,
|
|
142
|
+
{ tone: 'warn' },
|
|
143
|
+
h('div', { style: { display: 'flex', flexDirection: 'column', gap: '4px' } },
|
|
144
|
+
h('strong', null, t('recovery.detectOnlyTitle')),
|
|
145
|
+
h('div', null, t('recovery.detectOnlyBody')),
|
|
146
|
+
h('ul', { style: { margin: '2px 0 0', paddingLeft: '18px' } },
|
|
147
|
+
h('li', null, t('recovery.detectOnlyBullet1')),
|
|
148
|
+
h('li', null, t('recovery.detectOnlyBullet2')),
|
|
149
|
+
h('li', null, t('recovery.detectOnlyBullet3')),
|
|
150
|
+
),
|
|
151
|
+
),
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
|
|
76
155
|
/** @param {{ title?: unknown, candidate: Record<string, unknown>, t: Function }} props */
|
|
77
156
|
function CandidateCard(props) {
|
|
78
157
|
const candidate = props.candidate
|
|
@@ -83,6 +162,23 @@
|
|
|
83
162
|
const adviceKey = ADVICE_KEYS[String(candidate.recommendation || '')] || 'recovery.adviceDefault'
|
|
84
163
|
const confidenceKey = candidate.confidence === 'high' ? 'recovery.confidenceHigh' : candidate.confidence === 'medium' ? 'recovery.confidenceMedium' : 'recovery.confidenceLow'
|
|
85
164
|
const toolsSourceKey = candidate.toolsSource === 'unknown-outcome' ? 'recovery.toolsSourceUnknown' : candidate.toolsSource === 'pending' ? 'recovery.toolsSourcePending' : null
|
|
165
|
+
const [openEvidence, setOpenEvidence] = ACC.useState(false)
|
|
166
|
+
const [openMessage, setOpenMessage] = ACC.useState(false)
|
|
167
|
+
const hasMessage = message && typeof message === 'object' && typeof message.text === 'string' && message.text.length > 0
|
|
168
|
+
const evidenceText_ = evidence.map((item) => `#${String(item.seq)} ${String(item.type)} — ${evidenceText(item, t)}`).join('\n')
|
|
169
|
+
const summaryText = [
|
|
170
|
+
`${t('recovery.sessionId')}: ${String(candidate.sessionId || '')}`,
|
|
171
|
+
`${t('recovery.interruptedAt')}: ${timeText(candidate.interruptedAt, t)}`,
|
|
172
|
+
`${t('recovery.confidence')}: ${t(confidenceKey)}`,
|
|
173
|
+
`${t('recovery.liveness')}: ${t(LIVENESS_KEYS[String(candidate.liveness || 'unknown')] || 'recovery.livenessUnknown')}`,
|
|
174
|
+
`${t('recovery.tools')}: ${toolsText(candidate.tools, t)}`,
|
|
175
|
+
`${t('recovery.advice')}: ${t(adviceKey)}`,
|
|
176
|
+
evidenceText_,
|
|
177
|
+
].join('\n')
|
|
178
|
+
|
|
179
|
+
/** One small fact cell. */
|
|
180
|
+
const fact = (label, value) => h('div', { style: FACT_STYLE }, h('span', { style: FACT_LABEL_STYLE }, label), h('span', null, value))
|
|
181
|
+
|
|
86
182
|
return h(
|
|
87
183
|
C.Card,
|
|
88
184
|
{
|
|
@@ -92,7 +188,9 @@
|
|
|
92
188
|
candidate.title ? String(candidate.title) : String(t('recovery.untitled')),
|
|
93
189
|
h(C.Badge, { tone: 'info' }, `${t('recovery.confidence')}: ${t(confidenceKey)}`),
|
|
94
190
|
h(C.Badge, { tone: candidate.live === true ? 'neutral' : 'warn' }, candidate.live === true ? t('recovery.liveSession') : t('recovery.storedSession')),
|
|
191
|
+
h(C.Badge, { tone: 'neutral' }, t(LIVENESS_KEYS[String(candidate.liveness || 'unknown')] || 'recovery.livenessUnknown')),
|
|
95
192
|
),
|
|
193
|
+
actions: h(CopyButton, { text: summaryText, t, label: t('recovery.copyEvidence') }),
|
|
96
194
|
},
|
|
97
195
|
signals.length > 0
|
|
98
196
|
? h(
|
|
@@ -103,76 +201,137 @@
|
|
|
103
201
|
),
|
|
104
202
|
)
|
|
105
203
|
: null,
|
|
106
|
-
h(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
label: t('recovery.lastUserMessage'),
|
|
125
|
-
value:
|
|
126
|
-
message && typeof message === 'object' && typeof message.text === 'string' && message.text.length > 0
|
|
127
|
-
? h(C.Code, { text: String(message.text) })
|
|
128
|
-
: h('span', { style: MUTED_STYLE }, t('recovery.noUserMessage')),
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
}),
|
|
204
|
+
h(
|
|
205
|
+
'div',
|
|
206
|
+
{ className: 'acc-grid-fit' },
|
|
207
|
+
fact(t('recovery.sessionId'), h('span', { style: MONO_STYLE }, String(candidate.sessionId || ''))),
|
|
208
|
+
fact(t('recovery.interruptedAt'), timeText(candidate.interruptedAt, t)),
|
|
209
|
+
fact(
|
|
210
|
+
t('recovery.lastEvent'),
|
|
211
|
+
candidate.lastEvent ? h('span', { style: MONO_STYLE }, `#${String(candidate.lastEvent.seq)} ${String(candidate.lastEvent.type)}`) : String(t('common.unknown')),
|
|
212
|
+
),
|
|
213
|
+
fact(t('recovery.turn'), candidate.turn === null || candidate.turn === undefined ? String(t('common.unknown')) : String(candidate.turn)),
|
|
214
|
+
fact(t('recovery.tools'), `${toolsText(candidate.tools, t)}${toolsSourceKey === null ? '' : ` ${t(toolsSourceKey)}`}`),
|
|
215
|
+
fact(t('recovery.cwd'), candidate.cwd ? h('span', { style: MONO_STYLE }, String(candidate.cwd)) : String(t('common.unknown'))),
|
|
216
|
+
),
|
|
217
|
+
h(
|
|
218
|
+
C.Notice,
|
|
219
|
+
{ tone: 'info' },
|
|
220
|
+
h('div', null, h('strong', null, `${t('recovery.advice')}: `), t(adviceKey)),
|
|
221
|
+
),
|
|
132
222
|
evidence.length > 0
|
|
133
223
|
? h(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
h(
|
|
137
|
-
h(
|
|
138
|
-
C.Code,
|
|
139
|
-
{
|
|
140
|
-
text: evidence
|
|
141
|
-
.map((item) => `#${String(item.seq)} ${String(item.type)} — ${evidenceText(item, t)}`)
|
|
142
|
-
.join('\n'),
|
|
143
|
-
},
|
|
144
|
-
),
|
|
224
|
+
Disclosure,
|
|
225
|
+
{ open: openEvidence, onToggle: () => setOpenEvidence((value) => !value), label: t('recovery.evidenceToggle', { count: evidence.length }) },
|
|
226
|
+
h(C.Code, { text: evidenceText_ }),
|
|
145
227
|
typeof candidate.evidenceTruncated === 'number' && candidate.evidenceTruncated > 0
|
|
146
228
|
? h('div', { style: MUTED_STYLE }, t('recovery.evidenceTruncated', { count: ACC.fmt.num(candidate.evidenceTruncated) }))
|
|
147
229
|
: null,
|
|
148
230
|
)
|
|
149
231
|
: null,
|
|
232
|
+
hasMessage
|
|
233
|
+
? h(
|
|
234
|
+
Disclosure,
|
|
235
|
+
{ open: openMessage, onToggle: () => setOpenMessage((value) => !value), label: t('recovery.messageToggle') },
|
|
236
|
+
h(C.Code, { text: String(message.text) }),
|
|
237
|
+
)
|
|
238
|
+
: h('div', { style: MUTED_STYLE }, t('recovery.noUserMessage')),
|
|
239
|
+
)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* A read-only scan with a visible clock and a cancel path. The scan is one
|
|
244
|
+
* request; cancelling aborts it so a slow host never looks stuck.
|
|
245
|
+
* @param {number} limit
|
|
246
|
+
*/
|
|
247
|
+
function useScan(limit) {
|
|
248
|
+
const [state, setState] = ACC.useState({ status: 'loading' })
|
|
249
|
+
const [attempt, setAttempt] = ACC.useState(0)
|
|
250
|
+
const controllerRef = ACC.useRef(null)
|
|
251
|
+
ACC.useEffect(() => {
|
|
252
|
+
const controller = new AbortController()
|
|
253
|
+
controllerRef.current = controller
|
|
254
|
+
let alive = true
|
|
255
|
+
setState({ status: 'loading' })
|
|
256
|
+
ACC.api('recovery.scan', { limit, refresh: true }, { signal: controller.signal }).then(
|
|
257
|
+
(data) => {
|
|
258
|
+
if (alive) setState({ status: 'ready', data })
|
|
259
|
+
},
|
|
260
|
+
(error) => {
|
|
261
|
+
if (!alive) return
|
|
262
|
+
if (error && error.name === 'AbortError') {
|
|
263
|
+
setState({ status: 'cancelled' })
|
|
264
|
+
return
|
|
265
|
+
}
|
|
266
|
+
setState({ status: 'error', error })
|
|
267
|
+
},
|
|
268
|
+
)
|
|
269
|
+
return () => {
|
|
270
|
+
alive = false
|
|
271
|
+
controller.abort()
|
|
272
|
+
}
|
|
273
|
+
}, [limit, attempt])
|
|
274
|
+
return {
|
|
275
|
+
...state,
|
|
276
|
+
reload: ACC.useCallback(() => setAttempt((value) => value + 1), []),
|
|
277
|
+
cancel: ACC.useCallback(() => {
|
|
278
|
+
if (controllerRef.current !== null) controllerRef.current.abort()
|
|
279
|
+
}, []),
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** Loading state for the scan: elapsed time, scan bound and a cancel button. */
|
|
284
|
+
function ScanProgress(props) {
|
|
285
|
+
const { t, limit, onCancel } = props
|
|
286
|
+
const [elapsed, setElapsed] = ACC.useState(0)
|
|
287
|
+
ACC.useEffect(() => {
|
|
288
|
+
const started = Date.now()
|
|
289
|
+
const timer = setInterval(() => setElapsed(Math.floor((Date.now() - started) / 1000)), 500)
|
|
290
|
+
return () => clearInterval(timer)
|
|
291
|
+
}, [])
|
|
292
|
+
return h(
|
|
293
|
+
'div',
|
|
294
|
+
{ className: 'acc-card', 'aria-live': 'polite', style: { padding: '12px 16px', display: 'flex', flexDirection: 'column', gap: '8px' } },
|
|
150
295
|
h(
|
|
151
|
-
|
|
152
|
-
{
|
|
153
|
-
h(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
:
|
|
296
|
+
'div',
|
|
297
|
+
{ className: 'acc-row', style: { justifyContent: 'space-between' } },
|
|
298
|
+
h(
|
|
299
|
+
'div',
|
|
300
|
+
{ className: 'acc-row' },
|
|
301
|
+
h('span', { className: 'acc-spinner', 'aria-hidden': 'true' }),
|
|
302
|
+
h('strong', null, t('recovery.scanningProgress', { seconds: elapsed })),
|
|
303
|
+
),
|
|
304
|
+
h(C.Btn, { tone: 'ghost', onClick: onCancel, title: t('recovery.cancelHint') }, t('recovery.cancel')),
|
|
157
305
|
),
|
|
306
|
+
h('div', { style: MUTED_STYLE }, `${t('recovery.scanningHint', { limit: ACC.fmt.num(limit) })} · ${t('recovery.elapsed', { seconds: elapsed })}`),
|
|
158
307
|
)
|
|
159
308
|
}
|
|
160
309
|
|
|
161
|
-
/** @param {{ data: Record<string, any>, t: Function, reload: Function }} props */
|
|
310
|
+
/** @param {{ data: Record<string, any>, t: Function, reload: Function, navigate: Function, limit: number, onLimit: Function }} props */
|
|
162
311
|
function RecoveryBody(props) {
|
|
163
312
|
const data = props.data
|
|
164
313
|
const t = props.t
|
|
314
|
+
// Hooks stay unconditional: every branch below renders from these.
|
|
315
|
+
const [openActive, setOpenActive] = ACC.useState(false)
|
|
316
|
+
const [openErrors, setOpenErrors] = ACC.useState(false)
|
|
317
|
+
const [openCapability, setOpenCapability] = ACC.useState(false)
|
|
165
318
|
if (data.available === false) {
|
|
166
319
|
return h(
|
|
167
320
|
'div',
|
|
168
321
|
{ style: PAGE_ROOT_STYLE },
|
|
169
|
-
h(C.Notice, { tone: 'warn' }, t('recovery.detectOnly')),
|
|
170
322
|
h(
|
|
171
323
|
C.Card,
|
|
172
324
|
{ title: t('recovery.unavailableTitle'), actions: h(C.Btn, { onClick: props.reload }, t('recovery.scan')) },
|
|
173
|
-
h(
|
|
174
|
-
|
|
325
|
+
h(
|
|
326
|
+
C.Notice,
|
|
327
|
+
{ tone: 'warn' },
|
|
328
|
+
ACC.l10n.host('recovery.scanUnavailable', data.reason) || t('common.unavailable'),
|
|
329
|
+
ACC.l10n.raw(t('recovery.rawHostText'), data.reason),
|
|
330
|
+
),
|
|
331
|
+
ACC.l10n.host('recovery.scanUnavailableHint', data.hint) ? h('div', { style: MUTED_STYLE }, ACC.l10n.host('recovery.scanUnavailableHint', data.hint)) : null,
|
|
332
|
+
ACC.l10n.raw(t('recovery.rawHostText'), data.hint),
|
|
175
333
|
h('div', null, t('recovery.alternative')),
|
|
334
|
+
h(C.Btn, { onClick: () => props.navigate('diagnostics') }, t('recovery.openDiagnostics')),
|
|
176
335
|
),
|
|
177
336
|
)
|
|
178
337
|
}
|
|
@@ -183,111 +342,153 @@
|
|
|
183
342
|
const scan = capabilities.scan || {}
|
|
184
343
|
const resume = capabilities.resume || {}
|
|
185
344
|
const audit = data.audit || {}
|
|
345
|
+
|
|
186
346
|
return h(
|
|
187
347
|
'div',
|
|
188
348
|
{ style: PAGE_ROOT_STYLE },
|
|
189
|
-
h(C.Notice, { tone: 'warn' }, t('recovery.detectOnly')),
|
|
190
349
|
h(
|
|
191
350
|
C.Card,
|
|
192
351
|
{
|
|
193
352
|
title: t('recovery.summaryTitle'),
|
|
194
|
-
|
|
353
|
+
subtitle: data.generatedAt ? `${t('recovery.generatedAt')}: ${ACC.l10n.dateTime(data.generatedAt, t)}` : undefined,
|
|
354
|
+
actions: h(
|
|
355
|
+
'div',
|
|
356
|
+
{ className: 'acc-row' },
|
|
357
|
+
h(
|
|
358
|
+
'select',
|
|
359
|
+
{
|
|
360
|
+
className: 'acc-select',
|
|
361
|
+
value: String(props.limit),
|
|
362
|
+
'aria-label': t('recovery.scanRange'),
|
|
363
|
+
title: t('recovery.scanRangeHint'),
|
|
364
|
+
onChange: (event) => props.onLimit(Number(event.target.value)),
|
|
365
|
+
},
|
|
366
|
+
[30, 60, 100].map((value) => h('option', { key: String(value), value: String(value) }, t('recovery.scanRangeN', { count: value }))),
|
|
367
|
+
),
|
|
368
|
+
h(C.Btn, { onClick: props.reload }, t('recovery.scan')),
|
|
369
|
+
),
|
|
195
370
|
},
|
|
196
|
-
h(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
label: t('recovery.capabilityResume'),
|
|
208
|
-
value: resume.available === false ? t('recovery.resumeUnavailable') : t('recovery.resumeNative'),
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
label: t('common.audit'),
|
|
212
|
-
value: audit.recorded === true ? t('recovery.auditRecorded') : t('recovery.auditFailed', { reason: String(audit.reason || t('common.unknown')) }),
|
|
213
|
-
},
|
|
214
|
-
],
|
|
215
|
-
}),
|
|
371
|
+
h(
|
|
372
|
+
'div',
|
|
373
|
+
{ className: 'acc-grid-fit' },
|
|
374
|
+
h('div', { style: FACT_STYLE }, h('span', { style: FACT_LABEL_STYLE }, t('recovery.scanned')), h('strong', null, t('recovery.scannedValue', { scanned: ACC.fmt.num(data.scanned), total: ACC.fmt.num(data.total) }))),
|
|
375
|
+
h('div', { style: FACT_STYLE }, h('span', { style: FACT_LABEL_STYLE }, t('recovery.scannedEvents')), h('strong', null, ACC.fmt.num(data.eventsRead))),
|
|
376
|
+
h('div', { style: FACT_STYLE }, h('span', { style: FACT_LABEL_STYLE }, t('recovery.candidateCount')), h('strong', null, ACC.fmt.num(candidates.length))),
|
|
377
|
+
h('div', { style: FACT_STYLE }, h('span', { style: FACT_LABEL_STYLE }, t('recovery.activeCount')), h('strong', null, ACC.fmt.num(active.length))),
|
|
378
|
+
h('div', { style: FACT_STYLE }, h('span', { style: FACT_LABEL_STYLE }, t('recovery.errorCount')), h('strong', null, ACC.fmt.num(errors.length))),
|
|
379
|
+
),
|
|
216
380
|
h(C.Truncated, { truncated: data.truncated === true, label: t('recovery.truncated', { limit: ACC.fmt.num(data.limit) }) }),
|
|
217
381
|
data.budgetExceeded === true ? h(C.Notice, { tone: 'warn' }, t('recovery.budget')) : null,
|
|
382
|
+
active.length > 0
|
|
383
|
+
? h(
|
|
384
|
+
Disclosure,
|
|
385
|
+
{ open: openActive, onToggle: () => setOpenActive((value) => !value), label: `${t('recovery.activeTitle')}(${active.length})` },
|
|
386
|
+
h(C.Notice, { tone: 'neutral' }, t('recovery.activeNotice', { count: ACC.fmt.num(active.length) })),
|
|
387
|
+
h(
|
|
388
|
+
'ul',
|
|
389
|
+
{ style: { margin: 0, paddingLeft: '18px', ...MUTED_STYLE } },
|
|
390
|
+
active.map((entry) =>
|
|
391
|
+
h('li', { key: String(entry.sessionId) }, `${entry.title ? String(entry.title) : String(entry.sessionId)}(turn ${String(entry.turn)})`),
|
|
392
|
+
),
|
|
393
|
+
),
|
|
394
|
+
)
|
|
395
|
+
: null,
|
|
396
|
+
errors.length > 0
|
|
397
|
+
? h(
|
|
398
|
+
Disclosure,
|
|
399
|
+
{ open: openErrors, onToggle: () => setOpenErrors((value) => !value), label: `${t('recovery.errorsTitle')}(${errors.length})` },
|
|
400
|
+
h(C.Notice, { tone: 'warn' }, t('recovery.errorsNotice', { count: ACC.fmt.num(errors.length) })),
|
|
401
|
+
h(
|
|
402
|
+
'ul',
|
|
403
|
+
{ style: { margin: 0, paddingLeft: '18px', ...MUTED_STYLE } },
|
|
404
|
+
errors.map((entry) => h('li', { key: `${String(entry.sessionId)}:${String(entry.code)}` }, `${String(entry.sessionId)}: ${String(entry.code)}`)),
|
|
405
|
+
),
|
|
406
|
+
)
|
|
407
|
+
: null,
|
|
218
408
|
),
|
|
219
409
|
candidates.length === 0
|
|
220
|
-
? h(C.Empty, {
|
|
410
|
+
? h(C.Empty, {
|
|
411
|
+
title: t('recovery.empty'),
|
|
412
|
+
hint: t('recovery.emptyHint'),
|
|
413
|
+
action: h(
|
|
414
|
+
'div',
|
|
415
|
+
{ className: 'acc-row' },
|
|
416
|
+
h(C.Btn, { tone: 'primary', onClick: props.reload }, t('recovery.emptyRescan')),
|
|
417
|
+
h(C.Btn, { onClick: () => props.navigate('sessions') }, t('recovery.emptySessions')),
|
|
418
|
+
),
|
|
419
|
+
})
|
|
221
420
|
: h(
|
|
222
421
|
'div',
|
|
223
|
-
|
|
422
|
+
{ style: STACK_STYLE },
|
|
423
|
+
h('h3', { className: 'acc-section-title' }, t('recovery.candidatesHeading', { count: candidates.length })),
|
|
224
424
|
candidates.map((candidate) => h(CandidateCard, { key: String(candidate.sessionId), candidate, t })),
|
|
225
425
|
),
|
|
226
|
-
active.length > 0
|
|
227
|
-
? h(
|
|
228
|
-
C.Notice,
|
|
229
|
-
{ tone: 'neutral' },
|
|
230
|
-
t('recovery.activeNotice', { count: ACC.fmt.num(active.length) }),
|
|
231
|
-
h(
|
|
232
|
-
'div',
|
|
233
|
-
{ style: MUTED_STYLE },
|
|
234
|
-
active
|
|
235
|
-
.slice(0, 5)
|
|
236
|
-
.map((entry) => `${entry.title ? String(entry.title) : String(entry.sessionId)}(turn ${String(entry.turn)})`)
|
|
237
|
-
.join(','),
|
|
238
|
-
),
|
|
239
|
-
)
|
|
240
|
-
: null,
|
|
241
|
-
errors.length > 0
|
|
242
|
-
? h(
|
|
243
|
-
C.Notice,
|
|
244
|
-
{ tone: 'warn' },
|
|
245
|
-
t('recovery.errorsNotice', { count: ACC.fmt.num(errors.length) }),
|
|
246
|
-
h(
|
|
247
|
-
'div',
|
|
248
|
-
{ style: MUTED_STYLE },
|
|
249
|
-
errors
|
|
250
|
-
.slice(0, 5)
|
|
251
|
-
.map((entry) => `${String(entry.sessionId)}: ${String(entry.code)}`)
|
|
252
|
-
.join(','),
|
|
253
|
-
),
|
|
254
|
-
)
|
|
255
|
-
: null,
|
|
256
426
|
h(
|
|
257
427
|
C.Card,
|
|
258
428
|
{ title: t('recovery.capabilityTitle') },
|
|
259
|
-
h(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
429
|
+
h(
|
|
430
|
+
Disclosure,
|
|
431
|
+
{ open: openCapability, onToggle: () => setOpenCapability((value) => !value), label: t('recovery.capabilityToggle') },
|
|
432
|
+
h(C.KeyValues, {
|
|
433
|
+
items: [
|
|
434
|
+
{
|
|
435
|
+
label: t('recovery.capabilityScan'),
|
|
436
|
+
value: scan.available === false ? ACC.l10n.host('recovery.scanUnavailable', scan.reason) || t('common.unavailable') : t('recovery.capabilityScanMethod', { method: methodText(scan.method, t) }),
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
label: t('recovery.capabilityResume'),
|
|
440
|
+
value: resume.available === false ? t('recovery.resumeUnavailable') : t('recovery.resumeNative'),
|
|
441
|
+
},
|
|
442
|
+
{ label: t('recovery.policyTitle'), value: t('recovery.policyBody') },
|
|
443
|
+
{
|
|
444
|
+
label: t('recovery.auditLabel'),
|
|
445
|
+
value:
|
|
446
|
+
audit.recorded === true
|
|
447
|
+
? t('recovery.auditRecorded')
|
|
448
|
+
: t('recovery.auditFailedGeneric'),
|
|
449
|
+
},
|
|
450
|
+
],
|
|
451
|
+
}),
|
|
452
|
+
),
|
|
275
453
|
),
|
|
276
454
|
)
|
|
277
455
|
}
|
|
278
456
|
|
|
279
|
-
/** @param {{ t: Function }} props */
|
|
457
|
+
/** @param {{ t: Function, navigate: Function }} props */
|
|
280
458
|
function RecoveryPage(props) {
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
459
|
+
const [limit, setLimit] = ACC.useState(30)
|
|
460
|
+
const state = useScan(limit)
|
|
461
|
+
return h(
|
|
462
|
+
'div',
|
|
463
|
+
{ style: PAGE_ROOT_STYLE },
|
|
464
|
+
h(PolicyBanner, { t: props.t }),
|
|
465
|
+
state.status === 'loading'
|
|
466
|
+
? h(ScanProgress, { t: props.t, limit, onCancel: state.cancel })
|
|
467
|
+
: state.status === 'cancelled'
|
|
468
|
+
? h(
|
|
469
|
+
C.Notice,
|
|
470
|
+
{ tone: 'info' },
|
|
471
|
+
props.t('recovery.cancelled'),
|
|
472
|
+
h(C.Btn, { onClick: state.reload, icon: 'retry' }, props.t('recovery.rescan')),
|
|
473
|
+
)
|
|
474
|
+
: state.status === 'error'
|
|
475
|
+
? h(C.ErrorBox, { error: state.error, onRetry: state.reload, label: props.t('recovery.failed') })
|
|
476
|
+
: h(RecoveryBody, {
|
|
477
|
+
data: state.data,
|
|
478
|
+
t: props.t,
|
|
479
|
+
reload: state.reload,
|
|
480
|
+
navigate: props.navigate,
|
|
481
|
+
limit,
|
|
482
|
+
onLimit: setLimit,
|
|
483
|
+
}),
|
|
484
|
+
)
|
|
285
485
|
}
|
|
286
486
|
|
|
287
487
|
ACC.registerPage({
|
|
288
488
|
id: 'recovery',
|
|
289
489
|
titleKey: 'nav.recovery',
|
|
290
490
|
order: 90,
|
|
491
|
+
group: 'maintain',
|
|
291
492
|
render: (props) => h(RecoveryPage, props),
|
|
292
493
|
})
|
|
293
494
|
})()
|