Skip to content

Commit bcffb9d

Browse files
authored
fix: ai sidebar closing (supabase#45932)
## TL:DR fixes ai assistant panel closing after running queries in logs and analytics ## b4: (thanks to OP) <img width="2102" height="854" alt="Image" src="https://github.com/user-attachments/assets/6a1416d8-67bf-4166-999a-d8743746efda" /> ## after: https://github.com/user-attachments/assets/bec3366b-b4d6-41c8-a287-f8c37a818f71 ## ref: - closes supabase#45930 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/45932) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 8935043 commit bcffb9d

1 file changed

Lines changed: 7 additions & 12 deletions

File tree

  • apps/studio/pages/project/[ref]/logs/explorer

apps/studio/pages/project/[ref]/logs/explorer/index.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export const LogsExplorerPage: NextPageWithLayout = () => {
7272

7373
const editorRef = useRef<editor.IStandaloneCodeEditor>()
7474
const [editorId] = useState<string>(uuidv4())
75-
const { timestampStart, timestampEnd, setTimeRange } = useLogsUrlState()
75+
const { search, setSearch, timestampStart, timestampEnd, setTimeRange } = useLogsUrlState()
7676
const defaultHelper = useMemo(() => getDefaultHelper(EXPLORER_DATEPICKER_HELPERS), [])
7777
const initialDatePickerValue = useMemo<DatePickerValue>(() => {
7878
if (timestampStart && timestampEnd) {
@@ -217,15 +217,7 @@ export const LogsExplorerPage: NextPageWithLayout = () => {
217217
} else {
218218
setTimeRange('', '')
219219
}
220-
const queryParams: Record<string, string | string[] | undefined> = { ...router.query, q: query }
221-
if (datePickerValue.isHelper) {
222-
delete queryParams.its
223-
delete queryParams.ite
224-
}
225-
router.push({
226-
pathname: router.pathname,
227-
query: queryParams,
228-
})
220+
setSearch(query)
229221
addRecentLogSqlSnippet({ sql: query })
230222
}
231223

@@ -326,10 +318,13 @@ export const LogsExplorerPage: NextPageWithLayout = () => {
326318
}
327319

328320
useEffect(() => {
329-
if (q) {
321+
if (search) {
322+
setEditorValue(search)
323+
} else if (q) {
330324
setEditorValue(q)
325+
setSearch(q)
331326
}
332-
}, [q])
327+
}, [q, search, setSearch])
333328

334329
useEffect(() => {
335330
// prevents overwriting when the user selects a helper.

0 commit comments

Comments
 (0)