@agent-native/core 0.91.2 → 0.92.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/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +17 -0
- package/corpus/core/docs/content/faq.mdx +17 -0
- package/corpus/core/docs/content/notifications.mdx +12 -6
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/agent/production-agent.ts +140 -46
- package/corpus/core/src/agent/tool-search.ts +71 -4
- package/corpus/core/src/cli/index.ts +20 -0
- package/corpus/core/src/cli/upgrade.ts +798 -0
- package/corpus/core/src/client/AssistantChat.tsx +1 -1
- package/corpus/core/src/client/HighlightedCodeBlock.tsx +20 -3
- package/corpus/core/src/client/agent-chat-adapter.ts +31 -6
- package/corpus/core/src/client/chat/message-components.tsx +85 -8
- package/corpus/core/src/client/chat/tool-call-display.tsx +355 -144
- package/corpus/core/src/client/code-agent-chat-adapter.ts +2 -9
- package/corpus/core/src/client/session-replay.ts +3 -97
- package/corpus/core/src/client/settings/SettingsPanel.tsx +533 -389
- package/corpus/core/src/client/settings/SettingsSection.tsx +154 -17
- package/corpus/core/src/client/sse-event-processor.ts +29 -2
- package/corpus/core/src/extensions/actions.ts +113 -5
- package/corpus/core/src/notifications/channels.ts +88 -25
- package/corpus/core/src/notifications/registry.ts +17 -3
- package/corpus/core/src/notifications/types.ts +4 -1
- package/corpus/core/src/server/agent-chat-plugin.ts +7 -3
- package/corpus/core/src/server/request-context.ts +7 -0
- package/corpus/core/src/styles/agent-conversation.css +1 -1
- package/corpus/core/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/core/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/core/src/templates/default/AGENTS.md +10 -3
- package/corpus/core/src/templates/default/package.json +2 -1
- package/corpus/core/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/core/src/templates/headless/AGENTS.md +9 -3
- package/corpus/core/src/templates/headless/package.json +1 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/core/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/core/src/templates/workspace-root/AGENTS.md +10 -4
- package/corpus/core/src/templates/workspace-root/package.json +1 -0
- package/corpus/templates/analytics/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/analytics/.agents/skills/session-replay/SKILL.md +5 -6
- package/corpus/templates/analytics/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/analytics/AGENTS.md +7 -5
- package/corpus/templates/analytics/actions/save-monitor.ts +14 -0
- package/corpus/templates/analytics/app/components/dashboard/DataTable.tsx +41 -6
- package/corpus/templates/analytics/app/components/dashboard/SqlChart.tsx +122 -11
- package/corpus/templates/analytics/app/pages/monitoring/MonitoringPage.tsx +8 -2
- package/corpus/templates/analytics/app/pages/monitoring/uptime/MonitorFormPage.tsx +151 -32
- package/corpus/templates/analytics/app/pages/monitoring/uptime/i18n.ts +17 -2
- package/corpus/templates/analytics/app/pages/monitoring/uptime/types.ts +4 -0
- package/corpus/templates/analytics/app/pages/sessions/SessionDetailPage.tsx +54 -190
- package/corpus/templates/analytics/changelog/2026-07-08-dashboard-tables-keep-their-size-while-loading.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-monitoring-uptime-and-errors-tabs-now-clearly-show-which-view-is-active.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-session-replay-uses-stock-rrweb-sizing-again-so-recorded.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-sidebar-dashboard-menus-now-open-above-the-dashboard-canvas.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-uptime-alerting-clarifies-in-app-inbox-vs-email-and-lets-you-paste-slack-or-webhook-urls-per-monitor.md +6 -0
- package/corpus/templates/analytics/docs/uptime-monitoring.md +13 -11
- package/corpus/templates/analytics/server/db/schema-monitoring.ts +4 -0
- package/corpus/templates/analytics/server/lib/uptime-monitors.ts +60 -12
- package/corpus/templates/analytics/server/plugins/db.ts +10 -0
- package/corpus/templates/assets/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/assets/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/brain/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/brain/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/calendar/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/calendar/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/chat/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/clips/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/clips/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/clips/changelog/2026-07-08-desktop-meeting-notes-stay-active-from-tray-and-shortcut-controls.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-08-desktop-meeting-popovers-can-start-notes-and-join-the-meetin.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-08-meeting-notes-keep-their-recording-state-when-the-desktop.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-08-meeting-reminder-dropdowns-now-expand-fully-instead-of-being.md +6 -0
- package/corpus/templates/clips/desktop/src/app.tsx +123 -3
- package/corpus/templates/clips/desktop/src/hooks/useMeetingTranscription.ts +15 -1
- package/corpus/templates/clips/desktop/src/overlays/meeting-notification.tsx +23 -0
- package/corpus/templates/clips/desktop/src/styles.css +23 -1
- package/corpus/templates/clips/desktop/src-tauri/src/adhoc_meetings_watcher.rs +1 -3
- package/corpus/templates/clips/desktop/src-tauri/src/clips/mod.rs +40 -6
- package/corpus/templates/clips/desktop/src-tauri/src/lib.rs +4 -2
- package/corpus/templates/clips/desktop/src-tauri/src/meetings_watcher.rs +3 -5
- package/corpus/templates/clips/desktop/src-tauri/src/native_screen.rs +23 -19
- package/corpus/templates/clips/desktop/src-tauri/src/shortcuts.rs +3 -3
- package/corpus/templates/clips/desktop/src-tauri/src/silence_detector.rs +0 -1
- package/corpus/templates/clips/desktop/src-tauri/src/state.rs +5 -0
- package/corpus/templates/clips/desktop/src-tauri/src/tray.rs +18 -6
- package/corpus/templates/content/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/content/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/content/actions/_batch-utils.ts +8 -0
- package/corpus/templates/content/actions/_builder-cms-read-client.ts +7 -5
- package/corpus/templates/content/actions/_database-source-utils.ts +776 -319
- package/corpus/templates/content/actions/_database-utils.ts +6 -1
- package/corpus/templates/content/actions/_property-utils.ts +168 -0
- package/corpus/templates/content/actions/add-content-database-source-field-property.ts +19 -12
- package/corpus/templates/content/actions/bind-content-database-source-field.ts +19 -12
- package/corpus/templates/content/actions/delete-document.ts +9 -13
- package/corpus/templates/content/actions/refresh-content-database-source.ts +5 -5
- package/corpus/templates/content/app/components/editor/body-hydration.ts +35 -11
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +47 -5
- package/corpus/templates/content/app/hooks/use-documents.ts +8 -2
- package/corpus/templates/content/changelog/2026-07-08-builder-source-sync-now-completes-reliably-on-hosted-databases.md +6 -0
- package/corpus/templates/content/changelog/2026-07-08-fixed-builder-database-sync-so-large-sources-continue-past-t.md +6 -0
- package/corpus/templates/content/server/plugins/db.ts +19 -0
- package/corpus/templates/design/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/design/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/dispatch/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/dispatch/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/forms/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/forms/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/macros/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/mail/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/mail/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/plan/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/plan/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/slides/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/slides/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/videos/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/voice/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/dist/agent/production-agent.d.ts +5 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +112 -42
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/tool-search.d.ts +2 -0
- package/dist/agent/tool-search.d.ts.map +1 -1
- package/dist/agent/tool-search.js +60 -4
- package/dist/agent/tool-search.js.map +1 -1
- package/dist/cli/index.js +19 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/upgrade.d.ts +100 -0
- package/dist/cli/upgrade.d.ts.map +1 -0
- package/dist/cli/upgrade.js +678 -0
- package/dist/cli/upgrade.js.map +1 -0
- package/dist/client/AssistantChat.js +1 -1
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/HighlightedCodeBlock.d.ts +2 -0
- package/dist/client/HighlightedCodeBlock.d.ts.map +1 -1
- package/dist/client/HighlightedCodeBlock.js +10 -1
- package/dist/client/HighlightedCodeBlock.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +32 -4
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/chat/message-components.d.ts.map +1 -1
- package/dist/client/chat/message-components.js +61 -8
- package/dist/client/chat/message-components.js.map +1 -1
- package/dist/client/chat/tool-call-display.d.ts +12 -0
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +136 -42
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/client/code-agent-chat-adapter.js +2 -9
- package/dist/client/code-agent-chat-adapter.js.map +1 -1
- package/dist/client/session-replay.d.ts +0 -8
- package/dist/client/session-replay.d.ts.map +1 -1
- package/dist/client/session-replay.js +3 -80
- package/dist/client/session-replay.js.map +1 -1
- package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
- package/dist/client/settings/SettingsPanel.js +52 -19
- package/dist/client/settings/SettingsPanel.js.map +1 -1
- package/dist/client/settings/SettingsSection.d.ts +19 -4
- package/dist/client/settings/SettingsSection.d.ts.map +1 -1
- package/dist/client/settings/SettingsSection.js +33 -4
- package/dist/client/settings/SettingsSection.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts +9 -0
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +20 -2
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/extensions/actions.d.ts.map +1 -1
- package/dist/extensions/actions.js +85 -5
- package/dist/extensions/actions.js.map +1 -1
- package/dist/notifications/channels.d.ts +8 -3
- package/dist/notifications/channels.d.ts.map +1 -1
- package/dist/notifications/channels.js +61 -22
- package/dist/notifications/channels.js.map +1 -1
- package/dist/notifications/registry.d.ts.map +1 -1
- package/dist/notifications/registry.js +14 -3
- package/dist/notifications/registry.js.map +1 -1
- package/dist/notifications/routes.d.ts +1 -1
- package/dist/notifications/types.d.ts +4 -1
- package/dist/notifications/types.d.ts.map +1 -1
- package/dist/notifications/types.js.map +1 -1
- package/dist/observability/routes.d.ts +1 -1
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/server/agent-chat-plugin.d.ts +5 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +2 -2
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/request-context.d.ts +7 -0
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/request-context.js.map +1 -1
- package/dist/styles/agent-conversation.css +1 -1
- package/dist/templates/default/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/dist/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/dist/templates/default/AGENTS.md +10 -3
- package/dist/templates/default/package.json +2 -1
- package/dist/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/dist/templates/headless/AGENTS.md +9 -3
- package/dist/templates/headless/package.json +1 -0
- package/dist/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/dist/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/dist/templates/workspace-root/AGENTS.md +10 -4
- package/dist/templates/workspace-root/package.json +1 -0
- package/docs/content/faq.mdx +17 -0
- package/docs/content/notifications.mdx +12 -6
- package/package.json +2 -2
- package/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/src/templates/default/AGENTS.md +10 -3
- package/src/templates/default/package.json +2 -1
- package/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/src/templates/headless/AGENTS.md +9 -3
- package/src/templates/headless/package.json +1 -0
- package/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/src/templates/workspace-root/AGENTS.md +10 -4
- package/src/templates/workspace-root/package.json +1 -0
- package/corpus/templates/analytics/changelog/2026-07-08-session-replay-clamps-ultra-wide-viewports-while-keeping-the.md +0 -6
|
@@ -355,7 +355,7 @@ function isAssistantUiDuplicateMessageIdError(error: unknown): boolean {
|
|
|
355
355
|
|
|
356
356
|
function cloneContentParts(content: ContentPart[]): ContentPart[] {
|
|
357
357
|
return content.map((part) =>
|
|
358
|
-
part.type === "text"
|
|
358
|
+
part.type === "text" || part.type === "reasoning"
|
|
359
359
|
? { ...part }
|
|
360
360
|
: {
|
|
361
361
|
...part,
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* - A content hash gate means identical re-renders never re-invoke Shiki.
|
|
9
9
|
* - A final highlight is triggered immediately when streaming ends (caller
|
|
10
10
|
* passes streaming=false).
|
|
11
|
+
* - Non-streaming first paint waits for Shiki (invisible placeholder reserves
|
|
12
|
+
* space) so the UI never snaps from plain text to highlighted HTML.
|
|
11
13
|
*
|
|
12
14
|
* Usage:
|
|
13
15
|
* <HighlightedCodeBlock code={code} lang="typescript" containerClass="agent-markdown-shiki" />
|
|
@@ -69,6 +71,7 @@ export function HighlightedCodeBlock({
|
|
|
69
71
|
loadHighlighter,
|
|
70
72
|
}: HighlightedCodeBlockProps): React.ReactElement {
|
|
71
73
|
const [html, setHtml] = useState<string | null>(null);
|
|
74
|
+
const [failed, setFailed] = useState(false);
|
|
72
75
|
// Track the content hash for which html was last rendered so identical
|
|
73
76
|
// re-renders never re-invoke Shiki.
|
|
74
77
|
const renderedHashRef = useRef<number | null>(null);
|
|
@@ -111,12 +114,14 @@ export function HighlightedCodeBlock({
|
|
|
111
114
|
.then((out) => {
|
|
112
115
|
if (!cancelledRef.current) {
|
|
113
116
|
renderedHashRef.current = contentHash;
|
|
117
|
+
setFailed(false);
|
|
114
118
|
setHtml(out as string);
|
|
115
119
|
}
|
|
116
120
|
})
|
|
117
121
|
.catch(() => {
|
|
118
122
|
if (!cancelledRef.current) {
|
|
119
123
|
renderedHashRef.current = contentHash;
|
|
124
|
+
setFailed(true);
|
|
120
125
|
setHtml(null);
|
|
121
126
|
}
|
|
122
127
|
});
|
|
@@ -148,9 +153,21 @@ export function HighlightedCodeBlock({
|
|
|
148
153
|
/>
|
|
149
154
|
);
|
|
150
155
|
}
|
|
156
|
+
|
|
157
|
+
// Streaming: show plain growing text (previous html already kept above when
|
|
158
|
+
// available). Non-streaming first paint: reserve space invisibly so we never
|
|
159
|
+
// flash unhighlighted → highlighted.
|
|
160
|
+
const showPlain = streaming || failed;
|
|
151
161
|
return (
|
|
152
|
-
<
|
|
153
|
-
<
|
|
154
|
-
|
|
162
|
+
<div className={containerClass} aria-busy={!showPlain && !failed}>
|
|
163
|
+
<pre>
|
|
164
|
+
<code
|
|
165
|
+
className={lang ? `language-${lang}` : undefined}
|
|
166
|
+
style={showPlain ? undefined : { visibility: "hidden" }}
|
|
167
|
+
>
|
|
168
|
+
{code}
|
|
169
|
+
</code>
|
|
170
|
+
</pre>
|
|
171
|
+
</div>
|
|
155
172
|
);
|
|
156
173
|
}
|
|
@@ -196,6 +196,7 @@ function contentToContinuationHistory(content: ContentPart[]): string {
|
|
|
196
196
|
if (part.text.trim()) chunks.push(part.text.trim());
|
|
197
197
|
continue;
|
|
198
198
|
}
|
|
199
|
+
if (part.type === "reasoning") continue;
|
|
199
200
|
if (part.activity === true) continue;
|
|
200
201
|
const toolSummary = [
|
|
201
202
|
`Tool: ${part.toolName}`,
|
|
@@ -577,6 +578,12 @@ function contentToStructuredMessages(
|
|
|
577
578
|
continue;
|
|
578
579
|
}
|
|
579
580
|
|
|
581
|
+
// Reasoning/thinking is UI-only — do not send chain-of-thought back into
|
|
582
|
+
// model history on continuation.
|
|
583
|
+
if (part.type === "reasoning") {
|
|
584
|
+
continue;
|
|
585
|
+
}
|
|
586
|
+
|
|
580
587
|
if (isToolCallContentPart(part)) {
|
|
581
588
|
if (part.activity === true) continue;
|
|
582
589
|
const toolCallId = nextToolCallId();
|
|
@@ -736,11 +743,11 @@ function combineContinuationHistory(fragments: string[]): string {
|
|
|
736
743
|
}
|
|
737
744
|
|
|
738
745
|
function hasContinuationProgress(content: ContentPart[]): boolean {
|
|
739
|
-
return content.some((part) =>
|
|
740
|
-
part.type === "text"
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
);
|
|
746
|
+
return content.some((part) => {
|
|
747
|
+
if (part.type === "text") return part.text.trim().length > 0;
|
|
748
|
+
if (part.type === "reasoning") return false;
|
|
749
|
+
return part.result !== undefined;
|
|
750
|
+
});
|
|
744
751
|
}
|
|
745
752
|
|
|
746
753
|
const COMPLETED_TOOL_TIMEOUT_NAME_RE =
|
|
@@ -880,7 +887,9 @@ function lastUnresolvedToolActivity(
|
|
|
880
887
|
|
|
881
888
|
function snapshotContent(content: ContentPart[]): ContentPart[] {
|
|
882
889
|
return content.map((part) =>
|
|
883
|
-
part.type === "text"
|
|
890
|
+
part.type === "text" || part.type === "reasoning"
|
|
891
|
+
? { ...part }
|
|
892
|
+
: { ...part, args: { ...part.args } },
|
|
884
893
|
);
|
|
885
894
|
}
|
|
886
895
|
|
|
@@ -952,6 +961,22 @@ function contentAfterContinuationPrefix(
|
|
|
952
961
|
return content.slice(contentIndex);
|
|
953
962
|
}
|
|
954
963
|
|
|
964
|
+
if (prefixPart.type === "reasoning" && currentPart.type === "reasoning") {
|
|
965
|
+
if (currentPart.text === prefixPart.text) {
|
|
966
|
+
contentIndex += 1;
|
|
967
|
+
continue;
|
|
968
|
+
}
|
|
969
|
+
if (currentPart.text.startsWith(prefixPart.text)) {
|
|
970
|
+
const appendedText = currentPart.text.slice(prefixPart.text.length);
|
|
971
|
+
if (appendedText) {
|
|
972
|
+
delta.push({ type: "reasoning", text: appendedText });
|
|
973
|
+
}
|
|
974
|
+
contentIndex += 1;
|
|
975
|
+
continue;
|
|
976
|
+
}
|
|
977
|
+
return content.slice(contentIndex);
|
|
978
|
+
}
|
|
979
|
+
|
|
955
980
|
if (
|
|
956
981
|
prefixPart.type === "tool-call" &&
|
|
957
982
|
currentPart.type === "tool-call" &&
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
ActionBarPrimitive,
|
|
11
11
|
BranchPickerPrimitive,
|
|
12
12
|
ComposerPrimitive,
|
|
13
|
+
useMessagePartReasoning,
|
|
13
14
|
} from "@assistant-ui/react";
|
|
14
15
|
import type { Attachment } from "@assistant-ui/react";
|
|
15
16
|
import {
|
|
@@ -66,6 +67,8 @@ import {
|
|
|
66
67
|
ToolCallFallback,
|
|
67
68
|
FilesChangedSummary,
|
|
68
69
|
ChatRunningContext,
|
|
70
|
+
ReasoningCell,
|
|
71
|
+
WorkedForSummary,
|
|
69
72
|
} from "./tool-call-display.js";
|
|
70
73
|
|
|
71
74
|
// ─── Pending selection context key ───────────────────────────────────────────
|
|
@@ -793,7 +796,7 @@ function assistantMessageHasRenderableContent(message: {
|
|
|
793
796
|
return content.some((part) => {
|
|
794
797
|
if (!part || typeof part !== "object") return false;
|
|
795
798
|
const type = (part as { type?: unknown }).type;
|
|
796
|
-
if (type === "text") {
|
|
799
|
+
if (type === "text" || type === "reasoning") {
|
|
797
800
|
const text = (part as { text?: unknown }).text;
|
|
798
801
|
return typeof text === "string" && text.trim().length > 0;
|
|
799
802
|
}
|
|
@@ -837,6 +840,21 @@ export function shouldShowAssistantMessageFooter({
|
|
|
837
840
|
return !chatRunning && statusIsTerminal;
|
|
838
841
|
}
|
|
839
842
|
|
|
843
|
+
function ReasoningMessagePart() {
|
|
844
|
+
const part = useMessagePartReasoning();
|
|
845
|
+
const isStreaming = part.status?.type === "running";
|
|
846
|
+
return <ReasoningCell text={part.text} isStreaming={isStreaming} />;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
function groupAssistantWorkParts(part: {
|
|
850
|
+
type?: string;
|
|
851
|
+
}): ["group-work"] | null {
|
|
852
|
+
if (part.type === "reasoning" || part.type === "tool-call") {
|
|
853
|
+
return ["group-work"];
|
|
854
|
+
}
|
|
855
|
+
return null;
|
|
856
|
+
}
|
|
857
|
+
|
|
840
858
|
export function AssistantMessage() {
|
|
841
859
|
const [restoreState, setRestoreState] = useState<
|
|
842
860
|
"idle" | "confirming" | "restoring"
|
|
@@ -860,6 +878,39 @@ export function AssistantMessage() {
|
|
|
860
878
|
});
|
|
861
879
|
const cpCtx = React.useContext(CheckpointContext);
|
|
862
880
|
|
|
881
|
+
// Capture live run duration when this message finishes streaming.
|
|
882
|
+
const runStartedAtRef = useRef<number | null>(null);
|
|
883
|
+
const [capturedDurationMs, setCapturedDurationMs] = useState<number | null>(
|
|
884
|
+
null,
|
|
885
|
+
);
|
|
886
|
+
useEffect(() => {
|
|
887
|
+
if (chatRunning && isLast) {
|
|
888
|
+
if (runStartedAtRef.current == null) {
|
|
889
|
+
runStartedAtRef.current = Date.now();
|
|
890
|
+
}
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
if (
|
|
894
|
+
!chatRunning &&
|
|
895
|
+
isLast &&
|
|
896
|
+
runStartedAtRef.current != null &&
|
|
897
|
+
capturedDurationMs == null
|
|
898
|
+
) {
|
|
899
|
+
setCapturedDurationMs(Date.now() - runStartedAtRef.current);
|
|
900
|
+
runStartedAtRef.current = null;
|
|
901
|
+
}
|
|
902
|
+
}, [chatRunning, isLast, capturedDurationMs]);
|
|
903
|
+
|
|
904
|
+
// Animate collapse only when this message just finished running in-session.
|
|
905
|
+
const wasRunningRef = useRef(false);
|
|
906
|
+
const [animateCollapse, setAnimateCollapse] = useState(false);
|
|
907
|
+
useEffect(() => {
|
|
908
|
+
if (wasRunningRef.current && !chatRunning && isComplete && isLast) {
|
|
909
|
+
setAnimateCollapse(true);
|
|
910
|
+
}
|
|
911
|
+
wasRunningRef.current = chatRunning && isLast;
|
|
912
|
+
}, [chatRunning, isComplete, isLast]);
|
|
913
|
+
|
|
863
914
|
const handleRestore = useCallback(async () => {
|
|
864
915
|
if (restoreState === "idle") {
|
|
865
916
|
setRestoreState("confirming");
|
|
@@ -926,6 +977,13 @@ export function AssistantMessage() {
|
|
|
926
977
|
(p.structuredMeta.toolKind === "edit" ||
|
|
927
978
|
p.structuredMeta.toolKind === "write"),
|
|
928
979
|
);
|
|
980
|
+
const hasCollapsibleWork =
|
|
981
|
+
Array.isArray(msgContent) &&
|
|
982
|
+
msgContent.some(
|
|
983
|
+
(p) =>
|
|
984
|
+
p.type === "reasoning" ||
|
|
985
|
+
(p.type === "tool-call" && p.activity !== true),
|
|
986
|
+
);
|
|
929
987
|
|
|
930
988
|
if (!hasRenderableContent) return null;
|
|
931
989
|
|
|
@@ -935,14 +993,33 @@ export function AssistantMessage() {
|
|
|
935
993
|
style={{ contentVisibility: isComplete ? "auto" : "visible" }}
|
|
936
994
|
>
|
|
937
995
|
<div className="w-full max-w-[95%] text-sm leading-relaxed text-foreground">
|
|
938
|
-
<MessagePrimitive.
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
996
|
+
<MessagePrimitive.GroupedParts groupBy={groupAssistantWorkParts}>
|
|
997
|
+
{({ part, children }) => {
|
|
998
|
+
switch (part.type) {
|
|
999
|
+
case "group-work": {
|
|
1000
|
+
const showSummary =
|
|
1001
|
+
isComplete && !chatRunning && hasCollapsibleWork;
|
|
1002
|
+
if (!showSummary) return <>{children}</>;
|
|
1003
|
+
return (
|
|
1004
|
+
<WorkedForSummary
|
|
1005
|
+
durationMs={capturedDurationMs}
|
|
1006
|
+
autoCollapse={animateCollapse}
|
|
1007
|
+
>
|
|
1008
|
+
{children}
|
|
1009
|
+
</WorkedForSummary>
|
|
1010
|
+
);
|
|
1011
|
+
}
|
|
1012
|
+
case "text":
|
|
1013
|
+
return <MarkdownText />;
|
|
1014
|
+
case "reasoning":
|
|
1015
|
+
return <ReasoningMessagePart />;
|
|
1016
|
+
case "tool-call":
|
|
1017
|
+
return part.toolUI ?? <ToolCallFallback {...part} />;
|
|
1018
|
+
default:
|
|
1019
|
+
return null;
|
|
1020
|
+
}
|
|
944
1021
|
}}
|
|
945
|
-
|
|
1022
|
+
</MessagePrimitive.GroupedParts>
|
|
946
1023
|
{isComplete && hasCodeAgentTools && msgContent && (
|
|
947
1024
|
<FilesChangedSummary parts={msgContent} />
|
|
948
1025
|
)}
|