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.5 KB
Raw Blame
import { useValues } from 'kea'

import { LemonInputSelect, LemonInputSelectOption } from '@posthog/lemon-ui'

import type { CustomInputRendererProps } from 'lib/components/CyclotronJob/customInputRenderers'

import { scoutDisplayName } from 'products/signals/frontend/inbox/utils/scoutRunsWindow'

import { scoutPickerLogic } from './scoutPickerLogic'

export default function CyclotronJobInputScoutPicker({ value, onChange }: CustomInputRendererProps): JSX.Element {
    const { scoutConfigs, scoutConfigsLoading } = useValues(scoutPickerLogic)

    const selected = typeof value === 'string' ? value : ''
    const options: LemonInputSelectOption[] = scoutConfigs.map((config) => ({
        key: config.skill_name,
        label: config.enabled ? scoutDisplayName(config) : `${scoutDisplayName(config)} (paused)`,
    }))
    // A stored skill name that isn't in this team's fleet (deleted since, or authored
    // elsewhere) still needs to render as itself, not as blank.
    if (selected && !options.some((option) => option.key === selected)) {
        options.push({ key: selected, label: selected })
    }

    return (
        <LemonInputSelect
            mode="single"
            data-attr="select-signals-scout"
            placeholder={scoutConfigsLoading ? 'Loading scouts...' : 'Select a scout...'}
            value={selected ? [selected] : []}
            onChange={(val) => onChange(val[0] ?? null)}
            options={options}
            loading={scoutConfigsLoading}
        />
    )
}