Skip to content

: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.

refactor(max): move homepage hands-free start into a logic listener (#60783)

Paul D'Ambra4cf5297a9715
diff --git a/frontend/src/scenes/project-homepage/ai-first/HomepageInput.tsx b/frontend/src/scenes/project-homepage/ai-first/HomepageInput.tsx
index cb463e77e84c..d153f24b2e2b 100644
--- a/frontend/src/scenes/project-homepage/ai-first/HomepageInput.tsx
+++ b/frontend/src/scenes/project-homepage/ai-first/HomepageInput.tsx
@@ -29,11 +29,10 @@ import { HOMEPAGE_TAB_ID } from './constants'
function IdleInput(): JSX.Element {
const { query } = useValues(aiFirstHomepageLogic)
- const { setQuery, submitQuery, enterAiMode, startNewConversation } = useActions(aiFirstHomepageLogic)
+ const { setQuery, submitQuery, enterAiMode, startHandsFreeChat } = useActions(aiFirstHomepageLogic)
const { dataProcessingAccepted } = useValues(maxGlobalLogic)
const handsFreeFlag = useFeatureFlag('MAX_HANDS_FREE')
const { canUseHandsFree } = useValues(handsFreeLogic({ tabId: HOMEPAGE_TAB_ID }))
- const { enterHandsFree } = useActions(handsFreeLogic({ tabId: HOMEPAGE_TAB_ID }))
const inputRef = useRef<HTMLTextAreaElement>(null)
const handsFreeAvailable = handsFreeFlag && canUseHandsFree && dataProcessingAccepted
@@ -136,12 +135,7 @@ function IdleInput(): JSX.Element {
iconOnly
data-attr="homepage-hands-free"
className="shrink-0"
- onClick={() => {
- posthog.capture('homepage hands-free started')
- startNewConversation()
- submitQuery('ai')
- enterHandsFree()
- }}
+ onClick={startHandsFreeChat}
>
<IconMicrophone className="size-4" />
</ButtonPrimitive>
diff --git a/frontend/src/scenes/project-homepage/ai-first/aiFirstHomepageLogic.ts b/frontend/src/scenes/project-homepage/ai-first/aiFirstHomepageLogic.ts
index 486787d21c2d..f4e5da7948c4 100644
--- a/frontend/src/scenes/project-homepage/ai-first/aiFirstHomepageLogic.ts
+++ b/frontend/src/scenes/project-homepage/ai-first/aiFirstHomepageLogic.ts
@@ -1,7 +1,9 @@
import { actions, afterMount, connect, kea, listeners, path, reducers, selectors } from 'kea'
import { actionToUrl, router, urlToAction } from 'kea-router'
+import posthog from 'posthog-js'
import { tabUiStateLogic } from 'lib/logic/tabUiStateLogic'
+import { handsFreeLogic } from 'scenes/max/handsFreeLogic'
import { maxLogic } from 'scenes/max/maxLogic'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
@@ -92,6 +94,8 @@ export const aiFirstHomepageLogic = kea<aiFirstHomepageLogicType>([
actions: [
maxLogic({ tabId: HOMEPAGE_TAB_ID }),
['openConversation', 'startNewConversation', 'setQuestion'],
+ handsFreeLogic({ tabId: HOMEPAGE_TAB_ID }),
+ ['enterHandsFree'],
sceneLogic,
['setHomepage'],
tabUiStateLogic,
@@ -101,6 +105,7 @@ export const aiFirstHomepageLogic = kea<aiFirstHomepageLogicType>([
actions({
submitQuery: (mode: 'search' | 'ai') => ({ mode }),
+ startHandsFreeChat: true,
enterAiMode: (trigger: string) => ({ trigger }),
setQuery: (query: string) => ({ query }),
setAnimationPhase: (phase: AnimationPhase) => ({ phase }),
@@ -238,6 +243,14 @@ export const aiFirstHomepageLogic = kea<aiFirstHomepageLogicType>([
await breakpoint(200)
actions.setAnimationPhase('content')
},
+ startHandsFreeChat: () => {
+ posthog.capture('homepage hands-free started')
+ // Clear any in-progress conversation so hands-free always starts a fresh thread,
+ // then flip into AI mode (mounting maxThreadLogic) before Scribe starts listening.
+ actions.startNewConversation()
+ actions.submitQuery('ai')
+ actions.enterHandsFree()
+ },
enterAiMode: async ({ trigger }, breakpoint) => {
// Animate into AI mode without starting a conversation
await breakpoint(300)