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): move sidebar row actions into the hover cards, like desktop (#109666)

Shy Alter5164df0e3186
diff --git a/frontend/src/layout/today/TodayPreviewCardProvider.tsx b/frontend/src/layout/today/TodayPreviewCardProvider.tsx
index 090e26ba0243..b4e1f1ec1d4a 100644
--- a/frontend/src/layout/today/TodayPreviewCardProvider.tsx
+++ b/frontend/src/layout/today/TodayPreviewCardProvider.tsx
@@ -1,11 +1,13 @@
import { PreviewCard } from '@base-ui/react/preview-card'
-import { ReactNode, useMemo, useRef, useState } from 'react'
+import { useValues } from 'kea'
+import { ReactNode, useCallback, useMemo, useRef, useState } from 'react'
import { Card } from '@posthog/quill'
import { TodayPreviewCard, TodayPreviewCardContext } from './todayPreviewCardContext'
import { TodayPreviewPayload } from './todayPreviewCards'
import { TodaySessionHoverCard } from './TodaySessionHoverCard'
+import { todaySessionMenuLogic } from './todaySessionMenuLogic'
import { TodaySpaceHoverCard } from './TodaySpaceHoverCard'
/**
@@ -16,6 +18,9 @@ import { TodaySpaceHoverCard } from './TodaySpaceHoverCard'
export function TodayPreviewCardProvider({ children }: { children: ReactNode }): JSX.Element {
const [handle] = useState(() => PreviewCard.createHandle<TodayPreviewPayload>())
const [open, setOpen] = useState(false)
+ // "File to…" opens outside the card, so the pointer moving there reads as leaving it.
+ const [submenuOpen, setSubmenuOpen] = useState(false)
+ const { sessionDialogOpen } = useValues(todaySessionMenuLogic)
// A ref, so a hover that lands while a menu is open is refused on the same event.
const menuOpen = useRef(false)
const card = useMemo<TodayPreviewCard>(
@@ -30,11 +35,20 @@ export function TodayPreviewCardProvider({ children }: { children: ReactNode }):
}),
[handle]
)
+ const close = useCallback(() => {
+ setSubmenuOpen(false)
+ setOpen(false)
+ }, [])
return (
<TodayPreviewCardContext.Provider value={card}>
{children}
- <PreviewCard.Root handle={handle} open={open} onOpenChange={(next) => setOpen(next && !menuOpen.current)}>
+ <PreviewCard.Root
+ handle={handle}
+ // A session dialog keeps the card shut, so the card can't open over it.
+ open={(open || submenuOpen) && !sessionDialogOpen}
+ onOpenChange={(next) => setOpen(next && !menuOpen.current && !sessionDialogOpen)}
+ >
{({ payload }) =>
payload ? (
<PreviewCard.Portal>
@@ -50,9 +64,15 @@ export function TodayPreviewCardProvider({ children }: { children: ReactNode }):
<PreviewCard.Popup className="outline-none">
<Card size="sm" className="w-72 gap-0 border border-border py-0 shadow-md">
{payload.kind === 'space' ? (
- <TodaySpaceHoverCard preview={payload} />
+ <TodaySpaceHoverCard preview={payload} onAction={close} />
) : (
- <TodaySessionHoverCard preview={payload} />
+ <TodaySessionHoverCard
+ // Keyed on the row, so moving to another row unmounts the card and lowers the submenu flag.
+ key={payload.menu.menuId}
+ preview={payload}
+ onAction={close}
+ onSubmenuOpenChange={setSubmenuOpen}
+ />
)}
</Card>
</PreviewCard.Popup>
diff --git a/frontend/src/layout/today/TodaySessionActionItems.tsx b/frontend/src/layout/today/TodaySessionActionItems.tsx
new file mode 100644
index 000000000000..f5850ef9aece
--- /dev/null
+++ b/frontend/src/layout/today/TodaySessionActionItems.tsx
@@ -0,0 +1,119 @@
+import { useActions, useValues } from 'kea'
+
+import {
+ IconArchive,
+ IconCopy,
+ IconExternal,
+ IconFolder,
+ IconPencil,
+ IconPin,
+ IconPinFilled,
+ IconSearch,
+ IconSend,
+ IconStopFilled,
+} from '@posthog/icons'
+
+import { FEATURE_FLAGS } from 'lib/constants'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+
+import { TodayMenuParts } from './todayMenuParts'
+import { TodaySessionSurface, todaySessionMenuLogic } from './todaySessionMenuLogic'
+import { TodaySpaceFileList } from './TodaySpaceFileList'
+import { todaySpacesLogic } from './todaySpacesLogic'
+import { TodaySessionMenuTarget } from './todayWorkItems'
+
+interface TodaySessionActionItemsProps {
+ parts: TodayMenuParts
+ target: TodaySessionMenuTarget
+ surface: TodaySessionSurface
+ /** Starts each item's `data-attr`, so every surface counts on its own. */
+ dataAttrPrefix: string
+}
+
+/** A session's actions, in Desktop's order: the edits, the places it can go, then archive last. */
+export function TodaySessionActionItems({
+ parts: { Item, Separator, Sub },
+ target,
+ surface,
+ dataAttrPrefix,
+}: TodaySessionActionItemsProps): JSX.Element {
+ const { featureFlags } = useValues(featureFlagLogic)
+ const { spaces } = useValues(todaySpacesLogic)
+ const {
+ setSessionPinned,
+ startRenaming,
+ requestArchive,
+ moveSession,
+ openHandoff,
+ analyzeSession,
+ openSessionInNewTab,
+ copySessionLink,
+ stopSession,
+ } = useActions(todaySessionMenuLogic)
+ const { menuId, sessionId, pinned, activeRunId } = target
+ const runId = featureFlags[FEATURE_FLAGS.POSTHOG_CODE_TASK_ANALYSIS] ? target.analysisRunId : null
+ const attr = (name: string): string => `${dataAttrPrefix}-${name}`
+
+ return (
+ <>
+ <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
+ </Item>
+ <Item onClick={() => setSessionPinned(sessionId, !pinned)} dataAttr={attr('pin')}>
+ {pinned ? <IconPinFilled /> : <IconPin />}
+ {pinned ? 'Unpin' : 'Pin'}
+ </Item>
+ <Item onClick={() => startRenaming(sessionId, surface)} dataAttr={attr('rename')}>
+ <IconPencil />
+ Rename…
+ </Item>
+ {runId && (
+ <Item onClick={() => analyzeSession(sessionId, runId)} dataAttr={attr('analyze')}>
+ <IconSearch />
+ Run analysis
+ </Item>
+ )}
+ {activeRunId && (
+ <Item onClick={() => stopSession(sessionId, activeRunId)} dataAttr={attr('stop')}>
+ <IconStopFilled />
+ Stop session
+ </Item>
+ )}
+ {spaces.length > 0 && (
+ <Sub
+ label={
+ <>
+ <IconFolder />
+ File to…
+ </>
+ }
+ dataAttr={attr('file')}
+ >
+ <TodaySpaceFileList
+ currentSpaceId={target.spaceId}
+ onSelect={(spaceId) => moveSession(sessionId, spaceId)}
+ itemDataAttr={attr('move')}
+ searchDataAttr={attr('move-search')}
+ />
+ </Sub>
+ )}
+ {target.canHandOff && (
+ <Item onClick={() => openHandoff(menuId)} dataAttr={attr('handoff')}>
+ <IconSend />
+ Hand off…
+ </Item>
+ )}
+ <Separator />
+ <Item onClick={() => requestArchive(sessionId, menuId, activeRunId)} dataAttr={attr('archive')}>
+ <IconArchive />
+ {/* Only a running session asks first, so only its label promises a next step. */}
+ {activeRunId ? 'Archive…' : 'Archive'}
+ </Item>
+ </>
+ )
+}
diff --git a/frontend/src/layout/today/TodaySessionDialogs.tsx b/frontend/src/layout/today/TodaySessionDialogs.tsx
new file mode 100644
index 000000000000..7c2394d4d57a
--- /dev/null
+++ b/frontend/src/layout/today/TodaySessionDialogs.tsx
@@ -0,0 +1,25 @@
+import { useValues } from 'kea'
+
+import { TodaySessionArchiveDialog } from './TodaySessionArchiveDialog'
+import { TodaySessionHandoffDialog } from './TodaySessionHandoffDialog'
+import { todaySessionMenuLogic } from './todaySessionMenuLogic'
+import { TodaySessionMenuTarget } from './todayWorkItems'
+
+/** The dialogs a session's actions open. The row or card that owns `target.menuId` renders them, so they outlive the menu. */
+export function TodaySessionDialogs({ target }: { target: TodaySessionMenuTarget }): JSX.Element {
+ const { handoffMenuId, archiveConfirmMenuId } = useValues(todaySessionMenuLogic)
+ return (
+ <>
+ {target.canHandOff && handoffMenuId === target.menuId && (
+ <TodaySessionHandoffDialog sessionId={target.sessionId} />
+ )}
+ {target.activeRunId && archiveConfirmMenuId === target.menuId && (
+ <TodaySessionArchiveDialog
+ sessionId={target.sessionId}
+ title={target.title}
+ runId={target.activeRunId}
+ />
+ )}
+ </>
+ )
+}
diff --git a/frontend/src/layout/today/TodaySessionHoverCard.tsx b/frontend/src/layout/today/TodaySessionHoverCard.tsx
index dea762548eb3..0a50071b6714 100644
--- a/frontend/src/layout/today/TodaySessionHoverCard.tsx
+++ b/frontend/src/layout/today/TodaySessionHoverCard.tsx
@@ -1,3 +1,5 @@
+import { useEffect, useMemo } from 'react'
+
import { IconPinFilled, IconPullRequest } from '@posthog/icons'
import { Item, ItemContent, ItemSeparator, ItemTitle, Text, cn } from '@posthog/quill'
@@ -7,7 +9,9 @@ import { LinkPrimitive } from 'lib/lemon-ui/Link'
import { pullRequestStateMeta } from 'products/tasks/frontend/spaces/TaskPullRequestChip'
import { TaskUserAvatar, taskUserName } from 'products/tasks/frontend/spaces/TaskUserAvatar'
+import { cardMenuParts } from './todayMenuParts'
import { TodaySessionPreview } from './todayPreviewCards'
+import { TodaySessionActionItems } from './TodaySessionActionItems'
import { TodaySessionStatusDot } from './TodaySessionStatusDot'
function Fact({ label, children }: { label: string; children: JSX.Element | string }): JSX.Element {
@@ -21,9 +25,27 @@ function Fact({ label, children }: { label: string; children: JSX.Element | stri
)
}
-/** A session row's hover card: what the row's marks mean in words, where the work sits, and what the agent said last. */
-export function TodaySessionHoverCard({ preview }: { preview: TodaySessionPreview }): JSX.Element {
+interface TodaySessionHoverCardProps {
+ preview: TodaySessionPreview
+ /** Closes the card once an action is chosen. */
+ onAction: () => void
+ /** Keeps the card open while its "File to…" menu is. */
+ onSubmenuOpenChange: (open: boolean) => void
+}
+
+/**
+ * A session row's hover card: what the row's marks mean in words, where the work sits, what the agent said last,
+ * and the row's actions, like PostHog Desktop.
+ */
+export function TodaySessionHoverCard({
+ preview,
+ onAction,
+ onSubmenuOpenChange,
+}: TodaySessionHoverCardProps): JSX.Element {
const { dot, pullRequest, author } = preview
+ const parts = useMemo(() => cardMenuParts(onAction, onSubmenuOpenChange), [onAction, onSubmenuOpenChange])
+ // Base UI reports no close when the submenu unmounts with the card, which would keep the card open for good.
+ useEffect(() => () => onSubmenuOpenChange(false), [onSubmenuOpenChange])
const pullRequestState = pullRequestStateMeta(preview.pullRequestState)
return (
<div className="flex flex-col" data-attr="today-session-hover-card">
@@ -91,6 +113,15 @@ export function TodaySessionHoverCard({ preview }: { preview: TodaySessionPrevie
)}
</ItemContent>
</Item>
+ <ItemSeparator className="my-0" />
+ <div className="flex flex-col p-1">
+ <TodaySessionActionItems
+ parts={parts}
+ target={preview.menu}
+ surface="sidebar"
+ dataAttrPrefix="today-session-card"
+ />
+ </div>
</div>
)
}
diff --git a/frontend/src/layout/today/TodaySessionRow.tsx b/frontend/src/layout/today/TodaySessionRow.tsx
index 90f5f765315c..0436803aca50 100644
--- a/frontend/src/layout/today/TodaySessionRow.tsx
+++ b/frontend/src/layout/today/TodaySessionRow.tsx
@@ -1,6 +1,6 @@
import { useValues } from 'kea'
import { router } from 'kea-router'
-import { useMemo } from 'react'
+import { useId, useMemo } from 'react'
import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'
@@ -8,13 +8,13 @@ import { userLogic } from 'scenes/userLogic'
import { sessionPreview } from './todayPreviewCards'
import { TodayPreviewTrigger } from './TodayPreviewTrigger'
import { TodaySessionBadges } from './TodaySessionBadges'
-import { TodaySessionMenu } from './TodaySessionMenu'
+import { TodaySessionDialogs } from './TodaySessionDialogs'
import { TodaySessionSurface, todaySessionMenuLogic } from './todaySessionMenuLogic'
import { TodaySessionRenameInput } from './TodaySessionRenameInput'
import { TodaySessionStatusDot } from './TodaySessionStatusDot'
import { todaySpacesLogic } from './todaySpacesLogic'
import { TodaySpacesRow } from './TodaySpacesRow'
-import { TodayWorkItem, activeCloudRunId, analysisRunId, canHandOff } from './todayWorkItems'
+import { TodayWorkItem } from './todayWorkItems'
interface TodaySessionRowProps {
item: TodayWorkItem
@@ -43,9 +43,11 @@ export function TodaySessionRow({
const { location, searchParams } = useValues(router)
const { user } = useValues(userLogic)
const { pullRequestStates, spaceNames } = useValues(todaySpacesLogic)
+ const menuId = useId()
+ const userId = user?.id
const preview = useMemo(
- () => sessionPreview(item, { unread, pinned, pullRequestStates, spaceNames }),
- [item, unread, pinned, pullRequestStates, spaceNames]
+ () => sessionPreview(item, { unread, pinned, pullRequestStates, spaceNames, menuId, userId }),
+ [item, unread, pinned, pullRequestStates, spaceNames, menuId, userId]
)
const [pullRequest] = item.pullRequests
@@ -76,19 +78,13 @@ export function TodaySessionRow({
ticker
selected={selected}
onClickCapture={onSelectClick}
- action={
- <TodaySessionMenu
- sessionId={item.id}
- title={item.title}
- pinned={pinned}
- spaceId={item.channel}
- surface={surface}
- canHandOff={canHandOff(item, user?.id)}
- analysisRunId={analysisRunId(item)}
- activeRunId={activeCloudRunId(item)}
- />
- }
/>
)
- return <TodayPreviewTrigger payload={preview}>{row}</TodayPreviewTrigger>
+ // Like Desktop, the row's actions live in its hover card, which opens the dialogs on the row's behalf.
+ return (
+ <>
+ <TodayPreviewTrigger payload={preview}>{row}</TodayPreviewTrigger>
+ <TodaySessionDialogs target={preview.menu} />
+ </>
+ )
}
diff --git a/frontend/src/layout/today/TodaySpaceActions.tsx b/frontend/src/layout/today/TodaySpaceActions.tsx
index 7e69c58bbdc3..ab14a5e760c6 100644
--- a/frontend/src/layout/today/TodaySpaceActions.tsx
+++ b/frontend/src/layout/today/TodaySpaceActions.tsx
@@ -1,78 +1,51 @@
-import { useActions, useValues } from 'kea'
+import { useActions } from 'kea'
-import { IconEllipsis, IconGear, IconCopy, IconStar, IconStarFilled } from '@posthog/icons'
-import {
- Button,
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuSeparator,
- DropdownMenuTrigger,
- Tooltip,
- TooltipContent,
- TooltipTrigger,
-} from '@posthog/quill'
+import { IconCopy, IconGear, IconPlus, IconStar, IconStarFilled } from '@posthog/icons'
-import { LinkPrimitive } from 'lib/lemon-ui/Link'
import { urls } from 'scenes/urls'
import { ChannelDTOApi } from 'products/tasks/frontend/generated/api.schemas'
-import { useTodayPreviewMenuReport } from './todayPreviewCardContext'
-import { todaySpacesLogic } from './todaySpacesLogic'
+import { TodayMenuParts } from './todayMenuParts'
+import { spaceNewSessionUrl, todaySpacesLogic } from './todaySpacesLogic'
-export function TodaySpaceActions({ space }: { space: ChannelDTOApi }): JSX.Element {
- const { pendingSpaceIds } = useValues(todaySpacesLogic)
+interface TodaySpaceActionsProps {
+ parts: TodayMenuParts
+ space: ChannelDTOApi
+ /** Starts each item's `data-attr`, so every surface counts on its own. */
+ dataAttrPrefix: string
+}
+
+/** A space's actions, New session first, like the space rows in PostHog Desktop. */
+export function TodaySpaceActions({
+ parts: { Item, Separator },
+ space,
+ dataAttrPrefix,
+}: TodaySpaceActionsProps): JSX.Element {
const { toggleStar, copySpaceLink } = useActions(todaySpacesLogic)
- const reportMenuOpen = useTodayPreviewMenuReport()
- const saving = pendingSpaceIds.includes(space.id)
- const menuLabel = saving ? 'Saving your last change' : 'More actions'
+ const attr = (name: string): string => `${dataAttrPrefix}-${name}`
return (
- <DropdownMenu onOpenChange={reportMenuOpen}>
- <Tooltip>
- <TooltipTrigger
- delay={0}
- render={
- <DropdownMenuTrigger
- render={
- <Button
- size="icon-xs"
- aria-label={menuLabel}
- loading={saving}
- data-attr="today-space-row-menu"
- />
- }
- />
- }
- >
- <IconEllipsis />
- </TooltipTrigger>
- <TooltipContent>{menuLabel}</TooltipContent>
- </Tooltip>
- <DropdownMenuContent align="end" className="w-48">
- {space.system_role !== 'personal' && (
- <DropdownMenuItem
- onClick={() => toggleStar(space.id, !space.starred)}
- data-attr="today-space-row-star"
- >
- {space.starred ? <IconStarFilled /> : <IconStar />}
- {space.starred ? 'Unstar space' : 'Star space'}
- </DropdownMenuItem>
- )}
- <DropdownMenuItem onClick={() => copySpaceLink(space.id)} data-attr="today-space-row-copy-link">
- <IconCopy />
- Copy link
- </DropdownMenuItem>
- <DropdownMenuSeparator />
- <DropdownMenuItem
- render={<Button size="row" left render={<LinkPrimitive to={urls.taskSpaceSettings(space.id)} />} />}
- data-attr="today-space-row-settings"
- >
- <IconGear />
- Space settings
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
+ <>
+ <Item to={spaceNewSessionUrl(space.id)} dataAttr={attr('new-session')}>
+ <IconPlus />
+ New session
+ </Item>
+ {space.system_role !== 'personal' && (
+ <Item onClick={() => toggleStar(space.id, !space.starred)} dataAttr={attr('star')}>
+ {space.starred ? <IconStarFilled /> : <IconStar />}
+ {space.starred ? 'Unstar space' : 'Star space'}
+ </Item>
+ )}
+ <Item onClick={() => copySpaceLink(space.id)} dataAttr={attr('copy-link')}>
+ <IconCopy />
+ Copy link
+ </Item>
+ <Separator />
+ <Item to={urls.taskSpaceSettings(space.id)} dataAttr={attr('settings')}>
+ <IconGear />
+ Space settings
+ </Item>
+ </>
)
}
diff --git a/frontend/src/layout/today/TodaySpaceHoverCard.tsx b/frontend/src/layout/today/TodaySpaceHoverCard.tsx
index 9aa04a406203..3dae34733d14 100644
--- a/frontend/src/layout/today/TodaySpaceHoverCard.tsx
+++ b/frontend/src/layout/today/TodaySpaceHoverCard.tsx
@@ -1,3 +1,5 @@
+import { useMemo } from 'react'
+
import { IconGitRepository } from '@posthog/icons'
import { Item, ItemActions, ItemContent, ItemDescription, ItemSeparator, ItemTitle, Text } from '@posthog/quill'
@@ -5,7 +7,9 @@ import { dayjs } from 'lib/dayjs'
import { SpacePresenceAvatars } from 'products/tasks/frontend/spaces/SpacePresenceAvatars'
+import { cardMenuParts } from './todayMenuParts'
import { TodaySpaceKind, TodaySpacePreview } from './todayPreviewCards'
+import { TodaySpaceActions } from './TodaySpaceActions'
import { TodaySpaceGlyph } from './TodaySpaceGlyph'
const KIND_LABELS: Record<TodaySpaceKind, string> = {
@@ -14,8 +18,22 @@ const KIND_LABELS: Record<TodaySpaceKind, string> = {
personal: 'Personal space',
}
-/** A space row's hover card: what kind of space it is, who works in it, and which repositories it uses. */
-export function TodaySpaceHoverCard({ preview }: { preview: TodaySpacePreview }): JSX.Element {
+// A space's actions open no submenu, so nothing has to hold the card open.
+const NO_SUBMENU = (): void => {}
+
+/**
+ * A space row's hover card: what kind of space it is, who works in it, which repositories it uses, and its actions.
+ * Like PostHog Desktop, the row itself carries no buttons, so New session leads the list here.
+ */
+export function TodaySpaceHoverCard({
+ preview,
+ onAction,
+}: {
+ preview: TodaySpacePreview
+ /** Closes the card once an action is chosen. */
+ onAction: () => void
+}): JSX.Element {
+ const parts = useMemo(() => cardMenuParts(onAction, NO_SUBMENU), [onAction])
return (
<div className="flex flex-col" data-attr="today-space-hover-card">
{/* `flex-nowrap` keeps the faces beside a long name. */}
@@ -67,6 +85,10 @@ export function TodaySpaceHoverCard({ preview }: { preview: TodaySpacePreview })
</Item>
</>
)}
+ <ItemSeparator className="my-0" />
+ <div className="flex flex-col p-1">
+ <TodaySpaceActions parts={parts} space={preview.space} dataAttrPrefix="today-space-card" />
+ </div>
</div>
)
}
diff --git a/frontend/src/layout/today/TodaySpacesRow.tsx b/frontend/src/layout/today/TodaySpacesRow.tsx
index a486465e6c02..356211b62123 100644
--- a/frontend/src/layout/today/TodaySpacesRow.tsx
+++ b/frontend/src/layout/today/TodaySpacesRow.tsx
@@ -6,16 +6,8 @@ import { LinkPrimitive } from 'lib/lemon-ui/Link'
import { TodayOverflowText } from './TodayOverflowText'
-// The label's right padding for the icon-sized slots that sit over the end of the row, at rest and on hover.
-const TRAILING_PADDING = ['', 'pr-8', 'pr-12', 'pr-16', 'pr-20', 'pr-24'] as const
-const HOVER_TRAILING_PADDING = [
- '',
- 'group-hover/row:pr-8 group-focus-within/row:pr-8 group-has-[[data-popup-open]]/row:pr-8',
- 'group-hover/row:pr-12 group-focus-within/row:pr-12 group-has-[[data-popup-open]]/row:pr-12',
- 'group-hover/row:pr-16 group-focus-within/row:pr-16 group-has-[[data-popup-open]]/row:pr-16',
- 'group-hover/row:pr-20 group-focus-within/row:pr-20 group-has-[[data-popup-open]]/row:pr-20',
- 'group-hover/row:pr-24 group-focus-within/row:pr-24 group-has-[[data-popup-open]]/row:pr-24',
-] as const
+// The label's right padding for the icon-sized slots that sit over the end of the row.
+const TRAILING_PADDING = ['', 'pr-8', 'pr-12', 'pr-16', 'pr-20'] as const
interface TodaySpacesRowProps {
label: string
@@ -23,8 +15,7 @@ interface TodaySpacesRowProps {
to: string
active: boolean
dataAttr: string
- action?: JSX.Element | null
- /** Stays visible at the end of the row, after the hover action. */
+ /** Stays visible at the end of the row. Like Desktop, the row has no hover buttons to make room for. */
badge?: JSX.Element | null
/** How many icon-sized slots `badge` takes, so the label truncates before them. */
badgeCount?: 1 | 2 | 3
@@ -45,7 +36,6 @@ export function TodaySpacesRow({
to,
active,
dataAttr,
- action,
badge,
badgeCount = 1,
unread = false,
@@ -57,7 +47,6 @@ export function TodaySpacesRow({
const [hovered, setHovered] = useState(false)
const [keyboardFocused, setKeyboardFocused] = useState(false)
const badgeSlots = badge ? badgeCount : 0
- const actionSlots = action ? 1 : 0
const showUnreadDot = unread && unreadDot && !active
// Like PostHog Desktop, a row with badges shows its unread dot after them.
const trailingDot = showUnreadDot && !!badge
@@ -86,8 +75,7 @@ export function TodaySpacesRow({
'min-w-0 text-xs font-medium text-foreground',
// Like Desktop, the open row takes a stronger tint than the other selected rows.
selected ? (active ? 'bg-primary/20' : 'bg-primary/10') : active && 'bg-fill-selected',
- TRAILING_PADDING[restSlots],
- HOVER_TRAILING_PADDING[restSlots + actionSlots]
+ TRAILING_PADDING[restSlots]
)}
>
<span className="flex size-3.5 shrink-0 items-center justify-center">{icon}</span>
@@ -114,9 +102,8 @@ export function TodaySpacesRow({
)
)}
</Button>
- {(action || badge) && (
- // Like PostHog Desktop, the badges sit at the end of the row and move left for the hover action.
- // The action stays while its menu is open, so the menu keeps its anchor after the pointer leaves.
+ {badge && (
+ // Like PostHog Desktop, the badges sit at the end of the row.
<div className="absolute right-1 flex min-w-0 items-center gap-0.5">
{/* Desktop's spacing between the faces and the unread dot. */}
<span className="flex shrink-0 items-center gap-1.5">
@@ -129,11 +116,6 @@ export function TodaySpacesRow({
/>
)}
</span>
- {action && (
- <div className="hidden group-focus-within/row:flex group-hover/row:flex group-has-[[data-popup-open]]/row:flex">
- {action}
- </div>
- )}
</div>
)}
</div>
diff --git a/frontend/src/layout/today/TodaySpacesSidebar.tsx b/frontend/src/layout/today/TodaySpacesSidebar.tsx
index 33b7395f71c6..1b8266a01049 100644
--- a/frontend/src/layout/today/TodaySpacesSidebar.tsx
+++ b/frontend/src/layout/today/TodaySpacesSidebar.tsx
@@ -19,7 +19,6 @@ import { TodaySessionBulkBar } from './TodaySessionBulkBar'
import { TodaySessionRow } from './TodaySessionRow'
import { selectionClick } from './todaySessionSelection'
import { todaySessionSelectionLogic } from './todaySessionSelectionLogic'
-import { TodaySpaceActions } from './TodaySpaceActions'
import { TodaySpaceGlyph } from './TodaySpaceGlyph'
import { TodayWorkSectionId, isLockedSpace, spaceLabel, todaySpacesLogic } from './todaySpacesLogic'
import { TodaySpacesRow } from './TodaySpacesRow'
@@ -311,7 +310,6 @@ export function TodaySpacesSidebar(): JSX.Element {
to={urls.taskSpace(space.id)}
active={location.pathname.includes(urls.taskSpace(space.id))}
dataAttr="today-space-row"
- action={<TodaySpaceActions space={space} />}
badge={presence ? <SpacePresenceAvatars presence={presence} /> : null}
badgeCount={Math.min(presence?.people.length ?? 1, 3) as 1 | 2 | 3}
unread={unreadSpaceIds.has(space.id)}
diff --git a/frontend/src/layout/today/todayMenuParts.tsx b/frontend/src/layout/today/todayMenuParts.tsx
new file mode 100644
index 000000000000..4eedaedb7480
--- /dev/null
+++ b/frontend/src/layout/today/todayMenuParts.tsx
@@ -0,0 +1,80 @@
+import { ReactNode } from 'react'
+
+import { IconChevronRight } from '@posthog/icons'
+import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from '@posthog/quill'
+
+import { LinkPrimitive } from 'lib/lemon-ui/Link'
+
+export interface TodayMenuItemProps {
+ children: ReactNode
+ dataAttr: string
+ onClick?: () => void
+ /** Navigates instead of acting. */
+ to?: string
+}
+
+export interface TodayMenuSubProps {
+ label: ReactNode
+ dataAttr: string
+ children: ReactNode
+}
+
+/**
+ * What a row's action list draws with. Each kind of row writes its actions once against these parts,
+ * like PostHog Desktop, so its hover card and its menus can't drift apart.
+ */
+export interface TodayMenuParts {
+ Item: (props: TodayMenuItemProps) => JSX.Element
+ Separator: () => JSX.Element | null
+ Sub: (props: TodayMenuSubProps) => JSX.Element
+}
+
+const SUB_CONTENT_CLASS = 'max-h-80 w-64'
+
+/**
+ * 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 opens
+ * outside the card, so the card stays open while the pointer is in it. Desktop drops the separators here.
+ */
+export function cardMenuParts(onAction: () => void, onSubmenuOpenChange: (open: boolean) => void): TodayMenuParts {
+ return {
+ Item: ({ children, dataAttr, onClick, to }) => (
+ <Button
+ left
+ className="w-full"
+ onClick={() => {
+ onClick?.()
+ onAction()
+ }}
+ {...(to ? { render: <LinkPrimitive to={to} /> } : {})}
+ data-attr={dataAttr}
+ >
+ {children}
+ </Button>
+ ),
+ Separator: () => null,
+ Sub: ({ label, dataAttr, children }) => (
+ <DropdownMenu
+ onOpenChange={(open, details) => {
+ onSubmenuOpenChange(open)
+ if (!open && details.reason === 'item-press') {
+ onAction()
+ }
+ }}
+ >
+ <DropdownMenuTrigger
+ openOnHover
+ delay={150}
+ closeDelay={100}
+ render={<Button left className="w-full" data-attr={dataAttr} />}
+ >
+ <span className="flex flex-1 items-center gap-2">{label}</span>
+ <IconChevronRight />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent side="right" align="start" className={SUB_CONTENT_CLASS}>
+ {children}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ ),
+ }
+}
diff --git a/frontend/src/layout/today/todayPreviewCards.test.ts b/frontend/src/layout/today/todayPreviewCards.test.ts
index b03332d27992..a9b310a8bae5 100644
--- a/frontend/src/layout/today/todayPreviewCards.test.ts
+++ b/frontend/src/layout/today/todayPreviewCards.test.ts
@@ -67,6 +67,8 @@ describe('todayPreviewCards', () => {
pinned: false,
pullRequestStates: { 'https://github.com/example-org/web/pull/7': 'merged' },
spaceNames,
+ menuId: 'menu-1',
+ userId: null,
})
expect([preview.spaceName, preview.pullRequestState]).toEqual([expected, 'merged'])
})
diff --git a/frontend/src/layout/today/todayPreviewCards.ts b/frontend/src/layout/today/todayPreviewCards.ts
index ecf60eb309cb..bf21aa4ed6d3 100644
--- a/frontend/src/layout/today/todayPreviewCards.ts
+++ b/frontend/src/layout/today/todayPreviewCards.ts
@@ -3,7 +3,7 @@ import { SpacePresence } from 'products/tasks/frontend/spaces/spacePresence'
import { TaskPullRequest } from 'products/tasks/frontend/spaces/taskPullRequests'
import { TodaySessionDot, todaySessionDot } from './todaySessionDot'
-import { TodayWorkItem } from './todayWorkItems'
+import { TodaySessionMenuTarget, TodayWorkItem, sessionMenuTarget } from './todayWorkItems'
/** Repositories past this are counted rather than named, so the card stays a glance. */
const SPACE_PREVIEW_REPOSITORY_LIMIT = 3
@@ -23,11 +23,14 @@ export interface TodaySessionPreview {
author: TaskUserBasicInfoApi | null
timestamp: string | null
message: string | null
+ menu: TodaySessionMenuTarget
}
/** What a space row's hover card says. */
export interface TodaySpacePreview {
kind: 'space'
+ /** What the card's actions act on. */
+ space: ChannelDTOApi
name: string
spaceKind: TodaySpaceKind
/** The creator first, then whoever worked in the space most recently. */
@@ -55,11 +58,15 @@ export function sessionPreview(
pinned,
pullRequestStates,
spaceNames,
+ menuId,
+ userId,
}: {
unread: boolean
pinned: boolean
pullRequestStates: Record<string, PrStateEnumApi>
spaceNames: Record<string, string>
+ menuId: string
+ userId: number | null | undefined
}
): TodaySessionPreview {
// The row shows only the first pull request, so the card names the same one.
@@ -76,6 +83,7 @@ export function sessionPreview(
author: item.author,
timestamp: item.timestamp,
message: item.finalMessage,
+ menu: sessionMenuTarget(item, { menuId, pinned, userId }),
}
}
@@ -104,6 +112,7 @@ export function spacePreview(
): TodaySpacePreview {
return {
kind: 'space',
+ space,
name,
spaceKind: spaceKind(space),
people: spacePeople(space.created_by, presence),
diff --git a/frontend/src/layout/today/todaySessionMenuLogic.test.ts b/frontend/src/layout/today/todaySessionMenuLogic.test.ts
index 8cb88601881c..53500aac6a95 100644
--- a/frontend/src/layout/today/todaySessionMenuLogic.test.ts
+++ b/frontend/src/layout/today/todaySessionMenuLogic.test.ts
@@ -68,6 +68,7 @@ describe('todaySessionMenuLogic', () => {
expect(logic.values.handoffMenuId).toEqual('menu-1')
expect(logic.values.handoffUser).toEqual(colleague)
+ expect(logic.values.sessionDialogOpen).toBe(true)
})
it('stops the run it is given and refreshes the lists', async () => {
@@ -87,6 +88,7 @@ describe('todaySessionMenuLogic', () => {
await expectLogic(logic).toFinishAllListeners()
expect(logic.values.archiveConfirmMenuId).toEqual(dialog)
+ expect(logic.values.sessionDialogOpen).toEqual(dialog !== null)
expect(requests).toEqual(expected)
})
diff --git a/frontend/src/layout/today/todaySessionMenuLogic.ts b/frontend/src/layout/today/todaySessionMenuLogic.ts
index f503c80042a7..d7e1a842f9d9 100644
--- a/frontend/src/layout/today/todaySessionMenuLogic.ts
+++ b/frontend/src/layout/today/todaySessionMenuLogic.ts
@@ -1,4 +1,4 @@
-import { MakeLogicType, actions, connect, kea, listeners, path, reducers } from 'kea'
+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
import { router } from 'kea-router'
import { toast } from '@posthog/quill'
@@ -43,6 +43,7 @@ export interface todaySessionMenuLogicValues {
sessionId: string
surface: TodaySessionSurface
} | null
+ sessionDialogOpen: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -150,7 +151,19 @@ export interface todaySessionMenuLogicActions {
}
}
-export type todaySessionMenuLogicType = MakeLogicType<todaySessionMenuLogicValues, todaySessionMenuLogicActions>
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface todaySessionMenuLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ sessionDialogOpen: (handoffMenuId: string | null, archiveConfirmMenuId: string | null) => boolean
+ }
+}
+
+export type todaySessionMenuLogicType = MakeLogicType<
+ todaySessionMenuLogicValues,
+ todaySessionMenuLogicActions,
+ Record<string, any>,
+ todaySessionMenuLogicMeta
+>
export const todaySessionMenuLogic = kea<todaySessionMenuLogicType>([
path(['layout', 'today', 'todaySessionMenuLogic']),
@@ -230,6 +243,14 @@ export const todaySessionMenuLogic = kea<todaySessionMenuLogicType>([
},
],
}),
+ selectors({
+ // The hover card stays shut while one of these is up, so it can't open over the dialog.
+ sessionDialogOpen: [
+ (s) => [s.handoffMenuId, s.archiveConfirmMenuId],
+ (handoffMenuId: string | null, archiveConfirmMenuId: string | null): boolean =>
+ handoffMenuId !== null || archiveConfirmMenuId !== null,
+ ],
+ }),
listeners(({ actions, values }) => {
const update = async (sessionId: string, patch: PatchedTaskWriteApi, failure: string): Promise<boolean> => {
try {
diff --git a/frontend/src/layout/today/todayWorkItems.ts b/frontend/src/layout/today/todayWorkItems.ts
index 55b777e82986..3d265f03cadb 100644
--- a/frontend/src/layout/today/todayWorkItems.ts
+++ b/frontend/src/layout/today/todayWorkItems.ts
@@ -63,6 +63,36 @@ export function activeCloudRunId(item: TodayWorkItem): string | null {
: null
}
+/** What a session's menus and its hover card act on. */
+export interface TodaySessionMenuTarget {
+ /** The row or card that owns the follow-up dialogs, so they outlive the menu that opened them. */
+ menuId: string
+ sessionId: string
+ title: string
+ pinned: boolean
+ spaceId: string | null
+ canHandOff: boolean
+ analysisRunId: string | null
+ /** The latest run while it is an active cloud run: it can be stopped, and archiving asks first. */
+ activeRunId: string | null
+}
+
+export function sessionMenuTarget(
+ item: TodayWorkItem,
+ { menuId, pinned, userId }: { menuId: string; pinned: boolean; userId: number | null | undefined }
+): TodaySessionMenuTarget {
+ return {
+ menuId,
+ sessionId: item.id,
+ title: item.title,
+ pinned,
+ spaceId: item.channel,
+ canHandOff: canHandOff(item, userId),
+ analysisRunId: analysisRunId(item),
+ activeRunId: activeCloudRunId(item),
+ }
+}
+
function finalMessage(output: TaskRunDetailDTOApi['output'] | undefined): string | null {
const message = output?.final_message
return typeof message === 'string' && message.trim() ? message.trim() : null
diff --git a/frontend/src/scenes/project-homepage/today/Today.stories.tsx b/frontend/src/scenes/project-homepage/today/Today.stories.tsx
index 0e5ecbf902ff..ebc9994fa3f6 100644
--- a/frontend/src/scenes/project-homepage/today/Today.stories.tsx
+++ b/frontend/src/scenes/project-homepage/today/Today.stories.tsx
@@ -429,7 +429,8 @@ export const SpacesPane: Story = {
},
}
-// Hovering a space row shows only its "…" menu, so the faces and the unread dot keep their place.
+// A hovered space row shows no buttons, so the faces and the unread dot keep their place.
+// Its actions, New session first, are in the hover card that opens beside it.
export const SpacesPaneHoveringSpaceRow: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement)
@@ -438,6 +439,8 @@ export const SpacesPaneHoveringSpaceRow: Story = {
const row = labels.find((label) => label.closest('[data-attr="today-space-row"]'))
if (row) {
await userEvent.hover(row)
+ // The card opens in a portal outside the story's canvas.
+ await within(document.body).findByText('New session')
}
},
}
@@ -528,6 +531,8 @@ export const NarrowWindowWithSidebar: Story = {
}
// The card opens on hover, which a static story can't hold, so these render its contents in the same frame.
+const noop = (): void => {}
+
function HoverCardFrame({ children }: { children: ReactNode }): JSX.Element {
return (
<div className="p-4">
@@ -559,8 +564,13 @@ export const SessionHoverCard: Story = {
pinned: true,
pullRequestStates: { 'https://github.com/example-org/webapp/pull/421': 'merged' },
spaceNames: { 'space-checkout': 'checkout' },
+ menuId: 'story-card',
+ // The author, who can hand the session off, so the card lists every action a finished session has.
+ userId: 179,
}
)}
+ onAction={noop}
+ onSubmenuOpenChange={noop}
/>
</HoverCardFrame>
),
@@ -579,6 +589,7 @@ export const SpaceHoverCard: Story = {
{ people: [GRACE, ADA], liveUuids: [GRACE.uuid] },
'2026-09-28T18:28:00Z'
)}
+ onAction={noop}
/>
</HoverCardFrame>
),