: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
import { useActions, useValues } from 'kea'
import { LemonLabel, LemonSelect, LemonTextArea, Link } from '@posthog/lemon-ui'
import { urls } from 'scenes/urls'
import { suggestionActionLogic } from '../logics/suggestionActionLogic'
import type { TurnSuggestionLogicProps } from '../logics/turnSuggestionLogic'
import { CADENCE_OPTIONS, SCOUT_MODE_HINTS, cadenceLabel } from '../utils/turnSuggestions'
import { SlackDestinationSection } from './SlackDestinationSection'
import { SuggestionAcceptedBanner } from './SuggestionAcceptedBanner'
import { SuggestionActionRow } from './SuggestionActionRow'
import { SuggestionDraftSummary } from './SuggestionDraftSummary'
export function ScoutSuggestionCard(props: TurnSuggestionLogicProps): JSX.Element | null {
const logic = suggestionActionLogic(props)
const { suggestion, cadence, scoutBody, accepted, slackChannelLabel } = useValues(logic)
const { setCadence, setScoutBody } = useActions(logic)
if (suggestion?.kind !== 'scout') {
return null
}
if (accepted) {
return (
<SuggestionAcceptedBanner accepted={accepted} linkLabel="View scout">
Scout created. It runs {cadenceLabel(cadence)} and posts to {slackChannelLabel}.
</SuggestionAcceptedBanner>
)
}
const modeHint = SCOUT_MODE_HINTS[suggestion.scout.mode]
return (
<>
<SuggestionDraftSummary name={suggestion.scout.displayName}>
{suggestion.scout.description && (
<span className="text-xs text-secondary">{suggestion.scout.description}</span>
)}
{modeHint && <span className="text-xs text-secondary">{modeHint}</span>}
</SuggestionDraftSummary>
<div className="flex flex-col gap-1">
<LemonLabel info="The scout follows these on every run. Review them before you create it.">
Instructions
</LemonLabel>
<LemonTextArea
value={scoutBody}
onChange={setScoutBody}
minRows={3}
maxRows={10}
data-attr="posthog-ai-turn-suggestion-scout-instructions"
/>
</div>
<div className="flex flex-col gap-1">
<LemonLabel>Runs</LemonLabel>
<LemonSelect
size="small"
value={cadence}
options={CADENCE_OPTIONS}
onChange={(value) => value && setCadence(value)}
/>
</div>
<SlackDestinationSection {...props} connectHint="Connect Slack to post each run to a channel." />
<SuggestionActionRow
{...props}
label="Create scout"
dataAttr="posthog-ai-turn-suggestion-create-scout"
failedMessage={
<>
Couldn't create the scout. Try again, or create it from the <Link to={urls.inbox()}>inbox</Link>
.
</>
}
/>
</>
)
}