@adecore/agents-react 0.67.0 → 0.68.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/agents/AgentIcon.d.ts +7 -0
  2. package/dist/agents/AgentIcon.js +70 -31
  3. package/dist/chat/logic/timeline.d.ts +2 -0
  4. package/dist/chat/logic/timeline.js +47 -0
  5. package/dist/chat/subagent-list.d.ts +1 -2
  6. package/dist/chat/ui/Composer.js +491 -447
  7. package/dist/chat/ui/Markdown.d.ts +1 -1
  8. package/dist/chat/ui/Markdown.js +277 -203
  9. package/dist/chat/ui/PromptEditor.d.ts +3 -1
  10. package/dist/chat/ui/PromptEditor.js +4 -1
  11. package/dist/chat/ui/Timeline.js +5 -4
  12. package/dist/chat/ui/composer/ComposerMenu.js +22 -12
  13. package/dist/chat/ui/composer/chips.d.ts +2 -1
  14. package/dist/chat/ui/composer/chips.js +44 -1
  15. package/dist/chat/ui/composer/key-handler.d.ts +2 -0
  16. package/dist/chat/ui/composer/key-handler.js +12 -2
  17. package/dist/chat/ui/composer/placeholder.d.ts +2 -1
  18. package/dist/chat/ui/composer/placeholder.js +31 -10
  19. package/dist/chat/ui/composer/use-composer-menus.js +49 -39
  20. package/dist/chat/ui/composer/use-prompt-menus.d.ts +10 -7
  21. package/dist/chat/ui/composer/use-prompt-menus.js +183 -157
  22. package/dist/chat/ui/composer/use-prompt-suggestion.d.ts +16 -0
  23. package/dist/chat/ui/composer/use-prompt-suggestion.js +55 -0
  24. package/dist/chat/ui/index.d.ts +1 -1
  25. package/dist/chat/ui/index.js +1 -1
  26. package/dist/chat/ui/markdown-cache.d.ts +4 -0
  27. package/dist/chat/ui/markdown-cache.js +47 -0
  28. package/dist/chat/ui/reference-lookup.d.ts +2 -1
  29. package/dist/chat/ui/reference-lookup.js +1 -1
  30. package/dist/chat/ui/rows/SubagentRow.js +26 -24
  31. package/dist/chat/ui/rows/TaskRow.d.ts +11 -1
  32. package/dist/chat/ui/rows/TaskRow.js +281 -197
  33. package/dist/chat/ui/thread-references.js +12 -9
  34. package/dist/chat-client.d.ts +3 -1
  35. package/dist/chat-client.js +82 -30
  36. package/dist/chat-sink.d.ts +1 -0
  37. package/dist/host/host-hooks.d.ts +4 -1
  38. package/dist/host/host-hooks.js +11 -0
  39. package/dist/host/host.d.ts +18 -0
  40. package/dist/index.d.ts +1 -1
  41. package/dist/locales/en/agent-chat.d.ts +1 -0
  42. package/dist/locales/en/agent-chat.js +2 -1
  43. package/dist/locales/nl/agent-chat.d.ts +1 -0
  44. package/dist/locales/nl/agent-chat.js +2 -1
  45. package/dist/state/chats.d.ts +2 -0
  46. package/dist/state/chats.js +21 -5
  47. package/dist/theme.css +6 -0
  48. package/package.json +9 -9
  49. package/src/agents/AgentIcon.tsx +6 -2
  50. package/src/chat/logic/timeline.ts +63 -0
  51. package/src/chat/subagent-list.ts +1 -4
  52. package/src/chat/ui/Composer.tsx +15 -2
  53. package/src/chat/ui/Markdown.tsx +97 -55
  54. package/src/chat/ui/PromptEditor.tsx +7 -2
  55. package/src/chat/ui/Timeline.tsx +17 -14
  56. package/src/chat/ui/composer/ComposerMenu.tsx +14 -6
  57. package/src/chat/ui/composer/chips.ts +51 -2
  58. package/src/chat/ui/composer/key-handler.ts +17 -2
  59. package/src/chat/ui/composer/placeholder.ts +14 -3
  60. package/src/chat/ui/composer/use-composer-menus.ts +8 -3
  61. package/src/chat/ui/composer/use-prompt-menus.ts +33 -4
  62. package/src/chat/ui/composer/use-prompt-suggestion.ts +36 -0
  63. package/src/chat/ui/index.ts +1 -1
  64. package/src/chat/ui/markdown-cache.ts +60 -0
  65. package/src/chat/ui/reference-lookup.ts +4 -2
  66. package/src/chat/ui/rows/SubagentRow.tsx +1 -1
  67. package/src/chat/ui/rows/TaskRow.tsx +54 -9
  68. package/src/chat/ui/thread-references.ts +4 -2
  69. package/src/chat-client.ts +79 -22
  70. package/src/chat-sink.ts +6 -1
  71. package/src/host/host-hooks.ts +19 -1
  72. package/src/host/host.ts +41 -0
  73. package/src/index.ts +3 -0
  74. package/src/locales/en/agent-chat.ts +2 -1
  75. package/src/locales/nl/agent-chat.ts +2 -1
  76. package/src/state/chats.ts +22 -6
  77. package/src/theme.css +6 -0
