From 20b7660f3c4997a535397d6e4e0737601acaad07 Mon Sep 17 00:00:00 2001 From: Matt Aitken Date: Sat, 20 Dec 2025 23:41:44 +0000 Subject: [PATCH] Better UI for trying queries --- .../route.tsx | 142 ++++++++++++------ 1 file changed, 95 insertions(+), 47 deletions(-) diff --git a/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx b/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx index f28c04349..f47fc6e0a 100644 --- a/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx +++ b/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx @@ -509,7 +509,7 @@ function QueryHelpSidebar({ value="guide" className="min-h-0 flex-1 overflow-y-auto p-3 scrollbar-thin scrollbar-track-transparent scrollbar-thumb-charcoal-600" > - + void; + className?: string; +}) { + return ( +
+ + {onTry && ( +
+ +
+ )} +
+ ); +} + +function TRQLGuideContent({ + onTryExample, +}: { + onTryExample: (query: string, scope: QueryScope) => void; +}) { return (
{/* Table of contents */} @@ -557,26 +591,35 @@ function TRQLGuideContent() { Select columns from a table. Use * to select all columns, or list specific columns. - + onTryExample( + `SELECT run_id, task_identifier, status +FROM runs +LIMIT 10`, + "environment" + ) + } /> - + Alias columns with AS: - + onTryExample( + `SELECT task_identifier AS task, count() AS total +FROM runs +GROUP BY task`, + "environment" + ) + } + className="mt-1" /> @@ -589,19 +632,23 @@ GROUP BY task`} >, <=,{" "} >= - now() - INTERVAL 1 DAY`} - language="sql" - showLineNumbers={false} - showOpenInModal={false} - className="text-xs" + onTry={() => + onTryExample( + `SELECT * FROM runs +WHERE status = 'Failed' + AND created_at > now() - INTERVAL 1 DAY`, + "environment" + ) + } /> - + Other operators: - @@ -630,15 +674,20 @@ WHERE completed_at IS NOT NULL`} Sort results with ORDER BY (ASC/DESC). Limit results with{" "} LIMIT. - + onTryExample( + `SELECT run_id, compute_cost, created_at +FROM runs +ORDER BY compute_cost DESC, created_at ASC +LIMIT 50`, + "environment" + ) + } /> @@ -649,7 +698,7 @@ LIMIT 50`} Use GROUP BY with aggregate functions. Filter groups with{" "} HAVING. - 10 ORDER BY run_count DESC`} - language="sql" - showLineNumbers={false} - showOpenInModal={false} - className="text-xs" + onTry={() => + onTryExample( + `SELECT + task_identifier, + status, + count() AS run_count, + avg(usage_duration) AS avg_duration +FROM runs +GROUP BY task_identifier, status +HAVING run_count > 10 +ORDER BY run_count DESC`, + "environment" + ) + } /> @@ -859,21 +918,10 @@ function ExamplesContent({ {example.description} - onTryExample(example.query, example.scope)} /> -
))}