diff --git a/frontend/__snapshots__/components-command-bar--search.png b/frontend/__snapshots__/components-command-bar--search.png
index 45ec5c93fd8b5..d155d92fac149 100644
Binary files a/frontend/__snapshots__/components-command-bar--search.png and b/frontend/__snapshots__/components-command-bar--search.png differ
diff --git a/frontend/src/lib/components/CommandBar/SearchResult.tsx b/frontend/src/lib/components/CommandBar/SearchResult.tsx
index d7937300d81f8..907cc0e94712c 100644
--- a/frontend/src/lib/components/CommandBar/SearchResult.tsx
+++ b/frontend/src/lib/components/CommandBar/SearchResult.tsx
@@ -5,6 +5,12 @@ import { resultTypeToName } from './constants'
import { searchBarLogic, urlForResult } from './searchBarLogic'
import { SearchResult as SearchResultType } from './types'
import { LemonSkeleton } from '@posthog/lemon-ui'
+import { summarizeInsight } from 'scenes/insights/summarizeInsight'
+import { groupsModel } from '~/models/groupsModel'
+import { cohortsModel } from '~/models/cohortsModel'
+import { mathsLogic } from 'scenes/trends/mathsLogic'
+import { Node } from '~/queries/schema'
+import { FilterType } from '~/types'
type SearchResultProps = {
result: SearchResultType
@@ -86,9 +92,23 @@ type ResultNameProps = {
}
export const ResultName = ({ result }: ResultNameProps): JSX.Element | null => {
+ const { aggregationLabel } = useValues(groupsModel)
+ const { cohortsById } = useValues(cohortsModel)
+ const { mathDefinitions } = useValues(mathsLogic)
+
const { type, extra_fields } = result
if (type === 'insight') {
- return extra_fields.name ? {extra_fields.name} : {extra_fields.derived_name}
+ return extra_fields.name ? (
+ {extra_fields.name}
+ ) : (
+
+ {summarizeInsight(extra_fields.query as Node | null, extra_fields.filters as Partial, {
+ aggregationLabel,
+ cohortsById,
+ mathDefinitions,
+ })}
+
+ )
} else if (type === 'feature_flag') {
return {extra_fields.key}
} else if (type === 'notebook') {
diff --git a/posthog/api/search.py b/posthog/api/search.py
index a48f716f902f7..cbdd898949fd1 100644
--- a/posthog/api/search.py
+++ b/posthog/api/search.py
@@ -21,8 +21,8 @@
ENTITY_MAP = {
"insight": {
"klass": Insight,
- "search_fields": {"name": "A", "derived_name": "B", "description": "C"},
- "extra_fields": ["name", "derived_name", "description"],
+ "search_fields": {"name": "A", "description": "C"},
+ "extra_fields": ["name", "description", "filters", "query"],
},
"dashboard": {
"klass": Dashboard,
diff --git a/posthog/api/test/__snapshots__/test_feature_flag.ambr b/posthog/api/test/__snapshots__/test_feature_flag.ambr
index 2e6fddaa836e2..c7922b68432eb 100644
--- a/posthog/api/test/__snapshots__/test_feature_flag.ambr
+++ b/posthog/api/test/__snapshots__/test_feature_flag.ambr
@@ -1759,7 +1759,7 @@
"posthog_user"."toolbar_mode",
"posthog_user"."events_column_config"
FROM "posthog_featureflag"
- INNER JOIN "posthog_user" ON ("posthog_featureflag"."created_by_id" = "posthog_user"."id")
+ LEFT OUTER JOIN "posthog_user" ON ("posthog_featureflag"."created_by_id" = "posthog_user"."id")
WHERE ("posthog_featureflag"."team_id" = 2
AND "posthog_featureflag"."id" = 2)
LIMIT 21 /*controller='project_feature_flags-create-static-cohort-for-flag',route='api/projects/%28%3FP%3Cparent_lookup_team_id%3E%5B%5E/.%5D%2B%29/feature_flags/%28%3FP%3Cpk%3E%5B%5E/.%5D%2B%29/create_static_cohort_for_flag/%3F%24'*/
diff --git a/posthog/api/test/test_search.py b/posthog/api/test/test_search.py
index 543d2d5adc048..36f31c8ec9ef4 100644
--- a/posthog/api/test/test_search.py
+++ b/posthog/api/test/test_search.py
@@ -74,11 +74,7 @@ def test_response_format_and_ids(self):
"rank": response.json()["results"][1]["rank"],
"type": "insight",
"result_id": self.insight_1.short_id,
- "extra_fields": {
- "derived_name": None,
- "name": "second insight",
- "description": None,
- },
+ "extra_fields": {"name": "second insight", "description": None, "filters": {}, "query": None},
},
)
@@ -88,7 +84,7 @@ def test_extra_fields(self):
self.assertEqual(response.status_code, 200)
self.assertEqual(
response.json()["results"][0]["extra_fields"],
- {"derived_name": "derived name", "description": None, "name": None},
+ {"name": None, "description": None, "filters": {}, "query": None},
)
def test_search_with_fully_invalid_query(self):