@adecore/agents-react 0.45.0 → 0.46.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adecore/agents-react",
3
- "version": "0.45.0",
3
+ "version": "0.46.0",
4
4
  "description": "React agent chat threads, composers, approvals, provider accounts and usage views.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -72,11 +72,11 @@
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.45.0",
76
- "@adecore/editor": "0.45.0",
77
- "@adecore/editor-react": "0.45.0",
78
- "@adecore/intelligent-ui": "0.45.0",
79
- "@adecore/merge": "0.45.0",
75
+ "@adecore/agent-contracts": "0.46.0",
76
+ "@adecore/editor": "0.46.0",
77
+ "@adecore/editor-react": "0.46.0",
78
+ "@adecore/intelligent-ui": "0.46.0",
79
+ "@adecore/merge": "0.46.0",
80
80
  "@codemirror/commands": "^6.11.1",
81
81
  "@codemirror/language": "^6.13.1",
82
82
  "@codemirror/state": "^6.7.6",
@@ -100,14 +100,14 @@
100
100
  "zustand": "^5.0.16"
101
101
  },
102
102
  "peerDependencies": {
103
- "@adecore/ui": "^0.45.0",
103
+ "@adecore/ui": "^0.46.0",
104
104
  "i18next": "^26.4.2",
105
105
  "react": "^19.3.0",
106
106
  "react-dom": "^19.3.0",
107
107
  "react-i18next": "^17.0.15"
108
108
  },
