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): show the files a session produced on space feed cards (#110099)

Shy Altera9c9f0d084ab
diff --git a/products/tasks/frontend/spaces/SpaceFeedCard.tsx b/products/tasks/frontend/spaces/SpaceFeedCard.tsx
index 3ffda249eaeb..4832407bc2f9 100644
--- a/products/tasks/frontend/spaces/SpaceFeedCard.tsx
+++ b/products/tasks/frontend/spaces/SpaceFeedCard.tsx
@@ -1,7 +1,7 @@
import { useValues } from 'kea'
import { useId } from 'react'
-import { IconGitBranch } from '@posthog/icons'
+import { IconDocument, IconGitBranch } from '@posthog/icons'
import {
Badge,
Card,
@@ -34,10 +34,28 @@ import { SpaceFeedCardPrompt } from './SpaceFeedCardPrompt'
import { spaceFeedPreview } from './spaceFeedPreview'
import { spaceFeedStatus } from './spaceFeedStatus'
import { SpaceFeedStatusIcon } from './SpaceFeedStatusIcon'
+import { TaskFile, VISIBLE_FILE_COUNT, taskFiles } from './taskFiles'
import { TASK_CHIP_CLASS, TaskPullRequestChip } from './TaskPullRequestChip'
import { pullRequestLabel, splitPullRequests } from './taskPullRequests'
import { TaskUserAvatar, taskUserName } from './TaskUserAvatar'
+function TaskFileChip({ file }: { file: TaskFile }): JSX.Element {
+ return (
+ <Badge
+ render={<LinkPrimitive to={file.url} />}
+ aria-label={`Open ${file.name}`}
+ data-attr="today-file-chip-feed"
+ className={cn(
+ TASK_CHIP_CLASS,
+ 'border-border bg-fill-hover text-muted-foreground hover:bg-fill-selected hover:text-foreground'
+ )}
+ >
+ <IconDocument className="size-3 shrink-0" />
+ <span className="max-w-40 min-w-0 truncate">{file.name}</span>
+ </Badge>
+ )
+}
+
interface SpaceFeedCardProps {
task: TaskListItemApi
pinned: boolean
@@ -57,6 +75,8 @@ export function SpaceFeedCard({ task, pinned, unread, repository }: SpaceFeedCar
const [mainPullRequest] = item.pullRequests
const status = spaceFeedStatus(task.latest_run, mainPullRequest && pullRequestStates[mainPullRequest.url])
const pullRequests = splitPullRequests(item.pullRequests)
+ const files = taskFiles(task.id, task.latest_run?.artifacts)
+ const hiddenFiles = files.slice(VISIBLE_FILE_COUNT)
const preview = spaceFeedPreview('description_preview' in task ? task.description_preview : task.description)
const author = task.created_by
const authorName = author ? taskUserName(author) : null
@@ -111,7 +131,7 @@ export function SpaceFeedCard({ task, pinned, unread, repository }: SpaceFeedCar
</div>
</div>
<SpaceFeedCardPrompt taskId={task.id} prompt={preview} />
- {(repository || author || item.pullRequests.length > 0) && (
+ {(repository || author || item.pullRequests.length > 0 || files.length > 0) && (
<div className="mt-3 flex min-w-0 flex-wrap items-center gap-1.5">
{repository && (
<Badge
@@ -158,6 +178,28 @@ export function SpaceFeedCard({ task, pinned, unread, repository }: SpaceFeedCar
</PopoverContent>
</Popover>
)}
+ {files.slice(0, VISIBLE_FILE_COUNT).map((file) => (
+ <TaskFileChip key={file.name} file={file} />
+ ))}
+ {hiddenFiles.length > 0 && (
+ <Popover>
+ <PopoverTrigger
+ className={cn(
+ badgeVariants(),
+ TASK_CHIP_CLASS,
+ 'border-dashed border-border bg-fill-hover text-muted-foreground hover:bg-fill-selected hover:text-foreground'
+ )}
+ data-attr="today-file-chip-overflow"
+ >
+ {`+${hiddenFiles.length} ${hiddenFiles.length === 1 ? 'file' : 'files'}`}
+ </PopoverTrigger>
+ <PopoverContent align="start" className="flex max-w-72 flex-col items-start gap-1">
+ {hiddenFiles.map((file) => (
+ <TaskFileChip key={file.name} file={file} />
+ ))}
+ </PopoverContent>
+ </Popover>
+ )}
{author && authorName && (
<Tooltip>
<TooltipTrigger
diff --git a/products/tasks/frontend/spaces/taskFiles.test.ts b/products/tasks/frontend/spaces/taskFiles.test.ts
new file mode 100644
index 000000000000..73cf07ecdcaf
--- /dev/null
+++ b/products/tasks/frontend/spaces/taskFiles.test.ts
@@ -0,0 +1,49 @@
+import { TaskRunArtifactResponseApi } from '../generated/api.schemas'
+import { taskFiles } from './taskFiles'
+
+function artifact(name: string, overrides: Partial<TaskRunArtifactResponseApi> = {}): TaskRunArtifactResponseApi {
+ return {
+ id: `id-${name}-${overrides.uploaded_at ?? '1'}`,
+ name,
+ type: 'output',
+ source: 'agent_output',
+ storage_path: `tasks/artifacts/${name}`,
+ uploaded_at: '2026-01-01T10:00:00Z',
+ ...overrides,
+ }
+}
+
+describe('taskFiles', () => {
+ it.each([
+ ['no artifacts', null, []],
+ ['one agent file', [artifact('report.md')], ['report.md']],
+ [
+ 'files the agent did not hand back',
+ [
+ artifact('plan.md', { type: 'plan' }),
+ artifact('screenshot.png', { source: 'user_attachment' }),
+ artifact('skill.zip', { type: 'skill_bundle' }),
+ artifact('reference', { storage_path: undefined }),
+ artifact('old.csv', { dismissed_at: '2026-01-02T00:00:00Z' }),
+ ],
+ [],
+ ],
+ [
+ 'versions of one file, newest file first',
+ [
+ artifact('summary.md', { uploaded_at: '2026-01-01T09:00:00Z' }),
+ artifact('chart.html', { uploaded_at: '2026-01-01T10:00:00Z' }),
+ artifact('summary.md', { uploaded_at: '2026-01-01T11:00:00Z' }),
+ ],
+ ['summary.md', 'chart.html'],
+ ],
+ ])('lists %s', (_, artifacts, expected) => {
+ expect(taskFiles('task-1', artifacts).map((file) => file.name)).toEqual(expected)
+ })
+
+ it('links a file to its session with the file selected', () => {
+ expect(taskFiles('task-1', [artifact('q3 revenue.md')])[0].url).toEqual(
+ '/ai?task=task-1&artifact=q3%20revenue.md'
+ )
+ })
+})
diff --git a/products/tasks/frontend/spaces/taskFiles.ts b/products/tasks/frontend/spaces/taskFiles.ts
new file mode 100644
index 000000000000..fb74da62a7ad
--- /dev/null
+++ b/products/tasks/frontend/spaces/taskFiles.ts
@@ -0,0 +1,41 @@
+import { combineUrl } from 'kea-router'
+
+import { urls } from 'scenes/urls'
+
+import { TaskRunArtifactResponseApi } from '../generated/api.schemas'
+
+export interface TaskFile {
+ name: string
+ url: string
+}
+
+export const VISIBLE_FILE_COUNT = 2
+
+function isAgentFile(artifact: TaskRunArtifactResponseApi): boolean {
+ return (
+ !!artifact.id &&
+ !!artifact.storage_path &&
+ (artifact.type === 'output' || artifact.type === 'artifact') &&
+ artifact.source === 'agent_output' &&
+ !artifact.dismissed_at
+ )
+}
+
+export function taskFiles(
+ taskId: string,
+ artifacts: readonly TaskRunArtifactResponseApi[] | null | undefined
+): TaskFile[] {
+ const newestByName = new Map<string, string>()
+ for (const artifact of artifacts ?? []) {
+ if (!isAgentFile(artifact)) {
+ continue
+ }
+ const seen = newestByName.get(artifact.name)
+ if (seen === undefined || artifact.uploaded_at > seen) {
+ newestByName.set(artifact.name, artifact.uploaded_at)
+ }
+ }
+ return [...newestByName]
+ .sort(([, a], [, b]) => b.localeCompare(a))
+ .map(([name]) => ({ name, url: combineUrl(urls.aiTask(taskId), { artifact: name }).url }))
+}