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.

feat(today): long-press menu for PostHog AI chats in recent on phones (#111565)

Shy Alter411a00b0d9bc
diff --git a/frontend/src/layout/today/TodayChatRow.tsx b/frontend/src/layout/today/TodayChatRow.tsx
index 94780c5d2643..e45ec268d4c2 100644
--- a/frontend/src/layout/today/TodayChatRow.tsx
+++ b/frontend/src/layout/today/TodayChatRow.tsx
@@ -1,17 +1,20 @@
-import { useValues } from 'kea'
+import { useActions, useValues } from 'kea'
import { router } from 'kea-router'
-import { useMemo } from 'react'
+import { useMemo, useState } from 'react'
import { ContextMenu, ContextMenuContent, ContextMenuTrigger } from '@posthog/quill'
import { urls } from 'scenes/urls'
import { TodayChatActionItems } from './TodayChatActionItems'
-import { CONTEXT_PARTS } from './todayMenuParts'
+import { CONTEXT_PARTS, SHEET_PARTS } from './todayMenuParts'
import { useTodayPreviewMenuReport } from './todayPreviewCardContext'
import { chatPreview } from './todayPreviewCards'
import { TodayPreviewTrigger } from './TodayPreviewTrigger'
import { TodaySessionIcon } from './TodaySessionIcon'
+import { TodaySheetMenu } from './TodaySheetMenu'
+import { todayShellLogic } from './todayShellLogic'
+import { todaySpacesLogic } from './todaySpacesLogic'
import { TodaySpacesRow } from './TodaySpacesRow'
import { TodayWorkItem } from './todayWorkItems'
@@ -25,22 +28,48 @@ export function TodayChatRow({ item, dataAttr, optionValue }: TodayChatRowProps)
const { location, searchParams } = useValues(router)
const reportMenuOpen = useTodayPreviewMenuReport()
const preview = useMemo(() => chatPreview(item), [item])
+ const { phoneLayout } = useValues(todayShellLogic)
+ const { touchMenuOpened } = useActions(todaySpacesLogic)
+ const [sheetOpen, setSheetOpen] = useState(false)
+
+ const row = (
+ <TodayPreviewTrigger payload={preview}>
+ <TodaySpacesRow
+ label={preview.title}
+ icon={<TodaySessionIcon item={item} />}
+ to={urls.ai(item.id)}
+ active={location.pathname.endsWith('/ai') && searchParams.chat === item.id}
+ dataAttr={dataAttr}
+ weight="regular"
+ optionValue={optionValue}
+ />
+ </TodayPreviewTrigger>
+ )
+
+ if (phoneLayout) {
+ return (
+ <>
+ <ContextMenu
+ open={false}
+ onOpenChange={(next) => {
+ if (next) {
+ setSheetOpen(true)
+ touchMenuOpened('chat')
+ }
+ }}
+ >
+ <ContextMenuTrigger render={<div className="min-w-0" />}>{row}</ContextMenuTrigger>
+ </ContextMenu>
+ <TodaySheetMenu open={sheetOpen} onOpenChange={setSheetOpen} title={preview.title}>
+ <TodayChatActionItems parts={SHEET_PARTS} chatId={item.id} dataAttrPrefix="today-chat-sheet" />
+ </TodaySheetMenu>
+ </>
+ )
+ }
return (
<ContextMenu onOpenChange={reportMenuOpen}>
- <ContextMenuTrigger render={<div className="min-w-0" />}>
- <TodayPreviewTrigger payload={preview}>
- <TodaySpacesRow
- label={preview.title}
- icon={<TodaySessionIcon item={item} />}
- to={urls.ai(item.id)}
- active={location.pathname.endsWith('/ai') && searchParams.chat === item.id}
- dataAttr={dataAttr}
- weight="regular"
- optionValue={optionValue}
- />
- </TodayPreviewTrigger>
- </ContextMenuTrigger>
+ <ContextMenuTrigger render={<div className="min-w-0" />}>{row}</ContextMenuTrigger>
<ContextMenuContent className="w-56">
<TodayChatActionItems parts={CONTEXT_PARTS} chatId={item.id} dataAttrPrefix="today-chat-context" />
</ContextMenuContent>
diff --git a/frontend/src/layout/today/todaySpacesLogic.ts b/frontend/src/layout/today/todaySpacesLogic.ts
index d1e1e5317d6b..f2d2156237b5 100644
--- a/frontend/src/layout/today/todaySpacesLogic.ts
+++ b/frontend/src/layout/today/todaySpacesLogic.ts
@@ -82,7 +82,7 @@ const SPACE_PRESENCE_POLL_INTERVAL_MS = 90_000
export type TodayWorkSectionId = 'pinned' | 'recent' | 'spaces'
-export type TodayTouchMenu = 'session' | 'space' | 'bulk' | 'filter'
+export type TodayTouchMenu = 'session' | 'space' | 'bulk' | 'filter' | 'chat'
/** The space a path is in, like PostHog Desktop's scoped space. `/spaces/new` is in no space. */
export function spaceIdForPath(pathname: string): string | null {