@agent-native/core 0.54.0 → 0.55.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/README.md +16 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +4 -0
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/cli/connect.d.ts +3 -1
- package/dist/cli/connect.d.ts.map +1 -1
- package/dist/cli/connect.js +7 -1
- package/dist/cli/connect.js.map +1 -1
- package/dist/cli/gateway-helpers.d.ts +15 -0
- package/dist/cli/gateway-helpers.d.ts.map +1 -0
- package/dist/cli/gateway-helpers.js +51 -0
- package/dist/cli/gateway-helpers.js.map +1 -0
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/plan-local.d.ts +40 -0
- package/dist/cli/plan-local.d.ts.map +1 -1
- package/dist/cli/plan-local.js +495 -9
- package/dist/cli/plan-local.js.map +1 -1
- package/dist/cli/skills.d.ts +17 -2
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +135 -36
- package/dist/cli/skills.js.map +1 -1
- package/dist/cli/workspace-dev.d.ts.map +1 -1
- package/dist/cli/workspace-dev.js +9 -27
- package/dist/cli/workspace-dev.js.map +1 -1
- package/dist/client/AgentChatHome.d.ts +23 -0
- package/dist/client/AgentChatHome.d.ts.map +1 -0
- package/dist/client/AgentChatHome.js +13 -0
- package/dist/client/AgentChatHome.js.map +1 -0
- package/dist/client/AgentPanel.d.ts +29 -2
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +116 -68
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +140 -18
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/FeedbackButton.d.ts +7 -1
- package/dist/client/FeedbackButton.d.ts.map +1 -1
- package/dist/client/FeedbackButton.js +13 -3
- package/dist/client/FeedbackButton.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts +1 -2
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/agent-sidebar-state.d.ts +2 -0
- package/dist/client/agent-sidebar-state.d.ts.map +1 -1
- package/dist/client/agent-sidebar-state.js +15 -4
- package/dist/client/agent-sidebar-state.js.map +1 -1
- package/dist/client/chat/index.d.ts +5 -0
- package/dist/client/chat/index.d.ts.map +1 -1
- package/dist/client/chat/index.js +5 -0
- package/dist/client/chat/index.js.map +1 -1
- package/dist/client/chat/run-recovery.d.ts.map +1 -1
- package/dist/client/chat/run-recovery.js +4 -6
- package/dist/client/chat/run-recovery.js.map +1 -1
- package/dist/client/chat/tool-call-display.d.ts +1 -0
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +16 -0
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/client/chat/tool-render-registry.d.ts +24 -0
- package/dist/client/chat/tool-render-registry.d.ts.map +1 -0
- package/dist/client/chat/tool-render-registry.js +37 -0
- package/dist/client/chat/tool-render-registry.js.map +1 -0
- package/dist/client/chat/widgets/DataChartRenderer.d.ts +5 -0
- package/dist/client/chat/widgets/DataChartRenderer.d.ts.map +1 -0
- package/dist/client/chat/widgets/DataChartRenderer.js +33 -0
- package/dist/client/chat/widgets/DataChartRenderer.js.map +1 -0
- package/dist/client/chat/widgets/DataChartWidget.d.ts +5 -0
- package/dist/client/chat/widgets/DataChartWidget.d.ts.map +1 -0
- package/dist/client/chat/widgets/DataChartWidget.js +15 -0
- package/dist/client/chat/widgets/DataChartWidget.js.map +1 -0
- package/dist/client/chat/widgets/DataInsightsWidget.d.ts +5 -0
- package/dist/client/chat/widgets/DataInsightsWidget.d.ts.map +1 -0
- package/dist/client/chat/widgets/DataInsightsWidget.js +18 -0
- package/dist/client/chat/widgets/DataInsightsWidget.js.map +1 -0
- package/dist/client/chat/widgets/DataTableWidget.d.ts +9 -0
- package/dist/client/chat/widgets/DataTableWidget.d.ts.map +1 -0
- package/dist/client/chat/widgets/DataTableWidget.js +95 -0
- package/dist/client/chat/widgets/DataTableWidget.js.map +1 -0
- package/dist/client/chat/widgets/builtin-tool-renderers.d.ts +2 -0
- package/dist/client/chat/widgets/builtin-tool-renderers.d.ts.map +1 -0
- package/dist/client/chat/widgets/builtin-tool-renderers.js +27 -0
- package/dist/client/chat/widgets/builtin-tool-renderers.js.map +1 -0
- package/dist/client/chat/widgets/data-widget-types.d.ts +52 -0
- package/dist/client/chat/widgets/data-widget-types.d.ts.map +1 -0
- package/dist/client/chat/widgets/data-widget-types.js +93 -0
- package/dist/client/chat/widgets/data-widget-types.js.map +1 -0
- package/dist/client/chat-view-transition.d.ts +23 -0
- package/dist/client/chat-view-transition.d.ts.map +1 -0
- package/dist/client/chat-view-transition.js +50 -0
- package/dist/client/chat-view-transition.js.map +1 -0
- package/dist/client/composer/PromptComposer.d.ts +1 -1
- package/dist/client/composer/PromptComposer.d.ts.map +1 -1
- package/dist/client/composer/PromptComposer.js +2 -2
- package/dist/client/composer/PromptComposer.js.map +1 -1
- package/dist/client/composer/TiptapComposer.d.ts +2 -1
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +2 -1
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/index.d.ts +5 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +5 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/route-state.d.ts +6 -0
- package/dist/client/route-state.d.ts.map +1 -1
- package/dist/client/route-state.js +29 -1
- package/dist/client/route-state.js.map +1 -1
- package/dist/client/use-chat-threads.d.ts.map +1 -1
- package/dist/client/use-chat-threads.js +19 -4
- package/dist/client/use-chat-threads.js.map +1 -1
- package/dist/scripts/dev/index.d.ts +1 -0
- package/dist/scripts/dev/index.d.ts.map +1 -1
- package/dist/scripts/dev/index.js +129 -127
- package/dist/scripts/dev/index.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +8 -0
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +29 -21
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/prompts/framework-core-compact.d.ts +4 -1
- package/dist/server/prompts/framework-core-compact.d.ts.map +1 -1
- package/dist/server/prompts/framework-core-compact.js +11 -4
- package/dist/server/prompts/framework-core-compact.js.map +1 -1
- package/dist/server/prompts/framework-core.d.ts +4 -1
- package/dist/server/prompts/framework-core.d.ts.map +1 -1
- package/dist/server/prompts/framework-core.js +15 -5
- package/dist/server/prompts/framework-core.js.map +1 -1
- package/dist/server/prompts/shared-rules.d.ts +4 -1
- package/dist/server/prompts/shared-rules.d.ts.map +1 -1
- package/dist/server/prompts/shared-rules.js +4 -1
- package/dist/server/prompts/shared-rules.js.map +1 -1
- package/dist/styles/agent-native.css +55 -0
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +4 -0
- package/dist/vite/client.js.map +1 -1
- package/docs/content/external-agents.md +14 -4
- package/docs/content/getting-started.md +1 -0
- package/docs/content/key-concepts.md +34 -15
- package/docs/content/mcp-apps.md +2 -0
- package/docs/content/mcp-protocol.md +2 -2
- package/docs/content/template-plan.md +16 -1
- package/docs/content/what-is-agent-native.md +10 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantChat.d.ts","sourceRoot":"","sources":["../../src/client/AssistantChat.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AssistantChat.d.ts","sourceRoot":"","sources":["../../src/client/AssistantChat.tsx"],"names":[],"mappings":"AAAA,OAAO,KASN,MAAM,OAAO,CAAC;AAWf,OAAO,KAAK,EAEV,gBAAgB,EAChB,yBAAyB,EAC1B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,yBAAyB,CAAC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AAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IACnD,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC;IAC5D,oEAAoE;IACpE,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,QAAQ,CAAC;IACjD;;;OAGG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,2BAA2B,KAAK,gBAAgB,CAAC;IAC3E;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,qBAAqB,CAAC,EAAE,MAAM,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAC;IACxE,kFAAkF;IAClF,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC1C,kFAAkF;IAClF,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,eAAO,MAAM,mBAAmB,gBAAgB,CAAC;AAsDjD,8DAA8D;AAC9D,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,QAI9C;AA6CD,OAAO,EACL,iBAAiB,EAElB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,CAAC;AA85E7B,eAAO,MAAM,aAAa,gGAyFxB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useRef, useEffect, useCallback, useMemo, forwardRef, useImperativeHandle, } from "react";
|
|
2
|
+
import { useState, useRef, useEffect, useCallback, useMemo, useLayoutEffect, forwardRef, useImperativeHandle, } from "react";
|
|
3
3
|
import { AssistantRuntimeProvider, useLocalRuntime, useThreadRuntime, useThread, useAui, useComposer, useComposerRuntime, ThreadPrimitive, } from "@assistant-ui/react";
|
|
4
4
|
import { CompositeAttachmentAdapter } from "@assistant-ui/react";
|
|
5
5
|
import { createAgentChatAdapter, } from "./agent-chat-adapter.js";
|
|
@@ -14,6 +14,7 @@ import { cn } from "./utils.js";
|
|
|
14
14
|
import { useNearBottomAutoscroll } from "./conversation/index.js";
|
|
15
15
|
import { TextAttachmentAdapter } from "./composer/attachment-accept.js";
|
|
16
16
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "./components/ui/tooltip.js";
|
|
17
|
+
import { AGENT_CHAT_VIEW_TRANSITION_PREPARE_EVENT } from "./chat-view-transition.js";
|
|
17
18
|
import { GuidedQuestionFlow, useGuidedQuestionFlow, } from "./guided-questions.js";
|
|
18
19
|
import { useDevMode } from "./use-dev-mode.js";
|
|
19
20
|
import { agentNativePath } from "./api-path.js";
|
|
@@ -32,6 +33,7 @@ import { BuilderSetupCard, LoopLimitContinueCard, RunErrorRecoveryCard, PlanMode
|
|
|
32
33
|
import { repoHasAssistantMessage, getRepoMessages, getRepoMessage, shouldImportServerThreadData, } from "./chat/repo-helpers.js";
|
|
33
34
|
export { AssistantMessageListErrorBoundary, AssistantUiStaleIndexErrorBoundary, assistantUiRecoverableRenderErrorKind, isAssistantUiRecoverableRenderError, isAssistantUiStaleIndexError, } from "./assistant-ui-recovery.js";
|
|
34
35
|
export { displayableUserMessageText } from "./chat/message-components.js";
|
|
36
|
+
const useBrowserLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
35
37
|
function createUserMessageRunConfig(references, requestMode, recoveryAction, trackInRunsTray, approvedToolCalls) {
|
|
36
38
|
const custom = {};
|
|
37
39
|
if (references && references.length > 0) {
|
|
@@ -85,6 +87,12 @@ function clearPendingSelection() {
|
|
|
85
87
|
window.dispatchEvent(new CustomEvent("agent-panel:selection-cleared"));
|
|
86
88
|
}
|
|
87
89
|
}
|
|
90
|
+
// Thread ids the server has already told us don't exist (a prior mount's
|
|
91
|
+
// /threads/:id probe returned 404). Module-scoped so it survives remounts:
|
|
92
|
+
// re-probing a known-absent thread on every navigation just re-spams DevTools
|
|
93
|
+
// with 404s for a thread that has no server row yet (e.g. a freshly created,
|
|
94
|
+
// not-yet-sent chat). Reset on a full page reload.
|
|
95
|
+
const knownAbsentThreadIds = new Set();
|
|
88
96
|
async function waitForThreadRunToClear(apiUrl, threadId) {
|
|
89
97
|
if (!threadId)
|
|
90
98
|
return;
|
|
@@ -246,6 +254,45 @@ export function latestNonRecoveryUserMessageText(messages) {
|
|
|
246
254
|
return "";
|
|
247
255
|
}
|
|
248
256
|
export const CHAT_STORAGE_PREFIX = "agent-chat:";
|
|
257
|
+
const THREAD_SNAPSHOT_CACHE_PREFIX = `${CHAT_STORAGE_PREFIX}thread-snapshot:`;
|
|
258
|
+
function threadSnapshotCacheKey(apiUrl, threadId) {
|
|
259
|
+
return `${THREAD_SNAPSHOT_CACHE_PREFIX}${apiUrl}:${threadId}`;
|
|
260
|
+
}
|
|
261
|
+
function normalizeCachedThreadSnapshot(value) {
|
|
262
|
+
if (!value || typeof value !== "object")
|
|
263
|
+
return null;
|
|
264
|
+
const snapshot = value;
|
|
265
|
+
if (typeof snapshot.threadData !== "string")
|
|
266
|
+
return null;
|
|
267
|
+
return {
|
|
268
|
+
threadData: snapshot.threadData,
|
|
269
|
+
title: typeof snapshot.title === "string" ? snapshot.title : "",
|
|
270
|
+
preview: typeof snapshot.preview === "string" ? snapshot.preview : "",
|
|
271
|
+
messageCount: typeof snapshot.messageCount === "number" &&
|
|
272
|
+
Number.isFinite(snapshot.messageCount)
|
|
273
|
+
? snapshot.messageCount
|
|
274
|
+
: 0,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
function readCachedThreadSnapshot(apiUrl, threadId) {
|
|
278
|
+
if (!threadId || typeof sessionStorage === "undefined")
|
|
279
|
+
return null;
|
|
280
|
+
try {
|
|
281
|
+
const raw = sessionStorage.getItem(threadSnapshotCacheKey(apiUrl, threadId));
|
|
282
|
+
return raw ? normalizeCachedThreadSnapshot(JSON.parse(raw)) : null;
|
|
283
|
+
}
|
|
284
|
+
catch {
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
function writeCachedThreadSnapshot(apiUrl, threadId, snapshot) {
|
|
289
|
+
if (!threadId || typeof sessionStorage === "undefined")
|
|
290
|
+
return;
|
|
291
|
+
try {
|
|
292
|
+
sessionStorage.setItem(threadSnapshotCacheKey(apiUrl, threadId), JSON.stringify(snapshot));
|
|
293
|
+
}
|
|
294
|
+
catch { }
|
|
295
|
+
}
|
|
249
296
|
/** Remove persisted chat for a given tabId (or "default"). */
|
|
250
297
|
export function clearChatStorage(tabId) {
|
|
251
298
|
try {
|
|
@@ -600,7 +647,11 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
600
647
|
}, [isRunning, tabId, threadId]);
|
|
601
648
|
// ─── Chat persistence ──────────────────────────────────────────────
|
|
602
649
|
const hasRestoredRef = useRef(false);
|
|
603
|
-
const [
|
|
650
|
+
const [initialCachedThreadSnapshot] = useState(() => readCachedThreadSnapshot(apiUrl, threadId));
|
|
651
|
+
const hasImportedInitialCachedSnapshotRef = useRef(false);
|
|
652
|
+
const [isRestoring, setIsRestoring] = useState(!!(threadId || loadHistoryRepository) &&
|
|
653
|
+
!isNewThread &&
|
|
654
|
+
!initialCachedThreadSnapshot);
|
|
604
655
|
const onSaveThreadRef = useRef(onSaveThread);
|
|
605
656
|
onSaveThreadRef.current = onSaveThread;
|
|
606
657
|
const onGenerateTitleRef = useRef(onGenerateTitle);
|
|
@@ -694,6 +745,40 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
694
745
|
return null;
|
|
695
746
|
}
|
|
696
747
|
}, [apiUrl, importThreadData, loadHistoryRepository, threadId]);
|
|
748
|
+
const cacheCurrentThreadSnapshot = useCallback(() => {
|
|
749
|
+
if (!threadId || messages.length === 0)
|
|
750
|
+
return;
|
|
751
|
+
const repo = threadRuntime.export();
|
|
752
|
+
const threadData = JSON.stringify(stripBase64FromRepo(repo));
|
|
753
|
+
const { title, preview } = extractThreadMeta(repo);
|
|
754
|
+
writeCachedThreadSnapshot(apiUrl, threadId, {
|
|
755
|
+
threadData,
|
|
756
|
+
title,
|
|
757
|
+
preview,
|
|
758
|
+
messageCount: messages.length,
|
|
759
|
+
});
|
|
760
|
+
}, [apiUrl, messages.length, threadId, threadRuntime]);
|
|
761
|
+
useBrowserLayoutEffect(() => {
|
|
762
|
+
if (hasImportedInitialCachedSnapshotRef.current)
|
|
763
|
+
return;
|
|
764
|
+
if (!initialCachedThreadSnapshot)
|
|
765
|
+
return;
|
|
766
|
+
hasImportedInitialCachedSnapshotRef.current = true;
|
|
767
|
+
try {
|
|
768
|
+
importThreadData(initialCachedThreadSnapshot.threadData, {
|
|
769
|
+
markTitleGenerated: Boolean(initialCachedThreadSnapshot.title),
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
finally {
|
|
773
|
+
setIsRestoring(false);
|
|
774
|
+
}
|
|
775
|
+
}, [importThreadData, initialCachedThreadSnapshot]);
|
|
776
|
+
useEffect(() => {
|
|
777
|
+
window.addEventListener(AGENT_CHAT_VIEW_TRANSITION_PREPARE_EVENT, cacheCurrentThreadSnapshot);
|
|
778
|
+
return () => {
|
|
779
|
+
window.removeEventListener(AGENT_CHAT_VIEW_TRANSITION_PREPARE_EVENT, cacheCurrentThreadSnapshot);
|
|
780
|
+
};
|
|
781
|
+
}, [cacheCurrentThreadSnapshot]);
|
|
697
782
|
const wasRecentlyStoppedRun = useCallback((runId) => {
|
|
698
783
|
const stopped = userStoppedRunRef.current;
|
|
699
784
|
return Boolean(stopped &&
|
|
@@ -904,6 +989,11 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
904
989
|
// can only 404 and makes normal app startup look broken in DevTools.
|
|
905
990
|
setIsRestoring(false);
|
|
906
991
|
}
|
|
992
|
+
else if (threadId && knownAbsentThreadIds.has(threadId)) {
|
|
993
|
+
// A prior mount already learned this thread has no server row (404).
|
|
994
|
+
// Skip the re-probe so remounts don't re-spam 404s for the same id.
|
|
995
|
+
setIsRestoring(false);
|
|
996
|
+
}
|
|
907
997
|
else if (threadId) {
|
|
908
998
|
(async () => {
|
|
909
999
|
try {
|
|
@@ -911,13 +1001,33 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
911
1001
|
if (res.ok) {
|
|
912
1002
|
const data = await res.json();
|
|
913
1003
|
if (data.threadData) {
|
|
914
|
-
importThreadData(data.threadData, {
|
|
1004
|
+
const repo = importThreadData(data.threadData, {
|
|
1005
|
+
markTitleGenerated: true,
|
|
1006
|
+
});
|
|
1007
|
+
if (repo) {
|
|
1008
|
+
const { title, preview } = extractThreadMeta(repo);
|
|
1009
|
+
writeCachedThreadSnapshot(apiUrl, threadId, {
|
|
1010
|
+
threadData: typeof data.threadData === "string"
|
|
1011
|
+
? data.threadData
|
|
1012
|
+
: JSON.stringify(data.threadData),
|
|
1013
|
+
title: data.title || title,
|
|
1014
|
+
preview,
|
|
1015
|
+
messageCount: Array.isArray(repo.messages)
|
|
1016
|
+
? repo.messages.length
|
|
1017
|
+
: 0,
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
915
1020
|
}
|
|
916
1021
|
// Also skip title generation if thread already has a title
|
|
917
1022
|
if (data.title) {
|
|
918
1023
|
titleGeneratedRef.current = true;
|
|
919
1024
|
}
|
|
920
1025
|
}
|
|
1026
|
+
else if (res.status === 404) {
|
|
1027
|
+
// No server row for this thread yet — remember it so later remounts
|
|
1028
|
+
// skip the probe instead of re-fetching a known 404.
|
|
1029
|
+
knownAbsentThreadIds.add(threadId);
|
|
1030
|
+
}
|
|
921
1031
|
}
|
|
922
1032
|
catch {
|
|
923
1033
|
// Start fresh
|
|
@@ -1071,15 +1181,18 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1071
1181
|
return;
|
|
1072
1182
|
const repo = threadRuntime.export();
|
|
1073
1183
|
const { title, preview } = extractThreadMeta(repo);
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
threadData: JSON.stringify(stripBase64FromRepo(repo)),
|
|
1184
|
+
const threadData = JSON.stringify(stripBase64FromRepo(repo));
|
|
1185
|
+
const snapshot = {
|
|
1186
|
+
threadData,
|
|
1078
1187
|
title,
|
|
1079
1188
|
preview,
|
|
1080
1189
|
messageCount: messages.length,
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1190
|
+
};
|
|
1191
|
+
lastSaveTimeRef.current = now;
|
|
1192
|
+
savedTitleRef.current = title;
|
|
1193
|
+
writeCachedThreadSnapshot(apiUrl, threadId, snapshot);
|
|
1194
|
+
onSaveThreadRef.current(threadId, snapshot);
|
|
1195
|
+
}, [apiUrl, messages, isRunning, threadId, threadRuntime]);
|
|
1083
1196
|
// Persist full thread data after each completed response
|
|
1084
1197
|
useEffect(() => {
|
|
1085
1198
|
if (!hasRestoredRef.current)
|
|
@@ -1092,13 +1205,16 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1092
1205
|
if (threadId && onSaveThreadRef.current) {
|
|
1093
1206
|
// Save to server via the hook callback
|
|
1094
1207
|
const { title, preview } = extractThreadMeta(repo);
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
threadData
|
|
1208
|
+
const threadData = JSON.stringify(stripBase64FromRepo(repo));
|
|
1209
|
+
const snapshot = {
|
|
1210
|
+
threadData,
|
|
1098
1211
|
title,
|
|
1099
1212
|
preview,
|
|
1100
1213
|
messageCount: messages.length,
|
|
1101
|
-
}
|
|
1214
|
+
};
|
|
1215
|
+
savedTitleRef.current = title;
|
|
1216
|
+
writeCachedThreadSnapshot(apiUrl, threadId, snapshot);
|
|
1217
|
+
onSaveThreadRef.current(threadId, snapshot);
|
|
1102
1218
|
}
|
|
1103
1219
|
else {
|
|
1104
1220
|
// Legacy: save to sessionStorage
|
|
@@ -1108,7 +1224,7 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1108
1224
|
}
|
|
1109
1225
|
catch { }
|
|
1110
1226
|
}
|
|
1111
|
-
}, [messages, isRunning, threadId, tabId, threadRuntime]);
|
|
1227
|
+
}, [apiUrl, messages, isRunning, threadId, tabId, threadRuntime]);
|
|
1112
1228
|
useEffect(() => {
|
|
1113
1229
|
onMessageCountChange?.(messages.length);
|
|
1114
1230
|
}, [messages.length, onMessageCountChange]);
|
|
@@ -1829,12 +1945,18 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1829
1945
|
(!userStoppedRunRef.current.runId ||
|
|
1830
1946
|
!visibleRunError.runId ||
|
|
1831
1947
|
userStoppedRunRef.current.runId === visibleRunError.runId));
|
|
1948
|
+
const hasActiveChatWork = showRunningInUI ||
|
|
1949
|
+
isAutoResuming ||
|
|
1950
|
+
queuedMessages.length > 0 ||
|
|
1951
|
+
reconnectContent.length > 0;
|
|
1832
1952
|
const isFreshEmptyChat = messages.length === 0 &&
|
|
1953
|
+
!hasActiveChatWork &&
|
|
1833
1954
|
!isRestoring &&
|
|
1834
1955
|
!isReconnecting &&
|
|
1835
|
-
!authError
|
|
1836
|
-
!missingApiKey;
|
|
1956
|
+
!authError;
|
|
1837
1957
|
const centeredEmptyState = centerComposerWhenEmpty && isFreshEmptyChat;
|
|
1958
|
+
const showEmptyState = messages.length === 0 && !isReconnecting && !hasActiveChatWork;
|
|
1959
|
+
const showComposerSlot = Boolean(composerSlot) && (!centerComposerWhenEmpty || centeredEmptyState);
|
|
1838
1960
|
// Clarifying-question surface: the `ask-question` action writes a
|
|
1839
1961
|
// GuidedQuestionPayload to application_state under "guided-questions". The
|
|
1840
1962
|
// hook polls that key, and on submit/skip composes the answer as a normal
|
|
@@ -1894,7 +2016,7 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1894
2016
|
window.location.reload();
|
|
1895
2017
|
}, className: authSessionAvailable
|
|
1896
2018
|
? "text-xs text-background bg-foreground hover:opacity-90 px-3 py-1.5 rounded-md"
|
|
1897
|
-
: "text-xs text-muted-foreground hover:text-foreground px-3 py-1.5 rounded-md border border-border hover:bg-accent", children: "Refresh chat" })] })] })) : missingApiKey && messages.length === 0 ? (_jsx("div", { className: "flex flex-col items-center justify-center h-full px-2", children: _jsx(BuilderSetupCard, { onConnected: handleBuilderConnected, bouncePulse: missingKeyBouncePulse }) })) : isRestoring ? (_jsxs("div", { className: "flex flex-col gap-3 p-4", children: [_jsx("div", { className: "flex justify-end", children: _jsx("div", { className: "h-8 w-32 rounded-lg bg-muted animate-pulse" }) }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("div", { className: "h-4 w-48 rounded bg-muted animate-pulse" }), _jsx("div", { className: "h-4 w-64 rounded bg-muted animate-pulse" }), _jsx("div", { className: "h-4 w-40 rounded bg-muted animate-pulse" })] })] })) :
|
|
2019
|
+
: "text-xs text-muted-foreground hover:text-foreground px-3 py-1.5 rounded-md border border-border hover:bg-accent", children: "Refresh chat" })] })] })) : missingApiKey && messages.length === 0 ? (_jsx("div", { className: "flex flex-col items-center justify-center h-full px-2", children: _jsx(BuilderSetupCard, { onConnected: handleBuilderConnected, bouncePulse: missingKeyBouncePulse }) })) : isRestoring ? (_jsxs("div", { className: "flex flex-col gap-3 p-4", children: [_jsx("div", { className: "flex justify-end", children: _jsx("div", { className: "h-8 w-32 rounded-lg bg-muted animate-pulse" }) }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("div", { className: "h-4 w-48 rounded bg-muted animate-pulse" }), _jsx("div", { className: "h-4 w-64 rounded bg-muted animate-pulse" }), _jsx("div", { className: "h-4 w-40 rounded bg-muted animate-pulse" })] })] })) : showEmptyState ? (_jsxs("div", { className: cn("agent-empty-state", emptyStateDisplay === "hidden"
|
|
1898
2020
|
? "sr-only"
|
|
1899
2021
|
: "flex h-full flex-col items-center justify-center gap-4 px-4 py-16"), children: [_jsx("div", { className: "flex h-10 w-10 items-center justify-center rounded-full bg-muted", children: _jsx(IconMessage, { className: "h-5 w-5 text-muted-foreground" }) }), _jsx("p", { className: "sr-only", children: emptyStateText ?? "How can I help you?" }), emptyStateAddon, resolvedSuggestions && resolvedSuggestions.length > 0 ? (_jsx("div", { className: "flex flex-col gap-1.5 w-full max-w-[280px]", children: resolvedSuggestions.map((suggestion) => (_jsx("button", { onClick: () => {
|
|
1900
2022
|
threadRuntime.append({
|
|
@@ -1927,7 +2049,7 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1927
2049
|
.replace(/<context>[\s\S]*?<\/context>\n?/g, "")
|
|
1928
2050
|
.trim();
|
|
1929
2051
|
return (_jsx("div", { className: "flex justify-end group", children: _jsxs("div", { className: "relative max-w-[85%] rounded-lg bg-accent/50 text-foreground/60 px-3 py-2 text-sm leading-relaxed whitespace-pre-wrap break-words", children: [_jsxs("div", { className: "flex items-center gap-1.5 text-[10px] text-muted-foreground mb-1 font-medium uppercase tracking-wide", children: [_jsx(IconClock, { className: "h-3 w-3" }), "Queued"] }), displayText, msg.images && msg.images.length > 0 && (_jsx("div", { className: "flex flex-wrap gap-1.5 mt-1.5", children: msg.images.map((img, j) => (_jsx("img", { src: img, alt: "", className: "h-12 w-12 rounded object-cover border border-border/50" }, j))) })), _jsx("button", { type: "button", onClick: () => setQueuedMessages((prev) => prev.filter((m) => m.id !== msg.id)), "aria-label": "Remove from queue", className: "absolute -top-2 -right-2 flex h-5 w-5 items-center justify-center rounded-full border border-border bg-background text-muted-foreground opacity-0 group-hover:opacity-100 focus-visible:opacity-100 hover:text-foreground hover:bg-accent shadow-sm", children: _jsx(IconX, { className: "h-3 w-3" }) })] }) }, msg.id));
|
|
1930
|
-
})] })) }), showScrollToBottom && (_jsx("div", { className: "shrink-0 flex justify-center -mb-1", children: _jsx("button", { type: "button", onClick: scrollToBottom, className: "flex h-7 w-7 items-center justify-center rounded-full border border-border bg-background shadow-sm hover:bg-accent", "aria-label": "Scroll to bottom", children: _jsx(IconChevronDown, { className: "h-3.5 w-3.5 text-muted-foreground" }) }) })), composerSlot, guidedQuestions && guidedQuestions.length > 0 && (_jsx("div", { className: "shrink-0 px-3 pb-2 pt-1", children: _jsx("div", { className: "rounded-lg border border-border bg-card/60 shadow-sm", children: _jsx(GuidedQuestionFlow, { questions: guidedQuestions, onSubmit: handleGuidedQuestionsSubmit, onSkip: handleGuidedQuestionsSkip, ...(guidedQuestionsTitle
|
|
2052
|
+
})] })) }), showScrollToBottom && (_jsx("div", { className: "shrink-0 flex justify-center -mb-1", children: _jsx("button", { type: "button", onClick: scrollToBottom, className: "flex h-7 w-7 items-center justify-center rounded-full border border-border bg-background shadow-sm hover:bg-accent", "aria-label": "Scroll to bottom", children: _jsx(IconChevronDown, { className: "h-3.5 w-3.5 text-muted-foreground" }) }) })), showComposerSlot ? composerSlot : null, guidedQuestions && guidedQuestions.length > 0 && (_jsx("div", { className: "shrink-0 px-3 pb-2 pt-1", children: _jsx("div", { className: "rounded-lg border border-border bg-card/60 shadow-sm", children: _jsx(GuidedQuestionFlow, { questions: guidedQuestions, onSubmit: handleGuidedQuestionsSubmit, onSkip: handleGuidedQuestionsSkip, ...(guidedQuestionsTitle
|
|
1931
2053
|
? { title: guidedQuestionsTitle }
|
|
1932
2054
|
: {}), ...(guidedQuestionsDescription
|
|
1933
2055
|
? { description: guidedQuestionsDescription }
|