: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
feat(inbox): some ui clean up + scratchpad viewer (#65673)
Andrew Maguirea7c164248062
diff --git a/frontend/src/scenes/inbox/InboxScene.tsx b/frontend/src/scenes/inbox/InboxScene.tsxindex 59dd8475ad0c..312029149f09 100644--- a/frontend/src/scenes/inbox/InboxScene.tsx+++ b/frontend/src/scenes/inbox/InboxScene.tsx@@ -1,6 +1,6 @@import { useActions, useValues } from 'kea'-import { IconBug } from '@posthog/icons'+import { IconArrowLeft, IconBug } from '@posthog/icons'import { LemonButton, Tooltip } from '@posthog/lemon-ui'import { useResizeBreakpoints } from 'lib/hooks/useResizeObserver'@@ -15,6 +15,7 @@ import { AgentRunDetail } from './components/detail/AgentRunDetail'import { InboxDetailHeader } from './components/detail/InboxDetailHeader'import { ReportDetail, ReportDetailSkeleton } from './components/detail/ReportDetail'import { InboxOnboardingBanner, InboxOnboardingTakeover } from './components/onboarding/InboxOnboarding'+import { ScratchpadPanel } from './components/scratchpad/ScratchpadPanel'import { AgentSetupColumn } from './components/shell/AgentSetupColumn'import { InboxScopeSelect } from './components/shell/InboxScopeSelect'import { InboxTabBar } from './components/shell/InboxTabBar'@@ -135,6 +136,31 @@ function InboxDetailView({ report }: { report: SignalReport }): JSX.Element {)}+/**+ * Fleet-memory (scratchpad) detail surface: the browse/search panel under a back link, rendered+ * full-width over the list like the scout detail. Reached from the fleet-memory callout.+ */+function InboxScratchpadView(): JSX.Element {+ const { setScratchpadOpen } = useActions(inboxSceneLogic)++ return (+ <div className="flex flex-col min-h-0 flex-1 overflow-auto">+ <div className="px-4 pt-3">+ <LemonButton+ type="tertiary"+ size="small"+ icon={<IconArrowLeft />}+ onClick={() => setScratchpadOpen(false)}+ className="self-start"+ >+ Scouts+ </LemonButton>+ </div>+ <ScratchpadPanel />+ </div>+ )+}+export function InboxScene(): JSX.Element {const {isRunningSessionAnalysis,@@ -142,6 +168,7 @@ export function InboxScene(): JSX.Element {selectedReport,selectedReportLoading,selectedScoutSkillName,+ isScratchpadOpen,} = useValues(inboxSceneLogic)const { runSessionAnalysis } = useActions(inboxSceneLogic)const { onboardingMode } = useValues(inboxOnboardingLogic)@@ -151,7 +178,7 @@ export function InboxScene(): JSX.Element {// stays *mounted* (just hidden) rather than being unmounted. That keeps `reportListLogic` and the scroll// container alive, so clicking "back" lands on the same scroll position with the same loaded pages —// instead of remounting and resetting to the first page at the top.- const showDetail = !!selectedReportId || !!selectedScoutSkillName+ const showDetail = !!selectedReportId || !!selectedScoutSkillName || isScratchpadOpenreturn (<SceneContent className="gap-y-0 border-b-0 flex-1 min-h-0">@@ -192,7 +219,9 @@ export function InboxScene(): JSX.Element {{showDetail && (<div className="flex flex-col -mx-4 flex-1 min-h-0">- {selectedScoutSkillName ? (+ {isScratchpadOpen ? (+ <InboxScratchpadView />+ ) : selectedScoutSkillName ? (<ScoutDetailView skillName={selectedScoutSkillName} />) : selectedReport ? (<InboxDetailView report={selectedReport} />diff --git a/frontend/src/scenes/inbox/components/InboxReportList.tsx b/frontend/src/scenes/inbox/components/InboxReportList.tsxindex fb19199c8d11..d3e01d3009e3 100644--- a/frontend/src/scenes/inbox/components/InboxReportList.tsx+++ b/frontend/src/scenes/inbox/components/InboxReportList.tsx@@ -66,8 +66,8 @@ function InboxReportListInner({ tabKey, Card, emptyState }: InboxReportListProps// The list stays mounted (hidden) while a report/scout detail is open, so gate the view event on// the list actually being the visible surface — otherwise a deep-link to a report fires a phantom// `Inbox viewed` and then suppresses the real one when the user navigates back to the list.- const { selectedReportId, selectedScoutSkillName } = useValues(inboxSceneLogic)- const listVisible = !selectedReportId && !selectedScoutSkillName+ const { selectedReportId, selectedScoutSkillName, isScratchpadOpen } = useValues(inboxSceneLogic)+ const listVisible = !selectedReportId && !selectedScoutSkillName && !isScratchpadOpenconst sentinelRef = useRef<HTMLDivElement>(null)// Fire `Inbox viewed` once per tab mount, the first time its list settles while visible.diff --git a/frontend/src/scenes/inbox/components/config/scouts/FleetMemoryCallout.tsx b/frontend/src/scenes/inbox/components/config/scouts/FleetMemoryCallout.tsxnew file mode 100644index 000000000000..9fcbdc199d7e--- /dev/null+++ b/frontend/src/scenes/inbox/components/config/scouts/FleetMemoryCallout.tsx@@ -0,0 +1,47 @@+import { useValues } from 'kea'++import { IconArrowRight, IconNotebook } from '@posthog/icons'++import { TZLabel } from 'lib/components/TZLabel'+import { pluralize } from 'lib/utils/strings'++import { scratchpadLogic } from '../../../logics/scratchpadLogic'++/**+ * Scratchpad stat card for the scout troop list. Surfaces that the scouts have jotted down context+ * about this project — count + recency hint at what they're picking up — and links into the full+ * scratchpad browse/search surface. Renders nothing until there is at least one note, so a fresh+ * project isn't nudged toward an empty page.+ */+export function FleetMemoryCallout({ onOpen }: { onOpen: () => void }): JSX.Element | null {+ const { entries, totalCount, lastUpdatedAt } = useValues(scratchpadLogic)++ // Hold until the first load settles, then only show when there's something to read.+ if (entries === null || !totalCount) {+ return null+ }++ return (+ <button+ type="button"+ onClick={onOpen}+ className="flex w-full items-center gap-3 rounded border border-primary bg-bg-light px-4 py-3.5 text-left transition-colors hover:border-primary-3000 hover:bg-bg-3000"+ >+ <IconNotebook className="size-5 shrink-0 text-primary-3000" />+ <div className="flex min-w-0 flex-col">+ <span className="text-sm font-medium text-default">Scout scratchpad</span>+ <span className="truncate text-xs text-secondary leading-snug">+ {pluralize(totalCount, 'note')} your scouts have jotted down about this project+ {lastUpdatedAt ? (+ <>+ {' · updated '}+ <TZLabel time={lastUpdatedAt} />+ </>+ ) : null}+ </span>+ </div>+ <span className="flex-1" />+ <IconArrowRight className="size-4 shrink-0 text-muted" />+ </button>+ )+}diff --git a/frontend/src/scenes/inbox/components/config/scouts/ScoutHelperSkillLinks.tsx b/frontend/src/scenes/inbox/components/config/scouts/ScoutHelperSkillLinks.tsxindex 9e3c816f7106..b9ec3e2ef602 100644--- a/frontend/src/scenes/inbox/components/config/scouts/ScoutHelperSkillLinks.tsx+++ b/frontend/src/scenes/inbox/components/config/scouts/ScoutHelperSkillLinks.tsx@@ -1,17 +1,29 @@import { Link } from '@posthog/lemon-ui'+// General "learn more" entry point for scouts.+const SCOUTS_DOCS_URL = 'https://posthog.com/docs/self-driving/scouts'+// Desktop opens these two scout helper skills in its in-app Skills view; cloud has-// no in-app Skills surface, so they link out to the equivalent PostHog docs.+// no in-app Skills surface, so they link out to the skill source on GitHub.const HELPER_SKILLS = [- { label: 'authoring scouts', url: 'https://posthog.com/docs/signals' },- { label: 'exploring scouts', url: 'https://posthog.com/docs/signals' },+ {+ label: 'authoring scouts',+ url: 'https://github.com/PostHog/ai-plugin/blob/main/skills/authoring-signals-scouts/SKILL.md',+ },+ {+ label: 'exploring scouts',+ url: 'https://github.com/PostHog/ai-plugin/blob/main/skills/exploring-signals-scouts/SKILL.md',+ },]-/** One-line pointer to the two official scout helper skills. */+/** One-line footer: a "learn more" docs link plus pointers to the two official scout helper skills. */export function ScoutHelperSkillLinks(): JSX.Element {return (<span className="text-xs text-muted">- Helper skills:{' '}+ <Link to={SCOUTS_DOCS_URL} target="_blank">+ Learn more about scouts+ </Link>+ {' · Helper skills: '}{HELPER_SKILLS.map((skill, index) => (<span key={skill.label}>{index > 0 ? ' · ' : null}diff --git a/frontend/src/scenes/inbox/components/config/scouts/ScoutsFleetSection.tsx b/frontend/src/scenes/inbox/components/config/scouts/ScoutsFleetSection.tsxindex 68edcaf6b077..d538d62d521b 100644--- a/frontend/src/scenes/inbox/components/config/scouts/ScoutsFleetSection.tsx+++ b/frontend/src/scenes/inbox/components/config/scouts/ScoutsFleetSection.tsx@@ -1,15 +1,15 @@import { useActions, useValues } from 'kea'import { useEffect } from 'react'-import { IconChevronDown, IconCompass, IconPlus, IconSparkles } from '@posthog/icons'-import { LemonBanner, LemonButton, LemonSkeleton, LemonSwitch } from '@posthog/lemon-ui'+import { IconCompass, IconPlus, IconSparkles } from '@posthog/icons'+import { LemonBanner, LemonButton, LemonSkeleton } from '@posthog/lemon-ui'import { TZLabel } from 'lib/components/TZLabel'import { percentage } from 'lib/utils/numbers'import { pluralize } from 'lib/utils/strings'+import { inboxSceneLogic } from '../../../inboxSceneLogic'import { scoutFleetLogic } from '../../../logics/scoutFleetLogic'-import { signalSourcesLogic } from '../../../signalSourcesLogic'import { SignalScoutConfig } from '../../../types'import {FleetSummary,@@ -19,17 +19,22 @@ import {SCOUT_RUNS_WINDOW_SPAN,scoutRunsWindowLabel,} from '../../../utils/scoutRunsWindow'+import { agentSetupModalLogic } from '../../shell/agentSetupModalLogic'+import { FleetMemoryCallout } from './FleetMemoryCallout'import { ScoutHelperSkillLinks } from './ScoutHelperSkillLinks'import { ScoutRowCard } from './ScoutRowCard'/**- * Expandable scout troop manager, hosted in the Scout troop setup modal. Collapsed it is a- * one-line pulse; expanded it lists every scout with inline config controls.+ * Scout troop manager, hosted in the Scout troop setup modal (and the Agents settings tab). Both+ * hosts already title the section "Scout troop", so this always shows the full fleet: a stats+ * header (roster + run pulse) followed by every scout with inline config controls.* Cloud port of desktop's `ScoutsFleetSection`.*/export function ScoutsFleetSection(): JSX.Element {- const { scoutConfigs, scoutConfigsLoading, expanded, enabledCount, lastRunAt } = useValues(scoutFleetLogic)- const { setExpanded, loadScoutConfigs, startRunsPolling, stopRunsPolling } = useActions(scoutFleetLogic)+ const { scoutConfigs, scoutConfigsLoading } = useValues(scoutFleetLogic)+ const { loadScoutConfigs, startRunsPolling, stopRunsPolling } = useActions(scoutFleetLogic)+ const { setScratchpadOpen } = useActions(inboxSceneLogic)+ const { closeSetupModal } = useActions(agentSetupModalLogic)// Poll the runs window only while the fleet list is open — the always-mounted setup// widget reads configs only and shouldn't trigger the paginated runs requests.@@ -70,33 +75,16 @@ export function ScoutsFleetSection(): JSX.Element {return (<div className="flex flex-col gap-3"><ScoutAlphaBanner />- <ScoutsSourceGate />- <button- type="button"- onClick={() => setExpanded(!expanded)}- aria-expanded={expanded}- className="flex w-full items-center justify-between gap-3 rounded border border-primary bg-bg-light px-4 py-3.5 text-left transition-colors hover:border-primary-3000 hover:bg-bg-3000"- >- <div className="flex items-center gap-3 min-w-0">- <IconCompass className="size-5 shrink-0 text-primary-3000" />- <div className="flex flex-col min-w-0">- <span className="font-medium text-sm text-default">Scout troop</span>- <span className="text-xs text-secondary leading-snug">- {enabledCount} of {scoutConfigs.length} scouts enabled- {lastRunAt ? (- <>- {' · last dispatched '}- <TZLabel time={lastRunAt} />- </>- ) : null}- </span>- </div>- </div>- <IconChevronDown- className={`size-4 shrink-0 text-muted transition-transform ${expanded ? '' : '-rotate-90'}`}- />- </button>- {expanded ? <ScoutsFleetList /> : null}+ <FleetStatsHeader />+ <FleetMemoryCallout+ onOpen={() => {+ // This section can render inside the scout-troop setup modal; dismiss it so the+ // memory view isn't left hidden behind the portal'd modal. No-op outside a modal.+ closeSetupModal()+ setScratchpadOpen(true)+ }}+ />+ <ScoutsFleetList /></div>)}@@ -118,51 +106,6 @@ function ScoutAlphaBanner(): JSX.Element | null {)}-/**- * Team-level gate that decides whether scout findings emit to the inbox. Backed by the single- * `signals_scout` / `cross_source_issue` source config row — the same gate the backend emit- * preflight requires and the Code app toggles — so there is one source of truth, not a parallel- * control. It governs emit only: scouts still run on their schedule when this is off, so the copy- * is deliberately about findings reaching the inbox rather than "running scouts".- *- * This is also the natural home for a future unified switch that drives enrolment (run + emit)- * from one user action, retiring the manual coordinator allowlist — keep new scout on/off wiring- * here rather than adding a second control elsewhere.- */-function ScoutsSourceGate(): JSX.Element {- const { scoutsSourceConfig, isScoutsSourceToggling, sourceConfigs, sourceConfigsLoading } =- useValues(signalSourcesLogic)- const { toggleScoutsSource, loadSourceConfigs } = useActions(signalSourcesLogic)-- useEffect(() => {- loadSourceConfigs()- }, [loadSourceConfigs])-- const enabled = scoutsSourceConfig?.enabled ?? false- const initialLoading = sourceConfigsLoading && sourceConfigs === null-- return (- <div className="flex items-center gap-3 rounded border border-primary bg-bg-light px-4 py-3.5">- <div className="flex flex-col min-w-0">- <span className="font-medium text-sm text-default">Surface findings in your inbox</span>- <span className="text-xs text-secondary leading-snug">- Scouts run on their schedule regardless; this controls whether their findings reach your inbox.- </span>- </div>- <span className="flex-1" />- <LemonSwitch- aria-label="Surface scout findings in your inbox"- checked={enabled}- onChange={() => toggleScoutsSource()}- loading={isScoutsSourceToggling}- disabledReason={- initialLoading || (!isScoutsSourceToggling && sourceConfigs === null) ? 'Loading…' : undefined- }- />- </div>- )-}-/** One-line fleet pulse: running, success rate, signals emitted + emit rate. */function summarize(summary: FleetSummary | null): string {if (!summary) {@@ -180,27 +123,47 @@ function summarize(summary: FleetSummary | null): string {return parts.join(' · ')}-function ScoutsFleetList(): JSX.Element {- const { visibleConfigs, rollups, fleetSummary, hideDisabled, runsWindowComplete } = useValues(scoutFleetLogic)- const { setHideDisabled, updateScoutConfig } = useActions(scoutFleetLogic)+/**+ * Top-of-modal troop summary: roster (enabled / total + last dispatched) over the run pulse+ * (running / success / signals emitted across the window). Sits above the toggle row so the modal+ * leads with "what the troop is" before its controls.+ */+function FleetStatsHeader(): JSX.Element {+ const { scoutConfigs, enabledCount, lastRunAt, fleetSummary, runsWindowComplete } = useValues(scoutFleetLogic)return (- <div className="flex flex-col gap-3">+ <div className="flex flex-col gap-0.5"><div className="flex items-center gap-2 flex-wrap">- <span className="text-xs text-secondary">- {summarize(fleetSummary)}- <span className="text-muted"> · {scoutRunsWindowLabel(runsWindowComplete)}</span>+ <span className="text-sm font-medium text-default">+ {enabledCount} of {scoutConfigs?.length ?? enabledCount} scouts enabled</span>- <span className="flex-1" />- <LemonButton size="xsmall" type="tertiary" onClick={() => setHideDisabled(!hideDisabled)}>- {hideDisabled ? 'Show disabled' : 'Hide disabled'}- </LemonButton>+ {lastRunAt ? (+ <span className="text-xs text-secondary">+ last dispatched <TZLabel time={lastRunAt} />+ </span>+ ) : null}</div>+ <span className="text-xs text-muted">+ {summarize(fleetSummary)} · {scoutRunsWindowLabel(runsWindowComplete)}+ </span>+ </div>+ )+}+function ScoutsFleetList(): JSX.Element {+ const { visibleConfigs, rollups, hideDisabled } = useValues(scoutFleetLogic)+ const { setHideDisabled, updateScoutConfig } = useActions(scoutFleetLogic)++ return (+ <div className="flex flex-col gap-3"><div className="flex items-center gap-2 flex-wrap"><ScoutChatCta label="How is my scout troop performing?" prompt={SCOUT_FLEET_OVERVIEW_PROMPT} /><ScoutChatCta label="What signals were emitted recently?" prompt={SCOUT_RECENT_SIGNALS_PROMPT} /><ScoutChatCta label="Make a scout" prompt={SCOUT_AUTHOR_PROMPT} icon={<IconPlus />} />+ <span className="flex-1" />+ <LemonButton size="xsmall" type="tertiary" onClick={() => setHideDisabled(!hideDisabled)}>+ {hideDisabled ? 'Show disabled' : 'Hide disabled'}+ </LemonButton></div>{/* The enclosing modal owns the scroll, so the list stays flat here — a nesteddiff --git a/frontend/src/scenes/inbox/components/scratchpad/ScratchpadEntryCard.tsx b/frontend/src/scenes/inbox/components/scratchpad/ScratchpadEntryCard.tsxnew file mode 100644index 000000000000..79a1599cb7b8--- /dev/null+++ b/frontend/src/scenes/inbox/components/scratchpad/ScratchpadEntryCard.tsx@@ -0,0 +1,117 @@+import { type ComponentProps, useState } from 'react'++import { IconChevronDown, IconClock } from '@posthog/icons'+import { LemonTag, Link } from '@posthog/lemon-ui'++import { dayjs } from 'lib/dayjs'+import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'+import { humanFriendlyDetailedTime } from 'lib/utils/datetime'++import type { ScratchpadEntryApi } from 'products/signals/frontend/generated/api.schemas'++type LemonTagType = ComponentProps<typeof LemonTag>['type']++// The key prefix (everything before the first colon) encodes the note's *kind* — what the scout+// was doing when it wrote it. Surface it as a colored tag so the list scans at a glance.+const KIND_TAG_TYPE: Record<string, LemonTagType> = {+ pattern: 'highlight',+ dedupe: 'muted',+ noise: 'muted',+ baseline: 'success',+ watch: 'warning',+ watchlist: 'warning',+ coverage: 'completion',+ emerging: 'primary',+ explore: 'option',+ tags: 'option',+ recheck: 'caution',+}++function splitKey(key: string): { kind: string | null; body: string } {+ const idx = key.indexOf(':')+ return idx > 0 ? { kind: key.slice(0, idx), body: key.slice(idx + 1) } : { kind: null, body: key }+}++// `signals-scout-apm` → `apm`. The fleet prefix is noise once you're inside the scouts surface.+function scoutDisplayName(skill: string): string {+ return skill.replace(/^signals-scout-/, '')+}++/**+ * One scratchpad note the scout fleet has written about this project. Shares the collapse/expand+ * grammar of the scout emission cards: a header (chevron · kind · key · updated time) that stays+ * visible, a 2-line markdown preview when collapsed, the full body plus an attribution footer+ * (which scout created it, when, and how long it's been carried forward) when open.+ */+export function ScratchpadEntryCard({ entry }: { entry: ScratchpadEntryApi }): JSX.Element {+ const [expanded, setExpanded] = useState(false)++ const { kind, body } = splitKey(entry.key)+ const scoutName = entry.created_by_skill ? scoutDisplayName(entry.created_by_skill) : null++ // How long the note has been carried forward: a fresh creation reads ~0 days; a large gap+ // means the fleet has re-touched this learning across many runs — the "gets sharper" signal.+ const maintainedDays =+ entry.created_at && entry.updated_at ? dayjs(entry.updated_at).diff(dayjs(entry.created_at), 'day') : 0++ return (+ <div className="flex flex-col rounded border border-primary bg-bg-light">+ <button+ type="button"+ onClick={() => setExpanded((value) => !value)}+ className="flex items-center gap-2 px-3 py-2 text-left"+ aria-expanded={expanded}+ >+ <IconChevronDown+ className={`size-4 shrink-0 text-muted transition-transform ${expanded ? '' : '-rotate-90'}`}+ />+ {kind && (+ <LemonTag type={KIND_TAG_TYPE[kind] ?? 'muted'} size="small" className="shrink-0">+ {kind}+ </LemonTag>+ )}+ <span className="truncate font-mono text-xs text-primary">{body}</span>+ <span className="flex-1" />+ {entry.updated_at && (+ <span className="flex items-center gap-1 whitespace-nowrap text-[11px] text-muted">+ <IconClock className="size-3" />+ {humanFriendlyDetailedTime(entry.updated_at)}+ </span>+ )}+ </button>++ <div className="px-3 pb-2 pl-9">+ <LemonMarkdown+ disableImages+ className={expanded ? 'text-sm text-primary' : 'text-sm text-primary line-clamp-2'}+ >+ {entry.content || '_No content._'}+ </LemonMarkdown>++ {expanded && (entry.created_at || scoutName || entry.created_by_run_id) && (+ <div className="flex flex-wrap items-center gap-x-3 gap-y-1 border-t pt-2 mt-2 text-xs text-tertiary">+ {entry.created_at && <span>Created {humanFriendlyDetailedTime(entry.created_at)}</span>}+ {maintainedDays >= 1 && (+ <span>· carried forward {maintainedDays === 1 ? '1 day' : `${maintainedDays} days`}</span>+ )}+ <span className="flex-1" />+ {(scoutName || entry.created_by_run_id) && (+ <span className="shrink-0">+ by{' '}+ {entry.created_by_run_url ? (+ <Link to={entry.created_by_run_url}>+ {scoutName ? `${scoutName} scout` : 'a scout'}+ </Link>+ ) : scoutName ? (+ `${scoutName} scout`+ ) : (+ 'a scout'+ )}+ </span>+ )}+ </div>+ )}+ </div>+ </div>+ )+}diff --git a/frontend/src/scenes/inbox/components/scratchpad/ScratchpadPanel.tsx b/frontend/src/scenes/inbox/components/scratchpad/ScratchpadPanel.tsxnew file mode 100644index 000000000000..21934db4d51b--- /dev/null+++ b/frontend/src/scenes/inbox/components/scratchpad/ScratchpadPanel.tsx@@ -0,0 +1,166 @@+import { useActions, useValues } from 'kea'++import { IconChevronDown, IconClock, IconNotebook, IconStack } from '@posthog/icons'+import { LemonButton, LemonInput, LemonSegmentedButton, LemonSkeleton } from '@posthog/lemon-ui'++import { TZLabel } from 'lib/components/TZLabel'+import { pluralize } from 'lib/utils/strings'++import { scratchpadLogic } from '../../logics/scratchpadLogic'+import { ScratchpadEntryCard } from './ScratchpadEntryCard'++/**+ * Browse + search surface for the scout fleet's scratchpad (`SignalScratchpad`). Frames what the+ * scratchpad is up top (the context scouts jot down + how much has accumulated), then lets the user+ * read it newest-first or clustered by topic, and search it via the endpoint's ILIKE.+ *+ * Read-only: the harness writes scratchpad notes on internal scope; humans inspect them here.+ */+export function ScratchpadPanel(): JSX.Element {+ const {+ entries,+ entriesLoading,+ loadFailed,+ totalCount,+ lastUpdatedAt,+ groups,+ searchText,+ grouping,+ expandedNamespaces,+ } = useValues(scratchpadLogic)+ const { setSearchText, setGrouping, toggleNamespace, loadEntries } = useActions(scratchpadLogic)++ const isInitialLoad = entriesLoading && entries === null+ const isSearching = searchText.trim().length > 0++ return (+ <div className="flex flex-col gap-4 px-4 py-3">+ <ScratchpadHeader totalCount={totalCount} lastUpdatedAt={lastUpdatedAt} />++ <div className="flex flex-wrap items-center gap-2">+ <LemonInput+ type="search"+ placeholder="Search the scratchpad…"+ value={searchText}+ onChange={setSearchText}+ className="flex-1 min-w-[12rem]"+ allowClear+ />+ <LemonSegmentedButton+ size="small"+ value={grouping}+ onChange={setGrouping}+ options={[+ { value: 'recent', label: 'Recent', icon: <IconClock /> },+ { value: 'topic', label: 'By topic', icon: <IconStack /> },+ ]}+ />+ </div>++ {isInitialLoad ? (+ <div className="flex flex-col gap-2">+ <LemonSkeleton className="h-12 w-full rounded" />+ <LemonSkeleton className="h-12 w-full rounded" />+ <LemonSkeleton className="h-12 w-full rounded" />+ </div>+ ) : loadFailed && (!entries || entries.length === 0) ? (+ <ScratchpadErrorState onRetry={() => loadEntries()} loading={entriesLoading} />+ ) : !entries || entries.length === 0 ? (+ <ScratchpadEmptyState isSearching={isSearching} />+ ) : grouping === 'topic' ? (+ <div className="flex flex-col gap-3">+ {groups.map((group) => {+ // Collapsed by default for a high-level scan; a search forces every matching+ // topic open so results stay visible without a click.+ const isExpanded = isSearching || expandedNamespaces.includes(group.namespace)+ return (+ <div key={group.namespace} className="flex flex-col gap-2">+ <button+ type="button"+ onClick={() => toggleNamespace(group.namespace)}+ className="flex items-center gap-2 text-left"+ aria-expanded={isExpanded}+ >+ <IconChevronDown+ className={`size-4 shrink-0 text-muted transition-transform ${+ isExpanded ? '' : '-rotate-90'+ }`}+ />+ <span className="text-xs font-medium uppercase tracking-wide text-default">+ {group.label}+ </span>+ <span className="text-[11px] text-muted">+ {pluralize(group.entries.length, 'note')}+ </span>+ </button>+ {isExpanded &&+ group.entries.map((entry) => <ScratchpadEntryCard key={entry.key} entry={entry} />)}+ </div>+ )+ })}+ </div>+ ) : (+ <div className="flex flex-col gap-2">+ {entries.map((entry) => (+ <ScratchpadEntryCard key={entry.key} entry={entry} />+ ))}+ </div>+ )}+ </div>+ )+}++function ScratchpadHeader({+ totalCount,+ lastUpdatedAt,+}: {+ totalCount: number | null+ lastUpdatedAt: string | null+}): JSX.Element {+ return (+ <div className="flex flex-col gap-1">+ <div className="flex items-center gap-2">+ <IconNotebook className="size-5 text-primary-3000" />+ <span className="text-base font-semibold text-default">Scout scratchpad</span>+ </div>+ <p className="mb-0 max-w-2xl text-sm text-secondary">+ Where your scouts jot down useful context as they scan your project — things they've classified, ruled+ out, or the vocabulary they've settled on. Browse it to see what they're picking up about your setup.+ </p>+ {totalCount !== null && totalCount > 0 && (+ <span className="text-xs text-muted">+ {pluralize(totalCount, 'note')}+ {lastUpdatedAt ? (+ <>+ {' · last updated '}+ <TZLabel time={lastUpdatedAt} />+ </>+ ) : null}+ </span>+ )}+ </div>+ )+}++function ScratchpadErrorState({ onRetry, loading }: { onRetry: () => void; loading: boolean }): JSX.Element {+ return (+ <div className="flex flex-col items-center gap-2 rounded border border-dashed border-primary bg-bg-light px-4 py-8 text-center text-sm text-muted">+ <span>+ Couldn't load the scratchpad. The scout API may be unavailable or this project may not be enrolled yet.+ </span>+ <LemonButton type="secondary" size="small" onClick={onRetry} loading={loading}>+ Retry+ </LemonButton>+ </div>+ )+}++function ScratchpadEmptyState({ isSearching }: { isSearching: boolean }): JSX.Element {+ return (+ <div className="rounded border border-dashed border-primary bg-bg-light px-4 py-8 text-center text-sm text-muted">+ {isSearching+ ? 'No notes match your search.'+ : "Your scouts haven't jotted anything down yet. As they scan your project, their notes show up here."}+ </div>+ )+}diff --git a/frontend/src/scenes/inbox/inboxSceneLogic.ts b/frontend/src/scenes/inbox/inboxSceneLogic.tsindex b19cfdde3708..155af2c1bf52 100644--- a/frontend/src/scenes/inbox/inboxSceneLogic.ts+++ b/frontend/src/scenes/inbox/inboxSceneLogic.ts@@ -22,6 +22,7 @@ import { isAgentRunReport, isFinishedRunReport } from './inboxMembership'import type { inboxSceneLogicType } from './inboxSceneLogicType'import { INBOX_PIPELINE_STATUS_FILTERS } from './logics/inboxFiltersLogic'import { INBOX_FLAT_TAB_LIST_PARAMS, reportListLogic } from './logics/reportListLogic'+import { scratchpadLogic } from './logics/scratchpadLogic'import { signalSourcesLogic } from './signalSourcesLogic'import { InboxFlatListTabKey, INBOX_STAFF_ONLY_TAB_KEYS, INBOX_TAB_KEYS, InboxTabKey, SignalReport } from './types'@@ -42,6 +43,16 @@ function isStaffOnlyTab(tab: string | undefined): boolean {* so opening it can render the detail instantly from the list row instead of waiting on a fresh* `GET`. The background fetch still runs to converge on the authoritative record.*/+// The Fleet memory callout reads the same singleton `scratchpadLogic` the panel filters, so a+// leftover search (especially a no-match one) would make it count zero and hide itself. Clear the+// search whenever the scratchpad closes — by any path (close button, report/scout open, Back nav).+function clearScratchpadSearch(): void {+ const mounted = scratchpadLogic.findMounted()+ if (mounted?.values.searchText) {+ mounted.actions.setSearchText('')+ }+}+function findLoadedReport(id: string, runsReports: SignalReport[]): SignalReport | null {const fromRuns = runsReports.find((r) => r.id === id)if (fromRuns) {@@ -122,6 +133,9 @@ export const inboxSceneLogic = kea<inboxSceneLogicType>([skillName,findingId,}),+ // Scout fleet-memory (scratchpad) surface: a full-width browse/search view over the list,+ // mutually exclusive with the report and scout-detail views. Reached from the fleet-memory callout.+ setScratchpadOpen: (open: boolean) => ({ open }),runSessionAnalysis: true,runSessionAnalysisSuccess: true,runSessionAnalysisFailure: (error: string) => ({ error }),@@ -179,6 +193,15 @@ export const inboxSceneLogic = kea<inboxSceneLogicType>([setSelectedScoutSkillName: (_, { skillName }) => skillName,},],+ isScratchpadOpen: [+ false,+ {+ setScratchpadOpen: (_, { open }) => open,+ // Opening a report or a scout closes the memory view.+ setSelectedReportId: (state, { id }) => (id ? false : state),+ setSelectedScoutSkillName: (state, { skillName }) => (skillName ? false : state),+ },+ ],// The finding deep-linked within the selected scout, if any. Cleared whenever a scout is// (re)selected without a finding — navigating to a scout from the fleet drops any prior finding.selectedScoutFindingId: [@@ -250,6 +273,9 @@ export const inboxSceneLogic = kea<inboxSceneLogicType>([actions.seedSelectedReport(null)return}+ // Opening a report closes the scratchpad (reducer) — clear its transient search so the+ // callout doesn't stay hidden behind a stale no-match filter on the way back.+ clearScratchpadSearch()// The open method is resolved once the authoritative record lands in loadSelectedReportSuccess.cache.pendingOpenMethod = openMethod// A report and a scout detail are mutually exclusive full-width views.@@ -281,8 +307,26 @@ export const inboxSceneLogic = kea<inboxSceneLogicType>([cache.pendingOpenMethod = undefined},setSelectedScoutSkillName: ({ skillName }) => {- if (skillName !== null && values.selectedReportId !== null) {- actions.setSelectedReportId(null)+ if (skillName !== null) {+ // Opening a scout detail closes the scratchpad (reducer) — clear its transient search.+ clearScratchpadSearch()+ if (values.selectedReportId !== null) {+ actions.setSelectedReportId(null)+ }+ }+ },+ setScratchpadOpen: ({ open }) => {+ if (open) {+ // Close the open report/scout through their own actions so report dwell-time+ // bookkeeping runs (clearing the id in a reducer would skip the close tracking).+ if (values.selectedReportId !== null) {+ actions.setSelectedReportId(null)+ }+ if (values.selectedScoutSkillName !== null) {+ actions.setSelectedScoutSkillName(null)+ }+ } else {+ clearScratchpadSearch()}},loadSourceConfigsSuccess: () => {@@ -337,13 +381,15 @@ export const inboxSceneLogic = kea<inboxSceneLogicType>([{ replace: false },],setSelectedReportId: () => [- // When a report is cleared because a scout was just selected (mutually exclusive views),- // honor the scout's URL rather than bouncing to the list and clobbering the scout route.+ // When a report is cleared because a scout or the memory view was just opened (mutually+ // exclusive views), honor that surface's URL rather than bouncing to the list.values.selectedReportId? urls.inboxReport(values.activeTab, values.selectedReportId)- : values.selectedScoutSkillName- ? urls.inboxScout(values.selectedScoutSkillName, values.selectedScoutFindingId ?? undefined)- : urls.inbox(values.activeTab),+ : values.isScratchpadOpen+ ? urls.inboxScratchpad()+ : values.selectedScoutSkillName+ ? urls.inboxScout(values.selectedScoutSkillName, values.selectedScoutFindingId ?? undefined)+ : urls.inbox(values.activeTab),router.values.searchParams,router.values.hashParams,{ replace: false },@@ -351,9 +397,17 @@ export const inboxSceneLogic = kea<inboxSceneLogicType>([setSelectedScoutSkillName: () => [values.selectedScoutSkillName? urls.inboxScout(values.selectedScoutSkillName, values.selectedScoutFindingId ?? undefined)- : values.selectedReportId- ? urls.inboxReport(values.activeTab, values.selectedReportId)- : urls.inbox(values.activeTab),+ : values.isScratchpadOpen+ ? urls.inboxScratchpad()+ : values.selectedReportId+ ? urls.inboxReport(values.activeTab, values.selectedReportId)+ : urls.inbox(values.activeTab),+ router.values.searchParams,+ router.values.hashParams,+ { replace: false },+ ],+ setScratchpadOpen: () => [+ values.isScratchpadOpen ? urls.inboxScratchpad() : urls.inbox(values.activeTab),router.values.searchParams,router.values.hashParams,{ replace: false },@@ -361,6 +415,11 @@ export const inboxSceneLogic = kea<inboxSceneLogicType>([})),urlToAction(({ actions, values, cache }) => ({+ [urls.inboxScratchpad()]: () => {+ if (!values.isScratchpadOpen) {+ actions.setScratchpadOpen(true)+ }+ },[urls.inbox()]: () => {cache.inboxListVisited = trueif (values.selectedReportId !== null) {@@ -369,6 +428,9 @@ export const inboxSceneLogic = kea<inboxSceneLogicType>([if (values.selectedScoutSkillName !== null) {actions.setSelectedScoutSkillName(null)}+ if (values.isScratchpadOpen) {+ actions.setScratchpadOpen(false)+ }},[urls.inbox(':tab')]: ({ tab }: { tab?: string }) => {// A bare report deep-link `/inbox/<reportId>` redirected to report form. Mark the list as@@ -397,8 +459,15 @@ export const inboxSceneLogic = kea<inboxSceneLogicType>([if (values.selectedScoutSkillName !== null) {actions.setSelectedScoutSkillName(null)}+ if (values.isScratchpadOpen) {+ actions.setScratchpadOpen(false)+ }},[urls.inboxScout(':skillName')]: ({ skillName }: { skillName?: string }) => {+ // `/inbox/scouts/scratchpad` also matches this pattern; the memory handler owns that path.+ if (skillName === 'scratchpad') {+ return+ }const name = skillName ?? null// Also reset the finding when landing on the bare scout URL after a finding deep-link.if (values.selectedScoutSkillName !== name || values.selectedScoutFindingId !== null) {diff --git a/frontend/src/scenes/inbox/logics/scratchpadLogic.ts b/frontend/src/scenes/inbox/logics/scratchpadLogic.tsnew file mode 100644index 000000000000..fdbe45f78509--- /dev/null+++ b/frontend/src/scenes/inbox/logics/scratchpadLogic.ts@@ -0,0 +1,146 @@+import { actions, afterMount, kea, listeners, path, reducers, selectors } from 'kea'+import { loaders } from 'kea-loaders'++import { teamLogic } from 'scenes/teamLogic'++import { signalsScoutScratchpadSearch } from 'products/signals/frontend/generated/api'+import type { ScratchpadEntryApi } from 'products/signals/frontend/generated/api.schemas'++import type { scratchpadLogicType } from './scratchpadLogicType'++// The list view shows two ways to read the fleet's memory: newest-first (the API's+// native order) or clustered by the key namespace scouts choose (`tags:*`, `dedupe:*`).+export type ScratchpadGrouping = 'recent' | 'topic'++// Search reruns the server-side ILIKE on every keystroke; debounce so typing doesn't+// fire a request per character.+const SEARCH_DEBOUNCE_MS = 300+// `list` caps at 100 newest-first with no pagination wrapper — pull the whole window in+// one read and group/search client-side. A team that ever exceeds this wants a count ++// cursor on the endpoint (tracked as a backend follow-up), not deeper paging here.+const SCRATCHPAD_FETCH_LIMIT = 100++/** One namespace cluster in the "By topic" view: the raw prefix, a friendly label, and its entries. */+export interface ScratchpadNamespaceGroup {+ namespace: string+ label: string+ entries: ScratchpadEntryApi[]+}++/** Scouts namespace keys with a leading `prefix:` (e.g. `tags:errors:taxonomy`). Everything+ * before the first colon is the topic; keys without one fall into a shared "General" bucket. */+export function scratchpadNamespaceOf(key: string): string {+ const idx = key.indexOf(':')+ return idx > 0 ? key.slice(0, idx) : 'general'+}++export function humanizeNamespace(namespace: string): string {+ if (namespace === 'general') {+ return 'General'+ }+ return namespace.replace(/[-_]/g, ' ').replace(/\b\w/g, (char) => char.toUpperCase())+}++/**+ * Read-only view over the scout fleet's durable memory (`SignalScratchpad`). Owns the entry list,+ * the debounced search text (wired straight to the endpoint's `?text=` ILIKE), and the recent /+ * by-topic grouping toggle. There is no write surface on purpose — humans inspect this memory;+ * only the harness (internal-scope) writes it.+ */+export const scratchpadLogic = kea<scratchpadLogicType>([+ path(['scenes', 'inbox', 'logics', 'scratchpadLogic']),++ actions({+ setSearchText: (searchText: string) => ({ searchText }),+ setGrouping: (grouping: ScratchpadGrouping) => ({ grouping }),+ toggleNamespace: (namespace: string) => ({ namespace }),+ }),++ loaders(({ values }) => ({+ entries: [+ null as ScratchpadEntryApi[] | null,+ {+ loadEntries: async (_payload: void, breakpoint) => {+ const teamId = teamLogic.values.currentTeamId+ if (!teamId) {+ return []+ }+ const text = values.searchText.trim()+ const results = await signalsScoutScratchpadSearch(String(teamId), {+ text: text || undefined,+ limit: SCRATCHPAD_FETCH_LIMIT,+ })+ // Drop a stale response if the search moved on while this request was in flight.+ breakpoint()+ return results+ },+ },+ ],+ })),++ reducers({+ searchText: ['', { setSearchText: (_, { searchText }) => searchText }],+ grouping: ['recent' as ScratchpadGrouping, { setGrouping: (_, { grouping }) => grouping }],+ // Did the most recent load reject? Lets the panel tell a failed load apart from an empty+ // project (kea-loaders leaves `entries` at its prior value on failure, so it can't).+ loadFailed: [+ false,+ {+ loadEntries: () => false,+ loadEntriesSuccess: () => false,+ loadEntriesFailure: () => true,+ },+ ],+ // Which "By topic" clusters are open. Start collapsed (high-level view of topics first);+ // switching grouping resets the set so entering "By topic" always opens fully collapsed.+ expandedNamespaces: [+ [] as string[],+ {+ toggleNamespace: (state, { namespace }) =>+ state.includes(namespace) ? state.filter((n) => n !== namespace) : [...state, namespace],+ setGrouping: () => [],+ },+ ],+ }),++ selectors({+ totalCount: [(s) => [s.entries], (entries): number | null => (entries ? entries.length : null)],+ // Entries are newest-first, so the head's timestamp drives the callout's "updated when" hint.+ lastUpdatedAt: [(s) => [s.entries], (entries): string | null => entries?.[0]?.updated_at ?? null],+ // Entries arrive newest-first; preserve that order within each namespace cluster, and order+ // the clusters by their most recently touched entry so the liveliest topic floats to the top.+ groups: [+ (s) => [s.entries],+ (entries): ScratchpadNamespaceGroup[] => {+ const byNamespace = new Map<string, ScratchpadEntryApi[]>()+ for (const entry of entries ?? []) {+ const namespace = scratchpadNamespaceOf(entry.key)+ const bucket = byNamespace.get(namespace)+ if (bucket) {+ bucket.push(entry)+ } else {+ byNamespace.set(namespace, [entry])+ }+ }+ return [...byNamespace.entries()]+ .map(([namespace, namespaceEntries]) => ({+ namespace,+ label: humanizeNamespace(namespace),+ entries: namespaceEntries,+ }))+ .sort((a, b) => (b.entries[0]?.updated_at ?? '').localeCompare(a.entries[0]?.updated_at ?? ''))+ },+ ],+ }),++ listeners(({ actions }) => ({+ setSearchText: async (_, breakpoint) => {+ await breakpoint(SEARCH_DEBOUNCE_MS)+ actions.loadEntries()+ },+ })),++ afterMount(({ actions }) => {+ actions.loadEntries()+ }),+])diff --git a/frontend/src/scenes/inbox/signalSourcesLogic.ts b/frontend/src/scenes/inbox/signalSourcesLogic.tsindex 709e7473885e..7866a994aa3a 100644--- a/frontend/src/scenes/inbox/signalSourcesLogic.ts+++ b/frontend/src/scenes/inbox/signalSourcesLogic.ts@@ -140,7 +140,6 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([toggleErrorTrackingComplete: true,toggleHealthChecks: true,toggleConversations: true,- toggleScoutsSource: true,saveSessionAnalysisFilters: (filters: RecordingUniversalFilters) => ({ filters }),clearSessionAnalysisFilters: true,}),@@ -196,8 +195,6 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([toggleSourceConfigState(state, SignalSourceProduct.HEALTH_CHECKS, SignalSourceType.HEALTH_ISSUE),toggleConversations: (state: SignalSourceConfig[] | null) =>toggleSourceConfigState(state, SignalSourceProduct.CONVERSATIONS, SignalSourceType.TICKET),- toggleScoutsSource: (state: SignalSourceConfig[] | null) =>- toggleSourceConfigState(state, SignalSourceProduct.SIGNALS_SCOUT, SignalSourceType.CROSS_SOURCE_ISSUE),},togglingSourceKeys: [new Set<string>(),@@ -322,23 +319,6 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([(keys: Set<string>): boolean =>keys.has(`${SignalSourceProduct.HEALTH_CHECKS}_${SignalSourceType.HEALTH_ISSUE}`),],- // The scout source gate: a single team-level on/off that decides whether scout findings- // emit to the inbox at all. It is NOT a per-scout toggle (those live on SignalScoutConfig)- // and does not control whether scouts run — only whether what they find reaches the inbox.- scoutsSourceConfig: [- (s) => [s.sourceConfigs],- (sourceConfigs: SignalSourceConfig[] | null): SignalSourceConfig | null =>- sourceConfigs?.find(- (c) =>- c.source_product === SignalSourceProduct.SIGNALS_SCOUT &&- c.source_type === SignalSourceType.CROSS_SOURCE_ISSUE- ) ?? null,- ],- isScoutsSourceToggling: [- (s) => [s.togglingSourceKeys],- (keys: Set<string>): boolean =>- keys.has(`${SignalSourceProduct.SIGNALS_SCOUT}_${SignalSourceType.CROSS_SOURCE_ISSUE}`),- ],errorTrackingIsFullyEnabled: [(s) => [s.sourceConfigs],(sourceConfigs: SignalSourceConfig[] | null): boolean => {@@ -554,17 +534,6 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([enabled: desiredEnabled,})},- toggleScoutsSource: () => {- // The optimistic reducer flips the config before this listener runs,- // so config.enabled already reflects the desired state.- const config = values.scoutsSourceConfig- const desiredEnabled = config?.enabled ?? true- actions.toggleSignalSource({- sourceProduct: SignalSourceProduct.SIGNALS_SCOUT,- sourceType: SignalSourceType.CROSS_SOURCE_ISSUE,- enabled: desiredEnabled,- })- },toggleDataWarehouseSource: ({ dwSource }) => {const { sourceProduct, sourceType } = DATA_WAREHOUSE_SOURCE_CONFIG[dwSource]const config = getDataWarehouseSourceConfig(values, dwSource)diff --git a/frontend/src/scenes/scenes.ts b/frontend/src/scenes/scenes.tsindex 291b67ad2b0f..5992d7fb98cc 100644--- a/frontend/src/scenes/scenes.ts+++ b/frontend/src/scenes/scenes.ts@@ -930,6 +930,8 @@ export const routes: Record<string, [Scene | string, string]> = {[urls.health()]: [Scene.Health, 'health'],[urls.inbox()]: [Scene.Inbox, 'inbox'],[urls.inbox(':tab')]: [Scene.Inbox, 'inbox'],+ // Static memory route, registered before `:skillName` so it isn't read as a scout name.+ [urls.inboxScratchpad()]: [Scene.Inbox, 'inbox'],// Registered before the generic report route: both are two-segment `/inbox/x/y` shapes.[urls.inboxScout(':skillName')]: [Scene.Inbox, 'inbox'],// Deep-link to a single scout finding: the bare scout route plus a trailing `/<finding>` segment.diff --git a/frontend/src/scenes/urls.ts b/frontend/src/scenes/urls.tsindex 7828e108419c..0e2b85ae63ac 100644--- a/frontend/src/scenes/urls.ts+++ b/frontend/src/scenes/urls.ts@@ -306,6 +306,8 @@ export const urls = {const segment = findingId ? `/${findingId === ':findingId' ? findingId : encodeURIComponent(findingId)}` : ''return `/inbox/scouts/${skillName}${segment}`},+ // Scout fleet memory (scratchpad) browse/search surface, reached from the fleet-memory callout.+ inboxScratchpad: (): string => '/inbox/scouts/scratchpad',webAnalyticsBotAnalytics: (): string => '/web/bots',webAnalyticsHealth: (): string => '/web/health',pipelineStatus: (): string => '/health/pipeline-status',diff --git a/products/signals/backend/migrations/0049_turn_on_scout_source_by_default.py b/products/signals/backend/migrations/0049_turn_on_scout_source_by_default.pynew file mode 100644index 000000000000..120806913095--- /dev/null+++ b/products/signals/backend/migrations/0049_turn_on_scout_source_by_default.py@@ -0,0 +1,28 @@+from django.db import migrations+++def turn_on_scout_source(apps, schema_editor):+ """Land every team on scout findings surfacing to the inbox.++ The team-level "Surface findings in your inbox" toggle is being removed, so there's no+ longer a UI to turn it back on. The emit gate is now fail-open (absence of a row means on),+ which covers teams that never had a row. This flips the handful that explicitly toggled off+ in the old UI so they aren't stranded off — a team that really wants to opt out can still+ write an explicit disabled row via the MCP/API. One row per team, so a filtered UPDATE is cheap.+ """+ SignalSourceConfig = apps.get_model("signals", "SignalSourceConfig")+ SignalSourceConfig.objects.filter(+ source_product="signals_scout",+ source_type="cross_source_issue",+ enabled=False,+ ).update(enabled=True)+++class Migration(migrations.Migration):+ dependencies = [+ ("signals", "0048_signalreportartefact_latest_index"),+ ]++ operations = [+ migrations.RunPython(turn_on_scout_source, migrations.RunPython.noop),+ ]diff --git a/products/signals/backend/migrations/max_migration.txt b/products/signals/backend/migrations/max_migration.txtindex bba5624efd97..fa80e35d150c 100644--- a/products/signals/backend/migrations/max_migration.txt+++ b/products/signals/backend/migrations/max_migration.txt@@ -1 +1 @@-0048_signalreportartefact_latest_index+0049_turn_on_scout_source_by_defaultdiff --git a/products/signals/backend/models.py b/products/signals/backend/models.pyindex e6364b7b11ed..09232df6ace4 100644--- a/products/signals/backend/models.py+++ b/products/signals/backend/models.py@@ -79,7 +79,8 @@ class SignalSourceConfig(UUIDModel):"""Check whether a given signal source is enabled for a team.AI observability signals are always allowed (gated in llma evals workflows). TODO - this should be moved here.- For everything else, the team must have a SignalSourceConfig row with enabled=True.+ Scout findings are on by default (see below). For everything else, the team must have a+ SignalSourceConfig row with enabled=True."""if source_product == cls.SourceProduct.LLM_ANALYTICS:return True@@ -89,6 +90,17 @@ class SignalSourceConfig(UUIDModel):if source_product == cls.SourceProduct.REPLAY_VISION and source_type == cls.SourceType.SCANNER_FINDING:return True+ # Scout findings surface to the inbox by default — the team-level toggle was retired from the+ # UI, so this gate is fail-open: absence of a row means on. A team can still opt out via the+ # MCP/API by writing an explicit disabled row, which this honors.+ if source_product == cls.SourceProduct.SIGNALS_SCOUT and source_type == cls.SourceType.CROSS_SOURCE_ISSUE:+ return not cls.objects.filter(+ team_id=team_id,+ source_product=source_product,+ source_type=source_type,+ enabled=False,+ ).exists()+# Session problem signals are emitted as part of session analysis,# so they're gated by the pre-existing session_analysis_cluster configif source_product == cls.SourceProduct.SESSION_REPLAY and source_type == "session_problem":diff --git a/products/signals/backend/scout_harness/serializers.py b/products/signals/backend/scout_harness/serializers.pyindex 764af3b997a4..b662ac6a69d2 100644--- a/products/signals/backend/scout_harness/serializers.py+++ b/products/signals/backend/scout_harness/serializers.py@@ -269,6 +269,16 @@ class ScratchpadEntrySerializer(serializers.Serializer):allow_null=True,help_text="Run that wrote this entry, or null if human-authored.",)+ created_by_skill = serializers.CharField(+ allow_null=True,+ required=False,+ help_text="Canonical skill name of the scout that created this entry (e.g. `signals-scout-apm`), or null if human-authored.",+ )+ created_by_run_url = serializers.CharField(+ allow_null=True,+ required=False,+ help_text="Relative Tasks UI deep-link to the run that created this entry, or null if the run linkage isn't captured.",+ )class SearchMemoryQuerySerializer(serializers.Serializer):diff --git a/products/signals/backend/scout_harness/tools/scratchpad.py b/products/signals/backend/scout_harness/tools/scratchpad.pyindex 6ef44b0a755e..cf533ed3d366 100644--- a/products/signals/backend/scout_harness/tools/scratchpad.py+++ b/products/signals/backend/scout_harness/tools/scratchpad.py@@ -17,6 +17,7 @@ from typing import Anyfrom django.db import IntegrityError, transactionfrom products.signals.backend.models import SignalScratchpad+from products.signals.backend.scout_harness.tools.runs import _build_task_url# Defensive cap on search results.DEFAULT_SCRATCHPAD_SEARCH_LIMIT = 20@@ -42,6 +43,9 @@ class ScratchpadEntry:created_at: str | None = Noneupdated_at: str | None = Nonecreated_by_run_id: str | None = None+ # Identity + deep-link of the scout run that created the entry, resolved from `created_by_run`.+ created_by_skill: str | None = None+ created_by_run_url: str | None = Nonedef as_dict(self) -> dict[str, Any]:return asdict(self)@@ -70,7 +74,9 @@ def search_scratchpad((a preview). Ignored when `keys_only=True`, which already drops the body."""clamped_limit = _clamp_search_limit(limit)- qs = SignalScratchpad.objects.filter(team_id=team_id)+ # Join the creating run (and its task_run) so per-row skill/url resolution in `_to_entry`+ # stays a single query rather than an N+1 across the result window.+ qs = SignalScratchpad.objects.filter(team_id=team_id).select_related("created_by_run", "created_by_run__task_run")if text:from django.db.models import Q@@ -157,12 +163,23 @@ def _to_entry(# Django's FK descriptor exposes both `created_by_run` (object) and `created_by_run_id`# (the raw FK column). `getattr` keeps Pyright happy without a join.run_pk = getattr(row, "created_by_run_id", None)+ # Resolve the creating scout's identity + a deep-link to its run. `search_scratchpad` joins+ # both via select_related, so this is a no-N+1 read on the list path; the single-row write+ # path lazy-loads, which is fine. A human-authored entry (no run) leaves these null.+ run = row.created_by_run if run_pk else None+ task_run = getattr(run, "task_run", None) if run is not None else Nonereturn ScratchpadEntry(key=row.key,content=_project_content(row.content, keys_only=keys_only, content_max_chars=content_max_chars),created_at=row.created_at.isoformat() if row.created_at else None,updated_at=row.updated_at.isoformat() if row.updated_at else None,created_by_run_id=str(run_pk) if run_pk else None,+ created_by_skill=run.skill_name if run is not None else None,+ created_by_run_url=_build_task_url(+ team_id=row.team_id,+ task_id=str(task_run.task_id) if task_run is not None else None,+ task_run_id=str(task_run.id) if task_run is not None else None,+ ),)diff --git a/products/signals/backend/test/test_scout_harness_tools.py b/products/signals/backend/test/test_scout_harness_tools.pyindex b13297282173..fd0ad0c6da43 100644--- a/products/signals/backend/test/test_scout_harness_tools.py+++ b/products/signals/backend/test/test_scout_harness_tools.py@@ -321,6 +321,9 @@ class TestRemember(BaseTest):assert row.content == "ignore /favicon 404s"assert row.created_by_run_id is Noneassert entry.key == "known-noise"+ # No run → no scout attribution to surface.+ assert entry.created_by_skill is None+ assert entry.created_by_run_url is Nonedef test_idempotent_upsert_on_team_key(self) -> None:first = remember(team_id=self.team.id, key="k", content="v1")@@ -367,6 +370,15 @@ class TestRemember(BaseTest):)assert entry.created_by_run_id == str(run.id)+ def test_surfaces_creating_scout_and_run_url(self) -> None:+ run = _create_run(self.team)+ entry = remember(team_id=self.team.id, key="attributed", content="x", run_id=str(run.id))++ assert entry.created_by_skill == "signals-scout-errors"+ assert (+ entry.created_by_run_url == f"/project/{self.team.id}/tasks/{run.task_run.task_id}?runId={run.task_run_id}"+ )+class TestForget(BaseTest):def test_deletes_entry(self) -> None:@@ -645,8 +657,9 @@ async def ateam_emit(aorganization_emit):from products.signals.backend.models import SignalSourceConfigteam = await database_sync_to_async(Team.objects.create)(organization=aorganization_emit, name="emit-team")- # The signals_scout source must be explicitly enabled per-team — emit_signal()- # silently no-ops without it, and the harness preflight mirrors that gate.+ # The scout source is on by default (fail-open: no row means enabled), so emit isn't gated+ # off here. Seed the explicit enabled row anyway so tests that flip it to False to exercise the+ # source_disabled gate have a row to update.with team_scope(team.id, canonical=True):await database_sync_to_async(SignalSourceConfig.objects.create)(team=team,diff --git a/products/signals/backend/test/test_signal_source_config_api.py b/products/signals/backend/test/test_signal_source_config_api.pyindex b0787a35c905..f02801657da9 100644--- a/products/signals/backend/test/test_signal_source_config_api.py+++ b/products/signals/backend/test/test_signal_source_config_api.py@@ -484,3 +484,21 @@ class TestIsSourceEnabledGating(APIBaseTest):def test_replay_vision_scanner_finding_is_self_authorizing(self):# The scanner's `emits_signals` flag is the config — no SignalSourceConfig row exists.assert SignalSourceConfig.is_source_enabled(self.team.id, "replay_vision", "scanner_finding") is True++ @parameterized.expand(+ [+ ("no_row_defaults_on", None, True),+ ("explicit_disabled_opts_out", False, False),+ ("explicit_enabled_on", True, True),+ ]+ )+ def test_scout_source_on_by_default(self, _name, existing_enabled, expected):+ if existing_enabled is not None:+ SignalSourceConfig.objects.create(+ team=self.team,+ source_product=SignalSourceConfig.SourceProduct.SIGNALS_SCOUT,+ source_type=SignalSourceConfig.SourceType.CROSS_SOURCE_ISSUE,+ enabled=existing_enabled,+ )++ assert SignalSourceConfig.is_source_enabled(self.team.id, "signals_scout", "cross_source_issue") is expecteddiff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.tsindex 87727d6611d3..d40afe3d312a 100644--- a/products/signals/frontend/generated/api.schemas.ts+++ b/products/signals/frontend/generated/api.schemas.ts@@ -1368,6 +1368,16 @@ export interface ScratchpadEntryApi {* @nullable*/created_by_run_id: string | null+ /**+ * Canonical skill name of the scout that created this entry (e.g. `signals-scout-apm`), or null if human-authored.+ * @nullable+ */+ created_by_skill?: string | null+ /**+ * Relative Tasks UI deep-link to the run that created this entry, or null if the run linkage isn't captured.+ * @nullable+ */+ created_by_run_url?: string | null}/**diff --git a/products/signals/mcp/tools.yaml b/products/signals/mcp/tools.yamlindex 075ee82ad11a..aa2625b4448f 100644--- a/products/signals/mcp/tools.yaml+++ b/products/signals/mcp/tools.yaml@@ -244,12 +244,12 @@ tools:`source_product` to a `source_type` and an `enabled` flag. Valid `source_product` values: session_replay,llm_analytics, github, linear, zendesk, conversations, error_tracking, pganalyze, signals_scout, logs. Valid`source_type` values: session_analysis_cluster, evaluation, issue, ticket, issue_created, issue_reopened,- issue_spiking, cross_source_issue, alert_state_change. To turn the Signals scout source on for a project,- create `source_product=signals_scout`, `source_type=cross_source_issue`, `enabled=true` — this is the- team-level source gate that scout emit also requires (the per-scout `emit` flag is set separately via- `signals-scout-config-update`). There is at most one config per (source_product, source_type) per project;- if one already exists, update it instead. Enabling the session_analysis_cluster source requires the- organization to have approved AI data processing.+ issue_spiking, cross_source_issue, alert_state_change. The Signals scout source is ON BY DEFAULT — scout+ findings reach the inbox with no config row needed. The only reason to create a+ `source_product=signals_scout`, `source_type=cross_source_issue` row is to OPT OUT: create it with+ `enabled=false` (the per-scout `emit` flag is set separately via `signals-scout-config-update`). There is at+ most one config per (source_product, source_type) per project; if one already exists, update it instead.+ Enabling the session_analysis_cluster source requires the organization to have approved AI data processing.inbox-source-configs-destroy:operation: signals_source_configs_destroyenabled: falsediff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex 3bceab360564..524df648f870 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -3800,7 +3800,7 @@}},"inbox-source-configs-create": {- "description": "Create a signal source config for the current project, switching an inbox signal source on. A source ties a `source_product` to a `source_type` and an `enabled` flag. Valid `source_product` values: session_replay, llm_analytics, github, linear, zendesk, conversations, error_tracking, pganalyze, signals_scout, logs. Valid `source_type` values: session_analysis_cluster, evaluation, issue, ticket, issue_created, issue_reopened, issue_spiking, cross_source_issue, alert_state_change. To turn the Signals scout source on for a project, create `source_product=signals_scout`, `source_type=cross_source_issue`, `enabled=true` — this is the team-level source gate that scout emit also requires (the per-scout `emit` flag is set separately via `signals-scout-config-update`). There is at most one config per (source_product, source_type) per project; if one already exists, update it instead. Enabling the session_analysis_cluster source requires the organization to have approved AI data processing.",+ "description": "Create a signal source config for the current project, switching an inbox signal source on. A source ties a `source_product` to a `source_type` and an `enabled` flag. Valid `source_product` values: session_replay, llm_analytics, github, linear, zendesk, conversations, error_tracking, pganalyze, signals_scout, logs. Valid `source_type` values: session_analysis_cluster, evaluation, issue, ticket, issue_created, issue_reopened, issue_spiking, cross_source_issue, alert_state_change. The Signals scout source is ON BY DEFAULT — scout findings reach the inbox with no config row needed. The only reason to create a `source_product=signals_scout`, `source_type=cross_source_issue` row is to OPT OUT: create it with `enabled=false` (the per-scout `emit` flag is set separately via `signals-scout-config-update`). There is at most one config per (source_product, source_type) per project; if one already exists, update it instead. Enabling the session_analysis_cluster source requires the organization to have approved AI data processing.","category": "Signals","feature": "signals","summary": "Create signal source config",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 1ccf179f1938..af43f3f43e00 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -4068,7 +4068,7 @@}},"inbox-source-configs-create": {- "description": "Create a signal source config for the current project, switching an inbox signal source on. A source ties a `source_product` to a `source_type` and an `enabled` flag. Valid `source_product` values: session_replay, llm_analytics, github, linear, zendesk, conversations, error_tracking, pganalyze, signals_scout, logs. Valid `source_type` values: session_analysis_cluster, evaluation, issue, ticket, issue_created, issue_reopened, issue_spiking, cross_source_issue, alert_state_change. To turn the Signals scout source on for a project, create `source_product=signals_scout`, `source_type=cross_source_issue`, `enabled=true` — this is the team-level source gate that scout emit also requires (the per-scout `emit` flag is set separately via `signals-scout-config-update`). There is at most one config per (source_product, source_type) per project; if one already exists, update it instead. Enabling the session_analysis_cluster source requires the organization to have approved AI data processing.",+ "description": "Create a signal source config for the current project, switching an inbox signal source on. A source ties a `source_product` to a `source_type` and an `enabled` flag. Valid `source_product` values: session_replay, llm_analytics, github, linear, zendesk, conversations, error_tracking, pganalyze, signals_scout, logs. Valid `source_type` values: session_analysis_cluster, evaluation, issue, ticket, issue_created, issue_reopened, issue_spiking, cross_source_issue, alert_state_change. The Signals scout source is ON BY DEFAULT — scout findings reach the inbox with no config row needed. The only reason to create a `source_product=signals_scout`, `source_type=cross_source_issue` row is to OPT OUT: create it with `enabled=false` (the per-scout `emit` flag is set separately via `signals-scout-config-update`). There is at most one config per (source_product, source_type) per project; if one already exists, update it instead. Enabling the session_analysis_cluster source requires the organization to have approved AI data processing.","category": "Signals","feature": "signals","summary": "Create signal source config",diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex f462fb3b2fc1..5b0e122f5167 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -45962,6 +45962,16 @@ export namespace Schemas {* @nullable*/created_by_run_id: string | null;+ /**+ * Canonical skill name of the scout that created this entry (e.g. `signals-scout-apm`), or null if human-authored.+ * @nullable+ */+ created_by_skill?: string | null;+ /**+ * Relative Tasks UI deep-link to the run that created this entry, or null if the run linkage isn't captured.+ * @nullable+ */+ created_by_run_url?: string | null;}/**