@@ -4,13 +4,15 @@ import { AppIcon } from "@/components/app-square";
44import { Badge , Button , ScrollArea } from "@/components/ui" ;
55import { ALL_APPS_FRONTEND , getAppPath , getItemPath } from "@/lib/apps-frontend" ;
66import { getUninstalledAppIds } from "@/lib/apps-utils" ;
7+ import { classifyClickHouseSqlVsPrompt } from "@/lib/classify-query" ;
78import { cn } from "@/lib/utils" ;
89import { CheckIcon , CubeIcon , DownloadSimpleIcon , GearIcon , GlobeIcon , InfoIcon , KeyIcon , LayoutIcon , LightningIcon , PlayIcon , ShieldCheckIcon , SparkleIcon } from "@phosphor-icons/react" ;
910import { ALL_APPS , ALL_APP_TAGS , type AppId } from "@stackframe/stack-shared/dist/apps/apps-config" ;
1011import { runAsynchronouslyWithAlert } from "@stackframe/stack-shared/dist/utils/promises" ;
1112import Image from "next/image" ;
1213import React , { memo , useEffect , useMemo } from "react" ;
1314import { AIChatPreview } from "./commands/ask-ai" ;
15+ import { RunQueryPreview } from "./commands/run-query" ;
1416
1517export type CmdKPreviewProps = {
1618 isSelected : boolean ,
@@ -29,38 +31,6 @@ export type CmdKPreviewProps = {
2931 pathname : string ,
3032} ;
3133
32- // Run Query Preview Component - shows a TODO message for now
33- const RunQueryPreview = memo ( function RunQueryPreview ( {
34- query,
35- } : CmdKPreviewProps ) {
36- return (
37- < div className = "flex flex-col h-full w-full items-center justify-center p-6" >
38- < div className = "flex flex-col items-center gap-4 max-w-md text-center" >
39- < div className = "w-16 h-16 rounded-2xl bg-amber-500/10 flex items-center justify-center" >
40- < PlayIcon className = "h-8 w-8 text-amber-500" />
41- </ div >
42- < div >
43- < h3 className = "text-lg font-semibold text-foreground mb-2" > Run Query</ h3 >
44- < p className = "text-sm text-muted-foreground mb-4" >
45- Execute actions using natural language commands.
46- </ p >
47- </ div >
48- < div className = "w-full p-4 rounded-xl bg-amber-500/5 border border-amber-500/20" >
49- < p className = "text-xs text-amber-600 dark:text-amber-400 font-medium mb-2" > Your query:</ p >
50- < p className = "text-sm text-foreground italic" > “{ query } ”</ p >
51- </ div >
52- < div className = "mt-4 p-4 rounded-xl bg-muted/50 border border-border" >
53- < p className = "text-xs text-muted-foreground" >
54- 🚧 < span className = "font-medium" > Coming Soon</ span > — This feature is under development.
55- Soon you'll be able to run queries like “create a new user”,
56- “list all teams”, or “update project settings”.
57- </ p >
58- </ div >
59- </ div >
60- </ div >
61- ) ;
62- } ) ;
63-
6434// Create Dashboard Preview Component - shows a TODO message for now
6535const CreateDashboardPreview = memo ( function CreateDashboardPreview ( {
6636 query,
@@ -351,6 +321,8 @@ export function useCmdKCommands({
351321} ) : CmdKCommand [ ] {
352322 return useMemo ( ( ) => {
353323 const commands : CmdKCommand [ ] = [ ] ;
324+ const queryClassification = classifyClickHouseSqlVsPrompt ( query , { readonlyOnly : true } ) ;
325+ const shouldPrioritizeRunQuery = queryClassification . kind === "sql" ;
354326
355327 // Overview
356328 commands . push ( {
@@ -453,7 +425,7 @@ export function useCmdKCommands({
453425
454426 // AI-powered options (only when there's a query)
455427 if ( query . trim ( ) ) {
456- commands . push ( {
428+ const askAiCommand : CmdKCommand = {
457429 id : "ai/ask" ,
458430 icon : < SparkleIcon className = "h-3.5 w-3.5 text-purple-400" /> ,
459431 label : `Ask AI` ,
@@ -463,19 +435,25 @@ export function useCmdKCommands({
463435 preview : AIChatPreview ,
464436 hasVisualPreview : true ,
465437 highlightColor : "purple" ,
466- } ) ;
438+ } ;
467439
468- commands . push ( {
440+ const runQueryCommand : CmdKCommand = {
469441 id : "query/run" ,
470442 icon : < PlayIcon className = "h-3.5 w-3.5 text-amber-500" /> ,
471443 label : `Run Query` ,
472- description : "Execute actions using natural language " ,
473- keywords : [ "run" , "execute" , "query" , "action" , "command" , "vibecode" ] ,
444+ description : "Execute ClickHouse SQL analytics queries " ,
445+ keywords : [ "run" , "execute" , "query" , "action" , "command" , "vibecode" , "sql" , "clickhouse" , "analytics" ] ,
474446 onAction : { type : "focus" } ,
475447 preview : RunQueryPreview ,
476448 hasVisualPreview : true ,
477449 highlightColor : "gold" ,
478- } ) ;
450+ } ;
451+
452+ const orderedQueryCommands = shouldPrioritizeRunQuery
453+ ? [ runQueryCommand , askAiCommand ]
454+ : [ askAiCommand , runQueryCommand ] ;
455+
456+ commands . push ( ...orderedQueryCommands ) ;
479457
480458 commands . push ( {
481459 id : "create/dashboard" ,
0 commit comments