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(replay-vision): filter and search the watch feed (#99497)

Kim Svatos Duganf25d2c56907c
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 54b88a8048e3..bf97e883b857 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -9673,13 +9673,13 @@ snapshots:
scenes-app-project-homepage--project-homepage--light:
hash: v1.k794b7964.45567c13e93e1def5dabfea7b6a4a5a47253482e6dd5c587be257ae5b9374639.IC346vxEHrTKcFor0vVTajrOk8lCGCu3C5pdFW2iTOQ
scenes-app-replay-vision--home-watch-feed--dark:
- hash: v1.k794b7964.0de3098e0605993947f355d216016208c1d42beef59fa667746c851880bd3c7f.BdR__fH7LgRudacmcHVOlMwJcMjtCCEps4Z6ccewCf4
+ hash: v1.k794b7964.22279d36c1bfffe869426e3ff46a04fd8ecb86d23583a48a9abb14ef349020b5.p2vh9sQxAIkkqJfzQ3V8AZn9rVUa11zMRLm23MVqppo
scenes-app-replay-vision--home-watch-feed--light:
- hash: v1.k794b7964.8e172704c8b815db9c9045858c999c6a8cd68f16d622ad43c1bdefac10afff72.P2qDJ_vpuNVdE7MBxkAQzKE_V-K04IT9Sc2eFaqFank
+ hash: v1.k794b7964.48eaa73ef214aee024a250acc3132c5ca5e6435a45829db8b818b1e998ec2796.RuTKkzL4QVHg0ksX9rf7ahVB-uR_qksiQJwWGD4J5pY
scenes-app-replay-vision--home-watch-feed-empty--dark:
- hash: v1.k794b7964.a11e227e448c902b9992de9bce152859ab05891f01cd88c2363cd0c1d8ae0224.auA_OUt2YDuk88h8lAnes98ekvGzA7_-8xrUtAEAoSY
+ hash: v1.k794b7964.c8b63e7c03105a6a22c7dfecc5fa98afb410af14180977eeb9907c2e57f43e29.9d0B-LDyKHrQ75wpveOo913SMTZvi2fe4RTJOrFtDM0
scenes-app-replay-vision--home-watch-feed-empty--light:
- hash: v1.k794b7964.f4d960313b80fd632bd15a5bc789b2d8a37381284b0e4600f849a24071be5b1c.33KiuuIHiIiCZ3gMFApKeH-YYEAJbT9ajcDhdb_Pbr8
+ hash: v1.k794b7964.33393d260f0654e59dbc209d6052c2b0730dfc6e8f59925406cd3a9349569980.63xRgoQrVu1PM7n1sBaVx6QV7Otc_rKCusdfHhsGuBU
scenes-app-replay-vision--observation-detail--dark:
hash: v1.k794b7964.5c1e4dc71fab8dd16212232b0a6483e7b96f884bd6c9761f276e9d6d788192a3.EyeOt5zd-9ySXBJcK-nvwOcO-Q1umL8pWldTB9PWh9s
scenes-app-replay-vision--observation-detail--light:
diff --git a/products/replay_vision/backend/api/scanners.py b/products/replay_vision/backend/api/scanners.py
index 13d9a63a9004..8333a94e400f 100644
--- a/products/replay_vision/backend/api/scanners.py
+++ b/products/replay_vision/backend/api/scanners.py
@@ -1432,6 +1432,21 @@ class WatchFeedQuerySerializer(serializers.Serializer):
choices=ScannerType.choices,
help_text="Restrict the feed to observations from scanners of this type.",
)
+ tags = serializers.CharField(
+ required=False,
+ help_text=(
+ "Comma-separated scanner tags to restrict the feed to. A team with many scanners uses these to "
+ "follow one area without naming every scanner in it."
+ ),
+ )
+ search = serializers.CharField(
+ required=False,
+ help_text=(
+ "Case-insensitive text to match against the scan's own words (title, summary, reasoning, and the "
+ "notability sentence) and the scanner's name. Applied before ranking, so it searches the whole "
+ "window rather than the items that would have surfaced without it."
+ ),
+ )
limit = serializers.IntegerField(
required=False,
default=WATCH_FEED_DEFAULT_LIMIT,
@@ -1440,6 +1455,9 @@ class WatchFeedQuerySerializer(serializers.Serializer):
help_text=f"Feed items to return, at most {WATCH_FEED_MAX_LIMIT}. The feed is bounded, not paginated.",
)
+ def validate_tags(self, value: str) -> list[str]:
+ return [tagify(tag) for tag in split_csv(value)]
+
def validate_scanner_ids(self, value: str) -> list[UUID]:
raw_ids = split_csv(value)
if not raw_ids:
@@ -2129,6 +2147,17 @@ class ReplayScannerViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixin, vi
if params.get("scanner_ids"):
requested = set(params["scanner_ids"])
allowed_ids = [scanner_id for scanner_id in allowed_ids if scanner_id in requested]
+ if params.get("tags"):
+ # Narrow by tag through the scanner rows rather than the observations: a snapshot records the
+ # scanner's config at scan time, not its tags, and a retag should take effect immediately.
+ tagged_ids = set(
+ ReplayScanner.objects.filter(
+ team_id=self.team_id, id__in=allowed_ids, tagged_items__tag__name__in=params["tags"]
+ )
+ .distinct()
+ .values_list("id", flat=True)
+ )
+ allowed_ids = [scanner_id for scanner_id in allowed_ids if scanner_id in tagged_ids]
candidates = ReplayObservation.objects.filter(
team_id=self.team_id,
scanner_id__in=allowed_ids,
@@ -2139,6 +2168,18 @@ class ReplayScannerViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixin, vi
candidates = candidates.filter(created_at__lte=date_to)
if params.get("scanner_type"):
candidates = candidates.filter(scanner_snapshot__scanner_type=params["scanner_type"])
+ if params.get("search"):
+ # Applied before ranking so the box searches the whole window, not the slice that would have
+ # surfaced anyway. Unindexed, but the candidate query is already bounded by team, readable
+ # scanners, succeeded status and the date window. Lookup keys are literals, not caller input.
+ term = params["search"]
+ candidates = candidates.filter(
+ Q(scanner_result__model_output__reasoning__icontains=term)
+ | Q(scanner_result__model_output__summary__icontains=term)
+ | Q(scanner_result__model_output__title__icontains=term)
+ | Q(scanner_result__model_output__notability_reason__icontains=term)
+ | Q(scanner_snapshot__name__icontains=term)
+ )
# Row-gate on each row's snapshot experiment before ranking, so a restricted row can't take a slot.
candidates = accessible_observations(self.user_access_control, self.team_id, candidates)
viewer_id = cast(User, request.user).id
diff --git a/products/replay_vision/backend/tests/test_api.py b/products/replay_vision/backend/tests/test_api.py
index 37a7f4444289..38d9e305cd09 100644
--- a/products/replay_vision/backend/tests/test_api.py
+++ b/products/replay_vision/backend/tests/test_api.py
@@ -4827,6 +4827,49 @@ class TestWatchFeedAPI(_VisionAPITestCase):
self.assertEqual(allowed.status_code, 200, allowed.json())
self.assertEqual(allowed.json()["results"][0]["observation"]["session_id"], "scoped-sess")
+ def test_search_matches_scan_prose_and_scanner_name_across_the_whole_window(self) -> None:
+ # Search runs before ranking, so a match that the ranking would never have surfaced still
+ # comes back — that is the whole point of the box on a capped feed.
+ checkout = self._create_scanner(name="Checkout watcher")
+ other = self._create_scanner(name="Inbox watcher")
+ self._succeeded_observation(
+ checkout,
+ "coupon-sess",
+ 30,
+ {
+ "model_output": {
+ "scanner_type": "summarizer",
+ "title": "Coupon rejected",
+ "summary": "The coupon field rejected a valid code.",
+ "confidence": 0.9,
+ },
+ "signals_count": 0,
+ },
+ )
+ self._succeeded_observation(other, "inbox-sess", 1, self._monitor_result("no"))
+
+ resp = self.client.get(f"{self.feed_url}?search=coupon")
+ self.assertEqual([i["observation"]["session_id"] for i in resp.json()["results"]], ["coupon-sess"])
+
+ # The scanner's own name matches too, so typing an area name works.
+ resp = self.client.get(f"{self.feed_url}?search=inbox")
+ self.assertEqual([i["observation"]["session_id"] for i in resp.json()["results"]], ["inbox-sess"])
+
+ resp = self.client.get(f"{self.feed_url}?search=nothingmatchesthis")
+ self.assertEqual(resp.json()["results"], [])
+
+ def test_tag_filter_follows_current_scanner_tags_not_the_snapshot(self) -> None:
+ # Snapshots freeze config at scan time and never carried tags, so a retag has to take effect
+ # on existing observations immediately.
+ tagged = self._create_scanner(name="tagged")
+ untagged = self._create_scanner(name="untagged")
+ self._succeeded_observation(tagged, "tagged-sess", 10, self._monitor_result("no"))
+ self._succeeded_observation(untagged, "untagged-sess", 5, self._monitor_result("no"))
+ set_tags_on_object(["checkout"], tagged)
+
+ resp = self.client.get(f"{self.feed_url}?tags=checkout")
+ self.assertEqual([i["observation"]["session_id"] for i in resp.json()["results"]], ["tagged-sess"])
+
def test_malformed_scanner_result_ranks_by_recency_instead_of_500(self) -> None:
scanner = self._create_scanner(name="m")
self._succeeded_observation(scanner, "broken", 1, {"model_output": "not-a-dict"})
diff --git a/products/replay_vision/frontend/generated/api.schemas.ts b/products/replay_vision/frontend/generated/api.schemas.ts
index c4735d86e7c3..5bbb7481b598 100644
--- a/products/replay_vision/frontend/generated/api.schemas.ts
+++ b/products/replay_vision/frontend/generated/api.schemas.ts
@@ -2895,6 +2895,16 @@ export type VisionScannersWatchFeedRetrieveParams = {
* @minLength 1
*/
scanner_type?: VisionScannersWatchFeedRetrieveScannerType
+ /**
+ * Case-insensitive text to match against the scan's own words (title, summary, reasoning, and the notability sentence) and the scanner's name. Applied before ranking, so it searches the whole window rather than the items that would have surfaced without it.
+ * @minLength 1
+ */
+ search?: string
+ /**
+ * Comma-separated scanner tags to restrict the feed to. A team with many scanners uses these to follow one area without naming every scanner in it.
+ * @minLength 1
+ */
+ tags?: string
}
export type VisionScannersWatchFeedRetrieveScannerType =
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsx
index 68e43750e0ad..90ec88f34de3 100644
--- a/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsx
@@ -1,12 +1,14 @@
import { useActions, useValues } from 'kea'
-import { LemonButton, LemonSkeleton } from '@posthog/lemon-ui'
+import { IconSearch } from '@posthog/icons'
+import { LemonButton, LemonInput, LemonSkeleton } from '@posthog/lemon-ui'
import { DateFilter } from 'lib/components/DateFilter/DateFilter'
import { dateMapping } from 'lib/utils/dateFilters'
import { pluralize } from 'lib/utils/strings'
import { FilterPill } from '../../components/FilterPill'
+import { visionScannersListLogic } from '../../logics/visionScannersListLogic'
import { SCANNER_TYPE_OPTIONS, ScannerType } from '../types'
import { watchFeedLogic } from '../watchFeedLogic'
import { WatchFeedCard, observationClipRange } from './WatchFeedCard'
@@ -29,10 +31,37 @@ const FEED_DATE_OPTION_KEYS = new Set([
const FEED_DATE_OPTIONS = dateMapping.filter((option) => FEED_DATE_OPTION_KEYS.has(option.key))
export function WatchFeedTab(): JSX.Element {
- const { feedItems, feedItemsLoading, feedFailed, dateFrom, dateTo, scannerTypeFilter } = useValues(watchFeedLogic)
- const { setDateRange, setScannerTypeFilter, loadFeed } = useActions(watchFeedLogic)
+ const {
+ feedItems,
+ feedItemsLoading,
+ feedFailed,
+ dateFrom,
+ dateTo,
+ scannerTypeFilter,
+ scannerIdsFilter,
+ tagsFilter,
+ tagOptions,
+ search,
+ hasFeedFilters,
+ } = useValues(watchFeedLogic)
+ const {
+ setDateRange,
+ setScannerTypeFilter,
+ setScannerIdsFilter,
+ setTagsFilter,
+ setSearch,
+ clearFeedFilters,
+ loadFeed,
+ } = useActions(watchFeedLogic)
+ const { scanners: allScanners } = useValues(visionScannersListLogic)
+ const scannerOptions = allScanners.map((scanner) => ({
+ value: scanner.id,
+ label: scanner.name || '(untitled)',
+ }))
const items = feedItems ?? []
+ // Only the scanner picker narrows *which* scanners are in scope; the others narrow within them.
+ const narrowedToScanners = scannerIdsFilter.length
const scannerCount = new Set(items.map((item) => item.observation.scanner_id)).size
// Only observations that actually cite a moment contribute to the total; a non-cited card has no clip.
const citedMinutes = Math.round(
@@ -52,12 +81,39 @@ export function WatchFeedTab(): JSX.Element {
: 'What to watch'}
</h2>
<p className="text-muted text-sm m-0">
+ {narrowedToScanners > 0
+ ? `Following ${pluralize(narrowedToScanners, 'scanner')} of ${allScanners.length}. `
+ : ''}
{items.length > 0
? `Picked from ${pluralize(scannerCount, 'scanner')} in this window. Each clip is the moment an observation cites.`
: 'The observations most worth a look, picked across your scanners.'}
</p>
</div>
<div className="flex flex-wrap items-center gap-2">
+ <LemonInput
+ type="search"
+ placeholder="Search clips..."
+ value={search}
+ onChange={setSearch}
+ prefix={<IconSearch />}
+ className="max-w-xs"
+ data-attr="vision-watch-feed-search"
+ />
+ <FilterPill<string>
+ label="Scanners"
+ searchable
+ searchPlaceholder="Search scanners..."
+ options={scannerOptions}
+ value={scannerIdsFilter}
+ onChange={setScannerIdsFilter}
+ />
+ <FilterPill<string>
+ label="Tags"
+ searchable
+ options={tagOptions}
+ value={tagsFilter}
+ onChange={setTagsFilter}
+ />
<FilterPill<ScannerType>
label="Type"
options={TYPE_OPTIONS}
@@ -71,6 +127,11 @@ export function WatchFeedTab(): JSX.Element {
showRollingRangePicker={false}
onChange={(from, to) => setDateRange(from ?? null, to ?? null)}
/>
+ {hasFeedFilters && (
+ <LemonButton type="tertiary" size="small" onClick={() => clearFeedFilters()}>
+ Clear filters
+ </LemonButton>
+ )}
</div>
</div>
@@ -101,8 +162,20 @@ export function WatchFeedTab(): JSX.Element {
<WatchFeedCard key={item.observation.id} item={item} position={index} />
))
) : !feedFailed ? (
- <div className="text-sm text-secondary border border-dashed rounded p-6 text-center">
- Nothing worth watching in this window yet. Observations appear here as your scanners run.
+ <div className="flex flex-col items-center gap-2 text-sm text-secondary border border-dashed rounded p-6 text-center">
+ {hasFeedFilters ? (
+ <>
+ <span>No clips match these filters in this window.</span>
+ <LemonButton type="secondary" size="small" onClick={() => clearFeedFilters()}>
+ Clear filters
+ </LemonButton>
+ </>
+ ) : (
+ <span>
+ Nothing worth watching in this window yet. Observations appear here as your scanners
+ run.
+ </span>
+ )}
</div>
) : null}
</div>
diff --git a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.ts b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.ts
index cfaaa61496a1..2209bf8eb5c6 100644
--- a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.ts
@@ -1,3 +1,4 @@
+import { router } from 'kea-router'
import { expectLogic } from 'kea-test-utils'
import { useMocks } from '~/mocks/jest'
@@ -57,6 +58,75 @@ describe('watchFeedLogic', () => {
expect(new URL(feedSpy.mock.calls.at(-1)[0].request.url).searchParams.get('date_from')).toBe('-30d')
})
+ it('sends scanner, tag and search filters, and keeps persisted picks on a filterless URL', async () => {
+ logic.mount()
+ await expectLogic(logic).toDispatchActions(['loadFeedSuccess']).toFinishAllListeners()
+
+ await expectLogic(logic, () => {
+ logic.actions.setScannerIdsFilter(['scanner-a', 'scanner-b'])
+ })
+ .toDispatchActions(['loadFeedSuccess'])
+ .toFinishAllListeners()
+ let params = new URL(feedSpy.mock.calls.at(-1)[0].request.url).searchParams
+ expect(params.get('scanner_ids')).toBe('scanner-a,scanner-b')
+
+ await expectLogic(logic, () => {
+ logic.actions.setTagsFilter(['checkout'])
+ })
+ .toDispatchActions(['loadFeedSuccess'])
+ .toFinishAllListeners()
+ params = new URL(feedSpy.mock.calls.at(-1)[0].request.url).searchParams
+ expect(params.get('tags')).toBe('checkout')
+
+ await expectLogic(logic, () => {
+ logic.actions.setSearch(' coupon ')
+ })
+ .toDispatchActions(['loadFeedSuccess'])
+ .toFinishAllListeners()
+ expect(new URL(feedSpy.mock.calls.at(-1)[0].request.url).searchParams.get('search')).toBe('coupon')
+
+ // A URL with no feed params must not silently widen the reader's feed back to every scanner.
+ await expectLogic(logic, () => {
+ router.actions.push('/replay-vision')
+ }).toFinishAllListeners()
+ expect(logic.values.scannerIdsFilter).toEqual(['scanner-a', 'scanner-b'])
+ })
+
+ it('restores a shared link as a full snapshot, clearing filters it omits', async () => {
+ logic.mount()
+ await expectLogic(logic).toDispatchActions(['loadFeedSuccess']).toFinishAllListeners()
+
+ await expectLogic(logic, () => {
+ logic.actions.setScannerIdsFilter(['scanner-a'])
+ })
+ .toDispatchActions(['loadFeedSuccess'])
+ .toFinishAllListeners()
+
+ // A link that names only tags is a full snapshot: tags apply and the remembered scanner clears,
+ // in a single load, so the same link shows the same feed to every recipient.
+ await expectLogic(logic, () => {
+ router.actions.push('/replay-vision?feed_tags=checkout')
+ })
+ .toDispatchActions(['restoreFeedFilters', 'loadFeed', 'loadFeedSuccess'])
+ .toFinishAllListeners()
+ expect(logic.values.tagsFilter).toEqual(['checkout'])
+ expect(logic.values.scannerIdsFilter).toEqual([])
+ const params = new URL(feedSpy.mock.calls.at(-1)[0].request.url).searchParams
+ expect(params.get('tags')).toBe('checkout')
+ expect(params.get('scanner_ids')).toBeNull()
+ })
+
+ it('clears every filter at once', async () => {
+ logic.mount()
+ logic.actions.setScannerIdsFilter(['scanner-a'])
+ logic.actions.setTagsFilter(['checkout'])
+ await expectLogic(logic, () => {
+ logic.actions.clearFeedFilters()
+ })
+ .toMatchValues({ scannerIdsFilter: [], tagsFilter: [], search: '', hasFeedFilters: false })
+ .toFinishAllListeners()
+ })
+
it('flags a failed load and clears the flag on retry', async () => {
feedSpy.mockImplementation(() => [500, { detail: 'nope' }])
logic.mount()
diff --git a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts
index d736eec39bea..7fc0b703d8fe 100644
--- a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts
@@ -1,28 +1,48 @@
-import { MakeLogicType, actions, afterMount, kea, listeners, path, reducers } from 'kea'
+import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
-import { router } from 'kea-router'
+import { router, urlToAction } from 'kea-router'
+import { trackedActionToUrl } from 'lib/logic/scenes/trackedActionToUrl'
import posthog from 'lib/posthog-typed'
+import { getCurrentTeamIdOrNone } from 'lib/utils/getAppContext'
+import { objectsEqual } from 'lib/utils/objects'
import { sessionPlayerModalLogic } from 'scenes/session-recordings/player/modal/sessionPlayerModalLogic'
import { teamLogic } from 'scenes/teamLogic'
+import { urls } from 'scenes/urls'
+
+import { tagsModel } from '~/models/tagsModel'
import { visionScannersWatchFeedRetrieve } from '../generated/api'
import type { VisionScannersWatchFeedRetrieveParams, WatchFeedItemApi } from '../generated/api.schemas'
import type { ScannerTypeEnumApi } from '../generated/api.schemas'
+import { csvParam, parseCsvParam } from '../utils/urlParams'
import { ScannerType } from './types'
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface watchFeedLogicValues {
+ allTags: string[] // tagsModel
dateFrom: string
dateTo: string | null
feedFailed: boolean
feedItems: WatchFeedItemApi[] | null
feedItemsLoading: boolean
+ hasFeedFilters: boolean
+ scannerIdsFilter: string[]
scannerTypeFilter: ScannerType | null
+ search: string
+ tagOptions: {
+ label: string
+ value: string
+ }[]
+ tagsFilter: string[]
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface watchFeedLogicActions {
+ loadTags: () => any // tagsModel
+ clearFeedFilters: () => {
+ value: true
+ }
loadFeed: () => {
value: true
}
@@ -44,6 +64,15 @@ export interface watchFeedLogicActions {
value: true
}
}
+ restoreFeedFilters: (
+ search: string,
+ scannerIds: string[],
+ tags: string[]
+ ) => {
+ scannerIds: string[]
+ search: string
+ tags: string[]
+ }
setDateRange: (
dateFrom: string | null,
dateTo: string | null
@@ -51,22 +80,78 @@ export interface watchFeedLogicActions {
dateFrom: string | null
dateTo: string | null
}
+ setScannerIdsFilter: (scannerIds: string[]) => {
+ scannerIds: string[]
+ }
setScannerTypeFilter: (scannerType: ScannerType | null) => {
scannerType: ScannerTypeEnumApi | null
}
+ setSearch: (search: string) => {
+ search: string
+ }
+ setTagsFilter: (tags: string[]) => {
+ tags: string[]
+ }
}
-export type watchFeedLogicType = MakeLogicType<watchFeedLogicValues, watchFeedLogicActions>
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface watchFeedLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ hasFeedFilters: (
+ scannerIdsFilter: string[],
+ tagsFilter: string[],
+ scannerTypeFilter: ScannerTypeEnumApi | null,
+ search: string
+ ) => boolean
+ tagOptions: (
+ allTags: string[],
+ tagsFilter: string[]
+ ) => {
+ label: string
+ value: string
+ }[]
+ }
+}
+
+export type watchFeedLogicType = MakeLogicType<
+ watchFeedLogicValues,
+ watchFeedLogicActions,
+ Record<string, any>,
+ watchFeedLogicMeta
+>
export const DEFAULT_FEED_DATE_FROM: string = '-7d'
+function reportFiltered(values: watchFeedLogicValues): void {
+ posthog.capture('replay_vision_watch_feed_filtered', {
+ date_from: values.dateFrom,
+ date_to: values.dateTo,
+ scanner_type: values.scannerTypeFilter,
+ scanner_ids_count: values.scannerIdsFilter.length,
+ tags_count: values.tagsFilter.length,
+ has_search: values.search.trim().length > 0,
+ })
+}
+
/** Data for the What to watch tab: the window's most watchable observations, ranked server-side. */
export const watchFeedLogic = kea<watchFeedLogicType>([
path(['products', 'replay_vision', 'frontend', 'replay_scanners', 'watchFeedLogic']),
+ connect(() => ({
+ values: [tagsModel, ['tags as allTags']],
+ actions: [tagsModel, ['loadTags']],
+ })),
+
actions({
setDateRange: (dateFrom: string | null, dateTo: string | null) => ({ dateFrom, dateTo }),
setScannerTypeFilter: (scannerType: ScannerType | null) => ({ scannerType }),
+ setSearch: (search: string) => ({ search }),
+ setScannerIdsFilter: (scannerIds: string[]) => ({ scannerIds }),
+ setTagsFilter: (tags: string[]) => ({ tags }),
+ // Restores every shared-link filter at once so one request runs and every recipient sees the
+ // same feed, regardless of the scanner/tag selections their browser remembered.
+ restoreFeedFilters: (search: string, scannerIds: string[], tags: string[]) => ({ search, scannerIds, tags }),
+ clearFeedFilters: true,
loadFeed: true,
}),
@@ -88,6 +173,16 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
if (values.scannerTypeFilter) {
params.scanner_type = values.scannerTypeFilter
}
+ if (values.scannerIdsFilter.length > 0) {
+ params.scanner_ids = values.scannerIdsFilter.join(',')
+ }
+ if (values.tagsFilter.length > 0) {
+ params.tags = values.tagsFilter.join(',')
+ }
+ const trimmedSearch = values.search.trim()
+ if (trimmedSearch) {
+ params.search = trimmedSearch
+ }
const response = await visionScannersWatchFeedRetrieve(String(teamId), params)
// Drop out-of-order responses — the most recent filter change owns the feed.
breakpoint()
@@ -114,6 +209,37 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
null as ScannerType | null,
{
setScannerTypeFilter: (_, { scannerType }) => scannerType,
+ clearFeedFilters: () => null,
+ },
+ ],
+ search: [
+ '',
+ {
+ setSearch: (_, { search }) => search,
+ restoreFeedFilters: (_, { search }) => search,
+ clearFeedFilters: () => '',
+ },
+ ],
+ // Persisted so a team with many scanners lands on the ones they follow instead of the whole
+ // fleet on every visit. Keyed by team so a selection made on one team never carries into
+ // another team's feed, where those scanner ids do not exist and would hide every result.
+ // Browser-local until per-user pins exist, so it does not cross devices.
+ scannerIdsFilter: [
+ [] as string[],
+ { persist: true, prefix: `${getCurrentTeamIdOrNone() ?? 'unknown'}__` },
+ {
+ setScannerIdsFilter: (_, { scannerIds }) => scannerIds,
+ restoreFeedFilters: (_, { scannerIds }) => scannerIds,
+ clearFeedFilters: () => [],
+ },
+ ],
+ tagsFilter: [
+ [] as string[],
+ { persist: true, prefix: `${getCurrentTeamIdOrNone() ?? 'unknown'}__` },
+ {
+ setTagsFilter: (_, { tags }) => tags,
+ restoreFeedFilters: (_, { tags }) => tags,
+ clearFeedFilters: () => [],
},
],
feedFailed: [
@@ -127,19 +253,33 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
listeners(({ actions, values }) => ({
setDateRange: () => {
- posthog.capture('replay_vision_watch_feed_filtered', {
- date_from: values.dateFrom,
- date_to: values.dateTo,
- scanner_type: values.scannerTypeFilter,
- })
+ reportFiltered(values)
actions.loadFeed()
},
setScannerTypeFilter: () => {
- posthog.capture('replay_vision_watch_feed_filtered', {
- date_from: values.dateFrom,
- date_to: values.dateTo,
- scanner_type: values.scannerTypeFilter,
- })
+ reportFiltered(values)
+ actions.loadFeed()
+ },
+ setScannerIdsFilter: () => {
+ reportFiltered(values)
+ actions.loadFeed()
+ },
+ setTagsFilter: () => {
+ reportFiltered(values)
+ actions.loadFeed()
+ },
+ clearFeedFilters: () => {
+ reportFiltered(values)
+ actions.loadFeed()
+ },
+ setSearch: async (_, breakpoint) => {
+ // Debounce keystrokes; a shared-link restore loads once through restoreFeedFilters instead.
+ await breakpoint(300)
+ reportFiltered(values)
+ actions.loadFeed()
+ },
+ restoreFeedFilters: () => {
+ reportFiltered(values)
actions.loadFeed()
},
loadFeedSuccess: ({ feedItems }) => {
@@ -161,8 +301,72 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
},
})),
+ selectors({
+ hasFeedFilters: [
+ (s) => [s.scannerIdsFilter, s.tagsFilter, s.scannerTypeFilter, s.search],
+ (scannerIds: string[], tags: string[], scannerType: ScannerType | null, search: string): boolean =>
+ scannerIds.length > 0 || tags.length > 0 || !!scannerType || search.trim().length > 0,
+ ],
+ tagOptions: [
+ (s) => [s.allTags, s.tagsFilter],
+ (allTags: string[], tagsFilter: string[]): { value: string; label: string }[] =>
+ // Keep a tag restored from a shared link selectable even when the team list doesn't know it.
+ Array.from(new Set([...allTags.filter((tag) => !tag.includes(',')), ...tagsFilter]))
+ .sort()
+ .map((tag) => ({ value: tag, label: tag })),
+ ],
+ }),
+
+ trackedActionToUrl(({ values }) => {
+ const buildUrl = (): [string, Record<string, string | undefined>, undefined, { replace: true }] => [
+ urls.replayVision(),
+ {
+ ...router.values.searchParams,
+ feed_search: values.search.trim() || undefined,
+ feed_scanners: csvParam(values.scannerIdsFilter),
+ feed_tags: csvParam(values.tagsFilter),
+ },
+ undefined,
+ { replace: true },
+ ]
+ return {
+ setSearch: buildUrl,
+ setScannerIdsFilter: buildUrl,
+ setTagsFilter: buildUrl,
+ clearFeedFilters: buildUrl,
+ }
+ }),
+
+ urlToAction(({ actions, values }) => ({
+ [urls.replayVision()]: (_, searchParams) => {
+ // A link that carries any feed_* param is a full filter snapshot, so restore all three and
+ // clear the ones it omits — otherwise the reader's remembered scanner/tag picks would leak
+ // in and the same link would show different feeds to different people. A link with no feed_*
+ // param leaves those remembered picks alone rather than widening the feed to the whole fleet.
+ const hasFeedParams =
+ searchParams.feed_search !== undefined ||
+ searchParams.feed_scanners !== undefined ||
+ searchParams.feed_tags !== undefined
+ if (!hasFeedParams) {
+ return
+ }
+ const search = typeof searchParams.feed_search === 'string' ? searchParams.feed_search : ''
+ const scanners = parseCsvParam(searchParams.feed_scanners)
+ const tags = parseCsvParam(searchParams.feed_tags)
+ const unchanged =
+ search === values.search &&
+ objectsEqual(scanners, values.scannerIdsFilter) &&
+ objectsEqual(tags, values.tagsFilter)
+ if (!unchanged) {
+ actions.restoreFeedFilters(search, scanners, tags)
+ }
+ },
+ })),
+
// The tab content mounts only while the tab is active, so mount is the fetch signal.
afterMount(({ actions }) => {
actions.loadFeed()
+ // tagsModel is lazy; load it so the tag filter isn't empty on a direct visit.
+ actions.loadTags()
}),
])
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index dd1b26588cfd..9b6b43f788de 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -108876,6 +108876,16 @@ export namespace Schemas {
* @minLength 1
*/
scanner_type?: VisionScannersWatchFeedRetrieveScannerType;
+ /**
+ * Case-insensitive text to match against the scan's own words (title, summary, reasoning, and the notability sentence) and the scanner's name. Applied before ranking, so it searches the whole window rather than the items that would have surfaced without it.
+ * @minLength 1
+ */
+ search?: string;
+ /**
+ * Comma-separated scanner tags to restrict the feed to. A team with many scanners uses these to follow one area without naming every scanner in it.
+ * @minLength 1
+ */
+ tags?: string;
};
export type VisionScannersWatchFeedRetrieveScannerType = typeof VisionScannersWatchFeedRetrieveScannerType[keyof typeof VisionScannersWatchFeedRetrieveScannerType];