@mgamadeus/ddd-agents 0.10.6 → 0.10.7
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/chat.js +9 -9
- package/dist/chunks/{ConversationMarkdown-06rFO7Fr.js → ConversationMarkdown-DffEK45O.js} +3 -3
- package/dist/chunks/{ConversationMarkdown-06rFO7Fr.js.map → ConversationMarkdown-DffEK45O.js.map} +1 -1
- package/dist/chunks/{ConversationMessageInputComposerWidgets-BbIuDOUV.js → ConversationMessageInputComposerWidgets-D8fV62WH.js} +5 -5
- package/dist/chunks/{ConversationMessageInputComposerWidgets-BbIuDOUV.js.map → ConversationMessageInputComposerWidgets-D8fV62WH.js.map} +1 -1
- package/dist/chunks/{VoiceBarsIcon-BKtx_QIg.js → VoiceBarsIcon-7IYmM3LB.js} +5 -5
- package/dist/chunks/VoiceBarsIcon-7IYmM3LB.js.map +1 -0
- package/dist/chunks/{WebSearchResultsConversationWidget-W7O1fBB0.js → WebSearchResultsConversationWidget-D0cAmxr9.js} +2 -2
- package/dist/chunks/{WebSearchResultsConversationWidget-W7O1fBB0.js.map → WebSearchResultsConversationWidget-D0cAmxr9.js.map} +1 -1
- package/dist/chunks/{canvas-reducers-DDg9T7t8.js → canvas-reducers-BQH8YFBp.js} +2 -2
- package/dist/chunks/{canvas-reducers-DDg9T7t8.js.map → canvas-reducers-BQH8YFBp.js.map} +1 -1
- package/dist/chunks/{canvas-title-slot-context-8HUvNDuc.js → canvas-title-slot-context-CDNCeH2y.js} +2 -2
- package/dist/chunks/{canvas-title-slot-context-8HUvNDuc.js.map → canvas-title-slot-context-CDNCeH2y.js.map} +1 -1
- package/dist/chunks/{canvasBodies-qC-A_rlz.js → canvasBodies-By51Uxm-.js} +3 -3
- package/dist/chunks/{canvasBodies-qC-A_rlz.js.map → canvasBodies-By51Uxm-.js.map} +1 -1
- package/dist/chunks/{canvasStorage-DaM9851h.js → canvasStorage-Df_FW92q.js} +2 -2
- package/dist/chunks/{canvasStorage-DaM9851h.js.map → canvasStorage-Df_FW92q.js.map} +1 -1
- package/dist/chunks/link-navigation-BUcy5qWW.js.map +1 -1
- package/dist/chunks/{widget-name-resolver-BNSfO2Aw.js → widget-name-resolver-CSX7ZbfO.js} +2 -2
- package/dist/chunks/{widget-name-resolver-BNSfO2Aw.js.map → widget-name-resolver-CSX7ZbfO.js.map} +1 -1
- package/dist/client-testing.js +4 -4
- package/dist/image-render.js +4 -4
- package/dist/index.js +5 -5
- package/dist/kit.js +2 -2
- package/dist/preview.js +5 -5
- package/dist/renderer.js +8 -8
- package/dist/types/provider/environment.d.ts +2 -2
- package/dist/voice.js +1 -1
- package/dist/widgets.js +2 -2
- package/package.json +1 -1
- package/dist/chunks/VoiceBarsIcon-BKtx_QIg.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConversationMessageInputComposerWidgets-BbIuDOUV.js","sources":["../../src/chat/store/agents-chat-state.ts","../../src/chat/store/conversation-error-type.ts","../../src/chat/store/merge-chat-messages.ts","../../src/chat/store/reduce-agents-chat-state.ts","../../src/chat/store/create-agents-chat-store.ts","../../src/renderer/ConversationWidgetContext.tsx","../../src/chat/ConversationMessageInput/ConversationMessageInputComposerWidgets/ConversationMessageInputComposerWidgets.tsx"],"sourcesContent":["import type {\n AgentsClientError,\n AgentsConversation,\n AgentsConversationMessage,\n PostedMessage,\n StartedConversation,\n} from \"../../contract/conversation\";\nimport type { ChatMessage } from \"../chat-message\";\nimport type { CanvasCreatedEntity, CanvasSliceState } from \"../../renderer/canvas/canvas-reducers\";\nimport type { CanvasOpenRequest } from \"../../renderer/canvas/canvas-state\";\nimport type { ConversationErrorType } from \"./conversation-error-type\";\n\n/**\n * How an entry point outside the chat hands a job over to the chat that opens next (one generic opening\n * request): the first visible message, or an invisible start signal so the agent speaks first, the entry point the\n * start comes from, and a widget to mount without a message (a page handing over a tool). Set before the chat mounts,\n * so a reset keeps it; the chat clears each part once it consumed it.\n */\nexport interface AgentsChatOpeningRequest {\n /** The first visible owner message of the next started conversation. */\n userMessage: string | null;\n /** The invisible start signal of the next started conversation (an empty visible message carries it). */\n startSignalText: string | null;\n /** The entry point the start comes from; the server reopens that entry point's recent conversation instead. */\n entryPointKey: string | null;\n /** The canonical wire name of a deep-linkable widget the chat mounts once, without a message. */\n deepLinkedWidgetName: string | null;\n}\n\n/** The state of one chat instance. */\nexport interface AgentsChatState extends CanvasSliceState {\n /** The conversation shown; null for a cold chat until a start or the metadata read brings it. */\n conversation: AgentsConversation | null;\n /** Null until the first page or a send; ordered by `indexInConversation`, the optimistic message last. */\n messages: ChatMessage[] | null;\n /** A send is on its way. */\n conversationLoading: boolean;\n /** The last read or send for this conversation came back. */\n conversationLoaded: boolean;\n /** An older page exists: the scroll-up load stays armed. */\n hasMoreOlder: boolean;\n /** The agent works on a turn (the controller mirrors the derived activity here; read by the launcher). */\n aiThinking: boolean;\n error: ConversationErrorType | null;\n /** Seconds until the quota frees up again; set only while `error` is RATE_LIMIT. */\n rateLimitRetryAfterSeconds: number | null;\n /**\n * The conversation the newest metadata or page read asked for; null after a reset. A late answer for another\n * conversation — or one that lands after a reset — is dropped.\n */\n requestedConversationId: number | null;\n /** A start is on its way; no second start is sent meanwhile. */\n startingNewConversation: boolean;\n /** The token of the start on its way; its answer applies only while it is still the pending one. */\n pendingStartToken: number | null;\n /**\n * How many starts this chat instance sent — the source of `pendingStartToken`. Survives a reset (like\n * `canvasMountCount`): the store outlives a remount of the chat, so a token is never reused for another start.\n */\n startTokenCount: number;\n openingRequest: AgentsChatOpeningRequest;\n}\n\nexport const EMPTY_AGENTS_CHAT_OPENING_REQUEST: AgentsChatOpeningRequest = {\n userMessage: null,\n startSignalText: null,\n entryPointKey: null,\n deepLinkedWidgetName: null,\n};\n\nexport const INITIAL_AGENTS_CHAT_STATE: AgentsChatState = {\n conversation: null,\n messages: null,\n conversationLoading: false,\n conversationLoaded: false,\n hasMoreOlder: false,\n aiThinking: false,\n error: null,\n rateLimitRetryAfterSeconds: null,\n requestedConversationId: null,\n startingNewConversation: false,\n pendingStartToken: null,\n startTokenCount: 0,\n openingRequest: EMPTY_AGENTS_CHAT_OPENING_REQUEST,\n canvas: null,\n lastClosedCanvas: null,\n canvasMountCount: 0,\n};\n\n/**\n * What happens to a chat instance. The read and send events carry the port's answers (`AgentsConversationClient`);\n * the controller dispatches the `…Requested` event before it calls the port and the `…Received` / `…Failed` event\n * with the answer.\n */\nexport type AgentsChatEvent =\n /** A conversation switch, an empty chat, the chat's unmount: everything goes except the opening request and the two counters. */\n | { type: \"reset\" }\n | { type: \"conversationMetadataRequested\"; conversationId: number }\n | { type: \"conversationMetadataReceived\"; conversationId: number; conversation: AgentsConversation }\n | { type: \"conversationMetadataFailed\"; conversationId: number }\n | { type: \"messagesPageRequested\"; conversationId: number }\n /** `hasMoreOlder` null: a changed-messages read, which says nothing about older pages. */\n | {\n type: \"messagesPageReceived\";\n conversationId: number;\n messages: AgentsConversationMessage[];\n hasMoreOlder: boolean | null;\n }\n | { type: \"messagePostRequested\"; message: ChatMessage }\n | { type: \"messagePostReceived\"; conversationId: number; posted: PostedMessage }\n | { type: \"messagePostFailed\"; error: AgentsClientError }\n /** Takes the next start token (`pendingStartToken`); the controller reads it after the dispatch. */\n | { type: \"startRequested\"; message: ChatMessage }\n | { type: \"startReceived\"; startToken: number; started: StartedConversation }\n | { type: \"startFailed\"; error: AgentsClientError }\n | { type: \"errorSet\"; error: ConversationErrorType | null }\n | { type: \"aiThinkingSet\"; aiThinking: boolean }\n /** Sets the named parts of the opening request; the others stay. */\n | { type: \"openingRequestSet\"; openingRequest: Partial<AgentsChatOpeningRequest> }\n | { type: \"canvasOpened\"; request: CanvasOpenRequest }\n | { type: \"canvasClosed\"; byCustomer: boolean }\n | { type: \"canvasResetForNewTurn\" }\n | { type: \"canvasCleared\" }\n | { type: \"canvasCreatedEntityIdSet\"; created: CanvasCreatedEntity };\n","import type { AgentsClientError } from \"../../contract/conversation\";\n\n/**\n * The error card the chat shows. A plain object with string values (not a TypeScript `enum`), so the chat store, the\n * view and an app's older chat state share one vocabulary without a nominal type in between.\n */\nexport const ConversationErrorType = {\n AI_BUDGET: \"AI_BUDGET\",\n /**\n * HTTP 429 from an AI endpoint — a per-minute/hour/day usage quota was hit. Distinct from AI_BUDGET (monthly budget):\n * this one clears on its own after the Retry-After window.\n */\n RATE_LIMIT: \"RATE_LIMIT\",\n NETWORK_ERROR: \"NETWORK_ERROR\",\n CONVERSATION_NOT_FOUND: \"CONVERSATION_NOT_FOUND\",\n /**\n * The backend run FAILED (e.g. the model provider returned an error). The raw provider error is admin-only (never\n * shown here); the owner gets a generic \"something went wrong\" card.\n */\n AGENT_ERROR: \"AGENT_ERROR\",\n /**\n * The conversation is COMPLETED/CANCELLED and refuses further owner input. Set from the server's stable error code\n * `CONVERSATION_CLOSED` or by the chat's own pre-send guard; the error card owns the copy.\n */\n CONVERSATION_CLOSED: \"CONVERSATION_CLOSED\",\n} as const;\n\nexport type ConversationErrorType = (typeof ConversationErrorType)[keyof typeof ConversationErrorType];\n\n/**\n * The error card of a refused send (post or start), read from the port's error. Only the stable outcomes select a\n * dedicated card; every other refusal is a generic network error — the same classification the older chat applies to\n * the server's error codes (`AI_BUDGET_REACHED`, `RATE_LIMIT_EXCEEDED`, `CONVERSATION_CLOSED`).\n */\nexport const readConversationErrorTypeOfRefusedSend = (error: AgentsClientError): ConversationErrorType => {\n if (error.kind === \"budget\") return ConversationErrorType.AI_BUDGET;\n if (error.kind === \"rateLimit\") return ConversationErrorType.RATE_LIMIT;\n if (error.kind === \"closed\") return ConversationErrorType.CONVERSATION_CLOSED;\n return ConversationErrorType.NETWORK_ERROR;\n};\n","import type { ChatMessage } from \"../chat-message\";\n\n/**\n * Merges two message lists by `indexInConversation`, preferring `incoming` on a collision, sorted ascending by index.\n * Messages without an index (the optimistic owner message) cannot be matched, so they follow the indexed ones in order.\n * A start or post answer carries the whole list and a live read brings it again: concatenating would show every\n * message twice.\n */\nexport const mergeChatMessagesByIndex = (existing: ChatMessage[], incoming: ChatMessage[]): ChatMessage[] => {\n const messagesByIndex = new Map<number, ChatMessage>();\n const messagesWithoutIndex: ChatMessage[] = [];\n const collectMessage = (message: ChatMessage) => {\n if (message.indexInConversation != null) {\n messagesByIndex.set(message.indexInConversation, message);\n } else {\n messagesWithoutIndex.push(message);\n }\n };\n existing.forEach(collectMessage);\n incoming.forEach(collectMessage);\n const indexedMessages = Array.from(messagesByIndex.values()).sort(\n (first, second) => (first.indexInConversation ?? 0) - (second.indexInConversation ?? 0),\n );\n return [...indexedMessages, ...messagesWithoutIndex];\n};\n\n/**\n * Tags the messages of a send's answer: `fresh` when the id was not in the list before — the server just delivered it,\n * so its one-shot widgets may fire; a replayed message never fires them again.\n */\nexport const tagFreshChatMessages = (incoming: ChatMessage[], previousMessages: ChatMessage[]): ChatMessage[] => {\n const previousIds = new Set(previousMessages.map((message) => message.id).filter((id): id is number => id != null));\n return incoming.map((message) => ({ ...message, fresh: message.id != null && !previousIds.has(message.id) }));\n};\n\n/**\n * Merges a page of a keyset read (the newest page, an older page, the changed tail) into the loaded messages by index.\n * A message is `fresh` only when it is a live arrival: never shown before and newer than everything loaded — so the\n * streamed reply opens its canvas while a scroll-up page and the first page on open stay history. A message already\n * shown keeps its tag. A page of another conversation than the one shown replaces the list.\n */\nexport const mergeMessagesPage = (\n loadedMessages: ChatMessage[] | null,\n page: ChatMessage[],\n requestedConversationId: number,\n): ChatMessage[] => {\n const shownConversationId = loadedMessages?.find((message) => message.conversationId != null)?.conversationId;\n const replacesShownConversation = shownConversationId != null && shownConversationId !== requestedConversationId;\n const existingMessages = replacesShownConversation ? [] : (loadedMessages ?? []);\n const messagesByIndex = new Map<number, ChatMessage>();\n for (const existingMessage of existingMessages) {\n if (existingMessage.indexInConversation != null) {\n messagesByIndex.set(existingMessage.indexInConversation, existingMessage);\n }\n }\n const hadMessagesBeforeMerge = existingMessages.length > 0;\n const highestShownIndex = Math.max(-1, ...existingMessages.map((message) => message.indexInConversation ?? -1));\n for (const incomingMessage of page) {\n if (incomingMessage.indexInConversation == null) continue;\n const previousMessage = messagesByIndex.get(incomingMessage.indexInConversation);\n const isLiveArrival =\n hadMessagesBeforeMerge && previousMessage == null && incomingMessage.indexInConversation > highestShownIndex;\n messagesByIndex.set(incomingMessage.indexInConversation, {\n ...incomingMessage,\n fresh: previousMessage?.fresh ?? isLiveArrival,\n });\n }\n return Array.from(messagesByIndex.values()).sort(\n (first, second) => (first.indexInConversation ?? 0) - (second.indexInConversation ?? 0),\n );\n};\n","import {\n applyClearCanvas,\n applyCloseCanvas,\n applyOpenCanvas,\n applyResetCanvasForNewTurn,\n applySetCanvasCreatedEntityId,\n} from \"../../renderer/canvas/canvas-reducers\";\nimport type { AgentsClientError } from \"../../contract/conversation\";\nimport type { ChatMessage } from \"../chat-message\";\nimport { type AgentsChatEvent, type AgentsChatState, INITIAL_AGENTS_CHAT_STATE } from \"./agents-chat-state\";\nimport { ConversationErrorType, readConversationErrorTypeOfRefusedSend } from \"./conversation-error-type\";\nimport { mergeChatMessagesByIndex, mergeMessagesPage, tagFreshChatMessages } from \"./merge-chat-messages\";\n\n/** The error card and the quota wait of a refused send. */\nconst withRefusedSendError = (state: AgentsChatState, error: AgentsClientError): AgentsChatState => {\n const conversationErrorType = readConversationErrorTypeOfRefusedSend(error);\n return {\n ...state,\n error: conversationErrorType,\n rateLimitRetryAfterSeconds:\n conversationErrorType === ConversationErrorType.RATE_LIMIT ? (error.retryAfterSeconds ?? null) : null,\n };\n};\n\n/**\n * The messages a send's answer brings, merged over the loaded ones without the optimistic message it answers. The\n * optimistic owner rows are the rows without an index; the answer replaces the one whose text its saved owner row\n * carries (else the oldest one) — not blindly \"the last row\": a live read that merged in between already moved\n * indexed rows behind it, and dropping the last row then removed a real message and kept the optimistic one (a second\n * owner bubble, the activity line stuck on). A second message sent while the first was in flight keeps its bubble.\n */\nconst mergeSendAnswer = (loadedMessages: ChatMessage[] | null, answerMessages: ChatMessage[]): ChatMessage[] => {\n const optimisticMessages = (loadedMessages ?? []).filter((message) => message.indexInConversation == null);\n const answeredOwnerTexts = answerMessages\n .filter((message) => message.role === \"USER\" && message.indexInConversation != null)\n .map((message) => message.message ?? \"\");\n let replacedOptimisticMessage: ChatMessage | undefined =\n optimisticMessages.find((message) => answeredOwnerTexts.includes(message.message ?? \"\")) ?? optimisticMessages[0];\n const messagesWithoutOptimisticMessage = (loadedMessages ?? []).filter((message) => {\n if (message === replacedOptimisticMessage) {\n replacedOptimisticMessage = undefined;\n return false;\n }\n return true;\n });\n return mergeChatMessagesByIndex(\n messagesWithoutOptimisticMessage,\n tagFreshChatMessages(answerMessages, messagesWithoutOptimisticMessage),\n );\n};\n\n/** The canvas transitions mutate the fields of the object they get (`canvas-reducers.ts`); this keeps the state immutable. */\nconst withCanvasTransition = (\n state: AgentsChatState,\n applyCanvasTransition: (nextState: AgentsChatState) => void,\n): AgentsChatState => {\n const nextState = { ...state };\n applyCanvasTransition(nextState);\n const changed =\n nextState.canvas !== state.canvas ||\n nextState.lastClosedCanvas !== state.lastClosedCanvas ||\n nextState.canvasMountCount !== state.canvasMountCount;\n return changed ? nextState : state;\n};\n\n/**\n * The chat store's reducer: plain functions over the contract types. Each case is the one of the older\n * chat state (a Redux slice and its cases) it replaces, reading the port's answers instead of the\n * generated client's actions; the replay spec feeds both the same recorded sequence.\n */\nexport const reduceAgentsChatState = (state: AgentsChatState, event: AgentsChatEvent): AgentsChatState => {\n switch (event.type) {\n case \"reset\":\n // The opening request is set from outside before the chat mounts (a cold chat resets as it comes up); the canvas\n // mount count and the start token count are monotonic sources of identities: all three survive.\n return {\n ...INITIAL_AGENTS_CHAT_STATE,\n openingRequest: state.openingRequest,\n canvasMountCount: state.canvasMountCount,\n startTokenCount: state.startTokenCount,\n };\n\n case \"conversationMetadataRequested\":\n case \"messagesPageRequested\":\n return state.requestedConversationId === event.conversationId\n ? state\n : { ...state, requestedConversationId: event.conversationId };\n\n case \"conversationMetadataReceived\":\n // Dropped after a reset or when another conversation was asked for since: a late answer would put the old\n // conversation back, and the next send would post into it instead of starting a new one.\n if (state.requestedConversationId === null || state.requestedConversationId !== event.conversationId) {\n return state;\n }\n return { ...state, conversation: event.conversation, conversationLoaded: true };\n\n case \"conversationMetadataFailed\":\n // A metadata read is best-effort: the chat stays as it is.\n return { ...state, conversationLoaded: true };\n\n case \"messagesPageReceived\": {\n if (state.requestedConversationId === null || state.requestedConversationId !== event.conversationId) {\n return state;\n }\n if (state.conversation !== null && state.conversation.id !== event.conversationId) {\n return state;\n }\n return {\n ...state,\n messages: mergeMessagesPage(state.messages, event.messages, event.conversationId),\n hasMoreOlder: event.hasMoreOlder ?? state.hasMoreOlder,\n conversationLoaded: true,\n };\n }\n\n case \"messagePostRequested\":\n return {\n ...state,\n conversationLoading: true,\n conversationLoaded: false,\n aiThinking: true,\n error: null,\n rateLimitRetryAfterSeconds: null,\n messages: [...(state.messages ?? []), event.message],\n };\n\n case \"messagePostReceived\":\n if (event.conversationId !== state.conversation?.id) {\n return state;\n }\n // The reply arrives through live updates, not in this answer: `aiThinking` stays as it is.\n return {\n ...state,\n messages: mergeSendAnswer(state.messages, event.posted.messages),\n conversationLoading: false,\n conversationLoaded: true,\n error: null,\n };\n\n case \"messagePostFailed\":\n return withRefusedSendError(\n { ...state, conversationLoading: false, conversationLoaded: true, aiThinking: false },\n event.error,\n );\n\n case \"startRequested\":\n return {\n ...state,\n conversation: null,\n conversationLoading: true,\n conversationLoaded: false,\n aiThinking: true,\n error: null,\n rateLimitRetryAfterSeconds: null,\n startingNewConversation: true,\n startTokenCount: state.startTokenCount + 1,\n pendingStartToken: state.startTokenCount + 1,\n // A signal-only start (an empty visible message carries the start signal) seeds no empty bubble.\n messages: event.message.message ? [event.message] : [],\n };\n\n case \"startReceived\": {\n if (event.startToken !== state.pendingStartToken) {\n return state;\n }\n const { started } = event;\n if (started.reopenedExisting) {\n // The recent conversation of the start's entry point: nothing was appended, no turn started. Its messages are\n // not in the answer — the controller reads its newest page — so the optimistic bubble goes.\n return {\n ...state,\n conversation: started.conversation,\n messages: [],\n conversationLoading: false,\n conversationLoaded: true,\n aiThinking: false,\n startingNewConversation: false,\n pendingStartToken: null,\n };\n }\n // The reply arrives through live updates: `aiThinking` stays on.\n return {\n ...state,\n conversation: started.conversation,\n messages: mergeSendAnswer(state.messages, started.messages),\n conversationLoading: false,\n conversationLoaded: true,\n startingNewConversation: false,\n pendingStartToken: null,\n };\n }\n\n case \"startFailed\":\n return withRefusedSendError(\n {\n ...state,\n conversation: null,\n conversationLoading: false,\n conversationLoaded: true,\n aiThinking: false,\n startingNewConversation: false,\n pendingStartToken: null,\n },\n event.error,\n );\n\n case \"errorSet\":\n return state.error === event.error ? state : { ...state, error: event.error };\n\n case \"aiThinkingSet\":\n return state.aiThinking === event.aiThinking ? state : { ...state, aiThinking: event.aiThinking };\n\n case \"openingRequestSet\":\n return { ...state, openingRequest: { ...state.openingRequest, ...event.openingRequest } };\n\n case \"canvasOpened\":\n return withCanvasTransition(state, (nextState) => {\n applyOpenCanvas(nextState, event.request);\n });\n\n case \"canvasClosed\":\n return withCanvasTransition(state, (nextState) => applyCloseCanvas(nextState, event.byCustomer));\n\n case \"canvasResetForNewTurn\":\n return withCanvasTransition(state, applyResetCanvasForNewTurn);\n\n case \"canvasCleared\":\n return withCanvasTransition(state, applyClearCanvas);\n\n case \"canvasCreatedEntityIdSet\":\n return withCanvasTransition(state, (nextState) => {\n applySetCanvasCreatedEntityId(nextState, event.created);\n });\n }\n};\n","import { type AgentsChatEvent, type AgentsChatState, INITIAL_AGENTS_CHAT_STATE } from \"./agents-chat-state\";\nimport { reduceAgentsChatState } from \"./reduce-agents-chat-state\";\n\n/**\n * The state handle of one chat instance. The app creates one per chat (host application: one per agent\n * window, created before the window's chat mounts) and releases it with the chat; the chat and the app's code outside\n * the chat read and dispatch through the same handle. React reads it through `useAgentsChatSelector`.\n */\nexport interface AgentsChatStore {\n getState: () => AgentsChatState;\n /** Calls the listener after every state change; returns the unsubscribe. */\n subscribe: (listener: () => void) => () => void;\n dispatch: (event: AgentsChatEvent) => void;\n}\n\n/** The plain implementation of `AgentsChatStore`: one state object, replaced by the reducer on every event. */\nexport class AgentsChatStateContainer implements AgentsChatStore {\n protected state: AgentsChatState;\n protected readonly listeners = new Set<() => void>();\n\n constructor(initialState: AgentsChatState = INITIAL_AGENTS_CHAT_STATE) {\n this.state = initialState;\n }\n\n getState = (): AgentsChatState => this.state;\n\n subscribe = (listener: () => void): (() => void) => {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n dispatch = (event: AgentsChatEvent): void => {\n const nextState = reduceAgentsChatState(this.state, event);\n if (nextState === this.state) return;\n this.state = nextState;\n for (const notifyListener of [...this.listeners]) notifyListener();\n };\n}\n\n/** Creates the state handle of one chat instance. */\nexport const createAgentsChatStore = (initialState?: AgentsChatState): AgentsChatStore =>\n new AgentsChatStateContainer(initialState);\n","import React, { ReactNode, useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useAgentsEnvironment, useAgentsStateDispatch, useAgentsStateSelector } from \"../provider/AgentsProvider\";\nimport type { ConversationWidgetStatePartition } from \"./conversation-widget-state-partition\";\nimport { createAgentsChatStore } from \"../chat/store/create-agents-chat-store\";\nimport type { AgentsChatEvent } from \"../chat/store/agents-chat-state\";\nimport type { AgentsChatStore } from \"../chat/store/create-agents-chat-store\";\nimport { useAgentsChatSelector } from \"../chat/store/use-agents-chat-store\";\nimport type { CanvasState, LastClosedCanvas } from \"./canvas/canvas-state\";\nimport { CanvasViabilityContext, readCanvasViable } from \"../widgets/CanvasLauncherWidget/use-canvas-viable\";\nimport { ConversationComposerWidget } from \"./conversation-composer-widget\";\nimport type { CanvasCreatedEntity } from \"./canvas/canvas-reducers\";\nimport { clearStoredCanvas, storeOpenCanvas } from \"./canvas/canvasStorage\";\nimport {\n type CanvasOpenRequestFromOpener,\n type ConversationWidgetCallbacks,\n ConversationWidgetContext,\n defaultConversationWidgetCallbacks,\n type InjectSignalOptions,\n} from \"./ConversationWidgetCallbacksContext\";\n\n// The callbacks, their context and the chat-free hosts live in `ConversationWidgetCallbacksContext.tsx`; this module\n// adds the provider that reads the chat's state (the package chat store or an app's partition) and re-exports the rest.\nexport * from \"./ConversationWidgetCallbacksContext\";\n\n// Number of mounted agentic chat surfaces (widget, full-page chat, dashboard). Drives the app's \"a chat surface is\n// open\" action (`buildChatSurfaceOpenChangedAction`, e.g. a flag of the app's own flows): true while ≥1 is open.\n// Module-level so multiple providers share one count.\nlet agenticChatMountCount = 0;\n\nexport interface ConversationWidgetProviderProps {\n children: ReactNode;\n callbacks: Partial<ConversationWidgetCallbacks>;\n /**\n * The chat slice partition this provider's canvas lives in. The shell is shared by the two chat doors, so the door\n * says which partition: `AgentChat` passes `AgentChatInstance`; the AI-Extensions chat, every story and every spec\n * keep the default. A prop, not a callback — `callbacks` is `Partial`, and the partition is not optional.\n */\n sliceInstance?: ConversationWidgetStatePartition;\n /**\n * The package chat store of the chat: the agent chat passes its window's store and the provider reads\n * and writes the canvas there. Without it the provider reads a partition of the app's own chat state\n * (`sliceInstance`, else the environment's `defaultChatStatePartition`).\n */\n chatStore?: AgentsChatStore;\n /**\n * False for a host that renders the chat without the split (`ConversationView.disableSplitView`): there is nowhere\n * to open a canvas, so every open request is ignored with reason `noSurface`. Default true.\n */\n hostHasCanvasSurface?: boolean;\n}\n\n/** The canvas transitions the provider dispatches — the canvas events of the package chat store. */\ntype ConversationWidgetCanvasEvent = Extract<\n AgentsChatEvent,\n { type: \"canvasOpened\" | \"canvasClosed\" | \"canvasResetForNewTurn\" | \"canvasCleared\" | \"canvasCreatedEntityIdSet\" }\n>;\n\n/** What the provider reads from the chat's state and how it writes a canvas transition back. */\ninterface ConversationWidgetChatState {\n canvas: CanvasState | null;\n lastClosedCanvas: LastClosedCanvas | null;\n isConversationRunning: boolean;\n runState: string | null | undefined;\n messages: ConversationWidgetCallbacks[\"messages\"];\n dispatchCanvasEvent: (event: ConversationWidgetCanvasEvent) => void;\n}\n\ntype ConversationWidgetProviderBodyProps = Omit<ConversationWidgetProviderProps, \"sliceInstance\" | \"chatStore\"> & {\n chatState: ConversationWidgetChatState;\n};\n\nconst selectCanvas = (state: { canvas: CanvasState | null }) => state.canvas;\nconst selectLastClosedCanvas = (state: { lastClosedCanvas: LastClosedCanvas | null }) => state.lastClosedCanvas;\nconst selectAiThinking = (state: { aiThinking: boolean }) => state.aiThinking;\nconst selectRunState = (state: { conversation: { runState?: string | null } | null }) => state.conversation?.runState;\nconst selectMessages = (state: { messages: ConversationWidgetCallbacks[\"messages\"] }) => state.messages;\n\n/** The provider over the package chat store of the chat. */\nconst ChatStoreConversationWidgetProvider = (\n props: Omit<ConversationWidgetProviderProps, \"sliceInstance\" | \"chatStore\"> & { chatStore: AgentsChatStore },\n) => {\n const { chatStore, ...bodyProps } = props;\n const canvas = useAgentsChatSelector(chatStore, selectCanvas);\n const lastClosedCanvas = useAgentsChatSelector(chatStore, selectLastClosedCanvas);\n const isConversationRunning = useAgentsChatSelector(chatStore, selectAiThinking);\n const runState = useAgentsChatSelector(chatStore, selectRunState);\n const messages = useAgentsChatSelector(chatStore, selectMessages);\n const chatState = useMemo<ConversationWidgetChatState>(\n () => ({\n canvas,\n lastClosedCanvas,\n isConversationRunning,\n runState,\n messages,\n dispatchCanvasEvent: chatStore.dispatch,\n }),\n [canvas, lastClosedCanvas, isConversationRunning, runState, messages, chatStore],\n );\n return <ConversationWidgetProviderBody {...bodyProps} chatState={chatState} />;\n};\n\n/** The provider over a partition of the older chat state (the AI-Extensions chat, stories, specs). */\nconst SliceConversationWidgetProvider = (\n props: Omit<ConversationWidgetProviderProps, \"sliceInstance\" | \"chatStore\"> & {\n sliceInstance: ConversationWidgetStatePartition;\n },\n) => {\n const { sliceInstance, ...bodyProps } = props;\n const dispatch = useAgentsStateDispatch();\n // One selector per field, not one returning an object, so an unrelated store change does not re-render every widget\n // through a fresh object identity.\n const canvas = useAgentsStateSelector((state) => sliceInstance.selectState(state).canvas);\n const lastClosedCanvas = useAgentsStateSelector((state) => sliceInstance.selectState(state).lastClosedCanvas);\n const isConversationRunning = useAgentsStateSelector((state) => sliceInstance.selectState(state).aiThinking);\n const runState = useAgentsStateSelector((state) => sliceInstance.selectState(state).conversation?.runState);\n const messages = useAgentsStateSelector((state) => sliceInstance.selectState(state).messages);\n const dispatchCanvasEvent = useCallback(\n (event: ConversationWidgetCanvasEvent) => {\n const { actions } = sliceInstance;\n if (event.type === \"canvasOpened\") dispatch(actions.openCanvas(event.request));\n else if (event.type === \"canvasClosed\") dispatch(actions.closeCanvas({ byCustomer: event.byCustomer }));\n else if (event.type === \"canvasResetForNewTurn\") dispatch(actions.resetCanvasForNewTurn());\n else if (event.type === \"canvasCleared\") dispatch(actions.clearCanvas());\n else dispatch(actions.setCanvasCreatedEntityId(event.created));\n },\n [dispatch, sliceInstance],\n );\n const chatState = useMemo<ConversationWidgetChatState>(\n () => ({ canvas, lastClosedCanvas, isConversationRunning, runState, messages, dispatchCanvasEvent }),\n [canvas, lastClosedCanvas, isConversationRunning, runState, messages, dispatchCanvasEvent],\n );\n return <ConversationWidgetProviderBody {...bodyProps} chatState={chatState} />;\n};\n\n/** The provider over a chat store of its own — a host that brings neither a chat store nor a partition (a story). */\nconst OwnChatStoreConversationWidgetProvider = (\n props: Omit<ConversationWidgetProviderProps, \"sliceInstance\" | \"chatStore\">,\n) => {\n const [ownChatStore] = useState(createAgentsChatStore);\n return <ChatStoreConversationWidgetProvider {...props} chatStore={ownChatStore} />;\n};\n\n/**\n * The widget callbacks of one chat, the canvas model included. Reads the chat's state from the package chat store when\n * the host passes one (`chatStore`), else from a partition of the app's own chat state (`sliceInstance`, or the\n * environment's `defaultChatStatePartition` — host application: the AI-Extensions chat), else from a store of its own.\n */\nexport const ConversationWidgetProvider = (props: ConversationWidgetProviderProps) => {\n const { sliceInstance, chatStore, ...bodyProps } = props;\n const { defaultChatStatePartition } = useAgentsEnvironment();\n const statePartition = sliceInstance ?? defaultChatStatePartition;\n if (chatStore) return <ChatStoreConversationWidgetProvider {...bodyProps} chatStore={chatStore} />;\n if (statePartition) return <SliceConversationWidgetProvider {...bodyProps} sliceInstance={statePartition} />;\n return <OwnChatStoreConversationWidgetProvider {...bodyProps} />;\n};\n\nconst ConversationWidgetProviderBody = ({\n children,\n callbacks,\n hostHasCanvasSurface = true,\n chatState,\n}: ConversationWidgetProviderBodyProps) => {\n const dispatch = useAgentsStateDispatch();\n const { buildChatSurfaceOpenChangedAction } = useAgentsEnvironment();\n const { canvas, lastClosedCanvas, isConversationRunning, runState, messages } = chatState;\n const isConversationClosed = runState === \"COMPLETED\" || runState === \"CANCELLED\";\n const dispatchCanvasEventRef = useRef(chatState.dispatchCanvasEvent);\n dispatchCanvasEventRef.current = chatState.dispatchCanvasEvent;\n const hostHasCanvasSurfaceRef = useRef(hostHasCanvasSurface);\n hostHasCanvasSurfaceRef.current = hostHasCanvasSurface;\n // The width of the chat's own container when the chat measures it (`AgentChatController`), else the viewport.\n const canvasViability = useContext(CanvasViabilityContext);\n const canvasViabilityRef = useRef(canvasViability);\n canvasViabilityRef.current = canvasViability;\n\n // An agentic chat surface is open: the app hears it through its action (e.g. a flag every connect/create/verify flow\n // launched from inside the chat reads to stay in-widget instead of navigating away).\n // Set here (not at the connect button) so it also covers the verify path, where there is no connect click.\n // Ref-counted so concurrently-mounted chat surfaces don't clear each other's flag.\n const buildChatSurfaceOpenChangedActionRef = useRef(buildChatSurfaceOpenChangedAction);\n buildChatSurfaceOpenChangedActionRef.current = buildChatSurfaceOpenChangedAction;\n useEffect(() => {\n agenticChatMountCount += 1;\n if (agenticChatMountCount === 1 && buildChatSurfaceOpenChangedActionRef.current) {\n dispatch(buildChatSurfaceOpenChangedActionRef.current(true));\n }\n return () => {\n agenticChatMountCount -= 1;\n if (agenticChatMountCount === 0 && buildChatSurfaceOpenChangedActionRef.current) {\n dispatch(buildChatSurfaceOpenChangedActionRef.current(false));\n }\n };\n }, [dispatch]);\n\n // Mirror the latest callbacks in a ref so the exposed functions stay stable across\n // renders even if the parent passes a fresh `callbacks` object every render.\n const callbacksRef = useRef(callbacks);\n callbacksRef.current = callbacks;\n\n // Composer-widget ownership — controlled when the host supplies `composerWidgets` (the builder page, click-bridge\n // F), otherwise uncontrolled: the provider owns the state so a descendant (e.g. an app's editor drawer) can\n // mutate it directly. See ConversationWidgetCallbacks.\n const isComposerWidgetsControlled = callbacks.composerWidgets !== undefined;\n const [internalComposerWidgets, setInternalComposerWidgets] = useState<ConversationComposerWidget[]>([]);\n const composerWidgets = isComposerWidgetsControlled\n ? (callbacks.composerWidgets as ConversationComposerWidget[])\n : internalComposerWidgets;\n\n // Mirrors the latest resolved composerWidgets + controlled flag so the mutator callbacks below can compute the\n // next array off REAL current state while keeping stable identities across renders ([] deps) — same trick as\n // `callbacksRef` above.\n const composerWidgetsStateRef = useRef({ composerWidgets, isComposerWidgetsControlled });\n composerWidgetsStateRef.current = { composerWidgets, isComposerWidgetsControlled };\n\n const publishComposerWidgets = useCallback((next: ConversationComposerWidget[]) => {\n if (composerWidgetsStateRef.current.isComposerWidgetsControlled) {\n callbacksRef.current.onComposerWidgetsChange?.(next);\n } else {\n setInternalComposerWidgets(next);\n }\n }, []);\n\n const addComposerWidget = useCallback(\n (widgetName: string, fields: Record<string, unknown>): string => {\n const composerWidgetId = crypto.randomUUID();\n publishComposerWidgets([\n ...composerWidgetsStateRef.current.composerWidgets,\n { composerWidgetId, widgetName, fields },\n ]);\n return composerWidgetId;\n },\n [publishComposerWidgets],\n );\n\n const replaceComposerWidgetFields = useCallback(\n (composerWidgetId: string, fields: Record<string, unknown>) => {\n publishComposerWidgets(\n composerWidgetsStateRef.current.composerWidgets.map((widget) =>\n widget.composerWidgetId === composerWidgetId ? { ...widget, fields } : widget,\n ),\n );\n },\n [publishComposerWidgets],\n );\n\n const removeComposerWidget = useCallback(\n (composerWidgetId: string) => {\n publishComposerWidgets(\n composerWidgetsStateRef.current.composerWidgets.filter(\n (widget) => widget.composerWidgetId !== composerWidgetId,\n ),\n );\n },\n [publishComposerWidgets],\n );\n\n const clearComposerWidgets = useCallback(() => {\n publishComposerWidgets([]);\n }, [publishComposerWidgets]);\n\n // The one way to open a canvas (all four origins). The provider supplies what only it knows — the split's viability\n // (the chat container's width, like `useCanvasViable`) and whether this host has a canvas surface — and the reducer\n // applies the opening rule. Ignored requests change nothing.\n const openCanvas = useCallback(\n (request: CanvasOpenRequestFromOpener) => {\n dispatchCanvasEventRef.current({\n type: \"canvasOpened\",\n request: {\n ...request,\n viewportViable: readCanvasViable(canvasViabilityRef.current),\n hostHasCanvasSurface: hostHasCanvasSurfaceRef.current,\n },\n });\n },\n [],\n );\n\n // Close the open canvas; it stays re-openable as `lastClosedCanvas`. `byCustomer` = the canvas's own close control,\n // which vetoes a live re-delivery of the same identity until the next send / click / page hand-over.\n const closeCanvas = useCallback(\n (byCustomer: boolean) => {\n dispatchCanvasEventRef.current({ type: \"canvasClosed\", byCustomer });\n },\n [],\n );\n\n const lastClosedCanvasRef = useRef(lastClosedCanvas);\n lastClosedCanvasRef.current = lastClosedCanvas;\n const reopenLastClosedCanvas = useCallback(() => {\n const last = lastClosedCanvasRef.current;\n if (last === null) return;\n dispatchCanvasEventRef.current({\n type: \"canvasOpened\",\n request: {\n canvasId: last.canvasId,\n instanceId: last.instanceId,\n anchor: last.anchor,\n origin: \"widgetClick\",\n justDelivered: false,\n viewportViable: readCanvasViable(canvasViabilityRef.current),\n hostHasCanvasSurface: hostHasCanvasSurfaceRef.current,\n ...(last.createdEntityId !== undefined ? { createdEntityId: last.createdEntityId } : {}),\n },\n });\n }, []);\n\n const setCanvasCreatedEntityId = useCallback(\n (created: CanvasCreatedEntity) => {\n dispatchCanvasEventRef.current({ type: \"canvasCreatedEntityIdSet\", created });\n },\n [],\n );\n\n // The pointer of the OPEN canvas is remembered per conversation for a reload (`canvasStorage.ts`), for any\n // lifetime. Cleared when the canvas closes INSIDE the same conversation; a conversation switch clears the slice too,\n // but the LEFT conversation keeps its entry so coming back restores it.\n const storedCanvasConversationIdRef = useRef<number | undefined>(undefined);\n const conversationIdForStorage = callbacks.conversationId;\n useEffect(() => {\n if (canvas !== null) {\n storeOpenCanvas(conversationIdForStorage, canvas);\n storedCanvasConversationIdRef.current = conversationIdForStorage;\n return;\n }\n if (\n storedCanvasConversationIdRef.current !== undefined &&\n storedCanvasConversationIdRef.current === conversationIdForStorage\n ) {\n clearStoredCanvas(conversationIdForStorage);\n }\n storedCanvasConversationIdRef.current = undefined;\n }, [canvas, conversationIdForStorage]);\n\n // A conversation switch forgets the canvas and the last closed one (the LEFT conversation keeps its stored pointer).\n const resetCanvas = useCallback(() => {\n dispatchCanvasEventRef.current({ type: \"canvasCleared\" });\n }, []);\n\n // The SEND boundary: a turn canvas is over for good, a pinned one stays (`canvas-reducers.ts`).\n const resetCanvasForNewTurn = useCallback(() => {\n dispatchCanvasEventRef.current({ type: \"canvasResetForNewTurn\" });\n }, []);\n\n const sendMessageToChat = useCallback((message: string) => {\n return callbacksRef.current.sendMessageToChat?.(message);\n }, []);\n\n const prefillComposer = useCallback((text: string) => {\n callbacksRef.current.prefillComposer?.(text);\n }, []);\n\n const injectSignal = useCallback((signalText: string, options?: InjectSignalOptions) => {\n return callbacksRef.current.injectSignal?.(signalText, options);\n }, []);\n\n const minimizeChatHost = useCallback(() => {\n callbacksRef.current.minimizeChatHost?.();\n }, []);\n\n const contextValue = useMemo<ConversationWidgetCallbacks>(\n () => ({\n canvas,\n hostHasCanvasSurface,\n lastClosedCanvas,\n openCanvas,\n closeCanvas,\n reopenLastClosedCanvas,\n setCanvasCreatedEntityId,\n resetCanvas,\n resetCanvasForNewTurn,\n sendMessageToChat,\n prefillComposer,\n injectSignal,\n minimizeChatHost,\n chatAgentSpaceKey: callbacks.chatAgentSpaceKey,\n isConversationRunning,\n isConversationClosed,\n conversationId: callbacks.conversationId,\n composerWidgets,\n addComposerWidget,\n replaceComposerWidgetFields,\n removeComposerWidget,\n clearComposerWidgets,\n attachLibraryFilesToComposer: callbacks.attachLibraryFilesToComposer,\n onOpenConversation: callbacks.onOpenConversation,\n onSwitchConversation: callbacks.onSwitchConversation,\n isOnboardingSetupConversation: callbacks.isOnboardingSetupConversation ?? false,\n messages,\n }),\n [\n canvas,\n hostHasCanvasSurface,\n lastClosedCanvas,\n openCanvas,\n closeCanvas,\n reopenLastClosedCanvas,\n setCanvasCreatedEntityId,\n resetCanvas,\n resetCanvasForNewTurn,\n sendMessageToChat,\n prefillComposer,\n injectSignal,\n minimizeChatHost,\n callbacks.chatAgentSpaceKey,\n isConversationRunning,\n isConversationClosed,\n callbacks.conversationId,\n composerWidgets,\n addComposerWidget,\n replaceComposerWidgetFields,\n removeComposerWidget,\n clearComposerWidgets,\n callbacks.attachLibraryFilesToComposer,\n callbacks.onOpenConversation,\n callbacks.onSwitchConversation,\n callbacks.isOnboardingSetupConversation,\n messages,\n ],\n );\n\n return <ConversationWidgetContext.Provider value={contextValue}>{children}</ConversationWidgetContext.Provider>;\n};\n\n","import React from \"react\";\nimport { classNames } from \"../../../provider/class-names\";\nimport styles from \"./ConversationMessageInputComposerWidgets.module.scss\";\nimport { useConversationWidgetContext } from \"../../../renderer/ConversationWidgetContext\";\nimport { conversationWidgetRegistry } from \"../../../renderer/conversationWidgetRegistry\";\n\nexport interface ConversationMessageInputComposerWidgetsProps {\n testId?: string;\n}\n\n/**\n * Generic strip of composer widgets above the chat input's text area — the composer-side twin of\n * `ConversationMessageInputAttachmentsPreviewStrip`, same grid-rows 0fr→1fr reveal. Reads `composerWidgets` from the\n * widget context itself (so every ConversationView host gets it for free, mirroring the deleted selection chip),\n * and for each widget resolves the registry entry by `widgetName` and renders its `composerComponent` with\n * `{ composerWidgetId, fields, replaceFields, remove }`. An unknown name, or an entry without a `composerComponent`,\n * renders nothing for that widget — the same kill switch the fence plugin applies.\n */\nexport const ConversationMessageInputComposerWidgets = (props: ConversationMessageInputComposerWidgetsProps) => {\n const { testId = \"chat-input\" } = props;\n const { composerWidgets, replaceComposerWidgetFields, removeComposerWidget } = useConversationWidgetContext();\n\n const renderableWidgets = composerWidgets.flatMap((widget) => {\n const entry = conversationWidgetRegistry.widgets.find((candidate) => candidate.name === widget.widgetName);\n return entry?.composerComponent ? [{ widget, Component: entry.composerComponent }] : [];\n });\n\n return (\n <div\n className={classNames(styles.stripReveal, { [styles.stripRevealOpen]: renderableWidgets.length > 0 })}\n data-testid={`${testId}-composer-widgets-strip`}\n >\n <div className={styles.stripRevealInner}>\n <div className={styles.strip}>\n {renderableWidgets.map(({ widget, Component }) => (\n <Component\n key={widget.composerWidgetId}\n composerWidgetId={widget.composerWidgetId}\n fields={widget.fields}\n replaceFields={(nextFields) => replaceComposerWidgetFields(widget.composerWidgetId, nextFields)}\n remove={() => removeComposerWidget(widget.composerWidgetId)}\n testId={`${testId}-composer-widget-${widget.composerWidgetId}`}\n />\n ))}\n </div>\n </div>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA+DO,MAAM,oCAA8D;AAAA,EACzE,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,sBAAsB;AACxB;AAEO,MAAM,4BAA6C;AAAA,EACxD,cAAc;AAAA,EACd,UAAU;AAAA,EACV,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,4BAA4B;AAAA,EAC5B,yBAAyB;AAAA,EACzB,yBAAyB;AAAA,EACzB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,QAAQ;AAAA,EACR,kBAAkB;AAAA,EAClB,kBAAkB;AACpB;ACjFO,MAAM,wBAAwB;AAAA,EACnC,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA,EAKX,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,wBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA,EAKxB,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA,EAKb,qBAAqB;AAC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,OAAO,OACpB,4BAAkB,IAAI,CAAC,EAAE,QAAQ,gBAChC;AAAA,QAAC;AAAA,QAAA;AAAA,UAEC,kBAAkB,OAAO;AAAA,UACzB,QAAQ,OAAO;AAAA,UACf,eAAe,CAAC,eAAe,4BAA4B,OAAO,kBAAkB,UAAU;AAAA,UAC9F,QAAQ,MAAM,qBAAqB,OAAO,gBAAgB;AAAA,UAC1D,QAAQ,GAAG,MAAM,oBAAoB,OAAO,gBAAgB;AAAA,QAAA;AAAA,QALvD,OAAO;AAAA,MAAA,CAOf,GACH,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"ConversationMessageInputComposerWidgets-D8fV62WH.js","sources":["../../src/chat/store/agents-chat-state.ts","../../src/chat/store/conversation-error-type.ts","../../src/chat/store/merge-chat-messages.ts","../../src/chat/store/reduce-agents-chat-state.ts","../../src/chat/store/create-agents-chat-store.ts","../../src/renderer/ConversationWidgetContext.tsx","../../src/chat/ConversationMessageInput/ConversationMessageInputComposerWidgets/ConversationMessageInputComposerWidgets.tsx"],"sourcesContent":["import type {\n AgentsClientError,\n AgentsConversation,\n AgentsConversationMessage,\n PostedMessage,\n StartedConversation,\n} from \"../../contract/conversation\";\nimport type { ChatMessage } from \"../chat-message\";\nimport type { CanvasCreatedEntity, CanvasSliceState } from \"../../renderer/canvas/canvas-reducers\";\nimport type { CanvasOpenRequest } from \"../../renderer/canvas/canvas-state\";\nimport type { ConversationErrorType } from \"./conversation-error-type\";\n\n/**\n * How an entry point outside the chat hands a job over to the chat that opens next (one generic opening\n * request): the first visible message, or an invisible start signal so the agent speaks first, the entry point the\n * start comes from, and a widget to mount without a message (a page handing over a tool). Set before the chat mounts,\n * so a reset keeps it; the chat clears each part once it consumed it.\n */\nexport interface AgentsChatOpeningRequest {\n /** The first visible owner message of the next started conversation. */\n userMessage: string | null;\n /** The invisible start signal of the next started conversation (an empty visible message carries it). */\n startSignalText: string | null;\n /** The entry point the start comes from; the server reopens that entry point's recent conversation instead. */\n entryPointKey: string | null;\n /** The canonical wire name of a deep-linkable widget the chat mounts once, without a message. */\n deepLinkedWidgetName: string | null;\n}\n\n/** The state of one chat instance. */\nexport interface AgentsChatState extends CanvasSliceState {\n /** The conversation shown; null for a cold chat until a start or the metadata read brings it. */\n conversation: AgentsConversation | null;\n /** Null until the first page or a send; ordered by `indexInConversation`, the optimistic message last. */\n messages: ChatMessage[] | null;\n /** A send is on its way. */\n conversationLoading: boolean;\n /** The last read or send for this conversation came back. */\n conversationLoaded: boolean;\n /** An older page exists: the scroll-up load stays armed. */\n hasMoreOlder: boolean;\n /** The agent works on a turn (the controller mirrors the derived activity here; read by the launcher). */\n aiThinking: boolean;\n error: ConversationErrorType | null;\n /** Seconds until the quota frees up again; set only while `error` is RATE_LIMIT. */\n rateLimitRetryAfterSeconds: number | null;\n /**\n * The conversation the newest metadata or page read asked for; null after a reset. A late answer for another\n * conversation — or one that lands after a reset — is dropped.\n */\n requestedConversationId: number | null;\n /** A start is on its way; no second start is sent meanwhile. */\n startingNewConversation: boolean;\n /** The token of the start on its way; its answer applies only while it is still the pending one. */\n pendingStartToken: number | null;\n /**\n * How many starts this chat instance sent — the source of `pendingStartToken`. Survives a reset (like\n * `canvasMountCount`): the store outlives a remount of the chat, so a token is never reused for another start.\n */\n startTokenCount: number;\n openingRequest: AgentsChatOpeningRequest;\n}\n\nexport const EMPTY_AGENTS_CHAT_OPENING_REQUEST: AgentsChatOpeningRequest = {\n userMessage: null,\n startSignalText: null,\n entryPointKey: null,\n deepLinkedWidgetName: null,\n};\n\nexport const INITIAL_AGENTS_CHAT_STATE: AgentsChatState = {\n conversation: null,\n messages: null,\n conversationLoading: false,\n conversationLoaded: false,\n hasMoreOlder: false,\n aiThinking: false,\n error: null,\n rateLimitRetryAfterSeconds: null,\n requestedConversationId: null,\n startingNewConversation: false,\n pendingStartToken: null,\n startTokenCount: 0,\n openingRequest: EMPTY_AGENTS_CHAT_OPENING_REQUEST,\n canvas: null,\n lastClosedCanvas: null,\n canvasMountCount: 0,\n};\n\n/**\n * What happens to a chat instance. The read and send events carry the port's answers (`AgentsConversationClient`);\n * the controller dispatches the `…Requested` event before it calls the port and the `…Received` / `…Failed` event\n * with the answer.\n */\nexport type AgentsChatEvent =\n /** A conversation switch, an empty chat, the chat's unmount: everything goes except the opening request and the two counters. */\n | { type: \"reset\" }\n | { type: \"conversationMetadataRequested\"; conversationId: number }\n | { type: \"conversationMetadataReceived\"; conversationId: number; conversation: AgentsConversation }\n | { type: \"conversationMetadataFailed\"; conversationId: number }\n | { type: \"messagesPageRequested\"; conversationId: number }\n /** `hasMoreOlder` null: a changed-messages read, which says nothing about older pages. */\n | {\n type: \"messagesPageReceived\";\n conversationId: number;\n messages: AgentsConversationMessage[];\n hasMoreOlder: boolean | null;\n }\n | { type: \"messagePostRequested\"; message: ChatMessage }\n | { type: \"messagePostReceived\"; conversationId: number; posted: PostedMessage }\n | { type: \"messagePostFailed\"; error: AgentsClientError }\n /** Takes the next start token (`pendingStartToken`); the controller reads it after the dispatch. */\n | { type: \"startRequested\"; message: ChatMessage }\n | { type: \"startReceived\"; startToken: number; started: StartedConversation }\n | { type: \"startFailed\"; error: AgentsClientError }\n | { type: \"errorSet\"; error: ConversationErrorType | null }\n | { type: \"aiThinkingSet\"; aiThinking: boolean }\n /** Sets the named parts of the opening request; the others stay. */\n | { type: \"openingRequestSet\"; openingRequest: Partial<AgentsChatOpeningRequest> }\n | { type: \"canvasOpened\"; request: CanvasOpenRequest }\n | { type: \"canvasClosed\"; byCustomer: boolean }\n | { type: \"canvasResetForNewTurn\" }\n | { type: \"canvasCleared\" }\n | { type: \"canvasCreatedEntityIdSet\"; created: CanvasCreatedEntity };\n","import type { AgentsClientError } from \"../../contract/conversation\";\n\n/**\n * The error card the chat shows. A plain object with string values (not a TypeScript `enum`), so the chat store, the\n * view and an app's older chat state share one vocabulary without a nominal type in between.\n */\nexport const ConversationErrorType = {\n AI_BUDGET: \"AI_BUDGET\",\n /**\n * HTTP 429 from an AI endpoint — a per-minute/hour/day usage quota was hit. Distinct from AI_BUDGET (monthly budget):\n * this one clears on its own after the Retry-After window.\n */\n RATE_LIMIT: \"RATE_LIMIT\",\n NETWORK_ERROR: \"NETWORK_ERROR\",\n CONVERSATION_NOT_FOUND: \"CONVERSATION_NOT_FOUND\",\n /**\n * The backend run FAILED (e.g. the model provider returned an error). The raw provider error is admin-only (never\n * shown here); the owner gets a generic \"something went wrong\" card.\n */\n AGENT_ERROR: \"AGENT_ERROR\",\n /**\n * The conversation is COMPLETED/CANCELLED and refuses further owner input. Set from the server's stable error code\n * `CONVERSATION_CLOSED` or by the chat's own pre-send guard; the error card owns the copy.\n */\n CONVERSATION_CLOSED: \"CONVERSATION_CLOSED\",\n} as const;\n\nexport type ConversationErrorType = (typeof ConversationErrorType)[keyof typeof ConversationErrorType];\n\n/**\n * The error card of a refused send (post or start), read from the port's error. Only the stable outcomes select a\n * dedicated card; every other refusal is a generic network error — the same classification the older chat applies to\n * the server's error codes (`AI_BUDGET_REACHED`, `RATE_LIMIT_EXCEEDED`, `CONVERSATION_CLOSED`).\n */\nexport const readConversationErrorTypeOfRefusedSend = (error: AgentsClientError): ConversationErrorType => {\n if (error.kind === \"budget\") return ConversationErrorType.AI_BUDGET;\n if (error.kind === \"rateLimit\") return ConversationErrorType.RATE_LIMIT;\n if (error.kind === \"closed\") return ConversationErrorType.CONVERSATION_CLOSED;\n return ConversationErrorType.NETWORK_ERROR;\n};\n","import type { ChatMessage } from \"../chat-message\";\n\n/**\n * Merges two message lists by `indexInConversation`, preferring `incoming` on a collision, sorted ascending by index.\n * Messages without an index (the optimistic owner message) cannot be matched, so they follow the indexed ones in order.\n * A start or post answer carries the whole list and a live read brings it again: concatenating would show every\n * message twice.\n */\nexport const mergeChatMessagesByIndex = (existing: ChatMessage[], incoming: ChatMessage[]): ChatMessage[] => {\n const messagesByIndex = new Map<number, ChatMessage>();\n const messagesWithoutIndex: ChatMessage[] = [];\n const collectMessage = (message: ChatMessage) => {\n if (message.indexInConversation != null) {\n messagesByIndex.set(message.indexInConversation, message);\n } else {\n messagesWithoutIndex.push(message);\n }\n };\n existing.forEach(collectMessage);\n incoming.forEach(collectMessage);\n const indexedMessages = Array.from(messagesByIndex.values()).sort(\n (first, second) => (first.indexInConversation ?? 0) - (second.indexInConversation ?? 0),\n );\n return [...indexedMessages, ...messagesWithoutIndex];\n};\n\n/**\n * Tags the messages of a send's answer: `fresh` when the id was not in the list before — the server just delivered it,\n * so its one-shot widgets may fire; a replayed message never fires them again.\n */\nexport const tagFreshChatMessages = (incoming: ChatMessage[], previousMessages: ChatMessage[]): ChatMessage[] => {\n const previousIds = new Set(previousMessages.map((message) => message.id).filter((id): id is number => id != null));\n return incoming.map((message) => ({ ...message, fresh: message.id != null && !previousIds.has(message.id) }));\n};\n\n/**\n * Merges a page of a keyset read (the newest page, an older page, the changed tail) into the loaded messages by index.\n * A message is `fresh` only when it is a live arrival: never shown before and newer than everything loaded — so the\n * streamed reply opens its canvas while a scroll-up page and the first page on open stay history. A message already\n * shown keeps its tag. A page of another conversation than the one shown replaces the list.\n */\nexport const mergeMessagesPage = (\n loadedMessages: ChatMessage[] | null,\n page: ChatMessage[],\n requestedConversationId: number,\n): ChatMessage[] => {\n const shownConversationId = loadedMessages?.find((message) => message.conversationId != null)?.conversationId;\n const replacesShownConversation = shownConversationId != null && shownConversationId !== requestedConversationId;\n const existingMessages = replacesShownConversation ? [] : (loadedMessages ?? []);\n const messagesByIndex = new Map<number, ChatMessage>();\n for (const existingMessage of existingMessages) {\n if (existingMessage.indexInConversation != null) {\n messagesByIndex.set(existingMessage.indexInConversation, existingMessage);\n }\n }\n const hadMessagesBeforeMerge = existingMessages.length > 0;\n const highestShownIndex = Math.max(-1, ...existingMessages.map((message) => message.indexInConversation ?? -1));\n for (const incomingMessage of page) {\n if (incomingMessage.indexInConversation == null) continue;\n const previousMessage = messagesByIndex.get(incomingMessage.indexInConversation);\n const isLiveArrival =\n hadMessagesBeforeMerge && previousMessage == null && incomingMessage.indexInConversation > highestShownIndex;\n messagesByIndex.set(incomingMessage.indexInConversation, {\n ...incomingMessage,\n fresh: previousMessage?.fresh ?? isLiveArrival,\n });\n }\n return Array.from(messagesByIndex.values()).sort(\n (first, second) => (first.indexInConversation ?? 0) - (second.indexInConversation ?? 0),\n );\n};\n","import {\n applyClearCanvas,\n applyCloseCanvas,\n applyOpenCanvas,\n applyResetCanvasForNewTurn,\n applySetCanvasCreatedEntityId,\n} from \"../../renderer/canvas/canvas-reducers\";\nimport type { AgentsClientError } from \"../../contract/conversation\";\nimport type { ChatMessage } from \"../chat-message\";\nimport { type AgentsChatEvent, type AgentsChatState, INITIAL_AGENTS_CHAT_STATE } from \"./agents-chat-state\";\nimport { ConversationErrorType, readConversationErrorTypeOfRefusedSend } from \"./conversation-error-type\";\nimport { mergeChatMessagesByIndex, mergeMessagesPage, tagFreshChatMessages } from \"./merge-chat-messages\";\n\n/** The error card and the quota wait of a refused send. */\nconst withRefusedSendError = (state: AgentsChatState, error: AgentsClientError): AgentsChatState => {\n const conversationErrorType = readConversationErrorTypeOfRefusedSend(error);\n return {\n ...state,\n error: conversationErrorType,\n rateLimitRetryAfterSeconds:\n conversationErrorType === ConversationErrorType.RATE_LIMIT ? (error.retryAfterSeconds ?? null) : null,\n };\n};\n\n/**\n * The messages a send's answer brings, merged over the loaded ones without the optimistic message it answers. The\n * optimistic owner rows are the rows without an index; the answer replaces the one whose text its saved owner row\n * carries (else the oldest one) — not blindly \"the last row\": a live read that merged in between already moved\n * indexed rows behind it, and dropping the last row then removed a real message and kept the optimistic one (a second\n * owner bubble, the activity line stuck on). A second message sent while the first was in flight keeps its bubble.\n */\nconst mergeSendAnswer = (loadedMessages: ChatMessage[] | null, answerMessages: ChatMessage[]): ChatMessage[] => {\n const optimisticMessages = (loadedMessages ?? []).filter((message) => message.indexInConversation == null);\n const answeredOwnerTexts = answerMessages\n .filter((message) => message.role === \"USER\" && message.indexInConversation != null)\n .map((message) => message.message ?? \"\");\n let replacedOptimisticMessage: ChatMessage | undefined =\n optimisticMessages.find((message) => answeredOwnerTexts.includes(message.message ?? \"\")) ?? optimisticMessages[0];\n const messagesWithoutOptimisticMessage = (loadedMessages ?? []).filter((message) => {\n if (message === replacedOptimisticMessage) {\n replacedOptimisticMessage = undefined;\n return false;\n }\n return true;\n });\n return mergeChatMessagesByIndex(\n messagesWithoutOptimisticMessage,\n tagFreshChatMessages(answerMessages, messagesWithoutOptimisticMessage),\n );\n};\n\n/** The canvas transitions mutate the fields of the object they get (`canvas-reducers.ts`); this keeps the state immutable. */\nconst withCanvasTransition = (\n state: AgentsChatState,\n applyCanvasTransition: (nextState: AgentsChatState) => void,\n): AgentsChatState => {\n const nextState = { ...state };\n applyCanvasTransition(nextState);\n const changed =\n nextState.canvas !== state.canvas ||\n nextState.lastClosedCanvas !== state.lastClosedCanvas ||\n nextState.canvasMountCount !== state.canvasMountCount;\n return changed ? nextState : state;\n};\n\n/**\n * The chat store's reducer: plain functions over the contract types. Each case is the one of the older\n * chat state (a Redux slice and its cases) it replaces, reading the port's answers instead of the\n * generated client's actions; the replay spec feeds both the same recorded sequence.\n */\nexport const reduceAgentsChatState = (state: AgentsChatState, event: AgentsChatEvent): AgentsChatState => {\n switch (event.type) {\n case \"reset\":\n // The opening request is set from outside before the chat mounts (a cold chat resets as it comes up); the canvas\n // mount count and the start token count are monotonic sources of identities: all three survive.\n return {\n ...INITIAL_AGENTS_CHAT_STATE,\n openingRequest: state.openingRequest,\n canvasMountCount: state.canvasMountCount,\n startTokenCount: state.startTokenCount,\n };\n\n case \"conversationMetadataRequested\":\n case \"messagesPageRequested\":\n return state.requestedConversationId === event.conversationId\n ? state\n : { ...state, requestedConversationId: event.conversationId };\n\n case \"conversationMetadataReceived\":\n // Dropped after a reset or when another conversation was asked for since: a late answer would put the old\n // conversation back, and the next send would post into it instead of starting a new one.\n if (state.requestedConversationId === null || state.requestedConversationId !== event.conversationId) {\n return state;\n }\n return { ...state, conversation: event.conversation, conversationLoaded: true };\n\n case \"conversationMetadataFailed\":\n // A metadata read is best-effort: the chat stays as it is.\n return { ...state, conversationLoaded: true };\n\n case \"messagesPageReceived\": {\n if (state.requestedConversationId === null || state.requestedConversationId !== event.conversationId) {\n return state;\n }\n if (state.conversation !== null && state.conversation.id !== event.conversationId) {\n return state;\n }\n return {\n ...state,\n messages: mergeMessagesPage(state.messages, event.messages, event.conversationId),\n hasMoreOlder: event.hasMoreOlder ?? state.hasMoreOlder,\n conversationLoaded: true,\n };\n }\n\n case \"messagePostRequested\":\n return {\n ...state,\n conversationLoading: true,\n conversationLoaded: false,\n aiThinking: true,\n error: null,\n rateLimitRetryAfterSeconds: null,\n messages: [...(state.messages ?? []), event.message],\n };\n\n case \"messagePostReceived\":\n if (event.conversationId !== state.conversation?.id) {\n return state;\n }\n // The reply arrives through live updates, not in this answer: `aiThinking` stays as it is.\n return {\n ...state,\n messages: mergeSendAnswer(state.messages, event.posted.messages),\n conversationLoading: false,\n conversationLoaded: true,\n error: null,\n };\n\n case \"messagePostFailed\":\n return withRefusedSendError(\n { ...state, conversationLoading: false, conversationLoaded: true, aiThinking: false },\n event.error,\n );\n\n case \"startRequested\":\n return {\n ...state,\n conversation: null,\n conversationLoading: true,\n conversationLoaded: false,\n aiThinking: true,\n error: null,\n rateLimitRetryAfterSeconds: null,\n startingNewConversation: true,\n startTokenCount: state.startTokenCount + 1,\n pendingStartToken: state.startTokenCount + 1,\n // A signal-only start (an empty visible message carries the start signal) seeds no empty bubble.\n messages: event.message.message ? [event.message] : [],\n };\n\n case \"startReceived\": {\n if (event.startToken !== state.pendingStartToken) {\n return state;\n }\n const { started } = event;\n if (started.reopenedExisting) {\n // The recent conversation of the start's entry point: nothing was appended, no turn started. Its messages are\n // not in the answer — the controller reads its newest page — so the optimistic bubble goes.\n return {\n ...state,\n conversation: started.conversation,\n messages: [],\n conversationLoading: false,\n conversationLoaded: true,\n aiThinking: false,\n startingNewConversation: false,\n pendingStartToken: null,\n };\n }\n // The reply arrives through live updates: `aiThinking` stays on.\n return {\n ...state,\n conversation: started.conversation,\n messages: mergeSendAnswer(state.messages, started.messages),\n conversationLoading: false,\n conversationLoaded: true,\n startingNewConversation: false,\n pendingStartToken: null,\n };\n }\n\n case \"startFailed\":\n return withRefusedSendError(\n {\n ...state,\n conversation: null,\n conversationLoading: false,\n conversationLoaded: true,\n aiThinking: false,\n startingNewConversation: false,\n pendingStartToken: null,\n },\n event.error,\n );\n\n case \"errorSet\":\n return state.error === event.error ? state : { ...state, error: event.error };\n\n case \"aiThinkingSet\":\n return state.aiThinking === event.aiThinking ? state : { ...state, aiThinking: event.aiThinking };\n\n case \"openingRequestSet\":\n return { ...state, openingRequest: { ...state.openingRequest, ...event.openingRequest } };\n\n case \"canvasOpened\":\n return withCanvasTransition(state, (nextState) => {\n applyOpenCanvas(nextState, event.request);\n });\n\n case \"canvasClosed\":\n return withCanvasTransition(state, (nextState) => applyCloseCanvas(nextState, event.byCustomer));\n\n case \"canvasResetForNewTurn\":\n return withCanvasTransition(state, applyResetCanvasForNewTurn);\n\n case \"canvasCleared\":\n return withCanvasTransition(state, applyClearCanvas);\n\n case \"canvasCreatedEntityIdSet\":\n return withCanvasTransition(state, (nextState) => {\n applySetCanvasCreatedEntityId(nextState, event.created);\n });\n }\n};\n","import { type AgentsChatEvent, type AgentsChatState, INITIAL_AGENTS_CHAT_STATE } from \"./agents-chat-state\";\nimport { reduceAgentsChatState } from \"./reduce-agents-chat-state\";\n\n/**\n * The state handle of one chat instance. The app creates one per chat (host application: one per agent\n * window, created before the window's chat mounts) and releases it with the chat; the chat and the app's code outside\n * the chat read and dispatch through the same handle. React reads it through `useAgentsChatSelector`.\n */\nexport interface AgentsChatStore {\n getState: () => AgentsChatState;\n /** Calls the listener after every state change; returns the unsubscribe. */\n subscribe: (listener: () => void) => () => void;\n dispatch: (event: AgentsChatEvent) => void;\n}\n\n/** The plain implementation of `AgentsChatStore`: one state object, replaced by the reducer on every event. */\nexport class AgentsChatStateContainer implements AgentsChatStore {\n protected state: AgentsChatState;\n protected readonly listeners = new Set<() => void>();\n\n constructor(initialState: AgentsChatState = INITIAL_AGENTS_CHAT_STATE) {\n this.state = initialState;\n }\n\n getState = (): AgentsChatState => this.state;\n\n subscribe = (listener: () => void): (() => void) => {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n dispatch = (event: AgentsChatEvent): void => {\n const nextState = reduceAgentsChatState(this.state, event);\n if (nextState === this.state) return;\n this.state = nextState;\n for (const notifyListener of [...this.listeners]) notifyListener();\n };\n}\n\n/** Creates the state handle of one chat instance. */\nexport const createAgentsChatStore = (initialState?: AgentsChatState): AgentsChatStore =>\n new AgentsChatStateContainer(initialState);\n","import React, { ReactNode, useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useAgentsEnvironment, useAgentsStateDispatch, useAgentsStateSelector } from \"../provider/AgentsProvider\";\nimport type { ConversationWidgetStatePartition } from \"./conversation-widget-state-partition\";\nimport { createAgentsChatStore } from \"../chat/store/create-agents-chat-store\";\nimport type { AgentsChatEvent } from \"../chat/store/agents-chat-state\";\nimport type { AgentsChatStore } from \"../chat/store/create-agents-chat-store\";\nimport { useAgentsChatSelector } from \"../chat/store/use-agents-chat-store\";\nimport type { CanvasState, LastClosedCanvas } from \"./canvas/canvas-state\";\nimport { CanvasViabilityContext, readCanvasViable } from \"../widgets/CanvasLauncherWidget/use-canvas-viable\";\nimport { ConversationComposerWidget } from \"./conversation-composer-widget\";\nimport type { CanvasCreatedEntity } from \"./canvas/canvas-reducers\";\nimport { clearStoredCanvas, storeOpenCanvas } from \"./canvas/canvasStorage\";\nimport {\n type CanvasOpenRequestFromOpener,\n type ConversationWidgetCallbacks,\n ConversationWidgetContext,\n defaultConversationWidgetCallbacks,\n type InjectSignalOptions,\n} from \"./ConversationWidgetCallbacksContext\";\n\n// The callbacks, their context and the chat-free hosts live in `ConversationWidgetCallbacksContext.tsx`; this module\n// adds the provider that reads the chat's state (the package chat store or an app's partition) and re-exports the rest.\nexport * from \"./ConversationWidgetCallbacksContext\";\n\n// Number of mounted agentic chat surfaces (widget, full-page chat, dashboard). Drives the app's \"a chat surface is\n// open\" action (`buildChatSurfaceOpenChangedAction`, e.g. a flag of the app's own flows): true while ≥1 is open.\n// Module-level so multiple providers share one count.\nlet agenticChatMountCount = 0;\n\nexport interface ConversationWidgetProviderProps {\n children: ReactNode;\n callbacks: Partial<ConversationWidgetCallbacks>;\n /**\n * The chat slice partition this provider's canvas lives in. The shell is shared by the two chat doors, so the door\n * says which partition: `AgentChat` passes `AgentChatInstance`; the AI-Extensions chat, every story and every spec\n * keep the default. A prop, not a callback — `callbacks` is `Partial`, and the partition is not optional.\n */\n sliceInstance?: ConversationWidgetStatePartition;\n /**\n * The package chat store of the chat: the agent chat passes its window's store and the provider reads\n * and writes the canvas there. Without it the provider reads a partition of the app's own chat state\n * (`sliceInstance`, else the environment's `defaultChatStatePartition`).\n */\n chatStore?: AgentsChatStore;\n /**\n * False for a host that renders the chat without the split (`ConversationView.disableSplitView`): there is nowhere\n * to open a canvas, so every open request is ignored with reason `noSurface`. Default true.\n */\n hostHasCanvasSurface?: boolean;\n}\n\n/** The canvas transitions the provider dispatches — the canvas events of the package chat store. */\ntype ConversationWidgetCanvasEvent = Extract<\n AgentsChatEvent,\n { type: \"canvasOpened\" | \"canvasClosed\" | \"canvasResetForNewTurn\" | \"canvasCleared\" | \"canvasCreatedEntityIdSet\" }\n>;\n\n/** What the provider reads from the chat's state and how it writes a canvas transition back. */\ninterface ConversationWidgetChatState {\n canvas: CanvasState | null;\n lastClosedCanvas: LastClosedCanvas | null;\n isConversationRunning: boolean;\n runState: string | null | undefined;\n messages: ConversationWidgetCallbacks[\"messages\"];\n dispatchCanvasEvent: (event: ConversationWidgetCanvasEvent) => void;\n}\n\ntype ConversationWidgetProviderBodyProps = Omit<ConversationWidgetProviderProps, \"sliceInstance\" | \"chatStore\"> & {\n chatState: ConversationWidgetChatState;\n};\n\nconst selectCanvas = (state: { canvas: CanvasState | null }) => state.canvas;\nconst selectLastClosedCanvas = (state: { lastClosedCanvas: LastClosedCanvas | null }) => state.lastClosedCanvas;\nconst selectAiThinking = (state: { aiThinking: boolean }) => state.aiThinking;\nconst selectRunState = (state: { conversation: { runState?: string | null } | null }) => state.conversation?.runState;\nconst selectMessages = (state: { messages: ConversationWidgetCallbacks[\"messages\"] }) => state.messages;\n\n/** The provider over the package chat store of the chat. */\nconst ChatStoreConversationWidgetProvider = (\n props: Omit<ConversationWidgetProviderProps, \"sliceInstance\" | \"chatStore\"> & { chatStore: AgentsChatStore },\n) => {\n const { chatStore, ...bodyProps } = props;\n const canvas = useAgentsChatSelector(chatStore, selectCanvas);\n const lastClosedCanvas = useAgentsChatSelector(chatStore, selectLastClosedCanvas);\n const isConversationRunning = useAgentsChatSelector(chatStore, selectAiThinking);\n const runState = useAgentsChatSelector(chatStore, selectRunState);\n const messages = useAgentsChatSelector(chatStore, selectMessages);\n const chatState = useMemo<ConversationWidgetChatState>(\n () => ({\n canvas,\n lastClosedCanvas,\n isConversationRunning,\n runState,\n messages,\n dispatchCanvasEvent: chatStore.dispatch,\n }),\n [canvas, lastClosedCanvas, isConversationRunning, runState, messages, chatStore],\n );\n return <ConversationWidgetProviderBody {...bodyProps} chatState={chatState} />;\n};\n\n/** The provider over a partition of the older chat state (the AI-Extensions chat, stories, specs). */\nconst SliceConversationWidgetProvider = (\n props: Omit<ConversationWidgetProviderProps, \"sliceInstance\" | \"chatStore\"> & {\n sliceInstance: ConversationWidgetStatePartition;\n },\n) => {\n const { sliceInstance, ...bodyProps } = props;\n const dispatch = useAgentsStateDispatch();\n // One selector per field, not one returning an object, so an unrelated store change does not re-render every widget\n // through a fresh object identity.\n const canvas = useAgentsStateSelector((state) => sliceInstance.selectState(state).canvas);\n const lastClosedCanvas = useAgentsStateSelector((state) => sliceInstance.selectState(state).lastClosedCanvas);\n const isConversationRunning = useAgentsStateSelector((state) => sliceInstance.selectState(state).aiThinking);\n const runState = useAgentsStateSelector((state) => sliceInstance.selectState(state).conversation?.runState);\n const messages = useAgentsStateSelector((state) => sliceInstance.selectState(state).messages);\n const dispatchCanvasEvent = useCallback(\n (event: ConversationWidgetCanvasEvent) => {\n const { actions } = sliceInstance;\n if (event.type === \"canvasOpened\") dispatch(actions.openCanvas(event.request));\n else if (event.type === \"canvasClosed\") dispatch(actions.closeCanvas({ byCustomer: event.byCustomer }));\n else if (event.type === \"canvasResetForNewTurn\") dispatch(actions.resetCanvasForNewTurn());\n else if (event.type === \"canvasCleared\") dispatch(actions.clearCanvas());\n else dispatch(actions.setCanvasCreatedEntityId(event.created));\n },\n [dispatch, sliceInstance],\n );\n const chatState = useMemo<ConversationWidgetChatState>(\n () => ({ canvas, lastClosedCanvas, isConversationRunning, runState, messages, dispatchCanvasEvent }),\n [canvas, lastClosedCanvas, isConversationRunning, runState, messages, dispatchCanvasEvent],\n );\n return <ConversationWidgetProviderBody {...bodyProps} chatState={chatState} />;\n};\n\n/** The provider over a chat store of its own — a host that brings neither a chat store nor a partition (a story). */\nconst OwnChatStoreConversationWidgetProvider = (\n props: Omit<ConversationWidgetProviderProps, \"sliceInstance\" | \"chatStore\">,\n) => {\n const [ownChatStore] = useState(createAgentsChatStore);\n return <ChatStoreConversationWidgetProvider {...props} chatStore={ownChatStore} />;\n};\n\n/**\n * The widget callbacks of one chat, the canvas model included. Reads the chat's state from the package chat store when\n * the host passes one (`chatStore`), else from a partition of the app's own chat state (`sliceInstance`, or the\n * environment's `defaultChatStatePartition` — host application: the AI-Extensions chat), else from a store of its own.\n */\nexport const ConversationWidgetProvider = (props: ConversationWidgetProviderProps) => {\n const { sliceInstance, chatStore, ...bodyProps } = props;\n const { defaultChatStatePartition } = useAgentsEnvironment();\n const statePartition = sliceInstance ?? defaultChatStatePartition;\n if (chatStore) return <ChatStoreConversationWidgetProvider {...bodyProps} chatStore={chatStore} />;\n if (statePartition) return <SliceConversationWidgetProvider {...bodyProps} sliceInstance={statePartition} />;\n return <OwnChatStoreConversationWidgetProvider {...bodyProps} />;\n};\n\nconst ConversationWidgetProviderBody = ({\n children,\n callbacks,\n hostHasCanvasSurface = true,\n chatState,\n}: ConversationWidgetProviderBodyProps) => {\n const dispatch = useAgentsStateDispatch();\n const { buildChatSurfaceOpenChangedAction } = useAgentsEnvironment();\n const { canvas, lastClosedCanvas, isConversationRunning, runState, messages } = chatState;\n const isConversationClosed = runState === \"COMPLETED\" || runState === \"CANCELLED\";\n const dispatchCanvasEventRef = useRef(chatState.dispatchCanvasEvent);\n dispatchCanvasEventRef.current = chatState.dispatchCanvasEvent;\n const hostHasCanvasSurfaceRef = useRef(hostHasCanvasSurface);\n hostHasCanvasSurfaceRef.current = hostHasCanvasSurface;\n // The width of the chat's own container when the chat measures it (`AgentChatController`), else the viewport.\n const canvasViability = useContext(CanvasViabilityContext);\n const canvasViabilityRef = useRef(canvasViability);\n canvasViabilityRef.current = canvasViability;\n\n // An agentic chat surface is open: the app hears it through its action (e.g. a flag every connect/create/verify flow\n // launched from inside the chat reads to stay in-widget instead of navigating away).\n // Set here (not at the connect button) so it also covers the verify path, where there is no connect click.\n // Ref-counted so concurrently-mounted chat surfaces don't clear each other's flag.\n const buildChatSurfaceOpenChangedActionRef = useRef(buildChatSurfaceOpenChangedAction);\n buildChatSurfaceOpenChangedActionRef.current = buildChatSurfaceOpenChangedAction;\n useEffect(() => {\n agenticChatMountCount += 1;\n if (agenticChatMountCount === 1 && buildChatSurfaceOpenChangedActionRef.current) {\n dispatch(buildChatSurfaceOpenChangedActionRef.current(true));\n }\n return () => {\n agenticChatMountCount -= 1;\n if (agenticChatMountCount === 0 && buildChatSurfaceOpenChangedActionRef.current) {\n dispatch(buildChatSurfaceOpenChangedActionRef.current(false));\n }\n };\n }, [dispatch]);\n\n // Mirror the latest callbacks in a ref so the exposed functions stay stable across\n // renders even if the parent passes a fresh `callbacks` object every render.\n const callbacksRef = useRef(callbacks);\n callbacksRef.current = callbacks;\n\n // Composer-widget ownership — controlled when the host supplies `composerWidgets` (the builder page, click-bridge\n // F), otherwise uncontrolled: the provider owns the state so a descendant (e.g. an app's editor drawer) can\n // mutate it directly. See ConversationWidgetCallbacks.\n const isComposerWidgetsControlled = callbacks.composerWidgets !== undefined;\n const [internalComposerWidgets, setInternalComposerWidgets] = useState<ConversationComposerWidget[]>([]);\n const composerWidgets = isComposerWidgetsControlled\n ? (callbacks.composerWidgets as ConversationComposerWidget[])\n : internalComposerWidgets;\n\n // Mirrors the latest resolved composerWidgets + controlled flag so the mutator callbacks below can compute the\n // next array off REAL current state while keeping stable identities across renders ([] deps) — same trick as\n // `callbacksRef` above.\n const composerWidgetsStateRef = useRef({ composerWidgets, isComposerWidgetsControlled });\n composerWidgetsStateRef.current = { composerWidgets, isComposerWidgetsControlled };\n\n const publishComposerWidgets = useCallback((next: ConversationComposerWidget[]) => {\n if (composerWidgetsStateRef.current.isComposerWidgetsControlled) {\n callbacksRef.current.onComposerWidgetsChange?.(next);\n } else {\n setInternalComposerWidgets(next);\n }\n }, []);\n\n const addComposerWidget = useCallback(\n (widgetName: string, fields: Record<string, unknown>): string => {\n const composerWidgetId = crypto.randomUUID();\n publishComposerWidgets([\n ...composerWidgetsStateRef.current.composerWidgets,\n { composerWidgetId, widgetName, fields },\n ]);\n return composerWidgetId;\n },\n [publishComposerWidgets],\n );\n\n const replaceComposerWidgetFields = useCallback(\n (composerWidgetId: string, fields: Record<string, unknown>) => {\n publishComposerWidgets(\n composerWidgetsStateRef.current.composerWidgets.map((widget) =>\n widget.composerWidgetId === composerWidgetId ? { ...widget, fields } : widget,\n ),\n );\n },\n [publishComposerWidgets],\n );\n\n const removeComposerWidget = useCallback(\n (composerWidgetId: string) => {\n publishComposerWidgets(\n composerWidgetsStateRef.current.composerWidgets.filter(\n (widget) => widget.composerWidgetId !== composerWidgetId,\n ),\n );\n },\n [publishComposerWidgets],\n );\n\n const clearComposerWidgets = useCallback(() => {\n publishComposerWidgets([]);\n }, [publishComposerWidgets]);\n\n // The one way to open a canvas (all four origins). The provider supplies what only it knows — the split's viability\n // (the chat container's width, like `useCanvasViable`) and whether this host has a canvas surface — and the reducer\n // applies the opening rule. Ignored requests change nothing.\n const openCanvas = useCallback(\n (request: CanvasOpenRequestFromOpener) => {\n dispatchCanvasEventRef.current({\n type: \"canvasOpened\",\n request: {\n ...request,\n viewportViable: readCanvasViable(canvasViabilityRef.current),\n hostHasCanvasSurface: hostHasCanvasSurfaceRef.current,\n },\n });\n },\n [],\n );\n\n // Close the open canvas; it stays re-openable as `lastClosedCanvas`. `byCustomer` = the canvas's own close control,\n // which vetoes a live re-delivery of the same identity until the next send / click / page hand-over.\n const closeCanvas = useCallback(\n (byCustomer: boolean) => {\n dispatchCanvasEventRef.current({ type: \"canvasClosed\", byCustomer });\n },\n [],\n );\n\n const lastClosedCanvasRef = useRef(lastClosedCanvas);\n lastClosedCanvasRef.current = lastClosedCanvas;\n const reopenLastClosedCanvas = useCallback(() => {\n const last = lastClosedCanvasRef.current;\n if (last === null) return;\n dispatchCanvasEventRef.current({\n type: \"canvasOpened\",\n request: {\n canvasId: last.canvasId,\n instanceId: last.instanceId,\n anchor: last.anchor,\n origin: \"widgetClick\",\n justDelivered: false,\n viewportViable: readCanvasViable(canvasViabilityRef.current),\n hostHasCanvasSurface: hostHasCanvasSurfaceRef.current,\n ...(last.createdEntityId !== undefined ? { createdEntityId: last.createdEntityId } : {}),\n },\n });\n }, []);\n\n const setCanvasCreatedEntityId = useCallback(\n (created: CanvasCreatedEntity) => {\n dispatchCanvasEventRef.current({ type: \"canvasCreatedEntityIdSet\", created });\n },\n [],\n );\n\n // The pointer of the OPEN canvas is remembered per conversation for a reload (`canvasStorage.ts`), for any\n // lifetime. Cleared when the canvas closes INSIDE the same conversation; a conversation switch clears the slice too,\n // but the LEFT conversation keeps its entry so coming back restores it.\n const storedCanvasConversationIdRef = useRef<number | undefined>(undefined);\n const conversationIdForStorage = callbacks.conversationId;\n useEffect(() => {\n if (canvas !== null) {\n storeOpenCanvas(conversationIdForStorage, canvas);\n storedCanvasConversationIdRef.current = conversationIdForStorage;\n return;\n }\n if (\n storedCanvasConversationIdRef.current !== undefined &&\n storedCanvasConversationIdRef.current === conversationIdForStorage\n ) {\n clearStoredCanvas(conversationIdForStorage);\n }\n storedCanvasConversationIdRef.current = undefined;\n }, [canvas, conversationIdForStorage]);\n\n // A conversation switch forgets the canvas and the last closed one (the LEFT conversation keeps its stored pointer).\n const resetCanvas = useCallback(() => {\n dispatchCanvasEventRef.current({ type: \"canvasCleared\" });\n }, []);\n\n // The SEND boundary: a turn canvas is over for good, a pinned one stays (`canvas-reducers.ts`).\n const resetCanvasForNewTurn = useCallback(() => {\n dispatchCanvasEventRef.current({ type: \"canvasResetForNewTurn\" });\n }, []);\n\n const sendMessageToChat = useCallback((message: string) => {\n return callbacksRef.current.sendMessageToChat?.(message);\n }, []);\n\n const prefillComposer = useCallback((text: string) => {\n callbacksRef.current.prefillComposer?.(text);\n }, []);\n\n const injectSignal = useCallback((signalText: string, options?: InjectSignalOptions) => {\n return callbacksRef.current.injectSignal?.(signalText, options);\n }, []);\n\n const minimizeChatHost = useCallback(() => {\n callbacksRef.current.minimizeChatHost?.();\n }, []);\n\n const contextValue = useMemo<ConversationWidgetCallbacks>(\n () => ({\n canvas,\n hostHasCanvasSurface,\n lastClosedCanvas,\n openCanvas,\n closeCanvas,\n reopenLastClosedCanvas,\n setCanvasCreatedEntityId,\n resetCanvas,\n resetCanvasForNewTurn,\n sendMessageToChat,\n prefillComposer,\n injectSignal,\n minimizeChatHost,\n chatAgentSpaceKey: callbacks.chatAgentSpaceKey,\n isConversationRunning,\n isConversationClosed,\n conversationId: callbacks.conversationId,\n composerWidgets,\n addComposerWidget,\n replaceComposerWidgetFields,\n removeComposerWidget,\n clearComposerWidgets,\n attachLibraryFilesToComposer: callbacks.attachLibraryFilesToComposer,\n onOpenConversation: callbacks.onOpenConversation,\n onSwitchConversation: callbacks.onSwitchConversation,\n isOnboardingSetupConversation: callbacks.isOnboardingSetupConversation ?? false,\n messages,\n }),\n [\n canvas,\n hostHasCanvasSurface,\n lastClosedCanvas,\n openCanvas,\n closeCanvas,\n reopenLastClosedCanvas,\n setCanvasCreatedEntityId,\n resetCanvas,\n resetCanvasForNewTurn,\n sendMessageToChat,\n prefillComposer,\n injectSignal,\n minimizeChatHost,\n callbacks.chatAgentSpaceKey,\n isConversationRunning,\n isConversationClosed,\n callbacks.conversationId,\n composerWidgets,\n addComposerWidget,\n replaceComposerWidgetFields,\n removeComposerWidget,\n clearComposerWidgets,\n callbacks.attachLibraryFilesToComposer,\n callbacks.onOpenConversation,\n callbacks.onSwitchConversation,\n callbacks.isOnboardingSetupConversation,\n messages,\n ],\n );\n\n return <ConversationWidgetContext.Provider value={contextValue}>{children}</ConversationWidgetContext.Provider>;\n};\n\n","import React from \"react\";\nimport { classNames } from \"../../../provider/class-names\";\nimport styles from \"./ConversationMessageInputComposerWidgets.module.scss\";\nimport { useConversationWidgetContext } from \"../../../renderer/ConversationWidgetContext\";\nimport { conversationWidgetRegistry } from \"../../../renderer/conversationWidgetRegistry\";\n\nexport interface ConversationMessageInputComposerWidgetsProps {\n testId?: string;\n}\n\n/**\n * Generic strip of composer widgets above the chat input's text area — the composer-side twin of\n * `ConversationMessageInputAttachmentsPreviewStrip`, same grid-rows 0fr→1fr reveal. Reads `composerWidgets` from the\n * widget context itself (so every ConversationView host gets it for free, mirroring the deleted selection chip),\n * and for each widget resolves the registry entry by `widgetName` and renders its `composerComponent` with\n * `{ composerWidgetId, fields, replaceFields, remove }`. An unknown name, or an entry without a `composerComponent`,\n * renders nothing for that widget — the same kill switch the fence plugin applies.\n */\nexport const ConversationMessageInputComposerWidgets = (props: ConversationMessageInputComposerWidgetsProps) => {\n const { testId = \"chat-input\" } = props;\n const { composerWidgets, replaceComposerWidgetFields, removeComposerWidget } = useConversationWidgetContext();\n\n const renderableWidgets = composerWidgets.flatMap((widget) => {\n const entry = conversationWidgetRegistry.widgets.find((candidate) => candidate.name === widget.widgetName);\n return entry?.composerComponent ? [{ widget, Component: entry.composerComponent }] : [];\n });\n\n return (\n <div\n className={classNames(styles.stripReveal, { [styles.stripRevealOpen]: renderableWidgets.length > 0 })}\n data-testid={`${testId}-composer-widgets-strip`}\n >\n <div className={styles.stripRevealInner}>\n <div className={styles.strip}>\n {renderableWidgets.map(({ widget, Component }) => (\n <Component\n key={widget.composerWidgetId}\n composerWidgetId={widget.composerWidgetId}\n fields={widget.fields}\n replaceFields={(nextFields) => replaceComposerWidgetFields(widget.composerWidgetId, nextFields)}\n remove={() => removeComposerWidget(widget.composerWidgetId)}\n testId={`${testId}-composer-widget-${widget.composerWidgetId}`}\n />\n ))}\n </div>\n </div>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA+DO,MAAM,oCAA8D;AAAA,EACzE,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,sBAAsB;AACxB;AAEO,MAAM,4BAA6C;AAAA,EACxD,cAAc;AAAA,EACd,UAAU;AAAA,EACV,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,4BAA4B;AAAA,EAC5B,yBAAyB;AAAA,EACzB,yBAAyB;AAAA,EACzB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,QAAQ;AAAA,EACR,kBAAkB;AAAA,EAClB,kBAAkB;AACpB;ACjFO,MAAM,wBAAwB;AAAA,EACnC,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA,EAKX,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,wBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA,EAKxB,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA,EAKb,qBAAqB;AACvB;AASO,MAAM,yCAAyC,CAAC,UAAoD;AACzG,MAAI,MAAM,SAAS,SAAU,QAAO,sBAAsB;AAC1D,MAAI,MAAM,SAAS,YAAa,QAAO,sBAAsB;A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O;AAAA,UACf,eAAe,CAAC,eAAe,4BAA4B,OAAO,kBAAkB,UAAU;AAAA,UAC9F,QAAQ,MAAM,qBAAqB,OAAO,gBAAgB;AAAA,UAC1D,QAAQ,GAAG,MAAM,oBAAoB,OAAO,gBAAgB;AAAA,QAAA;AAAA,QALvD,OAAO;AAAA,MAAA,CAOf,GACH,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { s as Text, F as classNames, I as Icon, a5 as useAgentsEnvironment, B as Button } from "./link-navigation-BUcy5qWW.js";
|
|
3
|
+
import { s as Text, J as escapePlainTextForText, F as classNames, I as Icon, a5 as useAgentsEnvironment, B as Button } from "./link-navigation-BUcy5qWW.js";
|
|
4
4
|
import { useMemo, useState, useRef, useCallback, useEffect, useContext, useLayoutEffect, memo } from "react";
|
|
5
|
-
import { f as findBalancedJsonObjectEnd, s as splitComposerWidgetFencesFromMessageText, e as WidgetWindowRootContext, C as ConversationMarkdown } from "./ConversationMarkdown-
|
|
6
|
-
import { W as WIDGET_FENCE_LANG, G as resolveWidgetName, j as conversationWidgetRegistry, o as ConversationWidgetErrorBoundary } from "./widget-name-resolver-
|
|
5
|
+
import { f as findBalancedJsonObjectEnd, s as splitComposerWidgetFencesFromMessageText, e as WidgetWindowRootContext, C as ConversationMarkdown } from "./ConversationMarkdown-DffEK45O.js";
|
|
6
|
+
import { W as WIDGET_FENCE_LANG, G as resolveWidgetName, j as conversationWidgetRegistry, o as ConversationWidgetErrorBoundary } from "./widget-name-resolver-CSX7ZbfO.js";
|
|
7
7
|
const ANY_FENCE_DELIM_LINE = /^ {0,3}(`{3,}|~{3,})(.*)$/;
|
|
8
8
|
const parseFenceDelimiterLine = (line) => {
|
|
9
9
|
const match = ANY_FENCE_DELIM_LINE.exec(line);
|
|
@@ -273,7 +273,7 @@ const ConversationMessageUser = (props) => {
|
|
|
273
273
|
const textColor = theme === "light" ? "var(--agents-fg)" : theme === "dark" ? "var(--agents-chat-user-bubble-text)" : "var(--agents-fg-on-accent)";
|
|
274
274
|
const bubble = /* @__PURE__ */ jsxs("div", { className: classNames(styles$3.message, bubbleClass), "data-testid": "chat-message-user", children: [
|
|
275
275
|
/* @__PURE__ */ jsx(ConversationMessageUserWidgets, { widgets: widgetsInsideBubble }),
|
|
276
|
-
proseText !== "" && /* @__PURE__ */ jsx(Text, { allowNewLines: true, translate: false, color: textColor, children: proseText })
|
|
276
|
+
proseText !== "" && /* @__PURE__ */ jsx(Text, { testId: "conversation-message-user-text", allowNewLines: true, translate: false, color: textColor, children: escapePlainTextForText(proseText) })
|
|
277
277
|
] });
|
|
278
278
|
if (widgetsAboveBubble.length === 0) return bubble;
|
|
279
279
|
return /* @__PURE__ */ jsxs("div", { className: styles$3.messageWithWidgetsAboveBubble, children: [
|
|
@@ -640,4 +640,4 @@ export {
|
|
|
640
640
|
ConversationMessageHeader as b,
|
|
641
641
|
normalizeServerMessageToMarkdown as n
|
|
642
642
|
};
|
|
643
|
-
//# sourceMappingURL=VoiceBarsIcon-
|
|
643
|
+
//# sourceMappingURL=VoiceBarsIcon-7IYmM3LB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VoiceBarsIcon-7IYmM3LB.js","sources":["../../src/renderer/repair-malformed-widget-fences.ts","../../src/renderer/reference-naked-widget-json.ts","../../src/chat/strip-pre-call-message-marker.ts","../../src/chat/normalize-server-message-to-markdown.ts","../../src/chat/ConversationMessage/ConversationMessageUser/ConversationMessageUserWidgets.tsx","../../src/chat/ConversationMessage/ConversationMessageUser/ConversationMessageUser.tsx","../../src/chat/ConversationMessage/ConversationMessageWidgets/hooks/useTypewriter.ts","../../src/chat/ConversationMessage/ConversationMessageWidgets/hooks/useStreamingText.ts","../../src/chat/ConversationMessage/ConversationMessageWidgets/hooks/useFreshMessageBlockReveal.ts","../../src/chat/ConversationMessage/ConversationMessageWidgets/ConversationMessageHeader/ConversationMessageHeader.tsx","../../src/chat/ConversationMessage/ConversationMessageWidgets/copyRichToClipboard.ts","../../src/chat/ConversationMessage/ConversationMessageWidgets/ConversationMessageWidgets.tsx","../../src/chat/ConversationMessage/ConversationCallMarkerChip/VoiceBarsIcon/VoiceBarsIcon.tsx"],"sourcesContent":["import { findBalancedJsonObjectEnd } from \"./balanced-json-object\";\nimport { WIDGET_FENCE_LANG } from \"./widget-fence-syntax\";\n\n/**\n * Repair the ```widget fence defects a model produces when it switches into a function call mid-text, or drops a\n * closing fence, or opens a second widget before closing the first (text + fence + tool call\n * in ONE response). A LINE-AWARE pass: CommonMark opens a fence on a line that (after up to 3 spaces of indent)\n * starts with ``` , and closes it only on a line whose sole content — same indent rule — is ``` . Content inside\n * ANY open fence (widget, json, or anything else) is data and is never scanned or touched, so a ``` mentioned\n * inside a JSON string value never gets mistaken for a delimiter.\n *\n * Two repairs, both scoped to the ```widget lang only:\n * 1. A glued opener (```widget stuck to the end of a prose line, so Markdown never recognized it as starting a\n * line) is relocated onto its own line ONLY when a JSON object begins right after it — otherwise the text is\n * left completely untouched (a prose sentence that merely mentions ```widget must not be mangled).\n * 2. An open widget fence with no proper closing-fence LINE before either end-of-text or the next fence-opener\n * line gets a ``` closer spliced in right after its balanced JSON object (string-aware, so a ``` inside a JSON\n * string is never treated as the closer). A widget fence whose body isn't a JSON object at all is left\n * untouched — nothing could safely render there either way, and deleting text is not this function's job.\n *\n * The backend stores the model text as emitted, so this is the ONE place the shape is corrected — for stored\n * history and for every new message alike. Runs before `referenceNakedWidgetJson` so the re-fenced JSON is not\n * wrapped a second time. Pure; well-formed text is returned unchanged.\n */\n\n/** A fence delimiter LINE per CommonMark, either character: up to 3 spaces indent, then a run of 3+ of the same\n * fence character (`` ` `` or `~`), then the rest of the line. Used by {@link findFencedBlockRanges} — the GENERAL\n * \"is this real fence syntax\" question, as opposed to the WIDGET-fence-only scanning above. */\nconst ANY_FENCE_DELIM_LINE = /^ {0,3}(`{3,}|~{3,})(.*)$/;\n\n/** One real fence delimiter: its character, marker length and (trimmed) info string. */\ninterface FenceDelimiter {\n char: \"`\" | \"~\";\n length: number;\n info: string;\n}\n\n/**\n * Parse one line as a CommonMark fence delimiter, or null when it isn't one. A backtick run's info string may not\n * itself contain a backtick — CommonMark's own rule disambiguating a fence opener from an inline code span — so a\n * line such as \"```js `x`\" is not a fence delimiter at all (it never opens or closes anything).\n */\nconst parseFenceDelimiterLine = (line: string): FenceDelimiter | null => {\n const match = ANY_FENCE_DELIM_LINE.exec(line);\n if (!match) return null;\n const marker = match[1];\n const char = marker[0] as \"`\" | \"~\";\n const info = match[2].trim();\n if (char === \"`\" && info.includes(\"`\")) return null;\n return { char, length: marker.length, info };\n};\n\nconst isWidgetFenceInfo = (info: string): boolean => new RegExp(`^${WIDGET_FENCE_LANG}\\\\b`).test(info.trim());\n\n/** A ```widget opener anywhere in the text, glued or not — built from the shared lang constant. */\nconst widgetOpenerPattern = (): RegExp => new RegExp(\"```[ \\\\t]*\" + WIDGET_FENCE_LANG + \"\\\\b\");\n\n/** One line of `text` starting at `lineStart`: its content (terminator excluded — a trailing `\\r` of a CRLF\n * line ending is stripped too, so a delimiter regex's `.` never has to account for it) and the index right after\n * the line INCLUDING its terminator (or `text.length` at end-of-text). */\nconst readLine = (text: string, lineStart: number): { content: string; afterLine: number } => {\n const newlineIndex = text.indexOf(\"\\n\", lineStart);\n const lineEnd = newlineIndex === -1 ? text.length : newlineIndex;\n const afterLine = newlineIndex === -1 ? text.length : newlineIndex + 1;\n const rawContent = text.slice(lineStart, lineEnd);\n return { content: rawContent.endsWith(\"\\r\") ? rawContent.slice(0, -1) : rawContent, afterLine };\n};\n\n/**\n * Scan forward from `bodyStart` for a line that CLOSES the given opener: same fence character, a marker run at\n * least as long as the opener's, and nothing but whitespace after it (CommonMark's closing-fence rule). Unclosed →\n * end-of-text.\n */\nconst findClosingFenceEnd = (text: string, bodyStart: number, opener: FenceDelimiter): number => {\n let cursor = bodyStart;\n while (cursor < text.length) {\n const { content, afterLine } = readLine(text, cursor);\n const delimiter = parseFenceDelimiterLine(content);\n if (delimiter && delimiter.char === opener.char && delimiter.length >= opener.length && delimiter.info === \"\") {\n return afterLine;\n }\n cursor = afterLine;\n }\n return text.length;\n};\n\n/**\n * The `[start, end)` ranges of every REAL fenced code block in `text` — ``` or ~~~, CommonMark's own rules (up to\n * 3 spaces of indent, a closer using the same character with a run at least as long as the opener's, a backtick\n * opener's info string never containing a backtick). An unclosed opener runs to end-of-text. The GENERAL-PURPOSE\n * counterpart of this file's widget-fence-only scanning, built on the same {@link readLine} line walk — used by\n * `referenceNakedWidgetJson` to skip content genuinely inside a fence: a `~~~widget` fence (no tilde support\n * existed before), and content that follows a line which LOOKS like a backtick fence opener but isn't one per the\n * info-string rule above (that line never opens anything, so it can no longer swallow the real fence after it).\n */\nexport const findFencedBlockRanges = (text: string): Array<[number, number]> => {\n const ranges: Array<[number, number]> = [];\n let cursor = 0;\n while (cursor < text.length) {\n const { content, afterLine } = readLine(text, cursor);\n const opener = parseFenceDelimiterLine(content);\n if (opener) {\n const end = findClosingFenceEnd(text, afterLine, opener);\n ranges.push([cursor, end]);\n cursor = end;\n continue;\n }\n cursor = afterLine;\n }\n return ranges;\n};\n\n/**\n * Scan forward from `bodyStart` (right after a fence opener line) for the next LINE-anchored BACKTICK fence\n * delimiter (via {@link parseFenceDelimiterLine} — the same CommonMark rules `findFencedBlockRanges` uses, so a\n * line like \"```js `x`\" — an invalid info string, not a fence delimiter at all — is correctly skipped as plain\n * content rather than mistaken for one): a proper closing line (empty info) closes the fence normally; any other\n * delimiter line (another opener, any lang) is the boundary where this fence gave up without closing. Neither\n * found before end-of-text → unclosed at EOF.\n */\nconst findFenceEnd = (text: string, bodyStart: number): { closesAt: number } | { unclosedBoundary: number } => {\n let cursor = bodyStart;\n while (cursor < text.length) {\n const { content, afterLine } = readLine(text, cursor);\n const delimiter = parseFenceDelimiterLine(content);\n if (delimiter && delimiter.char === \"`\") {\n return delimiter.info === \"\" ? { closesAt: afterLine } : { unclosedBoundary: cursor };\n }\n cursor = afterLine;\n }\n return { unclosedBoundary: text.length };\n};\n\n/**\n * Resolve an OPEN widget fence's body starting at `bodyStart`: verbatim through a real closing-fence line when one\n * exists before end-of-text or the next fence-opener line; otherwise a ``` closer spliced in right after the\n * balanced JSON object; or, when the body isn't a JSON object at all, everything to end-of-text left untouched.\n */\nconst closeWidgetFenceBody = (text: string, bodyStart: number): { appended: string; resumeAt: number } => {\n const end = findFenceEnd(text, bodyStart);\n if (\"closesAt\" in end) {\n return { appended: text.slice(bodyStart, end.closesAt), resumeAt: end.closesAt };\n }\n const jsonObjectEnd = findBalancedJsonObjectEnd(text, bodyStart);\n if (jsonObjectEnd === null) {\n return { appended: text.slice(bodyStart), resumeAt: text.length };\n }\n return { appended: text.slice(bodyStart, jsonObjectEnd + 1) + \"\\n```\", resumeAt: jsonObjectEnd + 1 };\n};\n\nexport const repairMalformedWidgetFences = (text: string): string => {\n if (!widgetOpenerPattern().test(text)) return text;\n\n let result = \"\";\n let cursor = 0;\n while (cursor < text.length) {\n const { content, afterLine } = readLine(text, cursor);\n\n // Backtick fences only here (tilde ```widget``` has no repair path, same as before): a line whose backtick\n // run's info string itself contains a backtick (e.g. \"```js `x`\") is not a fence delimiter at all per\n // CommonMark, so it falls through to the glued-opener check / plain-text copy below, never swallowing a real\n // ```widget fence that follows it as a bogus \"other fence\".\n const delimiter = parseFenceDelimiterLine(content);\n if (delimiter && delimiter.char === \"`\") {\n const info = delimiter.info;\n if (info !== \"\" && isWidgetFenceInfo(info)) {\n result += content + text.slice(cursor + content.length, afterLine); // the opener line, verbatim\n const { appended, resumeAt } = closeWidgetFenceBody(text, afterLine);\n result += appended;\n cursor = resumeAt;\n continue;\n }\n if (info !== \"\") {\n // Some other fenced language: copy its whole body through untouched — never scanned for a widget opener,\n // so a widget-fence mention inside a JSON string value in THIS fence's content is never touched (a widget\n // fence itself can't legally start inside an already-open fence either way).\n const otherFenceEnd = findFenceEnd(text, afterLine);\n const bodyEnd = \"closesAt\" in otherFenceEnd ? otherFenceEnd.closesAt : text.length;\n result += text.slice(cursor, bodyEnd);\n cursor = bodyEnd;\n continue;\n }\n }\n\n // Not a fence-delimiter line: a glued opener (the fence's backticks stuck to the end of prose). Relocate onto\n // its own line ONLY when a JSON object begins right after it; a prose line that merely mentions ```widget with\n // nothing to render is left completely untouched.\n const gluedMatch = widgetOpenerPattern().exec(content);\n if (gluedMatch && gluedMatch.index > 0 && content.slice(0, gluedMatch.index).trim() !== \"\") {\n const bodyStart = afterLine;\n if (findBalancedJsonObjectEnd(text, bodyStart) !== null) {\n const openerLine = content.slice(gluedMatch.index) + text.slice(cursor + content.length, afterLine);\n result += content.slice(0, gluedMatch.index) + \"\\n\" + openerLine;\n const { appended, resumeAt } = closeWidgetFenceBody(text, bodyStart);\n result += appended;\n cursor = resumeAt;\n continue;\n }\n }\n\n result += text.slice(cursor, afterLine);\n cursor = afterLine;\n }\n return result;\n};\n","import { findBalancedJsonObjectEnd } from \"./balanced-json-object\";\nimport { findFencedBlockRanges } from \"./repair-malformed-widget-fences\";\nimport { resolveWidgetName } from \"./widget-name-resolver\";\n\n/**\n * Weak models (Gemini-3.5-Flash) intermittently emit a widget as a NAKED JSON line —\n * `{ \"type\": \"ExampleWidget\" }` — without the ```widget fence the skills instruct. Such a line is not rendered\n * by remarkWidgetFencePlugin (no fence) and not by the bare-line path (no `widget` prefix), so the customer sees raw\n * JSON. `detectUnrenderedWidgets` only DETECTS this (to corrective-signal the model); here we RENDER it: wrap a naked\n * line-starting JSON object whose `type` resolves to a REGISTERED widget in a ```widget fence, so the plugin renders\n * it — no model round-trip, the customer never sees JSON. UNKNOWN types are left untouched (the corrective-signal\n * path still handles `type: \"example\"` → suggest `ExampleWidget`).\n *\n * Fence-aware: JSON already inside any REAL fenced block (``` or ~~~, CommonMark rules — see\n * `findFencedBlockRanges`) is skipped (never double-fenced). Uses the SAME resolveWidgetName as the render plugin +\n * the detector, so \"would render\" is decided in one place.\n */\n\n/** A line-starting balanced { … } JSON object and its [start, end) span in the source text. */\ninterface JsonSpan {\n json: string;\n start: number;\n end: number;\n}\n\n/**\n * Scan line-starting balanced `{ … }` JSON objects (string-aware brace walk), returning each with its span. Mirrors\n * detect-unrendered-widgets' `extractNakedJsonCandidates`, but keeps offsets so the object can be replaced in place.\n */\nconst scanLineStartingJsonSpans = (text: string): JsonSpan[] => {\n const spans: JsonSpan[] = [];\n const lines = text.split(\"\\n\");\n let offset = 0;\n for (const line of lines) {\n const lineStart = offset;\n offset += line.length + 1;\n if (!line.trimStart().startsWith(\"{\")) continue;\n const openIndex = lineStart + line.indexOf(\"{\");\n const jsonObjectEnd = findBalancedJsonObjectEnd(text, openIndex);\n if (jsonObjectEnd !== null) {\n spans.push({ json: text.slice(openIndex, jsonObjectEnd + 1), start: openIndex, end: jsonObjectEnd + 1 });\n }\n }\n return spans;\n};\n\n/** The string `type` of a JSON object, or null when it is not an object with a non-empty string `type`. */\nconst widgetTypeOf = (jsonCandidate: string): string | null => {\n let parsed: unknown;\n try {\n parsed = JSON.parse(jsonCandidate);\n } catch {\n return null;\n }\n if (typeof parsed !== \"object\" || parsed === null) return null;\n const type = (parsed as Record<string, unknown>).type;\n return typeof type === \"string\" && type !== \"\" ? type : null;\n};\n\nexport const referenceNakedWidgetJson = (text: string): string => {\n if (!text.includes('\"type\"')) return text;\n\n const fencedRanges = findFencedBlockRanges(text);\n const isInsideFence = (position: number) => fencedRanges.some(([start, end]) => position >= start && position < end);\n\n // Right-to-left so each replacement leaves the earlier spans' offsets valid.\n const spans = scanLineStartingJsonSpans(text)\n .filter((span) => !isInsideFence(span.start))\n .reverse();\n\n let result = text;\n for (const span of spans) {\n const type = widgetTypeOf(span.json);\n if (type === null || resolveWidgetName(type) === undefined) continue; // unknown → leave for the corrective signal\n const fencedBlock = \"```widget\\n\" + span.json + \"\\n```\";\n result = result.slice(0, span.start) + fencedBlock + result.slice(span.end);\n }\n return result;\n};\n","/**\n * Mirrors `AIConversationMessage::PRE_CALL_MESSAGE_MARKER` (PHP). The model prefixes a short \"I'm about to do X\"\n * status line with this sentinel; the BACKEND only detects/signals on it and stores it RAW (it never strips). Every\n * render layer — this is the customer chat one — strips it before showing the text to the user.\n */\nexport const PRE_CALL_MESSAGE_MARKER = \"{preCallMessage}\";\n\n/**\n * The MANGLED JSON form some models emit instead of the sentinel (Gemini 3.5 Flash): the status line\n * arrives as `{ \"preCallMessage\": \"…\" }<` — optionally with extra fields and/or a trailing `<|im_call:…` pseudo call\n * marker — fused into the assistant text. Normalized to the inner status text so the user never sees raw JSON.\n * Mirrors the PHP normalization in `AIConversationMessage::stripPreCallMessageMarker`.\n */\nconst MANGLED_PRE_CALL_RE = /\\{\\s*\"preCallMessage\"\\s*:\\s*\"((?:[^\"\\\\]|\\\\.)*)\"\\s*,?\\s*[^}]*\\}\\s*(?:<\\S*)?/g;\n\n/**\n * Remove the {preCallMessage} sentinel from assistant text before display, and normalize the mangled JSON form to\n * its inner status line. Also holds back a leading PARTIAL of either shape while it is still streaming in (so the\n * user never sees a \"{preCa…\" or `{ \"preCallMessage\": \"Einen Mo` flash before the full form arrives).\n */\nexport const stripPreCallMessageMarker = (text: string): string => {\n if (!text) return text;\n const leading = text.replace(/^\\s+/, \"\");\n // The sentinel itself is still streaming (nothing after it yet) → render nothing until real content arrives.\n if (leading.length < PRE_CALL_MESSAGE_MARKER.length && PRE_CALL_MESSAGE_MARKER.startsWith(leading)) return \"\";\n // The mangled JSON form is still streaming (opened but not yet closed) → hold it back the same way.\n const mangledPrefix = '{ \"preCallMessage\"';\n const normalizedLeading = leading.replace(/\\s+/g, \" \");\n if (\n (normalizedLeading.length < mangledPrefix.length && mangledPrefix.startsWith(normalizedLeading)) ||\n (normalizedLeading.startsWith(mangledPrefix) && !normalizedLeading.includes(\"}\"))\n ) {\n return \"\";\n }\n const withMangledNormalized = text.replace(MANGLED_PRE_CALL_RE, (_match, escapedStatusLine: string) => {\n try {\n return JSON.parse(`\"${escapedStatusLine}\"`) as string;\n } catch {\n return escapedStatusLine;\n }\n });\n const withMarkerRemoved = withMangledNormalized.split(PRE_CALL_MESSAGE_MARKER).join(\"\");\n // The marker (or its mangled form) sits at the very start, after only whitespace → that whitespace was there\n // only to separate it from the rest of the text and is removed along with it. Anything else — a message that\n // never carried the marker there at all — keeps its OWN leading whitespace untouched, so a four-space-indented\n // code block at the start of a message stays indented (plain CommonMark code) instead of sliding to column 0\n // and becoming a widget fence.\n const markerWasLeading = leading.startsWith(PRE_CALL_MESSAGE_MARKER) || normalizedLeading.startsWith(mangledPrefix);\n return markerWasLeading ? withMarkerRemoved.replace(/^\\s+/, \"\") : withMarkerRemoved;\n};\n","import { referenceNakedWidgetJson } from \"../renderer/reference-naked-widget-json\";\nimport { repairMalformedWidgetFences } from \"../renderer/repair-malformed-widget-fences\";\n\nimport { stripPreCallMessageMarker } from \"./strip-pre-call-message-marker\";\n\ntype ServerTextPart = { type: \"text\"; text?: string };\n\ntype ServerComponentPart = {\n type: \"component\";\n name?: string;\n props?: Record<string, unknown>;\n};\n\ntype ServerToolUsePart = {\n type: \"tool_use\";\n name?: string;\n input?: unknown;\n};\n\ntype ServerMessagePart = ServerTextPart | ServerComponentPart | ServerToolUsePart;\n\nexport type AssistantServerMessagePayload = {\n role?: string;\n content?: ServerMessagePart[];\n parts?: ServerMessagePart[];\n messageId?: string;\n};\n\nconst WIDGET_ATTR_KEY = /^[a-zA-Z_:][a-zA-Z0-9_.:-]*$/;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => typeof value === \"object\" && value !== null;\n\nconst isTextPart = (part: unknown): part is ServerTextPart => isRecord(part) && part.type === \"text\";\n\nconst isComponentPart = (part: unknown): part is ServerComponentPart =>\n isRecord(part) && part.type === \"component\" && typeof part.name === \"string\" && part.name.length > 0;\n\nconst isToolUsePart = (part: unknown): part is ServerToolUsePart => isRecord(part) && part.type === \"tool_use\";\n\nconst isMessagePart = (part: unknown): part is ServerMessagePart =>\n isTextPart(part) || isComponentPart(part) || isToolUsePart(part);\n\nconst isPayload = (value: unknown): value is AssistantServerMessagePayload => {\n if (!isRecord(value)) return false;\n const parts = value.content ?? value.parts;\n return Array.isArray(parts) && parts.every(isMessagePart);\n};\n\n/**\n * The model occasionally emits a single part object instead of an array\n * ({\"content\":{\"type\":\"text\",...}}). Coerce it so the message still renders.\n */\nconst coerceSinglePartPayload = (value: unknown): AssistantServerMessagePayload | null => {\n if (!isRecord(value)) return null;\n const part = value.content ?? value.parts;\n if (!isMessagePart(part)) return null;\n const rest = { ...value };\n delete rest.parts;\n return { ...rest, content: [part] };\n};\n\nconst encodeAttrValue = (value: unknown) => JSON.stringify(value).replace(/'/g, \"\\\\u0027\");\n\nconst propsToAttrs = (props: Record<string, unknown>) =>\n Object.entries(props)\n .filter(([key, value]) => value !== undefined && WIDGET_ATTR_KEY.test(key))\n .map(([key, value]) => `${key}='${encodeAttrValue(value)}'`)\n .join(\" \");\n\nconst componentPartToWidget = (part: ServerComponentPart) => {\n const attrs = propsToAttrs(part.props ?? {});\n return attrs ? `::${part.name}{${attrs}}` : `::${part.name}`;\n};\n\nconst toolUsePartToWidget = (part: ServerToolUsePart) => {\n const payload = encodeAttrValue({ name: part.name, input: part.input });\n return `::ToolTrace{payload='${payload}'}`;\n};\n\nconst partToMarkdown = (part: ServerMessagePart) => {\n if (isTextPart(part)) return part.text?.trim() ?? \"\";\n if (isToolUsePart(part)) return toolUsePartToWidget(part);\n return componentPartToWidget(part);\n};\n\nconst payloadToMarkdown = (payload: AssistantServerMessagePayload) => {\n return (payload.content ?? payload.parts ?? []).map(partToMarkdown).filter(Boolean).join(\"\\n\\n\");\n};\n\nconst tryParsePayload = (value: string): AssistantServerMessagePayload | null => {\n try {\n const parsed = JSON.parse(value) as unknown;\n return isPayload(parsed) ? parsed : coerceSinglePartPayload(parsed);\n } catch {\n return null;\n }\n};\n\nexport const normalizeServerMessageToMarkdown = (message: unknown): string => {\n let result: string;\n if (typeof message === \"string\") {\n const parsed = tryParsePayload(message);\n result = parsed ? payloadToMarkdown(parsed) : message;\n } else if (isPayload(message)) {\n result = payloadToMarkdown(message);\n } else {\n const coerced = coerceSinglePartPayload(message);\n if (coerced) {\n result = payloadToMarkdown(coerced);\n } else {\n console.warn(\"[AIExtensions] normalizeServerMessageToMarkdown: unrecognized message shape\", message);\n result = \"\";\n }\n }\n // The backend stores the {preCallMessage} status-line sentinel raw (it only detects/signals on it) — strip it here.\n // Then repair a ```widget fence the model broke mid-text (opener glued to the prose line / never closed — the model\n // switched into a tool call), then re-fence any naked widget JSON (a weak model emitted\n // `{ \"type\": \"ExampleWidget\" }` without a ```widget fence): wrapping a known widget type lets\n // remarkWidgetFencePlugin render it, so the customer never sees raw JSON.\n return referenceNakedWidgetJson(repairMalformedWidgetFences(stripPreCallMessageMarker(result)));\n};\n","import React from \"react\";\nimport { ConversationComposerWidget } from \"../../../renderer/conversation-composer-widget\";\nimport { conversationWidgetRegistry } from \"../../../renderer/conversationWidgetRegistry\";\nimport { ConversationWidgetErrorBoundary } from \"../../../renderer/ConversationWidgetErrorBoundary\";\n\nexport interface ConversationMessageUserWidgetsProps {\n /** Composer-widget fences extracted from the customer's own message text (see `splitComposerWidgetFencesFromMessageText`). */\n widgets: ConversationComposerWidget[];\n}\n\n/**\n * Read-only echo of the composer widgets the customer sent inside their OWN message — rendered above the prose. Reuses each widget's registered message `component` (the same one an\n * assistant reply would mount via the remark pipeline) directly with the fence's fields as `payload` — NOT the\n * remark/markdown pipeline itself, which never runs for user text (interpreting the customer's own prose as\n * Markdown would change every user bubble). `fresh={false}`: this is always a replay of content already sent, never\n * a live delivery. Each widget renders inside its own `ConversationWidgetErrorBoundary` so a malformed fence never\n * blanks the whole bubble.\n */\nexport const ConversationMessageUserWidgets = (props: ConversationMessageUserWidgetsProps) => {\n const { widgets } = props;\n\n if (widgets.length === 0) return null;\n\n return (\n <>\n {widgets.map((widget) => {\n const entry = conversationWidgetRegistry.widgets.find((candidate) => candidate.name === widget.widgetName);\n if (!entry) return null;\n const Component = entry.component;\n return (\n <ConversationWidgetErrorBoundary key={widget.composerWidgetId} widgetName={entry.name}>\n <Component payload={JSON.stringify(widget.fields)} fresh={false} />\n </ConversationWidgetErrorBoundary>\n );\n })}\n </>\n );\n};\n","import { Text } from \"../../../provider/components\";\nimport React, { useMemo } from \"react\";\nimport { classNames } from \"../../../provider/class-names\";\nimport { escapePlainTextForText } from \"../../../provider/environment\";\nimport styles from \"./ConversationMessageUser.module.scss\";\nimport { splitComposerWidgetFencesFromMessageText } from \"../../../renderer/composer-widget-fence\";\nimport type { ConversationComposerWidget } from \"../../../renderer/conversation-composer-widget\";\nimport { conversationWidgetRegistry } from \"../../../renderer/conversationWidgetRegistry\";\nimport { ConversationMessageUserWidgets } from \"./ConversationMessageUserWidgets\";\n\nexport type ConversationMessageUserTheme = \"default\" | \"light\" | \"dark\" | \"primary\";\n\nexport interface ConversationMessageUserProps {\n text: string;\n theme?: ConversationMessageUserTheme;\n /** @deprecated Never read: a customer message looks the same in every chat. Kept so existing callers compile. */\n isGenericChat?: boolean;\n}\n\n/** True when the widget's registry entry shows its echo on its own above the bubble (e.g. attached images). */\nconst isShownAboveBubble = (widget: ConversationComposerWidget): boolean =>\n conversationWidgetRegistry.widgets.find((entry) => entry.name === widget.widgetName)?.customerMessagePlacement ===\n \"aboveBubble\";\n\nexport const ConversationMessageUser = (props: ConversationMessageUserProps) => {\n const { text, theme = \"default\" } = props;\n\n // Pull any registered composer-widget fences out of the customer's own message text so they render as\n // read-only widgets above the prose, exactly like the assistant-side remark pipeline renders them in a reply —\n // but WITHOUT running that pipeline over user text (never treat the customer's own prose as Markdown).\n // The prose is the customer's own text: it reaches the text component as plain text (`escapePlainTextForText`), so\n // an app's text component that reads a string as markup shows it as written.\n const { text: proseText, widgets } = useMemo(() => splitComposerWidgetFencesFromMessageText(text), [text]);\n const widgetsAboveBubble = useMemo(() => widgets.filter(isShownAboveBubble), [widgets]);\n const widgetsInsideBubble = useMemo(() => widgets.filter((widget) => !isShownAboveBubble(widget)), [widgets]);\n\n const bubbleClass =\n theme === \"light\"\n ? styles.whiteBubble\n : theme === \"dark\"\n ? styles.darkBubble\n : theme === \"primary\"\n ? styles.primaryBubble\n : undefined;\n\n const textColor =\n theme === \"light\"\n ? \"var(--agents-fg)\"\n : theme === \"dark\"\n ? \"var(--agents-chat-user-bubble-text)\"\n : \"var(--agents-fg-on-accent)\";\n\n const bubble = (\n <div className={classNames(styles.message, bubbleClass)} data-testid=\"chat-message-user\">\n <ConversationMessageUserWidgets widgets={widgetsInsideBubble} />\n {/* A widget-only message (e.g. images sent without text) has no prose line to render. */}\n {proseText !== \"\" && (\n <Text testId=\"conversation-message-user-text\" allowNewLines translate={false} color={textColor}>\n {escapePlainTextForText(proseText)}\n </Text>\n )}\n </div>\n );\n\n if (widgetsAboveBubble.length === 0) return bubble;\n\n // Widgets placed above the bubble (e.g. attached images) stand on their own, right-aligned; a message that is nothing\n // but such widgets shows no bubble at all.\n return (\n <div className={styles.messageWithWidgetsAboveBubble}>\n <ConversationMessageUserWidgets widgets={widgetsAboveBubble} />\n {(proseText !== \"\" || widgetsInsideBubble.length > 0) && bubble}\n </div>\n );\n};\n","import { useRef, useState, useCallback } from \"react\";\n\ninterface UseTypewriterOptions {\n // Characters per second to reveal\n speed?: number;\n // Minimum interval between UI commits (ms) to reduce re-renders\n commitIntervalMs?: number;\n}\n\nexport const useTypewriter = (options: UseTypewriterOptions = {}) => {\n const { speed = 200, commitIntervalMs = 50 } = options;\n\n const [displayedText, setDisplayedText] = useState<string>(\"\");\n const [isFinished, setIsFinished] = useState<boolean>(false);\n\n const fullTextRef = useRef<string>(\"\");\n const typeRAFRef = useRef<number | null>(null);\n const lastTimestampRef = useRef<number | null>(null);\n const renderedLengthRef = useRef<number>(0);\n const speedRef = useRef<number>(speed);\n const commitIntervalRef = useRef<number>(commitIntervalMs);\n const lastCommitTsRef = useRef<number>(0);\n\n const startTypewriter = useCallback(() => {\n if (typeRAFRef.current !== null) return; // already running\n if (renderedLengthRef.current >= fullTextRef.current.length) return; // nothing to render\n\n const animate = (timestamp: number) => {\n if (lastTimestampRef.current === null) {\n lastTimestampRef.current = timestamp;\n }\n\n const elapsedSeconds = (timestamp - lastTimestampRef.current) / 1000;\n lastTimestampRef.current = timestamp;\n\n const charactersToAdd = Math.max(1, Math.floor(elapsedSeconds * speedRef.current));\n const nextLength = Math.min(fullTextRef.current.length, renderedLengthRef.current + charactersToAdd);\n\n renderedLengthRef.current = nextLength;\n\n // Only commit to React state at most every commitIntervalMs or when finished\n if (\n timestamp - lastCommitTsRef.current >= commitIntervalRef.current ||\n nextLength === fullTextRef.current.length\n ) {\n const nextText = fullTextRef.current.slice(0, nextLength);\n setDisplayedText(nextText);\n lastCommitTsRef.current = timestamp;\n }\n\n if (nextLength < fullTextRef.current.length) {\n typeRAFRef.current = requestAnimationFrame(animate);\n } else {\n typeRAFRef.current = null;\n lastTimestampRef.current = null;\n setIsFinished(true);\n }\n };\n\n typeRAFRef.current = requestAnimationFrame(animate);\n }, []);\n\n const appendText = useCallback(\n (text: string) => {\n if (!text) return;\n fullTextRef.current += text;\n setIsFinished(false);\n startTypewriter();\n },\n [startTypewriter],\n );\n\n const stopTypewriter = useCallback(() => {\n if (typeRAFRef.current !== null) {\n cancelAnimationFrame(typeRAFRef.current);\n typeRAFRef.current = null;\n lastTimestampRef.current = null;\n }\n }, []);\n\n const finishTypewriter = useCallback(() => {\n stopTypewriter();\n setDisplayedText(fullTextRef.current);\n renderedLengthRef.current = fullTextRef.current.length;\n setIsFinished(true);\n }, [stopTypewriter]);\n\n return {\n displayedText,\n appendText,\n stopTypewriter,\n finishTypewriter,\n isFinished,\n };\n};\n","import { useEffect, useRef, useCallback } from \"react\";\n\ninterface UseStreamingTextOptions {\n eventSource?: EventSource;\n onTextChunk?: (chunk: string) => void;\n onError?: () => void;\n onDone?: () => void;\n}\n\nexport const useStreamingText = ({ eventSource, onTextChunk, onError, onDone }: UseStreamingTextOptions) => {\n const bufferRef = useRef<string>(\"\");\n const flushRAFRef = useRef<number | null>(null);\n\n const onTextChunkRef = useRef<typeof onTextChunk>(null);\n const onErrorRef = useRef<typeof onError>(null);\n const onDoneRef = useRef<typeof onDone>(null);\n onTextChunkRef.current = onTextChunk;\n onErrorRef.current = onError;\n onDoneRef.current = onDone;\n\n const flushBuffer = useCallback(() => {\n flushRAFRef.current = null;\n if (!bufferRef.current) return;\n\n const chunk = bufferRef.current;\n bufferRef.current = \"\";\n onTextChunkRef.current?.(chunk);\n }, []);\n\n const finish = useCallback(() => {\n if (flushRAFRef.current !== null) {\n cancelAnimationFrame(flushRAFRef.current);\n flushRAFRef.current = null;\n }\n flushBuffer();\n onDoneRef.current?.();\n }, [flushBuffer]);\n\n const handleMessage = useCallback(\n (event: MessageEvent) => {\n // OpenAI Chat Completions terminator\n if (event.data === \"[DONE]\") {\n finish();\n return;\n }\n\n try {\n const parsed = JSON.parse(event.data);\n\n // Chat Completions streaming delta\n const piece =\n parsed?.choices?.[0]?.delta?.content ??\n // fallback: support simple formats too\n (typeof parsed === \"string\" ? parsed : (parsed?.text ?? \"\"));\n\n // Some servers send a final frame with finish_reason\n const finishReason = parsed?.choices?.[0]?.finish_reason;\n\n if (piece) {\n bufferRef.current += piece;\n if (flushRAFRef.current === null) {\n flushRAFRef.current = requestAnimationFrame(flushBuffer);\n }\n }\n\n if (finishReason === \"stop\") {\n finish();\n }\n } catch (error) {\n console.error(\"Error parsing SSE message:\", error, event.data);\n onErrorRef.current?.();\n }\n },\n [flushBuffer, finish],\n );\n\n const handleError = useCallback(() => {\n onErrorRef.current?.();\n\n if (flushRAFRef.current !== null) {\n cancelAnimationFrame(flushRAFRef.current);\n flushRAFRef.current = null;\n }\n\n flushBuffer();\n }, [flushBuffer]);\n\n useEffect(() => {\n if (typeof window === \"undefined\" || !eventSource) return;\n\n eventSource.addEventListener(\"message\", handleMessage);\n eventSource.addEventListener(\"error\", handleError);\n\n return () => {\n eventSource.removeEventListener(\"message\", handleMessage);\n eventSource.removeEventListener(\"error\", handleError);\n\n if (flushRAFRef.current !== null) {\n cancelAnimationFrame(flushRAFRef.current);\n flushRAFRef.current = null;\n }\n\n flushBuffer();\n };\n }, [eventSource, handleMessage, handleError, flushBuffer]);\n};\n","import { RefObject, useContext, useLayoutEffect } from \"react\";\nimport { WidgetWindowRootContext } from \"../../../../renderer/widget-windowing\";\n\n/**\n * Fade a freshly-delivered assistant reply's rendered block elements in, one after another, instead of\n * popping the whole wall of text in at once. The reveal operates on the DOM blocks the markdown renderer\n * already produces (the direct children of the `[data-markdown-blocks-root]` div that is containerRef's\n * DIRECT child — nested Markdown instances rendered by widgets stamp the same attribute deeper\n * down and must not be picked up) — the markdown string is never split, so code fences, tables, nested\n * lists, and widgets are handled uniformly.\n *\n * - Blocks in view on arrival (tested against the FULL viewport, edge to edge): a quick staggered fade-in\n * (STAGGER_STEP_MS apart, capped at STAGGER_CAP_MS; each block fades over the faster INITIAL_FADE_MS set\n * inline) — the visible screen fills with text down to the bottom edge fast, no hidden band at the bottom.\n * - Blocks below the fold: a single, calmer fade at the CSS default duration the FIRST time any pixel of\n * them enters the scroll root — never replayed, never reversed on scroll-up.\n * - VISIBILITY DEADLINE: whatever the observers did or did not see, every block still hidden\n * VISIBILITY_DEADLINE_MS after the reply arrived becomes plainly visible (no fade) and the observers are\n * dropped. Delivered text must never depend on a scroll event to become readable.\n *\n * Invariants:\n * - Opacity + transform only, never display/visibility/height — hidden blocks keep their final layout space\n * from the first frame, so the pin/reserve machinery in ConversationViewBody sees stable heights and Cmd+F /\n * selection / a11y still find the pending text.\n * - Only fresh static replies animate (the caller gates via `enabled`); streaming is excluded upstream.\n * - Once per message id: a re-render / windowing pass / navigate-away-and-back never replays it.\n * - A block can never be stuck hidden: hiding happens in the same synchronous useLayoutEffect that creates\n * the observer; the deadline and the cleanup both finalize every still-hidden block to visible. (A\n * \"-15% into the viewport\" trigger left the reply's closing question invisible while the pinned-question\n * policy never scrolled — the owner saw the question only after their next send. Hence zero margin AND the\n * deadline.)\n */\n\nconst STAGGER_STEP_MS = 90;\nconst STAGGER_CAP_MS = 720;\n// The initial screen-fill batch fades each block faster than the CSS default (900ms) so the first screen\n// populates snappily; blocks scrolled into view later keep the calmer default fade untouched.\nconst INITIAL_FADE_MS = 550;\n// Scroll-reveal trigger — below-the-fold blocks ONLY (the initial batch tests against the full viewport).\n// Zero margin: a block reveals the moment any pixel of it is inside the scroll root. (A negative bottom\n// margin — \"reveal once the top is 15% up into the viewport\" — left a block whose top sat in that bottom band\n// hidden for good when nothing scrolled; a percentage margin is even measured against the root's WIDTH.)\nconst SCROLL_REVEAL_ROOT_MARGIN = \"0px\";\n// Hard upper bound on hiding: after this, every still-hidden block is made visible without animation.\nexport const VISIBILITY_DEADLINE_MS = 2500;\n\n// Module-scoped so the guard survives unmount/remount of ConversationMessageWidgets (Redux re-render, widget\n// windowing, navigate-away-and-back within the session) — the same one-shot pattern as\n// reloadReopenMessageIdRef in ConversationMessageList.\nconst alreadyRevealedMessageIds = new Set<string | number>();\n\nexport const useFreshMessageBlockReveal = (options: {\n /**\n * The rendered-message container — ConversationMessageWidgets's existing renderedRef. Its DIRECT child must be\n * the reply's own `[data-markdown-blocks-root]` div (ConversationMarkdown renders exactly one Markdown,\n * whose context provider adds no DOM node); the hook queries only that direct child.\n */\n containerRef: RefObject<HTMLDivElement | null>;\n /** fresh && message != null — static fresh assistant replies only. */\n enabled: boolean;\n /** Once-only guard key; when null/undefined the reply animates but is not recorded. */\n messageId?: string | number | null;\n}): void => {\n const { containerRef, enabled, messageId } = options;\n const scrollRoot = useContext(WidgetWindowRootContext);\n\n useLayoutEffect(() => {\n if (!enabled) return;\n if (messageId != null && alreadyRevealedMessageIds.has(messageId)) return;\n if (typeof IntersectionObserver === \"undefined\") return;\n if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n // Markdown rendered outside the chat scroll container (drawer/canvas hosts render their own Markdown\n // instances) has no scroll root and must never inherit the reveal.\n if (scrollRoot == null) return;\n\n // Direct child ONLY (`:scope >`): the shared Markdown component stamps `data-markdown-blocks-root` on\n // every instance, and a widget inside the reply can render its own nested Markdown (e.g.\n // WebSearchAnswer). The reply's own blocks root is always renderedRef's direct child — ConversationMarkdown\n // renders a context provider (no DOM node) around exactly one Markdown — so a descendant query could\n // conflate roots, while the direct-child query can only match the outer one.\n const blocksRoot = containerRef.current?.querySelector(\":scope > [data-markdown-blocks-root]\");\n if (blocksRoot == null) return;\n\n const blocks = Array.from(blocksRoot.children) as HTMLElement[];\n if (blocks.length === 0) return;\n\n for (const block of blocks) block.dataset.blockReveal = \"hidden\";\n if (messageId != null) alreadyRevealedMessageIds.add(messageId);\n\n // The one idempotent end state: observers gone, every still-hidden block plainly visible (the hook's\n // attribute and inline overrides removed — assigning \"revealed\" would start another 900ms fade), blocks\n // already revealed keep their finished state. Reached by the deadline, by cleanup, or by an observer\n // setup failure; queued observer callbacks after it are no-ops.\n let finalized = false;\n let scrollRevealObserver: IntersectionObserver | null = null;\n let initialViewportObserver: IntersectionObserver | null = null;\n const finalize = () => {\n if (finalized) return;\n finalized = true;\n initialViewportObserver?.disconnect();\n scrollRevealObserver?.disconnect();\n for (const block of blocks) {\n if (block.dataset.blockReveal === \"hidden\") {\n delete block.dataset.blockReveal;\n block.style.animationDelay = \"\";\n block.style.animationDuration = \"\";\n }\n }\n };\n const deadline = window.setTimeout(finalize, VISIBILITY_DEADLINE_MS);\n\n // Below-the-fold blocks reveal the first time any pixel of them enters the scroll root — single fade, no delay.\n scrollRevealObserver = new IntersectionObserver(\n (entries, observer) => {\n if (finalized) return;\n for (const entry of entries) {\n if (!entry.isIntersecting) continue;\n (entry.target as HTMLElement).dataset.blockReveal = \"revealed\";\n observer.unobserve(entry.target);\n }\n },\n { root: scrollRoot, rootMargin: SCROLL_REVEAL_ROOT_MARGIN, threshold: 0 },\n );\n\n // The initial pass fires exactly once, right after observe(), with every block's intersection state\n // against the FULL viewport (no trigger margin): everything visible — under the pinned question, down\n // to the bottom edge — reveals staggered, so the first screen is completely filled with text. The\n // blocks below the fold are handed to scrollRevealObserver.\n initialViewportObserver = new IntersectionObserver(\n (entries, observer) => {\n if (finalized) return;\n let staggerIndex = 0;\n for (const entry of entries) {\n const block = entry.target as HTMLElement;\n if (entry.isIntersecting) {\n block.style.animationDelay = `${Math.min(staggerIndex * STAGGER_STEP_MS, STAGGER_CAP_MS)}ms`;\n block.style.animationDuration = `${INITIAL_FADE_MS}ms`;\n staggerIndex++;\n block.dataset.blockReveal = \"revealed\";\n } else {\n scrollRevealObserver?.observe(block);\n }\n }\n observer.disconnect();\n },\n { root: scrollRoot, threshold: 0 },\n );\n\n for (const block of blocks) initialViewportObserver.observe(block);\n\n return () => {\n window.clearTimeout(deadline);\n finalize();\n };\n }, [enabled, messageId, scrollRoot, containerRef]);\n};\n","import { Icon, Text } from \"../../../../provider/components\";\nimport type { ChatAssistantCategory, ChatAssistantIdentity } from \"../../../chat-assistant-identity\";\nimport React, { memo } from \"react\";\nimport styles from \"./ConversationMessageHeader.module.scss\";\n\nexport interface ConversationMessageHeaderProps {\n aiPromptExtensionCategory?: ChatAssistantCategory;\n aiPromptExtension?: ChatAssistantIdentity;\n}\n\nexport const ConversationMessageHeader = memo((props: ConversationMessageHeaderProps) => {\n const { aiPromptExtensionCategory, aiPromptExtension } = props;\n\n // The extension's icon class is an icon of the app's icon set.\n const iconName = aiPromptExtension?.iconClass ?? \"ai\";\n\n return (\n <div className={styles.responseHeader}>\n <span className={styles.iconContainer}>\n <Icon color=\"var(--agents-fg-on-accent)\" hostIconName={iconName} />\n </span>\n <div>\n <Text role=\"help\" weight=\"bold\">\n {aiPromptExtension?.name ?? \"AI Extensions\"}\n </Text>\n {aiPromptExtensionCategory !== undefined ? (\n <Text role=\"caption\" replacements={{ productName: aiPromptExtensionCategory?.name }}>\n %productName% Assistant\n </Text>\n ) : null}\n {aiPromptExtensionCategory === undefined ? (\n <Text role=\"caption\">Assistant</Text>\n ) : null}\n </div>\n </div>\n );\n});\n","export async function copyRichToClipboard(plainText: string, html: string) {\n if (!plainText) {\n console.warn(\"No text to copy\");\n return;\n }\n\n if (!navigator.clipboard) {\n console.warn(\"Clipboard API not available\");\n return;\n }\n\n if (!(html && typeof ClipboardItem !== \"undefined\" && navigator.clipboard.write)) {\n console.warn(\"Clipboard does not support rich text, copying plain text only\");\n return navigator.clipboard.writeText(plainText);\n }\n try {\n const item = new ClipboardItem({\n \"text/plain\": new Blob([plainText], { type: \"text/plain\" }),\n \"text/html\": new Blob([html], { type: \"text/html\" }),\n });\n return navigator.clipboard.write([item]);\n } catch (error) {\n console.error(\"Failed to copy rich text to clipboard:\", error);\n return navigator.clipboard.writeText(plainText);\n }\n}\n","import { Button } from \"../../../provider/components\";\nimport type { ChatAssistantCategory, ChatAssistantIdentity } from \"../../chat-assistant-identity\";\nimport React, { memo, useCallback, useEffect, useRef, useState } from \"react\";\nimport styles from \"./ConversationMessageWidgets.module.scss\";\nimport { useTypewriter } from \"./hooks/useTypewriter\";\nimport { useStreamingText } from \"./hooks/useStreamingText\";\nimport { useFreshMessageBlockReveal } from \"./hooks/useFreshMessageBlockReveal\";\nimport { ConversationMessageHeader } from \"./ConversationMessageHeader/ConversationMessageHeader\";\nimport { ConversationMarkdown } from \"../../../renderer/ConversationMarkdown\";\nimport { copyRichToClipboard } from \"./copyRichToClipboard\";\nimport { normalizeServerMessageToMarkdown } from \"../../normalize-server-message-to-markdown\";\nimport { stripPreCallMessageMarker } from \"../../strip-pre-call-message-marker\";\nimport { useAgentsEnvironment } from \"../../../provider/AgentsProvider\";\n\nexport interface ConversationMessageWidgetsProps {\n aiPromptExtensionCategory?: ChatAssistantCategory;\n aiPromptExtension?: ChatAssistantIdentity;\n eventSource?: EventSource;\n message?: unknown;\n /**\n * The reply's widgets may be used (buttons, forms, hydration refresh): a live-delivered reply, and the newest reply\n * after a reload. Forwarded to every widget as `interactive` (+ the deprecated alias `fresh`).\n */\n interactive?: boolean;\n /**\n * The reply was delivered live right now — never after a reload. Forwarded to every widget as `justDelivered`, the\n * only gate for one-shot side effects (canvas open, draft creation), and the gate of the block reveal.\n */\n justDelivered?: boolean;\n hideWidgets?: boolean;\n /** Id of the host message: once-only guard of the block reveal, and the identity of a canvas opened from it. */\n messageId?: string | number | null;\n /**\n * Hide the assistant header (icon + name + \"Assistant\") and the copy button.\n * Used by a host, which renders bare assistant messages.\n */\n hideAssistantMeta?: boolean;\n /** Opt-in staggered fade-in of this fresh reply's markdown blocks (see useFreshMessageBlockReveal). Default off. */\n enableFreshMessageBlockReveal?: boolean;\n}\n\nexport const ConversationMessageWidgets = memo((props: ConversationMessageWidgetsProps) => {\n const {\n aiPromptExtensionCategory,\n aiPromptExtension,\n eventSource,\n message,\n interactive = false,\n justDelivered = false,\n hideWidgets = false,\n hideAssistantMeta = false,\n enableFreshMessageBlockReveal = false,\n messageId,\n } = props;\n const { MessageFooter } = useAgentsEnvironment();\n\n const [copied, setCopied] = useState(false);\n const timeoutRef = useRef<number | null>(null);\n const renderedRef = useRef<HTMLDivElement | null>(null);\n\n const { displayedText, appendText, finishTypewriter } = useTypewriter({\n speed: 200,\n commitIntervalMs: 100,\n });\n\n useEffect(() => {\n return () => {\n if (timeoutRef.current != null) window.clearTimeout(timeoutRef.current);\n };\n }, []);\n\n // Only stream when no static message is provided\n useStreamingText({\n eventSource: message != null ? undefined : eventSource,\n onTextChunk: appendText,\n onError: finishTypewriter,\n onDone: finishTypewriter,\n });\n\n // If a message is provided, render it directly; otherwise render streamed text\n // Static message → normalize (already strips the {preCallMessage} sentinel); live stream → strip it here too.\n const textToRender =\n message != null ? normalizeServerMessageToMarkdown(message) : stripPreCallMessageMarker(displayedText);\n\n // (The former \"a fresh widget message closes the open canvas\" layout effect is gone: a canvas is superseded only\n // by another canvas being opened — and a pinned canvas survives a widget reply.)\n\n // Fade the just-delivered reply's rendered blocks in (staggered in view, once on scroll below the fold). Static\n // live-delivered assistant replies only — never after a reload, and the streaming path (message == null) renders\n // progressively already.\n useFreshMessageBlockReveal({\n containerRef: renderedRef,\n enabled: enableFreshMessageBlockReveal && justDelivered && message != null,\n messageId,\n });\n\n const onCopy = useCallback(async () => {\n const fallbackText = textToRender || \"\";\n const plain = renderedRef.current?.innerText?.trim() || fallbackText;\n const html = renderedRef.current?.innerHTML || \"\";\n\n await copyRichToClipboard(plain, html);\n\n setCopied(true);\n if (timeoutRef.current != null) window.clearTimeout(timeoutRef.current);\n timeoutRef.current = window.setTimeout(() => setCopied(false), 2000);\n }, [textToRender]);\n\n return (\n <div className={styles.responseContainer}>\n {!hideAssistantMeta ? (\n <ConversationMessageHeader\n aiPromptExtensionCategory={aiPromptExtensionCategory}\n aiPromptExtension={aiPromptExtension}\n />\n ) : null}\n <div className={styles.responseMessage}>\n <div ref={renderedRef}>\n {/* TODO: move the markdown component into the component library */}\n <ConversationMarkdown\n markdown={textToRender}\n interactive={interactive}\n justDelivered={justDelivered}\n messageId={messageId ?? undefined}\n hideWidgets={hideWidgets}\n />\n </div>\n\n {!hideAssistantMeta ? (\n <Button\n variant=\"muted\"\n icon={copied ? \"check\" : \"duplicate\"}\n onClick={onCopy}\n size=\"small\"\n />\n ) : null}\n </div>\n\n {/* The app's footer under the message (for example an admin-only trace footer that gates itself). */}\n {MessageFooter ? <MessageFooter message={message} /> : null}\n </div>\n );\n});\n","import styles from \"./VoiceBarsIcon.module.scss\";\n\nexport interface VoiceBarsIconProps {\n /** Edge length in px; the bars take the current text colour. */\n size?: number;\n}\n\n/**\n * Five sound bars, the tallest in the middle — the mark of an in-app voice call with the agent.\n */\nexport const VoiceBarsIcon = (props: VoiceBarsIconProps) => {\n const { size = 18 } = props;\n return (\n <svg className={styles.icon} width={size} height={size} viewBox=\"0 0 24 24\" aria-hidden focusable=\"false\">\n <path d=\"M3.5 10.5v3M7.75 8v8M12 4.5v15M16.25 8v8M20.5 10.5v3\" />\n </svg>\n );\n};\n"],"names":["message","styles"],"mappings":";;;;;;AA4BA,MAAM,uBAAuB;AAc7B,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AA,GACN;AAAA,IAGC,gBAAgB,oBAAC,eAAA,EAAc,SAAAD,SAAA,CAAkB,IAAK;AAAA,EAAA,GACzD;AAEJ,CAAC;;;;;ACpIM,MAAM,gBAAgB,CAAC,UAA8B;AAC1D,QAAM,EAAE,OAAO,GAAA,IAAO;AACtB,6BACG,OAAA,EAAI,WAAW,OAAO,MAAM,OAAO,MAAM,QAAQ,MAAM,SAAQ,aAAY,eAAW,MAAC,WAAU,SAChG,8BAAC,QAAA,EAAK,GAAE,wDAAuD,EAAA,CACjE;AAEJ;"}
|
|
@@ -3075,7 +3075,7 @@ const ConversationWidgetAgentSpaceHeader = (props) => {
|
|
|
3075
3075
|
const label2 = data?.name ?? buildUnnamedAgentSpaceLabel(agentSpaceKey);
|
|
3076
3076
|
const explanation = buildWidgetOfAnotherAgentSpaceExplanation(label2);
|
|
3077
3077
|
const noteLabel = translateText("Showing data for %label%", { label: label2 });
|
|
3078
|
-
return /* @__PURE__ */ jsx("div", { className: inFlow ? styles$a.inFlowAnchor : styles$a.anchor, children: /* @__PURE__ */ jsx(Tooltip, { text: explanation, placement: "top", dark: true, wrapsChild: true, children: /* @__PURE__ */ jsx("span", { className: styles$a.root, role: "note", "aria-label": noteLabel, tabIndex: 0, children: /* @__PURE__ */ jsx("span", { className: styles$a.name, children: label2 }) }) }) });
|
|
3078
|
+
return /* @__PURE__ */ jsx("div", { className: inFlow ? styles$a.inFlowAnchor : styles$a.anchor, children: /* @__PURE__ */ jsx(Tooltip, { text: escapePlainTextForText(explanation), placement: "top", dark: true, wrapsChild: true, children: /* @__PURE__ */ jsx("span", { className: styles$a.root, role: "note", "aria-label": noteLabel, tabIndex: 0, children: /* @__PURE__ */ jsx("span", { className: styles$a.name, children: label2 }) }) }) });
|
|
3079
3079
|
};
|
|
3080
3080
|
const CANVAS_VIABLE_MIN_WIDTH = 850;
|
|
3081
3081
|
const isViewportViable = () => typeof window === "undefined" || window.innerWidth >= CANVAS_VIABLE_MIN_WIDTH;
|
|
@@ -5276,4 +5276,4 @@ export {
|
|
|
5276
5276
|
ConversationWidgetContext as y,
|
|
5277
5277
|
ConversationWidgetRenderContext as z
|
|
5278
5278
|
};
|
|
5279
|
-
//# sourceMappingURL=WebSearchResultsConversationWidget-
|
|
5279
|
+
//# sourceMappingURL=WebSearchResultsConversationWidget-D0cAmxr9.js.map
|