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(replay-vision): edit action + show its guidance on the action page (#67247)

Kim Svatos Dugan58a6070d0b4d
diff --git a/products/replay_vision/frontend/replay_scanners/VisionActionScene.tsx b/products/replay_vision/frontend/replay_scanners/VisionActionScene.tsx
index c8fe5ad725d6..708e6b96d04a 100644
--- a/products/replay_vision/frontend/replay_scanners/VisionActionScene.tsx
+++ b/products/replay_vision/frontend/replay_scanners/VisionActionScene.tsx
@@ -1,15 +1,23 @@
-import { BindLogic, useValues } from 'kea'
+import { BindLogic, useActions, useValues } from 'kea'
+import { IconPencil } from '@posthog/icons'
+import { LemonButton, LemonCard } from '@posthog/lemon-ui'
+
+import { AccessControlAction } from 'lib/components/AccessControlAction'
import { SceneExport } from 'scenes/sceneTypes'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
import { ProductKey } from '~/queries/schema/schema-general'
+import { AccessControlLevel, AccessControlResourceType } from '~/types'
+import type { VisionActionApi } from '../generated/api.schemas'
import { humanizeCadence, parseRruleToCadence } from './cadence'
+import { VisionActionForm } from './components/VisionActionForm'
import { VisionActionRuns } from './components/VisionActionRuns'
import { visionActionRunsLogic } from './visionActionRunsLogic'
import { visionActionSceneLogic } from './visionActionSceneLogic'
+import { visionActionsLogic } from './visionActionsLogic'
export const scene: SceneExport = {
component: VisionActionSceneComponent,
@@ -17,20 +25,73 @@ export const scene: SceneExport = {
productKey: ProductKey.REPLAY_VISION,
}
+// The title bar, current-guidance panel, and edit modal — shown once the action loads. Bound to
+// visionActionsLogic (keyed by the scanner) so the shared create/edit form drives the modal here too.
+function ActionOverview({
+ action,
+ scheduleLabel,
+}: {
+ action: VisionActionApi
+ scheduleLabel: string | null
+}): JSX.Element {
+ const { openEditForm } = useActions(visionActionsLogic)
+ const guidance = action.synthesis_config?.prompt_guide?.trim()
+
+ return (
+ <>
+ <SceneTitleSection
+ name={action.name}
+ description={scheduleLabel ? `Runs ${scheduleLabel.toLowerCase()}` : undefined}
+ resourceType={{ type: 'replay_vision' }}
+ actions={
+ <AccessControlAction
+ resourceType={AccessControlResourceType.SessionRecording}
+ minAccessLevel={AccessControlLevel.Editor}
+ >
+ <LemonButton
+ type="secondary"
+ icon={<IconPencil />}
+ onClick={() => openEditForm(action)}
+ data-attr="vision-action-edit-from-page"
+ >
+ Edit
+ </LemonButton>
+ </AccessControlAction>
+ }
+ />
+ <LemonCard hoverEffect={false} className="p-4">
+ <div className="text-xs font-semibold uppercase text-secondary mb-1">Summary guidance</div>
+ {guidance ? (
+ <p className="m-0 whitespace-pre-wrap">{guidance}</p>
+ ) : (
+ <p className="m-0 text-muted italic">
+ No guidance set — the AI summarizes this scanner's observations freely. Edit the action to steer
+ it.
+ </p>
+ )}
+ </LemonCard>
+ <VisionActionForm scannerId={action.scanner} />
+ </>
+ )
+}
+
function VisionActionDetail(): JSX.Element {
const { action, actionLoading } = useValues(visionActionRunsLogic)
-
- const title = action?.name ?? (actionLoading ? 'Loading…' : 'Action runs')
const rrule = action?.trigger_config?.rrule
const schedule = rrule ? humanizeCadence(parseRruleToCadence(rrule)) : null
return (
<SceneContent>
- <SceneTitleSection
- name={title}
- description={schedule ? `Runs ${schedule.toLowerCase()}` : undefined}
- resourceType={{ type: 'replay_vision' }}
- />
+ {action ? (
+ <BindLogic logic={visionActionsLogic} props={{ scannerId: action.scanner }}>
+ <ActionOverview action={action} scheduleLabel={schedule} />
+ </BindLogic>
+ ) : (
+ <SceneTitleSection
+ name={actionLoading ? 'Loading…' : 'Action runs'}
+ resourceType={{ type: 'replay_vision' }}
+ />
+ )}
<VisionActionRuns />
</SceneContent>
)
diff --git a/products/replay_vision/frontend/replay_scanners/visionActionsLogic.ts b/products/replay_vision/frontend/replay_scanners/visionActionsLogic.ts
index df38b867da5f..b5797b621439 100644
--- a/products/replay_vision/frontend/replay_scanners/visionActionsLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/visionActionsLogic.ts
@@ -14,6 +14,7 @@ import {
import { DeliveryTargetTypeEnumApi } from '../generated/api.schemas'
import type { VisionActionApi } from '../generated/api.schemas'
import { CadenceState, cadenceToRrule, DEFAULT_CADENCE, parseRruleToCadence } from './cadence'
+import { visionActionRunsLogic } from './visionActionRunsLogic'
import type { visionActionsLogicType } from './visionActionsLogicType'
export interface VisionActionsLogicProps {
@@ -224,9 +225,18 @@ export const visionActionsLogic = kea<visionActionsLogicType>([
},
submitVisionActionFormSuccess: () => {
- lemonToast.success(values.editingAction ? 'Action updated' : 'Action created')
+ // Capture before closeForm() clears editingAction.
+ const edited = values.editingAction
+ lemonToast.success(edited ? 'Action updated' : 'Action created')
actions.closeForm()
actions.loadActions()
+ // If this edit came from the action's own page, refresh it in place. findMounted acts only
+ // when that page is open (returns null otherwise) — no key coupling, no accidental mount.
+ if (edited) {
+ const runsLogic = visionActionRunsLogic.findMounted({ actionId: edited.id })
+ runsLogic?.actions.loadAction()
+ runsLogic?.actions.loadRuns()
+ }
},
submitVisionActionFormFailure: ({ error }: { error?: Error & { detail?: string } }) => {