: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): add desktop's list view to the space feed (#109596)
Shy Alterc0674025b3a3
diff --git a/frontend/src/scenes/project-homepage/today/Today.stories.tsx b/frontend/src/scenes/project-homepage/today/Today.stories.tsxindex 441292b39308..f503fda4e769 100644--- a/frontend/src/scenes/project-homepage/today/Today.stories.tsx+++ b/frontend/src/scenes/project-homepage/today/Today.stories.tsx@@ -422,6 +422,11 @@ export const SpacesPaneWithRecentFilterMenu: Story = {},}+export const SpacePageListView: Story = {+ decorators: [withSpaceFeedView({ view: 'list' })],+ parameters: { pageUrl: urls.taskSpace('space-checkout') },+}+export const SpacePagePullRequests: Story = {decorators: [withSpaceFeedView({ types: ['pr'] })],parameters: { pageUrl: urls.taskSpace('space-checkout') },diff --git a/products/tasks/frontend/spaces/SpaceFeed.tsx b/products/tasks/frontend/spaces/SpaceFeed.tsxindex a36130011983..2270c0f8c252 100644--- a/products/tasks/frontend/spaces/SpaceFeed.tsx+++ b/products/tasks/frontend/spaces/SpaceFeed.tsx@@ -18,6 +18,7 @@ import { todaySpacesLogic } from '~/layout/today/todaySpacesLogic'import { SpaceFeedCard } from './SpaceFeedCard'import { SpaceFeedControls } from './SpaceFeedControls'+import { SpaceFeedListRow } from './SpaceFeedListRow'import { SpaceFeedPullRequestRow } from './SpaceFeedPullRequestRow'import { spaceFeedViewLogic } from './spaceFeedViewLogic'import { spaceSceneLogic } from './spaceSceneLogic'@@ -33,10 +34,11 @@ export function SpaceFeed({ id }: { id: string }): JSX.Element {sessionsUnavailable,} = useValues(spaceSceneLogic({ id }))const { loadSessions } = useActions(spaceSceneLogic({ id }))- const { filtersActive } = useValues(spaceFeedViewLogic)+ const { view, filtersActive } = useValues(spaceFeedViewLogic)const { clearFilters } = useActions(spaceFeedViewLogic)const { pinnedItems, unreadSessionIds } = useValues(todaySpacesLogic)const pinnedIds = new Set(pinnedItems.map((item) => item.id))+ const listRows = view === 'list'if (sessionsLoading && !feedItems.length) {return (@@ -104,33 +106,64 @@ export function SpaceFeed({ id }: { id: string }): JSX.Element {)}{feedSections.map((section) => (<Fragment key={section.key}>- {section.label !== null && (- <div className="flex items-center gap-3 pt-5 pb-2">- <Separator className="flex-1" />+ {section.label !== null &&+ (listRows ? (<Text- render={<span />}size="xxs"- weight="semibold"+ weight="medium"variant="muted"- className="shrink-0 tracking-wider uppercase"+ className="px-2 pt-3 pb-1 tracking-wider uppercase">{section.label}</Text>- <Separator className="flex-1" />- </div>- )}+ ) : (+ <div className="flex items-center gap-3 pt-5 pb-2">+ <Separator className="flex-1" />+ <Text+ render={<span />}+ size="xxs"+ weight="semibold"+ variant="muted"+ className="shrink-0 tracking-wider uppercase"+ >+ {section.label}+ </Text>+ <Separator className="flex-1" />+ </div>+ ))}{section.entries.map((entry) => {const task = sessionsById[entry.item.id]if (!task) {return null}- return entry.kind === 'pr' ? (- <SpaceFeedPullRequestRow- key={entry.key}- pullRequest={entry.pullRequest}- session={entry.item}- author={task.created_by ?? null}- />+ // List rows are ruled apart, like PostHog Desktop's.+ const rowClassName = 'border-b border-border last:border-b-0'+ if (entry.kind === 'pr') {+ const row = (+ <SpaceFeedPullRequestRow+ key={entry.key}+ pullRequest={entry.pullRequest}+ session={entry.item}+ author={task.created_by ?? null}+ listRow={listRows}+ />+ )+ return listRows ? (+ <div key={entry.key} className={rowClassName}>+ {row}+ </div>+ ) : (+ row+ )+ }+ return listRows ? (+ <div key={entry.key} className={rowClassName}>+ <SpaceFeedListRow+ task={task}+ pinned={pinnedIds.has(task.id)}+ unread={unreadSessionIds.has(task.id)}+ />+ </div>) : (<SpaceFeedCardkey={entry.key}diff --git a/products/tasks/frontend/spaces/SpaceFeedControls.tsx b/products/tasks/frontend/spaces/SpaceFeedControls.tsxindex ac44c0d5030a..33e55b3d6dce 100644--- a/products/tasks/frontend/spaces/SpaceFeedControls.tsx+++ b/products/tasks/frontend/spaces/SpaceFeedControls.tsx@@ -1,15 +1,21 @@import { useActions, useValues } from 'kea'-import { ToggleGroup, ToggleGroupItem } from '@posthog/quill'+import { IconList, IconStack } from '@posthog/icons'+import { ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'-import { SPACE_FEED_TYPES, SpaceFeedType } from './spaceFeedEntries'+import { SPACE_FEED_TYPES, SpaceFeedType, SpaceFeedView } from './spaceFeedEntries'import { SpaceFeedFilterMenu } from './SpaceFeedFilterMenu'import { spaceFeedViewLogic } from './spaceFeedViewLogic'-/** The row above the feed: which types show and the filter menu, like PostHog Desktop's. */+const VIEWS: { value: SpaceFeedView; label: string; icon: JSX.Element }[] = [+ { value: 'list', label: 'List', icon: <IconList /> },+ { value: 'cards', label: 'Cards', icon: <IconStack /> },+]++/** The row above the feed: which types show, list or cards, and the filter menu, like PostHog Desktop's. */export function SpaceFeedControls({ sourceOptions }: { sourceOptions: string[] }): JSX.Element {- const { types } = useValues(spaceFeedViewLogic)- const { setTypes } = useActions(spaceFeedViewLogic)+ const { types, view } = useValues(spaceFeedViewLogic)+ const { setTypes, setView } = useActions(spaceFeedViewLogic)return (<div className="mb-1 flex w-full flex-wrap items-center justify-end gap-1">@@ -25,6 +31,34 @@ export function SpaceFeedControls({ sourceOptions }: { sourceOptions: string[] }</ToggleGroupItem>))}</ToggleGroup>+ <ToggleGroup+ value={[view]}+ onValueChange={(next) => {+ const [picked] = next+ if (picked === 'list' || picked === 'cards') {+ setView(picked)+ }+ }}+ spacing={1}+ aria-label="View"+ >+ {VIEWS.map(({ value, label, icon }) => (+ <Tooltip key={value}>+ {/* A span carries the tooltip, because the toggle item does not forward its ref, so the toggles are spaced. */}+ <TooltipTrigger delay={0} render={<span className="flex" />}>+ <ToggleGroupItem+ value={value}+ size="sm"+ aria-label={`${label} view`}+ data-attr={`today-space-feed-view-${value}`}+ >+ {icon}+ </ToggleGroupItem>+ </TooltipTrigger>+ <TooltipContent>{label}</TooltipContent>+ </Tooltip>+ ))}+ </ToggleGroup><SpaceFeedFilterMenu sourceOptions={sourceOptions} /></div>)diff --git a/products/tasks/frontend/spaces/SpaceFeedListRow.tsx b/products/tasks/frontend/spaces/SpaceFeedListRow.tsxnew file mode 100644index 000000000000..b5f1db074907--- /dev/null+++ b/products/tasks/frontend/spaces/SpaceFeedListRow.tsx@@ -0,0 +1,101 @@+import { useValues } from 'kea'++import { Badge, Spinner, Text } from '@posthog/quill'++import { LinkPrimitive } from 'lib/lemon-ui/Link'+import { urls } from 'scenes/urls'+import { userLogic } from 'scenes/userLogic'++import { TodaySessionMenu } from '~/layout/today/TodaySessionMenu'+import { todaySessionMenuLogic } from '~/layout/today/todaySessionMenuLogic'+import { TodaySessionRenameInput } from '~/layout/today/TodaySessionRenameInput'+import { todaySpacesLogic } from '~/layout/today/todaySpacesLogic'+import { activeCloudRunId, analysisRunId, canHandOff, sessionItem, shortTimeAgo } from '~/layout/today/todayWorkItems'++import { TaskListItemApi } from '../generated/api.schemas'+import { spaceFeedStatus } from './spaceFeedStatus'+import { SpaceFeedStatusIcon } from './SpaceFeedStatusIcon'+import { TaskUserAvatar, taskUserName } from './TaskUserAvatar'++interface SpaceFeedListRowProps {+ task: TaskListItemApi+ pinned: boolean+ unread: boolean+}++/** A session as one compact row of the feed's list view, like PostHog Desktop's. */+export function SpaceFeedListRow({ task, pinned, unread }: SpaceFeedListRowProps): JSX.Element {+ const { renaming } = useValues(todaySessionMenuLogic)+ const { user } = useValues(userLogic)+ const { pullRequestStates } = useValues(todaySpacesLogic)+ const item = sessionItem(task)+ const [mainPullRequest] = item.pullRequests+ const status = spaceFeedStatus(task.latest_run, mainPullRequest && pullRequestStates[mainPullRequest.url])+ const author = task.created_by++ if (renaming?.sessionId === task.id && renaming.surface === 'feed') {+ return (+ <div className="flex h-8 items-center gap-2 px-2">+ <SpaceFeedStatusIcon item={item} />+ <div className="min-w-0 flex-1">+ <TodaySessionRenameInput sessionId={task.id} title={task.title} />+ </div>+ </div>+ )+ }+ return (+ <div className="group/row relative flex h-8 w-full items-center gap-2 rounded-md px-2 transition-colors hover:bg-fill-selected">+ <SpaceFeedStatusIcon item={item} />+ <LinkPrimitive+ to={urls.aiTask(task.id)}+ className="min-w-0 flex-1 truncate text-sm font-medium text-foreground after:absolute after:inset-0"+ data-attr="today-space-feed-row"+ >+ {item.title || 'Untitled session'}+ </LinkPrimitive>+ {unread && (+ <span+ role="img"+ aria-label="Unread"+ className="size-1.5 shrink-0 rounded-full bg-primary"+ data-attr="today-unread-feed-dot"+ />+ )}+ {status && (+ <Badge variant={status.variant} className="shrink-0">+ {status.running && <Spinner aria-hidden data-icon="inline-start" />}+ {status.label}+ </Badge>+ )}+ {author && (+ <span role="img" aria-label={taskUserName(author)} className="relative flex shrink-0">+ <TaskUserAvatar user={author} />+ </span>+ )}+ {/* The age gives way to the menu on hover, so the row keeps its width. */}+ {item.timestamp && (+ <Text+ render={<span />}+ size="xs"+ variant="muted"+ className="w-8 shrink-0 text-right transition-opacity group-focus-within/row:opacity-0 group-hover/row:opacity-0"+ translate="no"+ >+ {shortTimeAgo(item.timestamp)}+ </Text>+ )}+ <span className="absolute right-1 opacity-0 transition-opacity group-focus-within/row:opacity-100 group-hover/row:opacity-100">+ <TodaySessionMenu+ sessionId={task.id}+ title={item.title}+ pinned={pinned}+ spaceId={item.channel}+ surface="feed"+ canHandOff={canHandOff(item, user?.id)}+ analysisRunId={analysisRunId(item)}+ activeRunId={activeCloudRunId(item)}+ />+ </span>+ </div>+ )+}diff --git a/products/tasks/frontend/spaces/SpaceFeedPullRequestRow.tsx b/products/tasks/frontend/spaces/SpaceFeedPullRequestRow.tsxindex f6187b3c6325..530b0a307e72 100644--- a/products/tasks/frontend/spaces/SpaceFeedPullRequestRow.tsx+++ b/products/tasks/frontend/spaces/SpaceFeedPullRequestRow.tsx@@ -18,39 +18,75 @@ interface SpaceFeedPullRequestRowProps {/** The session that opened the pull request. */session: TodayWorkItemauthor: TaskUserBasicInfoApi | null+ listRow: boolean}-/** A pull request card in the feed's PRs view, like PostHog Desktop's. It opens on GitHub. */-export function SpaceFeedPullRequestRow({ pullRequest, session, author }: SpaceFeedPullRequestRowProps): JSX.Element {+/** A pull request in the feed's PRs view, as a card or a list row, like PostHog Desktop's. It opens on GitHub. */+export function SpaceFeedPullRequestRow({+ pullRequest,+ session,+ author,+ listRow,+}: SpaceFeedPullRequestRowProps): JSX.Element {const { pullRequestStates } = useValues(todaySpacesLogic)const state = pullRequestStates[pullRequest.url]const known = pullRequestStateMeta(state)// GitHub reports no title to the web, so the row names the session that opened the pull request.const title = session.title || 'Untitled session'+ const icon = (+ <IconPullRequest className={cn('size-3.5 shrink-0', known ? known.iconClassName : 'text-muted-foreground')} />+ )+ const number = (+ <Text render={<span />} size="xs" variant="muted" className="shrink-0">+ {`#${pullRequest.number}`}+ </Text>+ )const age = session.timestamp ? shortTimeAgo(session.timestamp) : null+ const avatar = author && (+ <span role="img" aria-label={taskUserName(author)} className="relative flex shrink-0">+ <TaskUserAvatar user={author} />+ </span>+ )+ const link = (className: string): JSX.Element => (+ <LinkPrimitive+ to={pullRequest.url}+ target="_blank"+ aria-label={pullRequestLinkLabel(pullRequest, state)}+ className={cn('min-w-0 truncate text-foreground after:absolute after:inset-0', className)}+ data-attr="today-space-feed-pr"+ >+ {title}+ </LinkPrimitive>+ )+ if (listRow) {+ return (+ <div className="relative flex h-8 w-full items-center gap-2 rounded-md px-2 transition-colors hover:bg-fill-selected">+ {icon}+ {number}+ {link('flex-1 text-sm font-medium')}+ {avatar}+ {age && (+ <Text+ render={<span />}+ size="xs"+ variant="muted"+ className="w-8 shrink-0 text-right"+ translate="no"+ >+ {age}+ </Text>+ )}+ </div>+ )+ }return (<Card size="sm" className="relative my-1.5 gap-0 rounded-xl px-4 pt-3.5 pb-3 transition-colors hover:bg-muted"><div className="flex min-w-0 items-center gap-3"><div className="flex min-w-0 flex-1 items-baseline gap-1.5">- <IconPullRequest- className={cn(- 'size-3.5 shrink-0 translate-y-0.5',- known ? known.iconClassName : 'text-muted-foreground'- )}- />- <Text render={<span />} size="xs" variant="muted" className="shrink-0">- {`#${pullRequest.number}`}- </Text>- <LinkPrimitive- to={pullRequest.url}- target="_blank"- aria-label={pullRequestLinkLabel(pullRequest, state)}- className="min-w-0 truncate text-sm leading-snug font-semibold text-foreground after:absolute after:inset-0 hover:underline"- data-attr="today-space-feed-pr"- >- {title}- </LinkPrimitive>+ <span className="flex translate-y-0.5">{icon}</span>+ {number}+ {link('text-sm leading-snug font-semibold hover:underline')}{age && (<Text render={<span />} size="xs" variant="muted" className="shrink-0" translate="no">{`· ${age}`}@@ -62,13 +98,7 @@ export function SpaceFeedPullRequestRow({ pullRequest, session, author }: SpaceF<Text size="xs" variant="muted" className="mt-1.5 truncate">{pullRequest.repository}</Text>- {author && (- <div className="mt-3 flex justify-end">- <span role="img" aria-label={taskUserName(author)} className="relative flex shrink-0">- <TaskUserAvatar user={author} />- </span>- </div>- )}+ {avatar && <div className="mt-3 flex justify-end">{avatar}</div>}</Card>)}diff --git a/products/tasks/frontend/spaces/spaceFeedEntries.ts b/products/tasks/frontend/spaces/spaceFeedEntries.tsindex af78284877c2..bc1aab4daf84 100644--- a/products/tasks/frontend/spaces/spaceFeedEntries.ts+++ b/products/tasks/frontend/spaces/spaceFeedEntries.ts@@ -21,6 +21,8 @@ export const SPACE_FEED_TYPES: { value: SpaceFeedType; label: string }[] = [export const DEFAULT_SPACE_FEED_TYPES: SpaceFeedType[] = SPACE_FEED_TYPES.map((type) => type.value)+export type SpaceFeedView = 'list' | 'cards'+export type SpaceFeedStatusFilter = 'any' | 'unread'export type SpaceFeedPinnedFilter = 'any' | 'pinned'export type SpaceFeedEnvironmentFilter = 'any' | 'local' | 'cloud'diff --git a/products/tasks/frontend/spaces/spaceFeedViewLogic.ts b/products/tasks/frontend/spaces/spaceFeedViewLogic.tsindex 76c6f9dabee6..f4932913d675 100644--- a/products/tasks/frontend/spaces/spaceFeedViewLogic.ts+++ b/products/tasks/frontend/spaces/spaceFeedViewLogic.ts@@ -8,6 +8,7 @@ import {SpaceFeedFilters,SpaceFeedGrouping,SpaceFeedType,+ SpaceFeedView,hasActiveSpaceFeedFilters,} from './spaceFeedEntries'@@ -18,6 +19,7 @@ export interface spaceFeedViewLogicValues {grouping: SpaceFeedGroupingsort: TodayRecentSorttypes: SpaceFeedType[]+ view: SpaceFeedView}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -37,6 +39,9 @@ export interface spaceFeedViewLogicActions {setTypes: (types: SpaceFeedType[]) => {types: SpaceFeedType[]}+ setView: (view: SpaceFeedView) => {+ view: SpaceFeedView+ }}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -57,6 +62,7 @@ export type spaceFeedViewLogicType = MakeLogicType<export const spaceFeedViewLogic = kea<spaceFeedViewLogicType>([path(['products', 'tasks', 'spaces', 'spaceFeedViewLogic']),actions({+ setView: (view: SpaceFeedView) => ({ view }),setTypes: (types: SpaceFeedType[]) => ({ types }),setFilters: (filters: SpaceFeedFilters) => ({ filters }),clearFilters: true,@@ -64,6 +70,7 @@ export const spaceFeedViewLogic = kea<spaceFeedViewLogicType>([setGrouping: (grouping: SpaceFeedGrouping) => ({ grouping }),}),reducers({+ view: ['cards' as SpaceFeedView, { persist: true }, { setView: (_, { view }) => view }],types: [DEFAULT_SPACE_FEED_TYPES,{ persist: true },