: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(today): touch menus and select mode for the phone spaces pane (#111487)
Shy Altera5efead47fd7
diff --git a/frontend/src/layout/today/TodayRecentFilterMenu.tsx b/frontend/src/layout/today/TodayRecentFilterMenu.tsxindex 2e5c017e7154..fba6937ec85e 100644--- a/frontend/src/layout/today/TodayRecentFilterMenu.tsx+++ b/frontend/src/layout/today/TodayRecentFilterMenu.tsx@@ -1,9 +1,12 @@import { useActions, useValues } from 'kea'+import { useState } from 'react'-import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator } from '@posthog/quill'+import { IconFilter } from '@posthog/icons'+import { Button, DropdownMenu, DropdownMenuContent, Tooltip, TooltipContent, TooltipTrigger, cn } from '@posthog/quill'import { TodayFilterMenuTrigger } from './TodayFilterMenuTrigger'import { todayListAppearanceLogic } from './todayListAppearanceLogic'+import { DROPDOWN_PARTS, SHEET_PARTS } from './todayMenuParts'import {DEFAULT_RECENT_FILTERS,RECENT_CREATED_BY_OPTIONS,@@ -19,6 +22,8 @@ import {} from './todayRecentOrder'import { TodayRecentRadioSubmenu } from './TodayRecentRadioSubmenu'import { TodayRecentSourceSubmenu } from './TodayRecentSourceSubmenu'+import { TodaySheetMenu } from './TodaySheetMenu'+import { todayShellLogic } from './todayShellLogic'import { todaySpacesLogic } from './todaySpacesLogic'/**@@ -33,84 +38,127 @@ export function TodayRecentFilterMenu(): JSX.Element {recentSort,recentGrouping,} = useValues(todaySpacesLogic)- const { setRecentFilters, clearRecentFilters, setRecentSort, setRecentGrouping } = useActions(todaySpacesLogic)+ const { setRecentFilters, clearRecentFilters, setRecentSort, setRecentGrouping, touchMenuOpened } =+ useActions(todaySpacesLogic)const { openAppearanceDialog } = useActions(todayListAppearanceLogic)+ const { phoneLayout } = useValues(todayShellLogic)+ const [sheetOpen, setSheetOpen] = useState(false)++ const parts = phoneLayout ? SHEET_PARTS : DROPDOWN_PARTS+ const items = (+ <>+ <TodayRecentRadioSubmenu+ label="Group by"+ options={RECENT_GROUPING_OPTIONS}+ value={recentGrouping}+ defaultValue={DEFAULT_RECENT_GROUPING}+ onChange={setRecentGrouping}+ dataAttr="today-recent-group-by"+ />+ <TodayRecentRadioSubmenu+ label="Sort by"+ options={RECENT_SORT_OPTIONS}+ value={recentSort}+ defaultValue={DEFAULT_RECENT_SORT}+ onChange={setRecentSort}+ dataAttr="today-recent-sort-by"+ />+ <parts.Separator />+ <TodayRecentRadioSubmenu+ label="Status"+ options={RECENT_STATUS_OPTIONS}+ value={filters.status}+ defaultValue={DEFAULT_RECENT_FILTERS.status}+ onChange={(status) => setRecentFilters({ ...filters, status })}+ dataAttr="today-recent-filter-status"+ />+ <TodayRecentRadioSubmenu+ label="Created by"+ options={RECENT_CREATED_BY_OPTIONS}+ value={filters.createdBy}+ defaultValue={DEFAULT_RECENT_FILTERS.createdBy}+ onChange={(createdBy) => setRecentFilters({ ...filters, createdBy })}+ dataAttr="today-recent-filter-created-by"+ />+ <TodayRecentRadioSubmenu+ label="Pinned"+ options={RECENT_PINNED_OPTIONS}+ value={filters.pinned}+ defaultValue={DEFAULT_RECENT_FILTERS.pinned}+ onChange={(pinned) => setRecentFilters({ ...filters, pinned })}+ dataAttr="today-recent-filter-pinned"+ />+ <TodayRecentRadioSubmenu+ label="Environment"+ options={RECENT_ENVIRONMENT_OPTIONS}+ value={filters.environment}+ defaultValue={DEFAULT_RECENT_FILTERS.environment}+ onChange={(environment) => setRecentFilters({ ...filters, environment })}+ dataAttr="today-recent-filter-environment"+ />+ <TodayRecentSourceSubmenu+ selected={filters.sources}+ options={recentSourceOptions}+ onChange={(sources) => setRecentFilters({ ...filters, sources })}+ dataAttr="today-recent-filter-source"+ />+ <parts.Separator />+ <parts.Item onClick={openAppearanceDialog} dataAttr="today-recent-filter-appearance">+ Edit list item appearance…+ </parts.Item>+ {active && (+ <>+ <parts.Separator />+ <parts.Item variant="destructive" onClick={clearRecentFilters} dataAttr="today-recent-filter-clear">+ Clear filters+ </parts.Item>+ </>+ )}+ </>+ )++ if (phoneLayout) {+ const label = active ? 'Filters on' : 'Filter'+ return (+ <>+ <Tooltip>+ <TooltipTrigger+ delay={0}+ render={+ <Button+ size="icon-lg"+ aria-label={label}+ className={cn(+ 'relative text-muted-foreground',+ active && 'bg-fill-selected text-foreground'+ )}+ onClick={() => {+ setSheetOpen(true)+ touchMenuOpened('filter')+ }}+ data-attr="today-recent-filter"+ />+ }+ >+ <IconFilter />+ {active && (+ <span aria-hidden className="absolute top-1 right-1 size-1.5 rounded-full bg-primary" />+ )}+ </TooltipTrigger>+ <TooltipContent>{label}</TooltipContent>+ </Tooltip>+ <TodaySheetMenu open={sheetOpen} onOpenChange={setSheetOpen} title="Filter recent sessions">+ {items}+ </TodaySheetMenu>+ </>+ )+ }return (<DropdownMenu><TodayFilterMenuTrigger active={active} dataAttr="today-recent-filter" /><DropdownMenuContent align="end" className="min-w-56">- <TodayRecentRadioSubmenu- label="Group by"- options={RECENT_GROUPING_OPTIONS}- value={recentGrouping}- defaultValue={DEFAULT_RECENT_GROUPING}- onChange={setRecentGrouping}- dataAttr="today-recent-group-by"- />- <TodayRecentRadioSubmenu- label="Sort by"- options={RECENT_SORT_OPTIONS}- value={recentSort}- defaultValue={DEFAULT_RECENT_SORT}- onChange={setRecentSort}- dataAttr="today-recent-sort-by"- />- <DropdownMenuSeparator />- <TodayRecentRadioSubmenu- label="Status"- options={RECENT_STATUS_OPTIONS}- value={filters.status}- defaultValue={DEFAULT_RECENT_FILTERS.status}- onChange={(status) => setRecentFilters({ ...filters, status })}- dataAttr="today-recent-filter-status"- />- <TodayRecentRadioSubmenu- label="Created by"- options={RECENT_CREATED_BY_OPTIONS}- value={filters.createdBy}- defaultValue={DEFAULT_RECENT_FILTERS.createdBy}- onChange={(createdBy) => setRecentFilters({ ...filters, createdBy })}- dataAttr="today-recent-filter-created-by"- />- <TodayRecentRadioSubmenu- label="Pinned"- options={RECENT_PINNED_OPTIONS}- value={filters.pinned}- defaultValue={DEFAULT_RECENT_FILTERS.pinned}- onChange={(pinned) => setRecentFilters({ ...filters, pinned })}- dataAttr="today-recent-filter-pinned"- />- <TodayRecentRadioSubmenu- label="Environment"- options={RECENT_ENVIRONMENT_OPTIONS}- value={filters.environment}- defaultValue={DEFAULT_RECENT_FILTERS.environment}- onChange={(environment) => setRecentFilters({ ...filters, environment })}- dataAttr="today-recent-filter-environment"- />- <TodayRecentSourceSubmenu- selected={filters.sources}- options={recentSourceOptions}- onChange={(sources) => setRecentFilters({ ...filters, sources })}- dataAttr="today-recent-filter-source"- />- <DropdownMenuSeparator />- <DropdownMenuItem onClick={openAppearanceDialog} data-attr="today-recent-filter-appearance">- Edit list item appearance…- </DropdownMenuItem>- {active && (- <>- <DropdownMenuSeparator />- <DropdownMenuItem- variant="destructive"- onClick={clearRecentFilters}- data-attr="today-recent-filter-clear"- >- Clear filters- </DropdownMenuItem>- </>- )}+ {items}</DropdownMenuContent></DropdownMenu>)diff --git a/frontend/src/layout/today/TodayRecentFilterSubmenu.tsx b/frontend/src/layout/today/TodayRecentFilterSubmenu.tsxindex 1389d9ce04ec..f20ac142115b 100644--- a/frontend/src/layout/today/TodayRecentFilterSubmenu.tsx+++ b/frontend/src/layout/today/TodayRecentFilterSubmenu.tsx@@ -2,6 +2,9 @@ import { ReactNode } from 'react'import { DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, cn } from '@posthog/quill'+import { useTodaySheetMenu } from './todaySheetMenuContext'+import { TodaySheetSub } from './TodaySheetSub'+interface TodayRecentFilterSubmenuProps {label: string/** The choice in force, shown beside the label. */@@ -17,6 +20,14 @@ export function TodayRecentFilterSubmenu({narrowed = false,children,}: TodayRecentFilterSubmenuProps): JSX.Element {+ const sheet = useTodaySheetMenu()+ if (sheet) {+ return (+ <TodaySheetSub label={label} title={label} value={value} narrowed={narrowed}>+ {children}+ </TodaySheetSub>+ )+ }return (<DropdownMenuSub><DropdownMenuSubTrigger>diff --git a/frontend/src/layout/today/TodayRecentRadioSubmenu.tsx b/frontend/src/layout/today/TodayRecentRadioSubmenu.tsxindex 1d571591b304..7998f426c5b2 100644--- a/frontend/src/layout/today/TodayRecentRadioSubmenu.tsx+++ b/frontend/src/layout/today/TodayRecentRadioSubmenu.tsx@@ -1,6 +1,7 @@-import { DropdownMenuRadioGroup, DropdownMenuRadioItem, cn } from '@posthog/quill'+import { DropdownMenuRadioGroup, DropdownMenuRadioItem, ItemRadio, cn } from '@posthog/quill'import { TodayRecentFilterSubmenu } from './TodayRecentFilterSubmenu'+import { useTodaySheetMenu } from './todaySheetMenuContext'interface TodayRecentRadioSubmenuProps<T extends string> {label: string@@ -19,24 +20,45 @@ export function TodayRecentRadioSubmenu<T extends string>({onChange,dataAttr,}: TodayRecentRadioSubmenuProps<T>): JSX.Element {+ const sheet = useTodaySheetMenu()+ const optionLabel = (option: { label: string; dotClassName?: string }): JSX.Element => (+ <span className="flex items-center gap-2">+ {option.dotClassName && (+ <span aria-hidden className={cn('size-2 shrink-0 rounded-full', option.dotClassName)} />+ )}+ {option.label}+ </span>+ )return (<TodayRecentFilterSubmenulabel={label}value={options.find((option) => option.value === value)?.label ?? ''}narrowed={value !== defaultValue}>- <DropdownMenuRadioGroup value={value} onValueChange={(next) => onChange(next as T)}>- {options.map((option) => (- <DropdownMenuRadioItem key={option.value} value={option.value} data-attr={dataAttr}>- <span className="flex items-center gap-2">- {option.dotClassName && (- <span aria-hidden className={cn('size-2 shrink-0 rounded-full', option.dotClassName)} />- )}- {option.label}- </span>- </DropdownMenuRadioItem>- ))}- </DropdownMenuRadioGroup>+ {sheet ? (+ options.map((option) => (+ <ItemRadio+ key={option.value}+ className="text-base"+ aria-checked={option.value === value}+ onClick={() => {+ onChange(option.value)+ sheet.back()+ }}+ data-attr={dataAttr}+ >+ {optionLabel(option)}+ </ItemRadio>+ ))+ ) : (+ <DropdownMenuRadioGroup value={value} onValueChange={(next) => onChange(next as T)}>+ {options.map((option) => (+ <DropdownMenuRadioItem key={option.value} value={option.value} data-attr={dataAttr}>+ {optionLabel(option)}+ </DropdownMenuRadioItem>+ ))}+ </DropdownMenuRadioGroup>+ )}</TodayRecentFilterSubmenu>)}diff --git a/frontend/src/layout/today/TodayRecentSourceSubmenu.tsx b/frontend/src/layout/today/TodayRecentSourceSubmenu.tsxindex 54cec6b6360d..bdf5d9901cfc 100644--- a/frontend/src/layout/today/TodayRecentSourceSubmenu.tsx+++ b/frontend/src/layout/today/TodayRecentSourceSubmenu.tsx@@ -1,7 +1,8 @@-import { DropdownMenuCheckboxItem, DropdownMenuSeparator } from '@posthog/quill'+import { DropdownMenuCheckboxItem, DropdownMenuSeparator, ItemCheckbox } from '@posthog/quill'import { recentSourceLabel } from './todayRecentFilters'import { TodayRecentFilterSubmenu } from './TodayRecentFilterSubmenu'+import { useTodaySheetMenu } from './todaySheetMenuContext'interface TodayRecentSourceSubmenuProps {/** The sources kept. An empty list keeps every source. */@@ -25,6 +26,35 @@ export function TodayRecentSourceSubmenu({onChange,dataAttr,}: TodayRecentSourceSubmenuProps): JSX.Element {+ const sheet = useTodaySheetMenu()+ const toggle = (source: string, checked: boolean): void =>+ onChange(checked ? [...selected, source] : selected.filter((kept) => kept !== source))+ if (sheet) {+ return (+ <TodayRecentFilterSubmenu label="Source" value={sourcesLabel(selected)} narrowed={selected.length > 0}>+ <ItemCheckbox+ className="text-base"+ aria-checked={!selected.length}+ onClick={() => onChange([])}+ data-attr={`${dataAttr}-any`}+ >+ Any source+ </ItemCheckbox>+ <div role="separator" className="my-1 border-t border-border" />+ {options.map((source) => (+ <ItemCheckbox+ key={source}+ className="text-base"+ aria-checked={selected.includes(source)}+ onClick={() => toggle(source, !selected.includes(source))}+ data-attr={dataAttr}+ >+ {recentSourceLabel(source)}+ </ItemCheckbox>+ ))}+ </TodayRecentFilterSubmenu>+ )+ }return (<TodayRecentFilterSubmenu label="Source" value={sourcesLabel(selected)} narrowed={selected.length > 0}><DropdownMenuCheckboxItem@@ -41,9 +71,7 @@ export function TodayRecentSourceSubmenu({key={source}checked={selected.includes(source)}closeOnClick={false}- onCheckedChange={(checked) =>- onChange(checked ? [...selected, source] : selected.filter((kept) => kept !== source))- }+ onCheckedChange={(checked) => toggle(source, checked)}data-attr={dataAttr}>{recentSourceLabel(source)}diff --git a/frontend/src/layout/today/TodaySessionActionItems.tsx b/frontend/src/layout/today/TodaySessionActionItems.tsxindex cfdc30bc67b0..568af3a1a401 100644--- a/frontend/src/layout/today/TodaySessionActionItems.tsx+++ b/frontend/src/layout/today/TodaySessionActionItems.tsx@@ -2,6 +2,7 @@ import { useActions, useValues } from 'kea'import {IconArchive,+ IconCheckbox,IconCopy,IconExternal,IconFolder,@@ -20,6 +21,8 @@ import { isMac } from 'lib/utils/dom'import { TodayMenuParts } from './todayMenuParts'import { todayArchiveShortcutLabel } from './todaySessionArchiveShortcut'import { TodaySessionSurface, todaySessionMenuLogic } from './todaySessionMenuLogic'+import { todaySessionSelectionLogic } from './todaySessionSelectionLogic'+import { todayShellLogic } from './todayShellLogic'import { TodaySpaceFileList } from './TodaySpaceFileList'import { todaySpacesLogic } from './todaySpacesLogic'import { TodaySessionMenuTarget } from './todayWorkItems'@@ -41,6 +44,8 @@ export function TodaySessionActionItems({}: TodaySessionActionItemsProps): JSX.Element {const { featureFlags } = useValues(featureFlagLogic)const { spaces } = useValues(todaySpacesLogic)+ const { phoneLayout } = useValues(todayShellLogic)+ const { toggleSessionSelection } = useActions(todaySessionSelectionLogic)const {setSessionPinned,startRenaming,@@ -58,10 +63,12 @@ export function TodaySessionActionItems({return (<>- <Item onClick={() => openSessionInNewTab(sessionId)} dataAttr={attr('open-new-tab')}>- <IconExternal />- Open in new tab- </Item>+ {!phoneLayout && (+ <Item onClick={() => openSessionInNewTab(sessionId)} dataAttr={attr('open-new-tab')}>+ <IconExternal />+ Open in new tab+ </Item>+ )}<Item onClick={() => copySessionLink(sessionId)} dataAttr={attr('copy-link')}><IconCopy />Copy link@@ -94,6 +101,7 @@ export function TodaySessionActionItems({File to…</>}+ title="File to…"dataAttr={attr('file')}><TodaySpaceFileList@@ -110,6 +118,12 @@ export function TodaySessionActionItems({Hand off…</Item>)}+ {phoneLayout && surface === 'sidebar' && (+ <Item onClick={() => toggleSessionSelection(sessionId)} dataAttr={attr('select')}>+ <IconCheckbox />+ Select+ </Item>+ )}<Separator /><Item onClick={() => requestArchive(sessionId, menuId, activeRunId)} dataAttr={attr('archive')}><IconArchive />diff --git a/frontend/src/layout/today/TodaySessionBulkActionItems.tsx b/frontend/src/layout/today/TodaySessionBulkActionItems.tsxindex 6a675692a64e..fbb58fd39514 100644--- a/frontend/src/layout/today/TodaySessionBulkActionItems.tsx+++ b/frontend/src/layout/today/TodaySessionBulkActionItems.tsx@@ -64,6 +64,7 @@ export function TodaySessionBulkActionItems({{`File ${sessions} to…`}</>}+ title={`File ${sessions} to…`}dataAttr={attr('file')}><TodaySpaceFileListdiff --git a/frontend/src/layout/today/TodaySessionBulkBar.tsx b/frontend/src/layout/today/TodaySessionBulkBar.tsxindex 7e49a34f7ce5..d935ecb21fba 100644--- a/frontend/src/layout/today/TodaySessionBulkBar.tsx+++ b/frontend/src/layout/today/TodaySessionBulkBar.tsx@@ -15,6 +15,7 @@ import {import { TodaySessionBulkArchiveDialog } from './TodaySessionBulkArchiveDialog'import { sessionsLabel } from './todaySessionSelection'import { TodayBulkAction, todaySessionSelectionLogic } from './todaySessionSelectionLogic'+import { todayShellLogic } from './todayShellLogic'import { TodaySpaceFileList } from './TodaySpaceFileList'import { todaySpacesLogic } from './todaySpacesLogic'@@ -67,7 +68,9 @@ export function TodaySessionBulkBar(): JSX.Element {archiveSelected,} = useActions(todaySessionSelectionLogic)const { spaces } = useValues(todaySpacesLogic)+ const { phoneLayout } = useValues(todayShellLogic)const count = selectedSessionIds.length+ const minimum = phoneLayout ? 1 : 2const sessions = sessionsLabel(count)const pin = bulkPinDirection === 'pin'@@ -75,9 +78,9 @@ export function TodaySessionBulkBar(): JSX.Element {<>{/* The bar is the only sign of a selection and unmounts below two, so the announcement lives outside it. */}<span aria-live="polite" className="sr-only">- {count > 1 ? `${sessions} selected` : ''}+ {count >= minimum ? `${sessions} selected` : ''}</span>- {count > 1 && (+ {count >= minimum && (<divclassName="-mx-3 flex items-center justify-between gap-2 border-t border-border px-3 py-1.5"data-attr="today-session-bulk-bar"@@ -86,9 +89,11 @@ export function TodaySessionBulkBar(): JSX.Element {<Text size="xs" weight="medium" render={<span />} className="shrink-0">{`${count} selected`}</Text>- <Text size="xxs" variant="muted" render={<span />} className="truncate">- Esc to clear- </Text>+ {!phoneLayout && (+ <Text size="xxs" variant="muted" render={<span />} className="truncate">+ Esc to clear+ </Text>+ )}</div><div className="flex shrink-0 items-center gap-0.5"><BulkButtondiff --git a/frontend/src/layout/today/TodaySessionContextMenu.tsx b/frontend/src/layout/today/TodaySessionContextMenu.tsxindex 4d5580a4e115..5f1c79203191 100644--- a/frontend/src/layout/today/TodaySessionContextMenu.tsx+++ b/frontend/src/layout/today/TodaySessionContextMenu.tsx@@ -1,15 +1,18 @@-import { useActions } from 'kea'+import { useActions, useValues } from 'kea'import { ReactNode, useState } from 'react'import { ContextMenu, ContextMenuContent, ContextMenuTrigger } from '@posthog/quill'-import { CONTEXT_PARTS } from './todayMenuParts'+import { CONTEXT_PARTS, SHEET_PARTS } from './todayMenuParts'import { useTodayPreviewMenuReport } from './todayPreviewCardContext'import { TodaySessionActionItems } from './TodaySessionActionItems'import { useTodayArchiveShortcut } from './todaySessionArchiveShortcut'import { TodayBulkSelection, TodaySessionBulkActionItems } from './TodaySessionBulkActionItems'import { TodaySessionSurface, todaySessionMenuLogic } from './todaySessionMenuLogic'-import { rightClickActsOnSelection } from './todaySessionSelection'+import { rightClickActsOnSelection, sessionsLabel } from './todaySessionSelection'+import { TodaySheetMenu } from './TodaySheetMenu'+import { todayShellLogic } from './todayShellLogic'+import { todaySpacesLogic } from './todaySpacesLogic'import { TodaySessionMenuTarget } from './todayWorkItems'const BULK_DATA_ATTR_PREFIX: Record<TodaySessionSurface, string> = {@@ -33,8 +36,12 @@ export function TodaySessionContextMenu({children,}: TodaySessionContextMenuProps): JSX.Element {const { requestArchive } = useActions(todaySessionMenuLogic)+ const { phoneLayout } = useValues(todayShellLogic)+ const { spaceNames } = useValues(todaySpacesLogic)+ const { touchMenuOpened } = useActions(todaySpacesLogic)const reportMenuOpen = useTodayPreviewMenuReport()const [open, setOpen] = useState(false)+ const [sheetOpen, setSheetOpen] = useState(false)const setMenuOpen = (nextOpen: boolean): void => {setOpen(nextOpen)reportMenuOpen(nextOpen)@@ -45,6 +52,50 @@ export function TodaySessionContextMenu({requestArchive(target.sessionId, target.menuId, target.activeRunId)})+ if (phoneLayout) {+ const spaceName = target.spaceId ? spaceNames[target.spaceId] : null+ return (+ <>+ <ContextMenu+ open={false}+ onOpenChange={(next) => {+ if (next) {+ setSheetOpen(true)+ touchMenuOpened(bulk ? 'bulk' : 'session')+ }+ }}+ >+ <ContextMenuTrigger render={<div className="min-w-0" />}>{children}</ContextMenuTrigger>+ </ContextMenu>+ <TodaySheetMenu+ open={sheetOpen}+ onOpenChange={setSheetOpen}+ title={+ bulk+ ? `${sessionsLabel(selection.selectedSessionIds.length)} selected`+ : target.title || 'Untitled session'+ }+ description={bulk ? undefined : (spaceName ?? undefined)}+ >+ {bulk ? (+ <TodaySessionBulkActionItems+ parts={SHEET_PARTS}+ selection={selection}+ dataAttrPrefix={BULK_DATA_ATTR_PREFIX[surface]}+ />+ ) : (+ <TodaySessionActionItems+ parts={SHEET_PARTS}+ target={target}+ surface={surface}+ dataAttrPrefix="today-session-sheet"+ />+ )}+ </TodaySheetMenu>+ </>+ )+ }+return (<ContextMenu open={open} onOpenChange={setMenuOpen}><ContextMenuTrigger render={<div className="min-w-0" />}>{children}</ContextMenuTrigger>diff --git a/frontend/src/layout/today/TodaySheetMenu.tsx b/frontend/src/layout/today/TodaySheetMenu.tsxnew file mode 100644index 000000000000..ca44730f9cf7--- /dev/null+++ b/frontend/src/layout/today/TodaySheetMenu.tsx@@ -0,0 +1,103 @@+import { ReactNode, useMemo, useState } from 'react'++import { IconChevronLeft } from '@posthog/icons'+import {+ Button,+ Drawer,+ DrawerContent,+ DrawerDescription,+ DrawerHeader,+ DrawerTitle,+ Tooltip,+ TooltipContent,+ TooltipTrigger,+} from '@posthog/quill'++import { TodaySheetMenuContext, TodaySheetMenuControls } from './todaySheetMenuContext'++interface TodaySheetMenuProps {+ open: boolean+ onOpenChange: (open: boolean) => void+ title: string+ description?: string+ children: ReactNode+}++interface TodaySheetPage {+ id: string+ title: string+}++export function TodaySheetMenu({ open, onOpenChange, title, description, children }: TodaySheetMenuProps): JSX.Element {+ const [page, setPage] = useState<TodaySheetPage | null>(null)+ const [pageContainer, setPageContainer] = useState<HTMLElement | null>(null)++ const setOpen = (next: boolean): void => {+ if (!next) {+ setPage(null)+ }+ onOpenChange(next)+ }++ const controls = useMemo<TodaySheetMenuControls>(+ () => ({+ close: () => {+ setPage(null)+ onOpenChange(false)+ },+ back: () => setPage(null),+ openPage: (id, pageTitle) => setPage({ id, title: pageTitle }),+ activePageId: page?.id ?? null,+ pageContainer,+ }),+ [onOpenChange, page, pageContainer]+ )++ return (+ <Drawer open={open} onOpenChange={setOpen} swipeDirection="down">+ <DrawerContent data-attr="today-sheet-menu">+ <TodaySheetMenuContext.Provider value={controls}>+ {page ? (+ <div className="flex items-center gap-1 px-2 pt-1 pb-2">+ <Tooltip>+ <TooltipTrigger+ delay={0}+ render={+ <Button+ size="icon-lg"+ className="rounded-full"+ aria-label="Back"+ onClick={() => setPage(null)}+ data-attr="today-sheet-menu-back"+ />+ }+ >+ <IconChevronLeft />+ </TooltipTrigger>+ <TooltipContent>Back</TooltipContent>+ </Tooltip>+ <DrawerTitle className="truncate text-base font-semibold">{page.title}</DrawerTitle>+ </div>+ ) : (+ <DrawerHeader className="gap-0.5 border-b border-border px-4 pt-1 pb-3">+ <DrawerTitle className="truncate text-base font-semibold">{title}</DrawerTitle>+ {description && (+ <DrawerDescription className="truncate text-sm text-muted-foreground">+ {description}+ </DrawerDescription>+ )}+ </DrawerHeader>+ )}+ <div className="flex min-h-0 flex-col overflow-y-auto px-2 pt-1 pb-3" hidden={page !== null}>+ {children}+ </div>+ <div+ ref={setPageContainer}+ className="flex min-h-0 flex-col overflow-y-auto px-2 pb-3"+ hidden={page === null}+ />+ </TodaySheetMenuContext.Provider>+ </DrawerContent>+ </Drawer>+ )+}diff --git a/frontend/src/layout/today/TodaySheetSub.tsx b/frontend/src/layout/today/TodaySheetSub.tsxnew file mode 100644index 000000000000..77041509c244--- /dev/null+++ b/frontend/src/layout/today/TodaySheetSub.tsx@@ -0,0 +1,54 @@+import { ReactNode, useId } from 'react'+import { createPortal } from 'react-dom'++import { IconChevronRight } from '@posthog/icons'+import { ItemMenuItem, cn } from '@posthog/quill'++import { useTodaySheetMenu } from './todaySheetMenuContext'++interface TodaySheetSubProps {+ label: ReactNode+ title: string+ value?: string+ narrowed?: boolean+ dataAttr?: string+ children: ReactNode+}++export function TodaySheetSub({+ label,+ title,+ value,+ narrowed = false,+ dataAttr,+ children,+}: TodaySheetSubProps): JSX.Element {+ const sheet = useTodaySheetMenu()+ const pageId = useId()+ const open = sheet?.activePageId === pageId++ return (+ <>+ <ItemMenuItem+ className="flex-nowrap text-base"+ aria-haspopup="menu"+ onClick={() => sheet?.openPage(pageId, title)}+ data-attr={dataAttr}+ >+ <span className="flex min-w-0 items-center gap-2">{label}</span>+ {value && (+ <span+ className={cn(+ 'ml-auto min-w-0 truncate pl-4 text-right',+ narrowed ? 'text-primary' : 'text-muted-foreground'+ )}+ >+ {value}+ </span>+ )}+ <IconChevronRight className={cn('shrink-0 text-muted-foreground', !value && 'ml-auto')} />+ </ItemMenuItem>+ {open && sheet?.pageContainer && createPortal(children, sheet.pageContainer)}+ </>+ )+}diff --git a/frontend/src/layout/today/TodaySpaceContextMenu.tsx b/frontend/src/layout/today/TodaySpaceContextMenu.tsxindex 71470a5bc7da..d53e4947ce96 100644--- a/frontend/src/layout/today/TodaySpaceContextMenu.tsx+++ b/frontend/src/layout/today/TodaySpaceContextMenu.tsx@@ -1,16 +1,45 @@-import { ReactNode } from 'react'+import { useActions, useValues } from 'kea'+import { ReactNode, useState } from 'react'import { ContextMenu, ContextMenuContent, ContextMenuTrigger } from '@posthog/quill'import { ChannelDTOApi } from 'products/tasks/frontend/generated/api.schemas'-import { CONTEXT_PARTS } from './todayMenuParts'+import { CONTEXT_PARTS, SHEET_PARTS } from './todayMenuParts'import { useTodayPreviewMenuReport } from './todayPreviewCardContext'+import { TodaySheetMenu } from './TodaySheetMenu'+import { todayShellLogic } from './todayShellLogic'import { TodaySpaceActions } from './TodaySpaceActions'+import { spaceLabel, todaySpacesLogic } from './todaySpacesLogic'/** A space row's actions on right-click, the same list its hover card shows, like PostHog Desktop. */export function TodaySpaceContextMenu({ space, children }: { space: ChannelDTOApi; children: ReactNode }): JSX.Element {const reportMenuOpen = useTodayPreviewMenuReport()+ const { phoneLayout } = useValues(todayShellLogic)+ const { touchMenuOpened } = useActions(todaySpacesLogic)+ const [sheetOpen, setSheetOpen] = useState(false)++ if (phoneLayout) {+ return (+ <>+ <ContextMenu+ open={false}+ onOpenChange={(next) => {+ if (next) {+ setSheetOpen(true)+ touchMenuOpened('space')+ }+ }}+ >+ <ContextMenuTrigger render={<div className="min-w-0" />}>{children}</ContextMenuTrigger>+ </ContextMenu>+ <TodaySheetMenu open={sheetOpen} onOpenChange={setSheetOpen} title={spaceLabel(space)}>+ <TodaySpaceActions parts={SHEET_PARTS} space={space} dataAttrPrefix="today-space-sheet" />+ </TodaySheetMenu>+ </>+ )+ }+return (<ContextMenu onOpenChange={reportMenuOpen}><ContextMenuTrigger render={<div className="min-w-0" />}>{children}</ContextMenuTrigger>diff --git a/frontend/src/layout/today/TodaySpaceFileList.tsx b/frontend/src/layout/today/TodaySpaceFileList.tsxindex 095eb5ea8758..e203f8e4d4fd 100644--- a/frontend/src/layout/today/TodaySpaceFileList.tsx+++ b/frontend/src/layout/today/TodaySpaceFileList.tsx@@ -2,8 +2,9 @@ import { useValues } from 'kea'import { ChangeEvent, useState } from 'react'import { IconStar } from '@posthog/icons'-import { DropdownMenuRadioGroup, DropdownMenuRadioItem, Input, Text } from '@posthog/quill'+import { DropdownMenuRadioGroup, DropdownMenuRadioItem, Input, ItemRadio, Text } from '@posthog/quill'+import { useTodaySheetMenu } from './todaySheetMenuContext'import { fileToSpaces, spaceLabel, todaySpacesLogic } from './todaySpacesLogic'/** Desktop's "File to…" list gets a fixed height past this many spaces; the web adds its search there. */@@ -26,6 +27,7 @@ export function TodaySpaceFileList({}: TodaySpaceFileListProps): JSX.Element {const { spaces } = useValues(todaySpacesLogic)const [search, setSearch] = useState('')+ const sheet = useTodaySheetMenu()const targets = fileToSpaces(spaces, currentSpaceId, search)return (@@ -34,7 +36,7 @@ export function TodaySpaceFileList({// Keep typing away from the menu's typeahead; Escape still closes the menu.<div className="p-1" onKeyDown={(event) => event.key !== 'Escape' && event.stopPropagation()}><Input- autoFocus+ autoFocus={!sheet}value={search}onChange={(event: ChangeEvent<HTMLInputElement>) => setSearch(event.target.value)}placeholder="Search spaces…"@@ -48,16 +50,36 @@ export function TodaySpaceFileList({No spaces match your search</Text>)}- <DropdownMenuRadioGroup value={currentSpaceId ?? ''} onValueChange={(value: string) => onSelect(value)}>- {targets.map((space) => (- <DropdownMenuRadioItem key={space.id} value={space.id} closeOnClick data-attr={itemDataAttr}>+ {sheet ? (+ targets.map((space) => (+ <ItemRadio+ key={space.id}+ className="flex-nowrap text-base"+ aria-checked={space.id === currentSpaceId}+ onClick={() => {+ onSelect(space.id)+ sheet.close()+ }}+ data-attr={itemDataAttr}+ ><span className="truncate">{spaceLabel(space)}</span>{space.starred && space.system_role !== 'personal' && (- <IconStar className="ml-auto text-muted-foreground" />+ <IconStar className="shrink-0 text-muted-foreground" />)}- </DropdownMenuRadioItem>- ))}- </DropdownMenuRadioGroup>+ </ItemRadio>+ ))+ ) : (+ <DropdownMenuRadioGroup value={currentSpaceId ?? ''} onValueChange={(value: string) => onSelect(value)}>+ {targets.map((space) => (+ <DropdownMenuRadioItem key={space.id} value={space.id} closeOnClick data-attr={itemDataAttr}>+ <span className="truncate">{spaceLabel(space)}</span>+ {space.starred && space.system_role !== 'personal' && (+ <IconStar className="ml-auto text-muted-foreground" />+ )}+ </DropdownMenuRadioItem>+ ))}+ </DropdownMenuRadioGroup>+ )}</>)}diff --git a/frontend/src/layout/today/TodaySpacesPane.tsx b/frontend/src/layout/today/TodaySpacesPane.tsxindex a528e388cbdd..acce7a0fe18b 100644--- a/frontend/src/layout/today/TodaySpacesPane.tsx+++ b/frontend/src/layout/today/TodaySpacesPane.tsx@@ -3,14 +3,16 @@ import { useValues } from 'kea'import { TodayPreviewCardProvider } from './TodayPreviewCardProvider'import { todaySessionMenuLogic } from './todaySessionMenuLogic'import { todaySessionSelectionLogic } from './todaySessionSelectionLogic'+import { todayShellLogic } from './todayShellLogic'import { TodaySpacesSidebar } from './TodaySpacesSidebar'export function TodaySpacesPane(): JSX.Element {const { sessionDialogOpen } = useValues(todaySessionMenuLogic)const { bulkArchiveConfirm } = useValues(todaySessionSelectionLogic)+ const { phoneLayout } = useValues(todayShellLogic)return (- <TodayPreviewCardProvider disabled={sessionDialogOpen || bulkArchiveConfirm.open}>+ <TodayPreviewCardProvider disabled={phoneLayout || sessionDialogOpen || bulkArchiveConfirm.open}><TodaySpacesSidebar /></TodayPreviewCardProvider>)diff --git a/frontend/src/layout/today/TodaySpacesSidebar.tsx b/frontend/src/layout/today/TodaySpacesSidebar.tsxindex d84cf28bd773..9be35e15d2f6 100644--- a/frontend/src/layout/today/TodaySpacesSidebar.tsx+++ b/frontend/src/layout/today/TodaySpacesSidebar.tsx@@ -69,6 +69,12 @@ export function TodaySpacesSidebar(): JSX.Element {// Like Desktop, Cmd/Ctrl-click and Shift-click pick rows instead of opening them, and a plain click clears the pick.const onSelectClick = (sessionId: string, event: React.MouseEvent<HTMLElement>): void => {+ if (phoneLayout && selectedIds.size > 0) {+ event.preventDefault()+ event.stopPropagation()+ toggleSessionSelection(sessionId)+ return+ }const click = selectionClick(event)if (click === 'open') {clearSelection()diff --git a/frontend/src/layout/today/todayMenuParts.tsx b/frontend/src/layout/today/todayMenuParts.tsxindex 294e68279af9..cec3e4b1ae22 100644--- a/frontend/src/layout/today/todayMenuParts.tsx+++ b/frontend/src/layout/today/todayMenuParts.tsx@@ -18,10 +18,15 @@ import {DropdownMenuSubContent,DropdownMenuSubTrigger,DropdownMenuTrigger,+ ItemMenuItem,+ cn,} from '@posthog/quill'import { LinkPrimitive } from 'lib/lemon-ui/Link'+import { useTodaySheetMenu } from './todaySheetMenuContext'+import { TodaySheetSub } from './TodaySheetSub'+export interface TodayMenuItemProps {children: ReactNodedataAttr: string@@ -34,6 +39,7 @@ export interface TodayMenuItemProps {export interface TodayMenuSubProps {label: ReactNode+ title: stringdataAttr: stringchildren: ReactNode}@@ -96,6 +102,38 @@ export const CONTEXT_PARTS: TodayMenuParts = {),}+function SheetItem({ children, dataAttr, onClick, to, disabled, variant }: TodayMenuItemProps): JSX.Element {+ const sheet = useTodaySheetMenu()+ return (+ <ItemMenuItem+ className={cn(+ 'text-base no-underline',+ variant === 'destructive' ? 'text-destructive-foreground' : 'text-foreground'+ )}+ disabled={disabled}+ onClick={() => {+ onClick?.()+ sheet?.close()+ }}+ {...(to ? { render: <LinkPrimitive to={to} /> } : {})}+ data-attr={dataAttr}+ >+ {children}+ </ItemMenuItem>+ )+}++export const SHEET_PARTS: TodayMenuParts = {+ Item: SheetItem,+ Separator: () => <div role="separator" className="my-1 border-t border-border" />,+ Shortcut: () => <></>,+ Sub: ({ label, title, dataAttr, children }) => (+ <TodaySheetSub label={label} title={title} dataAttr={dataAttr}>+ {children}+ </TodaySheetSub>+ ),+}+/*** The parts for a hover card's action list. The card is not a menu, so its rows are plain buttons.* `onAction` closes the card after a choice. `onSubmenuOpenChange` reports "File to…", whose menu opensdiff --git a/frontend/src/layout/today/todaySessionSelectionLogic.test.ts b/frontend/src/layout/today/todaySessionSelectionLogic.test.tsindex 0cd49b198791..f8dc22758c0a 100644--- a/frontend/src/layout/today/todaySessionSelectionLogic.test.ts+++ b/frontend/src/layout/today/todaySessionSelectionLogic.test.ts@@ -149,4 +149,23 @@ describe('todaySessionSelectionLogic', () => {expect(logic.values.selectedSessionIds).toEqual([])})++ it.each([+ ['drops', 'a desktop window', 1280, []],+ ['keeps', 'a phone', 375, ['task-a']],+ ])('%s a picked session from a collapsed Recent section in %s', (_, __, width, expected) => {+ const originalWidth = window.innerWidth+ Object.defineProperty(window, 'innerWidth', { configurable: true, value: width })+ window.dispatchEvent(new Event('resize'))+ todaySpacesLogic.actions.toggleSection('recent')+ try {+ logic.actions.toggleSessionSelection('task-a')++ expect(logic.values.selectedSessionIds).toEqual(expected)+ } finally {+ todaySpacesLogic.actions.toggleSection('recent')+ Object.defineProperty(window, 'innerWidth', { configurable: true, value: originalWidth })+ window.dispatchEvent(new Event('resize'))+ }+ })})diff --git a/frontend/src/layout/today/todaySessionSelectionLogic.ts b/frontend/src/layout/today/todaySessionSelectionLogic.tsindex 7558fb15633b..d8950374a990 100644--- a/frontend/src/layout/today/todaySessionSelectionLogic.ts+++ b/frontend/src/layout/today/todaySessionSelectionLogic.ts@@ -23,6 +23,7 @@ import {pruneToVisible,toggleSelection,} from './todaySessionSelection'+import { todayShellLogic } from './todayShellLogic'import { TodayWorkSectionId, todaySpacesLogic } from './todaySpacesLogic'import { TodayWorkItem, activeCloudRunId } from './todayWorkItems'@@ -40,6 +41,7 @@ export const CLOSED_BULK_ARCHIVE_CONFIRM: TodayBulkArchiveConfirm = { open: fals// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface todaySessionSelectionLogicValues {currentTeamId: number | null // teamLogic+ phoneLayout: boolean // todayShellLogiccollapsedSections: TodayWorkSectionId[] // todaySpacesLogicpinnedItems: TodayWorkItem[] // todaySpacesLogicrecentGroups: TodayRecentSection[] // todaySpacesLogic@@ -126,7 +128,8 @@ export interface todaySessionSelectionLogicMeta {orderedSessionIds: (pinnedItems: TodayWorkItem[],recentGroups: TodayRecentSection[],- collapsedSections: TodayWorkSectionId[]+ collapsedSections: TodayWorkSectionId[],+ phoneLayout: boolean) => string[]selectedSessionIds: (selection: TodaySessionSelection, orderedSessionIds: string[]) => string[]selectedSessions: (@@ -149,7 +152,14 @@ export type todaySessionSelectionLogicType = MakeLogicType<export const todaySessionSelectionLogic = kea<todaySessionSelectionLogicType>([path(['layout', 'today', 'todaySessionSelectionLogic']),connect(() => ({- values: [teamLogic, ['currentTeamId'], todaySpacesLogic, ['collapsedSections', 'pinnedItems', 'recentGroups']],+ values: [+ teamLogic,+ ['currentTeamId'],+ todaySpacesLogic,+ ['collapsedSections', 'pinnedItems', 'recentGroups'],+ todayShellLogic,+ ['phoneLayout'],+ ],actions: [router, ['locationChanged'], todaySpacesLogic, ['loadPinnedTasks', 'loadRecentTasks']],})),actions({@@ -199,16 +209,17 @@ export const todaySessionSelectionLogic = kea<todaySessionSelectionLogicType>([}),selectors({orderedSessionIds: [- (s) => [s.pinnedItems, s.recentGroups, s.collapsedSections],+ (s) => [s.pinnedItems, s.recentGroups, s.collapsedSections, s.phoneLayout],(pinnedItems: TodayWorkItem[],recentGroups: TodayRecentSection[],- collapsedSections: TodayWorkSectionId[]+ collapsedSections: TodayWorkSectionId[],+ phoneLayout: boolean): string[] =>orderedVisibleSessionIds(pinnedItems,recentGroups.flatMap((group) => group.items),- collapsedSections+ phoneLayout ? [] : collapsedSections),],// Rows that leave the list, like archived ones or those behind a filter, drop out of the selection.diff --git a/frontend/src/layout/today/todaySheetMenuContext.ts b/frontend/src/layout/today/todaySheetMenuContext.tsnew file mode 100644index 000000000000..d847cdee9d62--- /dev/null+++ b/frontend/src/layout/today/todaySheetMenuContext.ts@@ -0,0 +1,15 @@+import { createContext, useContext } from 'react'++export interface TodaySheetMenuControls {+ close: () => void+ back: () => void+ openPage: (pageId: string, title: string) => void+ activePageId: string | null+ pageContainer: HTMLElement | null+}++export const TodaySheetMenuContext = createContext<TodaySheetMenuControls | null>(null)++export function useTodaySheetMenu(): TodaySheetMenuControls | null {+ return useContext(TodaySheetMenuContext)+}diff --git a/frontend/src/layout/today/todaySpacesLogic.ts b/frontend/src/layout/today/todaySpacesLogic.tsindex 0b94f5e56785..d1e1e5317d6b 100644--- a/frontend/src/layout/today/todaySpacesLogic.ts+++ b/frontend/src/layout/today/todaySpacesLogic.ts@@ -82,6 +82,8 @@ const SPACE_PRESENCE_POLL_INTERVAL_MS = 90_000export type TodayWorkSectionId = 'pinned' | 'recent' | 'spaces'+export type TodayTouchMenu = 'session' | 'space' | 'bulk' | 'filter'+/** 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 {const match = removeProjectIdIfPresent(pathname).match(/^\/spaces\/([^/]+)/)@@ -345,6 +347,9 @@ export interface todaySpacesLogicActions {spaceId: stringstarred: boolean}+ touchMenuOpened: (menu: TodayTouchMenu) => {+ menu: TodayTouchMenu+ }}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -415,6 +420,7 @@ export const todaySpacesLogic = kea<todaySpacesLogicType>([actions({toggleSection: (sectionId: TodayWorkSectionId) => ({ sectionId }),setPhoneSection: (section: TodayWorkSectionId) => ({ section }),+ touchMenuOpened: (menu: TodayTouchMenu) => ({ menu }),setSectionHeights: (heights: Partial<Record<TodayWorkSectionId, number>>) => ({ heights }),resetSectionPair: (upper: TodayWorkSectionId, lower: TodayWorkSectionId) => ({ upper, lower }),spaceVisited: (spaceId: string) => ({ spaceId }),@@ -751,6 +757,9 @@ export const todaySpacesLogic = kea<todaySpacesLogicType>([setPhoneSection: ({ section }) => {posthog.capture('today spaces section picked', { section })},+ touchMenuOpened: ({ menu }) => {+ posthog.capture('today touch menu opened', { menu })+ },loadPinnedTasksSuccess: ({ pinnedTasks }) =>actions.loadPullRequestStates(sessionIdsWithPullRequests(pinnedTasks)),loadRecentTasksSuccess: ({ recentTasks }) =>