: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(signals): suggestion cards carry the motivation and open the form (#96356)
posthog[bot]f47fcb2c3327
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 6c586d8415c6..08e8e37f127e 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -7517,21 +7517,21 @@ snapshots:scenes-app-inbox-scoutsuggestionsstrip--collapsed--light:hash: v1.k794b7964.524c8aa93e0feaeb73292c42a4e09a47b478b38390ac06af73fbe31b7e1ca1ec.v632nnbKCGANg2mx7LwpL-Fy2pYefM0E6w64y5z_JLYscenes-app-inbox-scoutsuggestionsstrip--empty-fleet--dark:- hash: v1.k794b7964.aa2c2112814769c9a73d9b17e8a4f5a65d20d12c4a3eb3d1dc8368cd5b79003e.Q7gGGZavfedBQJAr-_1xqWv4yLCOFue-swc8QJ0YvAY+ hash: v1.k794b7964.a9e935349a3145375d09cc1a483fd4cf2a760256000855e6e15a4cfaf2548236.mRkmlsFFKTFT_U5FUUw4ltXiVW4u7ICa1YC424x5GJEscenes-app-inbox-scoutsuggestionsstrip--empty-fleet--light:- hash: v1.k794b7964.e1601c331606821945e1d9edc36d15c14bc802b61f20630de2c22ad5e2db86c9.TKbpv7gwF7BsmV1jKWpqszbvqXCPg7WRDQI9DtzilWg+ hash: v1.k794b7964.90d7232a692b063940384aa89d05c70e2c1af66eeeca08fe49bcdd9938e456a0.a3KW1AmgQwcQV84WzmFAeCk_ars13rMcEHeBSkn8S-cscenes-app-inbox-scoutsuggestionsstrip--fresh--dark:- hash: v1.k794b7964.025e249cf99cd58afd28c27b498b5aa63893795cffe2a202bbd505a90305f178.w4q-5TkvRAsJ0twNnbYKfwdSzthw2rG__mD9mmuWez0+ hash: v1.k794b7964.a48a81bcaba120274c582d0d6f0fac80bece4cb6b22fda987d24ed69b8767b66.jAr47iAQdn6jjaCZKOl_3RLxcLLwMI5IT99clZsq9zAscenes-app-inbox-scoutsuggestionsstrip--fresh--light:- hash: v1.k794b7964.d1d61649f83e0a4e654a248652508334744eb365b102f6fbe5402c91db4bf597.FzlEPy11MSMg1mb29-SpMmPlk27oFRpmImz8-8q0x8Q+ hash: v1.k794b7964.974824a015d7b531be6f3544b35fc62335e7cdd38268851a858188fa7a0b8e94.DiX0pcHMec3rjRESiVcOD7Iofwcql4J-ejg4sm2SxTkscenes-app-inbox-scoutsuggestionsstrip--last-scan-failed--dark:- hash: v1.k794b7964.84fc93e2d3c983c6a5376e0791610d5d7c175eddf4b1b0d38e8911c527abe64f.hoQvI4Io7H0NYjWHA1EnADsb1j2E4xfuWDJYBXUhKeI+ hash: v1.k794b7964.94b77a977fb5d4d404498c2668ef981afe39efc40bf68fa47839344edceb218d.x4n7VdD6uc-Ialdy_YbZEKJzIIARdh6bFyzW_NDNeZ8scenes-app-inbox-scoutsuggestionsstrip--last-scan-failed--light:- hash: v1.k794b7964.c89125e7d79b3d8b200ea9e7f1184b2f9b130fd77c27e4d99349efcab5f25bef.v42_Rw_nFrqqiXB8w_K8HUvNXwY8Ya5hyw3-lnNt8HA+ hash: v1.k794b7964.3857c0fee475d63aa48ef4fac4512f5ce109b8e00af9ca32e6595c513c89f5f6.OJ_uYDe4-XN4PpYTm2xY37h5uBgtVterbJViPfb19Fsscenes-app-inbox-scoutsuggestionsstrip--narrow--dark:- hash: v1.k794b7964.19feb834d24ba87ef59338e26f92a86a4f5a95bc91168e17de6117680d05ce5d.pTh6SWq4vFFh2foaE_4N95GSvl1kmiG1k2BZr_YMEdA+ hash: v1.k794b7964.e63ad04f87f642241c737aa4bbae3fd1c5a6854cee585d3656462413782c4360.MwlQ_jwaUkyHRLsNX0izUKtokxhFYlwD4Zd4LOVG8TEscenes-app-inbox-scoutsuggestionsstrip--narrow--light:- hash: v1.k794b7964.1e21bf9514a62d0c875594f482df6f2709b55134f25ad65eb5116b6315b1b7b4.K6KZHvEue8jQ9F-I0SUR9GgFMPD9Z218e4gcXsfPcqU+ hash: v1.k794b7964.cbe4742ff8dfc06553ff2858fc8a6926f692e088f228da29dede4f29ea4b4446.91bUh6BgxoiV8Ajz04FB4J53DsAf3MMES1imt--pGxwscenes-app-inbox-scoutsuggestionsstrip--never-generated--dark:hash: v1.k794b7964.93f5297e0efc7eb2b3c3f65a27a4a0ed3244dc410d9433f90b48e4ea39d93987.clN4SMFV45IqYWkUU9vH1HgupFEFXIBzn3Ejum0d4q0scenes-app-inbox-scoutsuggestionsstrip--never-generated--light:@@ -7549,9 +7549,13 @@ snapshots:scenes-app-inbox-scoutsuggestionsstrip--single-card--light:hash: v1.k794b7964.c2a5937757b97e8cf9e8bced51ff2657bda26ede5c10b1038685c6dbb5caa1d6.CMvAxngQ_3HulQO7oIvTVD8noOEx2Y2bVYBx2rxkDacscenes-app-inbox-scoutsuggestionsstrip--stale--dark:- hash: v1.k794b7964.c8d0dcd6f2b06411a6856f5961ab93da09c1882be99dd859825a18d0ccbc7274.zidFHAbkvlJnvLwpmoKxWucwPQsPh8HSxqU9Ibp65uo+ hash: v1.k794b7964.f41b10ad25e74442dd46e735d605949a7f1c6a52099b864d5b32df18cb6c277e.N50quO-8rvUo-m3JJyPXlgoVZLWfTXoyyaT5TJAaKBwscenes-app-inbox-scoutsuggestionsstrip--stale--light:- hash: v1.k794b7964.e1201b72cabe1284f7ca9cf869bdcbfe7b4693e9a3bb4be068b0a7147ed0de0c.JaNzh5U52QhSM2Cvfu0VIjAp_T4Si1IAQ9rHeubHAjU+ hash: v1.k794b7964.256235fc6e9c29b0487f5e02eb9f3aa35b337f784a16ae5ab89325aa04885155.7i88MK5QfCyP7hDVBvmpnddyr0yVxIexj_HoGn2nAgQ+ scenes-app-inbox-scoutsuggestionsstrip--uneven-motivations--dark:+ hash: v1.k794b7964.e110afa6c50a22f1bb3e58160b76950c73672d67f34b1d536846194ecd94ada2.jFU8QIkM0XH7vfaZYlImtR4g7xXplTpE6x8DNNm4KH4+ scenes-app-inbox-scoutsuggestionsstrip--uneven-motivations--light:+ hash: v1.k794b7964.cd8f04a2768f00a4a8010f1cea58794c2379d9933b2ab2141b605faf53d57836.U_uthHW3YdqOsezpDPlYnSuud_bm3XQ1o-NVFNGqsHQscenes-app-inbox-scoutwriteaccesstag--compact--dark:hash: v1.k794b7964.449b1898c216f12c6a62f2c0a1544ce814cdc7e4d519c69287d686e8b9a90b79.yXNYamE5tvB24QXwyniqxYtd3IAlRpo-RoLspp9zOKQscenes-app-inbox-scoutwriteaccesstag--compact--light:diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionCard.test.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionCard.test.tsxnew file mode 100644index 000000000000..c451ce58ee47--- /dev/null+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionCard.test.tsx@@ -0,0 +1,100 @@+import { cleanup, fireEvent, render, waitFor } from '@testing-library/react'++import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'++import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'++import { mockScoutConfigs, mockScoutSuggestions, mockScoutSuggestionSet } from '../../../__mocks__/scoutConfigs'+import { scoutSuggestionsLogic } from '../../../logics/scoutSuggestionsLogic'+import { ScoutSuggestionCard } from './ScoutSuggestionCard'++jest.mock('lib/utils/accessControlUtils', () => ({+ ...jest.requireActual('lib/utils/accessControlUtils'),+ getAccessControlDisabledReason: jest.fn(() => null),+}))++const mockGetAccessControlDisabledReason = getAccessControlDisabledReason as jest.MockedFunction<+ typeof getAccessControlDisabledReason+>++describe('ScoutSuggestionCard', () => {+ const canonicalItem = mockScoutSuggestions[0]+ let skillReads: number+ let releaseSkillRead: () => void++ beforeEach(() => {+ skillReads = 0+ mockGetAccessControlDisabledReason.mockReturnValue(null)+ const skillReadPending = new Promise<void>((resolve) => {+ releaseSkillRead = resolve+ })+ useMocks({+ get: {+ '/api/projects/:team/signals/scout/configs/': [+ { ...mockScoutConfigs[0], skill_name: canonicalItem.skill_name },+ ],+ '/api/projects/:team/signals/scout/suggestions/': mockScoutSuggestionSet(),+ // Held open by the test, so the card can be pressed again while the read is out.+ '/api/projects/:team/llm_skills/name/:name/': async () => {+ skillReads += 1+ await skillReadPending+ return [+ 200,+ {+ name: canonicalItem.skill_name,+ description: 'Watches web vitals.',+ body: '# Web vitals\n\nCheck LCP on every run.',+ },+ ]+ },+ },+ })+ initKeaTests()+ featureFlagLogic.mount()+ })++ afterEach(cleanup)++ // A canonical press reads the scout over the network before the form opens. Without the busy+ // guard on the body, a second press repeats that read and reopens the form after it is closed.+ it('takes one press while the scout read is still out', async () => {+ const logic = scoutSuggestionsLogic()+ logic.mount()+ await waitFor(() => expect(logic.values.scoutConfigs).not.toBeNull())+ const { getByTestId } = render(<ScoutSuggestionCard item={canonicalItem} surface="strip" />)++ const body = getByTestId('scout-suggestion-body') as HTMLButtonElement+ fireEvent.click(body)++ await waitFor(() => expect(skillReads).toBe(1))+ expect(body.disabled).toBe(true)++ fireEvent.click(body)+ releaseSkillRead()++ await waitFor(() => expect(logic.values.createFromSuggestion).not.toBeNull())+ expect(skillReads).toBe(1)+ logic.unmount()+ })++ // The body wraps the tags, the title and the motivation, so a name built from its children+ // leads with the "Turn on" tag while the press only opens the form.+ it.each([+ {+ kind: 'canonical',+ item: canonicalItem,+ label: 'Review scout: Watch web vitals on the pricing page',+ },+ {+ kind: 'custom',+ item: mockScoutSuggestions[1],+ label: 'Review draft: Watch signup drop-off by plan',+ },+ ])('names the card body after the form it opens on a $kind pick', ({ item, label }) => {+ const { getByLabelText, getByTestId } = render(<ScoutSuggestionCard item={item} surface="strip" />)++ expect(getByLabelText(label)).toBe(getByTestId('scout-suggestion-body'))+ })+})diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionCard.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionCard.tsxindex bf2ccf84b0a3..50560b8aaab7 100644--- a/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionCard.tsx+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionCard.tsx@@ -9,12 +9,9 @@ import type { ScoutSuggestionItemApi } from 'products/signals/frontend/generatedimport type { ScoutSuggestionSurface } from '../../../inboxAnalytics'import { scoutSuggestionsLogic } from '../../../logics/scoutSuggestionsLogic'-import { suggestionCadenceLabel, suggestionMetaLine } from '../../../utils/scoutSuggestions'+import { suggestionMetaLine } from '../../../utils/scoutSuggestions'import { useScoutCreateDisabledReason } from './ScoutCreateModalHost'-/** How much of a drafted scout body the expanded card shows before pointing at the full draft. */-const DRAFT_PREVIEW_CHARS = 400-export interface ScoutSuggestionCardProps {item: ScoutSuggestionItemApisurface: ScoutSuggestionSurface@@ -22,18 +19,26 @@ export interface ScoutSuggestionCardProps {/*** One suggested scout: what it would watch, why it was picked for this project, and the three ways- * to act on it. Clicking the body expands it in place, so reading the whole draft never leaves the- * roster. Both kinds open the create form pre-filled: a custom pick with its draft, a canonical pick- * with the scout that already exists, so the person reads it before turning it on.+ * to act on it. The card carries the motivation only, because the create form already holds the+ * draft, the schedule and the output setting, and is where editing happens. Pressing the body opens+ * that form, so a person reads the offer before anything is written.*/export function ScoutSuggestionCard({ item, surface }: ScoutSuggestionCardProps): JSX.Element {- const { busySuggestionIds, expandedSuggestionId } = useValues(scoutSuggestionsLogic)- const { dismissSuggestion, toggleSuggestionExpanded } = useActions(scoutSuggestionsLogic)+ const { busySuggestionIds } = useValues(scoutSuggestionsLogic)+ const { dismissSuggestion, openCreateFromSuggestion } = useActions(scoutSuggestionsLogic)const isBusy = busySuggestionIds.includes(item.id)- const isExpanded = expandedSuggestionId === item.id+ // A canonical pick only turns a scout on, so the editor gate stops the draft path alone. The+ // busy guard stops both, because a repeat read can put the form back after the person closes it.+ const creationDisabledReason = useScoutCreateDisabledReason()+ const bodyDisabled = isBusy || (item.kind !== 'canonical' && creationDisabledReason !== null)return (- <div className="relative flex flex-col gap-2 rounded border border-primary bg-surface-primary p-3">+ <div+ className={cn(+ 'relative flex flex-col gap-2 rounded border border-primary bg-surface-primary p-3',+ !bodyDisabled && 'transition-colors hover:border-secondary'+ )}+ ><LemonButtonsize="xsmall"icon={<IconX />}@@ -46,18 +51,18 @@ export function ScoutSuggestionCard({ item, surface }: ScoutSuggestionCardProps)/><buttontype="button"- onClick={() => toggleSuggestionExpanded(item, surface)}- className="flex flex-col items-start gap-1.5 pr-6 text-left"- aria-expanded={isExpanded}+ disabled={bodyDisabled}+ onClick={() => openCreateFromSuggestion(item, surface, 'card')}+ className={cn('flex flex-col items-start gap-1.5 pr-6 text-left', !bodyDisabled && 'cursor-pointer')}+ // A name built from the children would lead with the "Turn on" tag and then read the+ // whole motivation, for a press that only opens the form.+ aria-label={`${reviewActionLabel(item)}: ${item.title}`}data-attr="scout-suggestion-body"><SuggestionTags item={item} /><span className="text-sm font-semibold leading-snug">{item.title}</span>- <p className={cn('m-0 text-xs leading-snug text-secondary', !isExpanded && 'line-clamp-2')}>- {item.why_here}- </p>+ <p className="m-0 text-xs leading-snug text-secondary">{item.why_here}</p></button>- {isExpanded && <SuggestionDetails item={item} />}{/* Pushed down so every card in a row puts its buttons on the same line, however manylines its evidence and cadence take. */}<span className="mt-auto pt-1 text-[11px] text-tertiary">{suggestionMetaLine(item.proposed_config)}</span>@@ -66,6 +71,11 @@ export function ScoutSuggestionCard({ item, surface }: ScoutSuggestionCardProps))}+/** What pressing the card does, carried by both the action button and the card body itself. */+function reviewActionLabel(item: ScoutSuggestionItemApi): string {+ return item.kind === 'canonical' ? 'Review scout' : 'Review draft'+}+/** What kind of offer the card makes, and how sure the producer was. */function SuggestionTags({ item }: { item: ScoutSuggestionItemApi }): JSX.Element {const isCanonical = item.kind === 'canonical'@@ -104,14 +114,14 @@ function SuggestionActions({ item, surface, isBusy }: ScoutSuggestionCardProps &return (<div className="flex flex-wrap items-center gap-1.5"><LemonButton- type="primary"+ type="secondary"size="xsmall"loading={isBusy}disabledReason={isCanonical ? undefined : (creationDisabledReason ?? undefined)}onClick={() => openCreateFromSuggestion(item, surface)}data-attr={isCanonical ? 'scout-suggestion-turn-on' : 'scout-suggestion-create'}>- {isCanonical ? 'Turn on' : 'Create scout'}+ {reviewActionLabel(item)}</LemonButton><LemonButtontype="secondary"@@ -126,38 +136,3 @@ function SuggestionActions({ item, surface, isBusy }: ScoutSuggestionCardProps &</div>)}--/** The rest of a suggestion, shown in place once the card is expanded. */-function SuggestionDetails({ item }: { item: ScoutSuggestionItemApi }): JSX.Element {- const draftPreview = item.draft_body.slice(0, DRAFT_PREVIEW_CHARS)-- return (- <div className="flex flex-col gap-2 border-t border-primary pt-2">- {item.description && <p className="m-0 text-xs leading-snug text-secondary">{item.description}</p>}- <dl className="m-0 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs">- <dt className="text-tertiary">Name</dt>- <dd className="m-0 truncate font-mono text-[11px]">{item.skill_name}</dd>- <dt className="text-tertiary">Schedule</dt>- <dd className="m-0">Runs {suggestionCadenceLabel(item.proposed_config)}</dd>- <dt className="text-tertiary">Output</dt>- <dd className="m-0">- {item.proposed_config.emit ? 'Files reports to the inbox' : 'Dry run, files nothing'}- </dd>- </dl>- {draftPreview && (- <div className="flex flex-col gap-1">- <span className="text-[11px] text-tertiary">What it would do on every run</span>- <p className="m-0 whitespace-pre-wrap font-mono text-[11px] leading-snug text-secondary">- {draftPreview}- {item.draft_body.length > DRAFT_PREVIEW_CHARS && '…'}- </p>- {item.draft_body.length > DRAFT_PREVIEW_CHARS && (- <span className="text-[11px] text-tertiary">- Open Create scout to read and edit the whole draft.- </span>- )}- </div>- )}- </div>- )-}diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionsStrip.stories.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionsStrip.stories.tsxindex a9decdfce1e4..3dd3ae85738b 100644--- a/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionsStrip.stories.tsx+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionsStrip.stories.tsx@@ -99,6 +99,29 @@ export const Stale: Story = {],}+// One long motivation beside two short ones: the check that a row no longer stretches to its tallest card.+export const UnevenMotivations: Story = {+ decorators: [+ mswDecorator({+ get: {+ [SUGGESTIONS_URL]: () => [+ 200,+ mockScoutSuggestionSet({+ items: [+ {+ ...mockScoutSuggestions[0],+ why_here:+ 'Checkout is the slowest page in this project on every Core Web Vital, and it has been getting slower for three weeks. Nothing in your fleet reads web vitals today, so a regression here only shows up once someone opens web analytics and looks.',+ },+ ...mockScoutSuggestions.slice(1),+ ],+ }),+ ],+ },+ }),+ ],+}+// A batch shrinks on its own as its picks get created, so one card has to look deliberate.export const SingleCard: Story = {decorators: [diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionsStrip.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionsStrip.tsxindex e2677d61566a..3e732da2ceeb 100644--- a/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionsStrip.tsx+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionsStrip.tsx@@ -143,7 +143,8 @@ function SuggestionGrid({ surface, columns = 3 }: { surface: ScoutSuggestionSurfreturn (<divclassName={cn(- 'grid grid-cols-1 gap-2',+ // Top-aligned, so a longer motivation cannot stretch its neighbours into empty boxes.+ 'grid grid-cols-1 items-start gap-2',// One card in a three-across grid stretches to a third of the row and reads as a// gap where the other two should be, so a lone card keeps a single narrow column.suggestions.length === 1 ? 'max-w-md' : ['@2xl:grid-cols-2', columns === 3 && '@3xl:grid-cols-3']diff --git a/products/signals/frontend/inbox/inboxAnalytics.ts b/products/signals/frontend/inbox/inboxAnalytics.tsindex dbd4e93eb2da..aca362024301 100644--- a/products/signals/frontend/inbox/inboxAnalytics.ts+++ b/products/signals/frontend/inbox/inboxAnalytics.ts@@ -815,7 +815,10 @@ export type ScoutSuggestionSurface = 'strip' | 'empty_state'export type ScoutSuggestionKind = 'canonical' | 'custom'/** What the person did with a suggestion card, beyond creating or dismissing it. */-export type ScoutSuggestionClickTarget = 'expand' | 'collapse' | 'turn_on' | 'create' | 'refine_with_ai'+export type ScoutSuggestionClickTarget = 'turn_on' | 'create' | 'refine_with_ai'++/** What the person pressed to reach that target: the action row's button, or the card body. */+export type ScoutSuggestionClickVia = 'button' | 'card'/** How a suggestion became a scout: the create API in place, or a chat the person drove. */export type ScoutSuggestionCreatedVia = 'api' | 'chat'@@ -844,17 +847,19 @@ export function captureScoutSuggestionsShown(params: {})}-/** A suggestion card was expanded, collapsed, or had one of its actions pressed. */+/** One of a suggestion card's actions was pressed. `via` separates the card body from the button. */export function captureScoutSuggestionClicked(params: {kind: ScoutSuggestionKindskillName: stringtarget: ScoutSuggestionClickTarget+ via: ScoutSuggestionClickViasurface: ScoutSuggestionSurface}): void {captureInboxEvent(INBOX_EVENTS.SCOUT_SUGGESTION_CLICKED, {suggestion_kind: params.kind,skill_name: params.skillName,click_target: params.target,+ via: params.via,surface: params.surface,})}diff --git a/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.test.ts b/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.test.tsindex 231dee98d87b..adaae69a4497 100644--- a/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.test.ts+++ b/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.test.ts@@ -1,6 +1,7 @@import { MOCK_TEAM_ID } from 'lib/api.mock'import { expectLogic } from 'kea-test-utils'+import posthog from 'posthog-js'import { ApiError } from 'lib/api-error'import { FEATURE_FLAGS } from 'lib/constants'@@ -28,6 +29,7 @@ import type {} from 'products/signals/frontend/generated/api.schemas'import { llmSkillsNameRetrieve } from 'products/skills/frontend/generated/api'+import { INBOX_EVENTS } from '../inboxAnalytics'import { scoutFleetLogic } from './scoutFleetLogic'import { scoutSuggestionsLogic } from './scoutSuggestionsLogic'@@ -309,6 +311,23 @@ describe('scoutSuggestionsLogic', () => {expect(logic.values.suggestions.map((item) => item.id)).toEqual([CUSTOM_ITEM.id])})+ it('reports a card-body press as the button it stands in for, marked as the card', async () => {+ await mountWithBatch()+ ;(posthog.capture as jest.Mock).mockClear()++ logic.actions.openCreateFromSuggestion(CUSTOM_ITEM, 'strip', 'card')+ logic.actions.openCreateFromSuggestion(CUSTOM_ITEM, 'strip')+ await expectLogic(logic).toFinishAllListeners()++ const clicks = (posthog.capture as jest.Mock).mock.calls.filter(+ ([event]) => event === INBOX_EVENTS.SCOUT_SUGGESTION_CLICKED+ )+ expect(clicks.map(([, properties]) => [properties.click_target, properties.via])).toEqual([+ ['create', 'card'],+ ['create', 'button'],+ ])+ })+it('sends one refresh request however often the button is pressed while it is out', async () => {await mountWithBatch()diff --git a/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.ts b/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.tsindex 890442525d22..58b01ffa5f23 100644--- a/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.ts+++ b/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.ts@@ -28,7 +28,7 @@ import {ScoutSuggestionKind,ScoutSuggestionSurface,} from '../inboxAnalytics'-import type { ScoutChatType } from '../inboxAnalytics'+import type { ScoutChatType, ScoutSuggestionClickVia } from '../inboxAnalytics'import type { ExistingScoutForSuggestion } from '../utils/scoutSuggestions'import { scoutFleetLogic } from './scoutFleetLogic'import type { SignalScoutConfig } from './scoutFleetLogic'@@ -62,7 +62,6 @@ export interface scoutSuggestionsLogicValues {existing: ExistingScoutForSuggestion | nullitem: ScoutSuggestionItemApi} | null- expandedSuggestionId: string | nullhasPicks: booleanhiddenSuggestionIds: string[]isRefreshing: boolean@@ -147,10 +146,12 @@ export interface scoutSuggestionsLogicActions {}openCreateFromSuggestion: (item: ScoutSuggestionItemApi,- surface: ScoutSuggestionSurface+ surface: ScoutSuggestionSurface,+ via?: ScoutSuggestionClickVia) => {item: ScoutSuggestionItemApisurface: ScoutSuggestionSurface+ via: ScoutSuggestionClickVia}refineSuggestionWithAi: (item: ScoutSuggestionItemApi,@@ -193,13 +194,6 @@ export interface scoutSuggestionsLogicActions {item: ScoutSuggestionItemApisurface: ScoutSuggestionSurface}- toggleSuggestionExpanded: (- item: ScoutSuggestionItemApi,- surface: ScoutSuggestionSurface- ) => {- item: ScoutSuggestionItemApi- surface: ScoutSuggestionSurface- }}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -275,10 +269,11 @@ export const scoutSuggestionsLogic = kea<scoutSuggestionsLogicType>([refineSuggestionWithAi: (item: ScoutSuggestionItemApi, surface: ScoutSuggestionSurface) => ({ item, surface }),restoreSuggestion: (suggestionId: string) => ({ suggestionId }),suggestionActionFinished: (suggestionId: string) => ({ suggestionId }),- openCreateFromSuggestion: (item: ScoutSuggestionItemApi, surface: ScoutSuggestionSurface) => ({- item,- surface,- }),+ openCreateFromSuggestion: (+ item: ScoutSuggestionItemApi,+ surface: ScoutSuggestionSurface,+ via: ScoutSuggestionClickVia = 'button'+ ) => ({ item, surface, via }),closeCreateFromSuggestion: true,askForSuggestions: true,suggestionCreated: (item: ScoutSuggestionItemApi, surface: ScoutSuggestionSurface) => ({ item, surface }),@@ -289,10 +284,6 @@ export const scoutSuggestionsLogic = kea<scoutSuggestionsLogicType>([setCollapsed: (collapsed: boolean) => ({ collapsed }),hideStrip: true,showStrip: true,- toggleSuggestionExpanded: (item: ScoutSuggestionItemApi, surface: ScoutSuggestionSurface) => ({- item,- surface,- }),reportSuggestionsShown: (surface: ScoutSuggestionSurface) => ({ surface }),}),@@ -356,12 +347,6 @@ export const scoutSuggestionsLogic = kea<scoutSuggestionsLogicType>([refreshFinished: () => false,},],- expandedSuggestionId: [- null as string | null,- {- toggleSuggestionExpanded: (state, { item }) => (state === item.id ? null : item.id),- },- ],createFromSuggestion: [null as { item: ScoutSuggestionItemApi; existing: ExistingScoutForSuggestion | null } | null,{@@ -487,6 +472,7 @@ export const scoutSuggestionsLogic = kea<scoutSuggestionsLogicType>([kind: suggestionKind(item),skillName: item.skill_name,target: 'refine_with_ai',+ via: 'button',surface,})// The server builds the primed first turn from the stored draft, so the chat opens on@@ -507,11 +493,12 @@ export const scoutSuggestionsLogic = kea<scoutSuggestionsLogicType>([cache.refiningSuggestionId = null}},- openCreateFromSuggestion: async ({ item, surface }) => {+ openCreateFromSuggestion: async ({ item, surface, via }) => {captureScoutSuggestionClicked({kind: suggestionKind(item),skillName: item.skill_name,target: item.kind === 'canonical' ? 'turn_on' : 'create',+ via,surface,})if (item.kind !== 'canonical') {@@ -558,15 +545,6 @@ export const scoutSuggestionsLogic = kea<scoutSuggestionsLogicType>([})actions.loadSuggestions()},- toggleSuggestionExpanded: ({ item, surface }) => {- captureScoutSuggestionClicked({- kind: suggestionKind(item),- skillName: item.skill_name,- // The reducer has already applied the toggle, so this reads the resulting state.- target: values.expandedSuggestionId === item.id ? 'expand' : 'collapse',- surface,- })- },reportSuggestionsShown: ({ surface }) => {captureScoutSuggestionsShown({count: values.suggestions.length,