:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(sql): add "New SQL query" command to open a blank query in a new tab (#73494)
Jovan Sakovic0029527c02a2
diff --git a/frontend/src/lib/components/Search/searchLogic.tsx b/frontend/src/lib/components/Search/searchLogic.tsxindex e1d36c0e81cf..512a5c74b652 100644--- a/frontend/src/lib/components/Search/searchLogic.tsx+++ b/frontend/src/lib/components/Search/searchLogic.tsx@@ -1,5 +1,6 @@import { MakeLogicType, actions, afterMount, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'import { loaders } from 'kea-loaders'+import { router } from 'kea-router'import { IconBell, IconClock, IconDownload, IconLeave, IconNotification } from '@posthog/icons'@@ -9,6 +10,8 @@ import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { preflightLogic } from 'lib/logic/preflightLogic'import { getEntryAccessDisabledReason, getProductAccessDisabledReason } from 'lib/utils/accessControlUtils'import { GroupQueryResult, mapGroupQueryResponse } from 'lib/utils/groups'+import { removeProjectIdIfPresent } from 'lib/utils/kea-router'+import { newInternalTab } from 'lib/utils/newInternalTab'import { toSentenceCase } from 'lib/utils/strings'import { organizationIntegrationsLogic } from 'scenes/settings/organization/organizationIntegrationsLogic'import { urls } from 'scenes/urls'@@ -363,11 +366,16 @@ export interface searchLogicMeta {user: UserType | null,sceneLogViewsByRef: Record<string, string>) => SearchItem[]- newItems: (featureFlags: FeatureFlagsSet, isDev: boolean | undefined, user: UserType | null) => SearchItem[]+ newItems: (+ featureFlags: FeatureFlagsSet,+ isDev: boolean | undefined,+ user: UserType | null,+ arg: string+ ) => SearchItem[]peopleItems: (treeGroupItems: FileSystemImport[], sceneLogViewsByRef: Record<string, string>) => SearchItem[]groupItems: (groupSearchResults: Partial<Record<GroupTypeIndex, GroupQueryResult[]>>,- aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun+ aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun // groupsModel) => SearchItem[]personItems: (personSearchResults: PersonType[]) => SearchItem[]playlistItems: (playlistSearchResults: FileSystemEntry[]) => SearchItem[]@@ -782,11 +790,12 @@ export const searchLogic = kea<searchLogicType>([},],newItems: [- (s) => [s.featureFlags, s.isDev, s.user],+ (s) => [s.featureFlags, s.isDev, s.user, (_, props: SearchLogicProps) => props.logicKey],(featureFlags: import('lib/logic/featureFlagLogic').FeatureFlagsSet,isDev: boolean | undefined,- user: null | import('~/types').UserType+ user: null | import('~/types').UserType,+ logicKey: string): SearchItem[] => {const allNewItems = getTreeItemsNew()const filteredItems = allNewItems.filter((item) => {@@ -799,7 +808,7 @@ export const searchLogic = kea<searchLogicType>([return true})- return filteredItems.map((item) => {+ const items: SearchItem[] = filteredItems.map((item) => {// Format display name:// "Insight/Lifecycle" -> "New Lifecycle insight"// "Data/Destination" -> "New Destination" (no suffix for Data)@@ -832,6 +841,31 @@ export const searchLogic = kea<searchLogicType>([},}})++ // Blank SQL query in a new browser tab (inheriting the active warehouse connection when+ // triggered from within the SQL editor). Scoped to the command palette: it relies on+ // onSelect + newInternalTab, and only the 'command' Search surface honors onSelect —+ // the new-tab scene and AI-first homepage are href-only and would render a dead item.+ if (logicKey === 'command') {+ items.push({+ id: 'new-sql-query-tab',+ name: 'New SQL query',+ displayName: 'New SQL query',+ category: 'create',+ productCategory: null,+ itemType: 'insight/hog',+ searchKeywords: ['sql', 'hogql', 'query', 'blank sql', 'new tab'],+ record: { type: 'insight', iconType: 'insight/hog' },+ onSelect: () => {+ const onSqlEditor =+ removeProjectIdIfPresent(router.values.location.pathname) === urls.sqlEditor()+ const connectionId = onSqlEditor ? router.values.hashParams?.c : undefined+ newInternalTab(urls.sqlEditor(connectionId ? { connectionId } : {}))+ },+ })+ }++ return items},],peopleItems: [