@adecore/agents-react 0.62.0 → 0.62.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat/index.d.ts +1 -0
- package/dist/chat/index.js +1 -0
- package/dist/chat/ui/ChatActivity.js +43 -2
- package/dist/chat/waiting-on.d.ts +34 -0
- package/dist/chat/waiting-on.js +78 -0
- package/dist/locales/en/agent-chat.d.ts +12 -0
- package/dist/locales/en/agent-chat.js +12 -0
- package/dist/locales/nl/agent-chat.d.ts +12 -0
- package/dist/locales/nl/agent-chat.js +12 -0
- package/package.json +9 -9
- package/src/chat/index.ts +1 -0
- package/src/chat/ui/ChatActivity.tsx +13 -3
- package/src/chat/waiting-on.ts +101 -0
- package/src/locales/en/agent-chat.ts +12 -0
- package/src/locales/nl/agent-chat.ts +12 -0
package/dist/chat/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export { RUNTIME_MODES, runtimeModeLabel, runtimeModeHint } from './runtime-mode
|
|
|
28
28
|
export { CHAT_SEND_KEYS, SEND_AND_NEW_SHORTCUT, sendKeyLabel, sendKeyHint, type ChatSendKey } from './send-key.js';
|
|
29
29
|
export type { StashedAttachment, StashedPrompt, StashedQuote } from './stash.js';
|
|
30
30
|
export { subagentTitle, summaryWordOf, stopOf, type SubagentStop } from './subagent-list.js';
|
|
31
|
+
export { waitingOnOf, waitingOnLabel, type WaitingChild, type WaitingOn, type WaitingOnInput } from './waiting-on.js';
|
|
31
32
|
export { useSubagentSupport } from './subagent-support.js';
|
|
32
33
|
export { crumbOf, openFromMain, composerWrites, canOpenSubagent, useSubagentView, useSubagentTrail, useSubagentItem, type SubagentStep, type SubagentTrail } from './subagent-view.js';
|
|
33
34
|
export { stepTimelineMessage, jumpToTimelineItem, type TurnTarget, registerTurnJumper, jumpToTimelineTurn, type ItemJumpOptions } from './timeline-scroll.js';
|
package/dist/chat/index.js
CHANGED
|
@@ -24,6 +24,7 @@ export { recentChatMessages, recentSubagentMessages } from './recent-messages.js
|
|
|
24
24
|
export { RUNTIME_MODES, runtimeModeLabel, runtimeModeHint } from './runtime-modes.js';
|
|
25
25
|
export { CHAT_SEND_KEYS, SEND_AND_NEW_SHORTCUT, sendKeyLabel, sendKeyHint } from './send-key.js';
|
|
26
26
|
export { subagentTitle, summaryWordOf, stopOf } from './subagent-list.js';
|
|
27
|
+
export { waitingOnOf, waitingOnLabel } from './waiting-on.js';
|
|
27
28
|
export { useSubagentSupport } from './subagent-support.js';
|
|
28
29
|
export { crumbOf, openFromMain, composerWrites, canOpenSubagent, useSubagentView, useSubagentTrail, useSubagentItem } from './subagent-view.js';
|
|
29
30
|
export { stepTimelineMessage, jumpToTimelineItem, registerTurnJumper, jumpToTimelineTurn } from './timeline-scroll.js';
|
|
@@ -16,6 +16,7 @@ import { backgroundCounts } from '../activity.js';
|
|
|
16
16
|
import { badgeCountOf, entryTimeOf, flyoutSubagents, progressOf, statusWordOf, subagentTitle, summaryWordOf, taskIdOf, taskRowStateOf } from '../subagent-list.js';
|
|
17
17
|
import { useSubagentSupport } from '../subagent-support.js';
|
|
18
18
|
import { canOpenSubagent, crumbOf, openFromMain, useSubagentTrail } from '../subagent-view.js';
|
|
19
|
+
import { waitingOnLabel, waitingOnOf } from '../waiting-on.js';
|
|
19
20
|
import { flyoutWorkflows, workflowPillOf } from '../workflow-list.js';
|
|
20
21
|
import { WorkflowRow } from './rows/WorkflowRow.js';
|
|
21
22
|
import { SubagentStopButton } from './SubagentStopButton.js';
|
|
@@ -162,7 +163,10 @@ export function ChatActivity(t0) {
|
|
|
162
163
|
icon: shells > 0 ? SquareTerminal : Activity,
|
|
163
164
|
size: 14
|
|
164
165
|
}),
|
|
165
|
-
label:
|
|
166
|
+
label: /*#__PURE__*/_jsx(BackgroundLabel, {
|
|
167
|
+
tasks: background
|
|
168
|
+
}),
|
|
169
|
+
heading: [shells > 0 && t("activity.shells", {
|
|
166
170
|
count: shells
|
|
167
171
|
}), monitors > 0 && t("activity.monitors", {
|
|
168
172
|
count: monitors
|
|
@@ -275,7 +279,7 @@ function Flyout(t0) {
|
|
|
275
279
|
if ($[1] !== icon || $[2] !== label) {
|
|
276
280
|
t3 = /*#__PURE__*/_jsxs(Surface, {
|
|
277
281
|
render: t2,
|
|
278
|
-
className: "pointer-events-auto inline-flex h-7.5 items-center gap-1.5 rounded-full px-3 text-xs text-text-muted tabular-nums hover:text-text",
|
|
282
|
+
className: "pointer-events-auto inline-flex h-7.5 max-w-full min-w-0 items-center gap-1.5 rounded-full px-3 text-xs text-text-muted tabular-nums hover:text-text",
|
|
279
283
|
children: [icon, label]
|
|
280
284
|
});
|
|
281
285
|
$[1] = icon;
|
|
@@ -321,6 +325,43 @@ function Flyout(t0) {
|
|
|
321
325
|
}
|
|
322
326
|
return t6;
|
|
323
327
|
}
|
|
328
|
+
/* What the background chip says: the oldest command or monitor and how long it has run, on a clock of its own. */
|
|
329
|
+
function BackgroundLabel(t0) {
|
|
330
|
+
const $ = _c(7);
|
|
331
|
+
const {
|
|
332
|
+
tasks
|
|
333
|
+
} = t0;
|
|
334
|
+
const now = useNow(1000);
|
|
335
|
+
let t1;
|
|
336
|
+
let t2;
|
|
337
|
+
if ($[0] !== now || $[1] !== tasks) {
|
|
338
|
+
const waiting = waitingOnOf({
|
|
339
|
+
background: tasks
|
|
340
|
+
});
|
|
341
|
+
t1 = "truncate";
|
|
342
|
+
t2 = waiting === null ? null : waitingOnLabel(waiting, now);
|
|
343
|
+
$[0] = now;
|
|
344
|
+
$[1] = tasks;
|
|
345
|
+
$[2] = t1;
|
|
346
|
+
$[3] = t2;
|
|
347
|
+
} else {
|
|
348
|
+
t1 = $[2];
|
|
349
|
+
t2 = $[3];
|
|
350
|
+
}
|
|
351
|
+
let t3;
|
|
352
|
+
if ($[4] !== t1 || $[5] !== t2) {
|
|
353
|
+
t3 = /*#__PURE__*/_jsx("span", {
|
|
354
|
+
className: t1,
|
|
355
|
+
children: t2
|
|
356
|
+
});
|
|
357
|
+
$[4] = t1;
|
|
358
|
+
$[5] = t2;
|
|
359
|
+
$[6] = t3;
|
|
360
|
+
} else {
|
|
361
|
+
t3 = $[6];
|
|
362
|
+
}
|
|
363
|
+
return t3;
|
|
364
|
+
}
|
|
324
365
|
function WorkflowIcon(t0) {
|
|
325
366
|
const $ = _c(2);
|
|
326
367
|
const {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ChatBackgroundTask, ChatInfo } from '@adecore/agent-contracts';
|
|
2
|
+
export interface WaitingChild {
|
|
3
|
+
paused?: {
|
|
4
|
+
until?: number;
|
|
5
|
+
};
|
|
6
|
+
child?: Pick<ChatInfo, 'status' | 'requests'>;
|
|
7
|
+
}
|
|
8
|
+
export interface WaitingOnInput {
|
|
9
|
+
children?: readonly WaitingChild[];
|
|
10
|
+
background?: readonly ChatBackgroundTask[];
|
|
11
|
+
subagents?: number;
|
|
12
|
+
workflows?: number;
|
|
13
|
+
delegating?: boolean;
|
|
14
|
+
planStatus?: string;
|
|
15
|
+
}
|
|
16
|
+
export type WaitingOn = {
|
|
17
|
+
kind: 'needs-you';
|
|
18
|
+
count: number;
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'paused';
|
|
21
|
+
until?: number;
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'command';
|
|
24
|
+
task: ChatBackgroundTask;
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'background';
|
|
27
|
+
subagents: number;
|
|
28
|
+
workflows: number;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'plan';
|
|
31
|
+
text: string;
|
|
32
|
+
};
|
|
33
|
+
export declare function waitingOnOf(input: WaitingOnInput): WaitingOn | null;
|
|
34
|
+
export declare function waitingOnLabel(waiting: WaitingOn, now: number): string;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { formatElapsedShort, formatMoment } from '@adecore/ui/format';
|
|
2
|
+
import i18next from 'i18next';
|
|
3
|
+
/*
|
|
4
|
+
* The one thing a chat waits on, most pressing first: a child that needs the person, a child paused
|
|
5
|
+
* until a time, the oldest command or monitor in the background, background subagents and workflows,
|
|
6
|
+
* and the plan's status line. Null when it waits on none of them.
|
|
7
|
+
*/
|
|
8
|
+
export function waitingOnOf(input) {
|
|
9
|
+
const children = input.children ?? [];
|
|
10
|
+
const needsYou = children.filter(entry => entry.child?.status === 'needs-you' || (entry.child?.requests?.length ?? 0) > 0).length;
|
|
11
|
+
if (needsYou > 0) {
|
|
12
|
+
return {
|
|
13
|
+
kind: 'needs-you',
|
|
14
|
+
count: needsYou
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const paused = children.filter(entry => entry.paused !== undefined);
|
|
18
|
+
if (paused.length > 0) {
|
|
19
|
+
const times = paused.flatMap(entry => entry.paused?.until === undefined ? [] : [entry.paused.until]);
|
|
20
|
+
return times.length === 0 ? {
|
|
21
|
+
kind: 'paused'
|
|
22
|
+
} : {
|
|
23
|
+
kind: 'paused',
|
|
24
|
+
until: Math.min(...times)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const oldest = (input.background ?? []).reduce((found, task) => found === null || task.startedAt < found.startedAt ? task : found, null);
|
|
28
|
+
if (oldest !== null) {
|
|
29
|
+
return {
|
|
30
|
+
kind: 'command',
|
|
31
|
+
task: oldest
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const subagents = input.subagents ?? 0;
|
|
35
|
+
const workflows = input.workflows ?? 0;
|
|
36
|
+
if (subagents > 0 || workflows > 0 || input.delegating === true) {
|
|
37
|
+
return {
|
|
38
|
+
kind: 'background',
|
|
39
|
+
subagents,
|
|
40
|
+
workflows
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const status = input.planStatus?.trim();
|
|
44
|
+
return status ? {
|
|
45
|
+
kind: 'plan',
|
|
46
|
+
text: status
|
|
47
|
+
} : null;
|
|
48
|
+
}
|
|
49
|
+
/* The line a person reads for it, in the words of the `agent-chat` namespace; `now` ages a command. */
|
|
50
|
+
export function waitingOnLabel(waiting, now) {
|
|
51
|
+
const t = (key, options) => i18next.t(`agent-chat:${key}`, options ?? {});
|
|
52
|
+
switch (waiting.kind) {
|
|
53
|
+
case 'needs-you':
|
|
54
|
+
return t('waitingOn.needsYou', {
|
|
55
|
+
count: waiting.count
|
|
56
|
+
});
|
|
57
|
+
case 'paused':
|
|
58
|
+
return waiting.until === undefined ? t('waitingOn.paused') : t('waitingOn.pausedUntil', {
|
|
59
|
+
time: formatMoment(waiting.until, now)
|
|
60
|
+
});
|
|
61
|
+
case 'command':
|
|
62
|
+
return t('waitingOn.command', {
|
|
63
|
+
command: waiting.task.command || waiting.task.description || t(`activity.${waiting.task.kind}`),
|
|
64
|
+
age: formatElapsedShort(Math.max(0, now - waiting.task.startedAt))
|
|
65
|
+
});
|
|
66
|
+
case 'background':
|
|
67
|
+
if (waiting.subagents === 0 && waiting.workflows === 0) {
|
|
68
|
+
return t('waitingOn.background');
|
|
69
|
+
}
|
|
70
|
+
return [waiting.subagents > 0 && t('waitingOn.subagents', {
|
|
71
|
+
count: waiting.subagents
|
|
72
|
+
}), waiting.workflows > 0 && t('waitingOn.workflows', {
|
|
73
|
+
count: waiting.workflows
|
|
74
|
+
})].filter(Boolean).join(' · ');
|
|
75
|
+
case 'plan':
|
|
76
|
+
return waiting.text;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -479,6 +479,18 @@ declare const _default: {
|
|
|
479
479
|
stop: string;
|
|
480
480
|
stopFailed: string;
|
|
481
481
|
};
|
|
482
|
+
waitingOn: {
|
|
483
|
+
needsYou_one: string;
|
|
484
|
+
needsYou_other: string;
|
|
485
|
+
paused: string;
|
|
486
|
+
pausedUntil: string;
|
|
487
|
+
command: string;
|
|
488
|
+
background: string;
|
|
489
|
+
subagents_one: string;
|
|
490
|
+
subagents_other: string;
|
|
491
|
+
workflows_one: string;
|
|
492
|
+
workflows_other: string;
|
|
493
|
+
};
|
|
482
494
|
subagents: {
|
|
483
495
|
stop: {
|
|
484
496
|
task: string;
|
|
@@ -479,6 +479,18 @@ export default {
|
|
|
479
479
|
stop: 'Stop',
|
|
480
480
|
stopFailed: 'Could not stop task'
|
|
481
481
|
},
|
|
482
|
+
waitingOn: {
|
|
483
|
+
needsYou_one: 'A sub-agent needs you',
|
|
484
|
+
needsYou_other: '{{count}} sub-agents need you',
|
|
485
|
+
paused: 'A sub-agent is paused',
|
|
486
|
+
pausedUntil: 'A sub-agent is paused until {{time}}',
|
|
487
|
+
command: '{{command}} · {{age}}',
|
|
488
|
+
background: 'Working in the background',
|
|
489
|
+
subagents_one: '{{count}} sub-agent in the background',
|
|
490
|
+
subagents_other: '{{count}} sub-agents in the background',
|
|
491
|
+
workflows_one: '{{count}} workflow',
|
|
492
|
+
workflows_other: '{{count}} workflows'
|
|
493
|
+
},
|
|
482
494
|
subagents: {
|
|
483
495
|
stop: {
|
|
484
496
|
task: 'Stop task',
|
|
@@ -479,6 +479,18 @@ declare const _default: {
|
|
|
479
479
|
stop: string;
|
|
480
480
|
stopFailed: string;
|
|
481
481
|
};
|
|
482
|
+
waitingOn: {
|
|
483
|
+
needsYou_one: string;
|
|
484
|
+
needsYou_other: string;
|
|
485
|
+
paused: string;
|
|
486
|
+
pausedUntil: string;
|
|
487
|
+
command: string;
|
|
488
|
+
background: string;
|
|
489
|
+
subagents_one: string;
|
|
490
|
+
subagents_other: string;
|
|
491
|
+
workflows_one: string;
|
|
492
|
+
workflows_other: string;
|
|
493
|
+
};
|
|
482
494
|
subagents: {
|
|
483
495
|
stop: {
|
|
484
496
|
task: string;
|
|
@@ -479,6 +479,18 @@ export default {
|
|
|
479
479
|
stop: 'Stoppen',
|
|
480
480
|
stopFailed: 'Kon de taak niet stoppen'
|
|
481
481
|
},
|
|
482
|
+
waitingOn: {
|
|
483
|
+
needsYou_one: 'Een sub-agent vraagt aandacht',
|
|
484
|
+
needsYou_other: '{{count}} sub-agents vragen aandacht',
|
|
485
|
+
paused: 'Een sub-agent is gepauzeerd',
|
|
486
|
+
pausedUntil: 'Een sub-agent is gepauzeerd tot {{time}}',
|
|
487
|
+
command: '{{command}} · {{age}}',
|
|
488
|
+
background: 'Bezig op de achtergrond',
|
|
489
|
+
subagents_one: '{{count}} sub-agent op de achtergrond',
|
|
490
|
+
subagents_other: '{{count}} sub-agents op de achtergrond',
|
|
491
|
+
workflows_one: '{{count}} workflow',
|
|
492
|
+
workflows_other: '{{count}} workflows'
|
|
493
|
+
},
|
|
482
494
|
subagents: {
|
|
483
495
|
stop: {
|
|
484
496
|
task: 'Taak stoppen',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adecore/agents-react",
|
|
3
|
-
"version": "0.62.
|
|
3
|
+
"version": "0.62.1",
|
|
4
4
|
"description": "React agent chat threads, composers, approvals, provider accounts and usage views.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -72,12 +72,12 @@
|
|
|
72
72
|
"test:visuals": "bun --config=integration.bunfig.toml --conditions=source test ./src/chat/visual-viewport.integration.test.ts"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@adecore/agent-contracts": "0.62.
|
|
76
|
-
"@adecore/editor": "0.62.
|
|
77
|
-
"@adecore/editor-react": "0.62.
|
|
78
|
-
"@adecore/intelligent-ui": "0.62.
|
|
79
|
-
"@adecore/merge": "0.62.
|
|
80
|
-
"@adecore/utils": "0.62.
|
|
75
|
+
"@adecore/agent-contracts": "0.62.1",
|
|
76
|
+
"@adecore/editor": "0.62.1",
|
|
77
|
+
"@adecore/editor-react": "0.62.1",
|
|
78
|
+
"@adecore/intelligent-ui": "0.62.1",
|
|
79
|
+
"@adecore/merge": "0.62.1",
|
|
80
|
+
"@adecore/utils": "0.62.1",
|
|
81
81
|
"@codemirror/commands": "^6.11.1",
|
|
82
82
|
"@codemirror/language": "^6.13.1",
|
|
83
83
|
"@codemirror/state": "^6.7.6",
|
|
@@ -101,14 +101,14 @@
|
|
|
101
101
|
"zustand": "^5.0.16"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
|
-
"@adecore/ui": "^0.62.
|
|
104
|
+
"@adecore/ui": "^0.62.1",
|
|
105
105
|
"i18next": "^26.4.2",
|
|
106
106
|
"react": "^19.3.0",
|
|
107
107
|
"react-dom": "^19.3.0",
|
|
108
108
|
"react-i18next": "^17.0.15"
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
|
-
"@adecore/ui": "0.62.
|
|
111
|
+
"@adecore/ui": "0.62.1",
|
|
112
112
|
"@types/bun": "^1.4.4",
|
|
113
113
|
"@types/react": "^19.3.0",
|
|
114
114
|
"@types/react-dom": "^19.3.0",
|
package/src/chat/index.ts
CHANGED
|
@@ -91,6 +91,7 @@ export { RUNTIME_MODES, runtimeModeLabel, runtimeModeHint } from './runtime-mode
|
|
|
91
91
|
export { CHAT_SEND_KEYS, SEND_AND_NEW_SHORTCUT, sendKeyLabel, sendKeyHint, type ChatSendKey } from './send-key';
|
|
92
92
|
export type { StashedAttachment, StashedPrompt, StashedQuote } from './stash';
|
|
93
93
|
export { subagentTitle, summaryWordOf, stopOf, type SubagentStop } from './subagent-list';
|
|
94
|
+
export { waitingOnOf, waitingOnLabel, type WaitingChild, type WaitingOn, type WaitingOnInput } from './waiting-on';
|
|
94
95
|
export { useSubagentSupport } from './subagent-support';
|
|
95
96
|
|
|
96
97
|
export {
|
|
@@ -16,6 +16,7 @@ import { backgroundCounts } from '../activity';
|
|
|
16
16
|
import { badgeCountOf, entryTimeOf, flyoutSubagents, progressOf, statusWordOf, subagentTitle, summaryWordOf, taskIdOf, taskRowStateOf } from '../subagent-list';
|
|
17
17
|
import { useSubagentSupport } from '../subagent-support';
|
|
18
18
|
import { canOpenSubagent, crumbOf, openFromMain, useSubagentTrail, type SubagentStep } from '../subagent-view';
|
|
19
|
+
import { waitingOnLabel, waitingOnOf } from '../waiting-on';
|
|
19
20
|
import { flyoutWorkflows, workflowPillOf, type WorkflowCall, type WorkflowWord } from '../workflow-list';
|
|
20
21
|
import { WorkflowRow } from './rows/WorkflowRow';
|
|
21
22
|
import { SubagentStopButton } from './SubagentStopButton';
|
|
@@ -98,7 +99,8 @@ export function ChatActivity({ chatId, workflows: showsWorkflows = true }: { cha
|
|
|
98
99
|
{background.length > 0 && (
|
|
99
100
|
<Flyout
|
|
100
101
|
icon={<Icon icon={shells > 0 ? SquareTerminal : Activity} size={14} />}
|
|
101
|
-
label={
|
|
102
|
+
label={<BackgroundLabel tasks={background} />}
|
|
103
|
+
heading={[shells > 0 && t('activity.shells', { count: shells }), monitors > 0 && t('activity.monitors', { count: monitors })]
|
|
102
104
|
.filter(Boolean)
|
|
103
105
|
.join(' · ')}
|
|
104
106
|
>
|
|
@@ -116,12 +118,12 @@ export function StatusIcon({ word }: { word: StatusWord }) {
|
|
|
116
118
|
}
|
|
117
119
|
|
|
118
120
|
/* A chip that opens a list over it, headed by what the chip says unless the list counts more than the chip does. */
|
|
119
|
-
function Flyout({ icon, label, heading = label, children }: { icon: ReactNode; label:
|
|
121
|
+
function Flyout({ icon, label, heading = label, children }: { icon: ReactNode; label: ReactNode; heading?: ReactNode; children: ReactNode }) {
|
|
120
122
|
return (
|
|
121
123
|
<Popover.Root>
|
|
122
124
|
<Surface
|
|
123
125
|
render={<Popover.Trigger />}
|
|
124
|
-
className="pointer-events-auto inline-flex h-7.5 items-center gap-1.5 rounded-full px-3 text-xs text-text-muted tabular-nums hover:text-text"
|
|
126
|
+
className="pointer-events-auto inline-flex h-7.5 max-w-full min-w-0 items-center gap-1.5 rounded-full px-3 text-xs text-text-muted tabular-nums hover:text-text"
|
|
125
127
|
>
|
|
126
128
|
{icon}
|
|
127
129
|
{label}
|
|
@@ -134,6 +136,14 @@ function Flyout({ icon, label, heading = label, children }: { icon: ReactNode; l
|
|
|
134
136
|
);
|
|
135
137
|
}
|
|
136
138
|
|
|
139
|
+
/* What the background chip says: the oldest command or monitor and how long it has run, on a clock of its own. */
|
|
140
|
+
function BackgroundLabel({ tasks }: { tasks: readonly ChatBackgroundTask[] }) {
|
|
141
|
+
const now = useNow(1000);
|
|
142
|
+
const waiting = waitingOnOf({ background: tasks });
|
|
143
|
+
|
|
144
|
+
return <span className="truncate">{waiting === null ? null : waitingOnLabel(waiting, now)}</span>;
|
|
145
|
+
}
|
|
146
|
+
|
|
137
147
|
function WorkflowIcon({ word }: { word: WorkflowWord }) {
|
|
138
148
|
return word === 'stalled' ? <Icon icon={TriangleAlert} size={14} className="shrink-0 text-status-needs-you" /> : <StatusIcon word={word} />;
|
|
139
149
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { ChatBackgroundTask, ChatInfo } from '@adecore/agent-contracts';
|
|
2
|
+
import { formatElapsedShort, formatMoment } from '@adecore/ui/format';
|
|
3
|
+
import i18next from 'i18next';
|
|
4
|
+
|
|
5
|
+
/* An open task the chat delegated: whether its child waits out a limit, and that child's info where the client has it. */
|
|
6
|
+
export interface WaitingChild {
|
|
7
|
+
paused?: { until?: number };
|
|
8
|
+
child?: Pick<ChatInfo, 'status' | 'requests'>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/* What a chat has that it may be waiting on, as every client already holds it. */
|
|
12
|
+
export interface WaitingOnInput {
|
|
13
|
+
children?: readonly WaitingChild[];
|
|
14
|
+
background?: readonly ChatBackgroundTask[];
|
|
15
|
+
/* Background subagents and workflows of the CLI's own, counted where the thread is loaded. */
|
|
16
|
+
subagents?: number;
|
|
17
|
+
workflows?: number;
|
|
18
|
+
/* `ChatInfo.delegating`, for a client that has only the info and so no counts. */
|
|
19
|
+
delegating?: boolean;
|
|
20
|
+
/* The status line of the plan the chat works on. */
|
|
21
|
+
planStatus?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type WaitingOn =
|
|
25
|
+
| { kind: 'needs-you'; count: number }
|
|
26
|
+
| { kind: 'paused'; until?: number }
|
|
27
|
+
| { kind: 'command'; task: ChatBackgroundTask }
|
|
28
|
+
| { kind: 'background'; subagents: number; workflows: number }
|
|
29
|
+
| { kind: 'plan'; text: string };
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
* The one thing a chat waits on, most pressing first: a child that needs the person, a child paused
|
|
33
|
+
* until a time, the oldest command or monitor in the background, background subagents and workflows,
|
|
34
|
+
* and the plan's status line. Null when it waits on none of them.
|
|
35
|
+
*/
|
|
36
|
+
export function waitingOnOf(input: WaitingOnInput): WaitingOn | null {
|
|
37
|
+
const children = input.children ?? [];
|
|
38
|
+
const needsYou = children.filter((entry) => entry.child?.status === 'needs-you' || (entry.child?.requests?.length ?? 0) > 0).length;
|
|
39
|
+
|
|
40
|
+
if (needsYou > 0) {
|
|
41
|
+
return { kind: 'needs-you', count: needsYou };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const paused = children.filter((entry) => entry.paused !== undefined);
|
|
45
|
+
|
|
46
|
+
if (paused.length > 0) {
|
|
47
|
+
const times = paused.flatMap((entry) => (entry.paused?.until === undefined ? [] : [entry.paused.until]));
|
|
48
|
+
|
|
49
|
+
return times.length === 0 ? { kind: 'paused' } : { kind: 'paused', until: Math.min(...times) };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const oldest = (input.background ?? []).reduce<ChatBackgroundTask | null>(
|
|
53
|
+
(found, task) => (found === null || task.startedAt < found.startedAt ? task : found),
|
|
54
|
+
null
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
if (oldest !== null) {
|
|
58
|
+
return { kind: 'command', task: oldest };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const subagents = input.subagents ?? 0;
|
|
62
|
+
const workflows = input.workflows ?? 0;
|
|
63
|
+
|
|
64
|
+
if (subagents > 0 || workflows > 0 || input.delegating === true) {
|
|
65
|
+
return { kind: 'background', subagents, workflows };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const status = input.planStatus?.trim();
|
|
69
|
+
|
|
70
|
+
return status ? { kind: 'plan', text: status } : null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* The line a person reads for it, in the words of the `agent-chat` namespace; `now` ages a command. */
|
|
74
|
+
export function waitingOnLabel(waiting: WaitingOn, now: number): string {
|
|
75
|
+
const t = (key: string, options?: Record<string, unknown>): string => i18next.t(`agent-chat:${key}`, options ?? {});
|
|
76
|
+
|
|
77
|
+
switch (waiting.kind) {
|
|
78
|
+
case 'needs-you':
|
|
79
|
+
return t('waitingOn.needsYou', { count: waiting.count });
|
|
80
|
+
case 'paused':
|
|
81
|
+
return waiting.until === undefined ? t('waitingOn.paused') : t('waitingOn.pausedUntil', { time: formatMoment(waiting.until, now) });
|
|
82
|
+
case 'command':
|
|
83
|
+
return t('waitingOn.command', {
|
|
84
|
+
command: waiting.task.command || waiting.task.description || t(`activity.${waiting.task.kind}`),
|
|
85
|
+
age: formatElapsedShort(Math.max(0, now - waiting.task.startedAt))
|
|
86
|
+
});
|
|
87
|
+
case 'background':
|
|
88
|
+
if (waiting.subagents === 0 && waiting.workflows === 0) {
|
|
89
|
+
return t('waitingOn.background');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return [
|
|
93
|
+
waiting.subagents > 0 && t('waitingOn.subagents', { count: waiting.subagents }),
|
|
94
|
+
waiting.workflows > 0 && t('waitingOn.workflows', { count: waiting.workflows })
|
|
95
|
+
]
|
|
96
|
+
.filter(Boolean)
|
|
97
|
+
.join(' · ');
|
|
98
|
+
case 'plan':
|
|
99
|
+
return waiting.text;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -479,6 +479,18 @@ export default {
|
|
|
479
479
|
stop: 'Stop',
|
|
480
480
|
stopFailed: 'Could not stop task'
|
|
481
481
|
},
|
|
482
|
+
waitingOn: {
|
|
483
|
+
needsYou_one: 'A sub-agent needs you',
|
|
484
|
+
needsYou_other: '{{count}} sub-agents need you',
|
|
485
|
+
paused: 'A sub-agent is paused',
|
|
486
|
+
pausedUntil: 'A sub-agent is paused until {{time}}',
|
|
487
|
+
command: '{{command}} · {{age}}',
|
|
488
|
+
background: 'Working in the background',
|
|
489
|
+
subagents_one: '{{count}} sub-agent in the background',
|
|
490
|
+
subagents_other: '{{count}} sub-agents in the background',
|
|
491
|
+
workflows_one: '{{count}} workflow',
|
|
492
|
+
workflows_other: '{{count}} workflows'
|
|
493
|
+
},
|
|
482
494
|
subagents: {
|
|
483
495
|
stop: {
|
|
484
496
|
task: 'Stop task',
|
|
@@ -479,6 +479,18 @@ export default {
|
|
|
479
479
|
stop: 'Stoppen',
|
|
480
480
|
stopFailed: 'Kon de taak niet stoppen'
|
|
481
481
|
},
|
|
482
|
+
waitingOn: {
|
|
483
|
+
needsYou_one: 'Een sub-agent vraagt aandacht',
|
|
484
|
+
needsYou_other: '{{count}} sub-agents vragen aandacht',
|
|
485
|
+
paused: 'Een sub-agent is gepauzeerd',
|
|
486
|
+
pausedUntil: 'Een sub-agent is gepauzeerd tot {{time}}',
|
|
487
|
+
command: '{{command}} · {{age}}',
|
|
488
|
+
background: 'Bezig op de achtergrond',
|
|
489
|
+
subagents_one: '{{count}} sub-agent op de achtergrond',
|
|
490
|
+
subagents_other: '{{count}} sub-agents op de achtergrond',
|
|
491
|
+
workflows_one: '{{count}} workflow',
|
|
492
|
+
workflows_other: '{{count}} workflows'
|
|
493
|
+
},
|
|
482
494
|
subagents: {
|
|
483
495
|
stop: {
|
|
484
496
|
task: 'Taak stoppen',
|