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.

1.3 KB
Raw Blame
import { MakeLogicType, actions, kea, path } from 'kea'

import { ResourceEditedEvent } from '~/types'

/** Discriminator on `notification_type` for transient "edited elsewhere" events on the SSE stream. */
export const RESOURCE_EDITED_EVENT_TYPE = 'resource_edited'

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface resourceEditedLogicActions {
    resourceEdited: (event: ResourceEditedEvent) => {
        event: ResourceEditedEvent
    }
}

export type resourceEditedLogicType = MakeLogicType<{}, resourceEditedLogicActions>

/**
 * A tiny event bus that decouples the notifications SSE consumer from editors that care about
 * "this resource was edited elsewhere" events. The SSE consumer (sidePanelNotificationsLogic)
 * forwards matching events here; interested editors (e.g. workflowLogic) connect to the
 * `resourceEdited` action and decide what to do — silently refresh or warn before clobbering.
 *
 * Kept deliberately logic-free so neither side has to depend on the other's internals.
 */
export const resourceEditedLogic = kea<resourceEditedLogicType>([
    path(['products', 'notifications', 'frontend', 'resourceEditedLogic']),
    actions({
        resourceEdited: (event: ResourceEditedEvent) => ({ event }),
    }),
])