Skip to content

Commit f6c3f84

Browse files
committed
running query gives content
1 parent 5e1647d commit f6c3f84

4 files changed

Lines changed: 23 additions & 9 deletions

File tree

src/components/AIStatusIndicator/AssistantModes.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export const getIsExpandableSection = (section: OperationSection) => {
8282
AIOperationStatus.InvestigatingTable,
8383
AIOperationStatus.InvestigatingDocs,
8484
AIOperationStatus.Thinking,
85+
AIOperationStatus.RunningQuery,
8586
].includes(section.type)
8687
}
8788

src/components/AIStatusIndicator/AssistantModesCompact.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,12 @@ export const AssistantModesCompact: React.FC<AssistantModesCompactProps> = ({
361361
nextSection,
362362
!nextSection ? endTimestamp : undefined,
363363
)
364-
const thinkingSegmentText =
365-
section.type === AIOperationStatus.Thinking
366-
? (section.operations[0]?.content ?? "")
367-
: ""
364+
const isContentSection =
365+
section.type === AIOperationStatus.Thinking ||
366+
section.type === AIOperationStatus.RunningQuery
367+
const sectionContentText = isContentSection
368+
? (section.operations[0]?.content ?? "")
369+
: ""
368370

369371
return (
370372
<ModeHeader
@@ -414,16 +416,16 @@ export const AssistantModesCompact: React.FC<AssistantModesCompactProps> = ({
414416
)}
415417
</Box>
416418
</ModeHeaderTop>
417-
{isExpandable && section.type === AIOperationStatus.Thinking && (
419+
{isExpandable && isContentSection && (
418420
<ExpandableWrapper $expanded={isExpanded}>
419421
<ExpandableContent>
420-
{thinkingSegmentText ? (
421-
<ThinkingContent>{thinkingSegmentText}</ThinkingContent>
422+
{sectionContentText ? (
423+
<ThinkingContent>{sectionContentText}</ThinkingContent>
422424
) : null}
423425
</ExpandableContent>
424426
</ExpandableWrapper>
425427
)}
426-
{isExpandable && section.type !== AIOperationStatus.Thinking && (
428+
{isExpandable && !isContentSection && (
427429
<ExpandableWrapper $expanded={isExpanded}>
428430
<ExpandableContent>
429431
<ReasoningThread>

src/providers/AIStatusProvider/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export type StatusArgs = {
7070
items?: Array<{ name: string; section?: string }>
7171
label?: string
7272
cellId?: string
73+
content?: string
7374
}
7475

7576
export type StatusEntry = {
@@ -186,6 +187,9 @@ export const AIStatusProvider: React.FC<AIStatusProviderProps> = ({
186187
type: newStatus,
187188
args: normalizedArgs ?? undefined,
188189
timestamp: Date.now(),
190+
...(normalizedArgs?.content !== undefined && {
191+
content: normalizedArgs.content,
192+
}),
189193
}
190194
if (
191195
statusRef.current === null ||

src/utils/tools/dispatch.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { buildRunQueryPayload, RUN_QUERY_DEFAULT_LIMIT } from "./runQuery"
3131
import { eventBus } from "../../modules/EventBus"
3232
import { EventType } from "../../modules/EventBus/types"
3333
import type { ToolExecutionContext } from "../ai/shared"
34+
import { formatSql } from "../formatSql"
3435

3536
const notebookErrorHint = (code: NotebookToolErrorCode): string => {
3637
switch (code) {
@@ -752,7 +753,13 @@ export const dispatchTool = async (
752753
return { content: decision.reason, is_error: true }
753754
}
754755
}
755-
setStatus(AIOperationStatus.RunningQuery)
756+
let formattedSql = sql
757+
try {
758+
formattedSql = formatSql(sql)
759+
} catch {
760+
// Fall back to raw SQL if the formatter can't parse it.
761+
}
762+
setStatus(AIOperationStatus.RunningQuery, { content: formattedSql })
756763
try {
757764
const requestedLimit =
758765
typeof limit === "number" && Number.isFinite(limit)

0 commit comments

Comments
 (0)