@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.
Files changed (53) hide show
  1. package/dist/agents/account-limits.js +5 -2
  2. package/dist/chat/logic/resume-compaction.js +2 -2
  3. package/dist/chat/logic/timeline.d.ts +1 -0
  4. package/dist/chat/logic/timeline.js +4 -1
  5. package/dist/chat/ui/RunSettings.js +63 -58
  6. package/dist/chat/ui/index.d.ts +1 -1
  7. package/dist/chat/ui/intelligent-ui/UiBlockFrame.js +130 -121
  8. package/dist/chat/ui/intelligent-ui/UiReply.js +28 -9
  9. package/dist/chat/ui/intelligent-ui/render-context.d.ts +2 -0
  10. package/dist/chat/ui/intelligent-ui/renderers/data.js +124 -94
  11. package/dist/chat/ui/intelligent-ui/use-ui-queries.d.ts +8 -2
  12. package/dist/chat/ui/intelligent-ui/use-ui-queries.js +162 -74
  13. package/dist/chat/ui/rows/MessageRows.d.ts +2 -1
  14. package/dist/chat/ui/rows/MessageRows.js +48 -40
  15. package/dist/chat/ui/rows/Rows.js +32 -30
  16. package/dist/locales/en/agent-chat.d.ts +3 -0
  17. package/dist/locales/en/agent-chat.js +3 -0
  18. package/dist/locales/en/agent-usage.d.ts +10 -0
  19. package/dist/locales/en/agent-usage.js +10 -0
  20. package/dist/locales/nl/agent-chat.d.ts +3 -0
  21. package/dist/locales/nl/agent-chat.js +3 -0
  22. package/dist/locales/nl/agent-usage.d.ts +10 -0
  23. package/dist/locales/nl/agent-usage.js +10 -0
  24. package/dist/theme.css +9 -4
  25. package/dist/usage/LimitProvenance.d.ts +5 -0
  26. package/dist/usage/LimitProvenance.js +104 -0
  27. package/dist/usage/LimitsList.js +153 -131
  28. package/dist/usage/UsageLimits.d.ts +1 -1
  29. package/dist/usage/UsageLimits.js +241 -158
  30. package/dist/usage/limit-groups.d.ts +2 -0
  31. package/dist/usage/limit-groups.js +12 -3
  32. package/package.json +9 -9
  33. package/src/agents/account-limits.ts +6 -2
  34. package/src/chat/logic/resume-compaction.ts +2 -2
  35. package/src/chat/logic/timeline.ts +7 -2
  36. package/src/chat/ui/RunSettings.tsx +9 -3
  37. package/src/chat/ui/index.ts +1 -0
  38. package/src/chat/ui/intelligent-ui/UiBlockFrame.tsx +5 -2
  39. package/src/chat/ui/intelligent-ui/UiReply.tsx +25 -6
  40. package/src/chat/ui/intelligent-ui/render-context.ts +5 -0
  41. package/src/chat/ui/intelligent-ui/renderers/data.tsx +58 -27
  42. package/src/chat/ui/intelligent-ui/use-ui-queries.ts +81 -61
  43. package/src/chat/ui/rows/MessageRows.tsx +11 -2
  44. package/src/chat/ui/rows/Rows.tsx +1 -1
  45. package/src/locales/en/agent-chat.ts +3 -0
  46. package/src/locales/en/agent-usage.ts +10 -0
  47. package/src/locales/nl/agent-chat.ts +3 -0
  48. package/src/locales/nl/agent-usage.ts +10 -0
  49. package/src/theme.css +9 -4
  50. package/src/usage/LimitProvenance.tsx +23 -0
  51. package/src/usage/LimitsList.tsx +10 -4
  52. package/src/usage/UsageLimits.tsx +88 -18
  53. package/src/usage/limit-groups.ts +16 -3
@@ -1,16 +1,18 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
2
  import { Button, Icon, SectionLabel, Segmented, Tooltip, useNow } from '@adecore/ui';
