Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/docs/content/docs/en/tools/exa.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ Search the web using Exa AI. Returns relevant search results with titles, URLs,
| `highlights` | boolean | No | Include highlighted snippets in results \(default: false\) |
| `summary` | boolean | No | Include AI-generated summaries in results \(default: false\) |
| `livecrawl` | string | No | Live crawling mode: never \(default\), fallback, always, or preferred \(always try livecrawl, fall back to cache if fails\) |
| `startCrawlDate` | string | No | Only include results crawled on or after this ISO 8601 date \(e.g., "2024-01-01" or "2024-01-01T00:00:00.000Z"\) |
| `endCrawlDate` | string | No | Only include results crawled on or before this ISO 8601 date |
| `startPublishedDate` | string | No | Only include results published on or after this ISO 8601 date |
| `endPublishedDate` | string | No | Only include results published on or before this ISO 8601 date |
| `apiKey` | string | Yes | Exa AI API Key |
| `pricing` | custom | No | No description |
| `metadata` | string | No | No description |
Expand Down
10 changes: 10 additions & 0 deletions apps/sim/app/workspace/[workspaceId]/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,21 @@ export function Home({ chatId }: HomeProps = {}) {
editQueuedMessage,
previewSession,
genericResourceData,
getCurrentRequestId,
} = useChat(
workspaceId,
chatId,
getMothershipUseChatOptions({
onResourceEvent: handleResourceEvent,
initialActiveResourceId: initialResourceId,
onRequestStarted: ({ requestId, userMessageId }) => {
captureEvent(posthogRef.current, 'task_request_started', {
workspace_id: workspaceId,
view: 'mothership',
request_id: requestId,
user_message_id: userMessageId,
})
},
})
)

Expand Down Expand Up @@ -198,6 +207,7 @@ export function Home({ chatId }: HomeProps = {}) {
captureEvent(posthogRef.current, 'task_generation_aborted', {
workspace_id: workspaceId,
view: 'mothership',
request_id: getCurrentRequestId(),
})
void stopGeneration().catch(() => {})
}
Expand Down
26 changes: 24 additions & 2 deletions apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export interface UseChatReturn {
editQueuedMessage: (id: string) => QueuedMessage | undefined
previewSession: FilePreviewSession | null
genericResourceData: GenericResourceData | null
getCurrentRequestId: () => string | undefined
}

const DEPLOY_TOOL_NAMES: Set<string> = new Set([
Expand Down Expand Up @@ -1278,6 +1279,8 @@ export interface UseChatOptions {
onTitleUpdate?: () => void
onStreamEnd?: (chatId: string, messages: ChatMessage[]) => void
initialActiveResourceId?: string | null
/** Fired when the server's `traceparent` response header arrives, before any stream content. */
onRequestStarted?: (info: { requestId: string; userMessageId: string }) => void
}

interface ActiveStreamRecovery {
Expand All @@ -1293,7 +1296,10 @@ interface StopGenerationOptions {
}

export function getMothershipUseChatOptions(
options: Pick<UseChatOptions, 'onResourceEvent' | 'onStreamEnd' | 'initialActiveResourceId'> = {}
options: Pick<
UseChatOptions,
'onResourceEvent' | 'onStreamEnd' | 'initialActiveResourceId' | 'onRequestStarted'
> = {}
): UseChatOptions {
return {
apiPath: MOTHERSHIP_CHAT_API_PATH,
Expand All @@ -1305,7 +1311,7 @@ export function getMothershipUseChatOptions(
export function getWorkflowCopilotUseChatOptions(
options: Pick<
UseChatOptions,
'workflowId' | 'onToolResult' | 'onTitleUpdate' | 'onStreamEnd'
'workflowId' | 'onToolResult' | 'onTitleUpdate' | 'onStreamEnd' | 'onRequestStarted'
> = {}
): UseChatOptions {
return {
Expand Down Expand Up @@ -1351,6 +1357,13 @@ export function useChat(
onTitleUpdateRef.current = options?.onTitleUpdate
const onStreamEndRef = useRef(options?.onStreamEnd)
onStreamEndRef.current = options?.onStreamEnd
const onRequestStartedRef = useRef(options?.onRequestStarted)
onRequestStartedRef.current = options?.onRequestStarted

const getCurrentRequestId = useCallback(() => {
const traceId = streamTraceparentRef.current?.split('-')[1] ?? ''
return /^[0-9a-f]{32}$/.test(traceId) ? traceId : undefined
}, [])

const clearQueueDispatchState = useCallback(() => {
queueDispatchEpochRef.current++
Expand Down Expand Up @@ -4209,6 +4222,14 @@ export function useChat(
if (traceparent) {
streamTraceparentRef.current = traceparent
setCurrentChatTraceparent(traceparent)
const traceId = traceparent.split('-')[1] ?? ''
if (/^[0-9a-f]{32}$/.test(traceId)) {
try {
onRequestStartedRef.current?.({ requestId: traceId, userMessageId })
} catch (callbackError) {
logger.warn('onRequestStarted callback threw', { error: callbackError })
}
}
}

if (!response.ok) {
Expand Down Expand Up @@ -5103,5 +5124,6 @@ export function useChat(
editQueuedMessage,
previewSession,
genericResourceData,
getCurrentRequestId,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function ExpandedCellPopover({
return
}
setDraftValue(isEditable ? formatValueForInput(target.value, target.column.type) : '')
const selector = `[data-table-scroll] [data-row="${target.row.position}"][data-col="${target.colIndex}"]`
const selector = `[data-table-scroll] [data-row-id="${target.row.id}"][data-col="${target.colIndex}"]`
const el = document.querySelector<HTMLElement>(selector)
if (!el) {
setRect(null)
Expand Down
Loading
Loading