@adecore/agents-react 0.55.1 → 0.55.2
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/agents/account-limits.js +5 -2
- package/dist/chat/logic/resume-compaction.js +2 -2
- package/dist/chat/logic/timeline.d.ts +1 -0
- package/dist/chat/logic/timeline.js +4 -1
- package/dist/chat/ui/RunSettings.js +63 -58
- package/dist/chat/ui/index.d.ts +1 -1
- package/dist/chat/ui/intelligent-ui/UiBlockFrame.js +130 -121
- package/dist/chat/ui/intelligent-ui/UiReply.js +28 -9
- package/dist/chat/ui/intelligent-ui/render-context.d.ts +2 -0
- package/dist/chat/ui/intelligent-ui/renderers/data.js +124 -94
- package/dist/chat/ui/intelligent-ui/use-ui-queries.d.ts +8 -2
- package/dist/chat/ui/intelligent-ui/use-ui-queries.js +162 -74
- package/dist/chat/ui/rows/MessageRows.d.ts +2 -1
- package/dist/chat/ui/rows/MessageRows.js +48 -40
- package/dist/chat/ui/rows/Rows.js +32 -30
- package/dist/locales/en/agent-chat.d.ts +3 -0
- package/dist/locales/en/agent-chat.js +3 -0
- package/dist/locales/en/agent-usage.d.ts +10 -0
- package/dist/locales/en/agent-usage.js +10 -0
- package/dist/locales/nl/agent-chat.d.ts +3 -0
- package/dist/locales/nl/agent-chat.js +3 -0
- package/dist/locales/nl/agent-usage.d.ts +10 -0
- package/dist/locales/nl/agent-usage.js +10 -0
- package/dist/theme.css +9 -4
- package/dist/usage/LimitProvenance.d.ts +5 -0
- package/dist/usage/LimitProvenance.js +104 -0
- package/dist/usage/LimitsList.js +153 -131
- package/dist/usage/UsageLimits.d.ts +1 -1
- package/dist/usage/UsageLimits.js +241 -158
- package/dist/usage/limit-groups.d.ts +2 -0
- package/dist/usage/limit-groups.js +12 -3
- package/package.json +9 -9
- package/src/agents/account-limits.ts +6 -2
- package/src/chat/logic/resume-compaction.ts +2 -2
- package/src/chat/logic/timeline.ts +7 -2
- package/src/chat/ui/RunSettings.tsx +9 -3
- package/src/chat/ui/index.ts +1 -0
- package/src/chat/ui/intelligent-ui/UiBlockFrame.tsx +5 -2
- package/src/chat/ui/intelligent-ui/UiReply.tsx +25 -6
- package/src/chat/ui/intelligent-ui/render-context.ts +5 -0
- package/src/chat/ui/intelligent-ui/renderers/data.tsx +58 -27
- package/src/chat/ui/intelligent-ui/use-ui-queries.ts +81 -61
- package/src/chat/ui/rows/MessageRows.tsx +11 -2
- package/src/chat/ui/rows/Rows.tsx +1 -1
- package/src/locales/en/agent-chat.ts +3 -0
- package/src/locales/en/agent-usage.ts +10 -0
- package/src/locales/nl/agent-chat.ts +3 -0
- package/src/locales/nl/agent-usage.ts +10 -0
- package/src/theme.css +9 -4
- package/src/usage/LimitProvenance.tsx +23 -0
- package/src/usage/LimitsList.tsx +10 -4
- package/src/usage/UsageLimits.tsx +88 -18
- package/src/usage/limit-groups.ts +16 -3
|
@@ -607,6 +607,8 @@ function ContextUsage({ usage, disabled, onCompact }: { usage: ChatUsage; disabl
|
|
|
607
607
|
const percent = Math.round(fraction * 100);
|
|
608
608
|
const segments = contextSegments(usage);
|
|
609
609
|
const used = formatTokens(usage.contextTokens);
|
|
610
|
+
// After a compaction whose CLI named no size, 0 is not how full the context is.
|
|
611
|
+
const pending = usage.contextPending === true;
|
|
610
612
|
|
|
611
613
|
return (
|
|
612
614
|
<Menu.Group className="flex flex-col gap-2 px-2.5 py-1.5">
|
|
@@ -615,10 +617,14 @@ function ContextUsage({ usage, disabled, onCompact }: { usage: ChatUsage; disabl
|
|
|
615
617
|
{t('contextMeter.title')}
|
|
616
618
|
</Menu.GroupLabel>
|
|
617
619
|
<span className={clsx('shrink-0 text-xs tabular-nums', fraction >= 0.7 ? contextTone(fraction) : 'text-text-faint')}>
|
|
618
|
-
{
|
|
620
|
+
{pending
|
|
621
|
+
? t('contextMeter.pending')
|
|
622
|
+
: usage.contextWindow
|
|
623
|
+
? t('contextMeter.of', { used, window: formatTokens(usage.contextWindow) })
|
|
624
|
+
: t('contextMeter.used', { tokens: used })}
|
|
619
625
|
</span>
|
|
620
626
|
</div>
|
|
621
|
-
{usage.contextWindow ? (
|
|
627
|
+
{usage.contextWindow && !pending ? (
|
|
622
628
|
<div
|
|
623
629
|
role="meter"
|
|
624
630
|
aria-valuenow={percent}
|
|
@@ -655,7 +661,7 @@ function ContextUsage({ usage, disabled, onCompact }: { usage: ChatUsage; disabl
|
|
|
655
661
|
)}
|
|
656
662
|
<div className="flex items-center gap-2 text-xs text-text-faint tabular-nums">
|
|
657
663
|
<span className="min-w-0 grow truncate">
|
|
658
|
-
{usage.contextWindow ? t('contextMeter.percentUsed', { percent: formatPercent(fraction * 100) }) : null}
|
|
664
|
+
{usage.contextWindow && !pending ? t('contextMeter.percentUsed', { percent: formatPercent(fraction * 100) }) : null}
|
|
659
665
|
</span>
|
|
660
666
|
<Menu.Item
|
|
661
667
|
unstyled
|
package/src/chat/ui/index.ts
CHANGED
|
@@ -64,8 +64,7 @@ function LivePart({ live }: { live: UiLiveStatus }) {
|
|
|
64
64
|
? t('blocks.live.refused', { source })
|
|
65
65
|
: t('blocks.live.label');
|
|
66
66
|
|
|
67
|
-
const
|
|
68
|
-
const hint = reason !== undefined ? reason : live.sources.length > 0 ? t('blocks.live.sources', { sources: live.sources.join(', ') }) : null;
|
|
67
|
+
const hint = live.sources.length > 0 ? t('blocks.live.sources', { sources: live.sources.join(', ') }) : null;
|
|
69
68
|
|
|
70
69
|
const body = (
|
|
71
70
|
<span tabIndex={hint === null ? undefined : 0} className="flex items-center gap-1.5">
|
|
@@ -101,6 +100,9 @@ function UiBlockFooter({ live = null, answered = null, fixes = NO_FIXES, shownAs
|
|
|
101
100
|
return null;
|
|
102
101
|
}
|
|
103
102
|
|
|
103
|
+
// On its own line rather than in a tooltip, since the value above stays dimmed until it no longer holds.
|
|
104
|
+
const reason = live !== null && (live.state === 'failed' || live.state === 'refused') ? uiReasonText(t, live.code, live.reason) : undefined;
|
|
105
|
+
|
|
104
106
|
return (
|
|
105
107
|
<div className="flex flex-col gap-1.5 text-2xs text-text-faint">
|
|
106
108
|
<div className="flex flex-wrap items-center gap-x-3 gap-y-1">
|
|
@@ -132,6 +134,7 @@ function UiBlockFooter({ live = null, answered = null, fixes = NO_FIXES, shownAs
|
|
|
132
134
|
</span>
|
|
133
135
|
)}
|
|
134
136
|
</div>
|
|
137
|
+
{reason !== undefined && reason !== '' && <p data-ui-live-reason>{reason}</p>}
|
|
135
138
|
{fixes.length > 0 && (
|
|
136
139
|
<ul id={listId} hidden={!fixesOpen} className="flex flex-col gap-0.5 text-text-muted">
|
|
137
140
|
{fixes.map((fix, index) => (
|
|
@@ -294,11 +294,29 @@ interface UiNodesProps {
|
|
|
294
294
|
|
|
295
295
|
/* The children of one parent, each in its own boundary. Where the parent stacks them, a run of text and inline nodes becomes a paragraph. */
|
|
296
296
|
function UiNodes({ nodes, parent, texts, context }: UiNodesProps): ReactNode {
|
|
297
|
-
const drawn = (node: UiViewNode) =>
|
|
298
|
-
|
|
299
|
-
<
|
|
300
|
-
|
|
301
|
-
|
|
297
|
+
const drawn = (node: UiViewNode) => {
|
|
298
|
+
const body = (
|
|
299
|
+
<UiNodeBoundary node={node}>
|
|
300
|
+
<UiNodeBody node={node} parent={parent} texts={texts} context={context} />
|
|
301
|
+
</UiNodeBoundary>
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
const live = context.liveNode?.(node.id);
|
|
305
|
+
|
|
306
|
+
if (live === undefined) {
|
|
307
|
+
return <Fragment key={node.id}>{body}</Fragment>;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Every node that reads live data has this wrapper, stale or not, so a failed read never mounts a map or a chart again.
|
|
311
|
+
// Text has no element of its own to dim, so its wrapper is an inline box rather than none.
|
|
312
|
+
const shape = node.type === '$text' ? 'chat-ui-live-text' : 'chat-ui-live contents';
|
|
313
|
+
|
|
314
|
+
return (
|
|
315
|
+
<span key={node.id} className={live === 'stale' ? `${shape} chat-ui-stale` : shape}>
|
|
316
|
+
{body}
|
|
317
|
+
</span>
|
|
318
|
+
);
|
|
319
|
+
};
|
|
302
320
|
|
|
303
321
|
const paragraph = PARAGRAPHS[parent];
|
|
304
322
|
|
|
@@ -506,7 +524,7 @@ function UiBlockBody({
|
|
|
506
524
|
[sources, element]
|
|
507
525
|
);
|
|
508
526
|
|
|
509
|
-
const liveValue = useUiLiveValues(block, evaluation.nodes, queries.currentReadings);
|
|
527
|
+
const { liveValue, liveNode } = useUiLiveValues(block, evaluation.nodes, queries.currentReadings);
|
|
510
528
|
const sendChoice = host.intelligentUi?.sendChoice;
|
|
511
529
|
const place = useMemo(() => placeReader(frozen, block.revision, unrecorded), [frozen, block.revision, unrecorded]);
|
|
512
530
|
|
|
@@ -518,6 +536,7 @@ function UiBlockBody({
|
|
|
518
536
|
failedChoiceId,
|
|
519
537
|
live: queries.live,
|
|
520
538
|
liveValue,
|
|
539
|
+
liveNode,
|
|
521
540
|
choiceReason: uiLiveChoiceReason(t, queries.live),
|
|
522
541
|
onChoose:
|
|
523
542
|
!queries.ready || queries.reading
|
|
@@ -44,6 +44,9 @@ export interface UiLiveStatus {
|
|
|
44
44
|
code?: string;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/* Whether a node that reads live data shows its last reading (`live`) or one a failed read left behind (`stale`). */
|
|
48
|
+
export type UiLiveNodeState = 'live' | 'stale';
|
|
49
|
+
|
|
47
50
|
/* Live history is separate from the comparison the agent supplies in Stat.previous. */
|
|
48
51
|
export interface UiLiveValue {
|
|
49
52
|
previous?: unknown;
|
|
@@ -79,6 +82,8 @@ export interface UiRenderContext {
|
|
|
79
82
|
place?(nodeId: string, address: string): UiPlacePoint | null | undefined;
|
|
80
83
|
/* Table cells use the evaluated rows index and column key. */
|
|
81
84
|
liveValue?(nodeId: string, prop: string, path?: readonly [row: number, key: string]): UiLiveValue | undefined;
|
|
85
|
+
/* Undefined for a node that reads no live data. */
|
|
86
|
+
liveNode?(nodeId: string): UiLiveNodeState | undefined;
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
export interface UiRendererProps<Props> {
|
|
@@ -3,7 +3,7 @@ import { Button, Icon, KeyValueList, Pill, ScrollArea, Tooltip } from '@adecore/
|
|
|
3
3
|
import { formatBytes, formatDuration, formatMoment, formatNumber, formatPercent, formatRounded } from '@adecore/ui/format';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { ArrowDown, ArrowRight, ArrowUp } from 'lucide-react';
|
|
6
|
-
import { createContext, useContext } from 'react';
|
|
6
|
+
import { createContext, useContext, type ReactNode } from 'react';
|
|
7
7
|
import { useTranslation } from 'react-i18next';
|
|
8
8
|
import { useBlockLocal } from '../block-local';
|
|
9
9
|
import { uiChildrenOf, uiWithUnit } from '../node-text';
|
|
@@ -21,15 +21,29 @@ const TILED_UP_TO = 4;
|
|
|
21
21
|
const EntityTiles = createContext(false);
|
|
22
22
|
|
|
23
23
|
/*
|
|
24
|
-
* A
|
|
25
|
-
* again and lights up once, even when it changes again before the last light settled.
|
|
24
|
+
* A value that live readings keep up to date. Keyed by its text, so a value that changed mounts
|
|
25
|
+
* again and lights up once, even when it changes again before the last light settled. A stale
|
|
26
|
+
* value is dimmed by the node around it, not here.
|
|
26
27
|
*/
|
|
27
|
-
function LiveFigure({
|
|
28
|
+
function LiveFigure({
|
|
29
|
+
text,
|
|
30
|
+
previous,
|
|
31
|
+
live,
|
|
32
|
+
className,
|
|
33
|
+
children
|
|
34
|
+
}: {
|
|
35
|
+
text: string;
|
|
36
|
+
previous?: string;
|
|
37
|
+
live?: UiLiveValue;
|
|
38
|
+
className?: string;
|
|
39
|
+
/* What to draw for `text`, where it is more than the text itself. */
|
|
40
|
+
children?: ReactNode;
|
|
41
|
+
}) {
|
|
28
42
|
const lit = live !== undefined && live.changed && !live.stale && previous !== text;
|
|
29
43
|
|
|
30
44
|
return (
|
|
31
|
-
<span key={text} className={clsx(
|
|
32
|
-
{text}
|
|
45
|
+
<span key={text} className={clsx(lit && 'chat-ui-changed', className) || undefined}>
|
|
46
|
+
{children ?? text}
|
|
33
47
|
</span>
|
|
34
48
|
);
|
|
35
49
|
}
|
|
@@ -57,7 +71,7 @@ export function StatRenderer({ node, context }: UiRendererProps<UiProps<'Stat'>>
|
|
|
57
71
|
text={uiWithUnit(formatRounded(value, 2), unit)}
|
|
58
72
|
previous={typeof live?.previous === 'number' ? uiWithUnit(formatRounded(live.previous, 2), unit) : undefined}
|
|
59
73
|
live={live}
|
|
60
|
-
className="max-w-full truncate text-lg font-semibold tabular-nums"
|
|
74
|
+
className="max-w-full truncate text-lg font-semibold text-text tabular-nums"
|
|
61
75
|
/>
|
|
62
76
|
{change !== null && (
|
|
63
77
|
<Tooltip label={said}>
|
|
@@ -122,25 +136,29 @@ function numberText(cell: Extract<UiTableCell, { kind: 'number' }>, unit: string
|
|
|
122
136
|
return cell.as === 'bytes' ? formatBytes(cell.value) : cell.as === 'duration' ? formatDuration(cell.value) : uiWithUnit(formatRounded(cell.value, 2), unit);
|
|
123
137
|
}
|
|
124
138
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
139
|
+
/* What a cell reads as, so two readings that draw the same do not light up. */
|
|
140
|
+
function cellText(cell: UiTableCell, column: UiTableColumn): string {
|
|
128
141
|
switch (cell.kind) {
|
|
129
142
|
case 'empty':
|
|
130
|
-
return
|
|
143
|
+
return '';
|
|
131
144
|
case 'text':
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
145
|
+
case 'tag':
|
|
146
|
+
return cell.text;
|
|
147
|
+
case 'number':
|
|
148
|
+
return numberText(cell, column.unit);
|
|
149
|
+
case 'date':
|
|
150
|
+
return formatMoment(cell.at);
|
|
151
|
+
case 'file':
|
|
152
|
+
return cell.path;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
135
155
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
);
|
|
143
|
-
}
|
|
156
|
+
function cellContent(cell: Exclude<UiTableCell, { kind: 'empty' }>, column: UiTableColumn): ReactNode {
|
|
157
|
+
switch (cell.kind) {
|
|
158
|
+
case 'text':
|
|
159
|
+
return cell.text;
|
|
160
|
+
case 'number':
|
|
161
|
+
return numberText(cell, column.unit);
|
|
144
162
|
case 'date':
|
|
145
163
|
return <time dateTime={new Date(cell.at).toISOString()}>{formatMoment(cell.at)}</time>;
|
|
146
164
|
case 'file':
|
|
@@ -155,6 +173,23 @@ function Cell({ value, column, live }: { value: unknown; column: UiTableColumn;
|
|
|
155
173
|
}
|
|
156
174
|
}
|
|
157
175
|
|
|
176
|
+
function Cell({ value, column, live }: { value: unknown; column: UiTableColumn; live?: UiLiveValue }) {
|
|
177
|
+
const cell = uiTableCell(value, column);
|
|
178
|
+
|
|
179
|
+
if (cell.kind === 'empty') {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const text = cellText(cell, column);
|
|
184
|
+
const previous = live?.previous === undefined ? undefined : cellText(uiTableCell(live.previous, column), column);
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<LiveFigure text={text} previous={previous} live={live}>
|
|
188
|
+
{cellContent(cell, column)}
|
|
189
|
+
</LiveFigure>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
158
193
|
/*
|
|
159
194
|
* Rows under a sticky head, scrolling inside 320px and sideways when wider than the column. Rows
|
|
160
195
|
* arrive one by one while the block streams, without animation; past fifty a person asks for the rest.
|
|
@@ -213,11 +248,7 @@ export function TableRenderer({ node, context }: UiRendererProps<UiProps<'Table'
|
|
|
213
248
|
isNumericColumn(column) ? 'text-right whitespace-nowrap' : 'text-left'
|
|
214
249
|
)}
|
|
215
250
|
>
|
|
216
|
-
<Cell
|
|
217
|
-
value={row[column.key]}
|
|
218
|
-
column={column}
|
|
219
|
-
live={isNumericColumn(column) ? context.liveValue?.(node.id, 'rows', [index, column.key]) : undefined}
|
|
220
|
-
/>
|
|
251
|
+
<Cell value={row[column.key]} column={column} live={context.liveValue?.(node.id, 'rows', [index, column.key])} />
|
|
221
252
|
</td>
|
|
222
253
|
))}
|
|
223
254
|
</tr>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ChatUiQueryReading, ChatUiQueryState } from '@adecore/agent-contracts';
|
|
2
|
-
import { uiInputValues, UI_CATALOG_VERSION, UI_HOST_LIMITS, UiState, type UiBlock, type UiViewNode
|
|
2
|
+
import { uiInputValues, uiNodeQueries, UI_CATALOG_VERSION, UI_HOST_LIMITS, UiState, type UiBlock, type UiViewNode } from '@adecore/intelligent-ui';
|
|
3
3
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { useChatHost } from '../../../host';
|
|
5
|
-
import
|
|
5
|
+
import { UiPageMemory } from './block-local';
|
|
6
|
+
import type { UiLiveNodeState, UiLiveValue, UiLiveStatus, UiRenderContext } from './render-context';
|
|
6
7
|
|
|
7
8
|
interface LocalReading {
|
|
8
9
|
identity: string;
|
|
@@ -14,6 +15,12 @@ const NO_READINGS: ChatUiQueryState['blocks'][string]['readings'] = {};
|
|
|
14
15
|
// A changed input reads once it has rested this long, so dragging a slider reads its last value only.
|
|
15
16
|
const INPUT_SETTLE_MS = 300;
|
|
16
17
|
|
|
18
|
+
// What each block last read, so a block the thread unmounts while scrolling comes back with its own last value rather than the frozen first one.
|
|
19
|
+
const remembered = new UiPageMemory<Record<string, LocalReading>>(64);
|
|
20
|
+
|
|
21
|
+
/* Answers for a read the host never tried; while a value stands they say nothing about it. */
|
|
22
|
+
const NOT_TRIED = new Set(['busy', 'refresh-limit']);
|
|
23
|
+
|
|
17
24
|
/* The reading that holds for these inputs: this view's own read of them, or the frozen first one for the inputs the block starts with. */
|
|
18
25
|
function successfulReading(
|
|
19
26
|
local: LocalReading | undefined,
|
|
@@ -45,7 +52,13 @@ export function useUiQueries(
|
|
|
45
52
|
frozen?: ChatUiQueryState['blocks'][string]
|
|
46
53
|
) {
|
|
47
54
|
const host = useChatHost();
|
|
48
|
-
const [
|
|
55
|
+
const memoryKey = JSON.stringify([context.scopeId, context.chatId, context.itemId, block.id]);
|
|
56
|
+
const [readings, setReadings] = useState<Record<string, LocalReading>>(() => remembered.get(memoryKey) ?? {});
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
remembered.set(memoryKey, readings);
|
|
60
|
+
}, [memoryKey, readings]);
|
|
61
|
+
|
|
49
62
|
const [busyInput, setBusyInput] = useState<string | null>(null);
|
|
50
63
|
const lastRead = useRef({ inputKey: '', at: 0 });
|
|
51
64
|
const names = Object.keys(block.queries);
|
|
@@ -168,15 +181,28 @@ export function useUiQueries(
|
|
|
168
181
|
state.setQuery(name, reading.value, block);
|
|
169
182
|
}
|
|
170
183
|
|
|
171
|
-
setReadings((previous) =>
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
reading.state === 'fresh' ? { inputs, reading } : previous[name]?.identity === identity ? previous[name].successful : undefined
|
|
184
|
+
setReadings((previous) => {
|
|
185
|
+
const untried = reading.state === 'failed' && reading.code !== undefined && NOT_TRIED.has(reading.code);
|
|
186
|
+
|
|
187
|
+
// The next refresh tries again; until then the value and any real reason it failed stay as they are.
|
|
188
|
+
if (untried && successfulReading(previous[name], initial[name], identity, inputs, defaultInputs) !== undefined) {
|
|
189
|
+
return previous;
|
|
178
190
|
}
|
|
179
|
-
|
|
191
|
+
|
|
192
|
+
return {
|
|
193
|
+
...previous,
|
|
194
|
+
[name]: {
|
|
195
|
+
identity,
|
|
196
|
+
reading,
|
|
197
|
+
successful:
|
|
198
|
+
reading.state === 'fresh'
|
|
199
|
+
? { inputs, reading }
|
|
200
|
+
: previous[name]?.identity === identity
|
|
201
|
+
? previous[name].successful
|
|
202
|
+
: undefined
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
});
|
|
180
206
|
} catch (error) {
|
|
181
207
|
if (stopped) {
|
|
182
208
|
return;
|
|
@@ -245,7 +271,22 @@ export function useUiQueries(
|
|
|
245
271
|
clearTimeout(timer);
|
|
246
272
|
}
|
|
247
273
|
};
|
|
248
|
-
}, [
|
|
274
|
+
}, [
|
|
275
|
+
block,
|
|
276
|
+
state,
|
|
277
|
+
context.scopeId,
|
|
278
|
+
context.chatId,
|
|
279
|
+
context.itemId,
|
|
280
|
+
context.phase,
|
|
281
|
+
inputs,
|
|
282
|
+
query,
|
|
283
|
+
subscribe,
|
|
284
|
+
element,
|
|
285
|
+
identity,
|
|
286
|
+
inputKey,
|
|
287
|
+
initial,
|
|
288
|
+
defaultInputs
|
|
289
|
+
]);
|
|
249
290
|
|
|
250
291
|
const currentReadings = Object.fromEntries(
|
|
251
292
|
names.flatMap((name) => {
|
|
@@ -262,8 +303,9 @@ export function useUiQueries(
|
|
|
262
303
|
? {
|
|
263
304
|
state: reading || (!ready && !failed) ? 'reading' : (failed?.[1].state ?? 'fresh'),
|
|
264
305
|
sources: names.map((name) => block.queries[name].source),
|
|
265
|
-
|
|
266
|
-
|
|
306
|
+
// From the readings that hold, so a failure does not take away when the value on screen was read.
|
|
307
|
+
readAt: names
|
|
308
|
+
.flatMap((name) => successfulFor(name, inputs) ?? [])
|
|
267
309
|
.reduce<number | null>((at, value) => (at === null ? value.readAt : Math.min(at, value.readAt)), null),
|
|
268
310
|
source: failed ? block.queries[failed[0]]?.source : undefined,
|
|
269
311
|
reason: failed?.[1].reason,
|
|
@@ -283,47 +325,16 @@ export function useUiLiveValues(block: UiBlock, nodes: readonly UiViewNode[], re
|
|
|
283
325
|
}
|
|
284
326
|
);
|
|
285
327
|
|
|
286
|
-
const dependencies =
|
|
328
|
+
const dependencies = useMemo(() => uiNodeQueries(block), [block]);
|
|
287
329
|
const names = new Set(Object.keys(block.queries));
|
|
288
|
-
|
|
289
|
-
const references = (value: unknown, into: Set<string>) => {
|
|
290
|
-
if (!value || typeof value !== 'object') {
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
const expression = value as Record<string, unknown>;
|
|
295
|
-
|
|
296
|
-
if (expression.kind === 'reference' && names.has(String(expression.name))) {
|
|
297
|
-
into.add(String(expression.name));
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
for (const child of Object.values(expression)) {
|
|
301
|
-
if (Array.isArray(child)) {
|
|
302
|
-
child.forEach((item) => references(item, into));
|
|
303
|
-
} else if (typeof child === 'object') {
|
|
304
|
-
references(child, into);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
const written = (nodes: readonly UiNode[], inherited = new Set<string>()) => {
|
|
310
|
-
for (const node of nodes) {
|
|
311
|
-
const related = new Set(inherited);
|
|
312
|
-
references(node.expressions, related);
|
|
313
|
-
dependencies.set(node.id, related);
|
|
314
|
-
written(node.children, node.type === 'Each' ? related : inherited);
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
written(block.nodes);
|
|
319
330
|
const values = new Map<string, Record<string, unknown>>();
|
|
320
|
-
const sources = new Map<string,
|
|
331
|
+
const sources = new Map<string, readonly string[]>();
|
|
321
332
|
|
|
322
333
|
const collect = (nodes: readonly UiViewNode[]) => {
|
|
323
334
|
for (const node of nodes) {
|
|
324
|
-
const related = dependencies
|
|
335
|
+
const related = dependencies[node.sourceId ?? node.id];
|
|
325
336
|
|
|
326
|
-
if (related
|
|
337
|
+
if (related !== undefined && !node.error) {
|
|
327
338
|
values.set(node.id, node.props);
|
|
328
339
|
sources.set(node.id, related);
|
|
329
340
|
}
|
|
@@ -341,29 +352,38 @@ export function useUiLiveValues(block: UiBlock, nodes: readonly UiViewNode[], re
|
|
|
341
352
|
}
|
|
342
353
|
|
|
343
354
|
if (!names.size) {
|
|
344
|
-
return undefined;
|
|
355
|
+
return { liveValue: undefined, liveNode: undefined };
|
|
345
356
|
}
|
|
346
357
|
|
|
347
|
-
|
|
358
|
+
const stale = (related: readonly string[]) => related.some((name) => readings[name]?.state === 'failed' || readings[name]?.state === 'refused');
|
|
359
|
+
|
|
360
|
+
const liveValue = (id: string, prop: string, path?: readonly [number, string]): UiLiveValue | undefined => {
|
|
348
361
|
const related = sources.get(id);
|
|
349
362
|
|
|
350
363
|
if (!related) {
|
|
351
364
|
return undefined;
|
|
352
365
|
}
|
|
353
366
|
|
|
354
|
-
const
|
|
355
|
-
|
|
367
|
+
const before = previous.get(id)?.[prop];
|
|
368
|
+
const now = values.get(id)?.[prop];
|
|
356
369
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
const value = get(values.get(id));
|
|
370
|
+
// A row added or taken away moves every row under it, so a cell compares only while the rows are the ones it had.
|
|
371
|
+
const moved = path !== undefined && (!Array.isArray(before) || !Array.isArray(now) || before.length !== now.length);
|
|
372
|
+
const was = path && Array.isArray(before) ? before[path[0]]?.[path[1]] : before;
|
|
373
|
+
const is = path && Array.isArray(now) ? now[path[0]]?.[path[1]] : now;
|
|
362
374
|
|
|
363
375
|
return {
|
|
364
|
-
previous:
|
|
365
|
-
changed:
|
|
366
|
-
stale:
|
|
376
|
+
previous: moved ? undefined : was,
|
|
377
|
+
changed: !moved && was !== undefined && JSON.stringify(was) !== JSON.stringify(is),
|
|
378
|
+
stale: stale(related)
|
|
367
379
|
};
|
|
368
380
|
};
|
|
381
|
+
|
|
382
|
+
const liveNode = (id: string): UiLiveNodeState | undefined => {
|
|
383
|
+
const related = sources.get(id);
|
|
384
|
+
|
|
385
|
+
return related === undefined ? undefined : stale(related) ? 'stale' : 'live';
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
return { liveValue, liveNode };
|
|
369
389
|
}
|
|
@@ -705,14 +705,23 @@ export function AgentTurnRow({ label, onOpen }: { label: string; onOpen?: () =>
|
|
|
705
705
|
}
|
|
706
706
|
|
|
707
707
|
/* A dashed line, since what stands above it is still there for the reader but only a summary to the agent. */
|
|
708
|
-
export function CompactionRow({ preTokens }: { preTokens: number | null }) {
|
|
708
|
+
export function CompactionRow({ preTokens, postTokens }: { preTokens: number | null; postTokens?: number }) {
|
|
709
709
|
const { t } = useTranslation('agent-chat');
|
|
710
710
|
|
|
711
|
+
// A size the CLI did not name is left out rather than guessed.
|
|
712
|
+
const text = preTokens
|
|
713
|
+
? postTokens === undefined
|
|
714
|
+
? t('rows.compaction.from', { tokens: formatTokens(preTokens) })
|
|
715
|
+
: t('rows.compaction.fromTo', { from: formatTokens(preTokens), to: formatTokens(postTokens) })
|
|
716
|
+
: postTokens === undefined
|
|
717
|
+
? t('rows.compaction.plain')
|
|
718
|
+
: t('rows.compaction.to', { tokens: formatTokens(postTokens) });
|
|
719
|
+
|
|
711
720
|
return (
|
|
712
721
|
<div className="flex items-center gap-3 pb-3 text-xs text-text-faint">
|
|
713
722
|
<span className="grow border-t border-dashed border-border" />
|
|
714
723
|
<Tooltip label={t('rows.compaction.summary')}>
|
|
715
|
-
<span>{
|
|
724
|
+
<span>{text}</span>
|
|
716
725
|
</Tooltip>
|
|
717
726
|
<span className="grow border-t border-dashed border-border" />
|
|
718
727
|
</div>
|
|
@@ -116,7 +116,7 @@ export function Row({ row, chatId, toggleGroup, toggleTurn, toggleSubagent, open
|
|
|
116
116
|
case 'sent':
|
|
117
117
|
return <SentByAgentRow chatId={chatId} id={row.id} tool={row.tool} sent={row.sent} />;
|
|
118
118
|
case 'compaction':
|
|
119
|
-
return <CompactionRow preTokens={row.preTokens} />;
|
|
119
|
+
return <CompactionRow preTokens={row.preTokens} postTokens={row.postTokens} />;
|
|
120
120
|
case 'selection-switch':
|
|
121
121
|
return <SelectionSwitchRow chatId={chatId} from={row.from} to={row.to} />;
|
|
122
122
|
case 'working':
|
|
@@ -105,6 +105,7 @@ export default {
|
|
|
105
105
|
used: '{{tokens}} used',
|
|
106
106
|
percentUsed: '{{percent}} used',
|
|
107
107
|
estimate: '≈{{tokens}}',
|
|
108
|
+
pending: 'Size known after the next reply',
|
|
108
109
|
parts: {
|
|
109
110
|
toolOutput: 'Tool output',
|
|
110
111
|
filesRead: 'Files read',
|
|
@@ -157,6 +158,8 @@ export default {
|
|
|
157
158
|
compaction: {
|
|
158
159
|
plain: 'Context compacted',
|
|
159
160
|
from: 'Context compacted from {{tokens}} tokens',
|
|
161
|
+
to: 'Context compacted to {{tokens}} tokens',
|
|
162
|
+
fromTo: 'Context compacted from {{from}} to {{to}} tokens',
|
|
160
163
|
summary: 'Everything above reaches the agent only as a summary'
|
|
161
164
|
},
|
|
162
165
|
selectionSwitch: {
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
limits: {
|
|
3
|
+
notRead: 'No plan limits have been read. Read them again on this machine.',
|
|
4
|
+
refresh: 'Read limits again',
|
|
5
|
+
reading: 'Reading limits',
|
|
6
|
+
refreshHint: 'Asks this machine to read the eligible accounts again.',
|
|
7
|
+
refreshFailed: 'Could not read limits. Try again.',
|
|
8
|
+
offline: 'Connect to this machine to read limits.',
|
|
9
|
+
lastKnown: 'Last known numbers',
|
|
3
10
|
title: 'Limits',
|
|
4
11
|
explain: 'The mark shows where usage would be at an even pace. Past the mark, you use it up faster than it resets.',
|
|
5
12
|
loading: 'Loading limits…',
|
|
@@ -24,6 +31,9 @@ export default {
|
|
|
24
31
|
signedOutDetail: 'Not logged in. Log in to see limits.',
|
|
25
32
|
logIn: 'Log in',
|
|
26
33
|
checked: {
|
|
34
|
+
unknown: 'Update time unknown',
|
|
35
|
+
updated: 'Last updated · {{when}}',
|
|
36
|
+
old: 'May be out of date',
|
|
27
37
|
now: 'now',
|
|
28
38
|
ago: '{{duration}} ago',
|
|
29
39
|
fromTurn: 'From a turn · {{when}}'
|
|
@@ -105,6 +105,7 @@ export default {
|
|
|
105
105
|
used: '{{tokens}} gebruikt',
|
|
106
106
|
percentUsed: '{{percent}} gebruikt',
|
|
107
107
|
estimate: '≈{{tokens}}',
|
|
108
|
+
pending: 'Grootte bekend na het volgende antwoord',
|
|
108
109
|
parts: {
|
|
109
110
|
toolOutput: 'Tool-output',
|
|
110
111
|
filesRead: 'Gelezen bestanden',
|
|
@@ -157,6 +158,8 @@ export default {
|
|
|
157
158
|
compaction: {
|
|
158
159
|
plain: 'Context gecomprimeerd',
|
|
159
160
|
from: 'Context gecomprimeerd vanaf {{tokens}} tokens',
|
|
161
|
+
to: 'Context gecomprimeerd tot {{tokens}} tokens',
|
|
162
|
+
fromTo: 'Context gecomprimeerd van {{from}} tot {{to}} tokens',
|
|
160
163
|
summary: 'Alles hierboven kent de agent alleen nog als samenvatting'
|
|
161
164
|
},
|
|
162
165
|
selectionSwitch: {
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
limits: {
|
|
3
|
+
notRead: 'Nog geen planlimieten gelezen. Lees ze opnieuw op deze machine.',
|
|
4
|
+
refresh: 'Limieten opnieuw lezen',
|
|
5
|
+
reading: 'Limieten lezen',
|
|
6
|
+
refreshHint: 'Vraagt deze machine de geschikte accounts opnieuw te lezen.',
|
|
7
|
+
refreshFailed: 'Limieten lezen mislukt. Probeer opnieuw.',
|
|
8
|
+
offline: 'Maak verbinding met deze machine om limieten te lezen.',
|
|
9
|
+
lastKnown: 'Laatst bekende cijfers',
|
|
3
10
|
title: 'Limieten',
|
|
4
11
|
explain: 'De markering toont waar het verbruik bij een gelijk tempo zou staan. Voorbij de markering verbruik je sneller dan het weer vrijkomt.',
|
|
5
12
|
loading: 'Limieten laden…',
|
|
@@ -24,6 +31,9 @@ export default {
|
|
|
24
31
|
signedOutDetail: 'Niet ingelogd. Log in om limieten te zien.',
|
|
25
32
|
logIn: 'Inloggen',
|
|
26
33
|
checked: {
|
|
34
|
+
unknown: 'Bijwerktijd onbekend',
|
|
35
|
+
updated: 'Laatst bijgewerkt · {{when}}',
|
|
36
|
+
old: 'Mogelijk verouderd',
|
|
27
37
|
now: 'nu',
|
|
28
38
|
ago: '{{duration}} geleden',
|
|
29
39
|
fromTurn: 'Uit een turn · {{when}}'
|
package/src/theme.css
CHANGED
|
@@ -155,15 +155,20 @@
|
|
|
155
155
|
@keyframes chat-fade { from { opacity: 0; } to { opacity: 1; } }
|
|
156
156
|
/* A node of an intelligent UI block that lands inside another, such as a step or a row: 160ms like
|
|
157
157
|
the card's own children, but only a fade, so a parent arriving with its children rises once. */
|
|
158
|
-
.chat-ui-nodes > * {
|
|
158
|
+
.chat-ui-nodes > *, .chat-ui-nodes > .chat-ui-live > * {
|
|
159
159
|
transition: opacity 160ms ease-out;
|
|
160
160
|
@starting-style { opacity: 0; }
|
|
161
161
|
}
|
|
162
|
-
/* A
|
|
163
|
-
|
|
162
|
+
/* A node whose live read failed dims its last value until a read succeeds. The wrapper draws no box of its
|
|
163
|
+
own, so its child dims; one stale inside another stays at the parent's opacity rather than dimming twice. */
|
|
164
|
+
.chat-ui-stale.chat-ui-live > *, .chat-ui-stale.chat-ui-live-text { opacity: 0.5; transition: opacity 160ms ease-out; }
|
|
165
|
+
.chat-ui-stale .chat-ui-stale.chat-ui-live > *, .chat-ui-stale .chat-ui-stale.chat-ui-live-text { opacity: 1; }
|
|
166
|
+
/* A value a live reading changed lights up in the accent once and settles back in 800ms. A tag keeps a
|
|
167
|
+
color of its own, so the light runs on the direct child too. */
|
|
168
|
+
.chat-ui-changed, .chat-ui-changed > * { animation: chat-ui-changed 800ms ease-out; }
|
|
164
169
|
@keyframes chat-ui-changed { from { color: var(--accent); } }
|
|
165
170
|
@media (prefers-reduced-motion: reduce) {
|
|
166
|
-
.chat-ui-changed { animation: none; }
|
|
171
|
+
.chat-ui-changed, .chat-ui-changed > * { animation: none; }
|
|
167
172
|
}
|
|
168
173
|
/*
|
|
169
174
|
* A block stands in a band across the whole thread, hatched above and below, with its tiles at the
|