3
- import { LogIn } from 'lucide-react';
4
- import { useState } from 'react';
3
+ import { ListRestart, LogIn } from 'lucide-react';
4
+ import { useEffect, useRef, useState, useSyncExternalStore } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { AccountDot } from '../agents/AccountDot.js';
7
7
  import { useChatHost } from '../host.js';
8
8
  import { useHostLoginBlocked } from '../host-hooks.js';
9
9
  import { useChatScope } from '../scope.js';
10
10
  import { useProviderAccounts } from '../state/provider-accounts.js';
11
+ import { useUsageStore } from '../state/usage.js';
11
12
  import { ChartLogo } from './ChartLogo.js';
12
13
  import { PROVIDER_LABELS } from './format.js';
13
- import { accountNote, checkedLabel, hasSeveralAccounts, isSignedOut } from './limit-groups.js';
14
+ import { accountNote, hasSeveralAccounts, isSignedOut, showsWindows } from './limit-groups.js';
15
+ import { LimitProvenance } from './LimitProvenance.js';
14
16
  import { useLimitGroups, useUsageLimits } from './limits.js';
15
17
  import { WindowBar } from './LimitsList.js';
16
18
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
@@ -91,7 +93,7 @@ function LoginButton(t0) {
91
93
  }
92
94
  /* One account: where its numbers come from, then a bar per window, or why there are none. */
