From bcffb9d2455edb9b7df2e1e768ce1ee4b1ffbe8e Mon Sep 17 00:00:00 2001
From: Vaibhav <117663341+7ttp@users.noreply.github.com>
Date: Fri, 15 May 2026 06:40:58 +0530
Subject: [PATCH] fix: ai sidebar closing (#45932)
## TL:DR
fixes ai assistant panel closing after running queries in logs and
analytics
## b4:
(thanks to OP)
## after:
https://github.com/user-attachments/assets/bec3366b-b4d6-41c8-a287-f8c37a818f71
## ref:
- closes https://github.com/supabase/supabase/issues/45930
## Summary by CodeRabbit
* **Bug Fixes**
* Improved synchronization between the Logs Explorer editor and the
URL/search state: running a query now updates the shared search state
(and recent snippets) rather than performing a full route push, and the
editor now prioritizes the URL/state value when present to prevent
mismatches during navigation or query execution.
[](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/45932)
---
.../project/[ref]/logs/explorer/index.tsx | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/apps/studio/pages/project/[ref]/logs/explorer/index.tsx b/apps/studio/pages/project/[ref]/logs/explorer/index.tsx
index c29beb0b7b3..38c94f560d7 100644
--- a/apps/studio/pages/project/[ref]/logs/explorer/index.tsx
+++ b/apps/studio/pages/project/[ref]/logs/explorer/index.tsx
@@ -72,7 +72,7 @@ export const LogsExplorerPage: NextPageWithLayout = () => {
const editorRef = useRef()
const [editorId] = useState(uuidv4())
- const { timestampStart, timestampEnd, setTimeRange } = useLogsUrlState()
+ const { search, setSearch, timestampStart, timestampEnd, setTimeRange } = useLogsUrlState()
const defaultHelper = useMemo(() => getDefaultHelper(EXPLORER_DATEPICKER_HELPERS), [])
const initialDatePickerValue = useMemo(() => {
if (timestampStart && timestampEnd) {
@@ -217,15 +217,7 @@ export const LogsExplorerPage: NextPageWithLayout = () => {
} else {
setTimeRange('', '')
}
- const queryParams: Record = { ...router.query, q: query }
- if (datePickerValue.isHelper) {
- delete queryParams.its
- delete queryParams.ite
- }
- router.push({
- pathname: router.pathname,
- query: queryParams,
- })
+ setSearch(query)
addRecentLogSqlSnippet({ sql: query })
}
@@ -326,10 +318,13 @@ export const LogsExplorerPage: NextPageWithLayout = () => {
}
useEffect(() => {
- if (q) {
+ if (search) {
+ setEditorValue(search)
+ } else if (q) {
setEditorValue(q)
+ setSearch(q)
}
- }, [q])
+ }, [q, search, setSearch])
useEffect(() => {
// prevents overwriting when the user selects a helper.