Skip to content

Commit eb5ad2b

Browse files
committed
On page load use the most recent query (fallback to default)
1 parent ad3f65f commit eb5ad2b

File tree

1 file changed

+6
-2
lines changed
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query

1 file changed

+6
-2
lines changed

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,10 @@ export default function Page() {
332332
const results = useTypedActionData<typeof action>();
333333
const navigation = useNavigation();
334334

335+
// Use most recent history item if available, otherwise fall back to defaults
336+
const initialQuery = history.length > 0 ? history[0].query : defaultQuery;
337+
const initialScope: QueryScope = history.length > 0 ? history[0].scope : "environment";
338+
335339
const editorRef = useRef<QueryEditorFormHandle>(null);
336340
const [prettyFormatting, setPrettyFormatting] = useState(true);
337341
const [resultsView, setResultsView] = useState<"table" | "graph">("table");
@@ -368,8 +372,8 @@ export default function Page() {
368372
{/* Query editor - isolated component to prevent re-renders */}
369373
<QueryEditorForm
370374
ref={editorRef}
371-
defaultQuery={defaultQuery}
372-
defaultScope="environment"
375+
defaultQuery={initialQuery}
376+
defaultScope={initialScope}
373377
history={history}
374378
isLoading={isLoading}
375379
/>

0 commit comments

Comments
 (0)