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.

feat(signals): render suggested scouts as rows (#106924)

posthog[bot]5f19325fbf1f
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index a5667977c5a1..02fd26f7370a 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -10599,25 +10599,25 @@ snapshots:
scenes-app-inbox-scoutsuggestionsstrip--collapsed--light:
hash: v1.k794b7964.ba1f143cb325b76519cbdd1b4d4b4ea85a86f5ce65609d2bd11027abb52ac503.Q79LTT3ZvTskWzqQLabkD8PvFaMpD2OgM-J5OsSPaMc
scenes-app-inbox-scoutsuggestionsstrip--empty-fleet--dark:
- hash: v1.k794b7964.a9e935349a3145375d09cc1a483fd4cf2a760256000855e6e15a4cfaf2548236.mRkmlsFFKTFT_U5FUUw4ltXiVW4u7ICa1YC424x5GJE
+ hash: v1.k794b7964.fd441460b2ff862f967f3c9bcd89fa58ad9e2ee9f23562d1490c8cdd41b766d8.8HR7wuFeVTJ26_uxCHRT-UZ0g8cNGFEE6xgCgL5bgEM
scenes-app-inbox-scoutsuggestionsstrip--empty-fleet--light:
- hash: v1.k794b7964.90d7232a692b063940384aa89d05c70e2c1af66eeeca08fe49bcdd9938e456a0.a3KW1AmgQwcQV84WzmFAeCk_ars13rMcEHeBSkn8S-c
+ hash: v1.k794b7964.d5c840f6a8a9a11c1c7e9a745c0575fad242dc6964ba25d29beddab98bcd00c5.N6CIKt8UghLILWUMTmR_myoRKavqFfwJB2le4cm7euk
scenes-app-inbox-scoutsuggestionsstrip--fresh--dark:
- hash: v1.k794b7964.570417fc559c4110bafec16cae540482291367ab8bd2de079ac60e5a7f00cdf0.xizQ1nHgCk4yYIF0A6lGvvcdD53WyCtXiCHRq7jnXPc
+ hash: v1.k794b7964.154e5aab3bc777cb4dbda3c04337da204207a3d65da56cf3a45380ce8db7f134.5hkmLqsOVVI30IkCk8uBUw71ryKaJzyMfF8tv142vIY
scenes-app-inbox-scoutsuggestionsstrip--fresh--light:
- hash: v1.k794b7964.c27d35c322743ada3c9189be878c17324ed9225e3abe84d0d8f4cba296af874d.KvV9wXRx-aX91LPGV8mBSwOSBX_gQVO-4KEH5mbxlV4
+ hash: v1.k794b7964.3aa421a902014d74bdbd7401d4ef45e9dc8aafbcafb3d5e7a3a51b86d04f6edf.lej2k2ZLQ8Kg3_Lhy9ijlaNr0wmoSRv29VDtWEHkG4o
scenes-app-inbox-scoutsuggestionsstrip--last-scan-failed--dark:
- hash: v1.k794b7964.de465356e1d0c3d5df4e27a38f222f1272cd482864e94f5c0926496b21585156.JrxNWbA8ll95SmETdYceyyUM7OXvaVFv4m2ZNqLTEc0
+ hash: v1.k794b7964.82cad8274617452c519e90046e04cfa8044dae0a3d401e94f298ec887b79b8c7.XBG7WRCfVj9GmUGM0NUAP5vgMWAWeEupplFBxwjoKwY
scenes-app-inbox-scoutsuggestionsstrip--last-scan-failed--light:
- hash: v1.k794b7964.862bc68a11983494741c4d1522c7a0b5a9dbc62fa096994e7ca39fcee696dc45.Gqy-Dr8yrhe7v2EdrEZFwjferFE9JMtvLBRegJF3Ebw
+ hash: v1.k794b7964.d00b8582a289f905268875ce9841d96720d8dc22e4af5ad09e464bb051817e61.PcTLkhlwDdhAxWG0jixUMw5A4x8RT272rW5Dily6opo
scenes-app-inbox-scoutsuggestionsstrip--low-activity--dark:
- hash: v1.k794b7964.732c41df9211ce01adee553f66133484b9e5ea18986cf871c44f27fa88846754.DoN92tzMp60OUzfZtXPqKJ9UiDTVJC9sLc5nQVmjHzU
+ hash: v1.k794b7964.9a30ac4b6f4fa1df1c6b74411d64befcc89b62aa6f03f733cd6badfa59839dca.mRQAC_yBIQg-IKff43vpG_TdKAx5axt_jo3A0AwGNFY
scenes-app-inbox-scoutsuggestionsstrip--low-activity--light:
- hash: v1.k794b7964.9073f092aa4a347930e8468bb2f212bbdbe96a636a9fbce691cffa6caa493b07.YTmjGLtgppZg6VzdbUe-5cMUkxvsWUPRELqQMczJIc8
+ hash: v1.k794b7964.d3e9167ac6ce1fa16ab27175c2f62dec069c739efb213391b0c652a736d1920b.po2oo5Ii0tv7MLw6_SkVWHjGlmg7Nwvbua4MVcAkQ2o
scenes-app-inbox-scoutsuggestionsstrip--narrow--dark:
- hash: v1.k794b7964.d16cb21c4d654c63d5f8b6047b3291b636b25e21b00a91b06bd8384967f8a4ef.h9itg-CPeBGLngbSfw7_TIYGEJHnd_Z_sQ4VYIS5u0k
+ hash: v1.k794b7964.b9ca13a41bed32023a43f006360e43b4b321b1e6cb31998e2eb3e860eac7a0f6.lDOXRuPYgisBlZOeEdJmKfyq2H55P3xVgiH_ZoqGFL8
scenes-app-inbox-scoutsuggestionsstrip--narrow--light:
- hash: v1.k794b7964.f53bb4fb7dcec95a06ccdb77e47ef05be374c48412a94f0bb9946aa992800a26.eEq4lrjpj4xFevZ3ltME_QTM3VLUFCiT09vgfY_jYI0
+ hash: v1.k794b7964.7ac141242ca1eff00382eabeb3a43499013fe0fd5348caa2fdb68358b546607f.hPLQzahnOp_1pNfmoDe6VzfxtpeAmbltAjv4ATkrFSk
scenes-app-inbox-scoutsuggestionsstrip--never-generated--dark:
hash: v1.k794b7964.1fa499f9b82d53b5303ac9c1aad41ae71c3181773bfebff8484f9aac6a5d7ad5.ulg5fyOIsf7mnLJJRsP0QggXrvaVc8UBP43QUI6WGmo
scenes-app-inbox-scoutsuggestionsstrip--never-generated--light:
@@ -10627,29 +10627,29 @@ snapshots:
scenes-app-inbox-scoutsuggestionsstrip--nothing-left--light:
hash: v1.k794b7964.b131d6038274a4ece4e940b9c90ba7d95e5a42fd946e78af7b4890049dec8e40.rpllE4H8WWpI6z-X5e5o_L19g9wUm6GPPVhLEMZ8s2g
scenes-app-inbox-scoutsuggestionsstrip--scanning--dark:
- hash: v1.k794b7964.02501aac586d12ac2cc0340fdac0d179a39eb4b8cc2f9532b5967c5681426088.o9gSlGc8K-5d-b0_iNcizWHVAi4ZF2pbHNANf8yVKHg
+ hash: v1.k794b7964.fe17e02125d5449e3505ef3bf61b5eb47bc0b332b831d679499af31aca5170de.C2y66KYFOQzGpFHnUyIhhou0Y8C3Xz8vsapiE6amba4
scenes-app-inbox-scoutsuggestionsstrip--scanning--light:
- hash: v1.k794b7964.cf75d9626a024617eb2bd00f0e7b5ea6aa5610289ea6083dc1161d1d5dd5687d.vS3wXU4w3UhH6WmNLujNwzrZqEs8tbth-hFf5iGxaXo
+ hash: v1.k794b7964.6f26390a759466930ab1593b023d8259eef4aa7c982087856a004c53618d302f.P-OJIu7MDI25Bg46abneQpEKpiqLtNxjui3EOLQMD2Y
scenes-app-inbox-scoutsuggestionsstrip--scanning-collapsed--dark:
hash: v1.k794b7964.63545765bd0fe34efaf7e3ffe818f0d738caf1d73488fde1033643314d4fb661.vrZopp4IB05ShUMt04rlcq7-lUx7SOKUdaeRStEFLDs
scenes-app-inbox-scoutsuggestionsstrip--scanning-collapsed--light:
hash: v1.k794b7964.e50cd1debd9222ccdc678191c8379c5cfabd8f484da0a82620fd1e76d2fd0183.oAkedvj_wiFanZgVYWxupy_lfqpyvLqBSg-Be1NtoFo
scenes-app-inbox-scoutsuggestionsstrip--scanning-with-nothing-to-show--dark:
- hash: v1.k794b7964.1ceb10e92b2b174ad12028c17dde944d0b0bc97c5b53bada9bf8a97ad01ab57a.VtAaDb7E-Kpob6xvmMPpbF0RqFpS03CJDVueTO39bhw
+ hash: v1.k794b7964.73f3ffff8f7508a460832449029b14420749d6fef3142fc4eea0d3b907d13bf1.2fnxAkaYyzXWb34r0S-zfhMNs_geRXqW0ruACUWHXLE
scenes-app-inbox-scoutsuggestionsstrip--scanning-with-nothing-to-show--light:
- hash: v1.k794b7964.3b0428f8278265e294340d9efd8410b2c805be5bf34a99e9c3b1f9121091ca00.O4pbyxNxgAnYJRBrhvNb1HX7nuJaxOmSgIcacOF5EmI
- scenes-app-inbox-scoutsuggestionsstrip--single-card--dark:
- hash: v1.k794b7964.7fb39e9f73376af10a4d336e214bd06938b336e030eb38fcc5dd93e528617ae1.4KJIUej-HPwSTEhDnsUxZ6Hh-fsp7CriBnUReVYTwa4
- scenes-app-inbox-scoutsuggestionsstrip--single-card--light:
- hash: v1.k794b7964.02340737115749e8a564e476d98b29f4b48c64749a785d93540f6ac1ea7be4ab.3xA716O2PrpfwKlGXo3SfaX3BXUXs_FtrjttYE4OKio
+ hash: v1.k794b7964.058cf2e011f6da4340efd1a02ef55d00242832cd2f524d40e5498d1791ce96d1.PqCtJgnEMpVO1UwL8zAGmVjoXEjlrqM6FGvB8A1xrno
+ scenes-app-inbox-scoutsuggestionsstrip--single-row--dark:
+ hash: v1.k794b7964.32ce444bc33f629c73648020c1c248ebd5991b19973de52362b2b96d56d8e75e.63YtWCu-_B-iwQDHWNq-8J-7kAvrR_NPBJn3fBeWRpo
+ scenes-app-inbox-scoutsuggestionsstrip--single-row--light:
+ hash: v1.k794b7964.80a585d188099a095603bff57292e5f36a4f59f3b945639a6302aaf4fc9eabc2.ek9q8ieaHFDd44VyWLBjGLL5wtUIKrk5YHRMUY8bpLk
scenes-app-inbox-scoutsuggestionsstrip--stale--dark:
- hash: v1.k794b7964.7e2fdf9c89dde86490a07cc7ec325a0944e7de0ea176267adeb68399511bc59d.qOHNB134qWxXVmDejFTj4zBeHmSs5W6YwXwPDDosGDs
+ hash: v1.k794b7964.af13f3fa290ce9f4deb019f46589983c43b7ecbf0da7000c61bc0730ab76140c.n040TecC4_mIKmyR62Rtq40IcGrwD7J6uSgZK3nh3ak
scenes-app-inbox-scoutsuggestionsstrip--stale--light:
- hash: v1.k794b7964.570754184d02350f0aa7aeb0551dcf4193adc7bf7e98b96837d83ad943fad285.HwY3-lDJfFM-XdprlRu32W06EqFnhydh4A2GqqLZw4k
+ hash: v1.k794b7964.3873fa5ef86e2b729be37b2d9305e3d323d7fdeb9486114ab94e0d1aa3d253f4.wRDurRZfiGlUYfdbUoLDkfcsSstWEctdd-GGuQfHu3g
scenes-app-inbox-scoutsuggestionsstrip--uneven-motivations--dark:
- hash: v1.k794b7964.522e12df24c16e51c08bddd3ab68137dcd39513e11c8874cc0f8a3309a3958e0.HnUHqh1rFVoNq9orm2xGyOGw7Ks_m_pl6AgecpsNwGs
+ hash: v1.k794b7964.b993087e480fc1db681058fc86f14bf1320b761a28da857e794cce6af50b0b99.-nJybLR6PljBiMrTrLZm0x-iWWMqIJHWFKWMe3JQqFI
scenes-app-inbox-scoutsuggestionsstrip--uneven-motivations--light:
- hash: v1.k794b7964.85244b3882afe2a024d9aac8b6a4b626fe5efe4cde65d265e554ccd75ee87a0d._NkkpHjYmgDw2mBavm1_jUZomc0i6WQAM5Xyj6ZIKOU
+ hash: v1.k794b7964.507bd34c3dfd17859203839ee2b48fde2356feeb39c5ea68a85111e81bde3653.BAUoWqxWUpZedEPIrw8_XyDM2Gpe1d49RqS76agw8H8
scenes-app-inbox-scoutwriteaccesstag--compact--dark:
hash: v1.k794b7964.449b1898c216f12c6a62f2c0a1544ce814cdc7e4d519c69287d686e8b9a90b79.yXNYamE5tvB24QXwyniqxYtd3IAlRpo-RoLspp9zOKQ
scenes-app-inbox-scoutwriteaccesstag--compact--light:
diff --git a/frontend/src/lib/cron.ts b/frontend/src/lib/cron.ts
index 09e88aee16c8..631922e894d1 100644
--- a/frontend/src/lib/cron.ts
+++ b/frontend/src/lib/cron.ts
@@ -9,7 +9,10 @@ function hasFiveFields(expr: string): boolean {
}
/** Human-readable description of a 5-field cron expression, or an error string. Returns null for empty input. */
-export function describeCron(expr: string | null | undefined): string | null {
+export function describeCron(
+ expr: string | null | undefined,
+ options?: Parameters<typeof cronstrue.toString>[1]
+): string | null {
if (!expr) {
return null
}
@@ -21,7 +24,7 @@ export function describeCron(expr: string | null | undefined): string | null {
// produce garbled output (e.g. "Monday through undefined") for
// syntactically incomplete expressions like "0 9 * * 1-".
CronExpressionParser.parse(expr)
- return cronstrue.toString(expr)
+ return cronstrue.toString(expr, options)
} catch {
return 'Invalid cron expression'
}
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionCard.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionCard.tsx
index 50560b8aaab7..efb8b7c2a16e 100644
--- a/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionCard.tsx
+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionCard.tsx
@@ -1,9 +1,11 @@
import { useActions, useValues } from 'kea'
+import { useLayoutEffect, useRef, useState } from 'react'
import { IconSparkles, IconX } from '@posthog/icons'
-import { LemonButton, LemonTag, Tooltip } from '@posthog/lemon-ui'
+import { LemonButton, LemonTag, Link, Tooltip } from '@posthog/lemon-ui'
import { cn } from 'lib/utils/css-classes'
+import { capitalizeFirstLetter } from 'lib/utils/strings'
import type { ScoutSuggestionItemApi } from 'products/signals/frontend/generated/api.schemas'
@@ -18,65 +20,96 @@ 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. 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.
+ * One suggested scout as a row: what it would watch, why it was picked for this project, and the
+ * three ways to act on it. The row 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 } = useValues(scoutSuggestionsLogic)
- const { dismissSuggestion, openCreateFromSuggestion } = useActions(scoutSuggestionsLogic)
+ const { openCreateFromSuggestion } = useActions(scoutSuggestionsLogic)
const isBusy = busySuggestionIds.includes(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)
+ const [expanded, setExpanded] = useState(false)
+ const [overflowing, setOverflowing] = useState(false)
+ const motivationRef = useRef<HTMLParagraphElement>(null)
+ const motivationId = `scout-suggestion-motivation-${item.id}`
+
+ useLayoutEffect(() => {
+ const element = motivationRef.current
+ if (expanded || !element) {
+ return
+ }
+ const checkOverflow = (): void => setOverflowing(element.scrollHeight > element.clientHeight + 1)
+ checkOverflow()
+ const observer = new ResizeObserver(checkOverflow)
+ observer.observe(element)
+ return () => observer.disconnect()
+ }, [item.why_here, expanded])
+
return (
<div
className={cn(
- 'relative flex flex-col gap-2 rounded border border-primary bg-surface-primary p-3',
- !bodyDisabled && 'transition-colors hover:border-secondary'
+ 'flex flex-col gap-2 px-3 py-2.5 @2xl:flex-row @2xl:items-start @2xl:gap-4',
+ !bodyDisabled && 'transition-colors hover:bg-surface-secondary'
)}
>
- <LemonButton
- size="xsmall"
- icon={<IconX />}
- tooltip="Dismiss. This won't be suggested again."
- disabledReason={isBusy ? 'Working on this suggestion' : undefined}
- onClick={() => dismissSuggestion(item, surface)}
- className="absolute right-1 top-1"
- aria-label={`Dismiss ${item.title}`}
- data-attr="scout-suggestion-dismiss"
- />
- <button
- type="button"
- 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="m-0 text-xs leading-snug text-secondary">{item.why_here}</p>
- </button>
- {/* Pushed down so every card in a row puts its buttons on the same line, however many
- lines its evidence and cadence take. */}
- <span className="mt-auto pt-1 text-[11px] text-tertiary">{suggestionMetaLine(item.proposed_config)}</span>
+ <div className="flex min-w-0 flex-1 flex-col items-start gap-1">
+ <button
+ type="button"
+ disabled={bodyDisabled}
+ onClick={() => openCreateFromSuggestion(item, surface, 'card')}
+ className={cn(
+ 'flex max-w-full flex-col items-start gap-1 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"
+ >
+ <div className="flex max-w-full flex-wrap items-center gap-x-2 gap-y-1">
+ <span className="min-w-0 truncate text-sm font-semibold leading-snug">{item.title}</span>
+ <SuggestionTags item={item} />
+ </div>
+ <p
+ ref={motivationRef}
+ id={motivationId}
+ className={cn('m-0 text-xs leading-snug text-secondary', !expanded && 'line-clamp-2')}
+ >
+ {item.why_here}
+ </p>
+ </button>
+ <div className="flex flex-wrap items-center gap-x-2 text-[11px]">
+ <span className="text-tertiary">{suggestionMetaLine(item.proposed_config)}</span>
+ {/* Outside the row button, so keyboard and touch users can read the full motivation. */}
+ {(overflowing || expanded) && (
+ <Link
+ onClick={() => setExpanded(!expanded)}
+ aria-expanded={expanded}
+ aria-controls={motivationId}
+ data-attr="scout-suggestion-motivation-toggle"
+ >
+ {expanded ? 'Show less' : 'Show more'}
+ </Link>
+ )}
+ </div>
+ </div>
<SuggestionActions item={item} surface={surface} isBusy={isBusy} />
</div>
)
}
-/** What pressing the card does, carried by both the action button and the card body itself. */
+/** What pressing the row does, carried by both the action button and the row 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. */
+/** What kind of offer the row makes, and how sure the producer was. */
function SuggestionTags({ item }: { item: ScoutSuggestionItemApi }): JSX.Element {
const isCanonical = item.kind === 'canonical'
return (
@@ -91,15 +124,17 @@ function SuggestionTags({ item }: { item: ScoutSuggestionItemApi }): JSX.Element
</LemonTag>
</Tooltip>
)}
- <span className="text-[11px] text-muted">{item.confidence} confidence</span>
+ <LemonTag type="muted" size="small">
+ {capitalizeFirstLetter(item.confidence)} confidence
+ </LemonTag>
</div>
)
}
-/** The card's primary action, which depends on its kind, next to the chat that refines it. */
+/** The row's primary action, which depends on its kind, the chat that refines it, and dismiss. */
function SuggestionActions({ item, surface, isBusy }: ScoutSuggestionCardProps & { isBusy: boolean }): JSX.Element {
const { aiConsentDisabledReason, runningChatType } = useValues(scoutSuggestionsLogic)
- const { refineSuggestionWithAi, openCreateFromSuggestion } = useActions(scoutSuggestionsLogic)
+ const { refineSuggestionWithAi, openCreateFromSuggestion, dismissSuggestion } = useActions(scoutSuggestionsLogic)
// A canonical pick opens the same form on the scout that already exists, so the person reads it
// before it runs, and submitting only writes the config. Creating a draft and refining with AI
// both end in a skill write, so those two carry the editor gate.
@@ -112,13 +147,15 @@ function SuggestionActions({ item, surface, isBusy }: ScoutSuggestionCardProps &
const isCanonical = item.kind === 'canonical'
return (
- <div className="flex flex-wrap items-center gap-1.5">
+ <div className="flex shrink-0 flex-wrap items-center gap-1.5">
<LemonButton
type="secondary"
size="xsmall"
loading={isBusy}
disabledReason={isCanonical ? undefined : (creationDisabledReason ?? undefined)}
onClick={() => openCreateFromSuggestion(item, surface)}
+ // One width for both labels, so the group starts at the same x on every row.
+ className="min-w-24 justify-center"
data-attr={isCanonical ? 'scout-suggestion-turn-on' : 'scout-suggestion-create'}
>
{reviewActionLabel(item)}
@@ -133,6 +170,15 @@ function SuggestionActions({ item, surface, isBusy }: ScoutSuggestionCardProps &
>
Refine with AI
</LemonButton>
+ <LemonButton
+ size="xsmall"
+ icon={<IconX />}
+ tooltip="Dismiss. This won't be suggested again."
+ disabledReason={isBusy ? 'Working on this suggestion' : undefined}
+ onClick={() => dismissSuggestion(item, surface)}
+ aria-label={`Dismiss ${item.title}`}
+ data-attr="scout-suggestion-dismiss"
+ />
</div>
)
}
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionsStrip.stories.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionsStrip.stories.tsx
index 477c2a50bc8f..7b2995d31af1 100644
--- a/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionsStrip.stories.tsx
+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionsStrip.stories.tsx
@@ -105,7 +105,8 @@ export const Stale: Story = {
],
}
-// One long motivation beside two short ones: the check that a row no longer stretches to its tallest card.
+// One long motivation above two short ones: the check that the motivation clamps to two lines and
+// the actions stay in line on every row.
export const UnevenMotivations: Story = {
decorators: [
mswDecorator({
@@ -128,8 +129,8 @@ export const UnevenMotivations: Story = {
],
}
-// A batch shrinks on its own as its picks get created, so one card has to look deliberate.
-export const SingleCard: Story = {
+// A batch shrinks on its own as its picks get created, so one row has to look deliberate.
+export const SingleRow: Story = {
decorators: [
mswDecorator({
get: { [SUGGESTIONS_URL]: () => [200, mockScoutSuggestionSet({ items: [mockScoutSuggestions[1]] })] },
@@ -203,7 +204,7 @@ export const NeverGenerated: Story = {
],
}
-// An empty fleet gets the same cards as the body of the empty state.
+// An empty fleet gets the same rows as the body of the empty state.
export const EmptyFleet: Story = {
decorators: [
mswDecorator({
@@ -216,10 +217,10 @@ export const EmptyFleet: Story = {
],
}
-// The narrow scene a sidebar plus an open side panel leaves: the card grid drops to one column.
+// The narrow scene a sidebar plus an open side panel leaves: the actions wrap under the text.
export const Narrow: Story = {
parameters: {
- testOptions: { viewport: { width: 600, height: 900 }, waitForLoadersToDisappear: false },
+ testOptions: { viewport: { width: 520, height: 900 }, waitForLoadersToDisappear: false },
},
decorators: [mswDecorator({ get: { [SUGGESTIONS_URL]: () => [200, mockScoutSuggestionSet()] } })],
}
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionsStrip.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionsStrip.tsx
index 96535b467d25..87eba5d9da90 100644
--- a/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionsStrip.tsx
+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionsStrip.tsx
@@ -90,7 +90,7 @@ export function ScoutSuggestionsStrip(): JSX.Element | null {
)
}
-/** Whichever of the strip's states applies: collapsed, placeholders with nothing yet to read, or the cards. */
+/** Whichever of the strip's states applies: collapsed, placeholders with nothing yet to read, or the rows. */
function StripBody(): JSX.Element {
const { suggestions, collapsed, batchStatus, isRefreshing, suggestionSetLoading } = useValues(scoutSuggestionsLogic)
@@ -114,7 +114,7 @@ function StripBody(): JSX.Element {
}
return (
<>
- <SuggestionGrid surface="strip" />
+ <SuggestionList surface="strip" />
{isRefreshing && <ScanningNote />}
<div className="flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted">
{batchStatus === 'stale' && (
@@ -140,7 +140,7 @@ function StripBody(): JSX.Element {
)
}
-/** The suggestion cards on their own, for the empty state's body. */
+/** The suggestion rows on their own, for the empty state's body. */
export function ScoutSuggestionsEmptyStateCards(): JSX.Element | null {
const { hasPicks } = useValues(scoutSuggestionsLogic)
useReportSuggestionsShown('empty_state')
@@ -151,24 +151,17 @@ export function ScoutSuggestionsEmptyStateCards(): JSX.Element | null {
return (
<div className="flex w-full flex-col gap-3">
- <SuggestionGrid surface="empty_state" columns={2} />
+ <SuggestionList surface="empty_state" />
<ScoutSuggestionCreateHost surface="empty_state" />
</div>
)
}
-function SuggestionGrid({ surface, columns = 3 }: { surface: ScoutSuggestionSurface; columns?: 2 | 3 }): JSX.Element {
+/** Full-width rows with dividers, the same shape as the roster rows under the strip. */
+function SuggestionList({ surface }: { surface: ScoutSuggestionSurface }): JSX.Element {
const { suggestions } = useValues(scoutSuggestionsLogic)
return (
- <div
- className={cn(
- // 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']
- )}
- >
+ <div className="@container divide-y divide-primary overflow-hidden rounded border border-primary bg-surface-primary">
{suggestions.map((item) => (
<ScoutSuggestionCard key={item.id} item={item} surface={surface} />
))}
@@ -203,13 +196,12 @@ function CollapsedLine({ titles }: { titles: string[] }): JSX.Element {
function SuggestionsSkeleton(): JSX.Element {
return (
- <div className="grid grid-cols-1 gap-2 @2xl:grid-cols-2 @3xl:grid-cols-3">
+ <div className="divide-y divide-primary rounded border border-primary bg-surface-primary">
{[0, 1, 2].map((index) => (
- <div key={index} className="flex flex-col gap-2 rounded border border-primary bg-surface-primary p-3">
- <LemonSkeleton className="h-3.5 w-16" />
- <LemonSkeleton className="h-3.5 w-4/5" />
- <LemonSkeleton className="h-3 w-full" />
- <LemonSkeleton className="h-6 w-24 rounded" />
+ <div key={index} className="flex flex-col gap-1.5 px-3 py-2.5">
+ <LemonSkeleton className="h-3.5 w-1/3" />
+ <LemonSkeleton className="h-3 w-4/5" />
+ <LemonSkeleton className="h-3 w-24" />
</div>
))}
</div>
diff --git a/products/signals/frontend/inbox/utils/scoutSuggestions.test.ts b/products/signals/frontend/inbox/utils/scoutSuggestions.test.ts
index af14b9e1799c..b5e92d56e807 100644
--- a/products/signals/frontend/inbox/utils/scoutSuggestions.test.ts
+++ b/products/signals/frontend/inbox/utils/scoutSuggestions.test.ts
@@ -1,40 +1,62 @@
-import type { ScoutSuggestionItemApi, SignalScoutConfigApi } from 'products/signals/frontend/generated/api.schemas'
+import type {
+ ScoutSuggestionItemApi,
+ ScoutSuggestionProposedConfigApi,
+ SignalScoutConfigApi,
+} from 'products/signals/frontend/generated/api.schemas'
-import { suggestionToCreateValues } from './scoutSuggestions'
+import { suggestionMetaLine, suggestionToCreateValues } from './scoutSuggestions'
-describe('suggestionToCreateValues', () => {
- it("carries an existing scout's repositories and write access into the form", () => {
- // Turning an existing scout on PATCHes the whole form back, so a field the mapper leaves
- // out is submitted as its empty default and the scout loses it.
- const item = {
- id: 'suggestion-1',
- skill_name: 'signals-scout-foo',
- description: 'proposed',
- draft_body: 'body',
- proposed_config: { run_cron_schedule: null, run_interval_minutes: null, emit: true },
- } as unknown as ScoutSuggestionItemApi
- const config = {
- id: 'config-1',
- emit: false,
- output_destinations: {},
- tags: ['billing'],
- mcp_gateway_server_ids: ['11111111-1111-1111-1111-111111111111'],
- repositories: ['acme-co/app', 'acme-co/docs'],
- write_scopes: ['dashboard:write'],
- run_cron_schedule: '30 9 * * *',
- run_interval_minutes: 1440,
- } as unknown as SignalScoutConfigApi
+describe('scoutSuggestions', () => {
+ describe('suggestionMetaLine', () => {
+ it.each([
+ [
+ { run_cron_schedule: '30 9 * * 1-5', run_interval_minutes: null, emit: true },
+ 'Runs at 09:30, Monday through Friday',
+ ],
+ [{ run_cron_schedule: '0 9 * * *', run_interval_minutes: null, emit: true }, 'Runs daily at 09:00'],
+ [
+ { run_cron_schedule: null, run_interval_minutes: 720, emit: false },
+ 'Runs every 12h · dry run, files nothing',
+ ],
+ ])('describes %j as %s', (config, expected) => {
+ expect(suggestionMetaLine(config as ScoutSuggestionProposedConfigApi)).toBe(expected)
+ })
+ })
+
+ describe('suggestionToCreateValues', () => {
+ it("carries an existing scout's repositories and write access into the form", () => {
+ // Turning an existing scout on PATCHes the whole form back, so a field the mapper leaves
+ // out is submitted as its empty default and the scout loses it.
+ const item = {
+ id: 'suggestion-1',
+ skill_name: 'signals-scout-foo',
+ description: 'proposed',
+ draft_body: 'body',
+ proposed_config: { run_cron_schedule: null, run_interval_minutes: null, emit: true },
+ } as unknown as ScoutSuggestionItemApi
+ const config = {
+ id: 'config-1',
+ emit: false,
+ output_destinations: {},
+ tags: ['billing'],
+ mcp_gateway_server_ids: ['11111111-1111-1111-1111-111111111111'],
+ repositories: ['acme-co/app', 'acme-co/docs'],
+ write_scopes: ['dashboard:write'],
+ run_cron_schedule: '30 9 * * *',
+ run_interval_minutes: 1440,
+ } as unknown as SignalScoutConfigApi
- const values = suggestionToCreateValues(item, { config, description: 'existing', body: 'existing body' })
+ const values = suggestionToCreateValues(item, { config, description: 'existing', body: 'existing body' })
- expect(values.existingConfigId).toBe('config-1')
- expect(values.config).toMatchObject({
- emit: false,
- tags: ['billing'],
- mcp_gateway_server_ids: ['11111111-1111-1111-1111-111111111111'],
- repositories: ['acme-co/app', 'acme-co/docs'],
- write_scopes: ['dashboard:write'],
- run_cron_schedule: '30 9 * * *',
+ expect(values.existingConfigId).toBe('config-1')
+ expect(values.config).toMatchObject({
+ emit: false,
+ tags: ['billing'],
+ mcp_gateway_server_ids: ['11111111-1111-1111-1111-111111111111'],
+ repositories: ['acme-co/app', 'acme-co/docs'],
+ write_scopes: ['dashboard:write'],
+ run_cron_schedule: '30 9 * * *',
+ })
})
})
})
diff --git a/products/signals/frontend/inbox/utils/scoutSuggestions.ts b/products/signals/frontend/inbox/utils/scoutSuggestions.ts
index 4369791fc748..5ab69ca8a4c6 100644
--- a/products/signals/frontend/inbox/utils/scoutSuggestions.ts
+++ b/products/signals/frontend/inbox/utils/scoutSuggestions.ts
@@ -16,15 +16,23 @@ export const DEFAULT_SUGGESTION_INTERVAL_MINUTES = 1440
export function suggestionCadenceLabel(config: ScoutSuggestionProposedConfigApi): string {
if (config.run_cron_schedule) {
const dailyTime = dailyCronToTime(config.run_cron_schedule)
- return dailyTime ? `daily at ${dailyTime}` : (describeCron(config.run_cron_schedule)?.toLowerCase() ?? 'daily')
+ if (dailyTime) {
+ return `daily at ${dailyTime}`
+ }
+ // The times are 24h, so cronstrue must not add "AM". Day names keep their capitals.
+ const described = describeCron(config.run_cron_schedule, { use24HourTimeFormat: true })
+ return described ? described.charAt(0).toLowerCase() + described.slice(1) : 'daily'
}
return formatRunIntervalShort(config.run_interval_minutes ?? DEFAULT_SUGGESTION_INTERVAL_MINUTES)
}
-/** The card's one-line summary of what the scout would do: how often, and where its output goes. */
+/**
+ * The one-line summary of what the scout would do. The output shows only when it is not the
+ * default, because every row would otherwise repeat "files reports to the inbox".
+ */
export function suggestionMetaLine(config: ScoutSuggestionProposedConfigApi): string {
- const output = config.emit ? 'files reports to the inbox' : 'dry run, files nothing'
- return `Runs ${suggestionCadenceLabel(config)} · ${output}`
+ const cadence = `Runs ${suggestionCadenceLabel(config)}`
+ return config.emit ? cadence : `${cadence} · dry run, files nothing`
}
/** The scout a canonical pick would turn on, as it exists on the project. */