Files
supabase/apps/studio/state/sql-editor-logs.ts
Jordi EnricandClaude Opus 4.8 0e5531d564 feat(studio): wire the Logs source into the SQL Editor
- Route execution through useExecuteSQLEditorQuery (Postgres vs logs endpoint).
- Add a "Logs" entry to the source selector; when selected, swap the Postgres
  role control for a time picker (defaults to last 24h) and run against logs.
- Make inline generation (Cmd+Shift+K) and the AI debug action prepend the
  ClickHouse logs schema so the assistant writes logs SQL.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 14:15:52 +02:00

20 lines
813 B
TypeScript

import { proxy, useSnapshot } from 'valtio'
import { getDefaultLogsTimeRange } from '@/components/interfaces/SQLEditor/sqlEditorLogs'
// Time range used when the SQL Editor runs against the logs source. Module-level
// so the picker (UtilityActions) and execution (SQLEditor) share one source of
// truth without threading props. Defaults to the last 24 hours.
const initialRange = getDefaultLogsTimeRange(new Date())
export const sqlEditorLogsState = proxy({
iso_timestamp_start: initialRange.iso_timestamp_start,
iso_timestamp_end: initialRange.iso_timestamp_end,
setTimeRange: (start: string, end: string) => {
sqlEditorLogsState.iso_timestamp_start = start
sqlEditorLogsState.iso_timestamp_end = end
},
})
export const useSqlEditorLogsStateSnapshot = () => useSnapshot(sqlEditorLogsState)