93
95
  function LimitCard(t0) {
94
- const $ = _c(37);
96
+ const $ = _c(35);
95
97
  const {
96
98
  account,
97
99
  named,
@@ -122,42 +124,31 @@ function LimitCard(t0) {
122
124
  const note = t2;
123
125
  const plan = signedOut ? null : account.entry?.plan;
124
126
  let t3;
125
- if ($[5] !== account.entry || $[6] !== now || $[7] !== signedOut) {
126
- t3 = signedOut || account.entry === null ? null : checkedLabel(account.entry, now);
127
- $[5] = account.entry;
128
- $[6] = now;
129
- $[7] = signedOut;
130
- $[8] = t3;
131
- } else {
132
- t3 = $[8];
133
- }
134
- const checked = t3;
135
- let t4;
136
- if ($[9] !== account.kind) {
137
- t4 = /*#__PURE__*/_jsx(ChartLogo, {
127
+ if ($[5] !== account.kind) {
128
+ t3 = /*#__PURE__*/_jsx(ChartLogo, {
138
129
  provider: account.kind,
139
130
  className: "shrink-0"
140
131
  });
141
- $[9] = account.kind;
142
- $[10] = t4;
132
+ $[5] = account.kind;
133
+ $[6] = t3;
143
134
  } else {
144
- t4 = $[10];
135
+ t3 = $[6];
145
136
  }
146
- const t5 = PROVIDER_LABELS[account.kind];
147
- let t6;
148
- if ($[11] !== t5) {
149
- t6 = /*#__PURE__*/_jsx("span", {
137
+ const t4 = PROVIDER_LABELS[account.kind];
138
+ let t5;
139
+ if ($[7] !== t4) {
140
+ t5 = /*#__PURE__*/_jsx("span", {
150
141
  className: "shrink-0",
151
- children: t5
142
+ children: t4
152
143
  });
153
- $[11] = t5;
154
- $[12] = t6;
144
+ $[7] = t4;
145
+ $[8] = t5;
155
146
  } else {
156
- t6 = $[12];
147
+ t5 = $[8];
157
148
  }
158
- let t7;
159
- if ($[13] !== account.color || $[14] !== account.name || $[15] !== named) {
160
- t7 = named && /*#__PURE__*/_jsxs(_Fragment, {
149
+ let t6;
150
+ if ($[9] !== account.color || $[10] !== account.name || $[11] !== named) {
151
+ t6 = named && /*#__PURE__*/_jsxs(_Fragment, {
161
152
  children: [/*#__PURE__*/_jsx("span", {
162
153
  className: "text-text-faint",
163
154
  children: "\xB7"
@@ -168,53 +159,54 @@ function LimitCard(t0) {
168
159
  children: account.name
169
160
  })]
170
161
  });
171
- $[13] = account.color;
172
- $[14] = account.name;
173
- $[15] = named;
174
- $[16] = t7;
162
+ $[9] = account.color;
163
+ $[10] = account.name;
164
+ $[11] = named;
165
+ $[12] = t6;
175
166
  } else {
176
- t7 = $[16];
167
+ t6 = $[12];
177
168
  }
178
- let t8;
179
- if ($[17] !== plan) {
180
- t8 = plan && /*#__PURE__*/_jsxs("span", {
169
+ let t7;
170
+ if ($[13] !== plan) {
171
+ t7 = plan && /*#__PURE__*/_jsxs("span", {
181
172
  className: "shrink-0 font-normal text-text-muted capitalize",
182
173
  children: ["\xB7 ", plan]
183
174
  });
184
- $[17] = plan;
185
- $[18] = t8;
175
+ $[13] = plan;
176
+ $[14] = t7;
186
177
  } else {
187
- t8 = $[18];
178
+ t7 = $[14];
188
179
  }
189
- let t9;
190
- if ($[19] !== checked) {
191
- t9 = checked !== null && /*#__PURE__*/_jsx("span", {
192
- className: "ml-auto shrink-0 pl-2 font-normal text-text-faint",
193
- children: checked
180
+ let t8;
181
+ if ($[15] !== t3 || $[16] !== t5 || $[17] !== t6 || $[18] !== t7) {
182
+ t8 = /*#__PURE__*/_jsxs("p", {
183
+ className: "flex min-w-0 items-center gap-2 text-xs font-medium",
184
+ children: [t3, t5, t6, t7]
194
185
  });
195
- $[19] = checked;
196
- $[20] = t9;
186
+ $[15] = t3;
187
+ $[16] = t5;
188
+ $[17] = t6;
189
+ $[18] = t7;
190
+ $[19] = t8;
197
191
  } else {
198
- t9 = $[20];
192
+ t8 = $[19];
199
193
  }
200
- let t10;
201
- if ($[21] !== t4 || $[22] !== t6 || $[23] !== t7 || $[24] !== t8 || $[25] !== t9) {
202
- t10 = /*#__PURE__*/_jsxs("p", {
203
- className: "flex min-w-0 items-center gap-2 text-xs font-medium",
204
- children: [t4, t6, t7, t8, t9]
194
+ let t9;
195
+ if ($[20] !== account.entry || $[21] !== now || $[22] !== signedOut) {
196
+ t9 = !signedOut && account.entry !== null && /*#__PURE__*/_jsx(LimitProvenance, {
197
+ entry: account.entry,
198
+ now: now
205
199
  });
206
- $[21] = t4;
207
- $[22] = t6;
208
- $[23] = t7;
209
- $[24] = t8;
210
- $[25] = t9;
211
- $[26] = t10;
200
+ $[20] = account.entry;
201
+ $[21] = now;
202
+ $[22] = signedOut;
203
+ $[23] = t9;
212
204
  } else {
213
- t10 = $[26];
205
+ t9 = $[23];
214
206
  }
215
- let t11;
216
- if ($[27] !== account || $[28] !== login || $[29] !== note || $[30] !== now || $[31] !== signedOut || $[32] !== t) {
217
- t11 = signedOut ? /*#__PURE__*/_jsxs(_Fragment, {
207
+ let t10;
208
+ if ($[24] !== account || $[25] !== login || $[26] !== note || $[27] !== now || $[28] !== signedOut || $[29] !== t) {
209
+ t10 = signedOut ? /*#__PURE__*/_jsxs(_Fragment, {
218
210
  children: [/*#__PURE__*/_jsx("p", {
219
211
  className: "text-xs text-text-faint",
220
212
  children: t("limits.signedOutDetail")
@@ -222,47 +214,50 @@ function LimitCard(t0) {
222
214
  account: account,
223
215
  login: login
224
216
  })]
225
- }) : note !== null ? /*#__PURE__*/_jsx("p", {
226
- className: "text-xs text-text-faint",
227
- children: note
228
- }) : /*#__PURE__*/_jsx("div", {
229
- className: "flex flex-col gap-4",
230
- children: account.entry?.windows.map(window => /*#__PURE__*/_jsx(WindowBar, {
231
- window: window,
232
- now: now,
233
- compact: false
234
- }, window.id))
217
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
218
+ children: [note !== null && /*#__PURE__*/_jsx("p", {
219
+ className: "text-xs text-text-muted",
220
+ children: note
221
+ }), showsWindows(account.entry) && /*#__PURE__*/_jsx("div", {
222
+ className: "flex flex-col gap-4",
223
+ children: account.entry?.windows.map(window => /*#__PURE__*/_jsx(WindowBar, {
224
+ window: window,
225
+ now: now,
226
+ compact: false
227
+ }, window.id))
228
+ })]
235
229
  });
236
- $[27] = account;
237
- $[28] = login;
238
- $[29] = note;
239
- $[30] = now;
240
- $[31] = signedOut;
241
- $[32] = t;
242
- $[33] = t11;
230
+ $[24] = account;
231
+ $[25] = login;
232
+ $[26] = note;
233
+ $[27] = now;
234
+ $[28] = signedOut;
235
+ $[29] = t;
236
+ $[30] = t10;
243
237
  } else {
244
- t11 = $[33];
238
+ t10 = $[30];
245
239
  }
246
- let t12;
247
- if ($[34] !== t10 || $[35] !== t11) {
248
- t12 = /*#__PURE__*/_jsxs("div", {
240
+ let t11;
241
+ if ($[31] !== t10 || $[32] !== t8 || $[33] !== t9) {
242
+ t11 = /*#__PURE__*/_jsxs("div", {
249
243
  className: "flex min-w-0 flex-col gap-3.5 rounded-xl border border-border bg-surface bg-clip-padding px-4 py-3.5",
250
- children: [t10, t11]
244
+ children: [t8, t9, t10]
251
245
  });
252
- $[34] = t10;
253
- $[35] = t11;
254
- $[36] = t12;
246
+ $[31] = t10;
247
+ $[32] = t8;
248
+ $[33] = t9;
249
+ $[34] = t11;
255
250
  } else {
256
- t12 = $[36];
251
+ t11 = $[34];
257
252
  }
258
- return t12;
253
+ return t11;
259
254
  }
260
255
  /*
261
256
  * What is left of each plan, asked of the CLIs themselves, a card per account. Nothing here reads a
262
257
  * credential: every CLI holds its own login and answers the question when the daemon starts one and asks.
263
258
  */
264
259
  export function UsageLimits() {
265
- const $ = _c(44);
260
+ const $ = _c(52);
266
261
  const host = useChatHost();
267
262
  const {
268
263
  t
@@ -277,9 +272,6 @@ export function UsageLimits() {
277
272
  } = host;
278
273
  const blocked = useHostLoginBlocked(scopeId);
279
274
  const [filter, setFilter] = useState("all");
280
- if (limits === null) {
281
- return null;
282
- }
283
275
  let t0;
284
276
  if ($[0] !== groups) {
285
277
  t0 = groups.length > 1 && hasSeveralAccounts(groups);
@@ -353,8 +345,19 @@ export function UsageLimits() {
353
345
  t6 = $[18];
354
346
  }
355
347
  let t7;
356
- if ($[19] !== current || $[20] !== filterable || $[21] !== groups || $[22] !== t) {
357
- t7 = filterable && /*#__PURE__*/_jsx(Segmented, {
348
+ if ($[19] !== limits || $[20] !== scopeId) {
349
+ t7 = /*#__PURE__*/_jsx(LimitsRefresh, {
350
+ limits: limits
351
+ }, scopeId);
352
+ $[19] = limits;
353
+ $[20] = scopeId;
354
+ $[21] = t7;
355
+ } else {
356
+ t7 = $[21];
357
+ }
358
+ let t8;
359
+ if ($[22] !== current || $[23] !== filterable || $[24] !== groups || $[25] !== t) {
360
+ t8 = filterable && /*#__PURE__*/_jsx(Segmented, {
358
361
  value: current,
359
362
  options: [{
360
363
  id: "all",
@@ -363,94 +366,108 @@ export function UsageLimits() {
363
366
  onValueChange: setFilter,
364
367
  label: t("limits.filter")
365
368
  });
366
- $[19] = current;
367
- $[20] = filterable;
368
- $[21] = groups;
369
- $[22] = t;
370
- $[23] = t7;
371
- } else {
372
- t7 = $[23];
373
- }
374
- let t8;
375
- if ($[24] !== t6 || $[25] !== t7) {
376
- t8 = /*#__PURE__*/_jsxs("div", {
377
- className: "flex min-h-8 items-center gap-3",
378
- children: [t6, t7]
379
- });
380
- $[24] = t6;
381
- $[25] = t7;
369
+ $[22] = current;
370
+ $[23] = filterable;
371
+ $[24] = groups;
372
+ $[25] = t;
382
373
  $[26] = t8;
383
374
  } else {
384
375
  t8 = $[26];
385
376
  }
386
377
  let t9;
387
- if ($[27] !== t) {
388
- t9 = t("limits.explain");
389
- $[27] = t;
390
- $[28] = t9;
378
+ if ($[27] !== t6 || $[28] !== t7 || $[29] !== t8) {
379
+ t9 = /*#__PURE__*/_jsxs("div", {
380
+ className: "flex min-h-8 items-center gap-3",
381
+ children: [t6, t7, t8]
382
+ });
383
+ $[27] = t6;
384
+ $[28] = t7;
385
+ $[29] = t8;
386
+ $[30] = t9;
391
387
  } else {
392
- t9 = $[28];
388
+ t9 = $[30];
393
389
  }
394
390
  let t10;
395
- if ($[29] !== t9) {
396
- t10 = /*#__PURE__*/_jsx("p", {
391
+ if ($[31] !== t) {
392
+ t10 = t("limits.explain");
393
+ $[31] = t;
394
+ $[32] = t10;
395
+ } else {
396
+ t10 = $[32];
397
+ }
398
+ let t11;
399
+ if ($[33] !== t10) {
400
+ t11 = /*#__PURE__*/_jsx("p", {
397
401
  className: "text-xs text-text-muted",
398
- children: t9
402
+ children: t10
399
403
  });
400
- $[29] = t9;
401
- $[30] = t10;
404
+ $[33] = t10;
405
+ $[34] = t11;
402
406
  } else {
403
- t10 = $[30];
407
+ t11 = $[34];
404
408
  }
405
- let t11;
406
- if ($[31] !== loginFor || $[32] !== now || $[33] !== shown) {
407
- let t12;
408
- if ($[35] !== loginFor || $[36] !== now) {
409
- t12 = group_2 => group_2.accounts.map(account_0 => /*#__PURE__*/_jsx(LimitCard, {
409
+ let t12;
410
+ if ($[35] !== limits || $[36] !== t) {
411
+ t12 = limits === null && /*#__PURE__*/_jsx("p", {
412
+ className: "text-xs text-text-faint",
413
+ children: t("limits.notRead")
414
+ });
415
+ $[35] = limits;
416
+ $[36] = t;
417
+ $[37] = t12;
418
+ } else {
419
+ t12 = $[37];
420
+ }
421
+ let t13;
422
+ if ($[38] !== loginFor || $[39] !== now || $[40] !== shown) {
423
+ let t14;
424
+ if ($[42] !== loginFor || $[43] !== now) {
425
+ t14 = group_2 => group_2.accounts.map(account_0 => /*#__PURE__*/_jsx(LimitCard, {
410
426
  account: account_0,
411
427
  named: group_2.accounts.length > 1,
412
428
  now: now,
413
429
  login: loginFor(group_2.kind)
414
430
  }, account_0.id));
415
- $[35] = loginFor;
416
- $[36] = now;
417
- $[37] = t12;
431
+ $[42] = loginFor;
432
+ $[43] = now;
433
+ $[44] = t14;
418
434
  } else {
419
- t12 = $[37];
435
+ t14 = $[44];
420
436
  }
421
- t11 = shown.flatMap(t12);
422
- $[31] = loginFor;
423
- $[32] = now;
424
- $[33] = shown;
425
- $[34] = t11;
437
+ t13 = shown.flatMap(t14);
438
+ $[38] = loginFor;
439
+ $[39] = now;
440
+ $[40] = shown;
441
+ $[41] = t13;
426
442
  } else {
427
- t11 = $[34];
443
+ t13 = $[41];
428
444
  }
429
- let t12;
430
- if ($[38] !== t11) {
431
- t12 = /*#__PURE__*/_jsx("div", {
432
- className: "grid grid-cols-2 gap-3",
433
- children: t11
445
+ let t14;
446
+ if ($[45] !== t13) {
447
+ t14 = /*#__PURE__*/_jsx("div", {
448
+ className: "grid grid-cols-2 gap-3 max-[640px]:grid-cols-1",
449
+ children: t13
434
450
  });
435
- $[38] = t11;
436
- $[39] = t12;
451
+ $[45] = t13;
452
+ $[46] = t14;
437
453
  } else {
438
- t12 = $[39];
454
+ t14 = $[46];
439
455
  }
440
- let t13;
441
- if ($[40] !== t10 || $[41] !== t12 || $[42] !== t8) {
442
- t13 = /*#__PURE__*/_jsxs("section", {
456
+ let t15;
457
+ if ($[47] !== t11 || $[48] !== t12 || $[49] !== t14 || $[50] !== t9) {
458
+ t15 = /*#__PURE__*/_jsxs("section", {
443
459
  className: "flex flex-col gap-3",
444
- children: [t8, t10, t12]
460
+ children: [t9, t11, t12, t14]
445
461
  });
446
- $[40] = t10;
447
- $[41] = t12;
448
- $[42] = t8;
449
- $[43] = t13;
462
+ $[47] = t11;
463
+ $[48] = t12;
464
+ $[49] = t14;
465
+ $[50] = t9;
466
+ $[51] = t15;
450
467
  } else {
451
- t13 = $[43];
468
+ t15 = $[51];
452
469
  }
453
- return t13;
470
+ return t15;
454
471
  }
455
472
  function _temp2(group_1) {
456
473
  return {
@@ -460,4 +477,70 @@ function _temp2(group_1) {
460
477
  }
461
478
  function _temp(row) {
462
479
  return row.accounts?.loginCommands;
480
+ }
481
+ function LimitsRefresh({
482
+ limits
483
+ }) {
484
+ const {
485
+ t
486
+ } = useTranslation('agent-usage');
487
+ const scope = useChatScope();
488
+ const [busy, setBusy] = useState(false);
489
+ const [failure, setFailure] = useState(null);
490
+ const pending = useRef(false);
491
+ const alive = useRef(true);
492
+ const answering = useSyncExternalStore(changed => scope.transport.subscribeStatus(changed), () => scope.transport.status === 'open', () => false);
493
+ useEffect(() => {
494
+ alive.current = true;
495
+ return () => {
496
+ alive.current = false;
497
+ };
498
+ }, []);
499
+ const read = async () => {
500
+ if (pending.current || scope.transport.status !== 'open') {
501
+ return;
502
+ }
503
+ pending.current = true;
504
+ setBusy(true);
505
+ setFailure(null);
506
+ try {
507
+ const snapshot = await scope.transport.request('usage.refreshLimits', {});
508
+ if (alive.current) {
509
+ useUsageStore.getState().setLimits(scope.id, snapshot);
510
+ }
511
+ } catch {
512
+ if (alive.current) {
513
+ setFailure({
514
+ snapshot: useUsageStore.getState().byScope[scope.id]?.limits ?? null
515
+ });
516
+ }
517
+ } finally {
518
+ pending.current = false;
519
+ if (alive.current) {
520
+ setBusy(false);
521
+ }
522
+ }
523
+ };
524
+ return /*#__PURE__*/_jsxs("div", {
525
+ className: "flex flex-col items-end gap-1",
526
+ children: [/*#__PURE__*/_jsx(Tooltip, {
527
+ label: answering ? t('limits.refreshHint') : t('limits.offline'),
528
+ children: /*#__PURE__*/_jsx("span", {
529
+ children: /*#__PURE__*/_jsxs(Button, {
530
+ size: "sm",
531
+ variant: "secondary",
532
+ disabled: !answering || busy,
533
+ onClick: () => void read(),
534
+ children: [/*#__PURE__*/_jsx(Icon, {
535
+ icon: ListRestart,
536
+ size: 14
537
+ }), busy ? t('limits.reading') : t('limits.refresh')]
538
+ })
539
+ })
540
+ }), failure !== null && failure.snapshot === limits && /*#__PURE__*/_jsx("p", {
541
+ role: "alert",
542
+ className: "max-w-80 text-xs text-status-error",
543
+ children: t('limits.refreshFailed')
544
+ })]
545
+ });
463
546
  }
@@ -20,6 +20,8 @@ export declare function noteIsWarning(account: LimitAccount): boolean;
20
20
  export declare function emptyWindows(group: LimitGroup, account: LimitAccount): readonly UsageWindow[];
21
21
  export declare function ringWindows(windows: readonly UsageWindow[]): readonly UsageWindow[];
22
22
  export declare function paceText(window: UsageWindow, now: number): string;
23
+ export declare function checkedAge(entry: UsageLimitsProvider, now: number): number | null;
24
+ export declare function showsWindows(entry: UsageLimitsProvider | null): boolean;
23
25
  export declare function checkedLabel(entry: UsageLimitsProvider, now: number): string | null;
24
26
  export declare function explain(provider: UsageLimitsProvider): string | null;
25
27
  export declare function accountNote(account: LimitAccount): string | null;
@@ -95,12 +95,21 @@ export function paceText(window, now) {
95
95
  pace: pace.percent
96
96
  });
97
97
  }
98
+ export function checkedAge(entry, now) {
99
+ if (!Number.isFinite(entry.checkedAt) || entry.checkedAt <= 0 || entry.checkedAt > now + MINUTE) {
100
+ return null;
101
+ }
102
+ return Math.max(0, now - entry.checkedAt);
103
+ }
104
+ export function showsWindows(entry) {
105
+ return entry !== null && entry.windows.length > 0 && (entry.unavailable === null || entry.unavailable.reason === 'failed');
106
+ }
98
107
  /* When the numbers came in and from where: a read of the machine's own, or a turn that reported them. Null before the first read. */
99
108
  export function checkedLabel(entry, now) {
100
- if (entry.checkedAt <= 0) {
109
+ const past = checkedAge(entry, now);
110
+ if (past === null) {
101
111
  return null;
102
112
  }
103
- const past = now - entry.checkedAt;
104
113
  const when = past < MINUTE ? i18next.t('agent-usage:limits.checked.now') : i18next.t('agent-usage:limits.checked.ago', {
105
114
  duration: formatDuration(past)
106
115
  });
@@ -122,7 +131,7 @@ export function explain(provider) {
122
131
  }
123
132
  return provider.unavailable.message ?? i18next.t('agent-usage:limits.unreachable');
124
133
  }
125
- /* Why an account has no bars, or null when it has them. An account the machine does not read says what its login is doing. */
134
+ /* The explanation for an account, including a failed read beside retained bars. An account the machine does not read says what its login is doing. */
126
135
  export function accountNote(account) {
127
136
  return account.entry === null ? accountStatusLine(account.status, true).text : explain(account.entry);
128
137
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adecore/agents-react",
3
- "version": "0.55.1",
3
+ "version": "0.55.2",
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.55.1",
76
- "@adecore/editor": "0.55.1",
77
- "@adecore/editor-react": "0.55.1",
78
- "@adecore/intelligent-ui": "0.55.1",
79
- "@adecore/merge": "0.55.1",
80
- "@adecore/utils": "0.55.1",
75
+ "@adecore/agent-contracts": "0.55.2",
76
+ "@adecore/editor": "0.55.2",
77
+ "@adecore/editor-react": "0.55.2",
78
+ "@adecore/intelligent-ui": "0.55.2",
79
+ "@adecore/merge": "0.55.2",
80
+ "@adecore/utils": "0.55.2",
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.55.1",
104
+ "@adecore/ui": "^0.55.2",
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.55.1",
111
+ "@adecore/ui": "0.55.2",
112
112
  "@types/bun": "^1.4.4",
113
113
  "@types/react": "^19.3.0",
114
114
  "@types/react-dom": "^19.3.0",
@@ -63,12 +63,16 @@ export function continueTarget(
63
63
  return continueTargets(accounts, snapshot, kind, current)[0] ?? null;
64
64
  }
65
65
 
66
- /* Whether another account a chat could go on under has no numbers yet, since the machine only reads one in use by itself. */
66
+ /* Whether another account needs a first read or a retry before its room can be offered. */
67
67
  export function hasUnreadAccount(
68
68
  accounts: ProviderAccounts | null,
69
69
  snapshot: UsageLimitsSnapshot | null,
70
70
  kind: AgentKind,
71
71
  current: string | undefined
72
72
  ): boolean {
73
- return others(accounts, kind, current).some((entry) => (limitsOfAccount(snapshot, entry.id)?.checkedAt ?? 0) === 0);
73
+ return others(accounts, kind, current).some((entry) => {
74
+ const reading = limitsOfAccount(snapshot, entry.id);
75
+
76
+ return (reading?.checkedAt ?? 0) === 0 || reading?.unavailable?.reason === 'failed';
77
+ });
74
78
  }
@@ -62,8 +62,8 @@ function offerableTurn({ info, compaction, items, dismissedTurnId }: OfferInput)
62
62
  return null;
63
63
  }
64
64
 
65
- // `contextTokens` keeps the old number until the next request, so the offer would return right after
66
- // a compaction. A native one is a turn without a message of the person, hence the look at the turn.
65
+ // A host from before compactions moved the meter, or a CLI whose estimate after the fold stays large,
66
+ // would bring the offer back right after a compaction. That is a turn without a message of the person, hence the look at the turn.
67
67
  if (items.some((item) => item.kind === 'compaction' && item.turnId === turn.id)) {
68
68
  return null;
69
69
  }
@@ -62,7 +62,7 @@ export type TimelineRow =
62
62
  | { kind: 'message'; id: string; message: ChatNoteMessage; createdAt: number }
63
63
  // A message this chat's agent sent another node with a command of a look, drawn as said instead of as its call.
64
64
  | { kind: 'sent'; id: string; tool: ChatToolItem; sent: CommandLookSent }
65
- | { kind: 'compaction'; id: string; preTokens: number | null }
65
+ | { kind: 'compaction'; id: string; preTokens: number | null; postTokens?: number }
66
66
  // The turn below ran on another model or effort than the turn before it.
67
67
  | { kind: 'selection-switch'; id: string; from: ModelSelection; to: ModelSelection }
68
68
  | {
@@ -504,7 +504,12 @@ function rowsForItems(items: ChatItem[], options: TimelineOptions, children: Map
504
504
 
505
505
  break;
506
506
  case 'compaction':
507
- rows.push({ kind: 'compaction', id: item.id, preTokens: item.preTokens });
507
+ rows.push({
508
+ kind: 'compaction',
509
+ id: item.id,
510
+ preTokens: item.preTokens,
511
+ ...(item.postTokens === undefined ? {} : { postTokens: item.postTokens })
512
+ });
508
513
 
509
514
  break;
510
515
  case 'turn':