: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(tasks): dismiss artifacts and open full page with a key (#110424)
Shy Alter67664fdc93e5
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/TaskRunArtifacts.stories.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/TaskRunArtifacts.stories.tsxindex c9266da4453a..ab383799e9e8 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/TaskRunArtifacts.stories.tsx+++ b/products/posthog_ai/frontend/scenes/TaskTracker/TaskRunArtifacts.stories.tsx@@ -403,6 +403,7 @@ function taskMocks(headers: { 'Content-Type': 'text/plain' },})},+ [`/api/projects/:team_id/tasks/${TASK_ID}/runs/:run_id/artifacts/dismiss/`]: { artifacts },},}}diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunArtifacts.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunArtifacts.tsxindex dc8232c764df..7fc97e246346 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunArtifacts.tsx+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunArtifacts.tsx@@ -13,6 +13,7 @@ import {IconExternal,IconLock,IconShare,+ IconHide,} from '@posthog/icons'import {Badge,@@ -36,6 +37,7 @@ import {ItemDescription,ItemMedia,ItemTitle,+ Kbd,Select,SelectContent,SelectItem,@@ -65,6 +67,7 @@ import {import { objectKindLink } from 'lib/components/AgentObjectTags/rewriteAgentObjectTags'import { dayjs } from 'lib/dayjs'+import { useKeyboardHotkeys } from 'lib/hooks/useKeyboardHotkeys'import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'import { LinkPrimitive } from 'lib/lemon-ui/Link'@@ -75,6 +78,7 @@ import {TaskRunTab,artifactPreviewKind,formatArtifactSize,+ hasFullPageView,isTextPreview,listboxKeyTarget,parseCsv,@@ -82,7 +86,7 @@ import {LIVING_ADAPTER_LABEL,postHogObjectRef,} from '../taskRunArtifacts'-import { artifactDownloadUrl, taskRunArtifactsLogic } from '../taskRunArtifactsLogic'+import { FullPageSource, artifactDownloadUrl, taskRunArtifactsLogic } from '../taskRunArtifactsLogic'import { ArtifactIcon } from './ArtifactIcon'import { ArtifactImageViewer } from './ArtifactImageViewer'@@ -94,6 +98,13 @@ const ArtifactObjectEmbed = lazy(() =>type PreviewMode = 'rendered' | 'source'+const FULL_PAGE_KEY = 'f'++/** The replay player uses F for its own full screen, so a replay gets no full page shortcut. */+function hasFullPageShortcut(artifact: RunArtifact): boolean {+ return postHogObjectRef(artifact)?.objectKind !== 'replay'+}+/** Size for a file, the object kind for a cited PostHog object, where the agent sent a living document. */function artifactDetail(artifact: RunArtifact): string {if (artifact.living) {@@ -109,6 +120,8 @@ function IconAction({href,to,disabledReason,+ loading,+ shortcut,children,dataAttr,}: {@@ -119,6 +132,9 @@ function IconAction({/** An app page to open. */to?: stringdisabledReason?: string+ loading?: boolean+ /** The key that does the same action, shown in the tooltip. */+ shortcut?: stringchildren: JSX.ElementdataAttr: string}): JSX.Element {@@ -131,6 +147,7 @@ function IconAction({size="icon"aria-label={label}disabled={!!disabledReason}+ loading={loading}onClick={onClick}data-attr={dataAttr}// A link renders as `<a>`, so Base UI must not expect a native button.@@ -148,7 +165,10 @@ function IconAction({>{children}</TooltipTrigger>- <TooltipContent>{disabledReason ?? label}</TooltipContent>+ <TooltipContent>+ {disabledReason ?? label}+ {shortcut && !disabledReason && <Kbd>{shortcut}</Kbd>}+ </TooltipContent></Tooltip>)}@@ -663,12 +683,14 @@ function ArtifactToolbar({mode: PreviewModeonModeChange: (mode: PreviewMode) => voidexpanded: boolean- onExpandedChange: (expanded: boolean) => void+ onExpandedChange: (expanded: boolean, source: FullPageSource) => void}): JSX.Element {- const { files, selectedFile, selectedIndex, selectedText, currentProjectId } = useValues(+ const { files, selectedFile, selectedIndex, selectedText, currentProjectId, dismissalPending } = useValues(+ taskRunArtifactsLogic({ taskId })+ )+ const { stepArtifact, downloadArtifact, reportObjectOpened, dismissFile } = useActions(taskRunArtifactsLogic({ taskId }))- const { stepArtifact, downloadArtifact, reportObjectOpened } = useActions(taskRunArtifactsLogic({ taskId }))const kind = artifactPreviewKind(artifact)const objectRef = postHogObjectRef(artifact)const objectLink =@@ -778,11 +800,23 @@ function ArtifactToolbar({<IconExternal className="size-4" /></IconAction>)}+ {/* No endpoint dismisses a living document, so it has no dismissal. */}+ {selectedFile && !artifact.living && (+ <IconAction+ label="Dismiss artifact"+ loading={dismissalPending}+ onClick={() => dismissFile(selectedFile.key)}+ dataAttr="task-artifact-dismiss"+ >+ <IconHide className="size-4" />+ </IconAction>+ )}{/* Full page always keeps its exit, because the stepper can land on an object with no embed. */}- {(expanded || kind !== 'reference' || (objectRef && LIVE_OBJECT_KINDS.has(objectRef.objectKind))) && (+ {(expanded || hasFullPageView(artifact)) && (<IconActionlabel={expanded ? 'Exit full page' : 'Open full page'}- onClick={() => onExpandedChange(!expanded)}+ shortcut={hasFullPageShortcut(artifact) ? FULL_PAGE_KEY.toUpperCase() : undefined}+ onClick={() => onExpandedChange(!expanded, 'button')}dataAttr={expanded ? 'task-artifact-collapse' : 'task-artifact-expand'}>{expanded ? <IconCollapse45 className="size-4" /> : <IconExpand45 className="size-4" />}@@ -810,11 +844,30 @@ function PreviewSurface({ taskId, mode }: { taskId: string; mode: PreviewMode })function ArtifactsWorkspace({ taskId }: { taskId: string }): JSX.Element {const { files, selectedArtifact } = useValues(taskRunArtifactsLogic({ taskId }))- const { setActiveTab } = useActions(taskRunArtifactsLogic({ taskId }))+ const { setActiveTab, reportFullPageOpened } = 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.useEffect(() => setMode('rendered'), [selectedArtifact?.id])+ const changeExpanded = (next: boolean, source: FullPageSource): void => {+ setExpanded(next)+ if (next) {+ reportFullPageOpened(source)+ }+ }+ // The hook skips key presses in inputs, text areas and editable content, so typing never toggles the view.+ useKeyboardHotkeys(+ {+ [FULL_PAGE_KEY]: {+ action: () => changeExpanded(!expanded, 'keyboard'),+ disabled:+ !selectedArtifact ||+ !hasFullPageShortcut(selectedArtifact) ||+ (!expanded && !hasFullPageView(selectedArtifact)),+ },+ },+ [expanded, selectedArtifact]+ )if (files.length === 0 || !selectedArtifact) {return (@@ -844,7 +897,7 @@ function ArtifactsWorkspace({ taskId }: { taskId: string }): JSX.Element {mode={mode}onModeChange={setMode}expanded={expanded}- onExpandedChange={setExpanded}+ onExpandedChange={changeExpanded}/>)return (diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifacts.test.ts b/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifacts.test.tsindex fee88af64d0a..6e88897373e5 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifacts.test.ts+++ b/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifacts.test.ts@@ -147,6 +147,20 @@ describe('taskRunArtifacts', () => {])})+ it('collectRunArtifacts applies dismissals over run manifests from before the change', () => {+ const run = {+ id: 'run-1',+ artifacts: [+ artifact({ id: 'dismissed-here' }),+ artifact({ id: 'restored-here', dismissed_at: '2026-09-28T19:00:00Z' }),+ artifact({ id: 'untouched' }),+ ],+ }+ expect(+ collectRunArtifacts([run], { 'dismissed-here': true, 'restored-here': false }).map(({ id }) => id)+ ).toEqual(['restored-here', 'untouched'])+ })+test.each([['merges one name across runs, newest first',diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifacts.ts b/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifacts.tsindex b6bcec6175e7..cfb9087097e3 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifacts.ts+++ b/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifacts.ts@@ -94,6 +94,12 @@ export function artifactPreviewKind(return 'none'}+/** A cited object with no live embed shows only a card, so it gets no full page view. */+export function hasFullPageView(artifact: TaskRunArtifactResponseApi & { living?: LivingVersion }): boolean {+ const ref = postHogObjectRef(artifact)+ return ref ? LIVE_OBJECT_KINDS.has(ref.objectKind) : artifactPreviewKind(artifact) !== 'reference'+}+export function isTextPreview(kind: ArtifactPreviewKind): boolean {return kind === 'markdown' || kind === 'html' || kind === 'csv' || kind === 'text'}@@ -202,15 +208,27 @@ interface RunWithArtifacts {/*** Agent files from every run of a task. A resumed task keeps writing new runs, so the files from earlier* runs in the chain are only on those runs. The first run that lists an id wins, so pass the live run first.+ * `dismissals` maps an artifact id to the dismissed state this page last set. It wins over the run data,+ * because the runs can hold a manifest from before that change.*/-export function collectRunArtifacts(runs: readonly (RunWithArtifacts | null | undefined)[]): RunArtifact[] {+export function collectRunArtifacts(+ runs: readonly (RunWithArtifacts | null | undefined)[],+ dismissals: Readonly<Record<string, boolean>> = {}+): RunArtifact[] {const byId = new Map<string, RunArtifact>()for (const run of runs) {if (!run) {continue}- for (const artifact of visibleRunArtifacts(run.artifacts ?? [])) {- if (artifact.id && !byId.has(artifact.id)) {+ const manifest = (run.artifacts ?? []).map((artifact) => {+ if (!artifact.id || dismissals[artifact.id] !== false) {+ return artifact+ }+ const { dismissed_at: _dismissedAt, ...restored } = artifact+ return restored+ })+ for (const artifact of visibleRunArtifacts(manifest)) {+ if (artifact.id && !dismissals[artifact.id] && !byId.has(artifact.id)) {byId.set(artifact.id, { ...artifact, runId: run.id })}}diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.ts b/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.tsindex d37a275df05b..219d68c65844 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.ts+++ b/products/posthog_ai/frontend/scenes/TaskTracker/taskRunArtifactsLogic.ts@@ -16,6 +16,8 @@ import { loaders } from 'kea-loaders'import { actionToUrl, router, urlToAction } from 'kea-router'import posthog from 'posthog-js'+import { toast } from '@posthog/quill-primitives'+import api from 'lib/api'import { projectLogic } from 'scenes/projectLogic'import { urls } from 'scenes/urls'@@ -23,6 +25,7 @@ import { urls } from 'scenes/urls'import {getTasksRunsArtifactsDownloadCreateUrl,getTasksRunsArtifactsDownloadRetrieveUrl,+ tasksRunsArtifactsDismissCreate,tasksRunsLivingArtifactsList,tasksRunsRetrieve,} from 'products/tasks/frontend/generated/api'@@ -56,6 +59,8 @@ export interface TaskRunArtifactsLogicProps {export type ArtifactSelectSource = 'click' | 'keyboard'+export type FullPageSource = 'button' | 'keyboard'+export interface ArtifactText {artifactId: stringtext: string | null@@ -83,6 +88,8 @@ export interface taskRunArtifactsLogicValues {chainRuns: TaskRunDetailDTOApi[]chainRunsLoading: booleancommentsOpen: boolean+ dismissalPending: boolean+ dismissals: Record<string, boolean>files: ArtifactFile[]livingArtifacts: TaskRunLivingArtifactResponseApi[]livingArtifactsLoading: boolean@@ -111,6 +118,12 @@ export interface taskRunArtifactsLogicActions {payload?: anyruns: TaskRun[]} // taskDetailSceneLogic+ dismissFile: (fileKey: string) => {+ fileKey: string+ }+ dismissalFailed: () => {+ value: true+ }downloadArtifact: (artifact: RunArtifact) => {artifact: RunArtifact}@@ -184,12 +197,18 @@ export interface taskRunArtifactsLogicActions {fileKey: stringversionId: string | null}+ reportFullPageOpened: (source: FullPageSource) => {+ source: FullPageSource+ }reportLinkCopied: () => {value: true}reportObjectOpened: (objectKind: string) => {objectKind: string}+ restoreFile: (file: ArtifactFile) => {+ file: ArtifactFile+ }selectArtifact: (fileKey: string,source?: ArtifactSelectSource@@ -206,6 +225,15 @@ export interface taskRunArtifactsLogicActions {setCommentsOpen: (open: boolean) => {open: boolean}+ setFileDismissed: (+ artifactIds: string[],+ dismissed: boolean,+ selectKey: string | null+ ) => {+ artifactIds: string[]+ dismissed: boolean+ selectKey: string | null+ }stepArtifact: (delta: number) => {delta: number}@@ -215,7 +243,11 @@ export interface taskRunArtifactsLogicActions {export interface taskRunArtifactsLogicMeta {key: string__keaTypeGenInternalSelectorTypes: {- artifacts: (selectedRun: TaskRunDetailDTOApi | null, chainRuns: TaskRunDetailDTOApi[]) => RunArtifact[]+ artifacts: (+ selectedRun: TaskRunDetailDTOApi | null,+ chainRuns: TaskRunDetailDTOApi[],+ dismissals: Record<string, boolean>+ ) => RunArtifact[]livingFiles: (livingArtifacts: TaskRunLivingArtifactResponseApi[]) => ArtifactFile[]files: (artifacts: RunArtifact[], livingFiles: ArtifactFile[]) => ArtifactFile[]selectedIndex: (files: ArtifactFile[], selectedFileKey: string | null) => number@@ -292,6 +324,17 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([reportLinkCopied: true,reportObjectOpened: (objectKind: string) => ({ objectKind }),setCommentsOpen: (open: boolean) => ({ open }),+ reportFullPageOpened: (source: FullPageSource) => ({ source }),+ // Dismissal covers every version of a file, so the whole entry leaves the list.+ dismissFile: (fileKey: string) => ({ fileKey }),+ restoreFile: (file: ArtifactFile) => ({ file }),+ // `selectKey` is the entry to open after the change: a neighbor after a dismissal, the file after an undo.+ setFileDismissed: (artifactIds: string[], dismissed: boolean, selectKey: string | null) => ({+ artifactIds,+ dismissed,+ selectKey,+ }),+ dismissalFailed: true,}),loaders(({ props, values }) => ({chainRuns: [@@ -405,7 +448,11 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([commentsOpen: [false, { setCommentsOpen: (_, { open }) => open }],selectedFileKey: [null as string | null,- { selectArtifact: (_, { fileKey }) => fileKey, openFromUrl: (_, { fileKey }) => fileKey },+ {+ selectArtifact: (_, { fileKey }) => fileKey,+ openFromUrl: (_, { fileKey }) => fileKey,+ setFileDismissed: (_, { selectKey }) => selectKey,+ },],selectedVersionId: [null as string | null,@@ -413,6 +460,26 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([selectArtifact: () => null,selectVersion: (_, { artifactId }) => artifactId,openFromUrl: (_, { versionId }) => versionId,+ setFileDismissed: () => null,+ },+ ],+ /** Artifact id to the dismissed state this page set. The run manifests can be older than the change. */+ dismissals: [+ {} as Record<string, boolean>,+ {+ setFileDismissed: (state, { artifactIds, dismissed }) => ({+ ...state,+ ...Object.fromEntries(artifactIds.map((id) => [id, dismissed])),+ }),+ },+ ],+ dismissalPending: [+ false,+ {+ dismissFile: () => true,+ restoreFile: () => true,+ setFileDismissed: () => false,+ dismissalFailed: () => false,},],mediaById: [@@ -432,9 +499,12 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([}),selectors({artifacts: [- (s) => [s.selectedRun, s.chainRuns],- (selectedRun: TaskRunDetailDTOApi | null, chainRuns: TaskRunDetailDTOApi[]): RunArtifact[] =>- collectRunArtifacts([selectedRun, ...chainRuns]),+ (s) => [s.selectedRun, s.chainRuns, s.dismissals],+ (+ selectedRun: TaskRunDetailDTOApi | null,+ chainRuns: TaskRunDetailDTOApi[],+ dismissals: Record<string, boolean>+ ): RunArtifact[] => collectRunArtifacts([selectedRun, ...chainRuns], dismissals),],livingFiles: [(s) => [s.livingArtifacts],@@ -525,7 +595,7 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([},],}),- listeners(({ actions, values }) => {+ listeners(({ actions, values, props }) => {const loadSelectedText = (): void => {const artifact = values.selectedArtifactconst kind = values.selectedKind@@ -553,6 +623,30 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([...(source ? { source } : {}),})}+ /** One request per run, because each run holds its own manifest and a file's versions can span runs. */+ const setDismissed = async (versions: RunArtifact[], dismissed: boolean): Promise<string[]> => {+ if (values.currentProjectId === null) {+ throw new Error('No project')+ }+ const projectId = String(values.currentProjectId)+ const idsByRun = new Map<string, string[]>()+ for (const version of versions) {+ if (version.id) {+ idsByRun.set(version.runId, [...(idsByRun.get(version.runId) ?? []), version.id])+ }+ }+ await Promise.all(+ [...idsByRun].map(([runId, ids]) =>+ tasksRunsArtifactsDismissCreate(projectId, props.taskId, runId, { artifact_ids: ids, dismissed })+ )+ )+ return [...idsByRun.values()].flat()+ }+ const dismissalProperties = (file: ArtifactFile): Record<string, unknown> => ({+ kind: artifactPreviewKind(file.latest),+ object_kind: postHogObjectRef(file.latest)?.objectKind ?? null,+ version_count: file.versions.length,+ })return {setActiveTab: ({ tab }) => {if (tab === 'artifacts') {@@ -606,6 +700,50 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([posthog.capture('task artifact comments opened', { kind: values.selectedKind })}},+ reportFullPageOpened: ({ source }) => {+ // pinned: analytics event name and properties. Renaming them breaks insights.+ posthog.capture('task artifact full page opened', { kind: values.selectedKind, source })+ },+ dismissFile: async ({ fileKey }) => {+ const { files } = values+ const index = files.findIndex((entry) => entry.key === fileKey)+ const file = files[index]+ // No endpoint dismisses a living document, so the toolbar offers no dismissal for one.+ if (!file || file.latest.living) {+ actions.dismissalFailed()+ return+ }+ let ids: string[]+ try {+ ids = await setDismissed(file.versions, true)+ } catch {+ toast.error({ title: "Couldn't dismiss the artifact. Try again." })+ actions.dismissalFailed()+ return+ }+ // The list keeps its place: the next entry opens, or the one before for the last entry.+ const neighbor = files[index + 1] ?? files[index - 1] ?? null+ actions.setFileDismissed(ids, true, neighbor?.key ?? null)+ // pinned: analytics event name and properties. Renaming them breaks insights.+ posthog.capture('task artifact dismissed', dismissalProperties(file))+ toast({+ title: `Dismissed ${file.name}`,+ action: { label: 'Undo', onClick: () => actions.restoreFile(file) },+ })+ },+ restoreFile: async ({ file }) => {+ let ids: string[]+ try {+ ids = await setDismissed(file.versions, false)+ } catch {+ toast.error({ title: "Couldn't restore the artifact. Try again." })+ actions.dismissalFailed()+ return+ }+ actions.setFileDismissed(ids, false, file.key)+ // pinned: analytics event name and properties. Renaming them breaks insights.+ posthog.capture('task artifact restored', dismissalProperties(file))+ },openFromUrl: ({ versionId }) => {// pinned: analytics event name and properties. Renaming them breaks insights.posthog.capture('task artifact link opened', { has_version: !!versionId })@@ -630,7 +768,7 @@ export const taskRunArtifactsLogic = kea<taskRunArtifactsLogicType>([}return [pathname, next, hashParams, { replace: true }]}- return { setActiveTab: syncUrl, selectArtifact: syncUrl, selectVersion: syncUrl }+ return { setActiveTab: syncUrl, selectArtifact: syncUrl, selectVersion: syncUrl, setFileDismissed: syncUrl }}),urlToAction(({ actions, values, props }) => ({'*': (_, searchParams, __, { pathname }) => {