: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(replay): fix follow moments and correct collection counts (#109016)
Hayne Ryucb2add965971
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 31e246b7d322..75bf44bbadb5 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -7547,9 +7547,9 @@ snapshots:replay-scenes-group--group-events-tab-with-modal-not-found--light:hash: v1.k794b7964.fb8d7ea4cd14495b48edfbe5b98a8fa0e6041fba2a6b04c193b3af9dcba40420.OEnNoyPZZ4jeRoA7BdS9ug_wOUFLwI77rUiz-Pqi_KUreplay-scenes-group--group-recording-tab-empty--dark:- hash: v1.k794b7964.0660887202ba71055373168f4b9df5cdc8251c89f0f96b77c4b3196845362f70.VFxGeaTyLzGuovqDxnkS9wWUmq2J0edku92QEPb1mJI+ hash: v1.k794b7964.9ceb258e7f5e0b631d3afa1ee490354951caf9a6849c5bc8cb3cd90c8ad5ed83.JIgbZhGw9_7Ml1ukbd_vvnh-p-55rraSQMm65T8QYrgreplay-scenes-group--group-recording-tab-empty--light:- hash: v1.k794b7964.06998246ac4a34809c233b8a664de4341ef8646c7c25865c31c34d15714b1904.ikkcZU-qTv5OBMBa0nR_7vnmBJwSfllp_59gzEO6w4I+ hash: v1.k794b7964.2ea10fa033d942d56164d82f34502ca37327c366b300aad559d7437926341e49.2UB6DyFJU9T0xF6-rfUmsfY-XSIjxIbvLXxv5mhdbwkreplay-scenes-group--group-recording-tab-multiple-and-not-found--dark:hash: v1.k794b7964.d42c3d4ddd4845edf7eb36d3661392d903df2c5390e4a3f0b6839458304d23da.FOzZSvQEF8DvpZfcB_fAecFEt4z80SjjJNG4WyiPYm4replay-scenes-group--group-recording-tab-multiple-and-not-found--light:@@ -7587,41 +7587,41 @@ snapshots:replay-tabs-home-failure--not-found--light:hash: v1.k794b7964.d9b15fdde17563eeb620d2a170d2b73434cc960fb55818fd07bb725d5a077700.LAZBeOy08kO2WM7ec--oJjkn8R_3VYZ-Wqvcg6IDD-8replay-tabs-home-filters-banner--page-filter-nudge--dark:- hash: v1.k794b7964.33db55efe063b4a0e5cf7399851c5e16172fd4b78dda3587881c7e58974e9507.6F1xl1LtKP40SgXwQBJF6ZZ65QMLRIXKXm1c5EzgCCE+ hash: v1.k794b7964.ef10ad389f863bfe246e69dc7bb0c74c3735cede108e2d373aa5b8338446b424.ewXseA-JwXOXnnzhCjOxwWoEzJiNIQsRDSepEBEsJ2Qreplay-tabs-home-filters-banner--page-filter-nudge--light:- hash: v1.k794b7964.63bf390f520ab045439f3b5e7fc148517a4cd49a956f984dfb568d414ac4fd03.M4ZZ0EydB1dbBv-yull_buDmcAN0BjTaY9xoP8-LxlE+ hash: v1.k794b7964.4ed6b8d9a68117b979e9445bbfee693c31dffe768071bb2b2f4f2d716eb9e360._393RO7m2y_y6cGHIAxTRFrIJ2Fu_RDFtKaF5FB4g9Ireplay-tabs-home-filters-banner--product-analytics-over-limit--dark:- hash: v1.k794b7964.6419b76d333a64f252a9fe748e5126f24a45c5ef281ee5f244bee651d8732d5b.uq-8FJ0MflN3hPv_ZAsPCd6wVw2NpRKB_UZUBKyLOb8+ hash: v1.k794b7964.883e2ce17802aabbf305467eedc51d55a3e3124e0d7d2998bb5c6fa387cc3833.wNyrJ_SnfMs_avoMKlU0Be48_3LzYlt_S3e1Lh1dd7wreplay-tabs-home-filters-banner--product-analytics-over-limit--light:- hash: v1.k794b7964.0119a627014451bb9c8930ca63913f0f92dfe56fc31415b84c815508dcde9b7a.P68BvqI6ZaeBJA3VqL_eybiB4wfcC0rA9Z8UXH3uXDw+ hash: v1.k794b7964.fc1065b54f0d2071003af2e30d70d5105c314760fdea4569f85c4063217dd599.HwAlbReoBS0zNE8Jw2JpX8RRXMOmZ-pdDStW9fe6f1oreplay-tabs-home-filters-banner--product-analytics-under-limit--dark:- hash: v1.k794b7964.9621e94ace22f6b0c839d8f7890e3cdf4aa9951c7bfee8f2a089e46a5f7f977a.dZbjaDtE-CMiMTkhTxV1u5NVSvEugAeaZ5oBS64HcH4+ hash: v1.k794b7964.5afe8e8639e305ff83e8efd5cf59af1c84468755028d07c5dfd21e7534cadbf0.vbE8VtSElMukmzXXJYYctZludMBuwDAr0IhrEG6bBe0replay-tabs-home-filters-banner--product-analytics-under-limit--light:- hash: v1.k794b7964.621980b6676868038ef6fda307d5b134d3879bc0638acf8936832351dc325f9e.q32al8_1uMGCjpaxXcoxMHz611C3uiHkep-dhcwXkjM+ hash: v1.k794b7964.59e9264ee12ece513f4f14a7eee8e342fcebabfca877d3bc82f6ee2af5052912.hrLTsc2TKsiyhWor_dF6NdDsQy7RSx0vRCBELQBsB8Mreplay-tabs-home-filters-banner--scanner-cross-sell--dark:- hash: v1.k794b7964.c27886267fbfa39c64398e447e3cf63d5929fc3c9ede6fc8bf9c30bfaeea87a7.YxiOImD793nydIZ3ort6IyBzGmOcsZQb9RmqCuyx0tk+ hash: v1.k794b7964.e0739c35f8f7e91dcc0eec9b0856ee24a4c427e365452b0998d753d58d689c08.xOCTBim155zwc_C3P-gZcul8rKMVsWypI4Dy9u_1Fxcreplay-tabs-home-filters-banner--scanner-cross-sell--light:- hash: v1.k794b7964.6cf63eeaf5abe507d73ec12a3ec9f404ce02e3c07e0aab059a3a1ea97ccfeb8d.O72XHqs276ly-AWZdwJvr_leOyBMigsKLK1SWFQ3XBo+ hash: v1.k794b7964.81ce74a3bf41d1e2d2edc4a7442df1eff1d9daedabf8d59b622ccd1c6c52d31a.G4iuMP9Aj2Gl5-mQbLL0elD4qBouOkT9nJQQy4ivk0Ureplay-tabs-home-filters-banner--templates-tab--dark:hash: v1.k794b7964.d438ddf6f2d9f05b13d8645a296bf3d7f9875d485708c4a921eb9c49f2991f90.sf5NCCDbhBU-m1nTsrn2EWTeYdDkfXwx2h3f8GFRGCoreplay-tabs-home-filters-banner--templates-tab--light:hash: v1.k794b7964.9e447d52b926cb22093f8c73945c9b4aebb3f79781e350a3f5245559c83e54d2.PJue3UTGwQpd6J6F_vyMA__xCKXHvLqyJew3QYep8SIreplay-tabs-home-success--filters-expanded--dark:- hash: v1.k794b7964.e85cac90eb14f279e3367d8d2ab0db3011d7bb6c5d85fee2fb5cd2d0095ea956.9KZY5n5cdZIaHcp8HzrLMg-rgB2x7i_uH93bqNN_MzU+ hash: v1.k794b7964.a05acdcbac185e041adaf30a6d8ef4977978907164381eba3d3dc9c9d8aea04d.qKdFMomWAKqzXhor-Jl8T1XN8Kgp4pdrZiklEnoryuIreplay-tabs-home-success--filters-expanded--light:- hash: v1.k794b7964.d3887aa861658b59e1b53e525b3b5c0fdef9ea63771166ac29e92504d08eaadd.vWIaoeW_DvUoh-LYUt5vowl0sJ22YLelc5dcyGrIGzk+ hash: v1.k794b7964.e032a16c10c90fa804fb97ad732d9bc5cf6344a9267ae94627db58d493b411b4.g6PymWcATP9BDl71RqlhQVkESH-RQHxENs9DiAFvdYsreplay-tabs-home-success--filters-expanded-lots-of-results--dark:- hash: v1.k794b7964.c343c3b079c4cf2d067c20c9062f96e992f4e852ffb7f1c07b2f2e1a574bbc0d.a_3yvG9VBkXYuj76X0iP0zQTqPIZEXpioAc2T4Dni4Y+ hash: v1.k794b7964.d155a139e5e1d6388a3950fa150338ca8357c13632f354cdde5ed7dc19e599ac.Jrs8QdMoU7XZcsTlpCafPTGTRNMZOe7sMu3e3leWWMgreplay-tabs-home-success--filters-expanded-lots-of-results--light:- hash: v1.k794b7964.98405638b17d696066169bc150c2826e43e86d22921b5d1ba9bdee16b37ecb3b.CzCFLMMvzsfMZwLAMcheLd1mQoaDfJpOqA1tbf0LB_w+ hash: v1.k794b7964.d23c821aa8bf3468d6b23967fce6e9729c6c7154fc8ff39fab45c0a5a8107a72.S_SrrD6uP_mX-sxVoDi6yldU9a0saynApriaS0NXxOQreplay-tabs-home-success--filters-expanded-lots-of-results-narrow--dark:- hash: v1.k794b7964.905ec7f223e6ba3d04b7b2aaf60d6561bfe515588ccecabb9b76c72d40a32d3f.4plJ9ELQU9sQLDvVForImE943RhoKKjmzPPkI6dZCDo+ hash: v1.k794b7964.0d914c8ec3c5beba7bca53b7364f18bcfe675b95d3a912e08ad62e33ec41226f.oSRJtsNoyVhqAtjsvvzypyt8WbJ2M2vDKlZTwIvTsRQreplay-tabs-home-success--filters-expanded-lots-of-results-narrow--light:- hash: v1.k794b7964.822aa003f36df8d2049a07f88f14951170896692015e0d2abac18a1bc91a22b3.vzX3w8na5zLvm78qhClA34ouQ2r_k8TFiIm2rbQqpMY+ hash: v1.k794b7964.46291f5cceabf5a2d9f1f514e60cc1ef214abbdee5ae26c6ea68591ce0d2f289.OR8N4L5BThnbqXgvDm_GeVt-fOffW2S7PKPgxrGnp4Ireplay-tabs-home-success--recent-recordings--dark:- hash: v1.k794b7964.81cd1efa8b9559e4b96b9c7e385648189ea45586548256b0cb000ffa80ca985e.14nEhQ9haxi7GqqJ-qd5Vh9UTXOwe0MYYBK3cRsRHm4+ hash: v1.k794b7964.0073c5938eb58b2f46998705da2f7057af76a33672895d3d62ebfa73fb10b35b.X0SVL-b3I11Gnd4z_tqve-gEpqiWfWVzNbqvu1Do7gsreplay-tabs-home-success--recent-recordings--light:- hash: v1.k794b7964.1c15c6439072ba99bc539ede94d6546436b78c44e4a026d638130a59e2bed515.RAh0r3lyA4w8xpZ1b0HeY_EBMhyx7A4GXQhD4Q1fzSA+ hash: v1.k794b7964.173d1bbadcf61ccbf7f8757e967f430d04ea7b3ac66a03b61422b367ddc3be18.7K4O18G9RYVA9eHlzoXwPOQXhw-29XM6Dm7g-i-oITMreplay-tabs-home-success--recent-recordings-empty--dark:hash: v1.k794b7964.b96eb8ff3becd42ef223773f142db0fb5a5c7d743adcce158cb164940f170c20.5aj7iROHwfdLWjLstJZEx3YzsXaFoHJbn4sok-n-0XMreplay-tabs-home-success--recent-recordings-empty--light:@@ -7631,9 +7631,9 @@ snapshots:replay-tabs-home-success--recordings-play-list-no-pinned-recordings--light:hash: v1.k794b7964.a0683ea0a59c86f2d0b3245db8fe807ae82271c393971cece0c7b9c58f0e2f10.UjlpwjlWZaZS9fN-ph4xozP-XM8jx4p4M3MsEYFJpMsreplay-tabs-home-success--second-recording-in-list--dark:- hash: v1.k794b7964.2ba8b5789dc4e6732085d5c3e9b4434011dfd0f50c9b9bf20101273d65e6ee7d.vbjff-vvIJ5OC55myq8StIReDxV12WsR2hkQyMFeHmk+ hash: v1.k794b7964.ee93f81501a6dfd56393b9c0eceacc7cb9f9670f5ddf734236fda11e5cd33c5e.3e5Mttfwj51jabXjO98LYD8X1VjqjG0INjIR6MhYTcsreplay-tabs-home-success--second-recording-in-list--light:- hash: v1.k794b7964.3a8372e58168132be7cc904fd0b41f6758930206eb5c51fb50f3a067f19398fc.HToJJ6kF0cytmkWxhkwCEtjSN0YxsJV7p8OtC9qShv0+ hash: v1.k794b7964.443294b49369139d989438bd62747619fc2d904ebc63f5ae0f3eaf5dd2b6231a.185aTQmO_ERbjSv7HapM2y_lw0Zu8QZNHA8OkVwXOncreplay-vision-analysis-nudge--default--dark:hash: v1.k794b7964.e21450a1b2054a36fab2a183fd4485190e7161c07830a04008b734f83ecabb1c.Hj2ygumZlfd2zAIz7tC6m7XoM-G15hY_amDmI_m-cJoreplay-vision-analysis-nudge--default--light:diff --git a/frontend/src/lib/components/DateFilter/dateFilterLogic.test.ts b/frontend/src/lib/components/DateFilter/dateFilterLogic.test.tsindex 32d90a1272ce..dfd91d2e0e7f 100644--- a/frontend/src/lib/components/DateFilter/dateFilterLogic.test.ts+++ b/frontend/src/lib/components/DateFilter/dateFilterLogic.test.ts@@ -330,11 +330,22 @@ describe('dateFilterLogic', () => {await expectLogic(narrowLogic).toMatchValues({ label: 'Until July 31, 2026' })})- it('still shows the placeholder when no range is set', async () => {- const narrowLogic = buildLogic(null, null)+ it.each([+ [undefined, 'No date range override'],+ ['Any time', 'Any time'],+ ])('shows placeholder %s when no range is set', async (placeholder, label) => {+ const narrowLogic = dateFilterLogic({+ key: `narrow-placeholder-${placeholder}`,+ onChange: jest.fn(),+ dateFrom: null,+ dateTo: null,+ dateOptions: narrowDateOptions,+ isDateFormatted: false,+ placeholder,+ })narrowLogic.mount()- await expectLogic(narrowLogic).toMatchValues({ label: 'No date range override' })+ await expectLogic(narrowLogic).toMatchValues({ label })})})})diff --git a/frontend/src/lib/components/DateFilter/dateFilterLogic.ts b/frontend/src/lib/components/DateFilter/dateFilterLogic.tsindex 822043688133..f89467a88c5e 100644--- a/frontend/src/lib/components/DateFilter/dateFilterLogic.ts+++ b/frontend/src/lib/components/DateFilter/dateFilterLogic.ts@@ -418,9 +418,8 @@ export const dateFilterLogic = kea<dateFilterLogicType>([? formatDate(dateStringToDayJs(dateFrom) ?? dayjs(dateFrom)): (dateFilterToText(dateFrom, dateTo, null, dateOptions, false) ??labelForRangeOutsideOptions(dateFrom, dateTo) ??- (isFixedDateMode- ? (placeholder ?? SELECT_FIXED_VALUE_PLACEHOLDER)- : NO_OVERRIDE_RANGE_PLACEHOLDER))+ placeholder ??+ (isFixedDateMode ? SELECT_FIXED_VALUE_PLACEHOLDER : NO_OVERRIDE_RANGE_PLACEHOLDER))},],}),diff --git a/frontend/src/scenes/session-recordings/player/playerSettingsLogic.ts b/frontend/src/scenes/session-recordings/player/playerSettingsLogic.tsindex 0782746c7ee1..53a70255dd2a 100644--- a/frontend/src/scenes/session-recordings/player/playerSettingsLogic.ts+++ b/frontend/src/scenes/session-recordings/player/playerSettingsLogic.ts@@ -18,7 +18,7 @@ export interface playerSettingsLogicValues {autoplayDirection: AutoplayDirectionhideRecordingsMenuLabelFor: (option: HideViewedRecordingsOptions- ) => 'Hide all viewed recordings' | 'Hide my viewed recordings' | 'Viewed and unviewed recordings'+ ) => 'All recordings' | 'Hide all viewed recordings' | 'Hide my viewed recordings'hideViewedRecordings: HideViewedRecordingsOptionsisPlaylistCollapsed: booleanisVerticallyStacked: boolean@@ -226,7 +226,7 @@ export const playerSettingsLogic = kea<playerSettingsLogicType>([case 'any-user':return 'Hide all viewed recordings'default:- return 'Viewed and unviewed recordings'+ return 'All recordings'}}},diff --git a/posthog/session_recordings/session_recording_playlist_api.py b/posthog/session_recordings/session_recording_playlist_api.pyindex 32e7746a693c..02c9c5e01483 100644--- a/posthog/session_recordings/session_recording_playlist_api.py+++ b/posthog/session_recordings/session_recording_playlist_api.py@@ -2,7 +2,7 @@ import jsonimport builtinsfrom collections import defaultdictfrom dataclasses import dataclass-from datetime import UTC, datetime+from datetime import UTC, datetime, timedeltafrom typing import Any, Optional, castfrom django.contrib.auth.models import AnonymousUser@@ -37,6 +37,7 @@ from posthog.models.team.team import Teamfrom posthog.models.utils import UUIDTfrom posthog.rate_limit import ClickHouseBurstRateThrottle, ClickHouseSustainedRateThrottlefrom posthog.redis import get_client+from posthog.session_recordings.data_retention import retention_period_in_daysfrom posthog.session_recordings.models.session_recording_playlist import SessionRecordingPlaylistViewedfrom posthog.session_recordings.session_recording_api import (current_user_viewed,@@ -176,18 +177,20 @@ def create_synthetic_playlist_instance(return instance+def live_playlist_items(+ items: QuerySet[SessionRecordingPlaylistItem], team: Team+) -> QuerySet[SessionRecordingPlaylistItem]:+ cutoff = now() - timedelta(days=retention_period_in_days(team.session_recording_retention_period))+ return items.exclude(deleted=True).exclude(recording__start_time__lt=cutoff)++def count_collection_recordings(playlist: SessionRecordingPlaylist, user: User, team: Team) -> dict[str, int | bool | None]:- playlist_items: QuerySet[SessionRecordingPlaylistItem] = playlist.playlist_items.exclude(deleted=True)- watched_playlist_items = current_user_viewed(- list(playlist.playlist_items.values_list("recording_id", flat=True)),- user,- team,- )+ session_ids = list(live_playlist_items(playlist.playlist_items.all(), team).values_list("recording_id", flat=True))- item_count = playlist_items.count()- watched_count = len(watched_playlist_items)+ item_count = len(session_ids)+ watched_count = len(current_user_viewed(session_ids, user, team))return {"count": item_count if item_count > 0 else None,@@ -335,20 +338,14 @@ def precompute_recordings_counts(playlists: list[SessionRecordingPlaylist], user# Defense-in-depth: the current caller (`list()`) passes team-scoped playlists# from `safely_get_queryset`, but filtering here keeps the helper safe if it's# ever reused by a caller that does not pre-scope.- base_qs = SessionRecordingPlaylistItem.objects.filter(- playlist_id__in=playlist_ids,- playlist__team_id=team.id,+ base_qs = live_playlist_items(+ SessionRecordingPlaylistItem.objects.filter(playlist_id__in=playlist_ids, playlist__team_id=team.id), team)- # Counts via SQL aggregation — avoids materializing non-deleted rows when we- # only need the count. Matches `.exclude(deleted=True)` semantics on the- # nullable BooleanField (both True=excluded, False/NULL=included).counts_by_playlist: dict[int, int] = dict(- base_qs.exclude(deleted=True).values("playlist_id").annotate(c=Count("id")).values_list("playlist_id", "c")+ base_qs.values("playlist_id").annotate(c=Count("id")).values_list("playlist_id", "c"))- # Separate scan for session_ids — includes soft-deleted rows to preserve the- # watched-count semantics of the pre-change count_collection_recordings.session_ids_by_playlist: dict[int, list[str]] = defaultdict(list)for playlist_id, session_id in base_qs.values_list("playlist_id", "recording_id"):if session_id is not None:diff --git a/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr b/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambrindex d27f553a12d7..e0ca035f12de 100644--- a/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr+++ b/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr@@ -269,6 +269,7 @@COUNT("posthog_sessionrecordingplaylistitem"."id") AS "c"FROM "posthog_sessionrecordingplaylistitem"INNER JOIN "posthog_sessionrecordingplaylist" ON ("posthog_sessionrecordingplaylistitem"."playlist_id" = "posthog_sessionrecordingplaylist"."id")+ LEFT OUTER JOIN "posthog_sessionrecording" ON ("posthog_sessionrecordingplaylistitem"."recording_id" = "posthog_sessionrecording"."session_id")WHERE ("posthog_sessionrecordingplaylist"."team_id" = 99999AND "posthog_sessionrecordingplaylistitem"."playlist_id" IN (1,2,@@ -276,7 +277,9 @@4,5 /* ... */)AND NOT ("posthog_sessionrecordingplaylistitem"."deleted"- AND "posthog_sessionrecordingplaylistitem"."deleted" IS NOT NULL))+ AND "posthog_sessionrecordingplaylistitem"."deleted" IS NOT NULL)+ AND NOT ("posthog_sessionrecording"."start_time" < '2024-12-02 12:00:00+00:00'::timestamptz+ AND "posthog_sessionrecording"."start_time" IS NOT NULL))GROUP BY 1'''# ---@@ -286,12 +289,17 @@"posthog_sessionrecordingplaylistitem"."recording_id" AS "recording_id"FROM "posthog_sessionrecordingplaylistitem"INNER JOIN "posthog_sessionrecordingplaylist" ON ("posthog_sessionrecordingplaylistitem"."playlist_id" = "posthog_sessionrecordingplaylist"."id")+ LEFT OUTER JOIN "posthog_sessionrecording" ON ("posthog_sessionrecordingplaylistitem"."recording_id" = "posthog_sessionrecording"."session_id")WHERE ("posthog_sessionrecordingplaylist"."team_id" = 99999AND "posthog_sessionrecordingplaylistitem"."playlist_id" IN (1,2,3,4,- 5 /* ... */))+ 5 /* ... */)+ AND NOT ("posthog_sessionrecordingplaylistitem"."deleted"+ AND "posthog_sessionrecordingplaylistitem"."deleted" IS NOT NULL)+ AND NOT ("posthog_sessionrecording"."start_time" < '2024-12-02 12:00:00+00:00'::timestamptz+ AND "posthog_sessionrecording"."start_time" IS NOT NULL))'''# ---# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.13@@ -910,6 +918,7 @@COUNT("posthog_sessionrecordingplaylistitem"."id") AS "c"FROM "posthog_sessionrecordingplaylistitem"INNER JOIN "posthog_sessionrecordingplaylist" ON ("posthog_sessionrecordingplaylistitem"."playlist_id" = "posthog_sessionrecordingplaylist"."id")+ LEFT OUTER JOIN "posthog_sessionrecording" ON ("posthog_sessionrecordingplaylistitem"."recording_id" = "posthog_sessionrecording"."session_id")WHERE ("posthog_sessionrecordingplaylist"."team_id" = 99999AND "posthog_sessionrecordingplaylistitem"."playlist_id" IN (1,2,@@ -917,7 +926,9 @@4,5 /* ... */)AND NOT ("posthog_sessionrecordingplaylistitem"."deleted"- AND "posthog_sessionrecordingplaylistitem"."deleted" IS NOT NULL))+ AND "posthog_sessionrecordingplaylistitem"."deleted" IS NOT NULL)+ AND NOT ("posthog_sessionrecording"."start_time" < '2024-12-02 12:00:00+00:00'::timestamptz+ AND "posthog_sessionrecording"."start_time" IS NOT NULL))GROUP BY 1'''# ---@@ -927,12 +938,17 @@"posthog_sessionrecordingplaylistitem"."recording_id" AS "recording_id"FROM "posthog_sessionrecordingplaylistitem"INNER JOIN "posthog_sessionrecordingplaylist" ON ("posthog_sessionrecordingplaylistitem"."playlist_id" = "posthog_sessionrecordingplaylist"."id")+ LEFT OUTER JOIN "posthog_sessionrecording" ON ("posthog_sessionrecordingplaylistitem"."recording_id" = "posthog_sessionrecording"."session_id")WHERE ("posthog_sessionrecordingplaylist"."team_id" = 99999AND "posthog_sessionrecordingplaylistitem"."playlist_id" IN (1,2,3,4,- 5 /* ... */))+ 5 /* ... */)+ AND NOT ("posthog_sessionrecordingplaylistitem"."deleted"+ AND "posthog_sessionrecordingplaylistitem"."deleted" IS NOT NULL)+ AND NOT ("posthog_sessionrecording"."start_time" < '2024-12-02 12:00:00+00:00'::timestamptz+ AND "posthog_sessionrecording"."start_time" IS NOT NULL))'''# ---# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.23@@ -1875,6 +1891,7 @@COUNT("posthog_sessionrecordingplaylistitem"."id") AS "c"FROM "posthog_sessionrecordingplaylistitem"INNER JOIN "posthog_sessionrecordingplaylist" ON ("posthog_sessionrecordingplaylistitem"."playlist_id" = "posthog_sessionrecordingplaylist"."id")+ LEFT OUTER JOIN "posthog_sessionrecording" ON ("posthog_sessionrecordingplaylistitem"."recording_id" = "posthog_sessionrecording"."session_id")WHERE ("posthog_sessionrecordingplaylist"."team_id" = 99999AND "posthog_sessionrecordingplaylistitem"."playlist_id" IN (1,2,@@ -1882,7 +1899,9 @@4,5 /* ... */)AND NOT ("posthog_sessionrecordingplaylistitem"."deleted"- AND "posthog_sessionrecordingplaylistitem"."deleted" IS NOT NULL))+ AND "posthog_sessionrecordingplaylistitem"."deleted" IS NOT NULL)+ AND NOT ("posthog_sessionrecording"."start_time" < '2024-12-02 12:00:00+00:00'::timestamptz+ AND "posthog_sessionrecording"."start_time" IS NOT NULL))GROUP BY 1'''# ---@@ -1892,12 +1911,17 @@"posthog_sessionrecordingplaylistitem"."recording_id" AS "recording_id"FROM "posthog_sessionrecordingplaylistitem"INNER JOIN "posthog_sessionrecordingplaylist" ON ("posthog_sessionrecordingplaylistitem"."playlist_id" = "posthog_sessionrecordingplaylist"."id")+ LEFT OUTER JOIN "posthog_sessionrecording" ON ("posthog_sessionrecordingplaylistitem"."recording_id" = "posthog_sessionrecording"."session_id")WHERE ("posthog_sessionrecordingplaylist"."team_id" = 99999AND "posthog_sessionrecordingplaylistitem"."playlist_id" IN (1,2,3,4,- 5 /* ... */))+ 5 /* ... */)+ AND NOT ("posthog_sessionrecordingplaylistitem"."deleted"+ AND "posthog_sessionrecordingplaylistitem"."deleted" IS NOT NULL)+ AND NOT ("posthog_sessionrecording"."start_time" < '2024-12-02 12:00:00+00:00'::timestamptz+ AND "posthog_sessionrecording"."start_time" IS NOT NULL))'''# ---# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.45diff --git a/posthog/session_recordings/test/test_session_recording_playlist.py b/posthog/session_recordings/test/test_session_recording_playlist.pyindex cba754d7e89a..d1507c80750f 100644--- a/posthog/session_recordings/test/test_session_recording_playlist.py+++ b/posthog/session_recordings/test/test_session_recording_playlist.py@@ -35,6 +35,7 @@ from posthog.session_recordings.session_recording_playlist_api import (PLAYLIST_LIST_MAX_LIMIT,_attach_empty_recordings_counts,_empty_saved_filters_counts,+ count_collection_recordings,parse_non_negative_int,parse_positive_int,precompute_recordings_counts,@@ -336,13 +337,11 @@ class TestSessionRecordingPlaylist(APIBaseTest, QueryMatchingTest):)def test_can_create_many_playlists_without_n_plus_1(self):- # one query to get started and then 13 per creation (was 14, -1 after dropping duplicate session lookup)- with self.assertNumQueries(13 * 50 + 1):+ with self.assertNumQueries(12 * 50 + 1):for i in range(50):self._create_playlist({"name": f"test-{i}", "type": "collection"})- # 13 per creation (was 14, -1 after dropping duplicate session lookup)- with self.assertNumQueries(13 * 100):+ with self.assertNumQueries(12 * 100):for i in range(100):self._create_playlist({"name": f"test-{i}", "type": "collection"})@@ -1650,17 +1649,29 @@ class TestPrecomputeRecordingsCounts(APIBaseTest):assert playlist._prefetched_collection_count == {"count": 3, "watched_count": 2} # type: ignore[attr-defined]assert not hasattr(playlist, "_prefetched_saved_filters_count")- def test_collection_with_soft_deleted_items_excluded_from_count(self) -> None:- playlist = self._make_playlist("all deleted")- rec = SessionRecording.objects.create(team=self.team, session_id="deleted-1")- SessionRecordingPlaylistItem.objects.create(playlist=playlist, recording=rec, deleted=True)- SessionRecordingViewed.objects.create(team=self.team, user=self.user, session_id="deleted-1")+ @parameterized.expand(+ [+ ("soft_deleted", {"deleted": True}, {}),+ ("expired", {}, {"start_time": datetime.now(UTC) - timedelta(days=31)}),+ ]+ )+ def test_gone_items_excluded_from_count_and_watched(+ self, _name: str, item_kwargs: dict, recording_kwargs: dict+ ) -> None:+ playlist = self._make_playlist("gone")+ rec = SessionRecording.objects.create(team=self.team, session_id="gone-1", **recording_kwargs)+ SessionRecordingPlaylistItem.objects.create(playlist=playlist, recording=rec, **item_kwargs)+ kept = SessionRecording.objects.create(+ team=self.team, session_id="kept-1", start_time=datetime.now(UTC) - timedelta(days=29)+ )+ SessionRecordingPlaylistItem.objects.create(playlist=playlist, recording=kept)+ for session_id in ["gone-1", "kept-1"]:+ SessionRecordingViewed.objects.create(team=self.team, user=self.user, session_id=session_id)precompute_recordings_counts([playlist], self.user, self.team)- # count excludes the soft-deleted item (None), but watched_count includes it- # to match the historical behavior of count_collection_recordings.- assert playlist._prefetched_collection_count == {"count": None, "watched_count": 1} # type: ignore[attr-defined]+ assert playlist._prefetched_collection_count == {"count": 1, "watched_count": 1} # type: ignore[attr-defined]+ assert count_collection_recordings(playlist, self.user, self.team) == {"count": 1, "watched_count": 1}def test_empty_collection_loads_saved_filters_from_redis(self) -> None:playlist = self._make_playlist("empty")diff --git a/products/replay_vision/frontend/components/ObservationProgressBar.tsx b/products/replay_vision/frontend/components/ObservationProgressBar.tsxindex e78c45081e88..1c1837e79dbd 100644--- a/products/replay_vision/frontend/components/ObservationProgressBar.tsx+++ b/products/replay_vision/frontend/components/ObservationProgressBar.tsx@@ -69,23 +69,20 @@ export function ObservationProgressBar({sessionId: stringcompact?: boolean}): JSX.Element {- const { progress, streamError } = useValues(observationProgressLogic({ observationId, sessionId }))+ const { progress, phaseStartedAt, streamError } = useValues(observationProgressLogic({ observationId, sessionId }))const { startStream } = useActions(observationProgressLogic({ observationId, sessionId }))usePeriodicRerender(1000)- // Record when the active phase was first observed so its asymptotic fill animates from then.- const startTimesRef = useRef<Record<number, number>>({})+ const mountedAtRef = useRef(Date.now())useEffect(() => {- startTimesRef.current = {}+ mountedAtRef.current = Date.now()startStream()}, [observationId, startStream])const currentStep = Math.min(progress?.step ?? 0, PHASE_ORDER.length - 1)const activePhase = PHASE_ORDER[currentStep]- if (!(currentStep in startTimesRef.current)) {- startTimesRef.current[currentStep] = Date.now()- }- const activeElapsed = Math.max(0, (Date.now() - startTimesRef.current[currentStep]) / 1000)+ const activeStartedAt = phaseStartedAt[currentStep] ?? mountedAtRef.current+ const activeElapsed = Math.max(0, (Date.now() - activeStartedAt) / 1000)// Real sub-progress only exists while rendering (frame counts from the rasterizer heartbeats); else asymptote.const frame = activePhase === 'rendering' ? progress?.rasterizer?.frame_progress : undefineddiff --git a/products/replay_vision/frontend/components/ObservationTimeline.tsx b/products/replay_vision/frontend/components/ObservationTimeline.tsxindex eb215cf9bebf..fa697087cd47 100644--- a/products/replay_vision/frontend/components/ObservationTimeline.tsx+++ b/products/replay_vision/frontend/components/ObservationTimeline.tsx@@ -13,6 +13,7 @@ import { currentMarkIndex, timelineGapPx } from '../utils/observationTimeline'import { ObservationMarkTooltip } from './ObservationSeekbarMarks'const ROW_GRID = 'grid grid-cols-[2.5rem_1rem_minmax(0,1fr)] gap-x-1.5'+const ROW_GRID_HOURS = 'grid grid-cols-[4rem_1rem_minmax(0,1fr)] gap-x-1.5'export function ObservationTimeline({sessionId,@@ -28,6 +29,8 @@ export function ObservationTimeline({const { hoveredMarkMs } = useValues(logic)const { setHoveredMark } = useActions(logic)const currentIndex = currentMarkIndex(marks, currentPlayerTime)+ const hasHours = marks.some((mark) => mark.timestampMs >= 3_600_000)+ const rowGrid = hasHours ? ROW_GRID_HOURS : ROW_GRIDuseEffect(() => () => setHoveredMark(null), [setHoveredMark])return (@@ -42,7 +45,7 @@ export function ObservationTimeline({<Fragment key={mark.timestampMs}>{gapPx > 0 && (<div- className={cn(ROW_GRID, 'px-2')}+ className={cn(rowGrid, 'px-2')}// eslint-disable-next-line react/forbid-dom-propsstyle={{ height: gapPx }}>@@ -53,7 +56,7 @@ export function ObservationTimeline({<divdata-current-moment={isCurrent ? true : undefined}className={cn(- ROW_GRID,+ rowGrid,'px-2 py-0.5 transition-colors',isCurrent && 'bg-fill-highlight-50',hoveredMarkMs === mark.timestampMs && 'bg-surface-secondary'@@ -67,7 +70,7 @@ export function ObservationTimeline({isCurrent ? 'text-accent font-semibold' : 'text-secondary')}>- {colonDelimitedDuration(Math.floor(mark.timestampMs / 1000), null)}+ {colonDelimitedDuration(Math.floor(mark.timestampMs / 1000), hasHours ? 3 : 2)}</span><div className="flex flex-col items-center -my-0.5"><span className={cn('w-0.5 flex-1', railColor)} />diff --git a/products/replay_vision/frontend/components/ObservationsDock.tsx b/products/replay_vision/frontend/components/ObservationsDock.tsxindex a6b6b7245fe2..f9c618534bea 100644--- a/products/replay_vision/frontend/components/ObservationsDock.tsx+++ b/products/replay_vision/frontend/components/ObservationsDock.tsx@@ -20,7 +20,12 @@ import { observationsDockLogic } from '../logics/observationsDockLogic'import { visionQuotaLogic } from '../logics/visionQuotaLogic'import { LIMIT_REACHED_TOOLTIP } from '../replay_scanners/scannerCopy'import { getReplayVisionEditDisabledReason } from '../utils/accessControl'-import { BUILT_IN_SUMMARY_LABEL, dockObservations, isUnsuccessfulScan } from '../utils/observation'+import {+ BUILT_IN_SUMMARY_LABEL,+ dockObservations,+ isSummaryObservation,+ isUnsuccessfulScan,+} from '../utils/observation'import { quotaUx } from '../utils/quotaProjection'import { ScanBlock, recordingScanBlock } from '../utils/scanEligibility'import { VisionDocsLink, visionDocsUrl } from './DocsLink'@@ -73,8 +78,9 @@ function useSummarizeBlockedReason(/** Runs whichever summarizer `resolveSummarizer` settles on, and lets the user pick another. */function SummarizeButton({ sessionId, scanBlock }: { sessionId: string; scanBlock: ScanBlock | null }): JSX.Element {const logic = observationsDockLogic({ sessionId })- const { summarizePending, defaultSummarizer, summarizerScanners } = useValues(logic)+ const { summarizePending, defaultSummarizer, summarizerScanners, observations } = useValues(logic)const { summarize, summarizeWith } = useActions(logic)+ const hasSummary = observations.some((o) => isSummaryObservation(o) && o.status === 'succeeded')const { quota } = useValues(visionQuotaLogic)const { dataProcessingAccepted } = useValues(aiConsentLogic)const [consentRequested, setConsentRequested] = useState(false)@@ -88,7 +94,11 @@ function SummarizeButton({ sessionId, scanBlock }: { sessionId: string; scanBlocinFlightDisabledReason ?? blockedReason(scanner)// Nobody could tell which summarizer the button used, so it says so. While a scan is running the// label is the only thing that says the click landed: the summary takes minutes to arrive.- const idleLabel = defaultSummarizer ? `Summarize with ${defaultSummarizer.name}` : 'Summarize this recording'+ const idleLabel = hasSummary+ ? 'Summarize again'+ : defaultSummarizer+ ? `Summarize with ${defaultSummarizer.name}`+ : 'Summarize this recording'const label = summarizePending ? 'Summarizing…' : idleLabelconst summarizerTooltip = summarizePending? 'Watching this recording. The summary appears below when it is ready.'@@ -129,7 +139,7 @@ function SummarizeButton({ sessionId, scanBlock }: { sessionId: string; scanBlocconst button = (<LemonButtonsize="small"- type="secondary"+ type={hasSummary ? 'tertiary' : 'secondary'}icon={<IconNotebook />}loading={summarizePending}// The endpoint refuses without org AI approval, so ask for it here rather than toasting a 400.diff --git a/products/replay_vision/frontend/components/PlayerSidebarObservationsTab.tsx b/products/replay_vision/frontend/components/PlayerSidebarObservationsTab.tsxindex 0226244bab11..cdc20344fbb5 100644--- a/products/replay_vision/frontend/components/PlayerSidebarObservationsTab.tsx+++ b/products/replay_vision/frontend/components/PlayerSidebarObservationsTab.tsx@@ -150,17 +150,15 @@ function defaultFocus(observations: ReplayObservationApi[]): ReplayObservationApfunction ObservationRuns({sessionId,observations,- seekbarMarks,onSeek,}: {sessionId: stringobservations: ReplayObservationApi[]- seekbarMarks: ObservationSeekbarMark[]onSeek: (timestampMs: number) => void}): JSX.Element | null {const logic = observationsDockLogic({ sessionId })const { focusedObservationId, followMoments, retryingObservationIds } = useValues(logic)- const { focusObservation, setFollowMoments, retryObservation } = useActions(logic)+ const { focusObservation, retryObservation } = useActions(logic)const { currentPlayerTime } = useValues(sessionRecordingPlayerLogic)const paneRef = useRef<HTMLDivElement>(null)const followedMs = useRef<number | null>(null)@@ -169,8 +167,9 @@ function ObservationRuns({[observations])const focused = observations.find((o) => o.id === focusedObservationId) ?? defaultFocus(observations)- const currentIndex = currentMarkIndex(seekbarMarks, currentPlayerTime)- const currentMs = currentIndex >= 0 ? seekbarMarks[currentIndex].timestampMs : null+ const focusedMarks = focused ? (marksByRun.get(focused.id) ?? []) : []+ const currentIndex = currentMarkIndex(focusedMarks, currentPlayerTime)+ const currentMs = currentIndex >= 0 ? focusedMarks[currentIndex].timestampMs : nulluseEffect(() => {if (!followMoments) {@@ -180,18 +179,9 @@ function ObservationRuns({if (currentMs === null || followedMs.current === currentMs) {return}- const owns = (o: ReplayObservationApi): boolean =>- marksByRun.get(o.id)?.some((m) => m.timestampMs === currentMs) ?? false- if (focused && !owns(focused)) {- const owner = observations.find(owns)- if (owner) {- focusObservation(owner.id)- return- }- }followedMs.current = currentMspaneRef.current?.querySelector<HTMLElement>(CURRENT_MOMENT_SELECTOR)?.scrollIntoView({ block: 'nearest' })- }, [currentMs, followMoments, focused, observations, marksByRun, focusObservation])+ }, [currentMs, followMoments])if (observations.length === 0) {return null@@ -237,10 +227,7 @@ function ObservationRuns({</Tooltip>) : undefined}- onClick={() => {- focusObservation(observation.id)- setFollowMoments(false)- }}+ onClick={() => focusObservation(observation.id)}data-attr="vision-run-row"><span className="flex items-center gap-2 min-w-0 w-full font-normal">@@ -512,12 +499,7 @@ function ObservationsTabContent({ sessionId }: { sessionId: string }): JSX.Eleme</div>)}</div>- <ObservationRuns- sessionId={sessionId}- observations={observations}- seekbarMarks={seekbarMarks}- onSeek={seekToTime}- />+ <ObservationRuns sessionId={sessionId} observations={observations} onSeek={seekToTime} /></>)}</div>diff --git a/products/replay_vision/frontend/observations/observationProgressLogic.test.ts b/products/replay_vision/frontend/observations/observationProgressLogic.test.tsnew file mode 100644index 000000000000..5e53affb73b1--- /dev/null+++ b/products/replay_vision/frontend/observations/observationProgressLogic.test.ts@@ -0,0 +1,44 @@+import { initKeaTests } from '~/test/init'++import { type ObservationProgress, observationProgressLogic } from './observationProgressLogic'++const tick = (step: number): ObservationProgress => ({ phase: 'any', step, total_steps: 6 })++describe('observationProgressLogic', () => {+ beforeEach(() => {+ initKeaTests()+ })++ it.each([+ ['progress', (logic: ReturnType<typeof observationProgressLogic.build>) => logic.values.progress, tick(2)],+ [+ 'phase start times',+ (logic: ReturnType<typeof observationProgressLogic.build>) => logic.values.phaseStartedAt,+ { 1: 1000, 2: 2000 },+ ],+ ])('keeps %s across a remount', (_, read, expected) => {+ const first = observationProgressLogic({ observationId: 'obs-1' })+ const unmount = first.mount()+ first.actions.setProgress(tick(1), 1000)+ first.actions.setProgress(tick(1), 1500)+ first.actions.setProgress(tick(2), 2000)+ unmount()++ const second = observationProgressLogic({ observationId: 'obs-1' })+ second.mount()+ expect(read(second)).toEqual(expected)+ })++ it('forgets a settled observation', () => {+ const first = observationProgressLogic({ observationId: 'obs-2' })+ const unmount = first.mount()+ first.actions.setProgress(tick(3), 1000)+ first.actions.streamCompleted()+ unmount()++ const second = observationProgressLogic({ observationId: 'obs-2' })+ second.mount()+ expect(second.values.progress).toBeNull()+ expect(second.values.phaseStartedAt).toEqual({})+ })+})diff --git a/products/replay_vision/frontend/observations/observationProgressLogic.ts b/products/replay_vision/frontend/observations/observationProgressLogic.tsindex 9cdd48f42c86..920a1d05bded 100644--- a/products/replay_vision/frontend/observations/observationProgressLogic.ts+++ b/products/replay_vision/frontend/observations/observationProgressLogic.ts@@ -22,6 +22,20 @@ export interface ObservationProgress {rasterizer?: ObservationRasterizerProgress | null}+export type PhaseStartedAt = Record<number, number>++interface RememberedProgress {+ progress: ObservationProgress | null+ phaseStartedAt: PhaseStartedAt+}++// Survives unmount so a reopened tab or dock resumes the bar instead of restarting it.+const progressMemory = new Map<string, RememberedProgress>()++function rememberedProgress(observationId: string): RememberedProgress {+ return progressMemory.get(observationId) ?? { progress: null, phaseStartedAt: {} }+}+export interface ObservationProgressLogicProps {observationId: string/** Lets the dock list refresh on completion; optional since the details page has no dock. */@@ -95,14 +109,19 @@ async function consumeProgressStream(// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface observationProgressLogicValues {+ phaseStartedAt: PhaseStartedAtprogress: ObservationProgress | nullstreamError: string | null}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface observationProgressLogicActions {- setProgress: (progress: ObservationProgress) => {+ setProgress: (+ progress: ObservationProgress,+ receivedAt?: number+ ) => {progress: ObservationProgress+ receivedAt: number}setStreamError: (error: string) => {error: string@@ -139,27 +158,40 @@ export const observationProgressLogic = kea<observationProgressLogicType>([actions({// Idempotent — callers that know the observation is in flight open the stream; settled rows never do.startStream: true,- setProgress: (progress: ObservationProgress) => ({ progress }),+ setProgress: (progress: ObservationProgress, receivedAt: number = Date.now()) => ({ progress, receivedAt }),streamCompleted: true,setStreamError: (error: string) => ({ error }),}),- reducers({+ reducers(({ props }) => ({progress: [- null as ObservationProgress | null,+ rememberedProgress(props.observationId).progress,{setProgress: (_, { progress }) => progress,},],+ phaseStartedAt: [+ rememberedProgress(props.observationId).phaseStartedAt,+ {+ setProgress: (state, { progress, receivedAt }) =>+ progress.step in state ? state : { ...state, [progress.step]: receivedAt },+ },+ ],streamError: [null as string | null,{setStreamError: (_, { error }) => error,},],- }),+ })),- listeners(({ props, actions, cache }) => ({+ listeners(({ props, actions, cache, values }) => ({+ setProgress: () => {+ progressMemory.set(props.observationId, {+ progress: values.progress,+ phaseStartedAt: values.phaseStartedAt,+ })+ },startStream: () => {const teamId = teamLogic.values.currentTeamIdif (cache.streamStarted || !teamId) {@@ -178,6 +210,7 @@ export const observationProgressLogic = kea<observationProgressLogicType>([streamCompleted: () => {// The observation settled — dispose the stream so tab hide/show cycles don't resurrect it.cache.disposables.dispose('progressStream')+ progressMemory.delete(props.observationId)// Refresh the dock list so the finished card swaps to the result immediately; no-op if the dock isn't mounted.if (props.sessionId) {observationsDockLogic.findMounted({ sessionId: props.sessionId })?.actions.loadObservations()diff --git a/products/replay_vision/frontend/search/ObservationSearch.tsx b/products/replay_vision/frontend/search/ObservationSearch.tsxindex d91aa8643ab1..f0967bb28ac7 100644--- a/products/replay_vision/frontend/search/ObservationSearch.tsx+++ b/products/replay_vision/frontend/search/ObservationSearch.tsx@@ -205,7 +205,7 @@ export function ObservationSearch({ className }: { className?: string }): JSX.ElonChange={(fromDate, toDate) => setDateRange(fromDate, toDate)}size="small"type="secondary"- placeholder="Any time"+ placeholder="All time"/></span><span onClick={(event) => event.stopPropagation()}>diff --git a/products/replay_vision/frontend/search/SearchResults.tsx b/products/replay_vision/frontend/search/SearchResults.tsxindex f6284832cdb4..81949d77b536 100644--- a/products/replay_vision/frontend/search/SearchResults.tsx+++ b/products/replay_vision/frontend/search/SearchResults.tsx@@ -11,6 +11,8 @@ import { colonDelimitedDuration } from 'lib/utils/durations'import { pluralize } from 'lib/utils/strings'import { urls } from 'scenes/urls'+import { PersonDisplay } from 'products/persons/frontend/components/PersonDisplay'+import { ObservationResultSummary } from '../components/ObservationCard'import { ObservationThumbnail } from '../components/ObservationThumbnail'import { RecordingExpiredTag } from '../components/RecordingExpiredTag'@@ -164,16 +166,18 @@ function MatchSnippet({function SubjectLink({ observation }: { observation: ReplayObservationApi }): JSX.Element {const email = observation.recording_subject_emailconst subjectClass = clsx('text-xs truncate', !email && 'font-mono')- return observation.distinct_id ? (- <Link- to={urls.personByDistinctId(observation.distinct_id)}- className={clsx(subjectClass, 'text-primary')}- data-attr="vision-search-result-person"- >- {email ?? observation.distinct_id}- </Link>- ) : (- <span className={clsx(subjectClass, 'text-muted')}>{email ?? observation.session_id}</span>+ if (!observation.distinct_id) {+ return <span className={clsx(subjectClass, 'text-muted')}>{email ?? observation.session_id}</span>+ }+ return (+ <span className={subjectClass} data-attr="vision-search-result-person">+ <PersonDisplay+ person={{ distinct_id: observation.distinct_id, properties: email ? { email } : {} }}+ displayName={email ?? observation.distinct_id}+ noEllipsis+ inline+ />+ </span>)}