: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
fix(signals): search the scout roster by the name on the card (#101836)
posthog[bot]43c110382a2c
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutRosterCard.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutRosterCard.tsxindex e03e48b310be..3abe52e5a766 100644--- a/products/signals/frontend/inbox/components/config/scouts/ScoutRosterCard.tsx+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutRosterCard.tsx@@ -1,4 +1,5 @@import { useActions, useValues } from 'kea'+import { memo } from 'react'import { Link } from '@posthog/lemon-ui'@@ -34,8 +35,11 @@ function MetaSeparator(): JSX.Element {* last checked, and its cadence on the left; the recent-run strip and the on/off switch on the* right. The body links to the scout page. The run boxes and the switch sit outside that link, so* a run box opens its task and the switch flips the scout without opening it.+ *+ * Memoized: a roster row keeps its identity while the search box narrows the list, so typing+ * re-renders only the cards that entered or left it.*/-export function ScoutRosterCard({ row }: { row: ScoutRosterRow }): JSX.Element {+export const ScoutRosterCard = memo(function ScoutRosterCard({ row }: { row: ScoutRosterRow }): JSX.Element {const { config, group } = rowconst {rollups,@@ -120,4 +124,4 @@ export function ScoutRosterCard({ row }: { row: ScoutRosterRow }): JSX.Element {</div></div>)-}+})diff --git a/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts b/products/signals/frontend/inbox/logics/scoutFleetLogic.test.tsindex 4058b376111a..1ea1bc06b84e 100644--- a/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts+++ b/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts@@ -235,6 +235,59 @@ describe('scoutFleetLogic', () => {expect(rosterConfigIds()).toHaveLength(2)})+ // The card shows `display_name`, falling back to the prettified `skill_name`. Matching anything+ // else returns cards whose names miss the query, which reads as a broken search.+ const CHECKOUT_WATCH = {+ ...BASE_CONFIG,+ id: 'checkout-watch',+ skill_name: 'signals-scout-logs',+ display_name: 'Checkout watch',+ description: 'error spikes and new failure patterns in application logs',+ }+ const FALLBACK_NAME = { ...BASE_CONFIG, id: 'fallback-name', skill_name: 'signals-scout-error-tracking' }++ it.each([+ ['a partial name', 'check', ['checkout-watch']],+ ['a mixed-case name', 'ChEcKoUt', ['checkout-watch']],+ ['a padded query', ' check ', ['checkout-watch']],+ // "Error tracking" is the fallback name; the raw slug it comes from has no space in it.+ ['the fallback name', 'error track', ['fallback-name']],+ ['a hidden skill_name', 'logs', []],+ ['a description', 'failure patterns', []],+ ['a whitespace-only query', ' ', ['checkout-watch', 'fallback-name']],+ ['an empty query', '', ['checkout-watch', 'fallback-name']],+ ])('resolves %s to the cards whose name matches', (_label, search, expected) => {+ logic.actions.loadScoutConfigsSuccess([CHECKOUT_WATCH, FALLBACK_NAME])++ logic.actions.setScoutSearch(search)++ expect(rosterConfigIds()).toEqual(expected)+ })++ it('narrows the same sorted rows as it searches, and keeps the other filters when cleared', () => {+ logic.actions.loadScoutConfigsSuccess([+ CHECKOUT_WATCH,+ FALLBACK_NAME,+ { ...BASE_CONFIG, id: 'checkout-off', skill_name: 'signals-scout-checkout-health', enabled: false },+ ])+ logic.actions.setScoutEnabledFilter('enabled')+ const unsearched = logic.values.rosterScouts+ const matchingRow = unsearched.find((row) => row.config.id === 'checkout-watch')++ logic.actions.setScoutSearch('check')++ // The turned-off scout stays out, so search narrows the filtered roster rather than the fleet.+ expect(rosterConfigIds()).toEqual(['checkout-watch'])+ // Re-sorting or rebuilding the rows on a keystroke would hand the list new objects and+ // re-render every card that did not change.+ expect(logic.values.rosterScouts[0]).toBe(matchingRow)++ logic.actions.setScoutSearch('')++ expect(logic.values.rosterScouts).toBe(unsearched)+ expect(logic.values.scoutEnabledFilter).toEqual('enabled')+ })+it('lists the whole roster A→Z and tags each row with its lifecycle group', () => {// The runs poll re-pins `rosterEvaluatedAt` to the wall clock when real time has moved a// scout out of the pause window, so the fixture dates only hold with the clock pinned too.diff --git a/products/signals/frontend/inbox/logics/scoutFleetLogic.ts b/products/signals/frontend/inbox/logics/scoutFleetLogic.tsindex 33282c3b6d8b..04d1687634a3 100644--- a/products/signals/frontend/inbox/logics/scoutFleetLogic.ts+++ b/products/signals/frontend/inbox/logics/scoutFleetLogic.ts@@ -306,6 +306,7 @@ export interface scoutFleetLogicValues {rosterEvaluatedAt: numberrosterGroupCounts: Record<ScoutGroupKey, number>rosterScouts: ScoutRosterRow[]+ rosterScoutsBeforeSearch: ScoutRosterRow[]runningChatType: ScoutChatType | nullrunsWindow: {complete: boolean@@ -600,16 +601,16 @@ export interface scoutFleetLogicMeta {activeScoutTags: (selectedScoutTags: string[], scoutTagOptions: ScoutTagOption[]) => string[]scoutOwnerOptions: (scoutConfigs: SignalScoutConfigApi[] | null) => ScoutOwnerOption[]activeScoutOwner: (selectedScoutOwner: string | null, scoutOwnerOptions: ScoutOwnerOption[]) => string | null- rosterScouts: (+ rosterScoutsBeforeSearch: (scoutConfigs: SignalScoutConfigApi[] | null,rollups: Map<string, ScoutRollup>,rosterEvaluatedAt: number,activeScoutTags: string[],activeScoutOwner: string | null,- scoutSearch: string,scoutEnabledFilter: ScoutEnabledFilter,scoutRosterSort: ScoutRosterSort) => ScoutRosterRow[]+ rosterScouts: (rosterScoutsBeforeSearch: ScoutRosterRow[], scoutSearch: string) => ScoutRosterRow[]rosterGroupCounts: (scoutConfigs: SignalScoutConfigApi[] | null,rollups: Map<string, ScoutRollup>,@@ -1224,19 +1225,20 @@ export const scoutFleetLogic = kea<scoutFleetLogicType>([scoutOwnerOptions.some((option) => option.uuid === selectedScoutOwner) ? selectedScoutOwner : null,],/**- * The roster as one alphabetical list, each row tagged with its lifecycle group and narrowed- * by the roster's own chrome (search and the tag, owner, and on/off filters).+ * The roster as one sorted list, each row tagged with its lifecycle group and narrowed by+ * every piece of the roster's chrome except search: the tag, owner, and on/off filters.* `rosterEvaluatedAt` advances only when time changes a lifecycle group, so settled polls keep* this selector's output stable.+ * Search sits in `rosterScouts` on top of this, so a keystroke only re-runs a name match:+ * the sort does not run again, and every row that still matches keeps its object identity.*/- rosterScouts: [+ rosterScoutsBeforeSearch: [(s) => [s.scoutConfigs,s.rollups,s.rosterEvaluatedAt,s.activeScoutTags,s.activeScoutOwner,- s.scoutSearch,s.scoutEnabledFilter,s.scoutRosterSort,],@@ -1246,11 +1248,9 @@ export const scoutFleetLogic = kea<scoutFleetLogicType>([rosterEvaluatedAt: number,activeScoutTags: string[],activeScoutOwner: string | null,- scoutSearch: string,scoutEnabledFilter: ScoutEnabledFilter,scoutRosterSort: ScoutRosterSort): ScoutRosterRow[] => {- const query = scoutSearch.trim().toLowerCase()const now = new Date(rosterEvaluatedAt)const rows = [...(scoutConfigs ?? [])].filter((config) => configMatchesScoutTags(config, activeScoutTags))@@ -1259,13 +1259,6 @@ export const scoutFleetLogic = kea<scoutFleetLogicType>([(config) =>scoutEnabledFilter === 'all' || config.enabled === (scoutEnabledFilter === 'enabled'))- .filter(- (config) =>- !query ||- scoutDisplayName(config).toLowerCase().includes(query) ||- config.skill_name.toLowerCase().includes(query) ||- (config.description ?? '').toLowerCase().includes(query)- ).sort(compareScoutsByName).map((config) => ({ config, group: scoutGroup(config, rollups.get(config.skill_name), now) }))if (scoutRosterSort === 'status') {@@ -1275,6 +1268,24 @@ export const scoutFleetLogic = kea<scoutFleetLogicType>([return rows},],+ /**+ * The roster the list renders: the filtered rows narrowed by the search box.+ * Search matches the name on the card and nothing else. A scout whose `skill_name` or+ * description holds the query, while its card reads something different, is not a match. A+ * returned card whose name misses the query reads as a broken search.+ */+ rosterScouts: [+ (s) => [s.rosterScoutsBeforeSearch, s.scoutSearch],+ (rosterScoutsBeforeSearch: ScoutRosterRow[], scoutSearch: string): ScoutRosterRow[] => {+ const query = scoutSearch.trim().toLowerCase()+ if (!query) {+ return rosterScoutsBeforeSearch+ }+ return rosterScoutsBeforeSearch.filter((row) =>+ scoutDisplayName(row.config).toLowerCase().includes(query)+ )+ },+ ],/*** Group sizes over the whole fleet, unnarrowed by search — the roster stats state how many* scouts need a decision, and that number must not move as you type into the search box.