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(posthog-ai): open the artifacts tab on a list on phones (#111540)

Shy Alter58a6e3b31adb
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunArtifacts.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunArtifacts.tsx
index 161494916176..55e1a46b92b2 100644
--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunArtifacts.tsx
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunArtifacts.tsx
@@ -508,8 +508,8 @@ function fileMeta(file: ArtifactFile): string {
: `${artifactDetail(file.latest)} · ${age}`
}
-function ArtifactNav({ taskId }: { taskId: string }): JSX.Element {
- const { files, selectedFile, isEditing } = useValues(taskRunArtifactsLogic({ taskId }))
+function ArtifactFileList({ taskId, size, label }: { taskId: string; size: 'xs' | 'sm'; label: string }): JSX.Element {
+ const { files, selectedFile, isEditing, todayPhone } = useValues(taskRunArtifactsLogic({ taskId }))
const { selectArtifact } = useActions(taskRunArtifactsLogic({ taskId }))
// Cited PostHog objects sit under their own label, after the files.
const objects = files.filter((file) => !!postHogObjectRef(file.latest))
@@ -529,14 +529,15 @@ function ArtifactNav({ taskId }: { taskId: string }): JSX.Element {
next.focus()
}
const renderRow = (file: ArtifactFile): JSX.Element => {
- const selected = file.key === selectedFile?.key
+ // The phone list opens a file, so no row shows as the open one.
+ const selected = !todayPhone && file.key === selectedFile?.key
return (
<Item
key={file.key}
- size="xs"
+ size={size}
aria-selected={selected}
// Roving tabindex: Tab enters the list on the open file, and the arrow keys move from there.
- tabIndex={selected ? 0 : -1}
+ tabIndex={selected || (todayPhone && file === files[0]) ? 0 : -1}
data-file-key={file.key}
className={cn(
'w-full cursor-pointer rounded-md border-transparent text-left hover:bg-fill-hover',
@@ -558,6 +559,35 @@ function ArtifactNav({ taskId }: { taskId: string }): JSX.Element {
</Item>
)
}
+ return (
+ <div
+ role="listbox"
+ aria-label={label}
+ onKeyDown={onKeyDown}
+ className="flex min-h-0 flex-1 flex-col gap-px overflow-y-auto p-1.5"
+ >
+ {files.filter((file) => !postHogObjectRef(file.latest)).map(renderRow)}
+ {objects.length > 0 && (
+ <div role="group" aria-label="In PostHog" className="flex flex-col gap-px">
+ <Text
+ size="xs"
+ weight="medium"
+ variant="muted"
+ render={<span aria-hidden />}
+ className="px-2 pt-3 pb-1"
+ >
+ In PostHog
+ </Text>
+ {objects.map(renderRow)}
+ </div>
+ )}
+ </div>
+ )
+}
+
+function ArtifactNav({ taskId }: { taskId: string }): JSX.Element {
+ const { files, isEditing } = useValues(taskRunArtifactsLogic({ taskId }))
+ const objectCount = files.filter((file) => !!postHogObjectRef(file.latest)).length
return (
<aside className="hidden w-64 shrink-0 flex-col border-r border-border @[52rem]/main-content:flex">
<div className="flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-3">
@@ -565,7 +595,7 @@ function ArtifactNav({ taskId }: { taskId: string }): JSX.Element {
Files
</Text>
<Text size="xs" variant="muted" render={<span />} className="tabular-nums">
- {files.length - objects.length}
+ {files.length - objectCount}
</Text>
</div>
{isEditing && (
@@ -573,28 +603,7 @@ function ArtifactNav({ taskId }: { taskId: string }): JSX.Element {
Save or cancel your changes to open another file.
</Text>
)}
- <div
- role="listbox"
- aria-label="Files"
- onKeyDown={onKeyDown}
- className="flex min-h-0 flex-1 flex-col gap-px overflow-y-auto p-1.5"
- >
- {files.filter((file) => !postHogObjectRef(file.latest)).map(renderRow)}
- {objects.length > 0 && (
- <div role="group" aria-label="In PostHog" className="flex flex-col gap-px">
- <Text
- size="xs"
- weight="medium"
- variant="muted"
- render={<span aria-hidden />}
- className="px-2 pt-3 pb-1"
- >
- In PostHog
- </Text>
- {objects.map(renderRow)}
- </div>
- )}
- </div>
+ <ArtifactFileList taskId={taskId} size="xs" label="Files" />
</aside>
)
}
@@ -928,8 +937,10 @@ function PreviewBody({ taskId, mode }: { taskId: string; mode: PreviewMode }): J
}
function ArtifactsWorkspace({ taskId }: { taskId: string }): JSX.Element {
- const { files, selectedArtifact, isEditing } = useValues(taskRunArtifactsLogic({ taskId }))
- const { setActiveTab, reportFullPageOpened } = useActions(taskRunArtifactsLogic({ taskId }))
+ const { files, selectedArtifact, isEditing, todayPhone, showArtifactList } = useValues(
+ taskRunArtifactsLogic({ taskId })
+ )
+ const { setActiveTab, reportFullPageOpened, closeArtifact } = useActions(taskRunArtifactsLogic({ taskId }))
const [mode, setMode] = useState<PreviewMode>('rendered')
const [expanded, setExpanded] = useState(false)
// A new file opens in its rendered form, whatever the last file showed.
@@ -976,6 +987,9 @@ function ArtifactsWorkspace({ taskId }: { taskId: string }): JSX.Element {
</Empty>
)
}
+ if (showArtifactList && !isEditing) {
+ return <ArtifactFileList taskId={taskId} size="sm" label="Artifacts" />
+ }
const toolbar =
selectedArtifact && !isEditing ? (
<ArtifactToolbar
@@ -1004,6 +1018,14 @@ function ArtifactsWorkspace({ taskId }: { taskId: string }): JSX.Element {
<div className="flex min-h-0 flex-1">
<ArtifactNav taskId={taskId} />
<section className="flex min-w-0 flex-1 flex-col">
+ {todayPhone && !isEditing && (
+ <div className="flex h-10 shrink-0 items-center border-b border-border px-1">
+ <Button size="sm" onClick={closeArtifact} data-attr="task-artifact-back">
+ <IconChevronLeft />
+ Artifacts
+ </Button>
+ </div>
+ )}
{toolbar}
{!expanded && <PreviewBody taskId={taskId} mode={mode} />}
</section>
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.test.ts b/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.test.ts
index 3426ac55d2e9..a14cc2099223 100644
--- a/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.test.ts
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.test.ts
@@ -1,5 +1,9 @@
import { router } from 'kea-router'
import { expectLogic } from 'kea-test-utils'
+import posthog from 'posthog-js'
+
+import { FEATURE_FLAGS } from 'lib/constants'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { initKeaTests } from '~/test/init'
@@ -79,6 +83,42 @@ describe('taskRunArtifactsLogic', () => {
expect(router.values.searchParams).toEqual({})
})
+ it('shows the list first on a phone and opens no file until one is picked', async () => {
+ const originalWidth = window.innerWidth
+ Object.defineProperty(window, 'innerWidth', { configurable: true, value: 390 })
+ try {
+ featureFlagLogic.mount()
+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.TODAY_RAIL_NAV], {
+ [FEATURE_FLAGS.TODAY_RAIL_NAV]: true,
+ })
+ runArtifacts = [reportVersion('report-v1', '2026-09-28T18:00:00Z')]
+ router.actions.push('/project/1/ai', { task: TASK_ID })
+ const capture = jest.spyOn(posthog, 'capture')
+ const logic = taskRunArtifactsLogic({ taskId: TASK_ID })
+ logic.mount()
+ logic.actions.setActiveTab('artifacts')
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(logic.values.showArtifactList).toBe(true)
+ expect(router.values.searchParams).toEqual({ task: TASK_ID })
+ expect(capture).not.toHaveBeenCalledWith('task artifact previewed', expect.anything())
+
+ logic.actions.selectArtifact('report.md')
+ expect(logic.values.showArtifactList).toBe(false)
+ expect(router.values.searchParams).toEqual({ task: TASK_ID, artifact: 'report.md' })
+ expect(capture).toHaveBeenCalledWith(
+ 'task artifact previewed',
+ expect.objectContaining({ kind: 'markdown', source: 'click' })
+ )
+
+ logic.actions.closeArtifact()
+ expect(logic.values.showArtifactList).toBe(true)
+ expect(router.values.searchParams).toEqual({ task: TASK_ID })
+ } finally {
+ Object.defineProperty(window, 'innerWidth', { configurable: true, value: originalWidth })
+ }
+ })
+
it('ignores an artifact link for another task', async () => {
router.actions.push('/project/1/tasks/other-task', { artifact: 'report.md' })
const logic = taskRunArtifactsLogic({ taskId: TASK_ID })
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.ts b/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.ts
index 5256c13252f7..b5b1cf20dc01 100644
--- a/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.ts
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.ts
@@ -22,6 +22,8 @@ import api from 'lib/api'
import { projectLogic } from 'scenes/projectLogic'
import { urls } from 'scenes/urls'
+import { todayShellLogic } from '~/layout/today/todayShellLogic'
+
import {
getTasksRunsArtifactsDownloadCreateUrl,
getTasksRunsArtifactsDownloadRetrieveUrl,
@@ -98,9 +100,12 @@ export interface taskRunArtifactsLogicValues {
currentProjectId: number | null // projectLogic
runs: TaskRun[] // taskDetailSceneLogic
selectedRun: TaskRunDetailDTOApi | null // taskDetailSceneLogic
+ phoneLayout: boolean // todayShellLogic
+ todayRailEnabled: boolean // todayShellLogic
activeTab: TaskRunTab
artifactMedia: ArtifactMedia | null
artifactMediaLoading: boolean
+ artifactOpen: boolean
artifactText: ArtifactText | null
artifactTextLoading: boolean
artifacts: RunArtifact[]
@@ -134,7 +139,9 @@ export interface taskRunArtifactsLogicValues {
selectedVersionId: string | null
selectedVersionIndex: number
shareUrl: string | null
+ showArtifactList: boolean
textsById: Record<string, ArtifactText>
+ todayPhone: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -149,6 +156,9 @@ export interface taskRunArtifactsLogicActions {
cancelEditing: () => {
value: true
}
+ closeArtifact: () => {
+ value: true
+ }
dismissFile: (fileKey: string) => {
fileKey: string
}
@@ -309,6 +319,8 @@ export interface taskRunArtifactsLogicMeta {
livingFiles: (livingArtifacts: TaskRunLivingArtifactResponseApi[]) => ArtifactFile[]
files: (artifacts: RunArtifact[], livingFiles: ArtifactFile[]) => ArtifactFile[]
selectedIndex: (files: ArtifactFile[], selectedFileKey: string | null) => number
+ todayPhone: (todayRailEnabled: boolean, phoneLayout: boolean) => boolean
+ showArtifactList: (todayPhone: boolean, artifactOpen: boolean) => boolean
selectedFile: (files: ArtifactFile[], selectedIndex: number) => ArtifactFile | null
selectedVersionIndex: (selectedFile: ArtifactFile | null, selectedVersionId: string | null) => number
selectedVersion: (selectedFile: ArtifactFile | null, selectedVersionIndex: number) => RunArtifact | null
@@ -414,12 +426,15 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([
['selectedRun', 'runs'],
projectLogic,
['currentProjectId'],
+ todayShellLogic,
+ ['todayRailEnabled', 'phoneLayout'],
],
actions: [taskDetailSceneLogic({ taskId: props.taskId }), ['loadTaskRunsSuccess']],
})),
actions({
setActiveTab: (tab: TaskRunTab) => ({ tab }),
selectArtifact: (fileKey: string, source: ArtifactSelectSource = 'click') => ({ fileKey, source }),
+ closeArtifact: true,
// `null` follows the latest version, so a new upload of the open file shows at once.
selectVersion: (artifactId: string | null) => ({ artifactId }),
stepArtifact: (delta: number) => ({ delta }),
@@ -555,6 +570,8 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([
'conversation' as TaskRunTab,
{ setActiveTab: (_, { tab }) => tab, openFromUrl: () => 'artifacts' },
],
+ // A phone shows the list until a file is picked. A wider window always shows the open file beside the list.
+ artifactOpen: [false, { selectArtifact: () => true, openFromUrl: () => true, closeArtifact: () => false }],
// The panel stays open across files, so a reviewer can read the comments on each one in turn.
commentsOpen: [false, { setCommentsOpen: (_, { open }) => open }],
selectedFileKey: [
@@ -679,6 +696,14 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([
files.findIndex((file) => file.key === selectedFileKey)
),
],
+ todayPhone: [
+ (s) => [s.todayRailEnabled, s.phoneLayout],
+ (todayRailEnabled: boolean, phoneLayout: boolean): boolean => todayRailEnabled && phoneLayout,
+ ],
+ showArtifactList: [
+ (s) => [s.todayPhone, s.artifactOpen],
+ (todayPhone: boolean, artifactOpen: boolean): boolean => todayPhone && !artifactOpen,
+ ],
selectedFile: [
(s) => [s.files, s.selectedIndex],
(files: ArtifactFile[], selectedIndex: number): ArtifactFile | null => files[selectedIndex] ?? null,
@@ -832,7 +857,7 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([
}
const previewSelected = (source?: ArtifactSelectSource): void => {
const artifact = values.selectedArtifact
- if (values.activeTab !== 'artifacts' || !artifact || !values.selectedKind) {
+ if (values.activeTab !== 'artifacts' || values.showArtifactList || !artifact || !values.selectedKind) {
return
}
// pinned: analytics event name and properties. Renaming them breaks insights.
@@ -1058,7 +1083,7 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([
delete next[ARTIFACT_PARAM]
delete next[VERSION_PARAM]
const fileKey = values.selectedFileKey ?? values.selectedFile?.key
- if (values.activeTab === 'artifacts' && fileKey) {
+ if (values.activeTab === 'artifacts' && !values.showArtifactList && fileKey) {
next[ARTIFACT_PARAM] = fileKey
if (values.selectedVersionId) {
next[VERSION_PARAM] = values.selectedVersionId
@@ -1066,7 +1091,13 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([
}
return [pathname, next, hashParams, { replace: true }]
}
- return { setActiveTab: syncUrl, selectArtifact: syncUrl, selectVersion: syncUrl, setFileDismissed: syncUrl }
+ return {
+ setActiveTab: syncUrl,
+ selectArtifact: syncUrl,
+ closeArtifact: syncUrl,
+ selectVersion: syncUrl,
+ setFileDismissed: syncUrl,
+ }
}),
urlToAction(({ actions, values, props }) => ({
'*': (_, searchParams, __, { pathname }) => {