: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(sidebar): add experiment with cmd+k hint (#64369)
Fernando Gomes3b3a51833763
diff --git a/frontend/src/layout/panel-layout/ai-first/Nav.tsx b/frontend/src/layout/panel-layout/ai-first/Nav.tsxindex 42fb7be8b16d..8983bdbd5651 100644--- a/frontend/src/layout/panel-layout/ai-first/Nav.tsx+++ b/frontend/src/layout/panel-layout/ai-first/Nav.tsx@@ -5,10 +5,9 @@ import { router } from 'kea-router'import posthog from 'posthog-js'import { lazy, Suspense, useEffect, useRef } from 'react'-import { IconApps, IconChat, IconChevronRight, IconSearch } from '@posthog/icons'+import { IconApps, IconChat, IconChevronRight } from '@posthog/icons'import { NewAccountMenu } from 'lib/components/Account/NewAccountMenu'-import { RenderKeybind } from 'lib/components/AppShortcuts/AppShortcutMenu'import { keyBinds } from 'lib/components/AppShortcuts/shortcuts'import { useAppShortcut } from 'lib/components/AppShortcuts/useAppShortcut'import { commandLogic } from 'lib/components/Command/commandLogic'@@ -29,6 +28,7 @@ import {panelLayoutLogic,} from '~/layout/panel-layout/panelLayoutLogic'+import { NavSearchButton } from '../../../lib/components/NavSearchButton/NavSearchButton'import { navigation3000Logic } from '../../navigation-3000/navigationLogic'import { NavBarFooter } from '../NavBarFooter'import { PanelLayoutPanels } from './PanelLayoutPanels'@@ -176,22 +176,7 @@ export function Nav(): JSX.Element {><NewAccountMenu isLayoutNavCollapsed={isLayoutNavCollapsed} />- <ButtonPrimitive- iconOnly- data-attr="nav-search"- tooltip={- <>- <span>Search</span> <RenderKeybind keybind={[keyBinds.search]} />- </>- }- tooltipPlacement={isLayoutNavCollapsed ? 'right' : undefined}- onClick={() => {- posthog.capture('nav search clicked')- toggleCommand()- }}- >- <IconSearch className="size-4 text-secondary" />- </ButtonPrimitive>+ <NavSearchButton isLayoutNavCollapsed={isLayoutNavCollapsed} toggleCommand={toggleCommand} />{isLayoutNavCollapsed && (<ButtonPrimitivediff --git a/frontend/src/lib/components/AppShortcuts/AppShortcutMenu.tsx b/frontend/src/lib/components/AppShortcuts/AppShortcutMenu.tsxindex 0d1f22f5e0f7..e3b26162ed19 100644--- a/frontend/src/lib/components/AppShortcuts/AppShortcutMenu.tsx+++ b/frontend/src/lib/components/AppShortcuts/AppShortcutMenu.tsx@@ -52,9 +52,10 @@ function getShortcutIcon(shortcut: AppShortcutType): JSX.Element | null {interface RenderKeybindProps {keybind: string[][]className?: string+ minimal?: boolean}-export function RenderKeybind({ keybind, className }: RenderKeybindProps): JSX.Element {+export function RenderKeybind({ keybind, className, minimal }: RenderKeybindProps): JSX.Element {return (<span className={cn('inline-flex items-center gap-1', className)}>{keybind.map((keybindOption, index) => {@@ -79,6 +80,7 @@ export function RenderKeybind({ keybind, className }: RenderKeybindProps): JSX.E<KeyboardShortcut{...Object.fromEntries(keybindOption.map((key: string) => [key, true]))}className="text-xs"+ minimal={minimal}/></React.Fragment>)diff --git a/frontend/src/lib/components/NavSearchButton/NavSearchButton.tsx b/frontend/src/lib/components/NavSearchButton/NavSearchButton.tsxnew file mode 100644index 000000000000..4a19969f4e13--- /dev/null+++ b/frontend/src/lib/components/NavSearchButton/NavSearchButton.tsx@@ -0,0 +1,48 @@+import { useValues } from 'kea'++import { IconSearch } from '@posthog/icons'++import { RenderKeybind } from 'lib/components/AppShortcuts/AppShortcutMenu'+import { keyBinds } from 'lib/components/AppShortcuts/shortcuts'+import posthog from 'lib/posthog-typed'+import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'++import { searchButtonLogic } from './searchButtonLogic'++interface NavSearchButtonProps {+ isLayoutNavCollapsed: boolean+ toggleCommand: () => void+}++export function NavSearchButton({ isLayoutNavCollapsed, toggleCommand }: NavSearchButtonProps): JSX.Element {+ const { showHint } = useValues(searchButtonLogic)++ return (+ <ButtonPrimitive+ iconOnly={!showHint}+ data-attr="nav-search"+ tooltip={+ <div className="flex items-center gap-2">+ <span>Search</span> <RenderKeybind keybind={[keyBinds.search]} />+ </div>+ }+ tooltipPlacement={isLayoutNavCollapsed ? 'right' : undefined}+ onClick={() => {+ posthog.capture('nav search clicked')+ toggleCommand()+ }}+ className="gap-0"+ >+ <IconSearch className="size-4 shrink-0 text-secondary" />+ <div+ className={`overflow-hidden whitespace-nowrap transition-[max-width,opacity] duration-300 ease-in-out ${+ showHint ? 'max-w-xs opacity-100' : 'max-w-0 opacity-0'+ }`}+ >+ <span className="flex items-center gap-1 pl-1 text-xs text-secondary">+ <RenderKeybind keybind={[keyBinds.search]} minimal />+ </span>+ </div>+ </ButtonPrimitive>+ )+}diff --git a/frontend/src/lib/components/NavSearchButton/searchButtonLogic.tsx b/frontend/src/lib/components/NavSearchButton/searchButtonLogic.tsxnew file mode 100644index 000000000000..604edb4327b2--- /dev/null+++ b/frontend/src/lib/components/NavSearchButton/searchButtonLogic.tsx@@ -0,0 +1,41 @@+import { kea, connect, path, actions, reducers, selectors, afterMount } from 'kea'++import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'++import type { searchButtonLogicType } from './searchButtonLogicType'++export const searchButtonLogic = kea<searchButtonLogicType>([+ path(['lib', 'components', 'NavSearchButton', 'searchButtonLogic']),+ connect(() => ({+ values: [featureFlagLogic, ['featureFlags']],+ })),+ actions(() => ({+ hideHint: true,+ })),+ reducers(() => ({+ hintVisible: [+ true,+ {+ hideHint: () => false,+ },+ ],+ })),+ selectors(() => ({+ isHintEnabled: [+ (s) => [s.featureFlags],+ (featureFlags) => featureFlags[FEATURE_FLAGS.SIDEBAR_SEARCH_COMMAND_HINT] === 'test',+ ],+ showHint: [+ (s) => [s.hintVisible, s.isHintEnabled],+ (hintVisible, isHintEnabled) => hintVisible && isHintEnabled,+ ],+ })),+ afterMount(({ actions, cache }) => {+ cache.disposables.add(() => {+ const id = setTimeout(() => actions.hideHint(), 5000)++ return () => clearTimeout(id)+ }, 'hintTimer')+ }),+])diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex 48cdd9a8b9ec..ed03e905e595 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -470,6 +470,7 @@ export const FEATURE_FLAGS = {SHOW_DATA_PIPELINES_NAV_ITEM: 'show-data-pipelines-nav-item', // owner: @raquelmsmithSHOW_REFERRER_FAVICON: 'show-referrer-favicon', // owner: @jordanm-posthog #team-web-analyticsSHOW_REPLAY_FILTERS_FEEDBACK_BUTTON: 'show-replay-filters-feedback-button', // owner: @ksvat #team-replay+ SIDEBAR_SEARCH_COMMAND_HINT: 'sidebar-search-command-hint', // owner: @fercgomesSIGNUP_AA_TEST_4_WAY: 'signup-aa-test-4-way', // owner: @andehen #team-experiments multivariate=control,test-1,test-2,test-3SLACK_DWH: 'slack-dwh', // owner: @MarconLP #team-warehouse-sourcesSNAPCHAT_ADS_SOURCE: 'snapchat-ads-source', // owner: @jabahamondes #team-web-analytics