@agent-native/core 0.0.0-beta-20260820222620 → 0.0.0-beta-20260820231735
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/templates/brain/actions/list-sources.ts +17 -7
- package/corpus/templates/brain/app/components/brain/Surface.tsx +4 -2
- package/corpus/templates/brain/app/lib/brain.ts +13 -3
- package/corpus/templates/brain/server/lib/brain-health.ts +5 -8
- package/corpus/templates/brain/server/lib/brain.ts +1 -0
- package/corpus/templates/brain/server/lib/capture-sanitization.ts +5 -0
- package/corpus/templates/brain/server/routes/api/brain/queue/run.post.ts +3 -2
- package/dist/chat-threads/store.d.ts +7 -0
- package/dist/chat-threads/store.js +15 -0
- package/dist/client/AgentPanel.d.ts +5 -1
- package/dist/client/AgentPanel.js +8 -8
- package/dist/client/AssistantChat.d.ts +3 -1
- package/dist/client/AssistantChat.js +22 -6
- package/dist/client/MultiTabAssistantChat.d.ts +3 -1
- package/dist/client/MultiTabAssistantChat.js +5 -4
- package/dist/client/use-chat-threads.d.ts +7 -0
- package/dist/client/use-chat-threads.js +144 -40
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/config.d.ts +3 -1
- package/dist/config.js +14 -9
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/observability/routes.d.ts +3 -3
- package/dist/server/agent-chat-plugin.js +112 -23
- package/dist/server/realtime-token.d.ts +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/vite/agent-native-config-loader.js +1 -1
- package/dist/vite/client.js +6 -8
- package/docs/content/agent-native-config.mdx +55 -31
- package/docs/content/environment-variables.mdx +51 -14
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ import { z } from "zod";
|
|
|
6
6
|
import { getDb, schema } from "../server/db/index.js";
|
|
7
7
|
import { nextBrainSourceSyncAt } from "../server/jobs/sync-sources.js";
|
|
8
8
|
import { listAccessibleAudienceIds } from "../server/lib/audiences.js";
|
|
9
|
+
import { sourceHealthState } from "../server/lib/brain-health.js";
|
|
9
10
|
import { parseJson, serializeSource } from "../server/lib/brain.js";
|
|
10
11
|
import { sourceProviderSchema } from "./_schemas.js";
|
|
11
12
|
|
|
@@ -71,14 +72,23 @@ export default defineAction({
|
|
|
71
72
|
.from(schema.brainSources)
|
|
72
73
|
.where(and(...clauses))
|
|
73
74
|
.orderBy(desc(schema.brainSources.updatedAt));
|
|
75
|
+
const nowMs = Date.now();
|
|
74
76
|
const sources = await Promise.all(
|
|
75
|
-
rows.map(async (row) =>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
rows.map(async (row) => {
|
|
78
|
+
const latest = await latestRun(row.id);
|
|
79
|
+
const nextSyncAt = nextBrainSourceSyncAt(row);
|
|
80
|
+
return {
|
|
81
|
+
...serializeSource(row),
|
|
82
|
+
recordCount: await sourceRecordCount(row.id),
|
|
83
|
+
latestRun: latest,
|
|
84
|
+
nextSyncAt,
|
|
85
|
+
health: sourceHealthState(row, latest, nextSyncAt, nowMs),
|
|
86
|
+
};
|
|
87
|
+
}),
|
|
81
88
|
);
|
|
82
|
-
return {
|
|
89
|
+
return {
|
|
90
|
+
count: rows.length,
|
|
91
|
+
sources,
|
|
92
|
+
};
|
|
83
93
|
},
|
|
84
94
|
});
|
|
@@ -117,7 +117,8 @@ export function StatusBadge({ status }: { status: string }) {
|
|
|
117
117
|
? IconCircleCheck
|
|
118
118
|
: normalized.includes("review") ||
|
|
119
119
|
normalized.includes("degraded") ||
|
|
120
|
-
normalized.includes("stale")
|
|
120
|
+
normalized.includes("stale") ||
|
|
121
|
+
normalized.includes("needs")
|
|
121
122
|
? IconClock
|
|
122
123
|
: normalized.includes("error")
|
|
123
124
|
? IconAlertTriangle
|
|
@@ -132,7 +133,8 @@ export function StatusBadge({ status }: { status: string }) {
|
|
|
132
133
|
"border-border bg-secondary text-secondary-foreground",
|
|
133
134
|
(normalized.includes("review") ||
|
|
134
135
|
normalized.includes("degraded") ||
|
|
135
|
-
normalized.includes("stale")
|
|
136
|
+
normalized.includes("stale") ||
|
|
137
|
+
normalized.includes("needs")) &&
|
|
136
138
|
"border-amber-500/35 bg-amber-500/10 text-amber-700 dark:text-amber-300",
|
|
137
139
|
normalized.includes("error") &&
|
|
138
140
|
"border-destructive/35 bg-destructive/10 text-destructive",
|
|
@@ -20,7 +20,14 @@ export type BrainView =
|
|
|
20
20
|
| "settings";
|
|
21
21
|
|
|
22
22
|
export type KnowledgeStatus = "approved" | "needs_review" | "draft" | "stale";
|
|
23
|
-
export type SourceHealth =
|
|
23
|
+
export type SourceHealth =
|
|
24
|
+
| "healthy"
|
|
25
|
+
| "needs_setup"
|
|
26
|
+
| "needs_sync"
|
|
27
|
+
| "stale"
|
|
28
|
+
| "degraded"
|
|
29
|
+
| "paused"
|
|
30
|
+
| "error";
|
|
24
31
|
export type ReviewPriority = "high" | "medium" | "low";
|
|
25
32
|
|
|
26
33
|
export interface Citation {
|
|
@@ -1144,8 +1151,11 @@ export function sourceDescription(source: BrainSource) {
|
|
|
1144
1151
|
export function sourceHealth(source: BrainSource): SourceHealth {
|
|
1145
1152
|
if (source.health) return source.health;
|
|
1146
1153
|
if (sourceRetryAfter(source)) return "degraded";
|
|
1147
|
-
if (source.status === "active")
|
|
1148
|
-
|
|
1154
|
+
if (source.status === "active") {
|
|
1155
|
+
if (source.lastError) return "degraded";
|
|
1156
|
+
if (sourceAutoSync(source) && !source.lastSyncedAt) return "needs_sync";
|
|
1157
|
+
return "healthy";
|
|
1158
|
+
}
|
|
1149
1159
|
if (source.status === "error") return "error";
|
|
1150
1160
|
if (source.status === "paused" || source.status === "archived")
|
|
1151
1161
|
return "paused";
|
|
@@ -189,9 +189,9 @@ function latestIso(values: Array<string | null | undefined>) {
|
|
|
189
189
|
return latest;
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
function sourceHealthState(
|
|
192
|
+
export function sourceHealthState(
|
|
193
193
|
source: SourceRow,
|
|
194
|
-
latestRun: SyncRunRow | null,
|
|
194
|
+
latestRun: Pick<SyncRunRow, "status"> | null,
|
|
195
195
|
nextSyncAt: string | null,
|
|
196
196
|
nowMs: number,
|
|
197
197
|
): BrainSourceHealthState {
|
|
@@ -530,12 +530,9 @@ export async function readBrainHealth() {
|
|
|
530
530
|
};
|
|
531
531
|
});
|
|
532
532
|
|
|
533
|
-
const sourceHealthCounts = countStatuses<
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
...sourceSummaries.map((source) => ({ status: source.health })),
|
|
537
|
-
...sourceRows.map((source) => ({ status: source.status })),
|
|
538
|
-
]);
|
|
533
|
+
const sourceHealthCounts = countStatuses<BrainSourceHealthState>(
|
|
534
|
+
sourceSummaries.map((source) => ({ status: source.health })),
|
|
535
|
+
);
|
|
539
536
|
const captureCounts = countStatuses(captureRows);
|
|
540
537
|
const captureDispositionCounts = countStatuses(
|
|
541
538
|
captureRows.map((capture) => ({
|
|
@@ -755,6 +755,7 @@ export async function createCapture(values: {
|
|
|
755
755
|
title: source.title,
|
|
756
756
|
provider: source.provider as BrainSourceProvider,
|
|
757
757
|
ownerEmail: source.ownerEmail,
|
|
758
|
+
orgId: source.orgId,
|
|
758
759
|
},
|
|
759
760
|
sourceConfig: parseJson<Record<string, unknown>>(source.configJson, {}),
|
|
760
761
|
settings,
|
|
@@ -71,6 +71,7 @@ export interface CaptureSanitizationInput {
|
|
|
71
71
|
title: string;
|
|
72
72
|
provider: BrainSourceProvider;
|
|
73
73
|
ownerEmail: string;
|
|
74
|
+
orgId?: string | null;
|
|
74
75
|
};
|
|
75
76
|
sourceConfig?: Record<string, unknown>;
|
|
76
77
|
settings: BrainSettings;
|
|
@@ -440,6 +441,10 @@ async function classifyWithApprovedModel(
|
|
|
440
441
|
apiKeyEnvVar: userApiKey.apiKeyEnvVar,
|
|
441
442
|
appId: "brain",
|
|
442
443
|
engineOption: engineName,
|
|
444
|
+
credentialIdentity: {
|
|
445
|
+
userEmail: input.source.ownerEmail,
|
|
446
|
+
orgId: input.source.orgId ?? undefined,
|
|
447
|
+
},
|
|
443
448
|
});
|
|
444
449
|
|
|
445
450
|
const maxChars = Math.min(
|
|
@@ -10,7 +10,8 @@ declare global {
|
|
|
10
10
|
var __AGENT_NATIVE_BRAIN_SCHEDULED_RUNTIME__: boolean | undefined;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const BRAIN_QUEUE_SWEEP_LIMIT =
|
|
13
|
+
export const BRAIN_QUEUE_SWEEP_LIMIT = 25;
|
|
14
|
+
export const BRAIN_MAX_DISTILLATIONS_PER_SWEEP = 2;
|
|
14
15
|
|
|
15
16
|
function productionLike() {
|
|
16
17
|
return (
|
|
@@ -53,7 +54,7 @@ export default defineEventHandler(async (event) => {
|
|
|
53
54
|
processBrainIngestQueueOnce({
|
|
54
55
|
limit: BRAIN_QUEUE_SWEEP_LIMIT,
|
|
55
56
|
runDistillation: true,
|
|
56
|
-
maxDistillations:
|
|
57
|
+
maxDistillations: BRAIN_MAX_DISTILLATIONS_PER_SWEEP,
|
|
57
58
|
}),
|
|
58
59
|
expireSensitivityQuarantines(),
|
|
59
60
|
]);
|
|
@@ -26,6 +26,13 @@ export interface ChatThreadScope {
|
|
|
26
26
|
id: string;
|
|
27
27
|
label?: string;
|
|
28
28
|
}
|
|
29
|
+
export declare function isAppOwnedChatScope(scope?: ChatThreadScope | null): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* A scoped rail may claim a legacy unscoped thread on its first write, but
|
|
32
|
+
* once a thread has a scope, a non-null incoming scope must match it. App-
|
|
33
|
+
* owned threads additionally require a scope on every subsequent write.
|
|
34
|
+
*/
|
|
35
|
+
export declare function threadScopeMismatch(existing?: ChatThreadScope | null, incoming?: ChatThreadScope | null): boolean;
|
|
29
36
|
export interface ChatThreadSource {
|
|
30
37
|
platform?: string | null;
|
|
31
38
|
appId?: string | null;
|
|
@@ -241,6 +241,21 @@ export async function repairLegacyChatThreadMessageCounts(options = {}) {
|
|
|
241
241
|
function generateId() {
|
|
242
242
|
return `thread-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
243
243
|
}
|
|
244
|
+
export function isAppOwnedChatScope(scope) {
|
|
245
|
+
return scope?.type === "workspace-app" || scope?.type === "desktop-app";
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* A scoped rail may claim a legacy unscoped thread on its first write, but
|
|
249
|
+
* once a thread has a scope, a non-null incoming scope must match it. App-
|
|
250
|
+
* owned threads additionally require a scope on every subsequent write.
|
|
251
|
+
*/
|
|
252
|
+
export function threadScopeMismatch(existing, incoming) {
|
|
253
|
+
if (!existing)
|
|
254
|
+
return false;
|
|
255
|
+
if (!incoming)
|
|
256
|
+
return isAppOwnedChatScope(existing);
|
|
257
|
+
return existing.type !== incoming.type || existing.id !== incoming.id;
|
|
258
|
+
}
|
|
244
259
|
function readScope(r) {
|
|
245
260
|
const type = r.scope_type;
|
|
246
261
|
const id = r.scope_id;
|
|
@@ -107,6 +107,8 @@ export interface AgentPanelProps extends Omit<AssistantChatProps, "onSwitchToCli
|
|
|
107
107
|
restoreActiveThread?: boolean;
|
|
108
108
|
/** Ambient resource context rendered as a composer chip. */
|
|
109
109
|
scope?: import("./use-chat-threads.js").ChatThreadScope | null;
|
|
110
|
+
/** Keep app-owned chat history isolated to the supplied scope. */
|
|
111
|
+
isolateHistoryByScope?: boolean;
|
|
110
112
|
/** @deprecated Scope context now appears inside the composer. */
|
|
111
113
|
showScopeBadge?: MultiTabAssistantChatProps["showScopeBadge"];
|
|
112
114
|
/** Stable browser tab id used for tab-scoped app-state context. */
|
|
@@ -239,6 +241,8 @@ export interface AgentSidebarProps {
|
|
|
239
241
|
onFullscreenRequest?: () => void;
|
|
240
242
|
/** Ambient resource context rendered as a composer chip. */
|
|
241
243
|
scope?: import("./use-chat-threads.js").ChatThreadScope | null;
|
|
244
|
+
/** Keep app-owned chat history isolated to the supplied scope. */
|
|
245
|
+
isolateHistoryByScope?: boolean;
|
|
242
246
|
/** @deprecated Scope context now appears inside the composer. */
|
|
243
247
|
showScopeBadge?: MultiTabAssistantChatProps["showScopeBadge"];
|
|
244
248
|
/** Stable browser tab id used for tab-scoped app-state context. */
|
|
@@ -254,7 +258,7 @@ export interface AgentSidebarProps {
|
|
|
254
258
|
* Wraps app content with a toggleable agent sidebar.
|
|
255
259
|
* Use AgentToggleButton in your header to open/close it.
|
|
256
260
|
*/
|
|
257
|
-
export declare function AgentSidebar({ children, emptyStateText, suggestions, dynamicSuggestions, composerToolbarSlot, composerSlot, onComposerTextChange, imageModelMenu, availableAgents, availableModels, modelListLoading, selectedAgent, onAgentChange, onConnectLocalRuntime, runtime, adapterReloadKey, threadFooterSlot, defaultSidebarWidth, sidebarWidth, position, defaultOpen, animateMobile, animateDesktop, chatViewTransition, chatViewTransitionHandoff, storageKey, openStorageKey, apiUrl, agentChatSurface, desktopIdentityUnauthenticated, desktopIdentityAuthenticated, showTabBar, suppressInlineOpenApp, composerPlaceholder, openOnChatRunning, onFullscreenRequest, scope, showScopeBadge, browserTabId, threadUrlSync, agentPageHref, suppressFirstRunOnboarding, }: AgentSidebarProps): React.JSX.Element;
|
|
261
|
+
export declare function AgentSidebar({ children, emptyStateText, suggestions, dynamicSuggestions, composerToolbarSlot, composerSlot, onComposerTextChange, imageModelMenu, availableAgents, availableModels, modelListLoading, selectedAgent, onAgentChange, onConnectLocalRuntime, runtime, adapterReloadKey, threadFooterSlot, defaultSidebarWidth, sidebarWidth, position, defaultOpen, animateMobile, animateDesktop, chatViewTransition, chatViewTransitionHandoff, storageKey, openStorageKey, apiUrl, agentChatSurface, desktopIdentityUnauthenticated, desktopIdentityAuthenticated, showTabBar, suppressInlineOpenApp, composerPlaceholder, openOnChatRunning, onFullscreenRequest, scope, isolateHistoryByScope, showScopeBadge, browserTabId, threadUrlSync, agentPageHref, suppressFirstRunOnboarding, }: AgentSidebarProps): React.JSX.Element;
|
|
258
262
|
/**
|
|
259
263
|
* Focus the agent chat composer input.
|
|
260
264
|
* Opens the sidebar if closed, then focuses the text input.
|
|
@@ -436,7 +436,7 @@ function CodeAccessUnavailablePanel({ title, description, ctaLabel, ctaHref, sec
|
|
|
436
436
|
});
|
|
437
437
|
}, className: "inline-flex items-center gap-1.5 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-foreground hover:bg-accent", children: secondaryCtaLabel })] })] }));
|
|
438
438
|
}
|
|
439
|
-
function AgentPanelInner({ defaultMode = "chat", className, style, apiUrl, emptyStateText, emptyStateAddon, suggestions, dynamicSuggestions, showHeader = true, onCollapse, isFullscreen, onToggleFullscreen, onFullViewRequest, onSnapTo75Percent, isWideDrawer, onExitWideDrawer, devAppUrl, storageKey, restoreActiveThread = true, scope, showScopeBadge, browserTabId, threadUrlSync, chatNotice, showTabBar = true, showPageNewChatButton = false, allowSettingsMode = true, chatOnly = false, agentPageHref, codeAccess, ...assistantChatProps }) {
|
|
439
|
+
function AgentPanelInner({ defaultMode = "chat", className, style, apiUrl, emptyStateText, emptyStateAddon, suggestions, dynamicSuggestions, showHeader = true, onCollapse, isFullscreen, onToggleFullscreen, onFullViewRequest, onSnapTo75Percent, isWideDrawer, onExitWideDrawer, devAppUrl, storageKey, restoreActiveThread = true, scope, isolateHistoryByScope = false, showScopeBadge, browserTabId, threadUrlSync, chatNotice, showTabBar = true, showPageNewChatButton = false, allowSettingsMode = true, chatOnly = false, agentPageHref, codeAccess, ...assistantChatProps }) {
|
|
440
440
|
const t = useT();
|
|
441
441
|
const navigate = useNavigate();
|
|
442
442
|
const location = useLocation();
|
|
@@ -838,7 +838,7 @@ function AgentPanelInner({ defaultMode = "chat", className, style, apiUrl, empty
|
|
|
838
838
|
const isActive = tab.id === activeTabId ||
|
|
839
839
|
(tab.id === focusParentId &&
|
|
840
840
|
activeTab?.parentThreadId === tab.id);
|
|
841
|
-
return (_jsxs("div", { role: "button", tabIndex: 0, ref: isActive ? activeTabRefCb : undefined, onClick: () => setActiveTabId(tab.id), onKeyDown: activateOnKeyDown(() => setActiveTabId(tab.id)), className: cn("agent-tab relative flex shrink-0 items-center gap-1 rounded-md px-2.5 py-1.5 text-[11px] font-medium cursor-pointer max-w-[150px]", isActive
|
|
841
|
+
return (_jsxs("div", { role: "button", tabIndex: 0, ref: isActive ? activeTabRefCb : undefined, onClick: () => setActiveTabId(tab.id), onKeyDown: activateOnKeyDown(() => setActiveTabId(tab.id)), className: cn("agent-tab relative flex shrink-0 items-center gap-1 rounded-md px-2.5 py-1.5 text-[11px] font-medium cursor-pointer min-w-[56px] max-w-[150px]", isActive
|
|
842
842
|
? "bg-accent text-foreground"
|
|
843
843
|
: "text-muted-foreground hover:bg-accent hover:text-foreground"), children: [_jsx("span", { className: "truncate pe-1", children: tab.label }), tab.status === "running" && (_jsx("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full bg-muted-foreground/50 animate-pulse" })), _jsx("button", { type: "button", "aria-label": t("agentPanel.closeTab"), onClick: (e) => {
|
|
844
844
|
e.stopPropagation();
|
|
@@ -881,7 +881,7 @@ function AgentPanelInner({ defaultMode = "chat", className, style, apiUrl, empty
|
|
|
881
881
|
const isActive = tab.id === activeTabId ||
|
|
882
882
|
(tab.id === focusParentId &&
|
|
883
883
|
activeTab?.parentThreadId === tab.id);
|
|
884
|
-
return (_jsxs("div", { role: "button", tabIndex: 0, ref: isActive ? activeTabRefCb : undefined, onClick: () => setActiveTabId(tab.id), onKeyDown: activateOnKeyDown(() => setActiveTabId(tab.id)), className: cn("agent-tab relative flex shrink-0 items-center gap-1 rounded-md px-2.5 py-1.5 text-[11px] font-medium cursor-pointer max-w-[150px]", isActive
|
|
884
|
+
return (_jsxs("div", { role: "button", tabIndex: 0, ref: isActive ? activeTabRefCb : undefined, onClick: () => setActiveTabId(tab.id), onKeyDown: activateOnKeyDown(() => setActiveTabId(tab.id)), className: cn("agent-tab relative flex shrink-0 items-center gap-1 rounded-md px-2.5 py-1.5 text-[11px] font-medium cursor-pointer min-w-[56px] max-w-[150px]", isActive
|
|
885
885
|
? "bg-accent text-foreground"
|
|
886
886
|
: "text-muted-foreground hover:bg-accent hover:text-foreground"), children: [_jsx("span", { className: "truncate pe-1", children: tab.label }), tab.status === "running" && (_jsx("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full bg-muted-foreground/50 animate-pulse" })), _jsx("button", { type: "button", "aria-label": t("agentPanel.closeTab"), onClick: (e) => {
|
|
887
887
|
e.stopPropagation();
|
|
@@ -899,7 +899,7 @@ function AgentPanelInner({ defaultMode = "chat", className, style, apiUrl, empty
|
|
|
899
899
|
})
|
|
900
900
|
: cliTabs.map((id, i) => (_jsxs("div", { role: "button", tabIndex: 0, ref: id === activeCliTab
|
|
901
901
|
? activeTabRefCb
|
|
902
|
-
: undefined, onClick: () => setActiveCliTab(id), onKeyDown: activateOnKeyDown(() => setActiveCliTab(id)), className: cn("agent-tab relative flex shrink-0 items-center gap-1 rounded-md px-2.5 py-1.5 text-[11px] font-medium cursor-pointer", id === activeCliTab
|
|
902
|
+
: undefined, onClick: () => setActiveCliTab(id), onKeyDown: activateOnKeyDown(() => setActiveCliTab(id)), className: cn("agent-tab relative flex shrink-0 items-center gap-1 rounded-md px-2.5 py-1.5 text-[11px] font-medium cursor-pointer min-w-[56px]", id === activeCliTab
|
|
903
903
|
? "bg-accent text-foreground"
|
|
904
904
|
: "text-muted-foreground hover:bg-accent hover:text-foreground"), children: [_jsxs("span", { children: ["Terminal ", i + 1] }), _jsx("button", { type: "button", "aria-label": t("agentPanel.closeTab"), onClick: (e) => {
|
|
905
905
|
e.stopPropagation();
|
|
@@ -917,7 +917,7 @@ function AgentPanelInner({ defaultMode = "chat", className, style, apiUrl, empty
|
|
|
917
917
|
? "bg-accent text-foreground"
|
|
918
918
|
: "text-muted-foreground hover:bg-accent hover:text-foreground"), children: "Main" }), childTabs.map((tab) => (_jsxs("div", { role: "button", tabIndex: 0, ref: tab.id === activeTabId
|
|
919
919
|
? activeTabRefCb
|
|
920
|
-
: undefined, onClick: () => setActiveTabId(tab.id), onKeyDown: activateOnKeyDown(() => setActiveTabId(tab.id)), className: cn("agent-tab relative flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium cursor-pointer max-w-[140px]", tab.id === activeTabId
|
|
920
|
+
: undefined, onClick: () => setActiveTabId(tab.id), onKeyDown: activateOnKeyDown(() => setActiveTabId(tab.id)), className: cn("agent-tab relative flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium cursor-pointer min-w-[48px] max-w-[140px]", tab.id === activeTabId
|
|
921
921
|
? "bg-accent text-foreground"
|
|
922
922
|
: "text-muted-foreground hover:bg-accent hover:text-foreground"), children: [_jsx("span", { className: "truncate pe-1", children: tab.subAgentName || tab.label }), tab.status === "running" && (_jsx("span", { className: "h-1 w-1 shrink-0 rounded-full bg-muted-foreground/50 animate-pulse" })), _jsx("button", { type: "button", "aria-label": t("agentPanel.closeTab"), onClick: (e) => {
|
|
923
923
|
e.stopPropagation();
|
|
@@ -981,7 +981,7 @@ function AgentPanelInner({ defaultMode = "chat", className, style, apiUrl, empty
|
|
|
981
981
|
`margin-left:auto;margin-right:auto;width:100%;}`,
|
|
982
982
|
} }), SHOW_ONBOARDING && mounted && (_jsx(Suspense, { fallback: null, children: _jsx(OnboardingPanel, {}) })), showFirstRunOnboarding && mounted && !insideAgentSidebar && (_jsx(Suspense, { fallback: null, children: _jsx(FirstRunOnboarding, {}) })), _jsx("div", { className: cn("flex flex-col min-h-0", mode === "chat" ? "flex-1" : "shrink-0"), children: mounted && (_jsx(Suspense, { fallback: _jsx(ChatLoadingSkeleton, { renderHeader: showHeader ? renderChatHeader : undefined, centerComposerWhenEmpty: assistantChatProps.centerComposerWhenEmpty, composerSlot: assistantChatProps.composerSlot, composerAreaClassName: assistantChatProps.composerAreaClassName, composerLayoutVariant: assistantChatProps.composerLayoutVariant }), children: _jsx(MultiTabAssistantChatLazy, { ...assistantChatProps, agentChatSurface: effectiveAgentChatSurface, apiUrl: apiUrl, showHeader: false, renderHeader: showHeader ? renderChatHeader : undefined, showTabBar: showTabBar, renderOverlay: showPageNewChatButton && !showHeader
|
|
983
983
|
? renderPageChatOverlay
|
|
984
|
-
: undefined, contentHidden: mode !== "chat", emptyStateText: emptyStateText, emptyStateAddon: emptyStateAddon, suggestions: suggestions, dynamicSuggestions: dynamicSuggestions, onSwitchToCli: () => switchMode("cli"), execMode: execMode, onExecModeChange: switchExecMode, storageKey: storageKey, restoreActiveThread: restoreActiveThread, scope: scope, showScopeBadge: showScopeBadge, browserTabId: browserTabId, threadUrlSync: threadUrlSync }) })) }), canUseCodeTools
|
|
984
|
+
: undefined, contentHidden: mode !== "chat", emptyStateText: emptyStateText, emptyStateAddon: emptyStateAddon, suggestions: suggestions, dynamicSuggestions: dynamicSuggestions, onSwitchToCli: () => switchMode("cli"), execMode: execMode, onExecModeChange: switchExecMode, storageKey: storageKey, restoreActiveThread: restoreActiveThread, scope: scope, isolateHistoryByScope: isolateHistoryByScope, showScopeBadge: showScopeBadge, browserTabId: browserTabId, threadUrlSync: threadUrlSync }) })) }), canUseCodeTools
|
|
985
985
|
? mode === "cli" &&
|
|
986
986
|
cliTabs.map((id) => (_jsx("div", { className: "min-h-0 relative flex-1", style: {
|
|
987
987
|
display: id === activeCliTab ? undefined : "none",
|
|
@@ -1418,7 +1418,7 @@ export function AgentChatSurface({ mode = "panel", className, defaultMode = "cha
|
|
|
1418
1418
|
* Wraps app content with a toggleable agent sidebar.
|
|
1419
1419
|
* Use AgentToggleButton in your header to open/close it.
|
|
1420
1420
|
*/
|
|
1421
|
-
export function AgentSidebar({ children, emptyStateText = "How can I help you?", suggestions, dynamicSuggestions, composerToolbarSlot, composerSlot, onComposerTextChange, imageModelMenu, availableAgents, availableModels, modelListLoading, selectedAgent, onAgentChange, onConnectLocalRuntime, runtime, adapterReloadKey, threadFooterSlot, defaultSidebarWidth, sidebarWidth, position = "right", defaultOpen = false, animateMobile = true, animateDesktop = true, chatViewTransition = false, chatViewTransitionHandoff = false, storageKey, openStorageKey, apiUrl, agentChatSurface, desktopIdentityUnauthenticated, desktopIdentityAuthenticated, showTabBar = true, suppressInlineOpenApp, composerPlaceholder, openOnChatRunning = false, onFullscreenRequest, scope, showScopeBadge, browserTabId, threadUrlSync, agentPageHref, suppressFirstRunOnboarding = false, }) {
|
|
1421
|
+
export function AgentSidebar({ children, emptyStateText = "How can I help you?", suggestions, dynamicSuggestions, composerToolbarSlot, composerSlot, onComposerTextChange, imageModelMenu, availableAgents, availableModels, modelListLoading, selectedAgent, onAgentChange, onConnectLocalRuntime, runtime, adapterReloadKey, threadFooterSlot, defaultSidebarWidth, sidebarWidth, position = "right", defaultOpen = false, animateMobile = true, animateDesktop = true, chatViewTransition = false, chatViewTransitionHandoff = false, storageKey, openStorageKey, apiUrl, agentChatSurface, desktopIdentityUnauthenticated, desktopIdentityAuthenticated, showTabBar = true, suppressInlineOpenApp, composerPlaceholder, openOnChatRunning = false, onFullscreenRequest, scope, isolateHistoryByScope = false, showScopeBadge, browserTabId, threadUrlSync, agentPageHref, suppressFirstRunOnboarding = false, }) {
|
|
1422
1422
|
const staticHostedHarnessEnabled = isHostedHarnessConfigured(injectedAgentNativeConfig().harness);
|
|
1423
1423
|
const hostedHarnessQuery = useActionQuery("get-hosted-harness-config", undefined, { enabled: staticHostedHarnessEnabled });
|
|
1424
1424
|
const hostedHarnessStatus = hostedHarnessQuery.data;
|
|
@@ -2059,7 +2059,7 @@ export function AgentSidebar({ children, emptyStateText = "How can I help you?",
|
|
|
2059
2059
|
? "desktop"
|
|
2060
2060
|
: undefined, "data-agent-sidebar-layout": panelLayout, "data-agent-sidebar-position": effectivePosition, "data-agent-native-hosted-harness-ui": hostedHarnessUi ? "desktop" : undefined, "data-agent-sidebar-state": panelOpen ? "open" : "closed", "data-agent-sidebar-per-app-chat": isPerAppChatSidebar ? "true" : undefined, "data-agent-sidebar-resizing": isResizing ? "true" : undefined, "data-agent-sidebar-chat-handoff": chatViewTransitionHandoff ? "true" : undefined, style: chatViewTransition
|
|
2061
2061
|
? getAgentChatViewTransitionStyle(panelStyle)
|
|
2062
|
-
: panelStyle, inert: sidebarAnimationEnabled && !panelOpen ? true : undefined, "aria-hidden": sidebarAnimationEnabled && !panelOpen ? true : undefined, children: _jsx("div", { className: "agent-sidebar-panel-inner flex min-h-0 flex-1 flex-col", children: _jsx(AgentPanel, { emptyStateText: emptyStateText, suggestions: suggestions, dynamicSuggestions: dynamicSuggestions, composerToolbarSlot: composerToolbarSlot, composerSlot: composerSlot, onComposerTextChange: onComposerTextChange, imageModelMenu: imageModelMenu, availableAgents: effectiveAvailableAgents, availableModels: availableModels, modelListLoading: modelListLoading, selectedAgent: effectiveSelectedAgent, onAgentChange: effectiveOnAgentChange, hostedHarness: hostedHarnessEnabled, onConnectLocalRuntime: onConnectLocalRuntime, runtime: runtime, adapterReloadKey: adapterReloadKey, threadFooterSlot: threadFooterSlot, apiUrl: apiUrl, agentChatSurface: agentChatSurface, desktopIdentityUnauthenticated: desktopIdentityUnauthenticated, desktopIdentityAuthenticated: desktopIdentityAuthenticated, showTabBar: effectiveShowTabBar, suppressInlineOpenApp: suppressInlineOpenApp, composerPlaceholder: composerPlaceholder, missingApiKeySetupLayout: "sidebar", onCollapse: () => setOpenPersisted(false), onSnapTo75Percent: isMobile ? undefined : snapTo75Percent, isWideDrawer: isMobile ? false : isWideDrawer, onExitWideDrawer: isMobile ? undefined : exitWideDrawer, onFullViewRequest: onFullscreenRequest, storageKey: storageKey, scope: scope, showScopeBadge: showScopeBadge, browserTabId: browserTabId, threadUrlSync: threadUrlSync, agentPageHref: agentPageHref, allowSettingsMode: false, chatOnly: true }) }) }), showResizeHandle && isLeft && (_jsx(ResizeHandle, { position: effectivePosition, onDrag: handleDrag, onResizeStart: handleResizeStart, onResizeEnd: handleResizeEnd }))] })) : null;
|
|
2062
|
+
: panelStyle, inert: sidebarAnimationEnabled && !panelOpen ? true : undefined, "aria-hidden": sidebarAnimationEnabled && !panelOpen ? true : undefined, children: _jsx("div", { className: "agent-sidebar-panel-inner flex min-h-0 flex-1 flex-col", children: _jsx(AgentPanel, { emptyStateText: emptyStateText, suggestions: suggestions, dynamicSuggestions: dynamicSuggestions, composerToolbarSlot: composerToolbarSlot, composerSlot: composerSlot, onComposerTextChange: onComposerTextChange, imageModelMenu: imageModelMenu, availableAgents: effectiveAvailableAgents, availableModels: availableModels, modelListLoading: modelListLoading, selectedAgent: effectiveSelectedAgent, onAgentChange: effectiveOnAgentChange, hostedHarness: hostedHarnessEnabled, onConnectLocalRuntime: onConnectLocalRuntime, runtime: runtime, adapterReloadKey: adapterReloadKey, threadFooterSlot: threadFooterSlot, apiUrl: apiUrl, agentChatSurface: agentChatSurface, desktopIdentityUnauthenticated: desktopIdentityUnauthenticated, desktopIdentityAuthenticated: desktopIdentityAuthenticated, showTabBar: effectiveShowTabBar, suppressInlineOpenApp: suppressInlineOpenApp, composerPlaceholder: composerPlaceholder, missingApiKeySetupLayout: "sidebar", onCollapse: () => setOpenPersisted(false), onSnapTo75Percent: isMobile ? undefined : snapTo75Percent, isWideDrawer: isMobile ? false : isWideDrawer, onExitWideDrawer: isMobile ? undefined : exitWideDrawer, onFullViewRequest: onFullscreenRequest, storageKey: storageKey, scope: scope, isolateHistoryByScope: isolateHistoryByScope, showScopeBadge: showScopeBadge, browserTabId: browserTabId, threadUrlSync: threadUrlSync, agentPageHref: agentPageHref, allowSettingsMode: false, chatOnly: true }) }) }), showResizeHandle && isLeft && (_jsx(ResizeHandle, { position: effectivePosition, onDrag: handleDrag, onResizeStart: handleResizeStart, onResizeEnd: handleResizeEnd }))] })) : null;
|
|
2063
2063
|
const drawerPlaceholder = wideDrawerEnabled && !presentationMode && panelOpen ? (_jsx("div", { "aria-hidden": "true", className: "agent-sidebar-drawer-placeholder shrink-0", "data-agent-sidebar-placeholder": "true", style: { width: drawerPlaceholderWidth + 1 } })) : null;
|
|
2064
2064
|
return (_jsx(AgentSidebarOnboardingContext.Provider, { value: true, children: _jsxs(RealtimeVoiceModeProvider, { browserTabId: browserTabId, children: [showFirstRunOnboarding && (_jsx(Suspense, { fallback: null, children: _jsx(FirstRunOnboarding, {}) })), _jsxs("div", { className: "agent-sidebar-shell flex min-w-0 flex-1 h-screen overflow-hidden", "data-agent-sidebar-position": effectivePosition, "data-agent-native-hosted-harness-ui": hostedHarnessUi ? "desktop" : undefined, "data-agent-native-hosted-chat": isPerAppChatHosted ? "true" : undefined, "data-agent-sidebar-resizing": isResizing ? "true" : undefined, children: [isMobile &&
|
|
2065
2065
|
!isPerAppChatHosted &&
|
|
@@ -11,7 +11,7 @@ import { type AgentChatRuntime } from "./chat/runtime.js";
|
|
|
11
11
|
import { type AgentComposerLayoutVariant, type ComposerSubmitIntent, type Reference } from "./composer/index.js";
|
|
12
12
|
import { type AgentDynamicSuggestionsOption } from "./dynamic-suggestions.js";
|
|
13
13
|
import { type ContentPart } from "./sse-event-processor.js";
|
|
14
|
-
import type
|
|
14
|
+
import { type ChatThreadScope, type ChatThreadSnapshot } from "./use-chat-threads.js";
|
|
15
15
|
export { AssistantMessageListErrorBoundary, AssistantUiStaleIndexErrorBoundary, assistantUiRecoverableRenderErrorKind, isAssistantUiRecoverableRenderError, isAssistantUiStaleIndexError, } from "./assistant-ui-recovery.js";
|
|
16
16
|
export { displayableUserMessageText } from "./chat/message-components.js";
|
|
17
17
|
export declare function shouldSuppressUnauthenticatedDesktopThreadRestore(surface: AgentChatSurfaceKind, status: number, desktopIdentityUnauthenticated?: boolean): boolean;
|
|
@@ -269,6 +269,8 @@ export interface AssistantChatProps {
|
|
|
269
269
|
threadId?: string;
|
|
270
270
|
/** Resource scope to include with chat requests for server-side context. */
|
|
271
271
|
contextScope?: ChatThreadScope | null;
|
|
272
|
+
/** Restrict server-side thread restores to the supplied app scope. */
|
|
273
|
+
isolateHistoryByScope?: boolean;
|
|
272
274
|
/** Namespace used to hide ambient composer context from other host surfaces. */
|
|
273
275
|
contextNamespace?: string;
|
|
274
276
|
/** Whether this chat owns the active visible composer context snapshot. */
|
|
@@ -39,6 +39,7 @@ import { McpConnectionSuggestion } from "./resources/McpConnectionSuggestion.js"
|
|
|
39
39
|
import { claimRunStream, createRunStreamToken, ownsRunStream, releaseRunStream, } from "./run-stream-ownership.js";
|
|
40
40
|
import { AgentAutoContinueSignal, readSSEStreamRaw, settleInterruptedToolCalls, } from "./sse-event-processor.js";
|
|
41
41
|
import { useAgentEngineConfigured } from "./use-agent-engine-configured.js";
|
|
42
|
+
import { appendChatThreadScopeParams, } from "./use-chat-threads.js";
|
|
42
43
|
import { useDevMode } from "./use-dev-mode.js";
|
|
43
44
|
import { useRunStuckDetection } from "./use-run-stuck-detection.js";
|
|
44
45
|
import { cn } from "./utils.js";
|
|
@@ -1386,7 +1387,7 @@ function approvalResolutionIdentity(approvalKey, toolCallId,
|
|
|
1386
1387
|
askId) {
|
|
1387
1388
|
return `${toolCallId ?? ""}\u0000${approvalKey}\u0000${askId ?? ""}`;
|
|
1388
1389
|
}
|
|
1389
|
-
const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateText, suggestions, dynamicSuggestions, threadFooterSlot, emptyStateAddon, showHeader = true, onSwitchToCli, className, apiUrl, tabId, browserTabId, threadId, contextScope, contextNamespace, isActiveComposer = true, onMessageCountChange, onSaveThread, onGenerateTitle, composerSlot, onComposerTextChange, composerAreaClassName, composerPlaceholder, missingApiKeySetupLayout = "default", composerLayoutVariant = "default", centerComposerWhenEmpty = false, emptyStateDisplay = "default", composerToolbarSlot, composerExtraActionButton, showModelSelector = true, composerDisabled = false, composerDisabledPlaceholder, isNewThread, isThreadStateLoading, onSlashCommand, execMode, onExecModeChange, approvalActions, planModeDisabled, planModeDisabledReason, selectedModel, defaultModel, selectedEngine, selectedEffort, availableModels, modelListLoading, onModelChange, onEffortChange, availableAgents, selectedAgent, hostedHarness, onAgentChange, imageModelMenu, onForkChat, onConnectProvider, onConnectLocalRuntime, plusMenuMode = "full", providerStatusChecksEnabled = true, loadHistoryRepository, historyReloadKey, externalStreaming = false, agentChatSurface = "app", desktopIdentityUnauthenticated = false, desktopIdentityAuthenticated = false, suppressInlineOpenApp = false, }, ref) {
|
|
1390
|
+
const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateText, suggestions, dynamicSuggestions, threadFooterSlot, emptyStateAddon, showHeader = true, onSwitchToCli, className, apiUrl, tabId, browserTabId, threadId, contextScope, isolateHistoryByScope = false, contextNamespace, isActiveComposer = true, onMessageCountChange, onSaveThread, onGenerateTitle, composerSlot, onComposerTextChange, composerAreaClassName, composerPlaceholder, missingApiKeySetupLayout = "default", composerLayoutVariant = "default", centerComposerWhenEmpty = false, emptyStateDisplay = "default", composerToolbarSlot, composerExtraActionButton, showModelSelector = true, composerDisabled = false, composerDisabledPlaceholder, isNewThread, isThreadStateLoading, onSlashCommand, execMode, onExecModeChange, approvalActions, planModeDisabled, planModeDisabledReason, selectedModel, defaultModel, selectedEngine, selectedEffort, availableModels, modelListLoading, onModelChange, onEffortChange, availableAgents, selectedAgent, hostedHarness, onAgentChange, imageModelMenu, onForkChat, onConnectProvider, onConnectLocalRuntime, plusMenuMode = "full", providerStatusChecksEnabled = true, loadHistoryRepository, historyReloadKey, externalStreaming = false, agentChatSurface = "app", desktopIdentityUnauthenticated = false, desktopIdentityAuthenticated = false, suppressInlineOpenApp = false, }, ref) {
|
|
1390
1391
|
const t = useT();
|
|
1391
1392
|
const thread = useThread();
|
|
1392
1393
|
const threadRuntime = useThreadRuntime();
|
|
@@ -1418,6 +1419,14 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1418
1419
|
enabled: messages.length === 0,
|
|
1419
1420
|
});
|
|
1420
1421
|
const messageListResetKey = useMemo(() => assistantUiMessageListStructureKey(messages), [messages]);
|
|
1422
|
+
const threadScopeQuery = useMemo(() => {
|
|
1423
|
+
if (!isolateHistoryByScope || !contextScope)
|
|
1424
|
+
return "";
|
|
1425
|
+
const params = new URLSearchParams();
|
|
1426
|
+
appendChatThreadScopeParams(params, contextScope);
|
|
1427
|
+
const query = params.toString();
|
|
1428
|
+
return query ? `?${query}` : "";
|
|
1429
|
+
}, [contextScope?.id, contextScope?.type, isolateHistoryByScope]);
|
|
1421
1430
|
// Chat-wide drag-and-drop: users expect to drop a file anywhere on the agent
|
|
1422
1431
|
// sidebar (thread, header, composer) and have it attach — same as ChatGPT,
|
|
1423
1432
|
// Claude.ai, Linear, Slack, etc. Tiptap's own `handleDrop` only fires inside
|
|
@@ -1989,7 +1998,7 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1989
1998
|
? setTimeout(() => ownAbort.abort(), getPollAbortMs(2000))
|
|
1990
1999
|
: null;
|
|
1991
2000
|
try {
|
|
1992
|
-
const refreshRes = await fetch(`${apiUrl}/threads/${encodeURIComponent(threadId)}`, { signal: signal ?? ownAbort?.signal });
|
|
2001
|
+
const refreshRes = await fetch(`${apiUrl}/threads/${encodeURIComponent(threadId)}${threadScopeQuery}`, { signal: signal ?? ownAbort?.signal });
|
|
1993
2002
|
if (!refreshRes.ok)
|
|
1994
2003
|
return null;
|
|
1995
2004
|
const refreshData = await refreshRes.json();
|
|
@@ -2006,7 +2015,13 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
2006
2015
|
if (ownAbortTimer)
|
|
2007
2016
|
clearTimeout(ownAbortTimer);
|
|
2008
2017
|
}
|
|
2009
|
-
}, [
|
|
2018
|
+
}, [
|
|
2019
|
+
apiUrl,
|
|
2020
|
+
importThreadData,
|
|
2021
|
+
loadHistoryRepository,
|
|
2022
|
+
threadId,
|
|
2023
|
+
threadScopeQuery,
|
|
2024
|
+
]);
|
|
2010
2025
|
const exportCleanThreadRepo = useCallback(() => ensureMessageMetadata(normalizeThreadRepository(threadRuntime.export())), [threadRuntime]);
|
|
2011
2026
|
const exportPersistableThreadRepo = useCallback(() => withLastAssistantRunDuration(exportCleanThreadRepo(), showRunningInUI ? null : lastChatRunDurationMs), [exportCleanThreadRepo, lastChatRunDurationMs, showRunningInUI]);
|
|
2012
2027
|
useEffect(() => {
|
|
@@ -2698,7 +2713,7 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
2698
2713
|
(async () => {
|
|
2699
2714
|
let canReconnect = false;
|
|
2700
2715
|
try {
|
|
2701
|
-
const res = await fetch(`${apiUrl}/threads/${encodeURIComponent(threadId)}`);
|
|
2716
|
+
const res = await fetch(`${apiUrl}/threads/${encodeURIComponent(threadId)}${threadScopeQuery}`);
|
|
2702
2717
|
if (!res.ok) {
|
|
2703
2718
|
if (!cancelled) {
|
|
2704
2719
|
setThreadRestoreError(shouldSuppressUnauthenticatedDesktopThreadRestore(agentChatSurface, res.status, desktopIdentityUnauthenticated)
|
|
@@ -2811,6 +2826,7 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
2811
2826
|
isThreadStateLoading,
|
|
2812
2827
|
desktopIdentityUnauthenticated,
|
|
2813
2828
|
restoreAttempt,
|
|
2829
|
+
threadScopeQuery,
|
|
2814
2830
|
]);
|
|
2815
2831
|
useEffect(() => {
|
|
2816
2832
|
if (!loadHistoryRepository ||
|
|
@@ -2992,7 +3008,7 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
2992
3008
|
const timer = setTimeout(() => {
|
|
2993
3009
|
(async () => {
|
|
2994
3010
|
try {
|
|
2995
|
-
const res = await fetch(`${apiUrl}/threads/${encodeURIComponent(threadId)}/queued`, {
|
|
3011
|
+
const res = await fetch(`${apiUrl}/threads/${encodeURIComponent(threadId)}/queued${threadScopeQuery}`, {
|
|
2996
3012
|
method: "POST",
|
|
2997
3013
|
headers: { "Content-Type": "application/json" },
|
|
2998
3014
|
body: JSON.stringify({ queuedMessages }),
|
|
@@ -3010,7 +3026,7 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
3010
3026
|
})();
|
|
3011
3027
|
}, 300);
|
|
3012
3028
|
return () => clearTimeout(timer);
|
|
3013
|
-
}, [queuedMessages, threadId, apiUrl]);
|
|
3029
|
+
}, [queuedMessages, threadId, apiUrl, threadScopeQuery]);
|
|
3014
3030
|
// Nudge the shared hook to re-check after a Builder connect.
|
|
3015
3031
|
const handleBuilderConnected = useCallback(() => {
|
|
3016
3032
|
focusComposerAfterConnectRef.current = true;
|
|
@@ -64,9 +64,11 @@ export type MultiTabAssistantChatProps = Omit<AssistantChatProps, "tabId" | "thr
|
|
|
64
64
|
threadUrlSync?: boolean | ChatThreadUrlSyncOptions;
|
|
65
65
|
/** Ambient resource context to show as a composer chip. */
|
|
66
66
|
scope?: ChatThreadScope | null;
|
|
67
|
+
/** Keep app-owned chat history isolated to the supplied scope. */
|
|
68
|
+
isolateHistoryByScope?: boolean;
|
|
67
69
|
/** @deprecated Scope context is now rendered in the composer. */
|
|
68
70
|
showScopeBadge?: boolean;
|
|
69
71
|
/** Cadence for hydrating agent-team sub-agent tab status. Default: 3000. */
|
|
70
72
|
agentTeamPollMs?: number;
|
|
71
73
|
};
|
|
72
|
-
export declare function MultiTabAssistantChat({ showTabBar, renderHeader, renderOverlay, contentHidden, apiUrl, storageKey, restoreActiveThread, browserTabId, threadUrlSync, scope, agentTeamPollMs, ...props }: MultiTabAssistantChatProps): React.JSX.Element;
|
|
74
|
+
export declare function MultiTabAssistantChat({ showTabBar, renderHeader, renderOverlay, contentHidden, apiUrl, storageKey, restoreActiveThread, browserTabId, threadUrlSync, scope, isolateHistoryByScope, agentTeamPollMs, ...props }: MultiTabAssistantChatProps): React.JSX.Element;
|
|
@@ -402,7 +402,7 @@ function runToAgentTeamTabInfo(run) {
|
|
|
402
402
|
status: run.status ?? "unknown",
|
|
403
403
|
};
|
|
404
404
|
}
|
|
405
|
-
export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderOverlay, contentHidden = false, apiUrl = agentNativePath("/_agent-native/agent-chat"), storageKey, restoreActiveThread = true, browserTabId, threadUrlSync = false, scope = null, agentTeamPollMs = DEFAULT_AGENT_TEAM_POLL_MS, ...props }) {
|
|
405
|
+
export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderOverlay, contentHidden = false, apiUrl = agentNativePath("/_agent-native/agent-chat"), storageKey, restoreActiveThread = true, browserTabId, threadUrlSync = false, scope = null, isolateHistoryByScope = false, agentTeamPollMs = DEFAULT_AGENT_TEAM_POLL_MS, ...props }) {
|
|
406
406
|
const translate = useT();
|
|
407
407
|
const contextNamespace = scope
|
|
408
408
|
? scope.contextKey?.trim() || `scope:${scope.type}:${scope.id}`
|
|
@@ -520,6 +520,7 @@ export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderO
|
|
|
520
520
|
routeThreadId: threadUrlSyncEnabled
|
|
521
521
|
? urlThreadId
|
|
522
522
|
: (activeDeepLinkedThreadId ?? undefined),
|
|
523
|
+
isolateHistoryByScope,
|
|
523
524
|
});
|
|
524
525
|
const switchThread = useCallback((threadId, options = {}) => {
|
|
525
526
|
switchThreadState(threadId);
|
|
@@ -1911,7 +1912,7 @@ export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderO
|
|
|
1911
1912
|
const isActive = tab.id === activeThreadId ||
|
|
1912
1913
|
(tab.id === focusParentId &&
|
|
1913
1914
|
activeTab?.parentThreadId === tab.id);
|
|
1914
|
-
return (_jsxs("div", { ref: isActive ? activeTabRefCb : undefined, className: cn("agent-tab relative flex items-center rounded-md text-[11px] font-medium shrink-0 max-w-[130px]", isActive
|
|
1915
|
+
return (_jsxs("div", { ref: isActive ? activeTabRefCb : undefined, className: cn("agent-tab relative flex items-center rounded-md text-[11px] font-medium shrink-0 min-w-[56px] max-w-[130px]", isActive
|
|
1915
1916
|
? "bg-accent text-foreground ring-1 ring-inset ring-border/60 shadow-sm"
|
|
1916
1917
|
: "text-muted-foreground hover:text-foreground hover:bg-accent/50"), children: [_jsxs("button", { type: "button", onClick: () => switchThread(tab.id), className: "flex items-center gap-1 px-2.5 py-1.5 min-w-0 flex-1 text-start", children: [_jsx("span", { className: "truncate pe-1", children: tab.label }), tab.status === "running" && (_jsx("span", { className: "w-1.5 h-1.5 rounded-full bg-muted-foreground/50 shrink-0 animate-pulse" }))] }), _jsx("button", { type: "button", "aria-label": translate("agentChat.tabs.closeTab"), onClick: (e) => {
|
|
1917
1918
|
e.stopPropagation();
|
|
@@ -1931,7 +1932,7 @@ export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderO
|
|
|
1931
1932
|
? "bg-accent text-foreground"
|
|
1932
1933
|
: "text-muted-foreground hover:bg-accent hover:text-foreground"), children: translate("agentChat.tabs.main") }), childTabs.map((tab) => (_jsxs("div", { ref: tab.id === activeThreadId
|
|
1933
1934
|
? activeTabRefCb
|
|
1934
|
-
: undefined, className: cn("agent-tab relative flex shrink-0 items-center rounded-md text-[10px] font-medium max-w-[130px]", tab.id === activeThreadId
|
|
1935
|
+
: undefined, className: cn("agent-tab relative flex shrink-0 items-center rounded-md text-[10px] font-medium min-w-[48px] max-w-[130px]", tab.id === activeThreadId
|
|
1935
1936
|
? "bg-accent text-foreground"
|
|
1936
1937
|
: "text-muted-foreground hover:bg-accent hover:text-foreground"), children: [_jsxs("button", { type: "button", onClick: () => switchThread(tab.id), className: "flex items-center gap-1 px-2 py-1 min-w-0 flex-1 text-start", children: [_jsx("span", { className: "truncate pe-1", children: tab.subAgentName || tab.label }), tab.status === "running" && (_jsx("span", { className: "w-1 h-1 rounded-full bg-muted-foreground/50 shrink-0 animate-pulse" }))] }), _jsx("button", { type: "button", "aria-label": translate("agentChat.tabs.closeTab"), onClick: (e) => {
|
|
1937
1938
|
e.stopPropagation();
|
|
@@ -1969,7 +1970,7 @@ export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderO
|
|
|
1969
1970
|
else {
|
|
1970
1971
|
chatRefs.current.delete(tabId);
|
|
1971
1972
|
}
|
|
1972
|
-
}, threadId: tabId, tabId: tabId, browserTabId: browserTabId, contextNamespace: contextNamespace, isActiveComposer: tabId === activeThreadId, apiUrl: apiUrl, isNewThread: newThreadIds.current.has(tabId) || isNewThread(tabId), isThreadStateLoading: isLoading, onMessageCountChange: (count) => setMessageCounts((prev) => prev[tabId] === count
|
|
1973
|
+
}, threadId: tabId, tabId: tabId, browserTabId: browserTabId, contextScope: scope, contextNamespace: contextNamespace, isolateHistoryByScope: isolateHistoryByScope, isActiveComposer: tabId === activeThreadId, apiUrl: apiUrl, isNewThread: newThreadIds.current.has(tabId) || isNewThread(tabId), isThreadStateLoading: isLoading, onMessageCountChange: (count) => setMessageCounts((prev) => prev[tabId] === count
|
|
1973
1974
|
? prev
|
|
1974
1975
|
: { ...prev, [tabId]: count }), onSaveThread: handleSaveThread, onGenerateTitle: handleGenerateTitle, onSlashCommand: handleSlashCommand, selectedModel: modelSelection?.model, selectedEngine: modelSelection?.engine, selectedEffort: modelSelection?.effort ?? DEFAULT_REASONING_EFFORT, composerSlot: props.composerSlot, defaultModel: defaultModel, availableModels: availableModels, modelListLoading: modelListLoading, onModelChange: handleModelChange, onEffortChange: handleEffortChange, onForkChat: () => handleForkChat(tabId),
|
|
1975
1976
|
// Sub-agent tabs are read-only: sending a new message from the
|
|
@@ -66,7 +66,14 @@ export interface UseChatThreadsOptions {
|
|
|
66
66
|
routeThreadId?: string | null;
|
|
67
67
|
/** Include connected and other-app chats in list/search results. */
|
|
68
68
|
includeExternal?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Restrict history to the supplied scope. App-owned chat rails use this to
|
|
71
|
+
* keep one app's conversations out of another app's history; ordinary
|
|
72
|
+
* resource scopes intentionally continue to show general chats.
|
|
73
|
+
*/
|
|
74
|
+
isolateHistoryByScope?: boolean;
|
|
69
75
|
}
|
|
76
|
+
export declare function appendChatThreadScopeParams(params: URLSearchParams, scope?: ChatThreadScope | null): void;
|
|
70
77
|
export declare function useChatThreads(apiUrl?: string, storageKey?: string, scope?: ChatThreadScope | null, options?: UseChatThreadsOptions): {
|
|
71
78
|
threads: ChatThreadSummary[];
|
|
72
79
|
activeThreadId: string | null;
|