Skip to content

Commit 487b451

Browse files
committed
validation flow
1 parent eee1cdb commit 487b451

File tree

11 files changed

+251
-90
lines changed

11 files changed

+251
-90
lines changed

src/components/AIStatusIndicator/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,13 @@ const getIsExpandableSection = (section: OperationSection) => {
462462
AIOperationStatus.RetrievingDocumentation,
463463
AIOperationStatus.FormattingResponse,
464464
AIOperationStatus.Aborted,
465+
AIOperationStatus.ValidatingQuery,
465466
].includes(section.type)
466467
}
467468

468469
export const AIStatusIndicator: React.FC = () => {
469470
const { status, currentOperation, currentModel } = useAIStatus()
470-
const [expanded, setExpanded] = useState(false)
471+
const [expanded, setExpanded] = useState(true)
471472
const [collapsedSections, setCollapsedSections] = useState<
472473
Record<string, boolean>
473474
>({})

src/components/ExplainQueryButton/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type {
1111
import {
1212
explainQuery,
1313
formatExplanationAsComment,
14-
createSchemaClient,
14+
createModelToolsClient,
1515
isAiAssistantError,
1616
type ActiveProviderSettings,
1717
} from "../../utils/aiAssistant"
@@ -85,9 +85,6 @@ export const ExplainQueryButton = ({ onBufferContentChange }: Props) => {
8585
value: "Query explanation in progress",
8686
},
8787
})
88-
const schemaClient = hasSchemaAccess
89-
? createSchemaClient(tables, quest)
90-
: undefined
9188
const provider = providerForModel(currentModel)
9289

9390
const settings: ActiveProviderSettings = {
@@ -99,7 +96,10 @@ export const ExplainQueryButton = ({ onBufferContentChange }: Props) => {
9996
const response = await explainQuery({
10097
query: queriesToRun[0],
10198
settings,
102-
schemaClient,
99+
modelToolsClient: createModelToolsClient(
100+
quest,
101+
hasSchemaAccess ? tables : undefined,
102+
),
103103
setStatus,
104104
abortSignal: abortController?.signal,
105105
})

src/components/GenerateSQLButton/index.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type { AiAssistantAPIError, GeneratedSQL } from "../../utils/aiAssistant"
1515
import {
1616
generateSQL,
1717
formatExplanationAsComment,
18-
createSchemaClient,
18+
createModelToolsClient,
1919
isAiAssistantError,
2020
type ActiveProviderSettings,
2121
} from "../../utils/aiAssistant"
@@ -143,10 +143,6 @@ export const GenerateSQLButton = ({ onBufferContentChange }: Props) => {
143143
toast.error("No model selected for AI Assistant")
144144
return
145145
}
146-
147-
const schemaClient = hasSchemaAccessValue
148-
? createSchemaClient(tables, quest)
149-
: undefined
150146
const provider = providerForModel(currentModel)
151147

152148
const settings: ActiveProviderSettings = {
@@ -158,7 +154,10 @@ export const GenerateSQLButton = ({ onBufferContentChange }: Props) => {
158154
const response = await generateSQL({
159155
description,
160156
settings,
161-
schemaClient,
157+
modelToolsClient: createModelToolsClient(
158+
quest,
159+
hasSchemaAccessValue ? tables : undefined,
160+
),
162161
setStatus,
163162
abortSignal: abortController?.signal,
164163
})

src/providers/AIStatusProvider/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export enum AIOperationStatus {
4343
InvestigatingTableSchema = "Investigating table schema",
4444
RetrievingDocumentation = "Reviewing docs",
4545
InvestigatingDocs = "Investigating docs",
46+
ValidatingQuery = "Validating generated query",
4647
FormattingResponse = "Formatting response",
4748
Aborted = "Operation has been cancelled",
4849
}

src/scenes/Editor/ButtonBar/FixQueryButton.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type {
88
} from "../../../utils/aiAssistant"
99
import {
1010
isAiAssistantError,
11-
createSchemaClient,
11+
createModelToolsClient,
1212
fixQuery,
1313
type ActiveProviderSettings,
1414
} from "../../../utils/aiAssistant"
@@ -147,9 +147,6 @@ export const FixQueryButton = ({
147147
value: "Query fix in progress",
148148
},
149149
})
150-
const schemaClient = hasSchemaAccess
151-
? createSchemaClient(tables, quest)
152-
: undefined
153150
const provider = providerForModel(currentModel)
154151

155152
const settings: ActiveProviderSettings = {
@@ -162,7 +159,10 @@ export const FixQueryButton = ({
162159
query: queryText,
163160
errorMessage,
164161
settings,
165-
schemaClient,
162+
modelToolsClient: createModelToolsClient(
163+
quest,
164+
hasSchemaAccess ? tables : undefined,
165+
),
166166
setStatus,
167167
abortSignal: abortController?.signal,
168168
word,

src/scenes/Editor/DiffEditor/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ const ExplanationText = styled.p`
8080
background: #2d303e;
8181
border: 1px solid #44475a;
8282
border-radius: 0.6rem;
83-
padding: 0.1rem 0.3rem;
83+
padding: 0 0.3rem;
8484
display: inline-flex;
8585
gap: 1rem;
8686
align-items: center;

0 commit comments

Comments
 (0)