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): match the desktop space feed layout (#109442)

Shy Alter73d408d6e3ca
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/EmbeddedTaskComposerImpl.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/EmbeddedTaskComposerImpl.tsx
index ed57b21c2007..96b388eb8b41 100644
--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/EmbeddedTaskComposerImpl.tsx
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/EmbeddedTaskComposerImpl.tsx
@@ -5,17 +5,21 @@ import { TaskComposer, TaskComposerProps } from './TaskComposer'
export type EmbeddedTaskComposerImplProps = Required<Pick<TaskTrackerSceneLogicProps, 'panelId'>> &
Pick<TaskTrackerSceneLogicProps, 'channelId' | 'initialRepositoryConfig' | 'composerOverride' | 'onTaskCreated'> &
- Pick<TaskComposerProps, 'focusRequest'>
+ Pick<TaskComposerProps, 'focusRequest' | 'autoFocus'>
/**
* The new-task composer alone, for a host page that lists tasks itself. It binds an embedded
* `taskTrackerSceneLogic` instance keyed by `panelId`, so it never shares a draft with the `/tasks` scene.
* It never renders the run: the host opens the created task from `onTaskCreated`.
*/
-export function EmbeddedTaskComposerImpl({ focusRequest, ...props }: EmbeddedTaskComposerImplProps): JSX.Element {
+export function EmbeddedTaskComposerImpl({
+ focusRequest,
+ autoFocus,
+ ...props
+}: EmbeddedTaskComposerImplProps): JSX.Element {
return (
<BindLogic logic={taskTrackerSceneLogic} props={props}>
- <TaskComposer variant="inline" focusRequest={focusRequest} />
+ <TaskComposer variant="inline" focusRequest={focusRequest} autoFocus={autoFocus} />
</BindLogic>
)
}
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskComposer.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskComposer.tsx
index 93aa4f2e986c..78f67e6badc9 100644
--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskComposer.tsx
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskComposer.tsx
@@ -40,9 +40,11 @@ export interface TaskComposerProps {
variant?: 'page' | 'inline'
/** A host bumps this number to move focus to the input, for example when the user asks for a new session. */
focusRequest?: number
+ /** Focus the input on mount. A host page that is not mainly a composer turns it off and uses `focusRequest`. */
+ autoFocus?: boolean
}
-export function TaskComposer({ variant = 'page', focusRequest = 0 }: TaskComposerProps): JSX.Element {
+export function TaskComposer({ variant = 'page', focusRequest = 0, autoFocus = true }: TaskComposerProps): JSX.Element {
const inline = variant === 'inline'
const { submitNewTask, setNewTaskData, setActiveSuggestionGroup, applySuggestion, clearConsentBlock } =
useActions(taskTrackerSceneLogic)
@@ -151,7 +153,11 @@ export function TaskComposer({ variant = 'page', focusRequest = 0 }: TaskCompose
<Composer.Placeholder>
{composerOverride?.placeholder ?? 'Describe the task in detail…'}
</Composer.Placeholder>
- <Composer.Textarea autoFocus onPaste={onPaste} data-attr="task-composer-input" />
+ <Composer.Textarea
+ autoFocus={autoFocus}
+ onPaste={onPaste}
+ data-attr="task-composer-input"
+ />
</Composer.Field>
<Composer.Footer className="flex flex-wrap items-center gap-1 pl-2">
<ComposerModePicker
diff --git a/products/tasks/frontend/spaces/SpaceFeed.tsx b/products/tasks/frontend/spaces/SpaceFeed.tsx
index b2623555b016..52b5ae7bd22e 100644
--- a/products/tasks/frontend/spaces/SpaceFeed.tsx
+++ b/products/tasks/frontend/spaces/SpaceFeed.tsx
@@ -9,9 +9,9 @@ import {
EmptyHeader,
EmptyMedia,
EmptyTitle,
+ Separator,
Skeleton,
Text,
- cn,
} from '@posthog/quill'
import { todaySpacesLogic } from '~/layout/today/todaySpacesLogic'
@@ -20,14 +20,16 @@ import { SpaceFeedCard } from './SpaceFeedCard'
import { spaceSceneLogic } from './spaceSceneLogic'
export function SpaceFeed({ id }: { id: string }): JSX.Element {
- const { feedGroups, sessionsById, sessionsLoading, sessionsUnavailable } = useValues(spaceSceneLogic({ id }))
+ const { feedGroups, feedRepositories, sessionsById, sessionsLoading, sessionsUnavailable } = useValues(
+ spaceSceneLogic({ id })
+ )
const { loadSessions } = useActions(spaceSceneLogic({ id }))
const { pinnedItems, unreadSessionIds } = useValues(todaySpacesLogic)
const pinnedIds = new Set(pinnedItems.map((item) => item.id))
if (sessionsLoading && !feedGroups.length) {
return (
- <div className="flex max-w-3xl flex-col gap-3 px-2 py-2">
+ <div className="flex flex-col gap-3 px-2 py-2">
<Skeleton className="h-4 w-1/4" />
<Skeleton className="h-4 w-3/4" />
<Skeleton className="h-4 w-2/3" />
@@ -69,12 +71,22 @@ export function SpaceFeed({ id }: { id: string }): JSX.Element {
)
}
return (
- <div className="flex max-w-3xl flex-col gap-2">
- {feedGroups.map((group, index) => (
+ <div className="flex flex-col gap-3">
+ {feedGroups.map((group) => (
<Fragment key={group.key}>
- <Text size="xs" variant="muted" className={cn('block px-1', index === 0 ? 'pt-1' : 'pt-4')}>
- {group.label}
- </Text>
+ <div className="flex items-center gap-3 pt-2">
+ <Separator className="flex-1" />
+ <Text
+ render={<span />}
+ size="xxs"
+ weight="semibold"
+ variant="muted"
+ className="shrink-0 tracking-wider uppercase"
+ >
+ {group.label}
+ </Text>
+ <Separator className="flex-1" />
+ </div>
{group.items.map((item) =>
sessionsById[item.id] ? (
<SpaceFeedCard
@@ -82,6 +94,7 @@ export function SpaceFeed({ id }: { id: string }): JSX.Element {
task={sessionsById[item.id]}
pinned={pinnedIds.has(item.id)}
unread={unreadSessionIds.has(item.id)}
+ repository={feedRepositories[item.id] ?? null}
/>
) : null
)}
diff --git a/products/tasks/frontend/spaces/SpaceFeedCard.tsx b/products/tasks/frontend/spaces/SpaceFeedCard.tsx
index 1e268c667ee2..498d5473b42b 100644
--- a/products/tasks/frontend/spaces/SpaceFeedCard.tsx
+++ b/products/tasks/frontend/spaces/SpaceFeedCard.tsx
@@ -10,6 +10,7 @@ import {
Popover,
PopoverContent,
PopoverTrigger,
+ Spinner,
Text,
Tooltip,
TooltipContent,
@@ -24,13 +25,13 @@ import { userLogic } from 'scenes/userLogic'
import { TodaySessionMenu } from '~/layout/today/TodaySessionMenu'
import { todaySessionMenuLogic } from '~/layout/today/todaySessionMenuLogic'
import { TodaySessionRenameInput } from '~/layout/today/TodaySessionRenameInput'
-import { TodaySessionStatusIcon } from '~/layout/today/TodaySessionStatusIcon'
import { todaySpacesLogic } from '~/layout/today/todaySpacesLogic'
import { activeCloudRunId, analysisRunId, canHandOff, sessionItem, shortTimeAgo } from '~/layout/today/todayWorkItems'
import { TaskListItemApi } from '../generated/api.schemas'
import { spaceFeedPreview } from './spaceFeedPreview'
import { spaceFeedStatus } from './spaceFeedStatus'
+import { SpaceFeedStatusIcon } from './SpaceFeedStatusIcon'
import { TaskPullRequestChip } from './TaskPullRequestChip'
import { pullRequestLabel, splitPullRequests } from './taskPullRequests'
@@ -38,9 +39,11 @@ interface SpaceFeedCardProps {
task: TaskListItemApi
pinned: boolean
unread: boolean
+ /** The repository to name on the card, or `null` when it is the space's usual one. */
+ repository: string | null
}
-export function SpaceFeedCard({ task, pinned, unread }: SpaceFeedCardProps): JSX.Element {
+export function SpaceFeedCard({ task, pinned, unread, repository }: SpaceFeedCardProps): JSX.Element {
const { renaming } = useValues(todaySessionMenuLogic)
const { user } = useValues(userLogic)
const { pullRequestStates } = useValues(todaySpacesLogic)
@@ -60,9 +63,12 @@ export function SpaceFeedCard({ task, pinned, unread }: SpaceFeedCardProps): JSX
: ''
return (
- <Card size="sm" className="group/card relative gap-2 px-3 py-3">
+ <Card
+ size="sm"
+ className="group/card relative 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-2">
- <TodaySessionStatusIcon item={item} pinned={false} />
+ <SpaceFeedStatusIcon item={item} />
{renaming?.sessionId === task.id && renaming.surface === 'feed' ? (
<div className="min-w-0 flex-1">
<TodaySessionRenameInput sessionId={task.id} title={task.title} />
@@ -72,7 +78,7 @@ export function SpaceFeedCard({ task, pinned, unread }: SpaceFeedCardProps): JSX
<LinkPrimitive
to={urls.aiTask(task.id)}
className={cn(
- 'min-w-0 truncate text-foreground after:absolute after:inset-0 hover:underline',
+ 'min-w-0 truncate text-sm text-foreground after:absolute after:inset-0 hover:underline',
unread ? 'font-semibold' : 'font-medium'
)}
data-attr="today-space-feed-card"
@@ -95,7 +101,12 @@ export function SpaceFeedCard({ task, pinned, unread }: SpaceFeedCardProps): JSX
</div>
)}
<div className="relative flex shrink-0 items-center gap-1">
- {status && <Badge variant={status.variant}>{status.label}</Badge>}
+ {status && (
+ <Badge variant={status.variant}>
+ {status.running && <Spinner aria-hidden data-icon="inline-start" />}
+ {status.label}
+ </Badge>
+ )}
<TodaySessionMenu
sessionId={task.id}
title={item.title}
@@ -109,13 +120,13 @@ export function SpaceFeedCard({ task, pinned, unread }: SpaceFeedCardProps): JSX
</div>
</div>
{preview && (
- <Text size="sm" variant="muted" className="line-clamp-2 break-words">
+ <Text size="xs" variant="muted" className="mt-1.5 line-clamp-2 break-words">
{preview}
</Text>
)}
- {(task.repository || author || item.pullRequests.length > 0) && (
- <div className="flex min-w-0 items-center gap-2 pt-1">
- {task.repository && (
+ {(repository || author || item.pullRequests.length > 0) && (
+ <div className="mt-3 flex min-w-0 items-center gap-1.5">
+ {repository && (
<Text
render={<span />}
size="xs"
@@ -123,7 +134,7 @@ export function SpaceFeedCard({ task, pinned, unread }: SpaceFeedCardProps): JSX
className="inline-flex min-w-0 items-center gap-1"
>
<IconGitBranch className="shrink-0" />
- <span className="truncate">{task.repository}</span>
+ <span className="truncate">{repository}</span>
</Text>
)}
{pullRequests.visible.map((pullRequest) => (
diff --git a/products/tasks/frontend/spaces/SpaceFeedStatusIcon.tsx b/products/tasks/frontend/spaces/SpaceFeedStatusIcon.tsx
new file mode 100644
index 000000000000..272e2e49d193
--- /dev/null
+++ b/products/tasks/frontend/spaces/SpaceFeedStatusIcon.tsx
@@ -0,0 +1,26 @@
+import { IconChat, IconCloud, IconPinFilled, IconSpinner } from '@posthog/icons'
+
+import { TodaySessionIconKind, todaySessionIcon } from '~/layout/today/todaySessionIcon'
+import { TodayWorkItem } from '~/layout/today/todayWorkItems'
+
+// A settled run fills its cloud, like PostHog Desktop's feed cards. `IconCloud` is an outline path, so
+// `*:fill-current` fills that path with the text colour.
+const ICONS: Record<TodaySessionIconKind, { label: string; icon: JSX.Element }> = {
+ chat: { label: 'Chat', icon: <IconChat className="text-muted-foreground" /> },
+ running: { label: 'Running', icon: <IconSpinner className="text-info-foreground motion-safe:animate-spin" /> },
+ queued: { label: 'Queued', icon: <IconCloud className="text-muted-foreground motion-safe:animate-pulse" /> },
+ completed: { label: 'Completed', icon: <IconCloud className="text-success-foreground *:fill-current" /> },
+ failed: { label: 'Failed', icon: <IconCloud className="text-destructive-foreground *:fill-current" /> },
+ stopped: { label: 'Stopped', icon: <IconCloud className="text-muted-foreground *:fill-current" /> },
+ pinned: { label: 'Pinned', icon: <IconPinFilled className="text-foreground" /> },
+ session: { label: 'Session', icon: <IconCloud className="text-muted-foreground" /> },
+}
+
+export function SpaceFeedStatusIcon({ item }: { item: TodayWorkItem }): JSX.Element {
+ const { label, icon } = ICONS[todaySessionIcon(item, false)]
+ return (
+ <span role="img" aria-label={label} className="flex">
+ {icon}
+ </span>
+ )
+}
diff --git a/products/tasks/frontend/spaces/SpaceScene.tsx b/products/tasks/frontend/spaces/SpaceScene.tsx
index 69c52f168938..f7ea749fade1 100644
--- a/products/tasks/frontend/spaces/SpaceScene.tsx
+++ b/products/tasks/frontend/spaces/SpaceScene.tsx
@@ -137,7 +137,8 @@ export function SpaceScene({ id }: SpaceSceneLogicProps): JSX.Element {
</TabsTrigger>
</TabsList>
<TabsContent value="feed">
- <div className="flex max-w-3xl flex-col gap-4">
+ {/* The same centered column as PostHog Desktop's space feed. */}
+ <div className="mx-auto flex w-full max-w-165 flex-col gap-4">
{/* Mounted once the space loads, so the composer starts on the space's repository. */}
{space && (
<div data-attr="today-space-new-task">
@@ -149,6 +150,7 @@ export function SpaceScene({ id }: SpaceSceneLogicProps): JSX.Element {
composerOverride={SPACE_COMPOSER_OVERRIDE}
onTaskCreated={sessionStarted}
focusRequest={composerFocusRequest}
+ autoFocus={false}
/>
</div>
)}
diff --git a/products/tasks/frontend/spaces/spaceFeedStatus.ts b/products/tasks/frontend/spaces/spaceFeedStatus.ts
index 3c0494a8afdb..fe6adb1c5b33 100644
--- a/products/tasks/frontend/spaces/spaceFeedStatus.ts
+++ b/products/tasks/frontend/spaces/spaceFeedStatus.ts
@@ -5,12 +5,14 @@ export type SpaceFeedStatusVariant = 'default' | 'info' | 'destructive' | 'succe
export interface SpaceFeedStatus {
label: string
variant: SpaceFeedStatusVariant
+ /** The run is working now, so the badge shows a spinner. */
+ running?: boolean
}
const RUN_STATUSES: Record<string, SpaceFeedStatus> = {
not_started: { label: 'Not started', variant: 'default' },
queued: { label: 'Queued', variant: 'default' },
- in_progress: { label: 'In progress', variant: 'info' },
+ in_progress: { label: 'In progress', variant: 'info', running: true },
completed: { label: 'Ready', variant: 'success' },
failed: { label: 'Failed', variant: 'destructive' },
cancelled: { label: 'Cancelled', variant: 'default' },
diff --git a/products/tasks/frontend/spaces/spaceSceneLogic.test.ts b/products/tasks/frontend/spaces/spaceSceneLogic.test.ts
index fc23df3df43c..0793aea907bc 100644
--- a/products/tasks/frontend/spaces/spaceSceneLogic.test.ts
+++ b/products/tasks/frontend/spaces/spaceSceneLogic.test.ts
@@ -8,6 +8,7 @@ import { spaceNewSessionUrl, todaySpacesLogic } from '~/layout/today/todaySpaces
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
+import { TaskListItemApi } from '../generated/api.schemas'
import { AutoArchiveSelection, spaceSceneLogic } from './spaceSceneLogic'
describe('spaceSceneLogic', () => {
@@ -137,6 +138,56 @@ describe('spaceSceneLogic', () => {
expect(logic.values.composerRepositoryConfig).toEqual(expected)
})
+ it.each([
+ [
+ 'one repository is used most',
+ [
+ ['a', 'acme/web'],
+ ['b', 'acme/api'],
+ ['c', 'acme/api'],
+ ],
+ { a: 'acme/web', b: null, c: null },
+ ],
+ [
+ 'two repositories tie',
+ [
+ ['a', 'acme/web'],
+ ['b', 'acme/api'],
+ ],
+ { a: null, b: 'acme/api' },
+ ],
+ [
+ 'a session has no repository',
+ [
+ ['a', null],
+ ['b', 'acme/api'],
+ ],
+ { a: null, b: null },
+ ],
+ [
+ 'archived sessions use another repository',
+ [
+ ['a', 'acme/web'],
+ ['b', 'acme/api', true],
+ ['c', 'acme/api', true],
+ ],
+ { a: null, b: 'acme/api', c: 'acme/api' },
+ ],
+ ] as [string, [string, string | null, boolean?][], Record<string, string | null>][])(
+ 'names a card repository only when it is not the usual one, when %s',
+ async (_, sessions, expected) => {
+ const logic = spaceSceneLogic({ id: 'space-a' })
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+
+ logic.actions.loadSessionsSuccess(
+ sessions.map(([id, repository, archived = false]) => ({ id, repository, archived }) as TaskListItemApi)
+ )
+
+ expect(logic.values.feedRepositories).toEqual(expected)
+ }
+ )
+
it('opens a started session and lists it in the feed', async () => {
const logic = spaceSceneLogic({ id: 'space-a' })
logic.mount()
diff --git a/products/tasks/frontend/spaces/spaceSceneLogic.ts b/products/tasks/frontend/spaces/spaceSceneLogic.ts
index cbee363cde5c..abf2da79dacc 100644
--- a/products/tasks/frontend/spaces/spaceSceneLogic.ts
+++ b/products/tasks/frontend/spaces/spaceSceneLogic.ts
@@ -70,7 +70,9 @@ export interface spaceSceneLogicValues {
composerFocusRequest: number
composerRepositoryConfig: SpaceComposerRepositoryConfig
creatorId: number | null
+ dominantRepository: string | null
feedGroups: TodayWorkGroup[]
+ feedRepositories: Record<string, string | null>
members: TaskUserBasicInfoApi[]
membersLoading: boolean
savingSpace: boolean
@@ -212,6 +214,11 @@ export interface spaceSceneLogicMeta {
) => string | null
activeTab: (location: { hash: string; pathname: string; search: string }) => SpaceTab
feedGroups: (sessions: TaskListItemApi[]) => TodayWorkGroup[]
+ dominantRepository: (sessions: TaskListItemApi[]) => string | null
+ feedRepositories: (
+ sessions: TaskListItemApi[],
+ dominantRepository: string | null
+ ) => Record<string, string | null>
sessionsById: (sessions: TaskListItemApi[]) => Record<string, TaskListItemApi>
breadcrumbs: (space: ChannelDTOApi | null, arg: any) => Breadcrumb[]
composerRepositoryConfig: (space: ChannelDTOApi | null) => SpaceComposerRepositoryConfig
@@ -377,6 +384,36 @@ export const spaceSceneLogic = kea<spaceSceneLogicType>([
(sessions: TaskListItemApi[]): TodayWorkGroup[] =>
groupByDay(sessions.filter((task) => !task.archived).map(sessionItem)),
],
+ // Like PostHog Desktop, a card names its repository only when it differs from the space's most used one.
+ // A tie goes to the repository of the most recently active session.
+ dominantRepository: [
+ (s) => [s.sessions],
+ (sessions: TaskListItemApi[]): string | null => {
+ const counts = new Map<string, number>()
+ for (const task of sessions) {
+ if (!task.archived && task.repository) {
+ counts.set(task.repository, (counts.get(task.repository) ?? 0) + 1)
+ }
+ }
+ let dominant: string | null = null
+ for (const [repository, count] of counts) {
+ if (dominant === null || count > (counts.get(dominant) ?? 0)) {
+ dominant = repository
+ }
+ }
+ return dominant
+ },
+ ],
+ feedRepositories: [
+ (s) => [s.sessions, s.dominantRepository],
+ (sessions: TaskListItemApi[], dominantRepository: string | null): Record<string, string | null> =>
+ Object.fromEntries(
+ sessions.map((task) => [
+ task.id,
+ task.repository && task.repository !== dominantRepository ? task.repository : null,
+ ])
+ ),
+ ],
sessionsById: [
(s) => [s.sessions],
(sessions: TaskListItemApi[]): Record<string, TaskListItemApi> =>