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,11 +1,177 @@
|
|
|
1
|
-
/* AGENTS.md editor page — instruction-chain list
|
|
2
|
-
*
|
|
1
|
+
/* AGENTS.md editor page — instruction-chain list, editor with its own metadata
|
|
2
|
+
* block, severity-grouped validation with per-line jumps, and backup history.
|
|
3
3
|
*
|
|
4
4
|
* The page owns no transport: every read/write goes through ACC.api, which is
|
|
5
|
-
* the document-relative POST channel of this plugin. Colors use only the
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* the document-relative POST channel of this plugin. Colors use only the host's
|
|
6
|
+
* semantic `--dsw-alias-*` aliases (dark mode is covered by the host redefining
|
|
7
|
+
* the same names). The settings content column already scrolls and is narrow
|
|
8
|
+
* (~360px), so the file list stacks above the editor and only the list itself
|
|
9
|
+
* scrolls; the page never claims height/overflow. */
|
|
10
|
+
/* --------------------------------------------------------------------------
|
|
11
|
+
* Shared page-side formatting attached to the kernel object.
|
|
12
|
+
*
|
|
13
|
+
* agents.js is the first page in the build order (scripts/build-client.mjs
|
|
14
|
+
* concatenates pages alphabetically), so these helpers exist before any page
|
|
15
|
+
* renders. Cross-file symbols belong on `ACC` per the client contract
|
|
16
|
+
* (docs/01-CONTRACT.md §4.1); nothing here touches the host or the document
|
|
17
|
+
* tree beyond reading the declared UI language.
|
|
18
|
+
* ------------------------------------------------------------------------ */
|
|
19
|
+
ACC.l10n = (function createL10n() {
|
|
20
|
+
/* CJK ideographs plus CJK/full-width punctuation: what the English UI must
|
|
21
|
+
* never render as its own copy. Data the user authored (file bodies, session
|
|
22
|
+
* titles, tool output) is exempt and stays visible. */
|
|
23
|
+
const CJK = /[\u3000-\u303f\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff00-\uffef]/
|
|
24
|
+
|
|
25
|
+
function lang() {
|
|
26
|
+
try {
|
|
27
|
+
if (typeof ACC.lang === 'function') {
|
|
28
|
+
const value = ACC.lang()
|
|
29
|
+
if (value === 'en' || value === 'zh') return value
|
|
30
|
+
}
|
|
31
|
+
} catch {
|
|
32
|
+
// fall through to the document language
|
|
33
|
+
}
|
|
34
|
+
let declared = 'zh'
|
|
35
|
+
try {
|
|
36
|
+
declared = String(document.documentElement.lang || 'zh')
|
|
37
|
+
} catch {
|
|
38
|
+
declared = 'zh'
|
|
39
|
+
}
|
|
40
|
+
return declared.toLowerCase().indexOf('en') === 0 ? 'en' : 'zh'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function locale() {
|
|
44
|
+
return lang() === 'en' ? 'en-US' : 'zh-CN'
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function hasCjk(text) {
|
|
48
|
+
return CJK.test(String(text === null || text === undefined ? '' : text))
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function lookup(key) {
|
|
52
|
+
const dictionary = ACC.i18n && ACC.i18n[lang()]
|
|
53
|
+
return dictionary && typeof dictionary[key] === 'string' ? dictionary[key] : undefined
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Dictionary value for the current language, or `fallback`. */
|
|
57
|
+
function map(key, fallback) {
|
|
58
|
+
const value = lookup(key)
|
|
59
|
+
if (value !== undefined) return value
|
|
60
|
+
return fallback === undefined || fallback === null ? '' : String(fallback)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Host-provided free text. In Chinese it is shown as-is; in English a mapped
|
|
65
|
+
* translation wins, then ASCII-only host text is shown verbatim, and text
|
|
66
|
+
* that would leak CJK into the English UI is replaced by '' (the caller
|
|
67
|
+
* offers the original through `raw()`).
|
|
68
|
+
*/
|
|
69
|
+
function host(key, hostText) {
|
|
70
|
+
const original = hostText === null || hostText === undefined ? '' : String(hostText)
|
|
71
|
+
if (original.length === 0) return ''
|
|
72
|
+
if (lang() !== 'en') return original
|
|
73
|
+
const mapped = lookup(key)
|
|
74
|
+
if (mapped !== undefined) return mapped
|
|
75
|
+
/* ASCII-only host text (evidence, codes, paths) is safe to show verbatim. */
|
|
76
|
+
if (hasCjk(original)) return ''
|
|
77
|
+
return original
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Same as `host()` but never returns an empty string. */
|
|
81
|
+
function hostOr(key, hostText, fallback) {
|
|
82
|
+
const value = host(key, hostText)
|
|
83
|
+
return value.length > 0 ? value : String(fallback === undefined ? '' : fallback)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function toTime(value) {
|
|
87
|
+
if (typeof value === 'number') return Number.isFinite(value) ? value : NaN
|
|
88
|
+
const parsed = Date.parse(String(value))
|
|
89
|
+
return Number.isFinite(parsed) ? parsed : NaN
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Locale-aware relative time ("4 minutes ago" / "4 分钟前"); '' when unknown. */
|
|
93
|
+
function relTime(value, t) {
|
|
94
|
+
const time = toTime(value)
|
|
95
|
+
if (!Number.isFinite(time)) return t ? t('common.unknown') : ''
|
|
96
|
+
const delta = time - Date.now()
|
|
97
|
+
const abs = Math.abs(delta)
|
|
98
|
+
const minute = 60_000
|
|
99
|
+
const hour = 60 * minute
|
|
100
|
+
const day = 24 * hour
|
|
101
|
+
const month = 30 * day
|
|
102
|
+
const year = 365 * day
|
|
103
|
+
let unit = 'second'
|
|
104
|
+
let amount = Math.round(delta / 1000)
|
|
105
|
+
if (abs >= year) {
|
|
106
|
+
unit = 'year'
|
|
107
|
+
amount = Math.round(delta / year)
|
|
108
|
+
} else if (abs >= month) {
|
|
109
|
+
unit = 'month'
|
|
110
|
+
amount = Math.round(delta / month)
|
|
111
|
+
} else if (abs >= day) {
|
|
112
|
+
unit = 'day'
|
|
113
|
+
amount = Math.round(delta / day)
|
|
114
|
+
} else if (abs >= hour) {
|
|
115
|
+
unit = 'hour'
|
|
116
|
+
amount = Math.round(delta / hour)
|
|
117
|
+
} else if (abs >= minute) {
|
|
118
|
+
unit = 'minute'
|
|
119
|
+
amount = Math.round(delta / minute)
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
return new Intl.RelativeTimeFormat(locale(), { numeric: 'auto' }).format(amount, unit)
|
|
123
|
+
} catch {
|
|
124
|
+
return t ? t('common.unknown') : ''
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Absolute local date-time; `t('common.unknown')` when the value is invalid. */
|
|
129
|
+
function dateTime(value, t) {
|
|
130
|
+
const text = ACC.fmt.dateTime(value)
|
|
131
|
+
if (text !== '未知') return text
|
|
132
|
+
return t ? t('common.unknown') : ''
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Byte size; `t('common.unknown')` when the value is invalid (never a fake 0). */
|
|
136
|
+
function bytes(value, t) {
|
|
137
|
+
const text = ACC.fmt.bytes(value)
|
|
138
|
+
if (text !== '未知') return text
|
|
139
|
+
return t ? t('common.unknown') : ''
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function rawBlock(label, text) {
|
|
143
|
+
const value = text === null || text === undefined ? '' : String(text)
|
|
144
|
+
if (value.length === 0) return null
|
|
145
|
+
if (!(lang() === 'en' && hasCjk(value))) return null
|
|
146
|
+
return h(
|
|
147
|
+
'details',
|
|
148
|
+
{ style: { marginTop: '2px' } },
|
|
149
|
+
h('summary', { style: { cursor: 'pointer', fontSize: '11px', color: 'var(--dsw-alias-label-tertiary, #81858c)' } }, label),
|
|
150
|
+
h(
|
|
151
|
+
'pre',
|
|
152
|
+
{
|
|
153
|
+
style: {
|
|
154
|
+
margin: '4px 0 0',
|
|
155
|
+
padding: '6px 8px',
|
|
156
|
+
whiteSpace: 'pre-wrap',
|
|
157
|
+
wordBreak: 'break-word',
|
|
158
|
+
fontFamily: 'var(--ds-font-family-code, ui-monospace, monospace)',
|
|
159
|
+
fontSize: '11px',
|
|
160
|
+
lineHeight: '16px',
|
|
161
|
+
border: '0.5px solid var(--dsw-alias-border-l2, rgba(0,0,0,.1))',
|
|
162
|
+
borderRadius: '6px',
|
|
163
|
+
color: 'var(--dsw-alias-label-secondary, #61666b)',
|
|
164
|
+
},
|
|
165
|
+
lang: 'zh',
|
|
166
|
+
},
|
|
167
|
+
value,
|
|
168
|
+
),
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return { lang, locale, hasCjk, map, host, hostOr, relTime, dateTime, bytes, raw: rawBlock }
|
|
173
|
+
})();
|
|
174
|
+
|
|
9
175
|
(function agentsPage() {
|
|
10
176
|
/** Host theme tokens actually present in the shell (COMPAT-CLIENT §4.2). */
|
|
11
177
|
const V = {
|
|
@@ -22,57 +188,23 @@
|
|
|
22
188
|
warn: 'var(--dsw-alias-state-warn-primary, #f59e0b)',
|
|
23
189
|
success: 'var(--dsw-alias-state-success-primary, #22c55e)',
|
|
24
190
|
radiusSm: 'var(--dsw-radius-sm, 8px)',
|
|
25
|
-
radiusMd: 'var(--dsw-radius-md, 12px)',
|
|
26
191
|
mono: 'var(--ds-font-family-code, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)',
|
|
27
192
|
font: 'var(--dsw-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif)',
|
|
28
193
|
}
|
|
29
194
|
|
|
30
195
|
const S = {
|
|
31
|
-
root: {
|
|
32
|
-
display: 'flex',
|
|
33
|
-
flexDirection: 'column',
|
|
34
|
-
gap: 16,
|
|
35
|
-
padding: '8px 0',
|
|
36
|
-
color: V.label,
|
|
37
|
-
fontFamily: V.font,
|
|
38
|
-
fontSize: 13,
|
|
39
|
-
lineHeight: '22px',
|
|
40
|
-
},
|
|
196
|
+
root: { display: 'flex', flexDirection: 'column', gap: 12, padding: '8px 0', color: V.label, fontFamily: V.font, fontSize: 13, lineHeight: '22px' },
|
|
41
197
|
split: { display: 'flex', flexWrap: 'wrap', gap: 12, alignItems: 'flex-start' },
|
|
42
|
-
list: {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
display: 'flex',
|
|
46
|
-
flexDirection: 'column',
|
|
47
|
-
gap: 4,
|
|
48
|
-
maxHeight: 420,
|
|
49
|
-
overflow: 'auto',
|
|
50
|
-
paddingRight: 2,
|
|
51
|
-
},
|
|
52
|
-
editorColumn: { flex: '1 1 420px', minWidth: 0, display: 'flex', flexDirection: 'column', gap: 8 },
|
|
53
|
-
rowButton: (active) => ({
|
|
54
|
-
display: 'flex',
|
|
55
|
-
flexDirection: 'column',
|
|
56
|
-
alignItems: 'stretch',
|
|
57
|
-
gap: 2,
|
|
58
|
-
width: '100%',
|
|
59
|
-
padding: '6px 8px',
|
|
60
|
-
textAlign: 'left',
|
|
61
|
-
font: 'inherit',
|
|
62
|
-
color: 'inherit',
|
|
63
|
-
cursor: 'pointer',
|
|
64
|
-
borderRadius: V.radiusSm,
|
|
65
|
-
border: `0.5px solid ${active ? V.business : 'transparent'}`,
|
|
66
|
-
background: active ? V.hover : 'transparent',
|
|
67
|
-
}),
|
|
68
|
-
metaRow: { display: 'flex', flexWrap: 'wrap', gap: 8, alignItems: 'center', fontSize: 12, color: V.secondary },
|
|
198
|
+
list: { flex: '1 1 260px', minWidth: 0, display: 'flex', flexDirection: 'column', gap: 2, maxHeight: 260, overflow: 'auto', paddingRight: 2 },
|
|
199
|
+
editorColumn: { flex: '1 1 320px', minWidth: 0, display: 'flex', flexDirection: 'column', gap: 8 },
|
|
200
|
+
metaRow: { display: 'flex', flexWrap: 'wrap', gap: 6, alignItems: 'center', fontSize: 11, color: V.secondary },
|
|
69
201
|
textarea: {
|
|
70
202
|
width: '100%',
|
|
71
|
-
minHeight:
|
|
203
|
+
minHeight: 300,
|
|
72
204
|
padding: 10,
|
|
73
205
|
boxSizing: 'border-box',
|
|
74
206
|
borderRadius: V.radiusSm,
|
|
75
|
-
border: `
|
|
207
|
+
border: `1px solid ${V.border}`,
|
|
76
208
|
background: V.layer1,
|
|
77
209
|
color: V.label,
|
|
78
210
|
fontFamily: V.mono,
|
|
@@ -84,73 +216,9 @@
|
|
|
84
216
|
overflowWrap: 'normal',
|
|
85
217
|
overflowX: 'auto',
|
|
86
218
|
},
|
|
87
|
-
issueRow: {
|
|
88
|
-
display: 'flex',
|
|
89
|
-
flexDirection: 'column',
|
|
90
|
-
gap: 2,
|
|
91
|
-
width: '100%',
|
|
92
|
-
padding: '6px 8px',
|
|
93
|
-
textAlign: 'left',
|
|
94
|
-
font: 'inherit',
|
|
95
|
-
color: 'inherit',
|
|
96
|
-
cursor: 'pointer',
|
|
97
|
-
borderRadius: V.radiusSm,
|
|
98
|
-
border: `0.5px solid ${V.border}`,
|
|
99
|
-
background: 'transparent',
|
|
100
|
-
},
|
|
101
|
-
sectionTitle: { margin: 0, fontSize: 13, fontWeight: 600, color: V.label },
|
|
102
|
-
label: { fontSize: 12, color: V.secondary },
|
|
219
|
+
issueRow: { display: 'flex', flexDirection: 'column', gap: 2, width: '100%', padding: '6px 8px', borderRadius: V.radiusSm, border: `0.5px solid ${V.border}`, background: 'transparent' },
|
|
103
220
|
monoText: { fontFamily: V.mono, fontSize: 11, color: V.secondary },
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
/** @param {{ tone?: 'neutral' | 'info' | 'warn' | 'error' | 'success', children?: unknown, title?: string }} props */
|
|
107
|
-
function Tag(props) {
|
|
108
|
-
const tone = props.tone || 'neutral'
|
|
109
|
-
const color = tone === 'error' ? V.error
|
|
110
|
-
: tone === 'warn' ? V.warn
|
|
111
|
-
: tone === 'success' ? V.success
|
|
112
|
-
: tone === 'info' ? V.business
|
|
113
|
-
: V.tertiary
|
|
114
|
-
return h(
|
|
115
|
-
'span',
|
|
116
|
-
{
|
|
117
|
-
title: props.title,
|
|
118
|
-
style: {
|
|
119
|
-
display: 'inline-flex',
|
|
120
|
-
alignItems: 'center',
|
|
121
|
-
padding: '0 6px',
|
|
122
|
-
borderRadius: 999,
|
|
123
|
-
border: `0.5px solid ${color}`,
|
|
124
|
-
color,
|
|
125
|
-
fontSize: 11,
|
|
126
|
-
lineHeight: '18px',
|
|
127
|
-
whiteSpace: 'nowrap',
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
props.children,
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/** @param {{ tone?: 'error' | 'warn' | 'info' | 'success', children?: unknown }} props */
|
|
135
|
-
function Notice(props) {
|
|
136
|
-
const color = props.tone === 'error' ? V.error : props.tone === 'warn' ? V.warn : props.tone === 'success' ? V.success : V.business
|
|
137
|
-
return h(
|
|
138
|
-
'div',
|
|
139
|
-
{
|
|
140
|
-
role: props.tone === 'error' ? 'alert' : 'status',
|
|
141
|
-
style: {
|
|
142
|
-
border: `0.5px solid ${color}`,
|
|
143
|
-
borderRadius: V.radiusSm,
|
|
144
|
-
padding: '8px 10px',
|
|
145
|
-
color,
|
|
146
|
-
display: 'flex',
|
|
147
|
-
flexDirection: 'column',
|
|
148
|
-
gap: 6,
|
|
149
|
-
fontSize: 12,
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
props.children,
|
|
153
|
-
)
|
|
221
|
+
clamp: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', maxWidth: '100%' },
|
|
154
222
|
}
|
|
155
223
|
|
|
156
224
|
/** @param {(key: string, values?: Record<string, string | number>) => string} t @param {string} source */
|
|
@@ -161,8 +229,8 @@
|
|
|
161
229
|
return t('agents.sourceProject')
|
|
162
230
|
}
|
|
163
231
|
|
|
164
|
-
/** @param {(key: string, values?: Record<string, string | number>) => string} t @param {number | null} maxBytes
|
|
165
|
-
function budgetText(t, maxBytes
|
|
232
|
+
/** @param {(key: string, values?: Record<string, string | number>) => string} t @param {number | null} maxBytes */
|
|
233
|
+
function budgetText(t, maxBytes) {
|
|
166
234
|
if (maxBytes === null || maxBytes === undefined) return t('agents.budgetUnknown')
|
|
167
235
|
return `${ACC.fmt.num(maxBytes)} ${t('common.bytes')}`
|
|
168
236
|
}
|
|
@@ -174,46 +242,82 @@
|
|
|
174
242
|
return t('agents.budgetSourceUnknown')
|
|
175
243
|
}
|
|
176
244
|
|
|
177
|
-
/** @param {string} code
|
|
178
|
-
function
|
|
179
|
-
if (code === 'error') return
|
|
180
|
-
if (code === 'warn') return
|
|
181
|
-
return
|
|
245
|
+
/** @param {string} code */
|
|
246
|
+
function severityTone(code) {
|
|
247
|
+
if (code === 'error') return 'danger'
|
|
248
|
+
if (code === 'warn') return 'warn'
|
|
249
|
+
return 'info'
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** @param {string} code @param {Function} t */
|
|
253
|
+
function severityLabel(code, t) {
|
|
254
|
+
if (code === 'error') return t('agents.severityError')
|
|
255
|
+
if (code === 'warn') return t('agents.severityWarn')
|
|
256
|
+
return t('agents.severityInfo')
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** Collapsible block with a real button header. */
|
|
260
|
+
function Disclosure(props) {
|
|
261
|
+
return h(
|
|
262
|
+
'div',
|
|
263
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: 6 } },
|
|
264
|
+
h(
|
|
265
|
+
'button',
|
|
266
|
+
{
|
|
267
|
+
type: 'button',
|
|
268
|
+
onClick: props.onToggle,
|
|
269
|
+
'aria-expanded': props.open,
|
|
270
|
+
style: { display: 'flex', alignItems: 'center', gap: 6, padding: 0, border: 0, background: 'transparent', color: 'inherit', font: 'inherit', cursor: 'pointer', textAlign: 'left' },
|
|
271
|
+
},
|
|
272
|
+
h('span', { 'aria-hidden': 'true' }, props.open ? '▾' : '▸'),
|
|
273
|
+
h('span', { className: 'acc-muted', style: { fontSize: '11px' } }, props.label),
|
|
274
|
+
),
|
|
275
|
+
props.open ? props.children : null,
|
|
276
|
+
)
|
|
182
277
|
}
|
|
183
278
|
|
|
184
279
|
/**
|
|
185
|
-
* One row in the instruction-file list
|
|
280
|
+
* One row in the instruction-file list: selected state is explicit, and the
|
|
281
|
+
* budget / byte / line facts ride on the row so the list answers "which file
|
|
282
|
+
* and how big" without opening it.
|
|
186
283
|
* @param {{ item: any, active: boolean, onSelect: Function, t: Function }} props
|
|
187
284
|
*/
|
|
188
285
|
function FileRow(props) {
|
|
189
286
|
const item = props.item
|
|
190
287
|
const badges = []
|
|
191
|
-
if (item.available !== true) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (item.
|
|
195
|
-
if (item.
|
|
196
|
-
if (item.
|
|
288
|
+
if (item.available !== true) badges.push(h(C.Badge, { key: 'unavailable', tone: 'warn', title: String(item.reason || '') }, props.t('agents.unavailableFile')))
|
|
289
|
+
if (item.available === true) {
|
|
290
|
+
if (item.deduped === true) badges.push(h(C.Badge, { key: 'deduped', tone: 'neutral', title: props.t('agents.dedupedBy', { path: item.dedupedBy || '' }) }, props.t('agents.deduped')))
|
|
291
|
+
if (item.budgetOmitted === true) badges.push(h(C.Badge, { key: 'omitted', tone: 'warn' }, props.t('agents.omitted')))
|
|
292
|
+
if (item.truncated === true) badges.push(h(C.Badge, { key: 'truncated', tone: 'warn' }, props.t('agents.truncatedBadge')))
|
|
293
|
+
if (item.inEffectiveChain === true) badges.push(h(C.Badge, { key: 'effective', tone: 'success' }, props.t('agents.effective')))
|
|
197
294
|
}
|
|
295
|
+
const disabled = item.available !== true
|
|
198
296
|
return h(
|
|
199
297
|
'button',
|
|
200
298
|
{
|
|
201
299
|
type: 'button',
|
|
300
|
+
className: `acc-list-item${props.active ? ' is-selected' : ''}`,
|
|
202
301
|
onClick: () => props.onSelect(item),
|
|
203
|
-
|
|
204
|
-
'aria-
|
|
302
|
+
disabled,
|
|
303
|
+
'aria-selected': props.active,
|
|
304
|
+
title: item.displayPath,
|
|
305
|
+
style: { flexDirection: 'column', alignItems: 'stretch', gap: 2, minHeight: 0, cursor: disabled ? 'not-allowed' : 'pointer', opacity: disabled ? 0.6 : 1 },
|
|
205
306
|
},
|
|
206
307
|
h(
|
|
207
308
|
'span',
|
|
208
|
-
{ style: { display: 'flex', alignItems: 'center', gap: 6,
|
|
209
|
-
h('span', {
|
|
210
|
-
h(
|
|
309
|
+
{ style: { display: 'flex', alignItems: 'center', gap: 6, minWidth: 0 } },
|
|
310
|
+
h('span', { className: 'acc-mono', style: { ...S.clamp, fontSize: 11 } }, item.displayPath),
|
|
311
|
+
h('span', { className: 'acc-grow' }),
|
|
312
|
+
h(C.Badge, { tone: item.source === 'user-global' || item.source === 'agents-home' ? 'info' : 'neutral' }, sourceLabel(props.t, item.source)),
|
|
211
313
|
),
|
|
212
314
|
h(
|
|
213
315
|
'span',
|
|
214
|
-
{ style: { ...S.
|
|
215
|
-
item.bytes === null || item.bytes === undefined ? props.t('agents.unknown') : ACC.fmt.bytes(item.bytes),
|
|
216
|
-
item.
|
|
316
|
+
{ style: { ...S.metaRow, gap: 8 } },
|
|
317
|
+
h('span', null, item.bytes === null || item.bytes === undefined ? props.t('agents.unknown') : ACC.fmt.bytes(item.bytes)),
|
|
318
|
+
item.eol ? h('span', null, props.t(item.eol === 'crlf' ? 'agents.eolCrlf' : item.eol === 'mixed' ? 'agents.eolMixed' : item.eol === 'none' ? 'agents.eolNone' : 'agents.eolLf')) : null,
|
|
319
|
+
item.lineCount !== undefined ? h('span', null, `${props.t('agents.lineCount')} ${ACC.fmt.num(item.lineCount)}`) : null,
|
|
320
|
+
item.mtimeMs ? h('span', null, ACC.l10n.relTime(item.mtimeMs, props.t)) : null,
|
|
217
321
|
),
|
|
218
322
|
badges.length > 0 ? h('span', { style: { display: 'flex', gap: 4, flexWrap: 'wrap' } }, badges) : null,
|
|
219
323
|
)
|
|
@@ -226,33 +330,26 @@
|
|
|
226
330
|
: chain.cwdSource === 'working-directory-default' ? 'agents.cwdSourceDefault' : 'agents.cwdSourceProcess'
|
|
227
331
|
return h(
|
|
228
332
|
'div',
|
|
229
|
-
{ style: { display: 'flex', flexDirection: 'column', gap:
|
|
230
|
-
h(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
h('span', null, `${props.t('agents.projectRoot')}:`),
|
|
243
|
-
h('span', { style: S.monoText }, chain.projectRoot),
|
|
244
|
-
),
|
|
245
|
-
h(
|
|
246
|
-
'div',
|
|
247
|
-
{ style: S.metaRow },
|
|
248
|
-
h('span', null, `${props.t('agents.budget')}:`),
|
|
249
|
-
h('span', { style: S.monoText }, budgetText(props.t, chain.budget.maxBytes, chain.budget.source)),
|
|
250
|
-
h(Tag, { tone: chain.budget.maxBytes === null ? 'warn' : 'success' }, budgetSourceText(props.t, chain.budget.source)),
|
|
251
|
-
h('span', null, `${props.t('agents.bytes')}:`),
|
|
252
|
-
h('span', { style: S.monoText }, `${ACC.fmt.bytes(chain.chains.userGlobal.bytes)} + ${ACC.fmt.bytes(chain.chains.project.bytes)}`),
|
|
253
|
-
),
|
|
333
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: 8 } },
|
|
334
|
+
h(C.KeyValues, {
|
|
335
|
+
items: [
|
|
336
|
+
{ label: props.t('agents.cwd'), value: h('span', { className: 'acc-mono', style: { wordBreak: 'break-all' } }, String(chain.cwd || '')) },
|
|
337
|
+
{ label: props.t('agents.cwdSource'), value: props.t(sourceKey) },
|
|
338
|
+
{ label: props.t('agents.projectRoot'), value: h('span', { className: 'acc-mono', style: { wordBreak: 'break-all' } }, String(chain.projectRoot || '')) },
|
|
339
|
+
{ label: props.t('agents.budget'), value: `${budgetText(props.t, chain.budget.maxBytes)} · ${budgetSourceText(props.t, chain.budget.source)}` },
|
|
340
|
+
{
|
|
341
|
+
label: props.t('agents.bytes'),
|
|
342
|
+
value: `${ACC.fmt.bytes(chain.chains.userGlobal.bytes)} + ${ACC.fmt.bytes(chain.chains.project.bytes)}`,
|
|
343
|
+
},
|
|
344
|
+
],
|
|
345
|
+
}),
|
|
254
346
|
Array.isArray(chain.warnings) && chain.warnings.length > 0
|
|
255
|
-
? h(
|
|
347
|
+
? h(
|
|
348
|
+
C.Notice,
|
|
349
|
+
{ tone: 'warn' },
|
|
350
|
+
h('div', null, props.t('agents.warningsFallback')),
|
|
351
|
+
ACC.l10n.raw(props.t('agents.rawHostText'), chain.warnings.join('\n')),
|
|
352
|
+
)
|
|
256
353
|
: null,
|
|
257
354
|
)
|
|
258
355
|
}
|
|
@@ -260,11 +357,12 @@
|
|
|
260
357
|
/**
|
|
261
358
|
* @param {{ doc: any, t: Function, dirty: boolean, busy: string, conflict: any,
|
|
262
359
|
* notice: any, error: any, onSave: Function, onForce: Function, onRevert: Function,
|
|
263
|
-
* onReload: Function, onViewDiff: Function, onClearConflict: Function,
|
|
264
|
-
* editorRef: any, onEditorChange: Function, onTabKey: Function }} props
|
|
360
|
+
* onReload: Function, onReloadDisk: Function, onViewDiff: Function, onClearConflict: Function,
|
|
361
|
+
* editorRef: any, editorEpoch: number, onEditorChange: Function, onTabKey: Function }} props
|
|
265
362
|
*/
|
|
266
363
|
function EditorPane(props) {
|
|
267
364
|
const doc = props.doc
|
|
365
|
+
const [openMeta, setOpenMeta] = ACC.useState(false)
|
|
268
366
|
const eolKey = doc.eol === 'crlf' ? 'agents.eolCrlf' : doc.eol === 'mixed' ? 'agents.eolMixed' : doc.eol === 'none' ? 'agents.eolNone' : 'agents.eolLf'
|
|
269
367
|
const busy = props.busy
|
|
270
368
|
return h(
|
|
@@ -273,11 +371,11 @@
|
|
|
273
371
|
h(
|
|
274
372
|
'div',
|
|
275
373
|
{ style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8, flexWrap: 'wrap' } },
|
|
276
|
-
h('
|
|
374
|
+
h('h4', { className: 'acc-section-title' }, props.t('agents.editor')),
|
|
277
375
|
h(
|
|
278
376
|
'div',
|
|
279
|
-
{
|
|
280
|
-
h(C.Btn, { tone: 'primary', onClick: props.onSave, disabled: busy === 'save' || !props.dirty }, busy === 'save' ? props.t('agents.saving') : props.t('agents.save')),
|
|
377
|
+
{ className: 'acc-row', style: { gap: 6 } },
|
|
378
|
+
h(C.Btn, { tone: 'primary', onClick: props.onSave, disabled: busy === 'save' || !props.dirty, icon: 'check' }, busy === 'save' ? props.t('agents.saving') : props.t('agents.save')),
|
|
281
379
|
h(C.Btn, { onClick: props.onRevert, disabled: !props.dirty || busy === 'save' }, props.t('agents.revert')),
|
|
282
380
|
h(C.Btn, { onClick: props.onReload, disabled: busy === 'save' }, props.t('agents.reload')),
|
|
283
381
|
),
|
|
@@ -285,35 +383,53 @@
|
|
|
285
383
|
h(
|
|
286
384
|
'div',
|
|
287
385
|
{ style: S.metaRow },
|
|
288
|
-
h('span', { style: S.
|
|
289
|
-
h(
|
|
290
|
-
h(
|
|
291
|
-
h('
|
|
292
|
-
h('
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
386
|
+
h('span', { className: 'acc-mono', style: { ...S.clamp, maxWidth: '190px' }, title: doc.displayPath }, doc.displayPath),
|
|
387
|
+
h(C.Badge, { tone: doc.bom ? 'warn' : 'neutral' }, doc.bom ? props.t('agents.encodingBom') : props.t('agents.encodingUtf8')),
|
|
388
|
+
h(C.Badge, { tone: doc.eol === 'mixed' ? 'warn' : 'neutral' }, props.t(eolKey)),
|
|
389
|
+
h(C.Badge, { tone: doc.guard === 'hash-only' ? 'warn' : 'success', title: doc.guard === 'hash-only' ? props.t('agents.guardHashOnly') : props.t('agents.guardHostVersion') }, props.t('agents.guard')),
|
|
390
|
+
props.dirty ? h(C.Badge, { tone: 'warn' }, props.t('agents.dirty')) : h(C.Badge, { tone: 'neutral' }, props.t('agents.clean')),
|
|
391
|
+
),
|
|
392
|
+
h(
|
|
393
|
+
Disclosure,
|
|
394
|
+
{ open: openMeta, onToggle: () => setOpenMeta((value) => !value), label: props.t('agents.metaToggle') },
|
|
395
|
+
h(C.KeyValues, {
|
|
396
|
+
items: [
|
|
397
|
+
{ label: props.t('agents.bytes'), value: ACC.fmt.bytes(doc.bytes) },
|
|
398
|
+
{ label: props.t('agents.lineCount'), value: ACC.fmt.num(doc.lineCount) },
|
|
399
|
+
{ label: props.t('agents.charCount'), value: ACC.fmt.num(doc.charCount) },
|
|
400
|
+
{ label: props.t('agents.trailingNewline'), value: doc.endsWithNewline ? props.t('agents.hasTrailing') : props.t('agents.noTrailing') },
|
|
401
|
+
{ label: props.t('agents.hash'), value: h('span', { className: 'acc-mono' }, String(doc.hash || '').slice(0, 16)) },
|
|
402
|
+
{
|
|
403
|
+
label: props.t('agents.budget'),
|
|
404
|
+
value: `${ACC.fmt.bytes(doc.bytes)} / ${doc.budget && doc.budget.maxBytes !== null && doc.budget.maxBytes !== undefined ? ACC.fmt.bytes(doc.budget.maxBytes) : props.t('agents.budgetUnknown')}`,
|
|
405
|
+
},
|
|
406
|
+
],
|
|
407
|
+
}),
|
|
297
408
|
),
|
|
298
409
|
props.conflict !== null
|
|
299
410
|
? h(
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
h(C.
|
|
309
|
-
h(
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
411
|
+
C.Notice,
|
|
412
|
+
{ tone: 'danger' },
|
|
413
|
+
h('div', { style: { fontWeight: 600 } }, props.t('agents.conflictTitle')),
|
|
414
|
+
h('div', null, props.t('agents.conflictHint')),
|
|
415
|
+
props.conflict.detail
|
|
416
|
+
? h('div', { style: S.monoText }, ACC.l10n.host('agents.conflictDetailGeneric', props.conflict.detail) || props.t('agents.conflictDetailGeneric'))
|
|
417
|
+
: null,
|
|
418
|
+
ACC.l10n.raw(props.t('agents.rawHostText'), props.conflict.detail),
|
|
419
|
+
h(C.Notice, { tone: 'info' }, props.t('agents.conflictReloadHint')),
|
|
420
|
+
h(
|
|
421
|
+
'div',
|
|
422
|
+
{ className: 'acc-row', style: { gap: 6, marginTop: 2 } },
|
|
423
|
+
h(C.Btn, { tone: 'primary', onClick: props.onReloadDisk }, props.t('agents.conflictReloadPrimary')),
|
|
424
|
+
h(C.Btn, { onClick: props.onViewDiff }, props.t('agents.viewDiff')),
|
|
425
|
+
h(C.Btn, { tone: 'danger', onClick: props.onForce }, props.t('agents.conflictForcePrimary')),
|
|
426
|
+
h(C.Btn, { tone: 'ghost', onClick: props.onClearConflict }, props.t('common.cancel')),
|
|
427
|
+
),
|
|
428
|
+
)
|
|
314
429
|
: null,
|
|
315
|
-
props.error !== null ? h(Notice, { tone: '
|
|
316
|
-
|
|
430
|
+
props.error !== null ? h(C.Notice, { tone: 'danger' }, `${props.t('agents.saveFailed')}: ${props.error.code || 'error'} · ${props.error.message || props.error}`) : null,
|
|
431
|
+
busy === 'save' ? h(C.Notice, { tone: 'info' }, props.t('agents.savingHint')) : null,
|
|
432
|
+
props.notice !== null ? h(C.Notice, { tone: 'success' }, props.notice) : null,
|
|
317
433
|
h('textarea', {
|
|
318
434
|
key: `${doc.path}:${doc.hash}:${props.editorEpoch}`,
|
|
319
435
|
ref: props.editorRef,
|
|
@@ -323,128 +439,237 @@
|
|
|
323
439
|
spellCheck: false,
|
|
324
440
|
wrap: 'off',
|
|
325
441
|
'aria-label': props.t('agents.editor'),
|
|
442
|
+
'aria-describedby': 'acc-agents-tab-hint',
|
|
326
443
|
style: S.textarea,
|
|
327
444
|
}),
|
|
328
|
-
h('div', { style: S.monoText }, props.t('agents.tabHint')),
|
|
445
|
+
h('div', { id: 'acc-agents-tab-hint', style: S.monoText }, props.t('agents.tabHint')),
|
|
329
446
|
)
|
|
330
447
|
}
|
|
331
448
|
|
|
332
|
-
/**
|
|
449
|
+
/**
|
|
450
|
+
* Validation report grouped by severity (error → warn → info). Every row
|
|
451
|
+
* carries its line number and a jump button, so a finding is locatable.
|
|
452
|
+
* @param {{ report: any, t: Function, onGoto: Function, onToggleIgnore: Function, busy: boolean }} props
|
|
453
|
+
*/
|
|
333
454
|
function ValidationPanel(props) {
|
|
334
455
|
const report = props.report
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
456
|
+
const items = Array.isArray(report.items) ? report.items : []
|
|
457
|
+
const [openGroups, setOpenGroups] = ACC.useState({ error: true, warn: true, info: false })
|
|
458
|
+
const groups = ['error', 'warn', 'info'].map((severity) => ({
|
|
459
|
+
severity,
|
|
460
|
+
items: items.filter((item) => item.severity === severity),
|
|
461
|
+
}))
|
|
462
|
+
const noteFor = (issue) => (issue.category === 'analysis' ? props.t('agents.manualCheck') : props.t('agents.deterministic'))
|
|
339
463
|
return h(
|
|
340
464
|
'div',
|
|
341
465
|
{ style: { display: 'flex', flexDirection: 'column', gap: 8 } },
|
|
342
466
|
h(
|
|
343
467
|
'div',
|
|
344
|
-
{
|
|
345
|
-
h(
|
|
346
|
-
h(
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
h(Tag, { tone: report.counts.error > 0 ? 'error' : 'neutral' }, `${props.t('agents.severityError')} ${report.counts.error}`),
|
|
350
|
-
h(Tag, { tone: report.counts.warn > 0 ? 'warn' : 'neutral' }, `${props.t('agents.severityWarn')} ${report.counts.warn}`),
|
|
351
|
-
h(Tag, { tone: 'neutral' }, `${props.t('agents.severityInfo')} ${report.counts.info}`),
|
|
352
|
-
report.counts.ignored > 0 ? h(Tag, { tone: 'neutral' }, `${props.t('agents.ignoredBadge')} ${report.counts.ignored}`) : null,
|
|
353
|
-
),
|
|
468
|
+
{ className: 'acc-row', style: { gap: 6 } },
|
|
469
|
+
h(C.Badge, { tone: report.counts.error > 0 ? 'danger' : 'neutral' }, `${props.t('agents.severityError')} ${report.counts.error}`),
|
|
470
|
+
h(C.Badge, { tone: report.counts.warn > 0 ? 'warn' : 'neutral' }, `${props.t('agents.severityWarn')} ${report.counts.warn}`),
|
|
471
|
+
h(C.Badge, { tone: 'info' }, `${props.t('agents.severityInfo')} ${report.counts.info}`),
|
|
472
|
+
report.counts.ignored > 0 ? h(C.Badge, { tone: 'neutral' }, `${props.t('agents.ignoredBadge')} ${report.counts.ignored}`) : null,
|
|
354
473
|
),
|
|
355
474
|
h(
|
|
356
475
|
'div',
|
|
357
476
|
{ style: S.metaRow },
|
|
358
|
-
h('span', null, props.t('agents.checkedFiles', { count:
|
|
477
|
+
h('span', null, props.t('agents.checkedFiles', { count: items.length > 0 ? new Set(items.map((item) => item.file)).size : 0 })),
|
|
359
478
|
h('span', null, `${props.t('agents.budget')}: ${report.budget.maxBytes === null ? props.t('agents.unknown') : ACC.fmt.bytes(report.budget.maxBytes)}`),
|
|
360
|
-
report.budget.overBudget ? h(
|
|
479
|
+
report.budget.overBudget ? h(C.Badge, { tone: 'danger' }, props.t('agents.omitted')) : null,
|
|
361
480
|
),
|
|
362
|
-
report.note ? h(Notice, { tone: 'info' }, report.note) : null,
|
|
363
|
-
|
|
364
|
-
groups.map((group) =>
|
|
365
|
-
'div',
|
|
366
|
-
{ key: group.key, style: { display: 'flex', flexDirection: 'column', gap: 4 } },
|
|
367
|
-
h(
|
|
368
|
-
'div',
|
|
369
|
-
{ style: { ...S.label, fontWeight: 600 } },
|
|
370
|
-
group.title,
|
|
371
|
-
group.key === 'analysis' ? ` · ${props.t('agents.manualCheck')}` : '',
|
|
372
|
-
),
|
|
481
|
+
report.note ? h(C.Notice, { tone: 'info' }, report.note) : null,
|
|
482
|
+
items.length === 0 ? h(C.Notice, { tone: 'success' }, props.t('agents.noIssues')) : null,
|
|
483
|
+
groups.map((group) =>
|
|
373
484
|
group.items.length === 0
|
|
374
|
-
?
|
|
375
|
-
:
|
|
376
|
-
'div',
|
|
377
|
-
{
|
|
378
|
-
key: issue.fingerprint,
|
|
379
|
-
style: { ...S.issueRow, opacity: issue.ignored ? 0.55 : 1, cursor: 'default' },
|
|
380
|
-
},
|
|
381
|
-
h(
|
|
485
|
+
? null
|
|
486
|
+
: h(
|
|
382
487
|
'div',
|
|
383
|
-
{ style: { display: 'flex',
|
|
384
|
-
h(Tag, { tone: severityStyle(issue.severity).tone }, props.t(severityStyle(issue.severity).key)),
|
|
385
|
-
h('span', { style: S.monoText }, `${props.t('agents.line')} ${issue.line}${issue.lineEnd && issue.lineEnd !== issue.line ? `–${issue.lineEnd}` : ''}`),
|
|
386
|
-
h('span', { style: S.monoText }, String(issue.rule || issue.type || '')),
|
|
387
|
-
issue.ignored ? h(Tag, { tone: 'neutral' }, props.t('agents.ignoredBadge')) : null,
|
|
488
|
+
{ key: group.severity, style: { display: 'flex', flexDirection: 'column', gap: 4 } },
|
|
388
489
|
h(
|
|
389
|
-
'
|
|
390
|
-
{
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
{
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
},
|
|
399
|
-
issue.ignored ? props.t('agents.unignore') : props.t('agents.ignore'),
|
|
400
|
-
),
|
|
490
|
+
'button',
|
|
491
|
+
{
|
|
492
|
+
type: 'button',
|
|
493
|
+
onClick: () => setOpenGroups((previous) => ({ ...previous, [group.severity]: !previous[group.severity] })),
|
|
494
|
+
'aria-expanded': openGroups[group.severity] !== false,
|
|
495
|
+
style: { display: 'flex', alignItems: 'center', gap: 6, padding: 0, border: 0, background: 'transparent', color: 'inherit', font: 'inherit', cursor: 'pointer', textAlign: 'left' },
|
|
496
|
+
},
|
|
497
|
+
h('span', { 'aria-hidden': 'true' }, openGroups[group.severity] !== false ? '▾' : '▸'),
|
|
498
|
+
h(C.Badge, { tone: severityTone(group.severity) }, `${severityLabel(group.severity, props.t)} ${group.items.length}`),
|
|
401
499
|
),
|
|
500
|
+
openGroups[group.severity] === false
|
|
501
|
+
? null
|
|
502
|
+
: group.items.map((issue) => {
|
|
503
|
+
const ruleKey = typeof issue.rule === 'string' && issue.rule.length > 0 ? issue.rule : 'generic'
|
|
504
|
+
const reasonText = ACC.l10n.host(`agents.rule.${ruleKey}.reason`, issue.reason)
|
|
505
|
+
const fixText = ACC.l10n.host(`agents.rule.${ruleKey}.fix`, issue.fix)
|
|
506
|
+
return h(
|
|
507
|
+
'div',
|
|
508
|
+
{ key: issue.fingerprint, style: { ...S.issueRow, opacity: issue.ignored ? 0.55 : 1 } },
|
|
509
|
+
h(
|
|
510
|
+
'div',
|
|
511
|
+
{ className: 'acc-row', style: { gap: 6 } },
|
|
512
|
+
h(C.Badge, { tone: severityTone(group.severity) }, severityLabel(group.severity, props.t)),
|
|
513
|
+
h('button', {
|
|
514
|
+
type: 'button',
|
|
515
|
+
className: 'acc-btn acc-btn-ghost',
|
|
516
|
+
onClick: () => props.onGoto(issue.line),
|
|
517
|
+
title: props.t('agents.gotoLine', { line: issue.line }),
|
|
518
|
+
'aria-label': props.t('agents.gotoLine', { line: issue.line }),
|
|
519
|
+
style: { padding: '0 6px', fontFamily: V.mono, fontSize: 11 },
|
|
520
|
+
}, `↦ ${props.t('agents.line')} ${issue.line}${issue.lineEnd && issue.lineEnd !== issue.line ? `–${issue.lineEnd}` : ''}`),
|
|
521
|
+
h('span', { className: 'acc-mono', style: { fontSize: 11, ...S.clamp, maxWidth: '110px' }, title: String(issue.rule || issue.type || '') }, String(issue.rule || issue.type || '')),
|
|
522
|
+
h('span', { className: 'acc-grow' }),
|
|
523
|
+
h(C.Btn, { tone: 'ghost', disabled: props.busy, onClick: () => props.onToggleIgnore(issue), style: { padding: '0 6px' }, ariaLabel: `${issue.ignored ? props.t('agents.unignore') : props.t('agents.ignore')} — ${props.t(`diagnostics.check.${issue.rule}`)}` }, issue.ignored ? props.t('agents.unignore') : props.t('agents.ignore')),
|
|
524
|
+
),
|
|
525
|
+
h('div', { style: { fontSize: 12, wordBreak: 'break-word' } }, reasonText),
|
|
526
|
+
h(
|
|
527
|
+
'div',
|
|
528
|
+
{ style: S.monoText },
|
|
529
|
+
`${props.t('agents.issueKind')}: ${noteFor(issue)}${fixText ? ` · ${props.t('agents.fix')}: ${fixText}` : ''}${issue.ignored ? ` · ${props.t('agents.ignoredBadge')}` : ''}`,
|
|
530
|
+
),
|
|
531
|
+
ACC.l10n.raw(props.t('agents.rawHostText'), `${String(issue.reason || '')}\n${String(issue.fix || '')}`),
|
|
532
|
+
)
|
|
533
|
+
}),
|
|
402
534
|
),
|
|
403
|
-
|
|
404
|
-
issue.fix ? h('div', { style: S.monoText }, `${props.t('agents.fix')}: ${String(issue.fix)}`) : null,
|
|
405
|
-
)),
|
|
406
|
-
)),
|
|
535
|
+
),
|
|
407
536
|
)
|
|
408
537
|
}
|
|
409
538
|
|
|
410
|
-
/**
|
|
539
|
+
/**
|
|
540
|
+
* Backup history as a compact table: time, size, note and the two actions.
|
|
541
|
+
* @param {{ backups: any, t: Function, onRestore: Function, onDiff: Function, busy: boolean }} props
|
|
542
|
+
*/
|
|
411
543
|
function BackupsPanel(props) {
|
|
412
544
|
const backups = props.backups
|
|
545
|
+
const items = Array.isArray(backups.items) ? backups.items : []
|
|
413
546
|
return h(
|
|
414
|
-
|
|
415
|
-
{
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
label: '',
|
|
428
|
-
render: (row) => h(
|
|
429
|
-
'span',
|
|
430
|
-
{ style: { display: 'flex', gap: 6, flexWrap: 'wrap' } },
|
|
431
|
-
h(C.Btn, { tone: 'ghost', onClick: () => props.onDiff(row) }, props.t('agents.backupDiff')),
|
|
432
|
-
h(C.Btn, { tone: 'danger', disabled: props.busy, onClick: () => props.onRestore(row) }, props.t('agents.restore')),
|
|
547
|
+
C.Table,
|
|
548
|
+
{
|
|
549
|
+
columns: [
|
|
550
|
+
{
|
|
551
|
+
key: 'createdAt',
|
|
552
|
+
label: props.t('agents.backupTime'),
|
|
553
|
+
render: (row) =>
|
|
554
|
+
h(
|
|
555
|
+
'div',
|
|
556
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: '1px' } },
|
|
557
|
+
h('span', { style: { fontSize: 11 } }, ACC.l10n.dateTime(row.createdAt, props.t)),
|
|
558
|
+
h('span', { className: 'acc-muted', style: { fontSize: 11 } }, ACC.l10n.relTime(row.createdAt, props.t)),
|
|
559
|
+
h('span', { className: 'acc-muted', style: { fontSize: 11, ...S.clamp, maxWidth: '150px' }, title: String(row.note || '') }, row.note ? String(row.note) : '—'),
|
|
433
560
|
),
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
561
|
+
},
|
|
562
|
+
{ key: 'bytes', label: props.t('agents.backupBytes'), align: 'right', render: (row) => ACC.fmt.bytes(row.bytes) },
|
|
563
|
+
{
|
|
564
|
+
key: 'actions',
|
|
565
|
+
label: '',
|
|
566
|
+
align: 'right',
|
|
567
|
+
render: (row) =>
|
|
568
|
+
h(
|
|
569
|
+
'div',
|
|
570
|
+
{ className: 'acc-row', style: { gap: 4, justifyContent: 'flex-end' } },
|
|
571
|
+
h(C.Btn, { tone: 'ghost', onClick: () => props.onDiff(row), style: { padding: '0 6px' } }, props.t('agents.backupDiff')),
|
|
572
|
+
h(C.Btn, { tone: 'danger', disabled: props.busy, onClick: () => props.onRestore(row), style: { padding: '0 6px' } }, props.t('agents.restore')),
|
|
573
|
+
),
|
|
574
|
+
},
|
|
575
|
+
],
|
|
576
|
+
rows: items,
|
|
577
|
+
rowKey: 'name',
|
|
578
|
+
empty: h(C.Empty, {
|
|
579
|
+
title: props.t('agents.noBackups'),
|
|
580
|
+
hint: props.t('agents.noBackupsHint'),
|
|
581
|
+
icon: 'inbox',
|
|
582
|
+
action: h(C.Btn, { onClick: props.onRefresh, icon: 'retry' }, props.t('agents.noBackupsAction')),
|
|
438
583
|
}),
|
|
584
|
+
},
|
|
585
|
+
)
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Host diff headers carry Chinese labels; they are the only non-content lines
|
|
590
|
+
* of a diff, so map just those two header lines in the English UI.
|
|
591
|
+
* @param {unknown} text @param {Function} t @returns {string}
|
|
592
|
+
*/
|
|
593
|
+
function localizeDiff(text, t) {
|
|
594
|
+
const source = String(text === null || text === undefined ? '' : text)
|
|
595
|
+
if (ACC.l10n.lang() !== 'en') return source
|
|
596
|
+
return source
|
|
597
|
+
.split('\n')
|
|
598
|
+
.map((line) => {
|
|
599
|
+
if (/^---\s*磁盘当前内容/.test(line)) return line.replace('磁盘当前内容', t('agents.diffFrom'))
|
|
600
|
+
if (/^\+\+\+\s*编辑器内容/.test(line)) return line.replace('编辑器内容', t('agents.diffTo'))
|
|
601
|
+
return line
|
|
602
|
+
})
|
|
603
|
+
.join('\n')
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/** Line-level diff block shared by the diff dialog and the save confirmation. */
|
|
607
|
+
function DiffView(props) {
|
|
608
|
+
const lines = localizeDiff(props.text, props.t).split('\n')
|
|
609
|
+
if (lines.length === 0 || (lines.length === 1 && lines[0].length === 0)) {
|
|
610
|
+
return h(C.Notice, { tone: 'info' }, props.t('agents.diffEmpty'))
|
|
611
|
+
}
|
|
612
|
+
return h(
|
|
613
|
+
'div',
|
|
614
|
+
{ style: { display: 'flex', flexDirection: 'column', border: `0.5px solid ${V.border}`, borderRadius: V.radiusSm, overflow: 'hidden' } },
|
|
615
|
+
lines.slice(0, 600).map((line, index) => {
|
|
616
|
+
const kind = line.startsWith('@@') ? 'hunk' : line.startsWith('+') ? 'add' : line.startsWith('-') ? 'del' : 'context'
|
|
617
|
+
const background = kind === 'add' ? 'color-mix(in srgb, var(--dsw-alias-state-success-primary, #22c55e) 14%, transparent)'
|
|
618
|
+
: kind === 'del' ? 'color-mix(in srgb, var(--dsw-alias-state-error-primary, #ec1313) 14%, transparent)'
|
|
619
|
+
: kind === 'hunk' ? V.hover : 'transparent'
|
|
620
|
+
const color = kind === 'add' ? V.success : kind === 'del' ? V.error : 'inherit'
|
|
621
|
+
return h(
|
|
622
|
+
'div',
|
|
623
|
+
{ key: String(index), style: { padding: '0 8px', background, color: kind === 'context' ? 'inherit' : color, fontFamily: V.mono, fontSize: 11, lineHeight: '17px', whiteSpace: 'pre-wrap', wordBreak: 'break-word' } },
|
|
624
|
+
line.length === 0 ? ' ' : line,
|
|
625
|
+
)
|
|
626
|
+
}),
|
|
439
627
|
)
|
|
440
628
|
}
|
|
441
629
|
|
|
442
630
|
/** @param {{ title: string, text: string, onClose: Function, t: Function }} props */
|
|
443
631
|
function DiffModal(props) {
|
|
632
|
+
return h(C.Modal, { title: props.title, onClose: props.onClose }, h(DiffView, { text: props.text, t: props.t }))
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Save confirmation: shows the exact diff that will be written and states that
|
|
637
|
+
* the current file is backed up first. The primary action names both effects.
|
|
638
|
+
* @param {{ metadata: any, diff: any, t: Function, busy: boolean, onClose: Function, onConfirm: Function }} props
|
|
639
|
+
*/
|
|
640
|
+
function SaveConfirm(props) {
|
|
641
|
+
const { t, metadata, diff } = props
|
|
444
642
|
return h(
|
|
445
643
|
C.Modal,
|
|
446
|
-
{
|
|
447
|
-
|
|
644
|
+
{
|
|
645
|
+
title: t('agents.saveConfirmTitle'),
|
|
646
|
+
tone: 'warning',
|
|
647
|
+
onClose: props.onClose,
|
|
648
|
+
footer: h(
|
|
649
|
+
'div',
|
|
650
|
+
{ className: 'acc-row', style: { justifyContent: 'flex-end' } },
|
|
651
|
+
h(C.Btn, { tone: 'ghost', onClick: props.onClose, disabled: props.busy }, t('common.cancel')),
|
|
652
|
+
h(C.Btn, { tone: 'primary', onClick: props.onConfirm, disabled: props.busy, icon: 'check' }, props.busy ? t('agents.saving') : t('agents.saveConfirmCta')),
|
|
653
|
+
),
|
|
654
|
+
},
|
|
655
|
+
h(C.KeyValues, {
|
|
656
|
+
items: [
|
|
657
|
+
{ label: t('common.path'), value: h('span', { className: 'acc-mono', style: { wordBreak: 'break-all' } }, String(metadata.path || '')) },
|
|
658
|
+
{ label: t('agents.bytes'), value: `${ACC.l10n.bytes(metadata.bytes, t)} → ${ACC.l10n.bytes(diff.nextBytes === undefined ? metadata.bytes : diff.nextBytes, t)}` },
|
|
659
|
+
],
|
|
660
|
+
}),
|
|
661
|
+
h(C.Notice, { tone: 'info' }, t('agents.saveConfirmBackup')),
|
|
662
|
+
h(C.Notice, { tone: 'warn' }, t('agents.saveConfirmScope')),
|
|
663
|
+
diff.status === 'loading'
|
|
664
|
+
? h(C.Loading, { label: t('agents.diffLoading') })
|
|
665
|
+
: diff.error !== undefined
|
|
666
|
+
? h(C.ErrorBox, { error: diff.error, label: t('agents.diffUnavailable') })
|
|
667
|
+
: h(
|
|
668
|
+
'div',
|
|
669
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: '6px' } },
|
|
670
|
+
h('div', { className: 'acc-section-title' }, diff.added === undefined && diff.removed === undefined ? t('agents.diffTitle') : t('agents.addedRemoved', { added: String(diff.added === undefined ? '—' : diff.added), removed: String(diff.removed === undefined ? '—' : diff.removed) })),
|
|
671
|
+
h(DiffView, { text: diff.text, t }),
|
|
672
|
+
),
|
|
448
673
|
)
|
|
449
674
|
}
|
|
450
675
|
|
|
@@ -452,40 +677,46 @@
|
|
|
452
677
|
function RestoreModal(props) {
|
|
453
678
|
return h(
|
|
454
679
|
C.Modal,
|
|
455
|
-
{
|
|
680
|
+
{
|
|
681
|
+
title: props.t('agents.restoreConfirmTitle'),
|
|
682
|
+
tone: 'warning',
|
|
683
|
+
onClose: props.onClose,
|
|
684
|
+
footer: h(
|
|
685
|
+
'div',
|
|
686
|
+
{ className: 'acc-row', style: { justifyContent: 'flex-end' } },
|
|
687
|
+
h(C.Btn, { onClick: props.onClose }, props.t('common.cancel')),
|
|
688
|
+
h(C.Btn, { tone: 'danger', disabled: props.busy, onClick: props.onConfirm }, props.busy ? props.t('agents.restoring') : props.t('agents.restoreCta')),
|
|
689
|
+
),
|
|
690
|
+
},
|
|
456
691
|
h('div', null, props.t('agents.restoreConfirmBody', { name: String(props.backup.name) })),
|
|
457
|
-
h(Notice, { tone: 'warn' }, props.t('agents.restoreConfirmDanger')),
|
|
458
|
-
h(
|
|
459
|
-
'div',
|
|
460
|
-
{ style: { display: 'flex', gap: 8, justifyContent: 'flex-end' } },
|
|
461
|
-
h(C.Btn, { onClick: props.onClose }, props.t('common.cancel')),
|
|
462
|
-
h(C.Btn, { tone: 'danger', disabled: props.busy, onClick: props.onConfirm }, props.busy ? props.t('agents.restoring') : props.t('agents.restore')),
|
|
463
|
-
),
|
|
692
|
+
h(C.Notice, { tone: 'warn' }, props.t('agents.restoreConfirmDanger')),
|
|
693
|
+
h(C.Notice, { tone: 'info' }, props.t('agents.restoreScope')),
|
|
464
694
|
)
|
|
465
695
|
}
|
|
466
696
|
|
|
467
697
|
/** @param {{ t: Function }} props */
|
|
468
698
|
function AgentsPage(props) {
|
|
469
699
|
const t = props.t
|
|
470
|
-
const [reloadKey, setReloadKey] = useState(0)
|
|
471
|
-
const [selectedPath, setSelectedPath] = useState('')
|
|
472
|
-
const [dirty, setDirty] = useState(false)
|
|
473
|
-
const [busy, setBusy] = useState('')
|
|
474
|
-
const [notice, setNotice] = useState(null)
|
|
475
|
-
const [error, setError] = useState(null)
|
|
476
|
-
const [conflict, setConflict] = useState(null)
|
|
477
|
-
const [diffModal, setDiffModal] = useState(null)
|
|
478
|
-
const [
|
|
479
|
-
const [
|
|
480
|
-
const [
|
|
481
|
-
const
|
|
700
|
+
const [reloadKey, setReloadKey] = ACC.useState(0)
|
|
701
|
+
const [selectedPath, setSelectedPath] = ACC.useState('')
|
|
702
|
+
const [dirty, setDirty] = ACC.useState(false)
|
|
703
|
+
const [busy, setBusy] = ACC.useState('')
|
|
704
|
+
const [notice, setNotice] = ACC.useState(null)
|
|
705
|
+
const [error, setError] = ACC.useState(null)
|
|
706
|
+
const [conflict, setConflict] = ACC.useState(null)
|
|
707
|
+
const [diffModal, setDiffModal] = ACC.useState(null)
|
|
708
|
+
const [saveConfirm, setSaveConfirm] = ACC.useState(null)
|
|
709
|
+
const [restoreTarget, setRestoreTarget] = ACC.useState(null)
|
|
710
|
+
const [editorEpoch, setEditorEpoch] = ACC.useState(0)
|
|
711
|
+
const [validationKey, setValidationKey] = ACC.useState(0)
|
|
712
|
+
const editorRef = ACC.useRef(null)
|
|
482
713
|
|
|
483
714
|
const chain = ACC.useAsync((context) => ACC.api('agents.files', { limit: 200 }, context), [reloadKey])
|
|
484
715
|
const chainData = chain.status === 'ready' ? chain.data : null
|
|
485
716
|
const items = chainData && Array.isArray(chainData.items) ? chainData.items : []
|
|
486
717
|
const readable = items.filter((item) => item.available === true)
|
|
487
718
|
|
|
488
|
-
useEffect(() => {
|
|
719
|
+
ACC.useEffect(() => {
|
|
489
720
|
if (readable.length === 0) {
|
|
490
721
|
if (selectedPath !== '') setSelectedPath('')
|
|
491
722
|
return
|
|
@@ -522,14 +753,15 @@
|
|
|
522
753
|
)
|
|
523
754
|
const backupsData = backups.status === 'ready' ? backups.data : null
|
|
524
755
|
|
|
525
|
-
const reloadAll = useCallback(() => {
|
|
756
|
+
const reloadAll = ACC.useCallback(() => {
|
|
526
757
|
setReloadKey((value) => value + 1)
|
|
527
758
|
setValidationKey((value) => value + 1)
|
|
528
759
|
}, [])
|
|
529
760
|
|
|
530
|
-
const reloadDocument = useCallback(() => {
|
|
761
|
+
const reloadDocument = ACC.useCallback(() => {
|
|
531
762
|
setConflict(null)
|
|
532
763
|
setError(null)
|
|
764
|
+
setNotice(null)
|
|
533
765
|
setDirty(false)
|
|
534
766
|
setEditorEpoch((value) => value + 1)
|
|
535
767
|
setReloadKey((value) => value + 1)
|
|
@@ -564,6 +796,26 @@
|
|
|
564
796
|
if (docData !== null) setDirty(element.value !== docData.text)
|
|
565
797
|
}
|
|
566
798
|
|
|
799
|
+
/** Open the save confirmation and compute the on-disk diff first. */
|
|
800
|
+
async function requestSave() {
|
|
801
|
+
if (docData === null || editorRef.current === null) return
|
|
802
|
+
const content = editorRef.current.value
|
|
803
|
+
setSaveConfirm({ metadata: docData, status: 'loading', text: '', added: undefined, removed: undefined })
|
|
804
|
+
try {
|
|
805
|
+
const result = await ACC.api('agents.diff', { path: docData.path, content })
|
|
806
|
+
setSaveConfirm({
|
|
807
|
+
metadata: docData,
|
|
808
|
+
status: 'ready',
|
|
809
|
+
text: String(result.diff || ''),
|
|
810
|
+
added: result.added,
|
|
811
|
+
removed: result.removed,
|
|
812
|
+
nextBytes: result.nextBytes,
|
|
813
|
+
})
|
|
814
|
+
} catch (failure) {
|
|
815
|
+
setSaveConfirm({ metadata: docData, status: 'error', error: failure, text: '' })
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
|
|
567
819
|
async function doSave(force) {
|
|
568
820
|
if (docData === null || editorRef.current === null) return
|
|
569
821
|
const content = editorRef.current.value
|
|
@@ -579,6 +831,7 @@
|
|
|
579
831
|
...(force ? { force: true } : {}),
|
|
580
832
|
})
|
|
581
833
|
setDirty(false)
|
|
834
|
+
setSaveConfirm(null)
|
|
582
835
|
setNotice(force ? t('agents.forceSavedOk', { name: String(saved.backup.name) }) : t('agents.savedOk', { name: String(saved.backup.name) }))
|
|
583
836
|
setEditorEpoch((value) => value + 1)
|
|
584
837
|
reloadAll()
|
|
@@ -676,17 +929,17 @@
|
|
|
676
929
|
return h(
|
|
677
930
|
'div',
|
|
678
931
|
{ style: S.root },
|
|
679
|
-
h(C.Empty, { title: t('agents.noFile'), hint: t('agents.noFileHint'), action: h(C.Btn, { onClick: chain.reload }, t('common.refresh')) }),
|
|
932
|
+
h(C.Empty, { title: t('agents.noFile'), hint: t('agents.noFileHint'), icon: 'inbox', action: h(C.Btn, { onClick: chain.reload, icon: 'retry' }, t('common.refresh')) }),
|
|
680
933
|
items.length > 0
|
|
681
934
|
? h(C.Table, {
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
935
|
+
columns: [
|
|
936
|
+
{ key: 'displayPath', label: t('agents.file'), render: (row) => h('span', { className: 'acc-mono', style: { fontSize: 11 } }, String(row.displayPath || '')) },
|
|
937
|
+
{ key: 'source', label: t('agents.source'), render: (row) => sourceLabel(t, row.source) },
|
|
938
|
+
{ key: 'reason', label: t('agents.reason'), render: (row) => h('span', { className: 'acc-muted', style: { fontSize: 11 } }, String(row.reason || '—')) },
|
|
939
|
+
],
|
|
940
|
+
rows: items,
|
|
941
|
+
rowKey: 'path',
|
|
942
|
+
})
|
|
690
943
|
: null,
|
|
691
944
|
)
|
|
692
945
|
}
|
|
@@ -694,30 +947,44 @@
|
|
|
694
947
|
return h(
|
|
695
948
|
'div',
|
|
696
949
|
{ style: S.root },
|
|
697
|
-
h(C.Card, { title: t('agents.title'), subtitle: t('agents.subtitle') }, h(ChainHeader, { chain: chainData, t, onReload: chain.reload })),
|
|
698
950
|
h(
|
|
699
951
|
C.Card,
|
|
700
|
-
{
|
|
952
|
+
{
|
|
953
|
+
title: t('agents.title'),
|
|
954
|
+
subtitle: t('agents.subtitle'),
|
|
955
|
+
actions: h(C.Btn, { tone: 'ghost', onClick: chain.reload, icon: 'retry', ariaLabel: t('agents.refreshChain') }, t('agents.refreshChain')),
|
|
956
|
+
},
|
|
957
|
+
h(ChainHeader, { chain: chainData, t, onReload: chain.reload }),
|
|
958
|
+
),
|
|
959
|
+
h(
|
|
960
|
+
C.Card,
|
|
961
|
+
{
|
|
962
|
+
title: t('agents.files'),
|
|
963
|
+
subtitle: t('agents.fileListHint'),
|
|
964
|
+
actions: h(C.Badge, { tone: 'neutral' }, t('agents.fileCount', { count: items.length })),
|
|
965
|
+
},
|
|
701
966
|
h(
|
|
702
967
|
'div',
|
|
703
968
|
{ style: S.split },
|
|
704
969
|
h(
|
|
705
970
|
'div',
|
|
706
971
|
{ style: S.list, role: 'listbox', 'aria-label': t('agents.files') },
|
|
707
|
-
items.map((item) =>
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
972
|
+
items.map((item) =>
|
|
973
|
+
h(FileRow, {
|
|
974
|
+
key: item.path,
|
|
975
|
+
item,
|
|
976
|
+
active: item.path === selectedPath,
|
|
977
|
+
t,
|
|
978
|
+
onSelect: (candidate) => {
|
|
979
|
+
if (candidate.available !== true) return
|
|
980
|
+
setSelectedPath(candidate.path)
|
|
981
|
+
setDirty(false)
|
|
982
|
+
setConflict(null)
|
|
983
|
+
setNotice(null)
|
|
984
|
+
setError(null)
|
|
985
|
+
},
|
|
986
|
+
}),
|
|
987
|
+
),
|
|
721
988
|
),
|
|
722
989
|
doc.status === 'loading'
|
|
723
990
|
? h(C.Loading, { label: t('common.loading') })
|
|
@@ -725,60 +992,75 @@
|
|
|
725
992
|
? h(C.ErrorBox, { error: doc.error, onRetry: doc.reload, label: t('agents.readFailed') })
|
|
726
993
|
: docData !== null
|
|
727
994
|
? h(EditorPane, {
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
995
|
+
doc: docData,
|
|
996
|
+
t,
|
|
997
|
+
dirty,
|
|
998
|
+
busy,
|
|
999
|
+
conflict,
|
|
1000
|
+
notice,
|
|
1001
|
+
error,
|
|
1002
|
+
onSave: requestSave,
|
|
1003
|
+
onForce: () => doSave(true),
|
|
1004
|
+
onRevert: () => {
|
|
1005
|
+
setDirty(false)
|
|
1006
|
+
setConflict(null)
|
|
1007
|
+
setNotice(null)
|
|
1008
|
+
setEditorEpoch((value) => value + 1)
|
|
1009
|
+
},
|
|
1010
|
+
onReload: reloadDocument,
|
|
1011
|
+
onReloadDisk: reloadDocument,
|
|
1012
|
+
onViewDiff: showConflictDiff,
|
|
1013
|
+
onClearConflict: () => setConflict(null),
|
|
1014
|
+
editorRef,
|
|
1015
|
+
editorEpoch,
|
|
1016
|
+
onEditorChange,
|
|
1017
|
+
onTabKey,
|
|
1018
|
+
})
|
|
751
1019
|
: null,
|
|
752
1020
|
),
|
|
753
1021
|
),
|
|
754
1022
|
h(
|
|
755
1023
|
C.Card,
|
|
756
|
-
{ title: t('agents.validation') },
|
|
1024
|
+
{ title: t('agents.validation'), subtitle: t('agents.validationHint') },
|
|
757
1025
|
report.status === 'loading'
|
|
758
1026
|
? h(C.Loading, { label: t('agents.validating') })
|
|
759
1027
|
: report.status === 'error'
|
|
760
1028
|
? h(C.ErrorBox, { error: report.error, onRetry: report.reload, label: t('agents.validateUnavailable') })
|
|
761
1029
|
: reportData !== null
|
|
762
1030
|
? h(ValidationPanel, {
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
1031
|
+
report: { ...reportData, filePath: docData === null ? '' : docData.path },
|
|
1032
|
+
t,
|
|
1033
|
+
busy: busy === 'ignore',
|
|
1034
|
+
onGoto: gotoLine,
|
|
1035
|
+
onToggleIgnore: toggleIgnore,
|
|
1036
|
+
})
|
|
769
1037
|
: null,
|
|
770
1038
|
),
|
|
771
1039
|
h(
|
|
772
1040
|
C.Card,
|
|
773
|
-
{ title: t('agents.backups') },
|
|
1041
|
+
{ title: t('agents.backups'), subtitle: t('agents.backupsHint') },
|
|
774
1042
|
backups.status === 'loading'
|
|
775
1043
|
? h(C.Loading, { label: t('common.loading') })
|
|
776
1044
|
: backups.status === 'error'
|
|
777
1045
|
? h(C.ErrorBox, { error: backups.error, onRetry: backups.reload, label: t('agents.backupsFailed') })
|
|
778
1046
|
: backupsData !== null
|
|
779
|
-
? h(BackupsPanel, { backups: backupsData, t, busy: busy === 'restore', onRestore: setRestoreTarget, onDiff: showBackupDiff })
|
|
1047
|
+
? h(BackupsPanel, { backups: backupsData, t, busy: busy === 'restore', onRestore: setRestoreTarget, onDiff: showBackupDiff, onRefresh: backups.reload })
|
|
780
1048
|
: null,
|
|
781
1049
|
),
|
|
1050
|
+
saveConfirm !== null
|
|
1051
|
+
? h(SaveConfirm, {
|
|
1052
|
+
metadata: saveConfirm.metadata,
|
|
1053
|
+
diff: saveConfirm.status === 'loading'
|
|
1054
|
+
? { status: 'loading' }
|
|
1055
|
+
: saveConfirm.status === 'error'
|
|
1056
|
+
? { status: 'error', error: saveConfirm.error }
|
|
1057
|
+
: { status: 'ready', text: saveConfirm.text, added: saveConfirm.added, removed: saveConfirm.removed, nextBytes: saveConfirm.nextBytes },
|
|
1058
|
+
t,
|
|
1059
|
+
busy: busy === 'save',
|
|
1060
|
+
onClose: () => setSaveConfirm(null),
|
|
1061
|
+
onConfirm: () => doSave(false),
|
|
1062
|
+
})
|
|
1063
|
+
: null,
|
|
782
1064
|
diffModal !== null ? h(DiffModal, { title: diffModal.title, text: diffModal.text, onClose: () => setDiffModal(null), t }) : null,
|
|
783
1065
|
restoreTarget !== null
|
|
784
1066
|
? h(RestoreModal, { backup: restoreTarget, t, busy: busy === 'restore', onClose: () => setRestoreTarget(null), onConfirm: confirmRestore })
|
|
@@ -790,6 +1072,7 @@
|
|
|
790
1072
|
id: 'agents',
|
|
791
1073
|
titleKey: 'nav.agents',
|
|
792
1074
|
order: 20,
|
|
1075
|
+
group: 'edit',
|
|
793
1076
|
render: (props) => h(AgentsPage, props),
|
|
794
1077
|
})
|
|
795
1078
|
})()
|