109
109
  "devDependencies": {
110
- "@adecore/ui": "0.45.0",
110
+ "@adecore/ui": "0.46.0",
111
111
  "@types/bun": "^1.4.4",
112
112
  "@types/react": "^19.3.0",
113
113
  "@types/react-dom": "^19.3.0",
@@ -445,7 +445,13 @@ export class ChatClient {
445
445
  const page =
446
446
  result.history === undefined
447
447
  ? undefined
448
- : { history: result.history, pending: result.pending ?? [], subagents: result.subagents ?? [], outline: result.outline ?? [] };
448
+ : {
449
+ history: result.history,
450
+ pending: result.pending ?? [],
451
+ subagents: result.subagents ?? [],
452
+ workflows: result.workflows ?? [],
453
+ outline: result.outline ?? []
454
+ };
449
455
 
450
456
  this.sink.reset(chatId, result.info, result.items, page);
451
457
  }
package/src/chat/index.ts CHANGED
@@ -34,6 +34,26 @@ export { EMPTY_TARGET, readTimelineTarget, type TimelineTarget } from './logic/t
34
34
  export { type TimelineRow, summarizeGroup, deriveTimelineRows, type SubagentBranch, type BaseMoved } from './logic/timeline';
35
35
  export { toolSummary, type FileChange } from './logic/tools';
36
36
 
37
+ export {
38
+ workflowPhases,
39
+ workflowCounts,
40
+ workflowAgentState,
41
+ workflowAgentTime,
42
+ workflowAgentPreview,
43
+ workflowDescription,
44
+ workflowPhaseState,
45
+ workflowPhaseTime,
46
+ liveWorkflowPhase,
47
+ type WorkflowPhaseView,
48
+ type WorkflowAgentView,
49
+ type WorkflowAgentState,
50
+ type WorkflowAgentPreview,
51
+ type WorkflowCounts,
52
+ type WorkflowPhaseState,
53
+ type WorkflowPhaseStateKind,
54
+ type WorkflowPhaseTime
55
+ } from './logic/workflow';
56
+
37
57
  export {
38
58
  MENTION_DRAG_TYPE,
39
59
  LEGACY_MENTION_DRAG_TYPE,
@@ -118,6 +118,85 @@ export function workflowCounts(phases: WorkflowPhaseView[]): WorkflowCounts {
118
118
  return counts;
119
119
  }
120
120
 
121
+ /* `running` while an agent of it is at work, `waiting` before any started, and once none can move again `failed` when one did not finish. */
122
+ export type WorkflowPhaseStateKind = 'running' | 'waiting' | 'done' | 'failed';
123
+
124
+ export interface WorkflowPhaseState {
125
+ state: WorkflowPhaseStateKind;
126
+ /* The agents of the phase that are no longer at work or waiting, of all it started so far. */
127
+ settled: number;
128
+ total: number;
129
+ }
130
+
131
+ /* A phase between two of its agents, some settled and some still waiting, is still at work. */
132
+ export function workflowPhaseState(phase: WorkflowPhaseView): WorkflowPhaseState {
133
+ const total = phase.agents.length;
134
+ const waiting = phase.agents.filter((view) => view.state === 'waiting').length;
135
+ const running = phase.agents.filter((view) => view.state === 'running').length;
136
+ const settled = total - waiting - running;
137
+
138
+ if (running > 0 || (waiting > 0 && settled > 0)) {
139
+ return { state: 'running', settled, total };
140
+ }
141
+
142
+ if (settled === 0) {
143
+ return { state: 'waiting', settled, total };
144
+ }
145
+
146
+ return { state: phase.agents.every((view) => view.state === 'done') ? 'done' : 'failed', settled, total };
147
+ }
148
+
149
+ export interface WorkflowPhaseTime {
150
+ startedAt: number;
151
+ /* Null while an agent of it is still at work, so the time counts on from `startedAt`. */
152
+ endedAt: number | null;
153
+ }
154
+
155
+ /*
156
+ * How long the phase's agents were at work, from the first start to the last known end. Agents of a
157
+ * phase run beside each other, so this is never the sum of their times. Null before any started.
158
+ */
159
+ export function workflowPhaseTime(phase: WorkflowPhaseView): WorkflowPhaseTime | null {
160
+ const started = phase.agents.flatMap((view) => (view.agent.startedAt === null ? [] : [view.agent.startedAt]));
161
+
162
+ if (started.length === 0) {
163
+ return null;
164
+ }
165
+
166
+ const startedAt = Math.min(...started);
167
+
168
+ if (phase.agents.some((view) => view.state === 'running')) {
169
+ return { startedAt, endedAt: null };
170
+ }
171
+
172
+ const ends = phase.agents.flatMap(({ agent }) => (agent.startedAt !== null && agent.durationMs !== null ? [agent.startedAt + agent.durationMs] : []));
173
+
174
+ return { startedAt, endedAt: Math.max(startedAt, ...ends) };
175
+ }
176
+
177
+ /*
178
+ * The phase a view beside the thread keeps open by itself: the one with an agent at work, the one whose
179
+ * agent started last when several are, and before any is at work the first that still waits. Null once
180
+ * the workflow stopped running, since then nothing is live.
181
+ */
182
+ export function liveWorkflowPhase(phases: WorkflowPhaseView[], workflowRunning: boolean): string | null {
183
+ if (!workflowRunning) {
184
+ return null;
185
+ }
186
+
187
+ let live: { key: string; startedAt: number } | null = null;
188
+
189
+ for (const phase of phases) {
190
+ for (const view of phase.agents) {
191
+ if (view.state === 'running' && (live === null || (view.agent.startedAt ?? 0) >= live.startedAt)) {
192
+ live = { key: phase.key, startedAt: view.agent.startedAt ?? 0 };
193
+ }
194
+ }
195
+ }
196
+
197
+ return live?.key ?? phases.find((phase) => workflowPhaseState(phase).state === 'waiting')?.key ?? null;
198
+ }
199
+
121
200
  const META_START = /export\s+const\s+meta\s*=\s*\{/;
122
201
  const DESCRIPTION = /\bdescription\s*:\s*(['"`])((?:\\.|(?!\1)[^\\])*)\1/;
123
202
 
@@ -27,8 +27,21 @@ const NO_TURNS = new Set<string>();
27
27
  /*
28
28
  * A sub-agent's whole conversation, read back from the host and grown while it is on screen. It
29
29
  * stands in the chat's own place, read-only, and a sub-agent it opened goes one level further down.
30
+ * Drawn anywhere else, such as in a panel of its own beside the chat, `info={false}` leaves out the bar
31
+ * that leads back through the chat's trail, and `onOpenConversation` opens a child in that place's
32
+ * own trail instead of the chat's.
30
33
  */
31
- export function SubagentTimeline({ chatId, toolUseId }: { chatId: string; toolUseId: string }) {
34
+ export function SubagentTimeline({
35
+ chatId,
36
+ toolUseId,
37
+ info = true,
38
+ onOpenConversation
39
+ }: {
40
+ chatId: string;
41
+ toolUseId: string;
42
+ info?: boolean;
43
+ onOpenConversation?(step: SubagentStep): void;
44
+ }) {
32
45
  const { t } = useTranslation('agent-chat');
33
46
  const scope = useChatScope();
34
47
  const { commandLooks } = useChatHost();
@@ -124,12 +137,16 @@ export function SubagentTimeline({ chatId, toolUseId }: { chatId: string; toolUs
124
137
  const readingWidth = useChatPreferences((preferences) => preferences.readingWidth);
125
138
 
126
139
  const openChild = (step: SubagentStep): void => {
127
- show(openBelow(trail, step));
140
+ if (onOpenConversation === undefined) {
141
+ show(openBelow(trail, step));
142
+ } else {
143
+ onOpenConversation(step);
144
+ }
128
145
  };
129
146
 
130
147
  return (
131
148
  <div className="flex h-full min-h-0 flex-col" style={readingWidthStyle(readingWidth)}>
132
- <SubagentInfo chatId={chatId} toolUseId={toolUseId} />
149
+ {info && <SubagentInfo chatId={chatId} toolUseId={toolUseId} />}
133
150
  {state.status === 'loading' && <div className="chat-column-content px-4 pt-4 text-xs text-text-faint">{t('subagents.loading')}</div>}
134
151
  {state.status === 'failed' && (
135
152
  <EmptyState icon={Bot}>{state.unsupported ? t('subagents.unsupported') : (state.error ?? t('subagents.unreadable'))}</EmptyState>
@@ -0,0 +1,94 @@
1
+ import clsx from 'clsx';
2
+ import type { Ref } from 'react';
3
+ import { Bot, ChevronRight, X } from 'lucide-react';
4
+ import { workflowAgentRef, type AgentKind } from '@adecore/agent-contracts';
5
+ import { formatElapsedShort } from '@adecore/ui/format';
6
+ import { Icon, useTickingText } from '@adecore/ui';
7
+ import { AgentIcon } from '../../agents/AgentIcon';
8
+ import { workflowAgentPreview, workflowAgentTime, type WorkflowAgentState, type WorkflowAgentView } from '../logic/workflow';
9
+ import type { SubagentStep } from '../subagent-view';
10
+ import { ROW_GUTTER } from './icons';
11
+
12
+ const DOT: Record<WorkflowAgentState, string> = {
13
+ running: 'bg-status-running',
14
+ waiting: 'bg-text-faint',
15
+ stopped: 'bg-text-faint',
16
+ done: 'bg-status-idle',
17
+ failed: 'bg-status-error'
18
+ };
19
+
20
+ const TIME = 'shrink-0 text-xs text-text-faint tabular-nums';
21
+
22
+ function Elapsed({ startedAt }: { startedAt: number }) {
23
+ const ref = useTickingText(() => formatElapsedShort(Date.now() - startedAt));
24
+
25
+ return <span ref={ref} className={TIME} />;
26
+ }
27
+
28
+ /*
29
+ * One agent of a workflow: its label, what it does or did, and its time. It opens the agent's
30
+ * conversation when `onOpen` is given and the agent started; one still waiting has no transcript yet.
31
+ * `selected` marks the agent whose conversation is open beside it.
32
+ */
33
+ export function WorkflowAgentLine({
34
+ view,
35
+ provider,
36
+ onOpen,
37
+ selected,
38
+ className,
39
+ ref
40
+ }: {
41
+ view: WorkflowAgentView;
42
+ provider: AgentKind | undefined;
43
+ onOpen?(step: SubagentStep): void;
44
+ selected?: boolean;
45
+ className?: string;
46
+ ref?: Ref<HTMLButtonElement>;
47
+ }) {
48
+ const { agent, state } = view;
49
+ const time = workflowAgentTime(view);
50
+ const preview = workflowAgentPreview(view);
51
+ const agentId = agent.agentId;
52
+ const open = onOpen !== undefined && agentId !== null ? () => onOpen({ toolUseId: workflowAgentRef(agentId), description: agent.label }) : undefined;
53
+
54
+ return (
55
+ <button
56
+ ref={ref}
57
+ data-workflow-agent={agent.index}
58
+ aria-pressed={selected}
59
+ className={clsx(
60
+ '-mx-1 mb-0.5 flex w-[calc(100%+8px)] items-start gap-2 rounded-md px-1 py-1 text-left enabled:hover:bg-surface-hover',
61
+ selected === true && 'bg-surface-active',
62
+ className
63
+ )}
64
+ disabled={open === undefined}
65
+ onClick={open}
66
+ >
67
+ <span className={clsx(ROW_GUTTER, 'relative text-text')}>
68
+ {provider === undefined ? <Icon icon={Bot} size={14} /> : <AgentIcon kind={provider} size={14} />}
69
+ <span className={clsx('absolute -right-0.75 bottom-0 size-2 rounded-full ring-2 ring-surface', DOT[state])} />
70
+ </span>
71
+ <span className="flex min-w-0 grow flex-col">
72
+ <span data-find-field="summary" className={clsx('truncate text-xs font-medium', state === 'failed' ? 'text-status-error' : 'text-text')}>
73
+ {agent.label}
74
+ </span>
75
+ {(preview.tool !== null || preview.text !== null) && (
76
+ <span className="truncate text-2xs text-text-muted">
77
+ {preview.tool !== null && <span className="font-mono text-code">{preview.tool}</span>}
78
+ {preview.tool !== null && preview.text !== null && ' · '}
79
+ {preview.text}
80
+ </span>
81
+ )}
82
+ </span>
83
+ <span className="flex h-5 shrink-0 items-center gap-2">
84
+ {state === 'running' && agent.startedAt !== null ? (
85
+ <Elapsed startedAt={agent.startedAt} />
86
+ ) : (
87
+ time !== null && <span className={TIME}>{time}</span>
88
+ )}
89
+ {state === 'failed' && <Icon icon={X} size={12} className="shrink-0 text-status-error" />}
90
+ <Icon icon={ChevronRight} size={12} className={clsx('shrink-0 text-text-faint', open === undefined && 'invisible')} />
91
+ </span>
92
+ </button>
93
+ );
94
+ }
@@ -74,4 +74,5 @@ export { ReportRow, AssistantRow, NoteRow, AgentTurnRow, CompactionRow } from '.
74
74
  export { TaskRow } from './rows/TaskRow';
75
75
  export { WorkRow, WorkGroupRow, WorkingRow } from './rows/WorkRows';
76
76
  export { WorkflowRow } from './rows/WorkflowRow';
77
+ export { WorkflowAgentLine } from './WorkflowAgentLine';
77
78
  export { useDiffSourceTokens } from './use-diff-source-tokens';
@@ -1,91 +1,21 @@
1
1
  import { useState } from 'react';
2
2
  import clsx from 'clsx';
3
3
  import { useTranslation } from 'react-i18next';
4
- import { Bot, ChevronRight, Square, TriangleAlert, Workflow, X } from 'lucide-react';
5
- import { workflowAgentRef, type AgentKind, type ChatToolItem, type ChatWorkflow } from '@adecore/agent-contracts';
6
- import { formatElapsedShort } from '@adecore/ui/format';
7
- import { Icon, IconButton, useTickingText } from '@adecore/ui';
8
- import { AgentIcon } from '../../../agents/AgentIcon';
9
- import {
10
- workflowAgentPreview,
11
- workflowAgentTime,
12
- workflowCounts,
13
- workflowDescription,
14
- workflowPhases,
15
- type WorkflowAgentState,
16
- type WorkflowAgentView,
17
- type WorkflowCounts,
18
- type WorkflowPhaseView
19
- } from '../../logic/workflow';
4
+ import { ChevronRight, Square, TriangleAlert, Workflow } from 'lucide-react';
5
+ import type { AgentKind, ChatToolItem, ChatWorkflow } from '@adecore/agent-contracts';
6
+ import { Icon, IconButton } from '@adecore/ui';
7
+ import { workflowCounts, workflowDescription, workflowPhases, type WorkflowCounts, type WorkflowPhaseView } from '../../logic/workflow';
20
8
  import { hasToolBody } from '../../logic/tools';
21
9
  import { useSubagentSupport } from '../../subagent-support';
22
10
  import type { SubagentStep } from '../../subagent-view';
23
11
  import { ROW_GUTTER } from '../icons';
12
+ import { WorkflowAgentLine } from '../WorkflowAgentLine';
24
13
  import { ToolBody } from './WorkRows';
25
14
  import { useChatScope } from '../../../scope';
26
15
  import { useChats } from '../../../state/chats';
27
16
  import { useChatActions } from '../../actions';
28
17
  import { useChatHost } from '../../../host';
29
18
 
30
- const DOT: Record<WorkflowAgentState, string> = {
31
- running: 'bg-status-running',
32
- waiting: 'bg-text-faint',
33
- stopped: 'bg-text-faint',
34
- done: 'bg-status-idle',
35
- failed: 'bg-status-error'
36
- };
37
-
38
- const TIME = 'shrink-0 text-xs text-text-faint tabular-nums';
39
-
40
- function Elapsed({ startedAt }: { startedAt: number }) {
41
- const ref = useTickingText(() => formatElapsedShort(Date.now() - startedAt));
42
-
43
- return <span ref={ref} className={TIME} />;
44
- }
45
-
46
- function AgentLine({ view, provider, onOpen }: { view: WorkflowAgentView; provider: AgentKind | undefined; onOpen?(step: SubagentStep): void }) {
47
- const { agent, state } = view;
48
- const time = workflowAgentTime(view);
49
- const preview = workflowAgentPreview(view);
50
- const agentId = agent.agentId;
51
- // One still waiting has no transcript yet.
52
- const open = onOpen !== undefined && agentId !== null ? () => onOpen({ toolUseId: workflowAgentRef(agentId), description: agent.label }) : undefined;
53
-
54
- return (
55
- <button
56
- className="-mx-1 mb-0.5 flex w-[calc(100%+8px)] items-start gap-2 rounded-md px-1 py-1 text-left enabled:hover:bg-surface-hover"
57
- disabled={open === undefined}
58
- onClick={open}
59
- >
60
- <span className={clsx(ROW_GUTTER, 'relative text-text')}>
61
- {provider === undefined ? <Icon icon={Bot} size={14} /> : <AgentIcon kind={provider} size={14} />}
62
- <span className={clsx('absolute -right-0.75 bottom-0 size-2 rounded-full ring-2 ring-surface', DOT[state])} />
63
- </span>
64
- <span className="flex min-w-0 grow flex-col">
65
- <span data-find-field="summary" className={clsx('truncate text-xs font-medium', state === 'failed' ? 'text-status-error' : 'text-text')}>
66
- {agent.label}
67
- </span>
68
- {(preview.tool !== null || preview.text !== null) && (
69
- <span className="truncate text-2xs text-text-muted">
70
- {preview.tool !== null && <span className="font-mono text-code">{preview.tool}</span>}
71
- {preview.tool !== null && preview.text !== null && ' · '}
72
- {preview.text}
73
- </span>
74
- )}
75
- </span>
76
- <span className="flex h-5 shrink-0 items-center gap-2">
77
- {state === 'running' && agent.startedAt !== null ? (
78
- <Elapsed startedAt={agent.startedAt} />
79
- ) : (
80
- time !== null && <span className={TIME}>{time}</span>
81
- )}
82
- {state === 'failed' && <Icon icon={X} size={12} className="shrink-0 text-status-error" />}
83
- <Icon icon={ChevronRight} size={12} className={clsx('shrink-0 text-text-faint', open === undefined && 'invisible')} />
84
- </span>
85
- </button>
86
- );
87
- }
88
-
89
19
  function PhaseBlock({ phase, provider, onOpen }: { phase: WorkflowPhaseView; provider: AgentKind | undefined; onOpen?(step: SubagentStep): void }) {
90
20
  const { t } = useTranslation('agent-chat');
91
21
  const settled = phase.agents.filter((view) => view.state === 'done' || view.state === 'failed').length;
@@ -101,7 +31,7 @@ function PhaseBlock({ phase, provider, onOpen }: { phase: WorkflowPhaseView; pro
101
31
  </div>
102
32
  )}
103
33
  {phase.agents.map((view) => (
104
- <AgentLine key={view.agent.index} view={view} provider={provider} onOpen={onOpen} />
34
+ <WorkflowAgentLine key={view.agent.index} view={view} provider={provider} onOpen={onOpen} />
105
35
  ))}
106
36
  </div>
107
37
  );
@@ -10,6 +10,7 @@ import type {
10
10
  ChatItem,
11
11
  ChatQuestionItem,
12
12
  ChatSubagentItem,
13
+ ChatToolItem,
13
14
  ChatVisual
14
15
  } from '@adecore/agent-contracts';
15
16
  import { appendToolOutput } from '@adecore/agent-contracts/text';
@@ -38,6 +39,11 @@ export interface ChatState {
38
39
  * that a message woke again without a scroll reaching back to its row.
39
40
  */
40
41
  subagentsBefore?: string[];
42
+ /*
43
+ * Workflow calls from before that part that still run or ended since the last message, held the
44
+ * same way, so what shows a workflow beside the thread knows of it and sees it move.
45
+ */
46
+ workflowsBefore?: string[];
41
47
  /*
42
48
  * The outline of the thread before that part (`outlineItems`), cut down and kept apart from
43
49
  * `items`, so the scrubber has a tick for every message before a scroll reaches it.
@@ -58,6 +64,8 @@ export interface ChatPage {
58
64
  pending: ChatItem[];
59
65
  /* The active sub-agents from before the page; absent from a host that sends none. */
60
66
  subagents?: ChatSubagentItem[];
67
+ /* The active Workflow calls from before the page; absent from a host that sends none. */
68
+ workflows?: ChatToolItem[];
61
69
  /* The outline of the thread before the page; absent from a host that sends none. */
62
70
  outline?: ChatItem[];
63
71
  }
@@ -119,8 +127,9 @@ function stateOf(info: ChatInfo, items: ChatItem[], page?: ChatPage): ChatState
119
127
 
120
128
  const before = page.pending.filter((item) => !(item.id in byId));
121
129
  const subagents = (page.subagents ?? []).filter((item) => !(item.id in byId));
130
+ const workflows = (page.workflows ?? []).filter((item) => !(item.id in byId) && !before.some((request) => request.id === item.id));
122
131
 
123
- for (const item of [...before, ...subagents]) {
132
+ for (const item of [...before, ...subagents, ...workflows]) {
124
133
  byId[item.id] = item;
125
134
  }
126
135
 
@@ -132,6 +141,7 @@ function stateOf(info: ChatInfo, items: ChatItem[], page?: ChatPage): ChatState
132
141
  history: page.history,
133
142
  waitingBefore: before.map((item) => item.id),
134
143
  subagentsBefore: subagents.map((item) => item.id),
144
+ workflowsBefore: workflows.map((item) => item.id),
135
145
  outlineBefore: (page.outline ?? []).filter((item) => !(item.id in byId))
136
146
  };
137
147
  }
@@ -143,7 +153,7 @@ function isBeforePage(state: ChatState, historyIndex: number | undefined): boole
143
153
 
144
154
  type ItemWriter = (state: ChatState, item: ChatItem, structural?: boolean) => ChatState;
145
155
 
146
- /* An item from before the page this client holds matters only as a sub-agent, a request that waits, or one that stopped waiting. */
156
+ /* An item from before the page this client holds matters only as a sub-agent, a workflow, a request that waits, or one that stopped waiting. */
147
157
  function withEarlierItem(state: ChatState, item: ChatItem, write: ItemWriter): ChatState {
148
158
  if (item.kind === 'subagent') {
149
159
  const subagents = state.subagentsBefore ?? [];
@@ -151,6 +161,12 @@ function withEarlierItem(state: ChatState, item: ChatItem, write: ItemWriter): C
151
161
  return { ...write(state, item), subagentsBefore: subagents.includes(item.id) ? subagents : [...subagents, item.id] };
152
162
  }
153
163
 
164
+ if (item.kind === 'tool' && item.name === 'Workflow' && item.workflow !== undefined) {
165
+ const workflows = state.workflowsBefore ?? [];
166
+
167
+ return { ...write(state, item), workflowsBefore: workflows.includes(item.id) ? workflows : [...workflows, item.id] };
168
+ }
169
+
154
170
  const waiting = state.waitingBefore ?? [];
155
171
  const held = waiting.includes(item.id);
156
172
 
@@ -181,16 +197,24 @@ export function prependPage(state: ChatState, cursor: string, page: ChatHistoryR
181
197
  const order = [...olderIds, ...state.order];
182
198
 
183
199
  if (page.history.cursor === null) {
184
- const { history: _history, waitingBefore: _waitingBefore, subagentsBefore: _subagentsBefore, outlineBefore: _outlineBefore, ...rest } = loaded;
200
+ const {
201
+ history: _history,
202
+ waitingBefore: _waitingBefore,
203
+ subagentsBefore: _subagentsBefore,
204
+ workflowsBefore: _workflowsBefore,
205
+ outlineBefore: _outlineBefore,
206
+ ...rest
207
+ } = loaded;
185
208
 
186
209
  return { ...rest, items, structure: items, order };
187
210
  }
188
211
 
189
212
  const waitingBefore = (state.waitingBefore ?? []).filter((id) => !olderIds.has(id));
190
213
  const subagentsBefore = (state.subagentsBefore ?? []).filter((id) => !olderIds.has(id));
214
+ const workflowsBefore = (state.workflowsBefore ?? []).filter((id) => !olderIds.has(id));
191
215
  const outlineBefore = (state.outlineBefore ?? []).filter((item) => !olderIds.has(item.id));
192
216
 
193
- return { ...loaded, items, structure: items, order, history: page.history, waitingBefore, subagentsBefore, outlineBefore };
217
+ return { ...loaded, items, structure: items, order, history: page.history, waitingBefore, subagentsBefore, workflowsBefore, outlineBefore };
194
218
  }
195
219
 
196
220
  /* The requests that still wait, oldest first: those from before the page this client holds, then the thread's own. */