@agent-native/core 0.11.0 → 0.11.2
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/dist/agent/thread-data-builder.d.ts +1 -0
- package/dist/agent/thread-data-builder.d.ts.map +1 -1
- package/dist/agent/thread-data-builder.js +1 -0
- package/dist/agent/thread-data-builder.js.map +1 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +8 -45
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +76 -16
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/builder-frame.d.ts.map +1 -1
- package/dist/client/builder-frame.js +10 -3
- package/dist/client/builder-frame.js.map +1 -1
- package/dist/client/components/ui/dropdown-menu.js +2 -2
- package/dist/client/components/ui/dropdown-menu.js.map +1 -1
- package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
- package/dist/client/resources/ResourcesPanel.js +6 -6
- package/dist/client/resources/ResourcesPanel.js.map +1 -1
- package/dist/client/settings/useBuilderStatus.d.ts.map +1 -1
- package/dist/client/settings/useBuilderStatus.js +6 -2
- package/dist/client/settings/useBuilderStatus.js.map +1 -1
- package/dist/client/sharing/ShareButton.d.ts +2 -0
- package/dist/client/sharing/ShareButton.d.ts.map +1 -1
- package/dist/client/sharing/ShareButton.js +84 -24
- package/dist/client/sharing/ShareButton.js.map +1 -1
- package/dist/client/use-action.d.ts.map +1 -1
- package/dist/client/use-action.js +1 -0
- package/dist/client/use-action.js.map +1 -1
- package/dist/server/action-routes.d.ts.map +1 -1
- package/dist/server/action-routes.js +1 -0
- package/dist/server/action-routes.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +14 -0
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +77 -12
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/builder-browser.d.ts +8 -6
- package/dist/server/builder-browser.d.ts.map +1 -1
- package/dist/server/builder-browser.js +54 -32
- package/dist/server/builder-browser.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts +7 -0
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +100 -74
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/package.json +1 -1
|
@@ -19,6 +19,7 @@ type AssistantMessage = NonNullable<ReturnType<typeof buildAssistantMessage>>;
|
|
|
19
19
|
*/
|
|
20
20
|
export declare function buildAssistantMessage(events: RunEvent[], runId?: string, options?: BuildAssistantMessageOptions): {
|
|
21
21
|
id: string;
|
|
22
|
+
createdAt: Date;
|
|
22
23
|
role: "assistant";
|
|
23
24
|
content: ContentPart[];
|
|
24
25
|
status: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread-data-builder.d.ts","sourceRoot":"","sources":["../../src/agent/thread-data-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,4BAA4B;IACpC,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACxC;AAED,KAAK,gBAAgB,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC;AAqC9E;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,QAAQ,EAAE,EAClB,KAAK,CAAC,EAAE,MAAM,EACd,OAAO,GAAE,4BAAiC,GACzC;I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pC,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM;YAAE,SAAS;QAClC,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;YAC1C,CAAC,CAAC,GAAG,CAAC,OAAO;iBACR,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC;iBACrC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;iBACvB,IAAI,CAAC,GAAG,CAAC;YACd,CAAC,CAAC,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ;gBAC/B,CAAC,CAAC,GAAG,CAAC,OAAO;gBACb,CAAC,CAAC,EAAE,CAAC;QACT,IAAI,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC;YACrB,IAAI,CAAC,KAAK;gBAAE,KAAK,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAClD,OAAO,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["import type { RunEvent } from \"./types.js\";\n\ninterface ContentPart {\n type: string;\n text?: string;\n toolCallId?: string;\n toolName?: string;\n argsText?: string;\n args?: Record<string, string>;\n result?: string;\n}\n\ninterface BuildAssistantMessageOptions {\n suppressInternalContinuation?: boolean;\n}\n\ntype AssistantMessage = NonNullable<ReturnType<typeof buildAssistantMessage>>;\n\nfunction isInternalContinuationError(event: {\n error: string;\n errorCode?: string;\n recoverable?: boolean;\n}): boolean {\n const code = String(event.errorCode ?? \"\").toLowerCase();\n const msg = event.error.toLowerCase();\n return (\n event.recoverable === true ||\n code === \"builder_gateway_timeout\" ||\n code === \"stale_run\" ||\n code === \"timeout\" ||\n code === \"timeout_error\" ||\n code === \"http_408\" ||\n code === \"http_429\" ||\n code === \"http_500\" ||\n code === \"http_502\" ||\n code === \"http_503\" ||\n code === \"http_504\" ||\n code === \"rate_limited\" ||\n code === \"too_many_concurrent_requests\" ||\n code === \"overloaded_error\" ||\n msg.includes(\"timeout\") ||\n msg.includes(\"gateway timeout\") ||\n msg.includes(\"inactivity timeout\") ||\n msg.includes(\"stream ended\") ||\n msg.includes(\"stream closed\") ||\n msg.includes(\"temporarily unavailable\") ||\n msg.includes(\"502\") ||\n msg.includes(\"503\") ||\n msg.includes(\"504\") ||\n msg.includes(\"529\")\n );\n}\n\n/**\n * Reconstruct an assistant-ui message from raw agent run events.\n * Mirrors the client-side processEvent logic so the server can persist\n * the assistant's response even if the frontend is disconnected.\n */\nexport function buildAssistantMessage(\n events: RunEvent[],\n runId?: string,\n options: BuildAssistantMessageOptions = {},\n): {\n id: string;\n role: \"assistant\";\n content: ContentPart[];\n status:\n | { type: \"complete\"; reason: \"stop\" }\n | { type: \"incomplete\"; reason: \"error\" };\n metadata: Record<string, unknown>;\n} | null {\n const content: ContentPart[] = [];\n let toolCallCounter = 0;\n let runError: {\n message: string;\n errorCode?: string;\n details?: string;\n recoverable?: boolean;\n } | null = null;\n let endedAtInternalContinuationBoundary = false;\n\n const appendText = (text: string) => {\n const last = content[content.length - 1];\n if (last && last.type === \"text\") {\n last.text = (last.text ?? \"\") + text;\n } else {\n content.push({ type: \"text\", text });\n }\n };\n\n for (const { event } of events) {\n if (event.type === \"clear\") {\n content.length = 0;\n toolCallCounter = 0;\n continue;\n }\n\n if (event.type === \"text\") {\n appendText(event.text ?? \"\");\n continue;\n }\n\n if (event.type === \"tool_start\") {\n const toolCallId = `tc_${++toolCallCounter}`;\n const args = (event.input ?? {}) as Record<string, string>;\n content.push({\n type: \"tool-call\",\n toolCallId,\n toolName: event.tool ?? \"unknown\",\n argsText: JSON.stringify(args),\n args,\n });\n continue;\n }\n\n if (event.type === \"tool_done\") {\n for (let i = content.length - 1; i >= 0; i--) {\n const part = content[i];\n if (\n part.type === \"tool-call\" &&\n part.toolName === event.tool &&\n part.result === undefined\n ) {\n part.result = event.result ?? \"\";\n break;\n }\n }\n continue;\n }\n\n if (event.type === \"loop_limit\") {\n // Older servers emitted this as a user-visible terminal event. Treat it\n // as an internal continuation boundary when rebuilding persisted turns.\n if (options.suppressInternalContinuation) {\n endedAtInternalContinuationBoundary = true;\n }\n continue;\n }\n\n if (event.type === \"auto_continue\") {\n if (options.suppressInternalContinuation) {\n endedAtInternalContinuationBoundary = true;\n }\n continue;\n }\n\n if (event.type === \"error\") {\n if (\n options.suppressInternalContinuation &&\n isInternalContinuationError(event)\n ) {\n endedAtInternalContinuationBoundary = true;\n continue;\n }\n if (event.errorCode === \"run_timeout\" && event.recoverable) {\n continue;\n }\n runError = {\n message: event.error,\n ...(event.errorCode ? { errorCode: event.errorCode } : {}),\n ...(event.details ? { details: event.details } : {}),\n ...(event.recoverable ? { recoverable: event.recoverable } : {}),\n };\n appendText(`${content.length > 0 ? \"\\n\\n\" : \"\"}Error: ${event.error}`);\n continue;\n }\n\n // done, missing_api_key — terminal signals, not content\n }\n\n if (content.length === 0 || endedAtInternalContinuationBoundary) return null;\n\n const metadata: Record<string, unknown> = {};\n if (runId) metadata.runId = runId;\n if (runError) {\n metadata.custom = {\n runError: {\n ...runError,\n ...(runId ? { runId } : {}),\n },\n };\n }\n\n return {\n id: `server-${runId ?? Date.now()}`,\n role: \"assistant\",\n content,\n status: runError\n ? { type: \"incomplete\" as const, reason: \"error\" as const }\n : { type: \"complete\" as const, reason: \"stop\" as const },\n metadata,\n };\n}\n\nfunction getStoredMessage(entry: any): any {\n return entry?.message ?? entry;\n}\n\nfunction getMessageRunId(message: any): string | undefined {\n const meta = message?.metadata;\n const direct = meta?.runId;\n const custom = meta?.custom?.runId;\n const errorRun = meta?.custom?.runError?.runId ?? meta?.runError?.runId;\n if (typeof direct === \"string\") return direct;\n if (typeof custom === \"string\") return custom;\n if (typeof errorRun === \"string\") return errorRun;\n return undefined;\n}\n\nfunction messageContentIsEmpty(content: unknown): boolean {\n if (Array.isArray(content)) return content.length === 0;\n return content == null || content === \"\";\n}\n\nfunction messageText(content: unknown): string {\n if (typeof content === \"string\") return content;\n if (!Array.isArray(content)) return \"\";\n return content\n .filter(\n (part: any) => part?.type === \"text\" && typeof part.text === \"string\",\n )\n .map((part: any) => part.text)\n .join(\"\");\n}\n\nfunction isTerminalAssistantStatus(status: unknown): boolean {\n const type = (status as { type?: unknown } | undefined)?.type;\n return type === \"complete\" || type === \"incomplete\";\n}\n\nfunction shouldReplaceLastAssistant(\n lastMessage: any,\n assistantMsg: AssistantMessage,\n): boolean {\n const lastContent = lastMessage?.content;\n if (messageContentIsEmpty(lastContent)) return true;\n\n const lastRunId = getMessageRunId(lastMessage);\n const nextRunId = getMessageRunId(assistantMsg);\n if (lastRunId && nextRunId && lastRunId === nextRunId) return true;\n\n const lastStatus = lastMessage?.status;\n if (lastStatus && !isTerminalAssistantStatus(lastStatus)) return true;\n\n try {\n if (JSON.stringify(lastContent) === JSON.stringify(assistantMsg.content)) {\n return true;\n }\n } catch {\n // Fall through to the text-prefix check.\n }\n\n const lastText = messageText(lastContent).trim();\n const nextText = messageText(assistantMsg.content).trim();\n return Boolean(lastText && nextText && nextText.startsWith(lastText));\n}\n\n/**\n * Merge the server-reconstructed assistant message into persisted\n * assistant-ui thread data.\n *\n * The browser periodically saves thread data while a run is still streaming.\n * That can leave the last assistant message non-empty but partial/pending.\n * Completion must replace that same-run partial message instead of treating\n * any assistant content as proof that the frontend already saved the final\n * turn.\n */\nexport function upsertAssistantMessage(\n repo: any,\n assistantMsg: AssistantMessage,\n): any {\n const nextRepo = repo && typeof repo === \"object\" ? repo : {};\n if (!Array.isArray(nextRepo.messages)) nextRepo.messages = [];\n\n const lastIndex = nextRepo.messages.length - 1;\n const lastEntry = lastIndex >= 0 ? nextRepo.messages[lastIndex] : undefined;\n const lastMsg = getStoredMessage(lastEntry);\n const lastRole = lastMsg?.role;\n const isWrapped = Boolean(lastEntry && \"message\" in lastEntry);\n\n if (\n lastRole === \"assistant\" &&\n shouldReplaceLastAssistant(lastMsg, assistantMsg)\n ) {\n nextRepo.messages[lastIndex] = isWrapped\n ? { ...lastEntry, message: assistantMsg }\n : assistantMsg;\n return nextRepo;\n }\n\n if (isWrapped) {\n const parentId =\n nextRepo.messages.length > 0\n ? (getStoredMessage(nextRepo.messages[nextRepo.messages.length - 1])\n ?.id ?? null)\n : null;\n nextRepo.messages.push({ message: assistantMsg, parentId });\n } else {\n nextRepo.messages.push(assistantMsg);\n }\n return nextRepo;\n}\n\n/**\n * Extract title and preview from a thread runtime export.\n * Isomorphic — works on both server and client.\n */\nexport function extractThreadMeta(repo: any): {\n title: string;\n preview: string;\n} {\n const msgs = repo?.messages;\n if (!Array.isArray(msgs) || msgs.length === 0)\n return { title: \"\", preview: \"\" };\n\n let title = \"\";\n let preview = \"\";\n for (const entry of msgs) {\n // Support both wrapped ({ message: { role, content } }) and flat ({ role, content }) formats\n const msg = entry?.message ?? entry;\n if (msg.role !== \"user\") continue;\n const textParts = Array.isArray(msg.content)\n ? msg.content\n .filter((p: any) => p.type === \"text\")\n .map((p: any) => p.text)\n .join(\" \")\n : typeof msg.content === \"string\"\n ? msg.content\n : \"\";\n if (textParts.trim()) {\n if (!title) title = textParts.trim().slice(0, 80);\n preview = textParts.trim().slice(0, 120);\n }\n }\n return { title, preview };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"thread-data-builder.js","sourceRoot":"","sources":["../../src/agent/thread-data-builder.ts"],"names":[],"mappings":"AAkBA,SAAS,2BAA2B,CAAC,KAIpC;IACC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IACzD,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;IACtC,OAAO,CACL,KAAK,CAAC,WAAW,KAAK,IAAI;Q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AE,OAAO,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["import type { RunEvent } from \"./types.js\";\n\ninterface ContentPart {\n type: string;\n text?: string;\n toolCallId?: string;\n toolName?: string;\n argsText?: string;\n args?: Record<string, string>;\n result?: string;\n}\n\ninterface BuildAssistantMessageOptions {\n suppressInternalContinuation?: boolean;\n}\n\ntype AssistantMessage = NonNullable<ReturnType<typeof buildAssistantMessage>>;\n\nfunction isInternalContinuationError(event: {\n error: string;\n errorCode?: string;\n recoverable?: boolean;\n}): boolean {\n const code = String(event.errorCode ?? \"\").toLowerCase();\n const msg = event.error.toLowerCase();\n return (\n event.recoverable === true ||\n code === \"builder_gateway_timeout\" ||\n code === \"stale_run\" ||\n code === \"timeout\" ||\n code === \"timeout_error\" ||\n code === \"http_408\" ||\n code === \"http_429\" ||\n code === \"http_500\" ||\n code === \"http_502\" ||\n code === \"http_503\" ||\n code === \"http_504\" ||\n code === \"rate_limited\" ||\n code === \"too_many_concurrent_requests\" ||\n code === \"overloaded_error\" ||\n msg.includes(\"timeout\") ||\n msg.includes(\"gateway timeout\") ||\n msg.includes(\"inactivity timeout\") ||\n msg.includes(\"stream ended\") ||\n msg.includes(\"stream closed\") ||\n msg.includes(\"temporarily unavailable\") ||\n msg.includes(\"502\") ||\n msg.includes(\"503\") ||\n msg.includes(\"504\") ||\n msg.includes(\"529\")\n );\n}\n\n/**\n * Reconstruct an assistant-ui message from raw agent run events.\n * Mirrors the client-side processEvent logic so the server can persist\n * the assistant's response even if the frontend is disconnected.\n */\nexport function buildAssistantMessage(\n events: RunEvent[],\n runId?: string,\n options: BuildAssistantMessageOptions = {},\n): {\n id: string;\n createdAt: Date;\n role: \"assistant\";\n content: ContentPart[];\n status:\n | { type: \"complete\"; reason: \"stop\" }\n | { type: \"incomplete\"; reason: \"error\" };\n metadata: Record<string, unknown>;\n} | null {\n const content: ContentPart[] = [];\n let toolCallCounter = 0;\n let runError: {\n message: string;\n errorCode?: string;\n details?: string;\n recoverable?: boolean;\n } | null = null;\n let endedAtInternalContinuationBoundary = false;\n\n const appendText = (text: string) => {\n const last = content[content.length - 1];\n if (last && last.type === \"text\") {\n last.text = (last.text ?? \"\") + text;\n } else {\n content.push({ type: \"text\", text });\n }\n };\n\n for (const { event } of events) {\n if (event.type === \"clear\") {\n content.length = 0;\n toolCallCounter = 0;\n continue;\n }\n\n if (event.type === \"text\") {\n appendText(event.text ?? \"\");\n continue;\n }\n\n if (event.type === \"tool_start\") {\n const toolCallId = `tc_${++toolCallCounter}`;\n const args = (event.input ?? {}) as Record<string, string>;\n content.push({\n type: \"tool-call\",\n toolCallId,\n toolName: event.tool ?? \"unknown\",\n argsText: JSON.stringify(args),\n args,\n });\n continue;\n }\n\n if (event.type === \"tool_done\") {\n for (let i = content.length - 1; i >= 0; i--) {\n const part = content[i];\n if (\n part.type === \"tool-call\" &&\n part.toolName === event.tool &&\n part.result === undefined\n ) {\n part.result = event.result ?? \"\";\n break;\n }\n }\n continue;\n }\n\n if (event.type === \"loop_limit\") {\n // Older servers emitted this as a user-visible terminal event. Treat it\n // as an internal continuation boundary when rebuilding persisted turns.\n if (options.suppressInternalContinuation) {\n endedAtInternalContinuationBoundary = true;\n }\n continue;\n }\n\n if (event.type === \"auto_continue\") {\n if (options.suppressInternalContinuation) {\n endedAtInternalContinuationBoundary = true;\n }\n continue;\n }\n\n if (event.type === \"error\") {\n if (\n options.suppressInternalContinuation &&\n isInternalContinuationError(event)\n ) {\n endedAtInternalContinuationBoundary = true;\n continue;\n }\n if (event.errorCode === \"run_timeout\" && event.recoverable) {\n continue;\n }\n runError = {\n message: event.error,\n ...(event.errorCode ? { errorCode: event.errorCode } : {}),\n ...(event.details ? { details: event.details } : {}),\n ...(event.recoverable ? { recoverable: event.recoverable } : {}),\n };\n appendText(`${content.length > 0 ? \"\\n\\n\" : \"\"}Error: ${event.error}`);\n continue;\n }\n\n // done, missing_api_key — terminal signals, not content\n }\n\n if (content.length === 0 || endedAtInternalContinuationBoundary) return null;\n\n const metadata: Record<string, unknown> = {};\n if (runId) metadata.runId = runId;\n if (runError) {\n metadata.custom = {\n runError: {\n ...runError,\n ...(runId ? { runId } : {}),\n },\n };\n }\n\n return {\n id: `server-${runId ?? Date.now()}`,\n createdAt: new Date(),\n role: \"assistant\",\n content,\n status: runError\n ? { type: \"incomplete\" as const, reason: \"error\" as const }\n : { type: \"complete\" as const, reason: \"stop\" as const },\n metadata,\n };\n}\n\nfunction getStoredMessage(entry: any): any {\n return entry?.message ?? entry;\n}\n\nfunction getMessageRunId(message: any): string | undefined {\n const meta = message?.metadata;\n const direct = meta?.runId;\n const custom = meta?.custom?.runId;\n const errorRun = meta?.custom?.runError?.runId ?? meta?.runError?.runId;\n if (typeof direct === \"string\") return direct;\n if (typeof custom === \"string\") return custom;\n if (typeof errorRun === \"string\") return errorRun;\n return undefined;\n}\n\nfunction messageContentIsEmpty(content: unknown): boolean {\n if (Array.isArray(content)) return content.length === 0;\n return content == null || content === \"\";\n}\n\nfunction messageText(content: unknown): string {\n if (typeof content === \"string\") return content;\n if (!Array.isArray(content)) return \"\";\n return content\n .filter(\n (part: any) => part?.type === \"text\" && typeof part.text === \"string\",\n )\n .map((part: any) => part.text)\n .join(\"\");\n}\n\nfunction isTerminalAssistantStatus(status: unknown): boolean {\n const type = (status as { type?: unknown } | undefined)?.type;\n return type === \"complete\" || type === \"incomplete\";\n}\n\nfunction shouldReplaceLastAssistant(\n lastMessage: any,\n assistantMsg: AssistantMessage,\n): boolean {\n const lastContent = lastMessage?.content;\n if (messageContentIsEmpty(lastContent)) return true;\n\n const lastRunId = getMessageRunId(lastMessage);\n const nextRunId = getMessageRunId(assistantMsg);\n if (lastRunId && nextRunId && lastRunId === nextRunId) return true;\n\n const lastStatus = lastMessage?.status;\n if (lastStatus && !isTerminalAssistantStatus(lastStatus)) return true;\n\n try {\n if (JSON.stringify(lastContent) === JSON.stringify(assistantMsg.content)) {\n return true;\n }\n } catch {\n // Fall through to the text-prefix check.\n }\n\n const lastText = messageText(lastContent).trim();\n const nextText = messageText(assistantMsg.content).trim();\n return Boolean(lastText && nextText && nextText.startsWith(lastText));\n}\n\n/**\n * Merge the server-reconstructed assistant message into persisted\n * assistant-ui thread data.\n *\n * The browser periodically saves thread data while a run is still streaming.\n * That can leave the last assistant message non-empty but partial/pending.\n * Completion must replace that same-run partial message instead of treating\n * any assistant content as proof that the frontend already saved the final\n * turn.\n */\nexport function upsertAssistantMessage(\n repo: any,\n assistantMsg: AssistantMessage,\n): any {\n const nextRepo = repo && typeof repo === \"object\" ? repo : {};\n if (!Array.isArray(nextRepo.messages)) nextRepo.messages = [];\n\n const lastIndex = nextRepo.messages.length - 1;\n const lastEntry = lastIndex >= 0 ? nextRepo.messages[lastIndex] : undefined;\n const lastMsg = getStoredMessage(lastEntry);\n const lastRole = lastMsg?.role;\n const isWrapped = Boolean(lastEntry && \"message\" in lastEntry);\n\n if (\n lastRole === \"assistant\" &&\n shouldReplaceLastAssistant(lastMsg, assistantMsg)\n ) {\n nextRepo.messages[lastIndex] = isWrapped\n ? { ...lastEntry, message: assistantMsg }\n : assistantMsg;\n return nextRepo;\n }\n\n if (isWrapped) {\n const parentId =\n nextRepo.messages.length > 0\n ? (getStoredMessage(nextRepo.messages[nextRepo.messages.length - 1])\n ?.id ?? null)\n : null;\n nextRepo.messages.push({ message: assistantMsg, parentId });\n } else {\n nextRepo.messages.push(assistantMsg);\n }\n return nextRepo;\n}\n\n/**\n * Extract title and preview from a thread runtime export.\n * Isomorphic — works on both server and client.\n */\nexport function extractThreadMeta(repo: any): {\n title: string;\n preview: string;\n} {\n const msgs = repo?.messages;\n if (!Array.isArray(msgs) || msgs.length === 0)\n return { title: \"\", preview: \"\" };\n\n let title = \"\";\n let preview = \"\";\n for (const entry of msgs) {\n // Support both wrapped ({ message: { role, content } }) and flat ({ role, content }) formats\n const msg = entry?.message ?? entry;\n if (msg.role !== \"user\") continue;\n const textParts = Array.isArray(msg.content)\n ? msg.content\n .filter((p: any) => p.type === \"text\")\n .map((p: any) => p.text)\n .join(\" \")\n : typeof msg.content === \"string\"\n ? msg.content\n : \"\";\n if (textParts.trim()) {\n if (!title) title = textParts.trim().slice(0, 80);\n preview = textParts.trim().slice(0, 120);\n }\n }\n return { title, preview };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentPanel.d.ts","sourceRoot":"","sources":["../../src/client/AgentPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;
|
|
1
|
+
{"version":3,"file":"AgentPanel.d.ts","sourceRoot":"","sources":["../../src/client/AgentPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KASN,MAAM,OAAO,CAAC;AAuCf,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAwJ7D,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAC3C,kBAAkB,EAClB,eAAe,CAChB;IACC,oCAAoC;IACpC,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC7B,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6GAA6G;IAC7G,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,iFAAiF;IACjF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,6HAA6H;IAC7H,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC,iGAAiG;IACjG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yFAAyF;IACzF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gFAAgF;IAChF,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC9B;AAstCD,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,2CAShD;AAID,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,gDAAgD;IAChD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB;yDACqD;IACrD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,sDAAsD;IACtD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oEAAoE;IACpE,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,cAAsC,EACtC,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,QAAkB,EAClB,WAAmB,EACnB,aAAqB,GACtB,EAAE,iBAAiB,2CAoVnB;AAED;;;GAGG;AACH,wBAAgB,cAAc,SAgB7B;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,2CAqBtE"}
|
|
@@ -21,11 +21,11 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
21
21
|
* // Full page
|
|
22
22
|
* <AgentPanel className="h-screen" />
|
|
23
23
|
*/
|
|
24
|
-
import ReactDOM from "react-dom";
|
|
25
24
|
import React, { useState, useEffect, useRef, useCallback, useMemo, lazy, Suspense, startTransition, } from "react";
|
|
26
25
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
27
26
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, normalizeTooltipText, } from "./components/ui/tooltip.js";
|
|
28
|
-
import {
|
|
27
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuShortcut, DropdownMenuTrigger, } from "./components/ui/dropdown-menu.js";
|
|
28
|
+
import { IconMessageCircle, IconMessageChatbot, IconTerminal2, IconSettings, IconLayoutSidebarRightCollapse, IconLayoutGrid, IconCheck, IconPlus, IconX, IconDotsVertical, IconHistory, IconArrowsMaximize, IconArrowsMinimize, } from "@tabler/icons-react";
|
|
29
29
|
import { FeedbackButton } from "./FeedbackButton.js";
|
|
30
30
|
import { MultiTabAssistantChat, } from "./MultiTabAssistantChat.js";
|
|
31
31
|
import { useDevMode } from "./use-dev-mode.js";
|
|
@@ -288,7 +288,7 @@ function AgentPanelInner({ defaultMode = "chat", className, apiUrl, emptyStateTe
|
|
|
288
288
|
const showDevToggle = canToggle && isLocalhost;
|
|
289
289
|
const renderModeButtons = useCallback((activeMode) => (_jsx(TooltipProvider, { delayDuration: 200, children: _jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsxs("button", { onClick: () => switchMode("chat"), "aria-label": "Chat mode", className: cn("flex items-center gap-1 rounded-md px-2 py-1 text-[12px] leading-none", activeMode === "chat"
|
|
290
290
|
? "bg-accent text-foreground"
|
|
291
|
-
: "text-muted-foreground hover:bg-accent/50 hover:text-foreground"), style: AGENT_PANEL_CONTROL_STYLE, children: [_jsx(
|
|
291
|
+
: "text-muted-foreground hover:bg-accent/50 hover:text-foreground"), style: AGENT_PANEL_CONTROL_STYLE, children: [_jsx(IconMessageCircle, { size: 14 }), "Chat"] }) }), _jsx(TooltipContent, { children: "Chat mode" })] }), isDevMode && (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsxs("button", { onClick: () => switchMode("cli"), "aria-label": "CLI terminal mode", className: cn("flex items-center gap-1 rounded-md px-2 py-1 text-[12px] leading-none", activeMode === "cli"
|
|
292
292
|
? "bg-accent text-foreground"
|
|
293
293
|
: "text-muted-foreground hover:bg-accent/50 hover:text-foreground"), style: AGENT_PANEL_CONTROL_STYLE, children: [_jsx(IconTerminal2, { size: 14 }), "CLI"] }) }), _jsx(TooltipContent, { children: "CLI terminal mode" })] })), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsxs("button", { onClick: () => switchMode("resources"), "aria-label": "Workspace files, agents, skills, and tasks", className: cn("flex items-center gap-1 rounded-md px-2 py-1 text-[12px] leading-none", activeMode === "resources"
|
|
294
294
|
? "bg-accent text-foreground"
|
|
@@ -298,7 +298,6 @@ function AgentPanelInner({ defaultMode = "chat", className, apiUrl, emptyStateTe
|
|
|
298
298
|
const renderHeaderActions = useCallback(() => (_jsxs("div", { className: "flex shrink-0 items-center gap-1.5", children: [SHOW_ONBOARDING && isDevMode && (_jsx(Suspense, { fallback: null, children: _jsx(SetupButton, {}) })), _jsx(FeedbackButton, { variant: "icon", side: "bottom", align: "end" }), onToggleFullscreen && (_jsx(IconTooltip, { content: isFullscreen ? "Exit fullscreen" : "Fullscreen", children: _jsx("button", { onClick: onToggleFullscreen, "aria-label": isFullscreen ? "Exit fullscreen" : "Enter fullscreen", className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent/50", children: isFullscreen ? (_jsx(IconArrowsMinimize, { size: 14 })) : (_jsx(IconArrowsMaximize, { size: 14 })) }) })), onCollapse && (_jsx(IconTooltip, { content: "Collapse sidebar", children: _jsx("button", { onClick: onCollapse, "aria-label": "Collapse sidebar", className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent/50", children: _jsx(IconLayoutSidebarRightCollapse, { size: 14 }) }) }))] })), [onCollapse, isDevMode, onToggleFullscreen, isFullscreen]);
|
|
299
299
|
const [tabMenuOpen, setTabMenuOpen] = useState(null);
|
|
300
300
|
const [cliPickerOpen, setCliPickerOpen] = useState(false);
|
|
301
|
-
const cliPickerBtnRef = useRef(null);
|
|
302
301
|
// Ref callback: scroll the active tab into view in the overflow container.
|
|
303
302
|
// Uses getBoundingClientRect for reliable positioning regardless of offsetParent.
|
|
304
303
|
const activeTabRefCb = useCallback((el) => {
|
|
@@ -365,47 +364,11 @@ function AgentPanelInner({ defaultMode = "chat", className, apiUrl, emptyStateTe
|
|
|
365
364
|
paddingRight: 6,
|
|
366
365
|
borderRadius: "0 6px 6px 0",
|
|
367
366
|
background: "linear-gradient(to right, transparent, hsl(var(--accent)) 40%)",
|
|
368
|
-
}, children: _jsx(IconX, { size: 10 }) })] }, id))) }), _jsxs("div", { className: "flex items-center gap-0.5 shrink-0 ml-auto", children: [mode === "chat" && (_jsxs(_Fragment, { children: [_jsx(IconTooltip, { content: "New chat", children: _jsx("button", { onClick: addTab, "aria-label": "New chat", className: "flex h-5 w-5 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent/50", children: _jsx(IconPlus, { size: 14 }) }) }), toggleHistory && (_jsx(IconTooltip, { content: "Chat history", children: _jsx("button", { onClick: toggleHistory, "aria-label": "Chat history", className: cn("flex h-5 w-5 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent/50", showHistory && "bg-accent text-foreground"), children: _jsx(IconHistory, { size: 14 }) }) })), _jsxs(
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
"
|
|
372
|
-
|
|
373
|
-
setTabMenuOpen(null);
|
|
374
|
-
}, children: ["Close Tab", _jsx("kbd", { className: "text-[10px] text-muted-foreground", children: closeTabHint })] }), _jsx("button", { className: "flex w-full items-center px-3 py-1.5 text-xs text-foreground hover:bg-accent", onClick: () => {
|
|
375
|
-
closeOtherTabs(activeTabId);
|
|
376
|
-
setTabMenuOpen(null);
|
|
377
|
-
}, children: "Close Other Tabs" }), _jsxs("button", { className: "flex w-full items-center justify-between px-3 py-1.5 text-xs text-foreground hover:bg-accent", onClick: () => {
|
|
378
|
-
closeAllTabs();
|
|
379
|
-
setTabMenuOpen(null);
|
|
380
|
-
}, children: ["Close All Tabs", _jsx("kbd", { className: "text-[10px] text-muted-foreground", children: closeAllTabsHint })] })] })] }))] })] })), mode === "cli" && (_jsxs(_Fragment, { children: [_jsx(IconTooltip, { content: "New terminal", children: _jsx("button", { onClick: addCliTab, "aria-label": "New terminal", className: "flex h-5 w-5 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent/50", children: _jsx(IconPlus, { size: 14 }) }) }), availableClis.length > 0 && (_jsxs("div", { className: "relative", children: [_jsx(IconTooltip, { content: `CLI: ${selectedLabel}`, children: _jsx("button", { ref: cliPickerBtnRef, onClick: () => setCliPickerOpen(!cliPickerOpen), "aria-label": `Select CLI, currently ${selectedLabel}`, className: cn("flex h-5 w-5 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent/50", cliPickerOpen && "bg-accent text-foreground"), children: _jsx(IconSettings, { size: 14 }) }) }), cliPickerOpen &&
|
|
381
|
-
ReactDOM.createPortal(_jsxs(_Fragment, { children: [_jsx("div", { className: "fixed inset-0 z-[9980]", onClick: () => setCliPickerOpen(false) }), _jsx("div", { className: "fixed z-[9990] w-48 rounded-md border border-border bg-popover py-1 shadow-lg", style: (() => {
|
|
382
|
-
const r = cliPickerBtnRef.current?.getBoundingClientRect();
|
|
383
|
-
if (!r)
|
|
384
|
-
return { top: 0, right: 0 };
|
|
385
|
-
return {
|
|
386
|
-
top: r.bottom + 4,
|
|
387
|
-
right: window.innerWidth - r.right,
|
|
388
|
-
};
|
|
389
|
-
})(), children: availableClis.map((cli) => (_jsxs("button", { className: cn("flex w-full items-center gap-2 px-3 py-1.5 text-xs hover:bg-accent", cli.command === selectedCli
|
|
390
|
-
? "text-foreground font-medium"
|
|
391
|
-
: "text-muted-foreground"), onClick: () => {
|
|
392
|
-
selectCli(cli.command);
|
|
393
|
-
setCliPickerOpen(false);
|
|
394
|
-
}, children: [cli.command === selectedCli && (_jsx(IconCheck, { size: 12, className: "shrink-0" })), _jsx("span", { className: cli.command !== selectedCli
|
|
395
|
-
? "ml-5"
|
|
396
|
-
: "", children: cli.label })] }, cli.command))) })] }), document.body)] })), _jsxs("div", { className: "relative", children: [_jsx(IconTooltip, { content: "Tab options", children: _jsx("button", { onClick: () => setTabMenuOpen(tabMenuOpen === "__cli_global"
|
|
397
|
-
? null
|
|
398
|
-
: "__cli_global"), className: cn("flex h-5 w-5 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent/50", tabMenuOpen === "__cli_global" &&
|
|
399
|
-
"bg-accent text-foreground"), "aria-label": "Terminal tab options", children: _jsx(IconDotsVertical, { size: 14 }) }) }), tabMenuOpen === "__cli_global" && (_jsxs(_Fragment, { children: [_jsx("div", { className: "fixed inset-0 z-40", onClick: () => setTabMenuOpen(null) }), _jsxs("div", { className: "absolute right-0 top-full mt-1 z-50 w-44 rounded-md border border-border bg-popover py-1 shadow-lg", children: [_jsxs("button", { className: "flex w-full items-center justify-between px-3 py-1.5 text-xs text-foreground hover:bg-accent", onClick: () => {
|
|
400
|
-
closeCliTab(activeCliTab);
|
|
401
|
-
setTabMenuOpen(null);
|
|
402
|
-
}, children: ["Close Tab", _jsx("kbd", { className: "text-[10px] text-muted-foreground", children: closeTabHint })] }), _jsx("button", { className: "flex w-full items-center px-3 py-1.5 text-xs text-foreground hover:bg-accent", onClick: () => {
|
|
403
|
-
closeOtherCliTabs(activeCliTab);
|
|
404
|
-
setTabMenuOpen(null);
|
|
405
|
-
}, children: "Close Other Tabs" }), _jsxs("button", { className: "flex w-full items-center justify-between px-3 py-1.5 text-xs text-foreground hover:bg-accent", onClick: () => {
|
|
406
|
-
closeAllCliTabs();
|
|
407
|
-
setTabMenuOpen(null);
|
|
408
|
-
}, children: ["Close All Tabs", _jsx("kbd", { className: "text-[10px] text-muted-foreground", children: closeAllTabsHint })] })] })] }))] })] }))] })] }), mode === "chat" && hasSubTabs && (_jsx("div", { className: "flex items-center px-2 py-0.5 border-b border-border gap-0.5 bg-muted/30", children: _jsxs("div", { className: "flex items-center gap-0.5 min-w-0 overflow-x-auto scrollbar-none flex-1", children: [_jsx("div", { role: "button", tabIndex: 0, onClick: () => setActiveTabId(focusParentId), onKeyDown: activateOnKeyDown(() => setActiveTabId(focusParentId)), className: cn("flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium cursor-pointer", activeTabId === focusParentId
|
|
367
|
+
}, children: _jsx(IconX, { size: 10 }) })] }, id))) }), _jsxs("div", { className: "flex items-center gap-0.5 shrink-0 ml-auto", children: [mode === "chat" && (_jsxs(_Fragment, { children: [_jsx(IconTooltip, { content: "New chat", children: _jsx("button", { onClick: addTab, "aria-label": "New chat", className: "flex h-5 w-5 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent/50", children: _jsx(IconPlus, { size: 14 }) }) }), toggleHistory && (_jsx(IconTooltip, { content: "Chat history", children: _jsx("button", { onClick: toggleHistory, "aria-label": "Chat history", className: cn("flex h-5 w-5 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent/50", showHistory && "bg-accent text-foreground"), children: _jsx(IconHistory, { size: 14 }) }) })), _jsxs(DropdownMenu, { open: tabMenuOpen === "__chat_global", onOpenChange: (open) => setTabMenuOpen(open ? "__chat_global" : null), children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { className: cn("flex h-5 w-5 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent/50", tabMenuOpen === "__chat_global" &&
|
|
368
|
+
"bg-accent text-foreground"), "aria-label": "Chat tab options", children: _jsx(IconDotsVertical, { size: 14 }) }) }), _jsxs(DropdownMenuContent, { align: "end", sideOffset: 4, className: "w-44", children: [_jsxs(DropdownMenuItem, { onSelect: () => closeTab(activeTabId), children: ["Close Tab", _jsx(DropdownMenuShortcut, { children: closeTabHint })] }), _jsx(DropdownMenuItem, { onSelect: () => closeOtherTabs(activeTabId), children: "Close Other Tabs" }), _jsxs(DropdownMenuItem, { onSelect: () => closeAllTabs(), children: ["Close All Tabs", _jsx(DropdownMenuShortcut, { children: closeAllTabsHint })] })] })] })] })), mode === "cli" && (_jsxs(_Fragment, { children: [_jsx(IconTooltip, { content: "New terminal", children: _jsx("button", { onClick: addCliTab, "aria-label": "New terminal", className: "flex h-5 w-5 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent/50", children: _jsx(IconPlus, { size: 14 }) }) }), availableClis.length > 0 && (_jsxs(DropdownMenu, { open: cliPickerOpen, onOpenChange: setCliPickerOpen, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { "aria-label": `Select CLI, currently ${selectedLabel}`, className: cn("flex h-5 w-5 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent/50", cliPickerOpen && "bg-accent text-foreground"), children: _jsx(IconSettings, { size: 14 }) }) }), _jsx(DropdownMenuContent, { align: "end", sideOffset: 4, className: "w-48", children: availableClis.map((cli) => (_jsxs(DropdownMenuItem, { onSelect: () => selectCli(cli.command), className: cn(cli.command === selectedCli
|
|
369
|
+
? "font-medium"
|
|
370
|
+
: "text-muted-foreground"), children: [cli.command === selectedCli ? (_jsx(IconCheck, { size: 12, className: "shrink-0" })) : (_jsx("span", { className: "w-3" })), cli.label] }, cli.command))) })] })), _jsxs(DropdownMenu, { open: tabMenuOpen === "__cli_global", onOpenChange: (open) => setTabMenuOpen(open ? "__cli_global" : null), children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { className: cn("flex h-5 w-5 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent/50", tabMenuOpen === "__cli_global" &&
|
|
371
|
+
"bg-accent text-foreground"), "aria-label": "Terminal tab options", children: _jsx(IconDotsVertical, { size: 14 }) }) }), _jsxs(DropdownMenuContent, { align: "end", sideOffset: 4, className: "w-44", children: [_jsxs(DropdownMenuItem, { onSelect: () => closeCliTab(activeCliTab), children: ["Close Tab", _jsx(DropdownMenuShortcut, { children: closeTabHint })] }), _jsx(DropdownMenuItem, { onSelect: () => closeOtherCliTabs(activeCliTab), children: "Close Other Tabs" }), _jsxs(DropdownMenuItem, { onSelect: () => closeAllCliTabs(), children: ["Close All Tabs", _jsx(DropdownMenuShortcut, { children: closeAllTabsHint })] })] })] })] }))] })] }), mode === "chat" && hasSubTabs && (_jsx("div", { className: "flex items-center px-2 py-0.5 border-b border-border gap-0.5 bg-muted/30", children: _jsxs("div", { className: "flex items-center gap-0.5 min-w-0 overflow-x-auto scrollbar-none flex-1", children: [_jsx("div", { role: "button", tabIndex: 0, onClick: () => setActiveTabId(focusParentId), onKeyDown: activateOnKeyDown(() => setActiveTabId(focusParentId)), className: cn("flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium cursor-pointer", activeTabId === focusParentId
|
|
409
372
|
? "bg-accent text-foreground"
|
|
410
373
|
: "text-muted-foreground hover:bg-accent hover:text-foreground"), children: "Main" }), childTabs.map((tab) => (_jsxs("div", { role: "button", tabIndex: 0, ref: tab.id === activeTabId ? 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 py-1 text-[10px] font-medium cursor-pointer max-w-[140px]", tab.id === activeTabId
|
|
411
374
|
? "bg-accent text-foreground"
|