@kingsoftcloud/agentkit-harness-ui 0.0.12 → 0.0.14
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/package.json +2 -2
- package/src/activity-groups.mjs +17 -1
- package/src/host/session-task-events.mjs +1 -1
- package/src/host/state/native-outcome.mjs +4 -0
- package/src/host/state/native-recovery.mjs +5 -0
- package/src/host/state/timeline-event-feed.mjs +36 -0
- package/src/host/task-timeline.mjs +2 -1
- package/src/project.mjs +1 -0
- package/src/react-binding.mjs +18 -9
- package/src/renderers.mjs +14 -13
- package/src/status-panel.mjs +14 -6
- package/src/view.mjs +7 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kingsoftcloud/agentkit-harness-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Reusable React task-process UI for AgentKit Native: an explicitly versioned event protocol, a pure state reducer, and an accessible timeline. No Studio/DSH/Python imports; React is a peer dependency.",
|
|
@@ -96,6 +96,6 @@
|
|
|
96
96
|
"registry": "https://registry.npmjs.org"
|
|
97
97
|
},
|
|
98
98
|
"dependencies": {
|
|
99
|
-
"@kingsoftcloud/agentkit-harness-core": "0.0.
|
|
99
|
+
"@kingsoftcloud/agentkit-harness-core": "0.0.14"
|
|
100
100
|
}
|
|
101
101
|
}
|
package/src/activity-groups.mjs
CHANGED
|
@@ -34,7 +34,7 @@ function awaitingCommand(item) {
|
|
|
34
34
|
* its parent active between model calls. Child outcomes remain independent.
|
|
35
35
|
* Narrative, visible reasoning, context markers and child tasks are boundaries.
|
|
36
36
|
*/
|
|
37
|
-
export function activityGroups(items, { stageTailIsRunning = false, enableChangesGrouping =
|
|
37
|
+
export function activityGroups(items, { stageTailIsRunning = false, enableChangesGrouping = true, enableBrowserGrouping = true } = {}) {
|
|
38
38
|
// A Shell input draft without a command is transparent to stage boundaries.
|
|
39
39
|
// Filter before counting/tail detection; keep the original event state intact.
|
|
40
40
|
items = items.filter(item => !awaitingCommand(item));
|
|
@@ -49,7 +49,19 @@ export function activityGroups(items, { stageTailIsRunning = false, enableChange
|
|
|
49
49
|
const kind = group === 'explore' ? explorationBucket(item) : toolIdentity(item.name).family;
|
|
50
50
|
counts[kind] = (counts[kind] ?? 0) + 1;
|
|
51
51
|
}
|
|
52
|
+
const paths = new Set();
|
|
53
|
+
let unknownFileOperations = 0;
|
|
54
|
+
if (group === 'changes') for (const item of children) {
|
|
55
|
+
const display = item.display ?? {}, input = item.input ?? {};
|
|
56
|
+
const candidates = display.kind === 'file_edit' && Array.isArray(display.files) ? display.files.map(file => file.path)
|
|
57
|
+
: display.path ? [display.path] : Array.isArray(input.files) ? input.files.map(file => file.path)
|
|
58
|
+
: [input.path ?? input.file_path ?? input.filePath ?? input.filename];
|
|
59
|
+
const known = candidates.filter(path => typeof path === 'string' && path.trim());
|
|
60
|
+
if (!known.length) unknownFileOperations++;
|
|
61
|
+
for (const path of known) paths.add(path.trim());
|
|
62
|
+
}
|
|
52
63
|
result.push({ kind: 'activity-group', id: `activity:${group}:${first.callId ?? first.id}`, family: group, children, counts,
|
|
64
|
+
...(group === 'changes' ? { fileCount: paths.size, unknownFileOperations } : {}),
|
|
53
65
|
active: stageTailIsRunning && index === items.length,
|
|
54
66
|
failed: children.filter(item => item.status === 'failed').length,
|
|
55
67
|
uncertain: children.filter(item => ['uncertain', 'interrupted', 'waiting'].includes(item.status)).length });
|
|
@@ -66,6 +78,10 @@ export function activityGroupSummary(group, locale) {
|
|
|
66
78
|
const parts = group.family === 'explore'
|
|
67
79
|
? Object.entries(units).filter(([key]) => group.counts[key])
|
|
68
80
|
.map(([key, unit]) => `${group.counts[key]} ${unit}${!zh && group.counts[key] !== 1 ? key === 'search' || key === 'web-fetch' ? 'es' : 's' : ''}`)
|
|
81
|
+
: group.family === 'changes'
|
|
82
|
+
? [group.fileCount ? `${group.fileCount} ${zh ? '个文件' : group.fileCount === 1 ? 'file' : 'files'}` : '',
|
|
83
|
+
`${group.children.length} ${zh ? '次操作' : 'operations'}`,
|
|
84
|
+
group.unknownFileOperations ? `${group.unknownFileOperations} ${zh ? '次路径待确认' : 'paths unconfirmed'}` : ''].filter(Boolean)
|
|
69
85
|
: [`${group.children.length} ${group.family === 'terminal' ? zh ? '个命令' : 'commands'
|
|
70
86
|
: group.family === 'browser' ? zh ? '次调用' : 'calls' : zh ? '次文件操作' : 'file operations'}`];
|
|
71
87
|
if (group.failed) parts.push(`${group.failed} ${zh ? '失败' : 'failed'}`);
|
|
@@ -220,7 +220,7 @@ export function nativeTaskState(state, status, running) {
|
|
|
220
220
|
&& !['completed', 'failed'].includes(item.status) && previews.has(item.callId)
|
|
221
221
|
? { ...item, status: 'running', display: previews.get(item.callId).display,
|
|
222
222
|
progress: previews.get(item.callId).truncated ? '运行中的输出预览已截断' : null } : item.kind === 'tool' && toolStates.has(item.callId)
|
|
223
|
-
? { ...item, status: toolStates.get(item.callId) } : item.kind === 'tool-preview' && taskState !== 'running'
|
|
223
|
+
? item.status === toolStates.get(item.callId) ? item : { ...item, status: toolStates.get(item.callId) } : item.kind === 'tool-preview' && taskState !== 'running'
|
|
224
224
|
? { ...item, streaming: false } : item.kind === 'tool' && ['scheduled', 'running'].includes(item.status)
|
|
225
225
|
&& ['interrupted', 'waiting', 'paused', 'cancelled', 'failed', 'unverified', 'completed'].includes(taskState)
|
|
226
226
|
? { ...item, status: taskState === 'waiting' ? 'waiting' : 'interrupted' } : item),
|
|
@@ -23,6 +23,10 @@ export function nativeRunPresentation(status) {
|
|
|
23
23
|
return status.canResume === true
|
|
24
24
|
? { label: '执行中断,等待恢复', detail: '原运行已没有活动执行者;恢复原任务后才会继续。已提交的回执保持不变。' }
|
|
25
25
|
: { label: '任务已中断', detail: status.error?.message || '原运行已停止。请查看运行记录和当前可用操作。' };
|
|
26
|
+
if (['preparing_context', 'compacting'].includes(status.phase)
|
|
27
|
+
&& status.modelRetryWait?.contract === 'agentkit.native-model-retry-wait/v1'
|
|
28
|
+
&& Number.isFinite(status.modelRetryWait.notBefore) && status.modelRetryWait.notBefore > 0)
|
|
29
|
+
return { label: '等待模型重试', detail: '模型请求正在按重试策略等待;任务尚未停止。' };
|
|
26
30
|
if (status.phase !== 'completed') return { label: phases[status.phase] || '处理中', detail: '' };
|
|
27
31
|
if (status.outcome === 'failed' || status.outcome === 'budget_exhausted') return { label: '任务未完成', detail: '本轮已结束,任务未完成。请查看错误、预算和结果记录。' };
|
|
28
32
|
if (status.outcome === 'verified') return { label: '任务已验证', detail: '任务已通过本次配置的验证检查;验证范围以结果证据为准。' };
|
|
@@ -16,6 +16,11 @@ export function validateNativeRecoveryStatus(value, { agentId, sessionId, runId
|
|
|
16
16
|
'运行错误记录无法识别,请刷新核对。');
|
|
17
17
|
if (value.outcome != null) check(['verified', 'unverified', 'partial', 'blocked', 'failed', 'budget_exhausted'].includes(value.outcome), '任务结果状态无法识别,请刷新核对。');
|
|
18
18
|
if (value.verificationRequired !== undefined) check(typeof value.verificationRequired === 'boolean', '任务验证要求无法识别,请刷新核对。');
|
|
19
|
+
if (value.modelRetryWait !== undefined) check(value.modelRetryWait?.contract === 'agentkit.native-model-retry-wait/v1'
|
|
20
|
+
&& Object.keys(value.modelRetryWait).sort().join(',') === 'contract,notBefore'
|
|
21
|
+
&& Number.isFinite(value.modelRetryWait.notBefore) && value.modelRetryWait.notBefore > 0
|
|
22
|
+
&& value.state === 'recovering' && ['preparing_context', 'compacting'].includes(value.phase),
|
|
23
|
+
'模型重试等待状态与原运行不一致,请刷新核对。');
|
|
19
24
|
if (value.canRetireResources !== undefined) check(typeof value.canRetireResources === 'boolean'
|
|
20
25
|
&& (!value.canRetireResources || !value.managed && value.phase === 'interrupted'
|
|
21
26
|
&& Number.isSafeInteger(value.resourceRetirementEventSeq) && value.resourceRetirementEventSeq >= 0),
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Presentation scheduling only. Never rewrite or drop authoritative events.
|
|
2
|
+
* Transient chunks share a paint; durable/reconnect changes publish immediately. */
|
|
3
|
+
export function createTimelineEventFeed(source, {
|
|
4
|
+
schedule = callback => typeof requestAnimationFrame === 'function' ? requestAnimationFrame(callback) : setTimeout(callback, 16),
|
|
5
|
+
cancel = handle => typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame(handle) : clearTimeout(handle),
|
|
6
|
+
} = {}) {
|
|
7
|
+
let snapshot = source.getSnapshot(), release = null, frame = null, generation = 0;
|
|
8
|
+
const listeners = new Set();
|
|
9
|
+
const cancelPending = () => { generation++; if (frame !== null) cancel(frame); frame = null; };
|
|
10
|
+
const publish = () => {
|
|
11
|
+
const next = source.getSnapshot();
|
|
12
|
+
if (next === snapshot) return;
|
|
13
|
+
snapshot = next;
|
|
14
|
+
for (const listener of [...listeners]) listener();
|
|
15
|
+
};
|
|
16
|
+
const changed = () => {
|
|
17
|
+
const change = source.getSnapshot().change;
|
|
18
|
+
const transient = change?.kind === 'append' && change.entries.length > 0
|
|
19
|
+
&& change.entries.every(entry => entry.event?.type === 'assistant/live-chunk');
|
|
20
|
+
if (!transient) { cancelPending(); publish(); return; }
|
|
21
|
+
if (frame !== null) return;
|
|
22
|
+
const current = generation;
|
|
23
|
+
frame = schedule(() => { if (current !== generation) return; frame = null; publish(); });
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
getSnapshot() { if (!listeners.size) snapshot = source.getSnapshot(); return snapshot; },
|
|
27
|
+
subscribe(listener) {
|
|
28
|
+
listeners.add(listener);
|
|
29
|
+
if (listeners.size === 1) { release = source.subscribe(changed); publish(); }
|
|
30
|
+
return () => {
|
|
31
|
+
listeners.delete(listener);
|
|
32
|
+
if (!listeners.size) { cancelPending(); release?.(); release = null; }
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -7,6 +7,7 @@ import { nativeStatusPanelModel } from './state/native-status-panel.mjs';
|
|
|
7
7
|
import { nativeTaskWorkspaceRoot, taskWorkspaceFileTarget } from './state/task-links.mjs';
|
|
8
8
|
import { resolveNativeRuntimeRoute, nativeRuntimeRouteInput } from './state/native-runtime-route.mjs';
|
|
9
9
|
import { createNativeTaskReadModel } from './state/native-task-read-model.mjs';
|
|
10
|
+
import { createTimelineEventFeed } from './state/timeline-event-feed.mjs';
|
|
10
11
|
import { createSessionTaskProjector, nativeTaskState, nativeStatusForTurn, bindNativeSubagents, nativeHistoricalToolState } from './session-task-events.mjs';
|
|
11
12
|
|
|
12
13
|
const labels = { result: '执行结果', thought: '思考', running: '执行中', thinking: '思考中…', ended: '本轮已结束', contextRunning: '正在压缩上下文', contextCompleted: '上下文已自动压缩',
|
|
@@ -179,7 +180,7 @@ export function installTaskTimeline(ctx, { ui, hostRemote, resolveAgentFromPrese
|
|
|
179
180
|
inject: sessionId => {
|
|
180
181
|
const binding = ctx.sessions.binding(sessionId);
|
|
181
182
|
if (!binding) throw Error('Task timeline session is unavailable');
|
|
182
|
-
return { hooks: { harnessEvents: binding.eventSource } };
|
|
183
|
+
return { hooks: { harnessEvents: createTimelineEventFeed(binding.eventSource) } };
|
|
183
184
|
},
|
|
184
185
|
}, TaskView));
|
|
185
186
|
}
|
package/src/project.mjs
CHANGED
|
@@ -22,6 +22,7 @@ export function visibleItems(state, { includeInternal = false } = {}) {
|
|
|
22
22
|
const visible = [];
|
|
23
23
|
for (const item of timeline) {
|
|
24
24
|
if (['tool', 'tool-preview'].includes(item.kind) && !toolConversationVisible(item)) continue;
|
|
25
|
+
if (item.kind === 'text' && !String(item.text ?? '').trim()) continue;
|
|
25
26
|
if (item.kind === 'thought' && !String(item.text ?? '').trim()) continue;
|
|
26
27
|
const previous = visible.at(-1);
|
|
27
28
|
if (item.kind === 'thought' && previous?.kind === 'thought') {
|
package/src/react-binding.mjs
CHANGED
|
@@ -245,10 +245,16 @@ export function createHarnessComponents(React) {
|
|
|
245
245
|
};
|
|
246
246
|
const callbacks = useMemo(() => ({ onOpenFile, onCopy, onOpenTerminal, onRetrieveFullDiff, onInspectTool, onOpenSubagent }),
|
|
247
247
|
[onOpenFile, onCopy, onOpenTerminal, onRetrieveFullDiff, onInspectTool, onOpenSubagent]);
|
|
248
|
+
// Tool view trees contain action descriptors, not callback closures. Stable
|
|
249
|
+
// completed items can retain both their parsed view and React subtree while
|
|
250
|
+
// the live tail changes. Disclosure and presentation options invalidate it.
|
|
251
|
+
const toolViewCache = useMemo(() => new WeakMap(), [toolOpen, labels, locale, workspaceRoot,
|
|
252
|
+
Boolean(onOpenFile), Boolean(onCopy), Boolean(onOpenTerminal), Boolean(onRetrieveFullDiff), Boolean(onInspectTool), Boolean(onOpenSubagent)]);
|
|
253
|
+
const toolElementCache = useMemo(() => new WeakMap(), [toolViewCache, reducedMotion]);
|
|
248
254
|
const tree = buildViewModel(state, {
|
|
249
|
-
thoughtOpen, toolOpen, historyOpen, labels, locale, showPlanDock, workspaceRoot, following, rootProps, ...callbacks,
|
|
255
|
+
thoughtOpen, toolOpen, historyOpen, labels, locale, showPlanDock, workspaceRoot, following, rootProps, toolViewCache, ...callbacks,
|
|
250
256
|
});
|
|
251
|
-
const rendered = renderTree(tree, renderText, callbacks, React, reducedMotion);
|
|
257
|
+
const rendered = renderTree(tree, renderText, callbacks, React, reducedMotion, toolElementCache);
|
|
252
258
|
if (styleSheet === null) return rendered;
|
|
253
259
|
return createElement(Fragment, null,
|
|
254
260
|
createElement("style", { "data-harness-ui": true }, styleSheet === undefined ? styles : styleSheet),
|
|
@@ -262,17 +268,18 @@ export function createHarnessComponents(React) {
|
|
|
262
268
|
* summary) are wrapped in small behavior components that attach their own
|
|
263
269
|
* refs/effects; everything else maps straight through.
|
|
264
270
|
*/
|
|
265
|
-
function renderTree(node, renderText, callbacks, React, reducedMotion) {
|
|
271
|
+
function renderTree(node, renderText, callbacks, React, reducedMotion, toolElementCache) {
|
|
266
272
|
if (node == null || node === false) return null;
|
|
267
273
|
if (typeof node !== "object") return node;
|
|
268
274
|
const { createElement } = React;
|
|
269
275
|
const testid = node.props?.["data-testid"];
|
|
270
276
|
const props = node.props || {};
|
|
277
|
+
if (testid === 'tool-block' && toolElementCache?.has(node)) return toolElementCache.get(node);
|
|
271
278
|
|
|
272
279
|
if (testid === "execute-command") {
|
|
273
280
|
return createElement(CommandBox, {
|
|
274
281
|
key: props["data-call-id"], type: node.type, props,
|
|
275
|
-
renderChildren: (node.children || []).map(c => renderTree(c, renderText, callbacks, React, reducedMotion)),
|
|
282
|
+
renderChildren: (node.children || []).map(c => renderTree(c, renderText, callbacks, React, reducedMotion, toolElementCache)),
|
|
276
283
|
});
|
|
277
284
|
}
|
|
278
285
|
|
|
@@ -286,7 +293,7 @@ function renderTree(node, renderText, callbacks, React, reducedMotion) {
|
|
|
286
293
|
axis: "vertical",
|
|
287
294
|
mask: "vertical",
|
|
288
295
|
reducedMotion,
|
|
289
|
-
renderChildren: (node.children || []).map(c => renderTree(c, renderText, callbacks, React, reducedMotion)),
|
|
296
|
+
renderChildren: (node.children || []).map(c => renderTree(c, renderText, callbacks, React, reducedMotion, toolElementCache)),
|
|
290
297
|
type: node.type,
|
|
291
298
|
props: node.props,
|
|
292
299
|
});
|
|
@@ -299,7 +306,7 @@ function renderTree(node, renderText, callbacks, React, reducedMotion) {
|
|
|
299
306
|
axis: "vertical",
|
|
300
307
|
freezeWhileReading: true,
|
|
301
308
|
mask: "vertical",
|
|
302
|
-
renderChildren: (node.children || []).map(c => renderTree(c, renderText, callbacks, React, reducedMotion)),
|
|
309
|
+
renderChildren: (node.children || []).map(c => renderTree(c, renderText, callbacks, React, reducedMotion, toolElementCache)),
|
|
303
310
|
type: node.type,
|
|
304
311
|
props: node.props,
|
|
305
312
|
});
|
|
@@ -310,7 +317,7 @@ function renderTree(node, renderText, callbacks, React, reducedMotion) {
|
|
|
310
317
|
return createElement(ScrollEnd, {
|
|
311
318
|
key: props["data-item-id"] || testid,
|
|
312
319
|
reducedMotion,
|
|
313
|
-
renderChildren: (node.children || []).map(c => renderTree(c, renderText, callbacks, React, reducedMotion)),
|
|
320
|
+
renderChildren: (node.children || []).map(c => renderTree(c, renderText, callbacks, React, reducedMotion, toolElementCache)),
|
|
314
321
|
type: node.type,
|
|
315
322
|
props: node.props,
|
|
316
323
|
});
|
|
@@ -319,8 +326,10 @@ function renderTree(node, renderText, callbacks, React, reducedMotion) {
|
|
|
319
326
|
const isText = testid === "text-block" && props["data-role"] !== "user";
|
|
320
327
|
const text = node.children?.[0]?.children?.[0];
|
|
321
328
|
const children = isText && renderText ? [renderText(String(text ?? ""), { streaming: props["data-streaming"] === "true" })]
|
|
322
|
-
: (node.children || []).map(child => renderTree(child, renderText, callbacks, React, reducedMotion));
|
|
323
|
-
|
|
329
|
+
: (node.children || []).map(child => renderTree(child, renderText, callbacks, React, reducedMotion, toolElementCache));
|
|
330
|
+
const element = createElement(node.type, { key: props["data-item-id"] ?? props["data-call-id"], ...props }, ...children);
|
|
331
|
+
if (testid === "tool-block") toolElementCache?.set(node, element);
|
|
332
|
+
return element;
|
|
324
333
|
}
|
|
325
334
|
|
|
326
335
|
// ── scroll mask helpers (reasoning.tsx / scrollMask.ts semantics) ───────────
|
package/src/renderers.mjs
CHANGED
|
@@ -120,7 +120,8 @@ function toolShell(item, opts, { icon, summary, body, canToggle = true, defaultO
|
|
|
120
120
|
if (action) summaryKids.push(action);
|
|
121
121
|
}
|
|
122
122
|
if (canToggle) summaryKids.push(chevronIcon("harness-tool-chevron"));
|
|
123
|
-
const
|
|
123
|
+
const visibleBody = open && canToggle ? (typeof body === 'function' ? body() : body) : [];
|
|
124
|
+
const bodyKids = Array.isArray(visibleBody) ? visibleBody : [visibleBody];
|
|
124
125
|
if (error && open && canToggle) bodyKids.push(h("div", {
|
|
125
126
|
className: "harness-tool-error", role: "alert", "data-testid": "tool-error",
|
|
126
127
|
}, error));
|
|
@@ -447,7 +448,7 @@ function editRenderer(item, opts) {
|
|
|
447
448
|
// Never infer a write succeeded: the diff/count come from the result display
|
|
448
449
|
// only. While running (no result), show the intent + file chips, no diff.
|
|
449
450
|
const opKind = files.length ? inferOperationKind(files[0].operationKind, null, files[0].patch) : "edit";
|
|
450
|
-
const pending = files.some(file => file.pending);
|
|
451
|
+
const pending = item.kind === 'tool-preview' || files.some(file => file.pending);
|
|
451
452
|
const title = pending ? /write|Write/.test(item.name) ? opts.labels.writePending || 'Write requested'
|
|
452
453
|
: opts.labels.editPending || 'Edit requested' : editKindLabel(opKind, running, opts) || toolTitle(item.name, item.input) || item.name;
|
|
453
454
|
const summary = [h("span", {
|
|
@@ -475,17 +476,17 @@ function editRenderer(item, opts) {
|
|
|
475
476
|
totalStat.removed > 0 ? h("span", { className: "harness-diff-removed" }, `-${totalStat.removed}`) : null));
|
|
476
477
|
}
|
|
477
478
|
|
|
478
|
-
const body =
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
}
|
|
479
|
+
const body = () => {
|
|
480
|
+
const nodes = [];
|
|
481
|
+
for (const f of files) {
|
|
482
|
+
if (!f.patch) continue;
|
|
483
|
+
const parsed = parseDiffHunks(f.patch, { maxLines: opts.diffMaxLines || 200 });
|
|
484
|
+
if (parsed) nodes.push(diffBlock(item.callId, f, { ...parsed, truncated: parsed.truncated || f.truncated }, opts));
|
|
485
|
+
else if (f.truncated) nodes.push(h("p", { className: "harness-diff-truncated", "data-testid": "edit-diff-truncated" }, opts.labels.diffUnavailable || "Diff preview omitted because of its size"));
|
|
486
|
+
}
|
|
487
|
+
if (item.display?.omittedFiles) nodes.push(h("p", { className: "harness-diff-truncated", "data-testid": "edit-diff-omitted" }, `${item.display.omittedFiles} ${opts.labels.diffFilesOmitted || "file previews omitted"}`));
|
|
488
|
+
return nodes;
|
|
489
|
+
};
|
|
489
490
|
return toolShell(item, opts, { icon: pencilIcon("harness-tool-kind-icon"), summary, body, canToggle: true,
|
|
490
491
|
defaultOpen: running && !files.some(f => f.patch) ? true : (files.length > 1 ? false : running) });
|
|
491
492
|
}
|
package/src/status-panel.mjs
CHANGED
|
@@ -424,7 +424,7 @@ export const statusPanelStyles = `
|
|
|
424
424
|
.harness-status-panel__plan-icon--done{ color:var(--sp-success); }
|
|
425
425
|
.harness-status-panel__plan-icon--active{ color:var(--sp-fg); }
|
|
426
426
|
.harness-status-panel__plan-icon--pending{ color:var(--sp-fg-subtlest); }
|
|
427
|
-
.harness-status-panel__plan-content{ flex:1; min-width:0; line-height:
|
|
427
|
+
.harness-status-panel__plan-content{ flex:1; min-width:0; line-height:20px; overflow:hidden; overflow-wrap:anywhere; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; }
|
|
428
428
|
.harness-status-panel__plan-content--done{ color:var(--sp-fg-subtlest); text-decoration:line-through; }
|
|
429
429
|
.harness-status-panel__plan-count{ font-variant-numeric:tabular-nums; }
|
|
430
430
|
.harness-status-panel__plan-count--done{ color:var(--sp-success); }
|
|
@@ -438,6 +438,7 @@ export const statusPanelStyles = `
|
|
|
438
438
|
.harness-status-panel__fold-trigger .harness-status-panel__fold-chevron{ width:0.875em; height:0.875em; }
|
|
439
439
|
.harness-status-panel__fold-preview{
|
|
440
440
|
display:none; position:absolute; left:0; bottom:100%; z-index:20;
|
|
441
|
+
box-sizing:border-box;
|
|
441
442
|
width:20rem; max-width:min(20rem, calc(100cqw - 2rem));
|
|
442
443
|
border:1px solid var(--sp-border); border-radius:0.75rem; background:var(--sp-bg);
|
|
443
444
|
box-shadow:0 4px 12px rgba(0,0,0,.12); padding:0.75rem;
|
|
@@ -782,9 +783,10 @@ export function createStatusPanelComponents(React, ReactDOM = {}) {
|
|
|
782
783
|
const template = group === "preceding" ? allCompleted ? labels.todoCompletedFold : labels.todoEarlierFold
|
|
783
784
|
: allPending ? labels.todoWaitingFold : labels.todoLaterFold;
|
|
784
785
|
const text = String(template).replace("{count}", String(items.length));
|
|
785
|
-
const ref = useRef(null), previewRef = useRef(null), closeTimer = useRef(null);
|
|
786
|
+
const ref = useRef(null), previewRef = useRef(null), closeTimer = useRef(null), clickedOpen = useRef(false);
|
|
786
787
|
const [position, setPosition] = useState(null);
|
|
787
|
-
const
|
|
788
|
+
const hide = () => { clickedOpen.current = false; setPosition(null); };
|
|
789
|
+
const close = () => { clearTimeout(closeTimer.current); closeTimer.current = setTimeout(hide, 120); };
|
|
788
790
|
const show = () => {
|
|
789
791
|
clearTimeout(closeTimer.current);
|
|
790
792
|
const node = ref.current;
|
|
@@ -798,7 +800,7 @@ export function createStatusPanelComponents(React, ReactDOM = {}) {
|
|
|
798
800
|
useEffect(() => () => clearTimeout(closeTimer.current), []);
|
|
799
801
|
const preview = h("div", { ref: previewRef, role: "tooltip", className: "harness-status-panel__fold-preview",
|
|
800
802
|
"data-fold-preview": group,
|
|
801
|
-
style: position && ReactDOM.createPortal ? { ...position, position: "fixed", display: "block", overflowY: "auto", pointerEvents: "auto" } : undefined,
|
|
803
|
+
style: position && ReactDOM.createPortal ? { ...position, bottom: "auto", right: "auto", position: "fixed", display: "block", overflowY: "auto", pointerEvents: "auto" } : undefined,
|
|
802
804
|
onMouseEnter: () => clearTimeout(closeTimer.current), onMouseLeave: close },
|
|
803
805
|
h("div", { className: "harness-status-panel__fold-preview-header" }, text),
|
|
804
806
|
h("ul", { className: "harness-status-panel__plan-list" }, items.map(i => h(PlanRow, { key: i.id, item: i }))));
|
|
@@ -806,9 +808,15 @@ export function createStatusPanelComponents(React, ReactDOM = {}) {
|
|
|
806
808
|
return h("div", { ref, className: "harness-status-panel__fold", "data-fold-group": group,
|
|
807
809
|
onMouseEnter: show, onMouseLeave: close, onFocus: show,
|
|
808
810
|
onBlur: event => { if (!ref.current?.contains(event.relatedTarget) && !previewRef.current?.contains(event.relatedTarget)) close(); },
|
|
809
|
-
onKeyDown: event => { if (event.key === "Escape") { clearTimeout(closeTimer.current);
|
|
811
|
+
onKeyDown: event => { if (event.key === "Escape") { clearTimeout(closeTimer.current); hide(); } } },
|
|
810
812
|
h("button", { type: "button", className: "harness-status-panel__fold-trigger", "aria-expanded": !!position,
|
|
811
|
-
|
|
813
|
+
// Hover/focus may have opened the preview before the click. Track
|
|
814
|
+
// clicks separately so the first click cannot immediately close it.
|
|
815
|
+
"data-fold-trigger": group, onClick: () => {
|
|
816
|
+
clearTimeout(closeTimer.current);
|
|
817
|
+
if (clickedOpen.current) hide();
|
|
818
|
+
else { clickedOpen.current = true; show(); }
|
|
819
|
+
} },
|
|
812
820
|
Icon("chevronLeft", { className: "harness-status-panel__fold-chevron" }), h("span", null, text)),
|
|
813
821
|
root && ReactDOM.createPortal ? position && ReactDOM.createPortal(preview, root) : preview);
|
|
814
822
|
}
|
package/src/view.mjs
CHANGED
|
@@ -220,8 +220,8 @@ function activityGroupBlock(group, opts) {
|
|
|
220
220
|
h('span', { className: group.active ? 'harness-tool-title-streaming' : undefined }, title),
|
|
221
221
|
h('span', { 'aria-hidden': true }, '·'),
|
|
222
222
|
h('span', { 'data-testid': 'activity-counts' }, detail), chevronIcon('harness-tool-chevron')),
|
|
223
|
-
h('div', { className: 'harness-activity-children' }, group.family === 'browser'
|
|
224
|
-
? renderTimelineItems(group.events, opts, false, false) : group.children.map(item => toolBlock(item, opts)))));
|
|
223
|
+
open || group.family !== 'changes' ? h('div', { className: 'harness-activity-children' }, group.family === 'browser'
|
|
224
|
+
? renderTimelineItems(group.events, opts, false, false) : group.children.map(item => toolBlock(item, opts))) : null));
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
function contextMarker(item, opts) {
|
|
@@ -335,7 +335,11 @@ function toolBlock(item, opts) {
|
|
|
335
335
|
// Dispatch to the renderer registry (execute / read / edit / default). Each
|
|
336
336
|
// renderer owns its summary, body, and host-action data attributes; this
|
|
337
337
|
// function is now a thin seam so the view stays a single projection.
|
|
338
|
-
|
|
338
|
+
const cached = opts.toolViewCache?.get(item);
|
|
339
|
+
if (cached) return cached;
|
|
340
|
+
const view = renderTool(item, opts);
|
|
341
|
+
opts.toolViewCache?.set(item, view);
|
|
342
|
+
return view;
|
|
339
343
|
}
|
|
340
344
|
|
|
341
345
|
function planDock(plan, opts) {
|