🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(conversation): keep steered follow-ups inside one continuous turn (#20218)
Innei5d4a22a9a494
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex ea36ef51e9a..bf40f0df38f 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -1283,7 +1283,7 @@"inputQueue.delete": "Delete","inputQueue.edit": "Edit","inputQueue.enqueueRejected": "Queue is full. Try again after the current run finishes.",- "inputQueue.queuedHint": "Queued — will steer the next turn",+ "inputQueue.queuedHint": "Sends when the current step finishes","inputQueue.sendNow": "Send now (interrupts current run)","intentUnderstanding.title": "Understanding your intent...","internalLink.agent.open": "Open agent",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex 1acf57e2e0e..bb77e0938b6 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -1283,7 +1283,7 @@"inputQueue.delete": "删除","inputQueue.edit": "编辑","inputQueue.enqueueRejected": "队列已满。请在当前运行完成后再试。",- "inputQueue.queuedHint": "已排队 — 将引导下一步操作",+ "inputQueue.queuedHint": "当前步骤完成后发送","inputQueue.sendNow": "立即发送(中断当前运行)","intentUnderstanding.title": "正在理解你的意图…","internalLink.agent.open": "打开助理",diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex ab1b5cea0c5..7a13e2c0ef0 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -786,7 +786,7 @@ export default {'inputQueue.delete': 'Delete','inputQueue.edit': 'Edit','inputQueue.enqueueRejected': 'Queue is full. Try again after the current run finishes.',- 'inputQueue.queuedHint': 'Queued — will steer the next turn',+ 'inputQueue.queuedHint': 'Sends when the current step finishes','inputQueue.sendNow': 'Send now (interrupts current run)','intentUnderstanding.title': 'Understanding your intent...','inviteMembers': 'Invite members',diff --git a/src/features/Conversation/ChatInput/OpStatusTray.tsx b/src/features/Conversation/ChatInput/OpStatusTray.tsxindex cab4c39d725..ae72e8679b5 100644--- a/src/features/Conversation/ChatInput/OpStatusTray.tsx+++ b/src/features/Conversation/ChatInput/OpStatusTray.tsx@@ -265,15 +265,17 @@ const OpStatusTray = memo<OpStatusTrayProps>(({ seamless, topAttached }) => {activity = mapped;}- if (!AI_RUNTIME_OPERATION_TYPES.includes(op.type)) {+ const isSteeredSend = op.type === 'sendMessage' && op.metadata.turnStartTime !== undefined;+ if (!AI_RUNTIME_OPERATION_TYPES.includes(op.type) && !isSteeredSend) {continue;}runtimeOperationIds.push(op.id);stepCount = Math.max(stepCount, normalizeStepCount(op.metadata.stepCount));- if (earliestStart === undefined || op.metadata.startTime < earliestStart) {- earliestStart = op.metadata.startTime;+ const turnStartTime = op.metadata.turnStartTime ?? op.metadata.startTime;+ if (earliestStart === undefined || turnStartTime < earliestStart) {+ earliestStart = turnStartTime;statusSeed = op.id;}}@@ -286,14 +288,20 @@ const OpStatusTray = memo<OpStatusTrayProps>(({ seamless, topAttached }) => {};});const operationsByMessage = useChatStore((s) => s.operationsByMessage);+ const handoffStartTime = useChatStore((s) =>+ operationSelectors.isSteerHandoffPending(context)(s)+ ? operationSelectors.getLatestAgentRuntimeTurnStartTime(context)(s)+ : undefined,+ );+ const startTime = operationState.startTime ?? handoffStartTime;const [now, setNow] = useState(() => Date.now());useEffect(() => {- if (!operationState.startTime) return;+ if (!startTime) return;setNow(Date.now());const id = setInterval(() => setNow(Date.now()), 1000);return () => clearInterval(id);- }, [operationState.startTime]);+ }, [startTime]);const operationIds = useMemo(() => new Set(operationState.operationIdsKey.split('|').filter(Boolean)),@@ -307,10 +315,10 @@ const OpStatusTray = memo<OpStatusTrayProps>(({ seamless, topAttached }) => {return calculateOperationUsageMetrics(dbMessages, operationIds, operationsByMessage);}, [dbMessages, operationIds, operationsByMessage]);- if (!operationState.startTime) return null;+ if (!startTime) return null;const { totalCost, totalTokens } = usageMetrics;- const elapsed = now - operationState.startTime;+ const elapsed = now - startTime;const costLabel = t('chat:opStatusTray.cost');const stepLabel = t('chat:opStatusTray.steps');const tokenLabel = t('chat:opStatusTray.tokens', { defaultValue: 'tokens' });@@ -324,7 +332,7 @@ const OpStatusTray = memo<OpStatusTrayProps>(({ seamless, topAttached }) => {const randomGeneratingStatus =pickRotatingStatusPhrase(generatingPhrases,- operationState.statusSeed ?? String(operationState.startTime),+ operationState.statusSeed ?? String(startTime),rotationStep,) ?? t('chat:opStatusTray.status.generating');const statusText =diff --git a/src/features/Conversation/ChatInput/QueueTray.tsx b/src/features/Conversation/ChatInput/QueueTray.tsxindex c4b97f64783..c7ddefda45c 100644--- a/src/features/Conversation/ChatInput/QueueTray.tsx+++ b/src/features/Conversation/ChatInput/QueueTray.tsx@@ -15,6 +15,7 @@ import {type QueuedFile,type QueuedMessage,reconstructUploadFilesFromQueue,+ SEND_NOW_CANCEL_REASON,} from '@/store/chat/slices/operation/types';import { messageMapKey } from '@/store/chat/utils/messageMapKey';import { useFileStore } from '@/store/file';@@ -51,6 +52,12 @@ const styles = createStaticStyles(({ css, cssVar }) => ({overflow: hidden;text-overflow: ellipsis;`,+ hint: css`+ padding-block: 0 6px;+ padding-inline: 34px 12px;+ font-size: 12px;+ color: ${cssVar.colorTextDescription};+ `,icon: css`flex-shrink: 0;color: ${cssVar.colorTextDescription};@@ -205,7 +212,7 @@ const QueueTray = memo(() => {const runningOpIds =operationSelectors.getRunningQueueBlockingOperationIds(context)(chat);const cancellationConfirmed = await Promise.all(- runningOpIds.map((id) => chat.cancelOperation(id, 'send_now')),+ runningOpIds.map((id) => chat.cancelOperation(id, SEND_NOW_CANCEL_REASON)),);if (cancellationConfirmed.some((confirmed) => !confirmed)) {throw new Error('Running agent cancellation was not confirmed');@@ -266,18 +273,21 @@ const QueueTray = memo(() => {)}</Flexbox><ActionIcon+ aria-label={t('inputQueue.edit')}icon={Pencil}size="small"title={t('inputQueue.edit')}onClick={() => handleEdit(msg)}/><ActionIcon+ aria-label={t('inputQueue.sendNow')}icon={ArrowUp}size="small"title={t('inputQueue.sendNow')}onClick={() => handleSendNow(msg)}/><ActionIcon+ aria-label={t('inputQueue.delete')}icon={Trash2}size="small"title={t('inputQueue.delete')}@@ -286,6 +296,7 @@ const QueueTray = memo(() => {</Flexbox>);})}+ <div className={styles.hint}>{t('inputQueue.queuedHint')}</div></Flexbox>);});diff --git a/src/features/Conversation/Messages/Assistant/components/InterruptedHint.tsx b/src/features/Conversation/Messages/Assistant/components/InterruptedHint.tsxindex 1a98508cb7d..2faa25b5426 100644--- a/src/features/Conversation/Messages/Assistant/components/InterruptedHint.tsx+++ b/src/features/Conversation/Messages/Assistant/components/InterruptedHint.tsx@@ -2,6 +2,11 @@ import { createStaticStyles } from 'antd-style';import { memo } from 'react';import { useTranslation } from 'react-i18next';+import { useChatStore } from '@/store/chat';+import { operationSelectors } from '@/store/chat/selectors';++import { contextSelectors, useConversationStore } from '../../../store';+const styles = createStaticStyles(({ css, cssVar }) => ({container: css`padding-block: 4px;@@ -12,6 +17,10 @@ const styles = createStaticStyles(({ css, cssVar }) => ({const InterruptedHint = memo(() => {const { t } = useTranslation('chat');+ const context = useConversationStore(contextSelectors.context);+ const handingOff = useChatStore(operationSelectors.isSteerHandoffPending(context));++ if (handingOff) return null;return (<div className={styles.container}>diff --git a/src/features/Conversation/Messages/AssistantGroup/components/Group.test.tsx b/src/features/Conversation/Messages/AssistantGroup/components/Group.test.tsxindex e123ab6f5e4..e9e9591d5aa 100644--- a/src/features/Conversation/Messages/AssistantGroup/components/Group.test.tsx+++ b/src/features/Conversation/Messages/AssistantGroup/components/Group.test.tsx@@ -12,6 +12,7 @@ import Group from './Group';let mockIsCollapsed = false;let mockIsGenerating = false;+let mockCreatingIds = new Set<string>();let mockDbMessages: {createdAt?: Date | number | string | null;id: string;@@ -40,6 +41,7 @@ vi.mock('../../../store', () => ({messageStateSelectors: {isAssistantGroupItemGenerating: () => () => mockIsGenerating,isMessageCollapsed: () => () => mockIsCollapsed,+ isMessageCreating: (id: string) => () => mockCreatingIds.has(id),isMessageGenerating: () => () => mockIsGenerating,},useConversationStore: (selector: (state: unknown) => unknown) =>@@ -177,6 +179,7 @@ describe('Group', () => {cleanup();mockIsCollapsed = false;mockIsGenerating = false;+ mockCreatingIds = new Set();mockDbMessages = [];mockOperations = [];});@@ -973,6 +976,33 @@ describe('Group', () => {expect(outside).toEqual(['b2']);});+ it('keeps the loading placeholder of a continuation that is still being created', () => {+ mockCreatingIds = new Set(['pending-assistant']);++ const { container } = render(+ <Group+ enableProcessFold+ isLatestItem+ blocks={chain1}+ id="group-1"+ messageIndex={0}+ continuations={[+ {+ blocks: [blk({ content: LOADING_FLAT, id: 'pending-assistant' })],+ id: 'pending-assistant',+ steerUserId: 'steer-1',+ },+ ]}+ />,+ );++ const ids = Array.from(container.querySelectorAll('[data-testid="answer-segment"]')).map(+ (node) => JSON.parse(node.getAttribute('data-block') || '{}').id,+ );+ expect(ids).toContain('pending-assistant');+ expect(screen.queryByTestId('process-fold')).not.toBeInTheDocument();+ });+it('skips the fold for a continuation whose whole output is the final answer', () => {mockOperations = [];diff --git a/src/features/Conversation/Messages/AssistantGroup/components/Group.tsx b/src/features/Conversation/Messages/AssistantGroup/components/Group.tsxindex 31d58d00985..26cf752fded 100644--- a/src/features/Conversation/Messages/AssistantGroup/components/Group.tsx+++ b/src/features/Conversation/Messages/AssistantGroup/components/Group.tsx@@ -15,7 +15,7 @@ import { MessageAggregationContext } from '../../Contexts/MessageAggregationContimport { formatReasoningDuration } from '../toolDisplayNames';import { CollapsedMessage } from './CollapsedMessage';import type { GroupChainInput, GroupChainView } from './groupChain';-import { buildChainView, getLastBlockCreatedAt, getTurnDurationMs } from './groupChain';+import { buildChainView, getChainDurationsMs, getLastBlockCreatedAt } from './groupChain';import ProcessFold from './ProcessFold';import { renderChainSegment } from './renderChainSegment';import type { GroupRenderSegment } from './segments';@@ -71,7 +71,11 @@ const Group = memo<GroupChildrenProps>(const [isCollapsed, generatingFlags] = useConversationStore((s) => [messageStateSelectors.isMessageCollapsed(id)(s),- chains.map((chain) => messageStateSelectors.isAssistantGroupItemGenerating(chain.id)(s)),+ chains.map(+ (chain) =>+ messageStateSelectors.isAssistantGroupItemGenerating(chain.id)(s) ||+ messageStateSelectors.isMessageCreating(chain.id)(s),+ ),],isEqual,);@@ -120,7 +124,7 @@ const Group = memo<GroupChildrenProps>([chains, persistedFinishTypes],);const chainDurations = useConversationStore(- (s) => chains.map((chain) => getTurnDurationMs(s.dbMessages, chain.blocks)),+ (s) => getChainDurationsMs(s.dbMessages, chains),isEqual,);const lastBlock = allBlocks.at(-1);diff --git a/src/features/Conversation/Messages/AssistantGroup/components/groupChain.test.ts b/src/features/Conversation/Messages/AssistantGroup/components/groupChain.test.tsnew file mode 100644index 00000000000..977bd4e94ad--- /dev/null+++ b/src/features/Conversation/Messages/AssistantGroup/components/groupChain.test.ts@@ -0,0 +1,52 @@+import { describe, expect, it } from 'vitest';++import type { AssistantContentBlock } from '@/types/index';++import { getChainDurationsMs } from './groupChain';++const blk = (id: string) => ({ content: '', id }) as AssistantContentBlock;++describe('getChainDurationsMs', () => {+ it('ends an interrupted turn at the steer that interrupted it', () => {+ const dbMessages = [+ { createdAt: 1000, id: 'a1' },+ { createdAt: 15_000, id: 'steer-1' },+ { createdAt: 15_100, id: 'b1' },+ { createdAt: 20_000, id: 'b2' },+ ];++ expect(+ getChainDurationsMs(dbMessages, [+ { blocks: [blk('a1')], id: 'a1' },+ { blocks: [blk('b1'), blk('b2')], id: 'g2', steerUserId: 'steer-1' },+ ]),+ ).toEqual([14_000, 4900]);+ });++ it('keeps the step span for the last or only turn', () => {+ const dbMessages = [+ { createdAt: 1000, id: 'a1' },+ { createdAt: 4000, id: 'a2' },+ ];++ expect(getChainDurationsMs(dbMessages, [{ blocks: [blk('a1'), blk('a2')], id: 'g1' }])).toEqual(+ [3000],+ );+ expect(getChainDurationsMs(dbMessages, [{ blocks: [blk('a1')], id: 'g1' }])).toEqual([0]);+ });++ it('falls back to the step span when the steer row is not loaded', () => {+ const dbMessages = [+ { createdAt: 1000, id: 'a1' },+ { createdAt: 2500, id: 'a2' },+ { createdAt: 9000, id: 'b1' },+ ];++ expect(+ getChainDurationsMs(dbMessages, [+ { blocks: [blk('a1'), blk('a2')], id: 'g1' },+ { blocks: [blk('b1')], id: 'g2', steerUserId: 'missing' },+ ]),+ ).toEqual([1500, 0]);+ });+});diff --git a/src/features/Conversation/Messages/AssistantGroup/components/groupChain.ts b/src/features/Conversation/Messages/AssistantGroup/components/groupChain.tsindex 9043385f087..2b41e8693b8 100644--- a/src/features/Conversation/Messages/AssistantGroup/components/groupChain.ts+++ b/src/features/Conversation/Messages/AssistantGroup/components/groupChain.ts@@ -95,6 +95,23 @@ export const getFirstBlockCreatedAt = (return earliest;};+export const getChainDurationsMs = (+ dbMessages: DbMessageLike[] | undefined,+ chains: GroupChainInput[],+): number[] =>+ chains.map((chain, index) => {+ const steerUserId = chains[index + 1]?.steerUserId;+ const steerCreatedAt = steerUserId+ ? toEpochMs(dbMessages?.find((message) => message.id === steerUserId)?.createdAt)+ : undefined;+ const startedAt = getFirstBlockCreatedAt(dbMessages, chain.blocks);++ if (steerCreatedAt !== undefined && startedAt !== undefined && steerCreatedAt > startedAt)+ return steerCreatedAt - startedAt;++ return getTurnDurationMs(dbMessages, chain.blocks);+ });+/*** When a set of steps finished, normalized to epoch ms.*diff --git a/src/features/Conversation/Messages/AssistantGroup/index.tsx b/src/features/Conversation/Messages/AssistantGroup/index.tsxindex 50ed6b5385f..dbbc8cbcba3 100644--- a/src/features/Conversation/Messages/AssistantGroup/index.tsx+++ b/src/features/Conversation/Messages/AssistantGroup/index.tsx@@ -108,7 +108,7 @@ const GroupMessage = memo<GroupMessageProps>(agentId,usage,createdAt,- children,+ children: groupChildren,performance,model,provider,@@ -117,6 +117,11 @@ const GroupMessage = memo<GroupMessageProps>(signalCallbacks,taskCompletions,} = item;+ const children = useMemo(+ () =>+ item.role === 'assistant' ? [item as unknown as AssistantContentBlock] : groupChildren,+ [groupChildren, item],+ );const avatar = useAgentMeta(agentId);const continuationMessages = useConversationStore((s) => continuations.map((c) => dataSelectors.getDisplayMessageById(c.groupId)(s)),diff --git a/src/features/Conversation/Messages/Contexts/MessageActionProvider.tsx b/src/features/Conversation/Messages/Contexts/MessageActionProvider.tsxindex 645493d6e96..4403e744542 100644--- a/src/features/Conversation/Messages/Contexts/MessageActionProvider.tsx+++ b/src/features/Conversation/Messages/Contexts/MessageActionProvider.tsx@@ -47,9 +47,7 @@ const AssistantGroupActionsRenderer: FC<SingletonPortalProps> = ({ id }) => {(s) => s.actionsBar?.assistantGroup ?? s.actionsBar?.assistant,);const item = useConversationStore(dataSelectors.getDisplayMessageById(id), isEqual);- const lastAssistantMsg = useConversationStore(- dataSelectors.getGroupLatestMessageWithoutTools(id),- );+ const lastAssistantMsg = useConversationStore(dataSelectors.getRowLatestMessageWithoutTools(id));const contentId = lastAssistantMsg?.id;if (!item) return null;diff --git a/src/features/Conversation/Messages/index.tsx b/src/features/Conversation/Messages/index.tsxindex 1363aa028fb..5807a1a61e7 100644--- a/src/features/Conversation/Messages/index.tsx+++ b/src/features/Conversation/Messages/index.tsx@@ -159,6 +159,19 @@ const MessageItem = memo<MessageItemProps>(}case 'assistant': {+ if (continuations?.length)+ return (+ <AssistantGroupMessage+ continuations={continuations}+ defaultWorkflowExpandLevel={defaultWorkflowExpandLevel}+ disableEditing={effectiveDisableEditing}+ footerRender={footerRender}+ id={id}+ index={index}+ isLatestItem={isLatestItem}+ />+ );+return (<AssistantMessagedisableEditing={effectiveDisableEditing}diff --git a/src/features/Conversation/store/slices/data/selectors.test.ts b/src/features/Conversation/store/slices/data/selectors.test.tsindex 3165a95412e..e42c02fd2b9 100644--- a/src/features/Conversation/store/slices/data/selectors.test.ts+++ b/src/features/Conversation/store/slices/data/selectors.test.ts@@ -43,3 +43,48 @@ describe('taskCallbackTaskIds', () => {expect(dataSelectors.taskCallbackTaskIds(stateWith([{ id: 'm1', role: 'user' }]))).toEqual([]);});});++describe('getRowLatestMessageWithoutTools', () => {+ it('resolves a steered row to the final answer of its last turn', () => {+ const state = stateWith([+ { content: 'first draft', id: 'a1', role: 'assistant' },+ { content: 'shorter please', id: 's1', metadata: { steer: true }, role: 'user' },+ {+ children: [+ { content: '', id: 'b1', tools: [{ id: 't1' }] },+ { content: 'final answer', id: 'b2' },+ ],+ id: 'g2',+ role: 'assistantGroup',+ },+ ]);++ expect(dataSelectors.getRowLatestMessageWithoutTools('a1')(state)).toMatchObject({+ content: 'final answer',+ id: 'b2',+ });+ });++ it('uses a plain assistant tail as the row answer', () => {+ const state = stateWith([+ { children: [{ content: 'first', id: 'b1' }], id: 'g1', role: 'assistantGroup' },+ { content: 'go on', id: 's1', metadata: { steer: true }, role: 'user' },+ { content: 'tail answer', id: 'a2', role: 'assistant' },+ ]);++ expect(dataSelectors.getRowLatestMessageWithoutTools('g1')(state)).toMatchObject({+ content: 'tail answer',+ id: 'a2',+ });+ });++ it('keeps the group answer for an unsteered row', () => {+ const state = stateWith([+ { children: [{ content: 'only answer', id: 'b1' }], id: 'g1', role: 'assistantGroup' },+ ]);++ expect(dataSelectors.getRowLatestMessageWithoutTools('g1')(state)).toMatchObject({+ id: 'b1',+ });+ });+});diff --git a/src/features/Conversation/store/slices/data/selectors.ts b/src/features/Conversation/store/slices/data/selectors.tsindex 5c6854989ab..aca68ed90d7 100644--- a/src/features/Conversation/store/slices/data/selectors.ts+++ b/src/features/Conversation/store/slices/data/selectors.ts@@ -211,6 +211,16 @@ const toAssistantContentBlock = (message: UIChatMessage): AssistantContentBlockusage: message.usage,});+const getRowLatestMessageWithoutTools = (id: string) => (s: State) => {+ const tailId = rowMemberIds(id)(s).at(-1) ?? id;+ const tail = getDisplayMessageById(tailId)(s);++ if (tail?.role !== 'assistant') return getGroupLatestMessageWithoutTools(tailId)(s);+ if (tail.tools?.length || !tail.content) return;++ return toAssistantContentBlock(tail);+};+/*** Walk displayMessages (including compressed groups and agentCouncil members)* to find an assistant content block by its id. Used to let tool subtrees@@ -318,6 +328,7 @@ export const dataSelectors = {getBlockHasTools,getDisplayMessageById,getGroupLatestMessageWithoutTools,+ getRowLatestMessageWithoutTools,getToolInBlock,getToolMessageCreatedAt,getToolsInBlock,diff --git a/src/features/Conversation/store/slices/data/steerChains.test.ts b/src/features/Conversation/store/slices/data/steerChains.test.tsindex d36d311ab04..08310f7308d 100644--- a/src/features/Conversation/store/slices/data/steerChains.test.ts+++ b/src/features/Conversation/store/slices/data/steerChains.test.ts@@ -61,14 +61,30 @@ describe('collectSteerChains', () => {collectSteerChains([msg('s1', 'user', { steer: true }), msg('g1', 'assistantGroup')]).hostOf.size,).toBe(0);+ });- expect(- collectSteerChains([- msg('a1', 'assistant'),- msg('s1', 'user', { steer: true }),- msg('g1', 'assistantGroup'),- ]).hostOf.size,- ).toBe(0);+ it('lets a plain assistant reply host the steer that followed it', () => {+ const { byHost, hostOf } = collectSteerChains([+ msg('u1', 'user'),+ msg('a1', 'assistant'),+ msg('s1', 'user', { steer: true }),+ msg('g1', 'assistantGroup'),+ ]);++ expect(byHost.get('a1')?.continuations).toEqual([{ groupId: 'g1', steerUserId: 's1' }]);+ expect(hostOf.get('s1')).toBe('a1');+ expect(hostOf.get('g1')).toBe('a1');+ });++ it('does not index a plain assistant reply that nothing steered', () => {+ const { byHost } = collectSteerChains([+ msg('u1', 'user'),+ msg('a1', 'assistant'),+ msg('u2', 'user'),+ msg('a2', 'assistant'),+ ]);++ expect(byHost.size).toBe(0);});it('breaks the chain at a regular user message', () => {diff --git a/src/features/Conversation/store/slices/data/steerChains.ts b/src/features/Conversation/store/slices/data/steerChains.tsindex 83743463ca0..043bd14c116 100644--- a/src/features/Conversation/store/slices/data/steerChains.ts+++ b/src/features/Conversation/store/slices/data/steerChains.ts@@ -16,15 +16,12 @@ export interface SteerChainIndex {hostOf: Map<string, string>;}-// A plain `assistant` reply (a turn that finished without tool calls) cannot host a-// chain: its row component has no continuation rendering, so a steer after it stays-// a separate row. Fixing that means promoting the reply to `assistantGroup` when it is-// interrupted, not widening this predicate.+// A plain `assistant` host has no continuation rendering of its own; the row+// renderer promotes it to the assistantGroup component once it hosts a chain.const isTurnHost = (message?: UIChatMessage) =>- message?.role === 'assistantGroup' || message?.role === 'supervisor';--const isTurnTail = (message?: UIChatMessage) =>- isTurnHost(message) || message?.role === 'assistant';+ message?.role === 'assistantGroup' ||+ message?.role === 'supervisor' ||+ message?.role === 'assistant';const isSteerUser = (message?: UIChatMessage) =>message?.role === 'user' && !!message.metadata?.steer;@@ -38,7 +35,7 @@ const buildSteerChainIndex = (messages: UIChatMessage[]): SteerChainIndex => {const message = messages[index]!;const next = messages[index + 1];- if (chain && isSteerUser(message) && isTurnTail(next)) {+ if (chain && isSteerUser(message) && isTurnHost(next)) {chain.continuations.push({ groupId: next!.id, steerUserId: message.id });chain.memberIds.push(message.id, next!.id);hostOf.set(message.id, chain.hostId);diff --git a/src/store/chat/slices/agentRun/actions/entries/conversationLifecycle.ts b/src/store/chat/slices/agentRun/actions/entries/conversationLifecycle.tsindex 4d4349ad6d3..57f3ec8eaa9 100644--- a/src/store/chat/slices/agentRun/actions/entries/conversationLifecycle.ts+++ b/src/store/chat/slices/agentRun/actions/entries/conversationLifecycle.ts@@ -65,6 +65,7 @@ import { getPendingTopicRepos } from '@/store/chat/pendingTopicRepos';import {dbMessageSelectors,displayMessageSelectors,+ operationSelectors,topicSelectors,} from '@/store/chat/selectors';import { selectRuntimeType } from '@/store/chat/slices/agentRun/actions/dispatch/agentDispatcher';@@ -737,7 +738,11 @@ export class ConversationLifecycleActionImpl {break;}}- if (runningQueueBlockingOp) {+ const queueDrainPending =+ !runningQueueBlockingOp &&+ !onlyAddUserMessage &&+ operationSelectors.isQueueDrainPending(operationContext)(this.#get());+ if (runningQueueBlockingOp || queueDrainPending) {// Snapshot file previews so the tray can render thumbnails AND the// resumed sendMessage can rebuild audioList/imageList/videoList — by the time// we drain, chatUploadFileList has long been cleared.@@ -762,7 +767,7 @@ export class ConversationLifecycleActionImpl {metadata: userMessageMetadata,createdAt: Date.now(),},- runningQueueBlockingOp.id,+ runningQueueBlockingOp?.id,);notifyMessageAccepted();return;@@ -896,6 +901,9 @@ export class ConversationLifecycleActionImpl {// whole send.const tempId = optimisticUserMessageId ?? generateEntityId('messages');const tempAssistantId = generateEntityId('messages');+ const steeredTurnStartTime = (metadata as Pick<MessageMetadata, 'steer'> | undefined)?.steer+ ? operationSelectors.getLatestAgentRuntimeTurnStartTime(operationContext)(this.#get())+ : undefined;const { operationId, abortController } = this.#get().startOperation({type: 'sendMessage',context: { ...operationContext, messageId: tempId },@@ -903,6 +911,7 @@ export class ConversationLifecycleActionImpl {metadata: {// Mark this as thread operation if threadId existsinThread: !!operationContext.threadId,+ ...(steeredTurnStartTime === undefined ? {} : { turnStartTime: steeredTurnStartTime }),},});sendOperationId = operationId;diff --git a/src/store/chat/slices/agentRun/actions/lifecycle/buildRunLifecycle.test.ts b/src/store/chat/slices/agentRun/actions/lifecycle/buildRunLifecycle.test.tsindex 5f9f4610905..bd4c4a4ec4a 100644--- a/src/store/chat/slices/agentRun/actions/lifecycle/buildRunLifecycle.test.ts+++ b/src/store/chat/slices/agentRun/actions/lifecycle/buildRunLifecycle.test.ts@@ -48,6 +48,7 @@ const makeStore = (afterCompletionCallbacks?: Array<() => void>) => {completeOperation: vi.fn(),dbMessagesMap: {},drainQueuedMessages: vi.fn<ChatStore['drainQueuedMessages']>(() => []),+ queuedMessages: {} as Record<string, unknown[]>,failOperation: vi.fn(),internal_updateTopic: vi.fn(),markTopicUnread: vi.fn(),@@ -130,6 +131,7 @@ describe('buildRunLifecycle.completeRun — transport-driven disposition', () =>{ content: 'The recording asks how to list files.', id: 'a1', role: 'assistant' },];store.drainQueuedMessages = vi.fn(() => [{ content: 'follow up', id: 'q1' } as any]);+ store.queuedMessages = { [messageMapKey(CONTEXT)]: [{ content: 'follow up', id: 'q1' }] };store.messagesMap = { [messageMapKey(CONTEXT)]: messages } as any;store.topicDataMap = {[topicMapKey({ agentId: 'a1' })]: {@@ -313,39 +315,44 @@ describe('buildRunLifecycle — sub-agent runs skip top-level effects', () => {expect(store.completeOperation).toHaveBeenCalledWith(OP);});- it('a top_level success DOES drain the queue (contrast probe)', async () => {+ it('a top_level success with an empty queue completes without requeueing (contrast probe)', async () => {const { get, store } = makeStore();- store.drainQueuedMessages = vi.fn(() => []);- await lifecycle('gateway', get, 'top_level').completeRun(+ const { requeued } = await lifecycle('gateway', get, 'top_level').completeRun(completeEvent('gateway', { status: 'completed' }),);- expect(store.drainQueuedMessages).toHaveBeenCalled();+ expect(requeued).toBe(false);+ expect(store.completeOperation).toHaveBeenCalledWith(OP);});- it('a drained queued follow-up is sent as a steer turn', async () => {+ it('keeps the queue in place until the steered send takes it', async () => {vi.useFakeTimers();try {const { get, store } = makeStore();const sendMessage = vi.fn(async () => {});(store as any).sendMessage = sendMessage;- store.drainQueuedMessages = vi.fn(() => [- {- content: 'queued',- createdAt: 1,- id: 'q1',- interruptMode: 'soft',- metadata: { scope: 'x' },- } as any,- ]);+ const queued = {+ content: 'queued',+ createdAt: 1,+ id: 'q1',+ interruptMode: 'soft',+ metadata: { scope: 'x' },+ } as any;+ store.queuedMessages = { [messageMapKey(CONTEXT)]: [queued] };+ store.drainQueuedMessages = vi.fn(() => [queued]);const { requeued } = await lifecycle('gateway', get, 'top_level').completeRun(completeEvent('gateway', { status: 'completed' }),);- await vi.runAllTimersAsync();expect(requeued).toBe(true);+ expect(store.completeOperation).toHaveBeenCalledWith(OP);+ expect(store.drainQueuedMessages).not.toHaveBeenCalled();++ await vi.runAllTimersAsync();++ expect(store.drainQueuedMessages).toHaveBeenCalledTimes(1);expect(sendMessage).toHaveBeenCalledWith(expect.objectContaining({message: 'queued',diff --git a/src/store/chat/slices/agentRun/actions/lifecycle/buildRunLifecycle.ts b/src/store/chat/slices/agentRun/actions/lifecycle/buildRunLifecycle.tsindex 2829b532259..74e9b5ad527 100644--- a/src/store/chat/slices/agentRun/actions/lifecycle/buildRunLifecycle.ts+++ b/src/store/chat/slices/agentRun/actions/lifecycle/buildRunLifecycle.ts@@ -438,16 +438,26 @@ export const buildRunLifecycle = (// Gated to TOP-LEVEL runs only: the input queue belongs to the parent// run, so a nested sub-agent completion must never drain it (it would// re-trigger the user's queued message mid-parent-run). See RunScope.- if (disposition === 'success' && adapter.runScope !== 'sub_agent') {- const remainingQueued = get().drainQueuedMessages(contextKey);- if (remainingQueued.length > 0) {- const merged = mergeQueuedMessages(remainingQueued);-- completeSuccess();- emitComplete(operationId, runtimeStatus);+ if (+ disposition === 'success' &&+ adapter.runScope !== 'sub_agent' &&+ (get().queuedMessages?.[contextKey]?.length ?? 0) > 0+ ) {+ completeSuccess();+ emitComplete(operationId, runtimeStatus);++ const execContext = { ...context };++ // Drain only when the send takes the queue: until then the tray and+ // the composer's busy state keep covering the hand-off window.+ setTimeout(() => {+ const remainingQueued = get().drainQueuedMessages(contextKey);+ if (remainingQueued.length === 0) {+ resetActiveTopicRunningStatus();+ return;+ }- const execContext = { ...context };- const mergedContent = merged.content;+ const merged = mergeQueuedMessages(remainingQueued);const mergedFiles =merged.filesPreview.length > 0? reconstructUploadFilesFromQueue(merged.filesPreview)@@ -455,28 +465,26 @@ export const buildRunLifecycle = (? (merged.files.map((id) => ({ id })) as any): undefined;- setTimeout(() => {- // Use the passed `get` (the live chat-store getter) rather than a- // direct `useChatStore` import: in prod they resolve to the same- // singleton sendMessage, and avoiding the value import keeps the chat- // store out of this module's graph — so gateway.ts can statically- // import buildRunLifecycle without re-entering the store mid-eval.- get()- .sendMessage({- context: execContext,- editorData: merged.editorData,- files: mergedFiles,- ...(merged.forceRuntime ? { forceRuntime: merged.forceRuntime } : {}),- message: mergedContent,- metadata: { ...merged.metadata, steer: true },- })- .catch((e: unknown) => {- console.error('[executeClientAgent] sendMessage for queued content failed:', e);- });- }, 100);-- return { requeued: true };- }+ // Use the passed `get` (the live chat-store getter) rather than a+ // direct `useChatStore` import: in prod they resolve to the same+ // singleton sendMessage, and avoiding the value import keeps the chat+ // store out of this module's graph — so gateway.ts can statically+ // import buildRunLifecycle without re-entering the store mid-eval.+ get()+ .sendMessage({+ context: execContext,+ editorData: merged.editorData,+ files: mergedFiles,+ ...(merged.forceRuntime ? { forceRuntime: merged.forceRuntime } : {}),+ message: merged.content,+ metadata: { ...merged.metadata, steer: true },+ })+ .catch((e: unknown) => {+ console.error('[executeClientAgent] sendMessage for queued content failed:', e);+ });+ }, 100);++ return { requeued: true };}// 3. Complete the operation based on the terminal disposition.diff --git a/src/store/chat/slices/operation/__tests__/actions.test.ts b/src/store/chat/slices/operation/__tests__/actions.test.tsindex 8e5fc92bd7b..93ba5f4d892 100644--- a/src/store/chat/slices/operation/__tests__/actions.test.ts+++ b/src/store/chat/slices/operation/__tests__/actions.test.ts@@ -221,6 +221,32 @@ describe('Operation Actions', () => {expect(childOp.parentOperationId).toBe(parentOpId!);});+ it('should carry the parent turn start into child operations', () => {+ const { result } = renderHook(() => useChatStore());++ let childOpId: string;+ let grandchildOpId: string;++ act(() => {+ const parent = result.current.startOperation({+ type: 'sendMessage',+ context: { agentId: 'session1', topicId: 'topic1' },+ metadata: { turnStartTime: 1000 },+ });+ childOpId = result.current.startOperation({+ type: 'execServerAgentRuntime',+ parentOperationId: parent.operationId,+ }).operationId;+ grandchildOpId = result.current.startOperation({+ type: 'reasoning',+ parentOperationId: childOpId,+ }).operationId;+ });++ expect(result.current.operations[childOpId!].metadata.turnStartTime).toBe(1000);+ expect(result.current.operations[grandchildOpId!].metadata.turnStartTime).toBe(1000);+ });+it('should update indexes correctly', () => {const { result } = renderHook(() => useChatStore());diff --git a/src/store/chat/slices/operation/__tests__/selectors.test.ts b/src/store/chat/slices/operation/__tests__/selectors.test.tsindex 41d9cfd4ed7..3633908f0e6 100644--- a/src/store/chat/slices/operation/__tests__/selectors.test.ts+++ b/src/store/chat/slices/operation/__tests__/selectors.test.ts@@ -9,6 +9,7 @@ import {INPUT_LOADING_OPERATION_TYPES,INTERIM_LOADING_OPERATION_TYPES,QUEUE_BLOCKING_OPERATION_TYPES,+ SEND_NOW_CANCEL_REASON,} from '../types';describe('Operation Selectors', () => {@@ -870,6 +871,169 @@ describe('Operation Selectors', () => {).toBeUndefined();});+ it('should count a steered run from the start of the turn it continues', () => {+ const { result } = renderHook(() => useChatStore());+ const context = { agentId: 'agent1', topicId: 'topic1' };++ act(() => {+ result.current.startOperation({+ type: 'execServerAgentRuntime',+ context,+ metadata: { startTime: 5000, turnStartTime: 1000 },+ });+ });++ expect(+ operationSelectors.getVisibleAgentRuntimeStartTimeByContext(context)(result.current),+ ).toBe(1000);+ });++ it('should keep counting while a steered send waits for its runtime to start', () => {+ const { result } = renderHook(() => useChatStore());+ const context = { agentId: 'agent1', topicId: 'topic1' };++ act(() => {+ result.current.startOperation({+ type: 'sendMessage',+ context,+ metadata: { startTime: 5000 },+ });+ });++ expect(+ operationSelectors.getVisibleAgentRuntimeStartTimeByContext(context)(result.current),+ ).toBeUndefined();++ act(() => {+ result.current.startOperation({+ type: 'sendMessage',+ context,+ metadata: { startTime: 6000, turnStartTime: 1000 },+ });+ });++ expect(+ operationSelectors.getVisibleAgentRuntimeStartTimeByContext(context)(result.current),+ ).toBe(1000);+ });++ it('should resolve the turn start of the latest runtime operation, finished or not', () => {+ const { result } = renderHook(() => useChatStore());+ const context = { agentId: 'agent1', topicId: 'topic1' };++ act(() => {+ const { operationId: first } = result.current.startOperation({+ type: 'execAgentRuntime',+ context,+ metadata: { startTime: 1000 },+ });+ result.current.completeOperation(first);+ const { operationId: second } = result.current.startOperation({+ type: 'execAgentRuntime',+ context,+ metadata: { startTime: 3000, turnStartTime: 1000 },+ });+ result.current.cancelOperation(second, 'send_now');+ result.current.startOperation({+ type: 'sendMessage',+ context,+ metadata: { startTime: 4000 },+ });+ });++ expect(operationSelectors.getLatestAgentRuntimeTurnStartTime(context)(result.current)).toBe(+ 1000,+ );+ expect(+ operationSelectors.getLatestAgentRuntimeTurnStartTime({ agentId: 'agent2' })(+ result.current,+ ),+ ).toBeUndefined();+ });++ it('should keep visible loading while a completed run hands its queue to the next turn', () => {+ const { result } = renderHook(() => useChatStore());+ const context = { agentId: 'agent1', topicId: 'topic1' };++ act(() => {+ const { operationId } = result.current.startOperation({+ type: 'execServerAgentRuntime',+ context,+ metadata: { startTime: 1000 },+ });+ result.current.completeOperation(operationId);+ });++ expect(operationSelectors.isSteerHandoffPending(context)(result.current)).toBe(false);+ expect(operationSelectors.isInputVisiblyLoadingByContext(context)(result.current)).toBe(+ false,+ );++ act(() => {+ result.current.enqueueMessage(messageMapKey(context), {+ content: 'follow up',+ createdAt: 2000,+ files: [],+ id: 'q1',+ interruptMode: 'soft',+ });+ });++ expect(operationSelectors.isSteerHandoffPending(context)(result.current)).toBe(true);+ expect(operationSelectors.isQueueDrainPending(context)(result.current)).toBe(true);+ expect(operationSelectors.isInputVisiblyLoadingByContext(context)(result.current)).toBe(true);+ });++ it('should treat a run cancelled by Send now as handing off to the queued message', () => {+ const { result } = renderHook(() => useChatStore());+ const context = { agentId: 'agent1', topicId: 'topic1' };++ act(() => {+ const { operationId } = result.current.startOperation({+ type: 'execServerAgentRuntime',+ context,+ metadata: { startTime: 1000 },+ });+ result.current.enqueueMessage(messageMapKey(context), {+ content: 'follow up',+ createdAt: 2000,+ id: 'q1',+ interruptMode: 'soft',+ });+ void result.current.cancelOperation(operationId, SEND_NOW_CANCEL_REASON);+ });++ expect(operationSelectors.isSteerHandoffPending(context)(result.current)).toBe(true);+ expect(operationSelectors.isQueueDrainPending(context)(result.current)).toBe(false);+ expect(operationSelectors.isInputVisiblyLoadingByContext(context)(result.current)).toBe(true);+ });++ it('should not treat a queue left behind a cancelled run as a pending handoff', () => {+ const { result } = renderHook(() => useChatStore());+ const context = { agentId: 'agent1', topicId: 'topic1' };++ act(() => {+ const { operationId } = result.current.startOperation({+ type: 'execAgentRuntime',+ context,+ metadata: { startTime: 1000 },+ });+ result.current.enqueueMessage(messageMapKey(context), {+ content: 'follow up',+ createdAt: 2000,+ files: [],+ id: 'q1',+ interruptMode: 'soft',+ });+ result.current.cancelOperation(operationId, 'user_cancelled');+ });++ expect(operationSelectors.isSteerHandoffPending(context)(result.current)).toBe(false);+ expect(operationSelectors.isInputVisiblyLoadingByContext(context)(result.current)).toBe(+ false,+ );+ });+it('should keep visible loading when a queued message waits behind a visibly-done op', () => {const { result } = renderHook(() => useChatStore());const context = { agentId: 'agent1', topicId: 'topic1' };diff --git a/src/store/chat/slices/operation/actions.ts b/src/store/chat/slices/operation/actions.tsindex 8bef925e9e2..c2ce61ab453 100644--- a/src/store/chat/slices/operation/actions.ts+++ b/src/store/chat/slices/operation/actions.ts@@ -128,14 +128,13 @@ export class OperationActionsImpl {// If parent operation exists and context is not fully provided, inherit from parentlet context: OperationContext = partialContext || {};+ const parentOp = parentOperationId ? this.#get().operations[parentOperationId] : undefined;+ const inheritedTurnStartTime = parentOp?.metadata.turnStartTime;- if (parentOperationId) {- const parentOp = this.#get().operations[parentOperationId];- if (parentOp) {- // Inherit parent's context, allow partial override- context = { ...parentOp.context, ...partialContext };- log('[startOperation] inherit context from parent %s: %o', parentOperationId, context);- }+ if (parentOp) {+ // Inherit parent's context, allow partial override+ context = { ...parentOp.context, ...partialContext };+ log('[startOperation] inherit context from parent %s: %o', parentOperationId, context);}log('[startOperation] create operation %s (type=%s, context=%o)', operationId, type, context);@@ -151,6 +150,7 @@ export class OperationActionsImpl {abortController,metadata: {startTime: now,+ ...(inheritedTurnStartTime === undefined ? {} : { turnStartTime: inheritedTurnStartTime }),...metadata,},parentOperationId,diff --git a/src/store/chat/slices/operation/selectors.ts b/src/store/chat/slices/operation/selectors.tsindex 51830ed2192..f4592b7f5b3 100644--- a/src/store/chat/slices/operation/selectors.ts+++ b/src/store/chat/slices/operation/selectors.ts@@ -8,6 +8,7 @@ import {INPUT_LOADING_OPERATION_TYPES,isQueueBlockingOperation,QUEUE_BLOCKING_OPERATION_TYPES,+ SEND_NOW_CANCEL_REASON,} from './types';// === Basic Queries ===@@ -327,6 +328,26 @@ const getRunningQueueBlockingOperationIds =.map((op) => op.id);};+const getOperationTurnStartTime = (op: Operation) =>+ op.metadata.turnStartTime ?? op.metadata.startTime;++const isTurnTimedOperation = (op: Operation) =>+ AI_RUNTIME_OPERATION_TYPES.includes(op.type) || op.metadata.turnStartTime !== undefined;++const getLatestAgentRuntimeTurnStartTime =+ (context: MessageMapKeyInput) =>+ (s: ChatStoreState): number | undefined => {+ if (!context.agentId) return undefined;++ let latest: Operation | undefined;+ for (const op of getOperationsByContext(context)(s)) {+ if (!AI_RUNTIME_OPERATION_TYPES.includes(op.type)) continue;+ if (!latest || op.metadata.startTime > latest.metadata.startTime) latest = op;+ }++ return latest ? getOperationTurnStartTime(latest) : undefined;+ };+/*** Get the earliest start time for a running agent runtime operation in a* specific context. This anchors visible elapsed-time UI to the top-level@@ -349,10 +370,8 @@ const getAgentRuntimeStartTimeByContext =continue;}- startTime =- startTime === undefined- ? op.metadata.startTime- : Math.min(startTime, op.metadata.startTime);+ const turnStartTime = getOperationTurnStartTime(op);+ startTime = startTime === undefined ? turnStartTime : Math.min(startTime, turnStartTime);}return startTime;@@ -370,14 +389,12 @@ const getVisibleAgentRuntimeStartTimeByContext =let startTime: number | undefined;for (const op of operations) {- if (!AI_RUNTIME_OPERATION_TYPES.includes(op.type) || !isVisiblyRunningOperation(op)) {+ if (!isTurnTimedOperation(op) || !isVisiblyRunningOperation(op)) {continue;}- startTime =- startTime === undefined- ? op.metadata.startTime- : Math.min(startTime, op.metadata.startTime);+ const turnStartTime = getOperationTurnStartTime(op);+ startTime = startTime === undefined ? turnStartTime : Math.min(startTime, turnStartTime);}return startTime;@@ -430,7 +447,9 @@ const isInputVisiblyLoadingByContext =const hasRunning = operations.some((op) => INPUT_LOADING_OPERATION_TYPES.includes(op.type) && isRunningOperation(op),);- return hasRunning && getQueuedMessages(context)(s).length > 0;+ if (hasRunning) return getQueuedMessages(context)(s).length > 0;++ return isSteerHandoffPending(context)(s);};// === Backward Compatibility ===@@ -911,6 +930,34 @@ const getQueuedMessages = (context: MessageMapKeyInput) => (s: ChatStoreState) =return s.queuedMessages[messageMapKey(context)] ?? [];};+const getIdleQueueHost = (context: MessageMapKeyInput) => (s: ChatStoreState) => {+ if (getQueuedMessages(context)(s).length === 0) return;++ let latest: Operation | undefined;+ for (const op of getOperationsByContext(context)(s)) {+ if (!INPUT_LOADING_OPERATION_TYPES.includes(op.type)) continue;+ if (isRunningOperation(op)) return;+ if (!AI_RUNTIME_OPERATION_TYPES.includes(op.type)) continue;+ if (!latest || op.metadata.startTime > latest.metadata.startTime) latest = op;+ }++ return latest;+};++// A successful top-level run always drains its queue into a steered send, so a+// queue sitting behind a completed run is the hand-off window, not a stale queue.+const isQueueDrainPending = (context: MessageMapKeyInput) => (s: ChatStoreState) =>+ getIdleQueueHost(context)(s)?.status === 'completed';++// Send now keeps its item queued until the interrupt is confirmed; that wait is+// part of the hand-off too, but its own send must not be re-queued.+const isSteerHandoffPending = (context: MessageMapKeyInput) => (s: ChatStoreState) => {+ const host = getIdleQueueHost(context)(s);+ if (host?.status === 'completed') return true;++ return host?.status === 'cancelled' && host.metadata.cancelReason === SEND_NOW_CANCEL_REASON;+};+/*** Operation Selectors*/@@ -928,6 +975,7 @@ export const operationSelectors = {getOperationById,getOperationContextFromMessage,getAgentRuntimeStartTimeByContext,+ getLatestAgentRuntimeTurnStartTime,getOperationsByContext,getOperationsByMessage,getOperationsByType,@@ -968,7 +1016,9 @@ export const operationSelectors = {isMessageProcessing,isMessageRegenerating,isRegenerating,+ isQueueDrainPending,isSendingMessage,+ isSteerHandoffPending,isTopicUnreadCompleted,isTopicVisiblyRunning,unreadCompletedCountForTopics,diff --git a/src/store/chat/slices/operation/types.ts b/src/store/chat/slices/operation/types.tsindex 4587c8add9e..01229b7e039 100644--- a/src/store/chat/slices/operation/types.ts+++ b/src/store/chat/slices/operation/types.ts@@ -171,6 +171,12 @@ export interface OperationMetadata {*/streamRetry?: StreamRetryMetadata;+ /**+ * Start of the turn a steered run continues. Elapsed timers count from here so+ * a queued follow-up reads as one continuous turn; inherited by child operations.+ */+ turnStartTime?: number;+/*** The model text stream has finished and there is no visible follow-up phase* to wait for, but the runtime operation still needs its terminal lifecycle@@ -432,6 +438,8 @@ export interface OperationFilter {* - execHeterogeneousAgent: Heterogeneous agent execution (Claude Code CLI, etc.)* - execServerAgentRuntime: Server-side agent execution (Group Chat)*/+export const SEND_NOW_CANCEL_REASON = 'send_now';+export const AI_RUNTIME_OPERATION_TYPES: OperationType[] = ['execAgentRuntime','execHeterogeneousAgent',