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.

fix(wizard): preserve run table menus during refresh (#130321)

posthog[bot]f5c43f4fc6be
diff --git a/docs/internal/wizard-runs.md b/docs/internal/wizard-runs.md
index 6a5da6c209db..2008923bdd6d 100644
--- a/docs/internal/wizard-runs.md
+++ b/docs/internal/wizard-runs.md
@@ -77,6 +77,12 @@ Only the selected onboarding run or open run details request hydration; discover
Failed hydration waits 30 seconds before an automatic retry, and the onboarding retry button bypasses that delay.
Run details load only tasks into shared state and use the dialog's existing artifact request.
+### Runs table
+
+Refreshing the same run keeps its row actions menu open.
+The menu closes if sorting, filtering, or pagination replaces that row with a different run.
+Menu actions use the latest run data, permissions, and in-flight state.
+
### Onboarding state
The boolean flag `wizard-onboarding-cloud-runs-enabled` adds cloud and local tabs to both the standard and simple installation steps.
diff --git a/products/wizard/frontend/components/run/WizardRunTable.test.tsx b/products/wizard/frontend/components/run/WizardRunTable.test.tsx
new file mode 100644
index 000000000000..2b1b060c616a
--- /dev/null
+++ b/products/wizard/frontend/components/run/WizardRunTable.test.tsx
@@ -0,0 +1,97 @@
+import '@testing-library/jest-dom'
+
+import { cleanup, fireEvent, render, screen, within } from '@testing-library/react'
+import type { ComponentProps } from 'react'
+
+import { initKeaTests } from '~/test/init'
+
+import type { WizardRunApi } from '../../generated/api.schemas'
+import { WizardRunTable } from './WizardRunTable'
+
+const run: WizardRunApi = {
+ id: '00000000-0000-4000-8000-000000000001',
+ team_id: 1,
+ created_by_id: 1,
+ created_by: null,
+ environment: 'cloud',
+ workspace: { type: 'git_repository', repository: 'example/project' },
+ program: {
+ id: 'posthog-integration',
+ name: 'PostHog integration',
+ description: '',
+ command: [],
+ wizard_version: '1.0.0',
+ tags: [],
+ required_programs: [],
+ supported_environments: ['cloud'],
+ },
+ status: 'running',
+ stage: 'executing_wizard',
+ error_code: null,
+ error_message: null,
+ created_at: '2026-01-01T10:00:00Z',
+ updated_at: null,
+ started_at: null,
+ finished_at: null,
+ deadline_at: null,
+}
+
+describe('WizardRunTable', () => {
+ beforeEach(() => initKeaTests())
+ afterEach(() => cleanup())
+
+ it('keeps the actions menu open across refreshes and uses the latest run, state and callbacks', async () => {
+ const props: ComponentProps<typeof WizardRunTable> = {
+ runs: [run],
+ totalRuns: 1,
+ currentUserId: 1,
+ loading: false,
+ failed: false,
+ hasActiveFilters: false,
+ refreshing: false,
+ cancelling: false,
+ onOpenLibrary: jest.fn(),
+ onClearFilters: jest.fn(),
+ onRefreshRuns: jest.fn(),
+ onSelect: jest.fn(),
+ onRefreshRun: jest.fn(),
+ onCopyRunId: jest.fn(),
+ onOpenWorkspace: jest.fn(),
+ onPaginate: jest.fn(),
+ onCancel: jest.fn(),
+ }
+ const { rerender } = render(<WizardRunTable {...props} />)
+ fireEvent.click(screen.getByLabelText('More options for PostHog integration'))
+ const menu = await screen.findByRole('menu')
+ expect(within(menu).getByText('Cancel run')).not.toHaveAttribute('aria-disabled', 'true')
+
+ const refreshedRun: WizardRunApi = { ...run, program: { ...run.program }, stage: 'creating_artifacts' }
+ const onSelect = jest.fn()
+ rerender(
+ <WizardRunTable
+ {...props}
+ runs={[refreshedRun]}
+ refreshing
+ cancelling
+ highlightedRunId={run.id}
+ onSelect={onSelect}
+ />
+ )
+ expect(menu).toBeInTheDocument()
+ expect(within(menu).getByText('Refreshing…')).toHaveAttribute('aria-disabled', 'true')
+ expect(within(menu).getByText('Canceling…')).toHaveAttribute('aria-disabled', 'true')
+
+ rerender(<WizardRunTable {...props} runs={[refreshedRun]} currentUserId={null} onSelect={onSelect} />)
+ expect(menu).toBeInTheDocument()
+ expect(within(menu).getByText('Refresh status')).not.toHaveAttribute('aria-disabled', 'true')
+ expect(within(menu).queryByText('Cancel run')).not.toBeInTheDocument()
+ fireEvent.click(within(menu).getByText('View run details'))
+ expect(onSelect).toHaveBeenCalledWith(refreshedRun)
+ expect(props.onSelect).not.toHaveBeenCalled()
+
+ fireEvent.click(screen.getByLabelText('More options for PostHog integration'))
+ const reopenedMenu = await screen.findByRole('menu')
+ rerender(<WizardRunTable {...props} runs={[{ ...refreshedRun, id: 'replacement-run' }]} />)
+ expect(reopenedMenu).not.toBeInTheDocument()
+ })
+})
diff --git a/products/wizard/frontend/components/run/WizardRunTable.tsx b/products/wizard/frontend/components/run/WizardRunTable.tsx
index 7d3bac352c64..2305ccc9c7a1 100644
--- a/products/wizard/frontend/components/run/WizardRunTable.tsx
+++ b/products/wizard/frontend/components/run/WizardRunTable.tsx
@@ -1,3 +1,5 @@
+import { createContext, useContext } from 'react'
+
import { IconFolder, IconGithub } from '@posthog/icons'
import type { DataTableProps } from '@posthog/quill-components'
import { DataTable } from '@posthog/quill-components'
@@ -29,26 +31,7 @@ import { WizardRunStatusTag } from '../run-tags/WizardRunStatusTag'
import { WizardRunActionsMenu } from './WizardRunActionsMenu'
import { WizardRunsEmptyState } from './WizardRunsEmptyState'
-export function WizardRunTable({
- runs,
- totalRuns,
- highlightedRunId,
- currentUserId,
- loading,
- failed,
- hasActiveFilters,
- refreshing,
- cancelling,
- onOpenLibrary,
- onClearFilters,
- onRefreshRuns,
- onSelect,
- onRefreshRun,
- onCopyRunId,
- onOpenWorkspace,
- onPaginate,
- onCancel,
-}: {
+interface WizardRunTableProps {
runs: WizardRunApi[]
totalRuns: number
highlightedRunId?: string | null
@@ -67,125 +50,145 @@ export function WizardRunTable({
onOpenWorkspace: (run: WizardRunApi, url: string) => void
onPaginate: (page: number, nextPage: number) => void
onCancel: (run: WizardRunApi) => void
-}): JSX.Element {
- const columns: DataTableProps<WizardRunApi, unknown>['columns'] = [
- {
- accessorKey: 'program.name',
- header: 'Program',
- cell: ({ row }) => {
- const run = row.original
+}
+
+const WizardRunTableContext = createContext<Pick<
+ WizardRunTableProps,
+ | 'currentUserId'
+ | 'refreshing'
+ | 'cancelling'
+ | 'onSelect'
+ | 'onRefreshRun'
+ | 'onCopyRunId'
+ | 'onOpenWorkspace'
+ | 'onCancel'
+> | null>(null)
+
+// TanStack renders cell functions as components, so their identity must survive updates to the table context.
+const columns: DataTableProps<WizardRunApi, unknown>['columns'] = [
+ {
+ accessorKey: 'program.name',
+ header: 'Program',
+ cell: function ProgramCell({ row }) {
+ const { onSelect } = useContext(WizardRunTableContext)!
+ const run = row.original
+ return (
+ <Button variant="link-muted" size="sm" onClick={() => onSelect(run)}>
+ <span className="flex min-w-44 flex-col items-start text-left">
+ <span className="font-semibold">{run.program.name}</span>
+ <Text size="xs" variant="muted">
+ Wizard {run.program.wizard_version}
+ </Text>
+ </span>
+ </Button>
+ )
+ },
+ },
+ {
+ id: 'workspace',
+ header: 'Workspace',
+ enableSorting: false,
+ meta: { expand: true },
+ cell: function WorkspaceCell({ row }) {
+ const { onOpenWorkspace } = useContext(WizardRunTableContext)!
+ const run = row.original
+ if (run.workspace.type === 'git_repository') {
+ const url = wizardGithubRepositoryUrl(run.workspace.repository)
return (
- <Button variant="link-muted" size="sm" onClick={() => onSelect(run)}>
- <span className="flex min-w-44 flex-col items-start text-left">
- <span className="font-semibold">{run.program.name}</span>
- <Text size="xs" variant="muted">
- Wizard {run.program.wizard_version}
- </Text>
- </span>
+ <Button
+ variant="link-muted"
+ size="sm"
+ render={
+ <LinkPrimitive
+ to={url}
+ target="_blank"
+ onClick={(event) => {
+ event.stopPropagation()
+ onOpenWorkspace(run, url)
+ }}
+ />
+ }
+ >
+ <IconGithub />
+ {run.workspace.repository}
</Button>
)
- },
+ }
+ return (
+ <Text size="xs" className="flex h-6 items-center gap-1 px-2">
+ <IconFolder className="size-3" />
+ {wizardWorkspaceLabel(run)}
+ </Text>
+ )
},
- {
- id: 'workspace',
- header: 'Workspace',
- enableSorting: false,
- meta: { expand: true },
- cell: ({ row }) => {
- const run = row.original
- if (run.workspace.type === 'git_repository') {
- const url = wizardGithubRepositoryUrl(run.workspace.repository)
- return (
- <Button
- variant="link-muted"
- size="sm"
- render={
- <LinkPrimitive
- to={url}
- target="_blank"
- onClick={(event) => {
- event.stopPropagation()
- onOpenWorkspace(run, url)
- }}
- />
- }
- >
- <IconGithub />
- {run.workspace.repository}
- </Button>
- )
- }
+ },
+ {
+ id: 'created_by',
+ accessorFn: (run) => run.created_by?.first_name || run.created_by?.email || '',
+ header: 'Created by',
+ cell: ({ row }) => {
+ const creator = row.original.created_by
+ if (!creator) {
return (
- <Text size="xs" className="flex h-6 items-center gap-1 px-2">
- <IconFolder className="size-3" />
- {wizardWorkspaceLabel(run)}
+ <Text size="sm" variant="muted">
+ Unknown
</Text>
)
- },
- },
- {
- id: 'created_by',
- accessorFn: (run) => run.created_by?.first_name || run.created_by?.email || '',
- header: 'Created by',
- cell: ({ row }) => {
- const creator = row.original.created_by
- if (!creator) {
- return (
- <Text size="sm" variant="muted">
- Unknown
- </Text>
- )
- }
+ }
- const name = [creator.first_name, creator.last_name].filter(Boolean).join(' ') || creator.email
- const initials = creator.first_name
- ? `${creator.first_name[0]}${creator.last_name[0] ?? ''}`
- : creator.email[0]
+ const name = [creator.first_name, creator.last_name].filter(Boolean).join(' ') || creator.email
+ const initials = creator.first_name
+ ? `${creator.first_name[0]}${creator.last_name[0] ?? ''}`
+ : creator.email[0]
- return (
- <span className="flex min-w-0 items-center gap-2">
- <Avatar size="sm">
- <AvatarFallback>{initials}</AvatarFallback>
- </Avatar>
- <Text size="sm" className="max-w-40 truncate">
- {name}
- </Text>
- </span>
- )
- },
- },
- {
- accessorKey: 'environment',
- header: 'Environment',
- cell: ({ row }) => <WizardRunEnvironmentTag environment={row.original.environment} />,
- },
- {
- accessorKey: 'status',
- header: 'Status',
- cell: ({ row }) => {
- const run = row.original
- return <WizardRunStatusTag status={run.status} />
- },
- },
- {
- accessorKey: 'started_at',
- header: 'Started',
- cell: ({ row }) =>
- row.original.started_at ? (
- <TZLabel time={row.original.started_at} className="whitespace-nowrap text-xs" />
- ) : (
- <Text size="xs" variant="muted">
- Not started
+ return (
+ <span className="flex min-w-0 items-center gap-2">
+ <Avatar size="sm">
+ <AvatarFallback>{initials}</AvatarFallback>
+ </Avatar>
+ <Text size="sm" className="max-w-40 truncate">
+ {name}
</Text>
- ),
+ </span>
+ )
},
- {
- id: 'actions',
- header: () => <span className="sr-only">Actions</span>,
- enableSorting: false,
- meta: { align: 'right' },
- cell: ({ row }) => (
+ },
+ {
+ accessorKey: 'environment',
+ header: 'Environment',
+ cell: ({ row }) => <WizardRunEnvironmentTag environment={row.original.environment} />,
+ },
+ {
+ accessorKey: 'status',
+ header: 'Status',
+ cell: ({ row }) => {
+ const run = row.original
+ return <WizardRunStatusTag status={run.status} />
+ },
+ },
+ {
+ accessorKey: 'started_at',
+ header: 'Started',
+ cell: ({ row }) =>
+ row.original.started_at ? (
+ <TZLabel time={row.original.started_at} className="whitespace-nowrap text-xs" />
+ ) : (
+ <Text size="xs" variant="muted">
+ Not started
+ </Text>
+ ),
+ },
+ {
+ id: 'actions',
+ header: () => <span className="sr-only">Actions</span>,
+ enableSorting: false,
+ meta: { align: 'right' },
+ cell: function ActionsCell({ row }) {
+ const { currentUserId, refreshing, cancelling, onSelect, onRefreshRun, onCopyRunId, onCancel } =
+ useContext(WizardRunTableContext)!
+ return (
<WizardRunActionsMenu
+ key={row.original.id}
run={row.original}
currentUserId={currentUserId}
refreshing={refreshing}
@@ -195,10 +198,31 @@ export function WizardRunTable({
onCopyRunId={onCopyRunId}
onCancel={onCancel}
/>
- ),
+ )
},
- ]
+ },
+]
+export function WizardRunTable({
+ runs,
+ totalRuns,
+ highlightedRunId,
+ currentUserId,
+ loading,
+ failed,
+ hasActiveFilters,
+ refreshing,
+ cancelling,
+ onOpenLibrary,
+ onClearFilters,
+ onRefreshRuns,
+ onSelect,
+ onRefreshRun,
+ onCopyRunId,
+ onOpenWorkspace,
+ onPaginate,
+ onCancel,
+}: WizardRunTableProps): JSX.Element {
if (failed && totalRuns === 0) {
return (
<Item tone="destructive" variant="outline">
@@ -247,20 +271,33 @@ export function WizardRunTable({
</div>
) : (
<Card size="sm" flush className="overflow-hidden">
- <DataTable
- columns={columns}
- data={runs}
- empty={empty}
- pageSize={25}
- fullWidth
- onRowClick={onSelect}
- rowClassName={(run) =>
- run.id === highlightedRunId
- ? 'bg-fill-highlight-100 hover:bg-fill-highlight-100'
- : undefined
- }
- onPageChange={onPaginate}
- />
+ <WizardRunTableContext.Provider
+ value={{
+ currentUserId,
+ refreshing,
+ cancelling,
+ onSelect,
+ onRefreshRun,
+ onCopyRunId,
+ onOpenWorkspace,
+ onCancel,
+ }}
+ >
+ <DataTable
+ columns={columns}
+ data={runs}
+ empty={empty}
+ pageSize={25}
+ fullWidth
+ onRowClick={onSelect}
+ rowClassName={(run) =>
+ run.id === highlightedRunId
+ ? 'bg-fill-highlight-100 hover:bg-fill-highlight-100'
+ : undefined
+ }
+ onPageChange={onPaginate}
+ />
+ </WizardRunTableContext.Provider>
</Card>
)}
</div>