@@ -17,6 +17,7 @@ export class ChatClient {
17
17
  earlier = new Map();
18
18
  observers = new Map();
19
19
  inspections = new Map();
20
+ skillLists = new Map();
20
21
  preferences = null;
21
22
  checkpoints = new WeakMap();
22
23
  constructor(transport, sink, providers = null) {
@@ -44,7 +45,10 @@ export class ChatClient {
44
45
  }) => this.sink.bookmarks(chatId, bookmarks)), transport.on('chat.visuals', ({
45
46
  chatId,
46
47
  visuals
47
- }) => this.sink.visuals(chatId, visuals)), transport.subscribeStatus(status => this.onStatus(status)));
48
+ }) => this.sink.visuals(chatId, visuals)), transport.on('chat.suggestion', ({
49
+ chatId,
50
+ suggestion
51
+ }) => this.sink.suggestion?.(chatId, suggestion)), transport.subscribeStatus(status => this.onStatus(status)));
48
52
  if (transport.status === 'open') {
49
53
  void this.loadProviders();
50
54
  void this.loadStatuses();
@@ -231,14 +235,30 @@ export class ChatClient {
231
235
  });
232
236
  return visuals;
233
237
  }
234
- /* What this chat's CLI would run as a skill, for the composer's `$` picker. */
235
- async listSkills(chatId) {
236
- const {
237
- skills
238
- } = await this.transport.request('skills.list', {
238
+ /*
239
+ * What this chat's CLI would run as a skill, for the composer's `$` picker. Chats the caller gives
240
+ * the same `alike` key share a request still on the wire, so a project that opens several chats in
241
+ * one folder asks once; an answer is never kept after it came. A shared request that failed is
242
+ * asked again for this chat alone, since it may have failed for the other chat only.
243
+ */
244
+ listSkills(chatId, alike) {
245
+ const ask = async () => (await this.transport.request('skills.list', {
239
246
  chatId
247
+ })).skills;
248
+ if (alike === undefined) {
249
+ return ask();
250
+ }
251
+ const pending = this.skillLists.get(alike);
252
+ if (pending !== undefined) {
253
+ return pending.catch(ask);
254
+ }
255
+ const request = ask().finally(() => {
256
+ if (this.skillLists.get(alike) === request) {
257
+ this.skillLists.delete(alike);
258
+ }
240
259
  });
241
- return skills;
260
+ this.skillLists.set(alike, request);
261
+ return request;
242
262
  }
243
263
  /* Starts the chat over; refused with `chat-busy` while a turn runs, unless `force` stops that turn. */
244
264
  async clear(chatId, force = false) {
@@ -267,13 +287,16 @@ export class ChatClient {
267
287
  }
268
288
  /*
269
289
  * What every chat on this machine is doing right now. `chat.status` only carries a change, so a
270
- * window that just opened or came back from a lost socket asks for the standing answer.
290
+ * window that just opened or came back from a lost socket asks for the standing answer. It leaves
291
+ * out the commands, which the sink keeps from the attach of a chat that has them.
271
292
  */
272
293
  async loadStatuses() {
273
294
  try {
274
295
  const {
275
296
  chats
276
- } = await this.transport.request('chat.list', {});
297
+ } = await this.transport.request('chat.list', {
298
+ omitCommands: true
299
+ });
277
300
  for (const info of chats) {
278
301
  this.sink.status(info.chatId, info);
279
302
  }
@@ -347,29 +370,11 @@ export class ChatClient {
347
370
  if (!entry) {
348
371
  return;
349
372
  }
350
- if (!entry.observerOnly) {
351
- await this.transport.request('chat.create', {
352
- chatId,
353
- provider: entry.provider,
354
- account: entry.account,
355
- cwd: entry.cwd,
356
- resume: entry.resume,
357
- selection: entry.selection,
358
- runtimeMode: entry.runtimeMode
359
- });
360
- }
361
- // Closed or opened again in the meantime: an opening that is still there attaches itself.
362
- if (this.mounted.get(chatId) !== entry) {
373
+ const since = this.sequence(chatId);
374
+ const result = await this.openOnHost(chatId, entry, since);
375
+ if (result === null) {
363
376
  return;
364
377
  }
365
- const since = this.sequence(chatId);
366
- const result = await this.transport.request('chat.attach', {
367
- chatId,
368
- historyLimit: HISTORY_PAGE,
369
- ...(since === undefined ? {} : {
370
- since
371
- })
372
- });
373
378
  const current = this.mounted.get(chatId);
374
379
  if (current !== entry) {
375
380
  // Its detach found nothing attached yet, and the host would stream this chat here until the socket closes.
@@ -408,6 +413,53 @@ export class ChatClient {
408
413
  // A host without bookmarks or visuals sends none, and then this chat has none.
409
414
  this.sink.bookmarks(chatId, result.bookmarks ?? []);
410
415
  this.sink.visuals(chatId, result.visuals ?? []);
416
+ this.sink.suggestion?.(chatId, result.suggestion ?? null);
417
+ }
418
+ /*
419
+ * Makes the chat and attaches it in one request. A host that predates `create` on `chat.attach`
420
+ * ignores it and refuses a chat it does not have yet, which is then made with `chat.create` first.
421
+ * Null when the chat was closed or opened again before that attach: an opening still there attaches itself.
422
+ */
423
+ async openOnHost(chatId, entry, since) {
424
+ const read = {
425
+ chatId,
426
+ historyLimit: HISTORY_PAGE,
427
+ ...(since === undefined ? {} : {
428
+ since
429
+ })
430
+ };
431
+ if (entry.observerOnly) {
432
+ return this.transport.request('chat.attach', read);
433
+ }
434
+ const create = {
435
+ provider: entry.provider,
436
+ account: entry.account,
437
+ cwd: entry.cwd,
438
+ resume: entry.resume,
439
+ selection: entry.selection,
440
+ runtimeMode: entry.runtimeMode
441
+ };
442
+ try {
443
+ return await this.transport.request('chat.attach', {
444
+ ...read,
445
+ create
446
+ });
447
+ } catch (e) {
448
+ if (errorCode(e) !== 'chat-not-found') {
449
+ throw e;
450
+ }
451
+ }
452
+ if (this.mounted.get(chatId) !== entry) {
453
+ return null;
454
+ }
455
+ await this.transport.request('chat.create', {
456
+ chatId,
457
+ ...create
458
+ });
459
+ if (this.mounted.get(chatId) !== entry) {
460
+ return null;
461
+ }
462
+ return this.transport.request('chat.attach', read);
411
463
  }
412
464
  sequence(chatId) {
413
465
  if (!this.sink.historyIdentity) {
@@ -23,5 +23,6 @@ export interface ChatSink {
23
23
  status(chatId: string, info: ChatThreadInfo): void;
24
24
  bookmarks(chatId: string, bookmarks: ChatBookmark[]): void;
25
25
  visuals(chatId: string, visuals: ChatVisual[]): void;
26
+ suggestion?(chatId: string, suggestion: string | null): void;
26
27
  forget(chatId: string): void;
27
28
  }
@@ -1,6 +1,7 @@
1
1
  import type { ProviderPlatform } from '@adecore/agent-contracts';
2
+ import type { ReactNode } from 'react';
2
3
  import type { AccountRule } from './host.js';
3
- import { type ChatHost, type CommandLook, type ComposerStatusItem, type UnknownItemWords } from './host.js';
4
+ import { type ChatHost, type CommandLook, type ComposerStatusItem, type HostSkill, type HostTaskRow, type UnknownItemWords } from './host.js';
4
5
  import { type Referables } from './references.js';
5
6
  export declare function useHostCodeMode(): 'light' | 'dark';
6
7
  export declare function useHostCodeThemes(): {
@@ -19,6 +20,8 @@ export declare function useHostTimelineFind(...args: Parameters<ChatHost['useTim
19
20
  export declare function useHostReferables(scopeId: string, chatId: string): Referables;
20
21
  export declare function useHostLoginBlocked(...args: Parameters<ChatHost['useLoginBlocked']>): ReturnType<ChatHost['useLoginBlocked']>;
21
22
  export declare function useHostExpandingCommands(): ReturnType<NonNullable<ChatHost['useExpandingCommands']>>;
23
+ export declare function useHostSkills(scopeId: string, chatId: string): readonly HostSkill[];
24
+ export declare function useHostTaskRow(row: HostTaskRow): ReactNode;
22
25
  export declare function useHostMachinePlatform(scopeId: string): ProviderPlatform | null;
23
26
  export declare function useHostProjectLook(...args: Parameters<ChatHost['useProjectLook']>): ReturnType<ChatHost['useProjectLook']>;
24
27
  export declare function useHostMachineLabel(...args: Parameters<ChatHost['useMachineLabel']>): ReturnType<ChatHost['useMachineLabel']>;
@@ -55,6 +55,17 @@ export function useHostExpandingCommands() {
55
55
  const useExpanding = useChatHost().useExpandingCommands ?? noExpanding;
56
56
  return useExpanding();
57
57
  }
58
+ const NO_SKILLS = [];
59
+ const noSkills = () => NO_SKILLS;
60
+ export function useHostSkills(scopeId, chatId) {
61
+ const useSkills = useChatHost().useSkills ?? noSkills;
62
+ return useSkills(scopeId, chatId);
63
+ }
64
+ const noTaskRow = () => null;
65
+ export function useHostTaskRow(row) {
66
+ const useTaskRow = useChatHost().useTaskRow ?? noTaskRow;
67
+ return useTaskRow(row);
68
+ }
58
69
  const noPlatform = () => null;
59
70
  export function useHostMachinePlatform(scopeId) {
60
71
  const useMachinePlatform = useChatHost().useMachinePlatform ?? noPlatform;
@@ -77,6 +77,16 @@ export interface SubagentTask {
77
77
  until?: number;
78
78
  };
79
79
  }
80
+ export type TaskRowState = 'running' | 'paused' | 'done' | 'failed' | 'cancelled' | 'waiting';
81
+ export interface HostTaskRow {
82
+ scopeId: string;
83
+ chatId: string;
84
+ item: ChatSubagentItem;
85
+ task: SubagentTask | null;
86
+ state: TaskRowState;
87
+ open: boolean;
88
+ onPress(): void;
89
+ }
80
90
  export interface TimelineFindOptions {
81
91
  chatId: string;
82
92
  frame: RefObject<HTMLDivElement | null>;
@@ -271,6 +281,12 @@ export interface AgentMark {
271
281
  viewBox?: string;
272
282
  fillRule?: 'nonzero' | 'evenodd';
273
283
  }
284
+ export interface HostSkill {
285
+ readonly name: string;
286
+ readonly title: string;
287
+ readonly description: string;
288
+ readonly icon: AgentMark;
289
+ }
274
290
  export interface UnknownItemWords {
275
291
  readonly item: string;
276
292
  readonly request: string;
@@ -282,6 +298,7 @@ export interface ChatHost {
282
298
  hint: string;
283
299
  expand(args: string): Promise<string>;
284
300
  }[];
301
+ useSkills?(scopeId: string, chatId: string): readonly HostSkill[];
285
302
  renderEmptyThread?(chatId: string): ReactNode;
286
303
  renderToolActions?(tool: {
287
304
  name: string;
@@ -289,6 +306,7 @@ export interface ChatHost {
289
306
  output: string | null;
290
307
  state: string;
291
308
  }, chatId: string | undefined): ReactNode;
309
+ useTaskRow?(row: HostTaskRow): ReactNode;
292
310
  renderToolResult?(tool: {
293
311
  name: string;
294
312
  input: unknown;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { type ChatActions, type FileRef, type ShellCodeBlockContext, type ChatPlace, type SubagentTask, type TimelineFindOptions, type TimelineFind, type ComposerDictationProps, type ComposerHeaderSlotProps, type ComposerSlotProps, type ReferenceIconProps, type OutsideReference, type ComposerStatusDetail, type ComposerStatusItem, type SubagentSlotProps, type ThreadCard, type VisualHost, type HostMenuAction, type ReplyAuthor, type UnknownItemWords, type ChatHost, type UiMapSource, type UiModelViewProps, type CommandLook, type CommandLookCall, type CommandLookSent, type CommandLookMatch, type CommandName, type ToolLook, type ToolLookCall, type ToolLookMatch, ChatHostProvider, type AgentMark, type ChatHostLayer, useChatHost } from './host/host.js';
1
+ export { type ChatActions, type FileRef, type ShellCodeBlockContext, type ChatPlace, type SubagentTask, type TaskRowState, type HostTaskRow, type TimelineFindOptions, type TimelineFind, type ComposerDictationProps, type ComposerHeaderSlotProps, type ComposerSlotProps, type ReferenceIconProps, type OutsideReference, type ComposerStatusDetail, type ComposerStatusItem, type SubagentSlotProps, type ThreadCard, type VisualHost, type HostMenuAction, type ReplyAuthor, type UnknownItemWords, type ChatHost, type UiMapSource, type UiModelViewProps, type CommandLook, type CommandLookCall, type CommandLookSent, type CommandLookMatch, type CommandName, type ToolLook, type ToolLookCall, type ToolLookMatch, ChatHostProvider, type AgentMark, type HostSkill, type ChatHostLayer, useChatHost } from './host/host.js';
2
2
  export { type ChatScope, ChatScopeContext, useChatScope } from './scope.js';
3
3
  export { type ChatRequestMap, type ChatEventMap, type ChatTransportStatus, type ChatTransport, ChatTransportError, errorCode, isConnectionError } from './transport.js';
4
4
  export { portTransport, type PortTransport, type PortTransportOptions } from './port-transport.js';
@@ -398,6 +398,7 @@ declare const _default: {
398
398
  references: string;
399
399
  skills: string;
400
400
  readOnly: string;
401
+ suggestion: string;
401
402
  };
402
403
  jumpToEnd: string;
403
404
  mentions: {
@@ -397,7 +397,8 @@ export default {
397
397
  files: 'files',
398
398
  references: 'views',
399
399
  skills: 'skills',
400
- readOnly: 'Go back to the main agent to write'
400
+ readOnly: 'Go back to the main agent to write',
401
+ suggestion: 'to fill in'
401
402
  },
402
403
  jumpToEnd: 'Jump to end',
403
404
  mentions: {
@@ -398,6 +398,7 @@ declare const _default: {
398
398
  references: string;
399
399
  skills: string;
400
400
  readOnly: string;
401
+ suggestion: string;
401
402
  };
402
403
  jumpToEnd: string;
403
404
  mentions: {
@@ -397,7 +397,8 @@ export default {
397
397
  files: 'bestanden',
398
398
  references: 'weergaven',
399
399
  skills: 'skills',
400
- readOnly: 'Ga terug naar de main agent om te schrijven'
400
+ readOnly: 'Ga terug naar de main agent om te schrijven',
401
+ suggestion: 'om in te vullen'
401
402
  },
402
403
  jumpToEnd: 'Naar het einde',
403
404
  mentions: {
@@ -14,6 +14,7 @@ export interface ChatState {
14
14
  outlineBefore?: ChatThreadItem[];
15
15
  bookmarks?: ChatBookmark[];
16
16
  visuals?: ChatVisual[];
17
+ suggestion?: string | null;
17
18
  }
18
19
  export type ChatsById = Record<string, ChatState>;
19
20
  export type ChatStatuses = Record<string, Pick<ChatState, 'info'>>;
@@ -27,6 +28,7 @@ interface ChatsStore {
27
28
  status(key: string, info: ChatThreadInfo): void;
28
29
  bookmarks(key: string, bookmarks: ChatBookmark[]): void;
29
30
  visuals(key: string, visuals: ChatVisual[]): void;
31
+ suggestion(key: string, suggestion: string | null): void;
30
32
  forget(key: string): void;
31
33
  forgetWhere(matches: (key: string) => boolean): void;
32
34
  }
@@ -285,10 +285,11 @@ export const useChats = create(set => ({
285
285
  statusByKey: {},
286
286
  reset(key, info, items, page) {
287
287
  set(s => {
288
- // The bookmarks and the visuals are not part of the thread; they come in on their own and outlive a reset of it.
288
+ // The bookmarks, the visuals and the suggestion are not part of the thread; they come in on their own and outlive a reset of it.
289
289
  const {
290
290
  bookmarks,
291
- visuals
291
+ visuals,
292
+ suggestion
292
293
  } = s.byKey[key] ?? {};
293
294
  const next = {
294
295
  ...stateOf(info, items, page),
@@ -297,6 +298,9 @@ export const useChats = create(set => ({
297
298
  }),
298
299
  ...(visuals === undefined ? {} : {
299
300
  visuals
301
+ }),
302
+ ...(suggestion === undefined ? {} : {
303
+ suggestion
300
304
  })
301
305
  };
302
306
  return {
@@ -374,8 +378,14 @@ export const useChats = create(set => ({
374
378
  statusByKey: withStatus(s.statusByKey, key, info)
375
379
  };
376
380
  }
381
+ // The commands come from the attach and its events; a status may come from a list that left them out.
382
+ const next = {
383
+ ...info,
384
+ slashCommands: current.info.slashCommands,
385
+ skills: current.info.skills
386
+ };
377
387
  // An attached client already had this on `chat.event`; writing it again would redraw the thread.
378
- if (sameInfo(current.info, info)) {
388
+ if (sameInfo(current.info, next)) {
379
389
  return {};
380
390
  }
381
391
  return {
@@ -383,10 +393,10 @@ export const useChats = create(set => ({
383
393
  ...s.byKey,
384
394
  [key]: {
385
395
  ...current,
386
- info
396
+ info: next
387
397
  }
388
398
  },
389
- statusByKey: withStatus(s.statusByKey, key, info)
399
+ statusByKey: withStatus(s.statusByKey, key, next)
390
400
  };
391
401
  });
392
402
  },
@@ -400,6 +410,11 @@ export const useChats = create(set => ({
400
410
  visuals
401
411
  }));
402
412
  },
413
+ suggestion(key, suggestion) {
414
+ set(s => withFields(s, key, {
415
+ suggestion
416
+ }));
417
+ },
403
418
  forget(key) {
404
419
  set(s => {
405
420
  const next = {
@@ -434,6 +449,7 @@ export function chatSink(keyOf) {
434
449
  status: (chatId, info) => useChats.getState().status(keyOf(chatId), info),
435
450
  bookmarks: (chatId, bookmarks) => useChats.getState().bookmarks(keyOf(chatId), bookmarks),
436
451
  visuals: (chatId, visuals) => useChats.getState().visuals(keyOf(chatId), visuals),
452
+ suggestion: (chatId, suggestion) => useChats.getState().suggestion(keyOf(chatId), suggestion),
437
453
  forget: chatId => useChats.getState().forget(keyOf(chatId))
438
454
  };
439
455
  }
package/dist/theme.css CHANGED
@@ -144,6 +144,9 @@
144
144
  /* A word of a reply that just arrived. The duration is REVEAL_FADE_MS in chat/ui/reveal.ts, which
145
145
  keeps the spans until it is over; ease-in-out, because ease-out jumps up and then trails. */
146
146
  .chat-fade { animation: chat-fade 300ms ease-in-out both; }
147
+ /* A reply keeps its spans once the reveal is over; without the animation, a thread hidden and shown
148
+ again does not fade the whole reply in a second time. */
149
+ .chat-markdown[data-faded-in] .chat-fade { animation: none; }
147
150
  /* A whole reply that was written out of sight. */
148
151
  .chat-fade-whole { animation: chat-fade 220ms ease-out both; }
149
152
  /* A block of a reply streamed a block at a time, faded in when it is inserted and never when a
@@ -301,6 +304,9 @@
301
304
  .composer-hints, .composer-hints-extra, .composer-hint { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
302
305
  /* The joiner starts with its own comma, so it sits against the lead without the gap. */
303
306
  .composer-hints-extra { margin-left: -8px; }
307
+ /* A predicted prompt wraps like the text it stands for; its key has no joiner to lean on. */
308
+ .composer-hints.composer-suggestion { display: inline; white-space: normal; }
309
+ .composer-suggestion .composer-hints-extra { margin-left: 8px; }
304
310
  .composer-hints kbd { padding: 0 6px; border-radius: 5px; background: var(--surface-active); color: var(--text-muted); font-family: var(--font-mono); font-size: var(--text-code); line-height: var(--text-code--line-height); }
305
311
  /* The widths of Tailwind's `@md` container variant, which the rest of the composer narrows at. */
306
312
  @container composer (width < 28rem) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adecore/agents-react",
3
- "version": "0.67.0",
3
+ "version": "0.68.0",
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.67.0",
76
- "@adecore/editor": "0.67.0",
77
- "@adecore/editor-react": "0.67.0",
78
- "@adecore/intelligent-ui": "0.67.0",
79
- "@adecore/merge": "0.67.0",
80
- "@adecore/utils": "0.67.0",
75
+ "@adecore/agent-contracts": "0.68.0",
76
+ "@adecore/editor": "0.68.0",
77
+ "@adecore/editor-react": "0.68.0",
78
+ "@adecore/intelligent-ui": "0.68.0",
79
+ "@adecore/merge": "0.68.0",
80
+ "@adecore/utils": "0.68.0",
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.1.0"
102
102
  },
103
103
  "peerDependencies": {
104
- "@adecore/ui": "^0.67.0",
104
+ "@adecore/ui": "^0.68.0",
105
105
  "i18next": "^26.4.2 || ^27.0.0",
106
106
  "react": "^19.3.0",
107
107
  "react-dom": "^19.3.0",
108
108
  "react-i18next": "^17.0.15 || ^18.0.0"
109
109
  },
110
110
  "devDependencies": {
111
- "@adecore/ui": "0.67.0",
111
+ "@adecore/ui": "0.68.0",
112
112
  "@types/bun": "^1.4.4",
113
113
  "@types/react": "^19.3.0",
114
114
  "@types/react-dom": "^19.3.0",
@@ -23,10 +23,14 @@ export function AgentIcon({ kind, size = 14, className }: { kind: AgentKind; siz
23
23
  return <Icon icon={Bot} size={size} className={className} />;
24
24
  }
25
25
 
26
+ return <MarkGlyph mark={mark} size={size} className={className} />;
27
+ }
28
+
29
+ /* A mark in the current text color; `decorative` hides it from a screen reader where a label beside it says the same. */
30
+ export function MarkGlyph({ mark, size = 14, className, decorative = false }: { mark: AgentMark; size?: number; className?: string; decorative?: boolean }) {
26
31
  return (
27
32
  <svg
28
- role="img"
29
- aria-label={mark.title}
33
+ {...(decorative ? { 'aria-hidden': true } : { role: 'img', 'aria-label': mark.title })}
30
34
  viewBox={mark.viewBox ?? '0 0 24 24'}
31
35
  width={size}
32
36
  height={size}
@@ -708,3 +708,66 @@ export function deriveTimelineRows(items: ChatThreadItem[], options: TimelineOpt
708
708
 
709
709
  return rows;
710
710
  }
711
+
712
+ function isPlainObject(value: unknown): value is Record<string, unknown> {
713
+ if (typeof value !== 'object' || value === null) {
714
+ return false;
715
+ }
716
+
717
+ const prototype = Object.getPrototypeOf(value);
718
+
719
+ return prototype === Object.prototype || prototype === null;
720
+ }
721
+
722
+ /* Equal all the way down; an item the store left alone is the same object, so a row is compared without opening it. */
723
+ function sameValue(left: unknown, right: unknown): boolean {
724
+ if (Object.is(left, right)) {
725
+ return true;
726
+ }
727
+
728
+ if (Array.isArray(left)) {
729
+ return Array.isArray(right) && left.length === right.length && left.every((value, index) => sameValue(value, right[index]));
730
+ }
731
+
732
+ if (!isPlainObject(left) || !isPlainObject(right)) {
733
+ return false;
734
+ }
735
+
736
+ const keys = Object.keys(left);
737
+
738
+ return keys.length === Object.keys(right).length && keys.every((key) => Object.hasOwn(right, key) && sameValue(left[key], right[key]));
739
+ }
740
+
741
+ /*
742
+ * `next`, with every row that holds what the row of the same id in `previous` held swapped for that
743
+ * row, and `previous` itself when nothing changed. Deriving the rows makes every row anew, so without
744
+ * this one tool that starts would draw every row of the thread again.
745
+ */
746
+ export function keepUnchangedRows(previous: TimelineRow[], next: TimelineRow[]): TimelineRow[] {
747
+ const byId = new Map(previous.map((row) => [row.id, row]));
748
+ let changed = previous.length !== next.length;
749
+
750
+ const kept = next.map((row, index) => {
751
+ const before = byId.get(row.id);
752
+ const keep = before !== undefined && sameValue(before, row) ? before : row;
753
+
754
+ if (keep !== previous[index]) {
755
+ changed = true;
756
+ }
757
+
758
+ return keep;
759
+ });
760
+
761
+ return changed ? kept : previous;
762
+ }
763
+
764
+ /* A `keepUnchangedRows` that remembers the rows it handed out last, for a thread that derives its rows again. */
765
+ export function createRowKeeper(): (rows: TimelineRow[]) => TimelineRow[] {
766
+ let kept: TimelineRow[] = [];
767
+
768
+ return (rows) => {
769
+ kept = keepUnchangedRows(kept, rows);
770
+
771
+ return kept;
772
+ };
773
+ }
@@ -3,7 +3,7 @@ import { formatMoment, formatElapsedShort } from '@adecore/ui/format';
3
3
  import i18next from 'i18next';
4
4
  import type { StatusWord } from '../agents/status-look';
5
5
  import type { ChatThreadInfo, ChatThreadItem } from '../chat-sink';
6
- import type { SubagentTask } from '../host/host';
6
+ import type { SubagentTask, TaskRowState } from '../host/host';
7
7
 
8
8
  export function subagentTitle(item: ChatSubagentItem): string {
9
9
  return item.description || item.summary || item.subagentType || i18next.t('agent-chat:rows.subagent.label');
@@ -22,9 +22,6 @@ export function statusWordOf(item: ChatSubagentItem, task: SubagentTask | null):
22
22
  return item.status;
23
23
  }
24
24
 
25
- /* What a task's row says its agent is doing: the task's own state, or that the agent waits on a person while the task runs. */
26
- export type TaskRowState = StatusWord | 'waiting';
27
-
28
25
  export function taskRowStateOf(item: ChatSubagentItem, task: SubagentTask | null, child: ChatThreadInfo | undefined): TaskRowState {
29
26
  const word = statusWordOf(item, task);
30
27
 
@@ -41,6 +41,7 @@ import { useNotice } from './composer/use-notice';
41
41
  import { usePendingRequests } from './composer/use-pending-requests';
42
42
  import { usePromptHistory } from './composer/use-prompt-history';
43
43
  import { usePromptHold } from './composer/use-prompt-hold';
44
+ import { usePromptSuggestion } from './composer/use-prompt-suggestion';
44
45
  import { useTakeBack } from './composer/use-take-back';
45
46
  import { ComposerInput, type ComposerInputHandle } from './ComposerInput';
46
47
  import { GoalDock } from './GoalDock';
@@ -192,14 +193,25 @@ export function Composer({
192
193
  const pending = usePendingRequests(chatId);
193
194
  const compactionOffer = useCompactionOffer(chatId, info, capabilities?.compaction);
194
195
  const sigils = { mentionable: capabilities?.mentions !== false, referable: menus.offersViews, hasSkills: menus.hasSkills };
195
- const placeholder = useHintedPlaceholder({ chatId, disabled, readOnly, ...sigils });
196
+
197
+ const suggestion = usePromptSuggestion({
198
+ chatId,
199
+ info,
200
+ empty: isEmptyDraft(draft),
201
+ writable,
202
+ asked: pending.length > 0,
203
+ fill: (text) => inputRef.current?.insert(text)
204
+ });
205
+
206
+ const placeholder = useHintedPlaceholder({ chatId, disabled, readOnly, suggestion: suggestion?.text ?? null, ...sigils });
196
207
  const editorExtensions = [
197
208
  chipDecorations({
198
209
  mentions: draft.mentions,
199
210
  skills: draft.skills,
200
211
  references: menus.referenceChips,
201
212
  referenceIcon: host.ReferenceIcon,
202
- named: menus.namedLook
213
+ named: menus.namedLook,
214
+ hostSkills: menus.hostSkills
203
215
  }),
204
216
  LEAVE_DROPS_TO_THE_CARD
205
217
  ];
@@ -228,6 +240,7 @@ export function Composer({
228
240
  menus,
229
241
  history,
230
242
  noteKey: files.noteKey,
243
+ suggestion,
231
244
  toggleStash,
232
245
  submit
233
246
  });