: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
chore(search): keep only the unified cmd+k ranking (#130675)
Shy Alterd20e1b76983b
diff --git a/frontend/src/lib/components/CommandKSearch/COMMAND_K_SEARCH_UX.md b/frontend/src/lib/components/CommandKSearch/COMMAND_K_SEARCH_UX.mdindex 4efd03fe39e4..5338987df957 100644--- a/frontend/src/lib/components/CommandKSearch/COMMAND_K_SEARCH_UX.md+++ b/frontend/src/lib/components/CommandKSearch/COMMAND_K_SEARCH_UX.md@@ -110,11 +110,10 @@ The input is always in exactly one mode, decided from the token under the cursor### Ranked results-Results for a search with words follow ordered tie-breaking rules: words matched, typos, word proximity, name before folder, exact words, word position, exactness, the person's recent views, then recency. Products rank with the same rules through their name and search keywords, so "recordings" finds Session replay. When a name match and a search keyword match tie, the name match ranks first, so "metrics" puts Metrics above Data catalog.+Results for a search with words rank with one scorer that applies the same rules to every result type. Products rank through their name and search keywords, so "recordings" finds Session replay. When a name match and a search keyword match tie, the name match ranks first, so "metrics" puts Metrics above Data catalog.- Accounts rank with the results when account search is enabled. The Accounts API matches the full search text, so an account can suppress the partial-match or spelling notice even when its display name does not contain the text. Distinct accounts with the same name stay separate. Accounts get no file-system **See all** filter.-- In the test group of the `command-k-unified-ranking` experiment, one scorer ranks every result type with the same rules.- The sources only find candidates. The scorer then orders them by words matched, typos, match tier, the person's recent views, word proximity, word position, a type preference, then recency.+- The sources only find candidates. The scorer then orders them by words matched, typos, match tier, the person's recent views, word proximity, word position, a type preference, then recency.Match tiers, best first: exact name, exact name in singular, exact search keyword, name starts with the search, the same in singular, every word starts a name word, every word starts a name or keyword word, a match on an identity field (account external ID, website domain or email domain, person distinct ID), a match inside a word, then a match in the folder or type only.Names compare as words, split on hyphens and underscores, so `checkout flow` matches the flags `checkout-flow-redesign` and `checkout_flow_redesign` as names that start with the search.When every source answers and nothing matches, Cmd+K tries the search once more with underscores as spaces and says so ("No matches for **posthog_personal_api_key**. Showing results for **posthog personal api key**."), so a pasted variable name finds Personal API keys.diff --git a/frontend/src/lib/components/CommandKSearch/commandKRankedResults.test.ts b/frontend/src/lib/components/CommandKSearch/commandKRankedResults.test.tsindex b39d98b6bb14..5ccfff9c6d29 100644--- a/frontend/src/lib/components/CommandKSearch/commandKRankedResults.test.ts+++ b/frontend/src/lib/components/CommandKSearch/commandKRankedResults.test.ts@@ -207,9 +207,9 @@ describe('buildRankedResults', () => {products: [],accounts: [1, 2, 3, 4].map((n) => account(`account-${n}`, 'Billing')),expected: [- 'Best matches: Billing, Billing insight 6',- 'Accounts: Billing, Billing, Billing',+ 'Best matches: Billing insight 6, Billing','Insights: Billing insight 5, Billing insight 4, Billing insight 3, (See all 6 insights)',+ 'Accounts: Billing, Billing, Billing',],},{@@ -232,7 +232,7 @@ describe('buildRankedResults', () => {],},{- name: 'with unified ranking, the app Settings row ranks above a product tab with the same name',+ name: 'the app Settings row ranks above a product tab with the same name',query: 'settings',results: [],products: [@@ -243,77 +243,69 @@ describe('buildRankedResults', () => {},],settings: [{ id: 'settings', name: 'Settings', category: 'settings' }],- unifiedRanking: true,expected: ['Results: Settings, Workflows Settings'],},{- name: 'with unified ranking, an account that matches only inside a word ranks below a name match',+ name: 'an account that matches only inside a word ranks below a name match',query: 'stripe',results: [result('1', 'Stripe revenue', 'insight', [-1, 0, 0, 0, -1, 0, 1, 0, -1])],products: [],accounts: [account('account-1', 'Pinstripe Example Co')],- unifiedRanking: true,expected: ['Results: Stripe revenue, Pinstripe Example Co'],},{- name: 'with unified ranking, a domain search puts the account that owns the domain first',+ name: 'a domain search puts the account that owns the domain first',query: 'example.org',results: [result('1', 'Example org signups', 'insight', [-2, 0, 0, 0, -2, 0, 1, 0, -1])],products: [],accounts: [account('account-1', 'Acme', ['example.org'])],- unifiedRanking: true,expected: ['Results: Acme, Example org signups'],},{- name: 'with unified ranking, a hyphenated flag key that starts with the search words ranks first',+ name: 'a hyphenated flag key that starts with the search words ranks first',query: 'checkout flow',results: [result('1', 'Flow of checkout events', 'insight', [-2, 0, 0, 0, -2, 0, 2, 0, -2]),result('2', 'checkout-flow-redesign', 'feature_flag', [-2, 0, 0, 0, -2, 0, 5, 0, -1]),],products: [],- unifiedRanking: true,expected: ['Results: checkout-flow-redesign, Flow of checkout events'],},{- name: 'with unified ranking, an account with a generic name and no CRM record ranks below a saved object',+ name: 'an account with a generic name and no CRM record ranks below a saved object',query: 'studio',results: [result('1', 'Studio review', 'notebook', [-1, 0, 0, 0, -1, 0, 1, 0, -1])],products: [],accounts: [account('account-1', 'Studio')],- unifiedRanking: true,expected: ['Results: Studio review, Studio'],},{- name: 'with unified ranking, a curated account with the same name still ranks first',+ name: 'a curated account with the same name still ranks first',query: 'studio',results: [result('1', 'Studio review', 'notebook', [-1, 0, 0, 0, -1, 0, 1, 0, -1])],products: [],accounts: [account('account-1', 'Studio', [], true)],- unifiedRanking: true,expected: ['Results: Studio, Studio review'],},{- name: 'with unified ranking, a snake_case name splits into words like a hyphenated one',+ name: 'a snake_case name splits into words like a hyphenated one',query: 'checkout flow',results: [result('1', 'Flow of checkout redesign', 'insight', [-2, 0, 0, 0, -2, 0, 2, 0, -2]),result('2', 'checkout_flow_redesign', 'feature_flag', [-2, 0, 0, 0, -2, 0, 5, 0, -1]),],products: [],- unifiedRanking: true,expected: ['Results: checkout_flow_redesign, Flow of checkout redesign'],},{- name: 'with unified ranking, a product that starts with the search ranks above an exact saved object name',+ name: 'a product that starts with the search ranks above an exact saved object name',query: 'replay',results: [result('1', 'Replay', 'notebook', [-1, 0, 0, 0, -1, 0, 0, 0, -1])],products: [product('Session replay'), product('Replay vision')],- unifiedRanking: true,expected: ['Results: Replay vision, Replay, Session replay'],},{- name: 'with unified ranking, an exact folder match beats a name that needs a typo',+ name: 'an exact folder match beats a name that needs a typo',query: 'revenue',results: [result('1', 'Revenue board', 'dashboard', [-1, 0, 0, 0, -1, 0, 1, 0, -2]),@@ -323,49 +315,43 @@ describe('buildRankedResults', () => {},],products: [],- unifiedRanking: true,expected: ['Results: Revenue board, Revenge'],},{- name: 'with unified ranking, a match inside a word beats a word that needs a typo',+ name: 'a match inside a word beats a word that needs a typo',query: 'stripe',results: [result('1', 'Stripe revenue', 'insight', [-1, 0, 0, 0, -1, 0, 1, 0, -1])],products: [],accounts: [account('account-1', 'Pinstripe Strive')],- unifiedRanking: true,expected: ['Results: Stripe revenue, Pinstripe Strive'],},{- name: 'with unified ranking, a keyword with fewer typos wins over an earlier keyword',+ name: 'a keyword with fewer typos wins over an earlier keyword',query: 'lajehouse',results: [result('1', 'Warehouse costs', 'insight', [-1, 1, 0, 0, -1, 0, 5, 0, -1])],products: [product('Data ops', ['managed warehouse', 'lakehouse'])],- unifiedRanking: true,expected: ['Results: Data ops'],},{- name: 'with unified ranking, an account the API matched keeps zero typos over a fuzzy name',+ name: 'an account the API matched keeps zero typos over a fuzzy name',query: 'stripe',results: [result('1', 'Ada stripe com signups', 'insight', [-1, 0, 0, 0, -1, 1, 2, 0, -1])],products: [],accounts: [account('account-1', 'Strive')],- unifiedRanking: true,expected: ['Results: Ada stripe com signups, Strive'],},{- name: 'with unified ranking, a search keyword still matches with a typo',+ name: 'a search keyword still matches with a typo',query: 'recordigns',results: [],products: [product('Session replay', ['recordings']), product('Surveys')],- unifiedRanking: true,expected: ['Results: Session replay'],},{- name: 'with unified ranking, an exact name ranks above an exact search keyword',+ name: 'an exact name ranks above an exact search keyword',query: 'metrics',results: [],products: [product('Data catalog', ['metrics']), product('Metrics')],- unifiedRanking: true,expected: ['Results: Metrics, Data catalog'],},{@@ -382,7 +368,7 @@ describe('buildRankedResults', () => {],},{- name: 'with unified ranking, a flat list of one saved-object type that hits the cap ends with its see-all row',+ name: 'a flat list of one saved-object type that hits the cap ends with its see-all row',query: 'revenue',results: Array.from({ length: RESULTS_LIMIT + 5 }, (_, n) =>result(`dashboard-${n}`, `Revenue ${n}`, 'dashboard', exactWordRank(100 - n), {@@ -390,7 +376,6 @@ describe('buildRankedResults', () => {})),products: [],- unifiedRanking: true,expected: [`Results: ${Array.from({ length: RESULTS_LIMIT }, (_, n) => `Revenue ${n}`).join(', ')}, (See all ${RESULTS_LIMIT + 5} dashboards)`,],@@ -403,10 +388,9 @@ describe('buildRankedResults', () => {expected: [`Results: ${Array.from({ length: RESULTS_LIMIT + 2 }, (_, n) => `Pricing ${n}`).join(', ')}`],},{- name: 'with unified ranking, every product shows when products are the only match, past the flat list cap',+ name: 'every product shows when products are the only match, past the flat list cap',query: 'pricing',results: [],- unifiedRanking: true,products: Array.from({ length: RESULTS_LIMIT + 2 }, (_, n) => product(`Pricing ${n}`)),expected: [`Results: ${Array.from({ length: RESULTS_LIMIT + 2 }, (_, n) => `Pricing ${n}`).join(', ')}`],},@@ -424,34 +408,21 @@ describe('buildRankedResults', () => {`Results: ${Array.from({ length: RESULTS_LIMIT + 5 }, (_, n) => `Project settings ${n}`).join(', ')}`,],},- ])(- '$name',- ({- query,- results,- products,- persons = [],- accounts = [],- settings = [],- unifiedRanking = false,- expected,- }) => {- expect(- summary(- buildRankedResults({- query,- highlightWords: query.split(' '),- results,- products,- persons,- accounts,- settings,- state: 'ready',- scoped: false,- unifiedRanking,- })- )- ).toEqual(expected)- }- )+ ])('$name', ({ query, results, products, persons = [], accounts = [], settings = [], expected }) => {+ expect(+ summary(+ buildRankedResults({+ query,+ highlightWords: query.split(' '),+ results,+ products,+ persons,+ accounts,+ settings,+ state: 'ready',+ scoped: false,+ })+ )+ ).toEqual(expected)+ })})diff --git a/frontend/src/lib/components/CommandKSearch/commandKRankedResults.ts b/frontend/src/lib/components/CommandKSearch/commandKRankedResults.tsindex cc0057d5e5d2..14da680e1a61 100644--- a/frontend/src/lib/components/CommandKSearch/commandKRankedResults.ts+++ b/frontend/src/lib/components/CommandKSearch/commandKRankedResults.ts@@ -11,7 +11,6 @@ import {compareRanks,isIdentityQuery,rankCandidate,- rankLocalItem,searchWords,tokenTypos,} from './commandKRanking'@@ -42,73 +41,6 @@ function groupLabel(groupKey: string): string {return capitalizeFirstLetter(pluralTypeName(getItemTypeDisplayName(groupKey) ?? groupKey.replace(/_/g, ' ')))}-const RANKED_LOCAL_CACHE_SIZE = 50-const rankedLocalCache = new WeakMap<SearchItem[], Map<string, RankedItem[]>>()--function rankLocalItems(items: SearchItem[], query: string, groupKey: string): RankedItem[] {- const key = `${groupKey}:${query}`- let byQuery = rankedLocalCache.get(items)- if (!byQuery) {- byQuery = new Map()- rankedLocalCache.set(items, byQuery)- }- const cached = byQuery.get(key)- if (cached) {- return cached- }- const ranked = rankItems(items, query, groupKey)- if (byQuery.size >= RANKED_LOCAL_CACHE_SIZE) {- byQuery.delete(byQuery.keys().next().value!)- }- byQuery.set(key, ranked)- return ranked-}--function rankItems(items: SearchItem[], query: string, groupKey: string): RankedItem[] {- return items.flatMap((item) => {- const name = String(item.displayName || item.name)- const aliases =- groupKey === 'settings'- ? [- ...(item.searchKeywords ?? []),- [- name,- ...(item.searchKeywords ?? []),- item.parentName ?? '',- ...(item.contextKeywords ?? []),- ].join(' '),- ]- : item.searchKeywords- const ranked = rankLocalItem(query, name, aliases, !!item.parentName, groupKey === 'settings')- return ranked- ? [- {- item:- ranked.matchedAlias && !item.hideMatchedKeyword- ? { ...item, matchedSearchKeyword: ranked.matchedAlias }- : item,- rank: ranked.rank,- groupKey,- },- ]- : []- })-}--function rankAccounts(accounts: SearchItem[], query: string): RankedItem[] {- const queryMatch = rankLocalItem(query, query)- if (!queryMatch) {- return []- }- return accounts.map((item) => {- const nameMatch = rankLocalItem(query, String(item.displayName || item.name))- // The Accounts API matches the full query, including identities that the display name does not contain.- const rank =- nameMatch?.rank[0] === queryMatch.rank[0] && nameMatch.rank[1] === 0 ? nameMatch.rank : queryMatch.rank- return { item, rank, groupKey: 'accounts' }- })-}-const IDENTITY_GROUPS = ['accounts', 'persons']const PRODUCT_TIER_BOOST = 3const UNCURATED_ACCOUNT_TIER_PENALTY = 3@@ -314,7 +246,6 @@ interface RankedResultsInput {accounts?: SearchItem[]state: CommandKSection['state']scoped: boolean- unifiedRanking?: boolean}export function buildRankedResults({@@ -329,25 +260,14 @@ export function buildRankedResults({accounts = [],state,scoped,- unifiedRanking = false,}: RankedResultsInput): CommandKSection[] {- const candidates: RankedItem[] = (- unifiedRanking- ? [- ...rankUnified(results, query, groupKeyFor),- ...rankUnified(products, query, () => 'products'),- ...rankUnified(persons, query, () => 'persons'),- ...rankUnified(settings, query, () => 'settings'),- ...rankUnified(accounts, query, () => 'accounts'),- ]- : [- ...results.map((item) => ({ item, rank: item.rankKey ?? [], groupKey: groupKeyFor(item) })),- ...rankLocalItems(products, query, 'products'),- ...rankLocalItems(persons, query, 'persons'),- ...rankLocalItems(settings, query, 'settings'),- ...rankAccounts(accounts, query),- ]- ).sort((a, b) => compareRanks(a.rank, b.rank))+ const candidates: RankedItem[] = [+ ...rankUnified(results, query, groupKeyFor),+ ...rankUnified(products, query, () => 'products'),+ ...rankUnified(persons, query, () => 'persons'),+ ...rankUnified(settings, query, () => 'settings'),+ ...rankUnified(accounts, query, () => 'accounts'),+ ].sort((a, b) => compareRanks(a.rank, b.rank))if (!candidates.length) {return []}diff --git a/frontend/src/lib/components/CommandKSearch/commandKRanking.ts b/frontend/src/lib/components/CommandKSearch/commandKRanking.tsindex e16e85311f4b..8467baf31c03 100644--- a/frontend/src/lib/components/CommandKSearch/commandKRanking.ts+++ b/frontend/src/lib/components/CommandKSearch/commandKRanking.ts@@ -165,25 +165,19 @@ interface LocalRank {matchedAlias: string | null}-export function rankLocalItem(- query: string,- name: string,- aliases: string[] = [],- isTab = false,- shortQueryAliases = false-): LocalRank | null {+export function rankLocalItem(query: string, name: string, aliases: string[] = []): LocalRank | null {const normalized = query.trim().toLowerCase().replace(/\s+/g, ' ').slice(0, MAX_LOCAL_QUERY_LENGTH)const tokens = searchWords(normalized)if (!tokens.length) {return null}let best: LocalRank | null = null- const byName = rankName(normalized, tokens, name, isTab ? 1 : 0)+ const byName = rankName(normalized, tokens, name, 0)if (byName) {best = { rank: byName, matchedAlias: null }}- for (const alias of shortQueryAliases || normalized.length >= MIN_ALIAS_QUERY_LENGTH ? aliases : []) {- const byAlias = rankName(normalized, tokens, alias, isTab ? 2 : 1)+ for (const alias of normalized.length >= MIN_ALIAS_QUERY_LENGTH ? aliases : []) {+ const byAlias = rankName(normalized, tokens, alias, 1)if (byAlias && (!best || compareRanks(byAlias, best.rank) < 0)) {best = { rank: byAlias, matchedAlias: alias }}diff --git a/frontend/src/lib/components/CommandKSearch/commandKSearchLogic.test.ts b/frontend/src/lib/components/CommandKSearch/commandKSearchLogic.test.tsindex 28414ff93750..8c4939d713a9 100644--- a/frontend/src/lib/components/CommandKSearch/commandKSearchLogic.test.ts+++ b/frontend/src/lib/components/CommandKSearch/commandKSearchLogic.test.ts@@ -1,8 +1,6 @@import { router } from 'kea-router'import { searchListsLogic } from 'lib/components/Search/searchListsLogic'-import { FEATURE_FLAGS } from 'lib/constants'-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import type { SettingSectionId } from '~/scenes/settings/types'import { initKeaTests } from '~/test/init'@@ -73,7 +71,6 @@ describe('commandKSearchLogic', () => {['answered with nothing', false, { from: 'zzq_xyw', to: 'zzq xyw' }],['answered, but one failed', true, null],])('corrects a search only after every source %s', (_, oneFailed, expected) => {- featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.COMMAND_K_UNIFIED_RANKING]: 'test' })logic.actions.inputChanged('zzq_xyw', 7, false)const sources = Object.keys(logic.values.remoteQueries)expect(sources.length).toBeGreaterThan(1)diff --git a/frontend/src/lib/components/CommandKSearch/commandKSearchLogic.tsx b/frontend/src/lib/components/CommandKSearch/commandKSearchLogic.tsxindex f9e37511344b..e415ca750e26 100644--- a/frontend/src/lib/components/CommandKSearch/commandKSearchLogic.tsx+++ b/frontend/src/lib/components/CommandKSearch/commandKSearchLogic.tsx@@ -64,7 +64,6 @@ import {resolveQuery,tokenAtCursor,} from './commandKQuery'-import { freeWords } from './commandKRanking'import {CommandKMode,CommandKRow,@@ -376,7 +375,6 @@ export interface commandKSearchLogicMeta {query: SectionsQuerystale: boolean},- featureFlags: FeatureFlagsSet,searchCorrection: SearchCorrection | null,expandedGroups: string[]) => CommandKSection[]@@ -775,7 +773,6 @@ export const commandKSearchLogic = kea<commandKSearchLogicType>([s.localLists,s.remote,s.displayedQuery,- s.featureFlags,s.searchCorrection,s.expandedGroups,],@@ -786,14 +783,10 @@ export const commandKSearchLogic = kea<commandKSearchLogicType>([local: LocalLists,remote: RemoteSlots,displayed: { query: SectionsQuery; stale: boolean },- featureFlags: FeatureFlagsSet,searchCorrection: SearchCorrection | null,expandedGroups: string[]- ): CommandKSection[] => {- const unifiedRanking =- freeWords(displayed.query.remoteQueries.results ?? '').length > 0 &&- featureFlags[FEATURE_FLAGS.COMMAND_K_UNIFIED_RANKING] === 'test'- return buildSections({+ ): CommandKSection[] =>+ buildSections({mode,context,suggestions,@@ -802,7 +795,6 @@ export const commandKSearchLogic = kea<commandKSearchLogicType>([...displayed.query,stale: displayed.stale,personsFirst: !!displayed.query.remoteQueries.persons?.includes('@'),- unifiedRanking,expandedGroups,searchCorrection:searchCorrection &&@@ -811,8 +803,7 @@ export const commandKSearchLogic = kea<commandKSearchLogicType>([)? searchCorrection: null,- })- },+ }),],selectableRows: [(s) => [s.sections],@@ -853,14 +844,7 @@ export const commandKSearchLogic = kea<commandKSearchLogicType>([!!sourceQuery && !!values.remote[source as RemoteSource].failed?.[sourceQuery])const empty = !values.sections.some((section) => section.rows.some((row) => row.kind === 'item'))- if (- corrected &&- settled &&- !failed &&- !values.displayedQuery.stale &&- empty &&- values.featureFlags[FEATURE_FLAGS.COMMAND_K_UNIFIED_RANKING] === 'test'- ) {+ if (corrected && settled && !failed && !values.displayedQuery.stale && empty) {actions.applyCorrection({ from: query, to: corrected })}}diff --git a/frontend/src/lib/components/CommandKSearch/commandKSections.test.ts b/frontend/src/lib/components/CommandKSearch/commandKSections.test.tsindex 8f62c668159c..7fd76aafd29c 100644--- a/frontend/src/lib/components/CommandKSearch/commandKSections.test.ts+++ b/frontend/src/lib/components/CommandKSearch/commandKSections.test.ts@@ -55,7 +55,6 @@ const input = (mode: CommandKMode, overrides: Partial<SectionsInput>): SectionsIviewAll: null,stale: false,personsFirst: false,- unifiedRanking: false,searchCorrection: null,...overrides,})@@ -130,29 +129,26 @@ describe('buildSections', () => {category: 'results',record: { type: 'ticket', id: '1' },}- test.each<[string, string, SearchItem[], string[], boolean]>([+ test.each<[string, string, SearchItem[], string[]]>([['file system results with a server rank','type:dashboard revenue',[{ ...dashboard('a', '1'), rankKey: [-1, 0, 0, 0, -1, 0, 2, 0, 0] }],['results/a'],- false,],['results from a type API that sends no rank, in the order it sent them','type:alert revenue',alerts,['results/alert-2', 'results/alert-1'],- false,],[- 'a type API result that matched outside its name, with unified ranking',+ 'a type API result that matched outside its name','type:ticket revenue',[ticketMatchedInMessage],['results/ticket-1'],- true,],- ])('keeps the View all row after ranked %s', (_, results, items, rowKeys, unifiedRanking) => {+ ])('keeps the View all row after ranked %s', (_, results, items, rowKeys) => {const viewAll: ViewAll = {item: { id: 'view-all', name: 'View all', category: 'results', href: '/list' },placement: 'trail',@@ -160,7 +156,7 @@ describe('buildSections', () => {const remote = emptyRemoteSlots()remote.results = { cache: { [results]: items } }const sections = buildSections(- input('search', { remote, remoteQueries: { results }, localQuery: 'revenue', viewAll, unifiedRanking })+ input('search', { remote, remoteQueries: { results }, localQuery: 'revenue', viewAll }))expect(sections.find((section) => section.key === 'results')?.rows.map((row) => row.key)).toEqual([...rowKeys,@@ -385,7 +381,7 @@ describe('buildSections', () => {}})- it('with unified ranking, a domain search through the sections puts the account that owns the domain first', () => {+ it('a domain search through the sections puts the account that owns the domain first', () => {const account: SearchItem = {id: 'account-1',name: 'Acme',@@ -403,7 +399,7 @@ describe('buildSections', () => {localQuery: 'example.org',})- const sections = buildSections(input('search', { remote, ...current, unifiedRanking: true }))+ const sections = buildSections(input('search', { remote, ...current }))expect(sections[0].rows[0]).toMatchObject({ kind: 'item', item: account })})@@ -444,7 +440,7 @@ describe('buildSections', () => {},],['best-matches'],- 'settings-item',+ 'a',],] as [string, string, string, SearchItem[], string[], string][])('ranks an exact-match setting with the results when %s',@@ -473,17 +469,15 @@ describe('buildSections', () => {expect(sections.map((section) => section.key)).toEqual(keys)const firstItem = sections[0].rows[0]expect(firstItem.kind === 'item' ? firstItem.item.id : null).toBe(first)+ expect(+ sections.flatMap((section) => section.rows.map((row) => (row.kind === 'item' ? row.item.id : null)))+ ).toContain('settings-item')})- test.each([- [false, []],- [true, []],- [false, ['Theme']],- [true, ['Theme']],- ] as [boolean, string[]][])(- 'keeps the theme shortcut next to a dashboard that matches every word, unified ranking %s, settings %j',- (unifiedRanking, settingNames) => {+ test.each([[[]], [['Theme']]] as [string[]][])(+ 'keeps the theme shortcut next to a dashboard that matches every word, settings %j',+ (settingNames) => {const themeItem = themeSearchItem('dark theme', false, { setTheme: jest.fn(), toggleTheme: jest.fn() })const settings: SearchItem[] = settingNames.map((name) => ({id: `settings-${name}`,@@ -506,7 +500,6 @@ describe('buildSections', () => {remoteQueries: { results: 'dark theme' },localQuery: 'dark theme',themeItem,- unifiedRanking,}))@@ -516,69 +509,58 @@ describe('buildSections', () => {})- test.each([- [false, false],- [true, false],- [false, true],- [true, true],- ])(- 'shows one Settings group that expands to every match, unified ranking %s, expanded %s',- (unifiedRanking, expanded) => {- const settings: SearchItem[] = [- ...Array.from({ length: 10 }, (_, index) => ({- id: `settings-${index}`,- name: `Settings ${index}`,- displayName: `Settings ${index}`,- category: 'settings',- })),- { id: 'settings-shared', name: 'Shared settings', category: 'settings' },- ]- const products: SearchItem[] = [{ id: 'product-shared', name: 'Shared settings', category: 'products' }]- const remote = emptyRemoteSlots()- remote.results = {- cache: {- settings: [- { ...dashboard('a', '1'), name: 'Settings board', rankKey: [-1, 0, 0, 0, -1, 0, 1, 0, 0] },- ],- },- }- const sections = buildSections(- input('search', {- local: { ...emptyLocal(), settings, products },- remote,- remoteQueries: { results: 'settings' },- localQuery: 'settings',- unifiedRanking,- expandedGroups: expanded ? ['settings'] : [],- })- )+ test.each([false, true])('shows one Settings group that expands to every match, expanded %s', (expanded) => {+ const settings: SearchItem[] = [+ ...Array.from({ length: 10 }, (_, index) => ({+ id: `settings-${index}`,+ name: `Settings ${index}`,+ displayName: `Settings ${index}`,+ category: 'settings',+ })),+ { id: 'settings-shared', name: 'Shared settings', category: 'settings' },+ ]+ const products: SearchItem[] = [{ id: 'product-shared', name: 'Shared settings', category: 'products' }]+ const remote = emptyRemoteSlots()+ remote.results = {+ cache: {+ settings: [{ ...dashboard('a', '1'), name: 'Settings board', rankKey: [-1, 0, 0, 0, -1, 0, 1, 0, 0] }],+ },+ }+ const sections = buildSections(+ input('search', {+ local: { ...emptyLocal(), settings, products },+ remote,+ remoteQueries: { results: 'settings' },+ localQuery: 'settings',+ expandedGroups: expanded ? ['settings'] : [],+ })+ )- const settingsSections = sections.filter((section) => section.label === 'Settings')- expect(settingsSections).toHaveLength(1)- expect(settingsSections[0].count).toBe(11)- const settingRowIds = sections.flatMap((section) =>- section.rows.flatMap((row) =>- row.kind === 'item' && row.item.category === 'settings' ? [row.item.id] : []- )+ const settingsSections = sections.filter((section) => section.label === 'Settings')+ expect(settingsSections).toHaveLength(1)+ expect(settingsSections[0].count).toBe(11)+ const settingRowIds = sections.flatMap((section) =>+ section.rows.flatMap((row) =>+ row.kind === 'item' && row.item.category === 'settings' ? [row.item.id] : [])- const expandRows = settingsSections[0].rows.filter((row) => row.kind === 'expand')- expect([settingRowIds.length, expandRows]).toEqual(- expanded- ? [11, []]- : [- 4,- [- {- kind: 'expand',- key: 'group-settings/expand',- group: 'settings',- label: 'Show all 11 settings',- },- ],- ]- )- }- )+ )+ const expandRows = settingsSections[0].rows.filter((row) => row.kind === 'expand')+ expect([settingRowIds.length, expandRows]).toEqual(+ expanded+ ? [11, []]+ : [+ 4,+ [+ {+ kind: 'expand',+ key: 'group-settings/expand',+ group: 'settings',+ label: 'Show all 11 settings',+ },+ ],+ ]+ )+ })const SETTING_ROWS: SearchItem[] = [{@@ -642,18 +624,13 @@ describe('buildSections', () => {},]- test.each(- [- ['surveys', 'settings-project-surveys'],- ['rename project', 'settings-project-customization-display-name'],- ['project timezone', 'settings-project-customization-date-and-time'],- ['ai', 'settings-project-customization-custom-bots'],- ['personal user settings', 'settings-level-user'],- ].flatMap(([query, id]) => [- [query, id, false],- [query, id, true],- ]) as [string, string, boolean][]- )('finds the setting for %s (%s), unified ranking %s', (query, id, unifiedRanking) => {+ test.each([+ ['surveys', 'settings-project-surveys'],+ ['rename project', 'settings-project-customization-display-name'],+ ['project timezone', 'settings-project-customization-date-and-time'],+ ['ai', 'settings-project-customization-custom-bots'],+ ['personal user settings', 'settings-level-user'],+ ] as [string, string][])('finds the setting for %s (%s)', (query, id) => {const products: SearchItem[] = [{ id: 'product-surveys', name: 'Surveys', category: 'products', href: '/surveys' },]@@ -665,7 +642,6 @@ describe('buildSections', () => {remote,remoteQueries: { results: query },localQuery: query,- unifiedRanking,}))@@ -676,54 +652,48 @@ describe('buildSections', () => {expect(sections.filter((section) => section.label === 'Settings').length).toBeLessThanOrEqual(1)})- test.each([false, true])(- 'lists the level landing rows before a nested setting named Settings, unified ranking %s',- (unifiedRanking) => {- const setting = (id: string, name: string, parentName?: string): SearchItem => ({- id,- name,- displayName: name,- category: 'settings',- ...(parentName ? { parentName } : {}),+ it('lists the level landing rows before a nested setting named Settings', () => {+ const setting = (id: string, name: string, parentName?: string): SearchItem => ({+ id,+ name,+ displayName: name,+ category: 'settings',+ ...(parentName ? { parentName } : {}),+ })+ const settings: SearchItem[] = [+ setting('settings', 'Settings'),+ setting('settings-activity', 'Settings', 'Project settings › Activity logs'),+ setting('settings-level-user', 'User settings'),+ setting('settings-level-project', 'Project settings'),+ setting('settings-level-organization', 'Organization settings'),+ ...['Alpha', 'Beta', 'Gamma', 'Delta'].map((name) =>+ setting(`settings-${name}`, `${name} settings`, 'Project settings')+ ),+ ]+ const remote = emptyRemoteSlots()+ remote.results = {+ cache: {+ settings: [{ ...dashboard('a', '1'), name: 'Settings board', rankKey: [-1, 0, 0, 0, -1, 0, 1, 0, 0] }],+ },+ }+ const sections = buildSections(+ input('search', {+ local: { ...emptyLocal(), settings },+ remote,+ remoteQueries: { results: 'settings' },+ localQuery: 'settings',})- const settings: SearchItem[] = [- setting('settings', 'Settings'),- setting('settings-activity', 'Settings', 'Project settings › Activity logs'),- setting('settings-level-user', 'User settings'),- setting('settings-level-project', 'Project settings'),- setting('settings-level-organization', 'Organization settings'),- ...['Alpha', 'Beta', 'Gamma', 'Delta'].map((name) =>- setting(`settings-${name}`, `${name} settings`, 'Project settings')- ),- ]- const remote = emptyRemoteSlots()- remote.results = {- cache: {- settings: [- { ...dashboard('a', '1'), name: 'Settings board', rankKey: [-1, 0, 0, 0, -1, 0, 1, 0, 0] },- ],- },- }- const sections = buildSections(- input('search', {- local: { ...emptyLocal(), settings },- remote,- remoteQueries: { results: 'settings' },- localQuery: 'settings',- unifiedRanking,- })- )+ )- const group = sections.find((section) => section.key === 'group-settings')- expect(group?.rows.slice(0, 3).map((row) => (row.kind === 'item' ? row.item.id : row.kind))).toEqual([- 'settings-level-user',- 'settings-level-project',- 'settings-level-organization',- ])- }- )+ const group = sections.find((section) => section.key === 'group-settings')+ expect(group?.rows.slice(0, 3).map((row) => (row.kind === 'item' ? row.item.id : row.kind))).toEqual([+ 'settings-level-user',+ 'settings-level-project',+ 'settings-level-organization',+ ])+ })- it('with unified ranking, a pasted snake_case name ranks its matching setting first', () => {+ it('a pasted snake_case name ranks its matching setting first', () => {const setting: SearchItem = {id: 'settings-api-keys',name: 'User: Personal API keys (api keys)',@@ -741,7 +711,6 @@ describe('buildSections', () => {remote,remoteQueries: { results: 'personal_api_keys' },localQuery: 'personal_api_keys',- unifiedRanking: true,}))diff --git a/frontend/src/lib/components/CommandKSearch/commandKSections.ts b/frontend/src/lib/components/CommandKSearch/commandKSections.tsindex e18c173e90ad..fb4c35dcb768 100644--- a/frontend/src/lib/components/CommandKSearch/commandKSections.ts+++ b/frontend/src/lib/components/CommandKSearch/commandKSections.ts@@ -243,7 +243,6 @@ export interface SectionsInput extends SectionsQuery {remote: RemoteSlotsstale: booleanpersonsFirst: boolean- unifiedRanking: booleansearchCorrection: SearchCorrection | nullexpandedGroups?: string[]}@@ -343,10 +342,6 @@ const plainName = (item: SearchItem): string =>.replace(/\s*\([^)]*\)\s*$/, '').trim()-// The unified scorer splits words on underscores, so the settings it ranks are matched the same way.-export const settingsQuery = (localQuery: string, unifiedRanking: boolean): string =>- unifiedRanking ? localQuery.replace(/_/g, ' ') : localQuery-export function rankableSettings(local: LocalLists, localQuery: string): SearchItem[] {const productDestinations = new Set(local.products.filter((item) => !item.parentName).map((item) => `${plainName(item)}|${item.href ?? ''}`)@@ -364,14 +359,14 @@ function rankedResultsSections(state: CommandKSection['state'],persons: SearchItem[],accounts: SearchItem[],- unifiedRanking: boolean,themeItem: SearchItem | null,expandedGroups: string[]): CommandKSection[] {const words = freeWords(query)- const rankedSettingsQuery = settingsQuery(localQuery, unifiedRanking)+ // The scorer splits words on underscores, so the settings it ranks are matched the same way.+ const rankedSettingsQuery = localQuery.replace(/_/g, ' ')const rankable = rankableSettings(local, rankedSettingsQuery)- // The unified scorer reads punctuation, so a domain or an email address keeps it.+ // The scorer reads punctuation, so a domain or an email address keeps it.const freeText = query.replace(FILTER_TOKEN, ' ').replace(/\s+/g, ' ').trim()return buildRankedResults({persons,@@ -381,13 +376,12 @@ function rankedResultsSections((item) => !rankable.some((ranked) => ranked.id === item.id)),expandedGroups,- query: unifiedRanking ? freeText : words.join(' '),+ query: freeText,highlightWords: words,results,products: localQuery ? local.products : [],state,scoped: (query.match(FILTER_TOKEN) ?? []).some((token) => token.trim().startsWith('type:')),- unifiedRanking,})}@@ -543,7 +537,6 @@ function buildSectionsForQuery(input: SectionsInput): CommandKSection[] {state,leadingPersons,accountsQuery ? remote.accounts.cache[accountsQuery] : [],- input.unifiedRanking,input.themeItem,input.expandedGroups ?? [])diff --git a/frontend/src/lib/components/Search/searchListsLogic.test.ts b/frontend/src/lib/components/Search/searchListsLogic.test.tsindex 72fe3c35009e..09952b001199 100644--- a/frontend/src/lib/components/Search/searchListsLogic.test.ts+++ b/frontend/src/lib/components/Search/searchListsLogic.test.ts@@ -153,71 +153,67 @@ describe('searchListsLogic', () => {expect(terminalDockLogic.values.dockOpen).toBe(false)})- it.each([false, true])(- 'finds a setting through its section keyword next to a dashboard named like the search, unified ranking %s',- (unifiedRanking) => {- featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.TODAY_RAIL_NAV]: true })- const component = {} as JSX.Element- logic.actions.setSettingsMap([- {- id: 'environment-ai-cloud-environments',- level: 'environment',- title: 'Cloud environments',- flag: 'TODAY_RAIL_NAV',- keywords: ['desktop'],- settings: [- { id: 'ai-cloud-environments', title: 'Environments', component },- { id: 'ai-cloud-custom-images', title: 'Custom images', keywords: ['dependencies'], component },- ],- },- ])- const remote = emptyRemoteSlots()- remote.results = {- cache: {- 'desktop images': [- {- id: 'dashboard-1',- name: 'Desktop images board',- category: 'results',- record: { type: 'dashboard', ref: '1' },- rankKey: [-2, 0, 0, 0, -2, 0, 1, 0, 0],- },- ],- },- }- const sections = buildSections({- mode: 'search',- context: { kind: 'text', token: null },- suggestions: null,- local: {- products: [],- 'data-management': [],- people: [],- health: [],- actions: [],- shortcuts: [],- settings: logic.values.commandKSettingsItems,- create: [],- recents: [],- starred: [],- },- remote,- remoteQueries: { results: 'desktop images' },- localQuery: 'desktop images',- themeItem: null,- askAiQuestion: null,- viewAll: null,- stale: false,- personsFirst: false,- unifiedRanking,- searchCorrection: null,- })-- expect(- sections.flatMap((section) => section.rows.flatMap((row) => (row.kind === 'item' ? [row.item.id] : [])))- ).toContain('settings-project-ai-cloud-environments-ai-cloud-custom-images')+ it('finds a setting through its section keyword next to a dashboard named like the search', () => {+ featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.TODAY_RAIL_NAV]: true })+ const component = {} as JSX.Element+ logic.actions.setSettingsMap([+ {+ id: 'environment-ai-cloud-environments',+ level: 'environment',+ title: 'Cloud environments',+ flag: 'TODAY_RAIL_NAV',+ keywords: ['desktop'],+ settings: [+ { id: 'ai-cloud-environments', title: 'Environments', component },+ { id: 'ai-cloud-custom-images', title: 'Custom images', keywords: ['dependencies'], component },+ ],+ },+ ])+ const remote = emptyRemoteSlots()+ remote.results = {+ cache: {+ 'desktop images': [+ {+ id: 'dashboard-1',+ name: 'Desktop images board',+ category: 'results',+ record: { type: 'dashboard', ref: '1' },+ rankKey: [-2, 0, 0, 0, -2, 0, 1, 0, 0],+ },+ ],+ },}- )+ const sections = buildSections({+ mode: 'search',+ context: { kind: 'text', token: null },+ suggestions: null,+ local: {+ products: [],+ 'data-management': [],+ people: [],+ health: [],+ actions: [],+ shortcuts: [],+ settings: logic.values.commandKSettingsItems,+ create: [],+ recents: [],+ starred: [],+ },+ remote,+ remoteQueries: { results: 'desktop images' },+ localQuery: 'desktop images',+ themeItem: null,+ askAiQuestion: null,+ viewAll: null,+ stale: false,+ personsFirst: false,+ searchCorrection: null,+ })++ expect(+ sections.flatMap((section) => section.rows.flatMap((row) => (row.kind === 'item' ? [row.item.id] : [])))+ ).toContain('settings-project-ai-cloud-environments-ai-cloud-custom-images')+ })it.each([['off', false, 'Model preferences', false],diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex ddccfc722825..f607d14e615b 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -283,7 +283,6 @@ export const FEATURE_FLAGS = {CLEARABLE_NOTIFICATIONS: 'clearable-notifications', // owner: @jordanm-posthog #team-web-analyticsCOHORT_INLINE_CALCULATION: 'inline-cohort-calculation', // owner: #team-analytics-platform, inlines fast dynamic cohort queries instead of using precomputed cohortpeople tableCOHORTS_TAXONOMIC_BASIC_LIST: 'cohorts-taxonomic-basic-list', // owner: @adamleith, picker sends ?basic=true to the cohorts list endpoint (trimmed payload: no query/groups/last_error_message/experiment_set; filters is kept)- COMMAND_K_UNIFIED_RANKING: 'command-k-unified-ranking', // owner: @puemos #team-platform-ux multivariate=control,test, experiment: rank every Command K result type with one scorerCONDENSED_FILTER_BAR: 'condensed_filter_bar', // owner: @jordanm-posthog #team-web-analyticsCREATE_FORM_TOOL: 'phai-create-form-tool', // owner: @kappa90 #team-posthog-aiCRM_ITERATION_ONE: 'crm-iteration-one', // owner: @arthurdedeus #team-customer-analytics