:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(replay): replay updated UI candidate 1 (#121920)
Hayne Ryu2d22c7ca160f
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 93ded1ee99b8..d6da4673670f 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -6179,9 +6179,9 @@ snapshots:marketing-analytics-conversion-recordings--query-error--light:hash: v1.k794b7964.c32a81254ecf704df432890875e747e34a0265cdd9aae7bd4a0b932d56f1026a.P5ahAUoGy5S_M5myQ_gs2VeSCa3KUAKm0HDUW7Nfd0gmarketing-analytics-conversion-recordings--with-recordings--dark:- hash: v1.k794b7964.034708435d5dcfd7176fa9f1047b3589e9f50ab1d1779162889e3f2809195efc.7fhQ5OBKQDIopN0biLM-QvGCezQktcPkIeiWCxg-Ejw+ hash: v1.k794b7964.e4ba9a5b539d8d5793cd006a4216d0fb269bfdf6aadb73fc2a0000bbc134a628.538OiZKa7nx5_GM1n-96_LPIFUtjFVrMfe0eZyoh1TEmarketing-analytics-conversion-recordings--with-recordings--light:- hash: v1.k794b7964.dc373cb616c36370cc092f289074f31c9890f19cb62b8764b73aff939cd33c5c.4_wo4AtdoSFk4dcwLNDHTJdh1GuBXk2r-S5beDQadG8+ hash: v1.k794b7964.2bd23ebf34db8691d2635efd1d0e69e72c62a5bf316b0eb5d111f31c5adbd599.-EMHfqpoNfdDI8FC2Puf8apQ3FIgYPXYrpearRoPrIkmarketing-analytics-customer-acquisition-cards--configuration-loading--dark:hash: v1.k794b7964.4e3295796230b8ccc9ce5cb239d9ffe000af9d00324d31584d3fa6fde8550fe9.04jR2iHz7Mn5n3Z6KmK4yt-R520UGYL9im_4Icykhxkmarketing-analytics-customer-acquisition-cards--configuration-loading--light:@@ -8739,9 +8739,9 @@ snapshots:replay-overview-tab--many-other-watchers-overview-tab--light:hash: v1.k794b7964.fc81e1b68ca43fe792f88d3e6712c1bc140216c9bfac92f2f341202c92c49ef7.vIkiS8VE-qBGJId317Nj6tlA-8vaX8tpiD4MTe4yaocreplay-overview-tab--narrow-overview-tab--dark:- hash: v1.k794b7964.0fad6539e471b3e2684e135c812a781f84a0a6470a25ccc80cc5d89e88c23620.g1deiVKpBiF22OcamxJXEGpVTas3pLcjRL2isCkTdIs+ hash: v1.k794b7964.6141b1063fda0ba8da19ccd842e7a663fb91c37e276991eb8e06593d45b720b0.CHUcuXGZpRnMAekvLe2pd4obYHovyxjSY9kNP0fQHK4replay-overview-tab--narrow-overview-tab--light:- hash: v1.k794b7964.b5ebe29e2a1d311e0120f3f6ab67fcc1238e95c11e0f5972a47069aaa67e67f9.0Koj4ROe-Lij-staIcK0VY9hGFfDeEXvtNOw_vfNA3w+ hash: v1.k794b7964.406563a072ebe6a814b3b09dd1751f3e484cd8ecece21393fe8f260ec5a09dae.7K6YSQDcgtMsuNC5RVsJtkfvRwKfPw5OXidOVctajAEreplay-overview-tab--one-other-watchers-overview-tab--dark:hash: v1.k794b7964.e15d0677a0d91200e19d23daa1711e441e37cfbf0291449ab543817024d67b93.qzW6XTyxIvjLcrkssDncWGOeZ5WNV7iwnwrdHkXjI3kreplay-overview-tab--one-other-watchers-overview-tab--light:@@ -8843,17 +8843,17 @@ snapshots:replay-scenes-group--group-recording-tab-empty--light:hash: v1.k794b7964.0aba17cdb4216d3caca398c7a35df1f826e96d159d9bfe3074b8869002cdb7bd.nd9tUuKuiuz6fGJqeQKAgfOLZDJhkClu8ZkSd97guccreplay-scenes-group--group-recording-tab-multiple-and-not-found--dark:- hash: v1.k794b7964.10f6a549118011d67fe12097c2727572de2f1ed4e10ee08a7499318a97d0f50b.7V5PfAC0aXPR_ETMwYxLjY48Hl0mh0IqTZaHIovSyoc+ hash: v1.k794b7964.e74ac55b6f7b6f495df65ac800c8d424a8459cefacbe44bd28ae456534c10631.mc_AnDljplyXaSAJhx0NtiiO4--nZq5CCUr48sIBS_creplay-scenes-group--group-recording-tab-multiple-and-not-found--light:- hash: v1.k794b7964.db107b354a8707c342fadf7fbc8e5d22f9a06e67cc5928d90882488a056b6f42.vot1toRfMn4sTbfzXr9lNAHkLm0pfzXLJKM0CJvf8gI+ hash: v1.k794b7964.911ccbaef08b8208e678e5e1d99b6684e2a3b3f6509fa300abd4467817de99e8.LOUG4UOR0R60J9YQWwbgsUceCZiiE0XNkMwsY81uub0replay-scenes-person--person-recording-tab-empty--dark:hash: v1.k794b7964.1ebd1d16c864a5eb85d980e24e9788e46407270bb5310aab1536ad82ff866564.funLfJoiZRptOAQJqpHwZycNYtwWvcrk8TJGIaJWJHEreplay-scenes-person--person-recording-tab-empty--light:hash: v1.k794b7964.d9534be8bacd85647b416e9673fc9c1b0cb663da2653b0bb2c70da2cb04a19c5.-lYEEqjkENx3FAfT5KASFseck3ypZr_EUtmY3b3oTNcreplay-scenes-person--person-recording-tab-multiple-and-not-found--dark:- hash: v1.k794b7964.9d8c1937a0f02be0a7613ce103ddb87759e785755d3dae9193f29957da3f9626.ZFwd937qv7MRGNiZymmNf72I5hQHZ7VBrAX6oXA6klk+ hash: v1.k794b7964.1a68ea4457989f29be10ee4257de32c104f5c5eb3efc973c0fd92797568d05f5.ZPd0rmKpijvvT6HG6em65d8C7Zf_vRx4rvZjV8wzrfwreplay-scenes-person--person-recording-tab-multiple-and-not-found--light:- hash: v1.k794b7964.4aa9fd925d4ed9c732a7d2fa999898cd4aec29a3f7bf2f63a4a1ddc26646540b.VqnRNdFDOrxW-1mXIfhWiiDFi2EL5JUDA9B7R4vyRTg+ hash: v1.k794b7964.8ec391f15df9d90808c6c406da3e64b338dbd949ee25a8f460070fa9407c2b30.PqJZp1HCJVOCBrDGOz1MxjsC_2yFyyP3gUpozNk_UXAreplay-sharing--private-link--dark:hash: v1.k794b7964.5ef4bd7e1d49d4506c360881a3a1482e857b5240362d76c855692eab18fc0764.0IvXqC6Lmuj5NeaGPbu0_5gr6mVBAtiGtBfKu7gvQXAreplay-sharing--private-link--light:@@ -8867,53 +8867,53 @@ snapshots:replay-tabs-collections--recordings-play-lists--light:hash: v1.k794b7964.6222abf98105cd0188d4cc9af5e440747293bad8393a5dd32379199e1c69aa0e.2T21X0LwwT672EPjH_o_c93FVUaCP_ouE0bFEXKpilAreplay-tabs-home-failure--not-found--dark:- hash: v1.k794b7964.302eb9c04317d3be0c61238d109c926938a52700c72fb9d20cfb858aaff2e772.BLyhmTRYcFYwXe5RsPygUm2K7_C5zSAduG195q8LFQg+ hash: v1.k794b7964.437d3c8dfdd121bda6fad40b2205bf3f7945b2494e6b6e374a238a758300fc43.X0GoW05bsLsPC3ERjwbp7GGcL4I2GTm7LLf1gt91bJ4replay-tabs-home-failure--not-found--light:- hash: v1.k794b7964.d0daf28e4514f86abdaa99f1a91969610c3f88e62a9af10fbd5df88fc7fe9ae0.q_jAwIlsdyNshHxRa45soOXdCCyWPiubasBQ8Os60yw+ hash: v1.k794b7964.49ea7dd5dead8a4545c4b7499408647959fec345ee4d40b8152ba7849733e377.QON8b8jJ00Ur3R0fNZ7_qNXkMPthG1pn8Gb8ycVtepkreplay-tabs-home-filters-banner--event-match-scope-only-during-recording--dark:- hash: v1.k794b7964.dd2964a3e756dd0261aa83e0f7310ff687bb8583bdff44070a01e329c3feb5ee.cIa9kjO5Inh407IVQivla3swrEr1rZziIi_4YhXLzxs+ hash: v1.k794b7964.9beb61ea56525082087e0f04472a36de2503d4bfd8cbf4baebb5e287dca8e232.z9jJjPgtJGDDS0sPeddm6jNB4hm1jZZP3yno9EnWMOoreplay-tabs-home-filters-banner--event-match-scope-only-during-recording--light:- hash: v1.k794b7964.6f6389d482771217fa21dea2665bf2349f4274ffdcb2ff239f9c1f6fd18f731c.1KW-i3U5jzWzZug4oaY-Qi_dwjoJ6hhK3bQtCnaQjLk+ hash: v1.k794b7964.54ae43251efcf7aa89cdc9af5506e73bc82622d60dfc95ef605babd84135d644.9nYobMnjOHY2iRKipG5k62z1maiw8Xm2doFqAdkoxVoreplay-tabs-home-filters-banner--event-match-scope-whole-session--dark:- hash: v1.k794b7964.522ca2d353a9622198f97c08ca27056538d980b489fc5677fa6726705c29db5a.5VxfB5UFxSCZ5DRxdr_xSXTKLxjGU16hfkCIjrj3ess+ hash: v1.k794b7964.52212ce8c5401dfb91b138d4bcab1adcd29498c2057d58d06dcedf935faec0f1.tyDPhoRytRueTpkHjC7Vz2IBUQBifc79aTVWQV5jOMQreplay-tabs-home-filters-banner--event-match-scope-whole-session--light:- hash: v1.k794b7964.42134a709a647667dfc0bc09025e744a1ed61dcec2966177445c3876d5fae7c5.WHaZQ1ueNT2unUD4yxQ4DX30erBaVO1yzy65GzElwd8+ hash: v1.k794b7964.ad8d5bac57c5fe6965170f59a28a715724ff476af06f8787056416e128d1b5e5.qNlMshdeQZdBpWqr2wDPzPcVUoAw-mw0p2tIGVHAeC4replay-tabs-home-filters-banner--page-filter-nudge--dark:- hash: v1.k794b7964.db808bfce453fe6fe0ce6c442530168d0a232b35673e65cd61354e797d941a02.7tRlekjUhZUnKQ_KKSQa2M7FM2EqvsHV-r9W_VF4mGI+ hash: v1.k794b7964.8a2c1dc5c51348c726fb2abe8cdaee33100dd9e85dfc8ff9baf2c13357691832.59oDr1ks2fOmBHhGUjEm3QaTD-UQQzfIhZuAKefiVH0replay-tabs-home-filters-banner--page-filter-nudge--light:- hash: v1.k794b7964.e873dbbc71e9ef40babc3d4e4749fba5a3b21fa0e32149d5f9caac42c609c5d5.O7VY_rtgeSCxwSdy_iOBGvOpS2rSNWi12lpb_USXQ7Y+ hash: v1.k794b7964.7134fa71ce46640db4b8743445a471393d47dc26eabfe85f60f2fc20a8be7f28.omY-rfHYXANlkhvRwCHJY0SahEY7TVGszVQUK29VYqwreplay-tabs-home-filters-banner--product-analytics-over-limit--dark:- hash: v1.k794b7964.f9b691207903431e1fb01d91481fe9903baf64254ce7f8bc48bc55f88f3a121f.CVjgPjTOt8P1EjDNQMQ5T_ThMIEP2-5QzfnJ7dWaBKc+ hash: v1.k794b7964.4bd3a7abdb232acb5565388cf6c13a14a9b57d1bf6f985b92628de76c6871526.7w-iP89o-Res4PgB9HjDaAG77inMI3GwSM_nQgD02lEreplay-tabs-home-filters-banner--product-analytics-over-limit--light:- hash: v1.k794b7964.de64cd78f8f6461e6db71b630ec3b5fc239643ced20bec50aec92d6c5f66d212.gI9R-kl-sdIvZY9haVtKn5SGlWJKraPHkyaFvLWow4E+ hash: v1.k794b7964.60c7fe370d8ce06ecebf18201a8ea7d0c06d1b73525bb247cdbc14a1f7ebfccc.A63WXBmB-PyuHDskA8FBc_wtsqYcVKvVlem5Xi2RdvIreplay-tabs-home-filters-banner--product-analytics-under-limit--dark:- hash: v1.k794b7964.a5cdd99396658dc913f5abb4646687028e65407e4d962b9eb68893b5467560d6.Mgi3ulQYY34IebAwtjOaeUAw6ZMhQtE8gsKorkjIu74+ hash: v1.k794b7964.b5c29c8b3f922ee4454f46e2eeac484bab2bf334f2d4008cceffc119256bd85d.UvMrn-EcZS6vDlxCnUlbNyOr1EpraCx7LlmKCWBGCXcreplay-tabs-home-filters-banner--product-analytics-under-limit--light:- hash: v1.k794b7964.23a4553f70ab341940a4b311195338bd2ee2568a33b3ec912bedae50ba196c01.tOLWQgPOna_Ul2cka3Pe0c8y3W8VSimcRq7MY3_6fPw+ hash: v1.k794b7964.bc227a614a4387183844d3f52df818b273b31d8d0a8d3b0e40fdf0a31488fb03.xFHUQD9ILXWiU9zR3XymL0E5VNOqa0jRvXiL5_FTiIsreplay-tabs-home-filters-banner--scanner-cross-sell--dark:- hash: v1.k794b7964.526550d3f475ebc70b5cca3160d7a5c94c5e25363ab4035590de24431b93065a.CkuW1p8le1hTzsKiBQQNTkq9dFPzCC7hDY5598shCEE+ hash: v1.k794b7964.cdda062e13754aeb37e3982382846ef836705498f6bbea45bb44a461945d43e2.8rtPhnDj48obOBCmP9Gzsmi6GQZwxWOvqT79lwYouDEreplay-tabs-home-filters-banner--scanner-cross-sell--light:- hash: v1.k794b7964.e450993871be830f7b006d44e458cb3ce4a8a4d16be457501210c404be53aa52.PRNFvZV3_zIDtlgwxYC-dBvs67whu67VQ_e_z6RdKNE+ hash: v1.k794b7964.a96216b5edb663a43474a80662c186bcdbf2c28ed8b5102d628fefa68b50ed98.vgbb2qohMFpIa0AX9WIcn8fgG6mxvygJDNu10McdBoUreplay-tabs-home-filters-banner--templates-tab--dark:- hash: v1.k794b7964.7d6d49c411c6891c25de7aecc530c06b51718b740f35f855013985047aebd2b6.KhH4mG61G5uQDtwaeCQoLNiEgGEJsB0UQojy6XS1YJo+ hash: v1.k794b7964.d029de296a4c76b82cefbd0e68f9990c27a1b9692764a9b3ddc4317dd5d184d4.VGIKGjydwEuB3kz2DSDoMy-1QWQkGO6PPu44E4bBto0replay-tabs-home-filters-banner--templates-tab--light:- hash: v1.k794b7964.2971745bb4db9b59b9dedf24921c62b61ccee8d5a2a85c91d0cf7acd7db42c80.0lliFM2dRqHQCYLwT3z0BLInPeVcHfz13lThHdx8dL4+ hash: v1.k794b7964.ec3ff93f6befcc3023bbd463bec6bf5de024dcb5a72cbe89a71d9d9f1c4d5766.p3-qJefglz62Ax8FJVuw4Nw5-H1b0ruj-_qD-sJw2d8replay-tabs-home-success--filters-expanded--dark:- hash: v1.k794b7964.11150cad6dc684f97f7c813c63a408d028da5a2c219f41a188f9c66d1379dbc1.dzTvXzE1zThZJ41yMw_LWTjjK8Np2j-SZG0jNPdqqHc+ hash: v1.k794b7964.3c44116a81b13e5bff825b60a47b55545c35a3759daf56a7ff005b06cea92894.sj__iXfOu_gPKw-bMvL88GS6peE_38mwdweD8Q1grTgreplay-tabs-home-success--filters-expanded--light:- hash: v1.k794b7964.0da4318182426e5ffb35d62764c803fd05d7ad49727f52bc81340032025f2f66.IHqOu8aRQ6DbBoGxxSIBTNgk0hPoJzMVvMSV6rNqaQU+ hash: v1.k794b7964.f0180f3ef7eec6b7662913c7983466985fd0b704320fd6f621dc6231e0b1998f.gg-hptkYHCvENZNY6lWpUG4bzEPWKd_QjiRAJ8ej194replay-tabs-home-success--filters-expanded-lots-of-results--dark:- hash: v1.k794b7964.263ae4d72a08816d427770f8f8c2f2107cc8f2c817d96e5a59e8c5fca05fc8a3.c5dbS8NiRnE-J7SX8SoSZS1qbeOoq4FY6tqlM79pnHg+ hash: v1.k794b7964.5cb5a9aa3e35980de21372b10eb781a2ce68355582f67678927f2f77717eecc3.0LEZPVgNM1y1wtv59dWFaDBegqN7GjLSKkOfuR15qmUreplay-tabs-home-success--filters-expanded-lots-of-results--light:- hash: v1.k794b7964.a2ad73835c8da36da8335ee1a5a38b59c815386e2a89266aa7f120436a5a83ab.UDVGd6f0FW-YvLLLtedcURYCb6x0xwI8_mQ0AP7n6Jo+ hash: v1.k794b7964.d48d3508658ec8b85c7af44556b696575a3e2cb82d13b31294bcb0d96b78b45d.brsMUPxQYONxKep5EIw-yQLcLx6RuwpCVJ28jI9yX8sreplay-tabs-home-success--filters-expanded-lots-of-results-narrow--dark:- hash: v1.k794b7964.37675dec7c088901e8acc7bc159b56eec26155c193f07d2f1984cace5cb69a49.jKcKD4ByomxRvewddfcQstAvpOqfQMaDHGnKS48I1Lg+ hash: v1.k794b7964.febe88ceea4dda13bacdf1c607f75d2e9abc102d1e629a66eba13d8c214d4e0b.62Nmx_LaX3f_TV70sgyUln1PXSzkSdnd1lMAc0l_Lh0replay-tabs-home-success--filters-expanded-lots-of-results-narrow--light:- hash: v1.k794b7964.7e5d93d6446e0fce0f04fa64aebf08f9e496031c49bd1ac847b35baea3ed7bf6.0dlBaNL4P3jSz36hZxYyorjnU08kP-f429Cwafc0_Qs+ hash: v1.k794b7964.cd7d4b9bcc2428c930d39c997f638565ea8b2791874a0e7c87622c3c3255a731.siGaa9VC8KBAz3q1NMXU9gEFxkLVg97LK1C3x12CUb8replay-tabs-home-success--recent-recordings--dark:- hash: v1.k794b7964.181b88b21680b75a599b3a1765dbfe5fcf171853f8ae011a6461e4a0a1789bba.Oq_Dvjnqt2cSqjHv_o_ReNVY88pzBPT46Bbz1Pju0g8+ hash: v1.k794b7964.b0a65fcb5e406ac108ae66fbef584d481a4d1242527916bdd2b76f29e6aefb0c.zpDbRoN8-M-qV7UrfHGBbG2ue9x8-FnKOcwfS4i6Bxgreplay-tabs-home-success--recent-recordings--light:- hash: v1.k794b7964.8d6dbd08c082759fad1506f5b972a562e4b3488cd0ff462b13c7b2a9c032d1b4.CObf9Ea5XxCYHHuPw1rL7Sw_TIEG7fXvZafg653dJoA+ hash: v1.k794b7964.ac1564ef89f9e8009a6f3db77886b0b2cf4044a572ed6e1065f8a8f1628b2ada.zOa2TIPnFuePySl7nOze6xBbdrR1gLu_KCVaLva4vAwreplay-tabs-home-success--recent-recordings-empty--dark:hash: v1.k794b7964.b96eb8ff3becd42ef223773f142db0fb5a5c7d743adcce158cb164940f170c20.5aj7iROHwfdLWjLstJZEx3YzsXaFoHJbn4sok-n-0XMreplay-tabs-home-success--recent-recordings-empty--light:@@ -8923,9 +8923,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.fe2c9b3f0d9d53c3c11414cffbd05edf9aaa13add32a0fcfa6bc8733ebf85ba2.2Hj3Zq1VAfEZ9FLper9Qb_VIiGLLsESrsqLaHXj5IOE+ hash: v1.k794b7964.c68c60552b46fc734ea298b8f5eb77d2cdfe6e7955e2ffd748f1f4e2e85615a6.j6HUWRibjb_k6dqSYZPq2WlsgQQGqpl6tcIUFnF41x4replay-tabs-home-success--second-recording-in-list--light:- hash: v1.k794b7964.5b4ed5a0a35924db2c7858412c31c68ab88ebb292d124c8ee305438bb1591f4f.PjJ2oQIuMUmkW9EWtpaSaK4bEUpuh04mp51gtft_0Zg+ hash: v1.k794b7964.73cd035dd729011ad95b931125575c12a551fbdcf3e9878c56f0e590336ebe9f.gCbEpTZY4gXbcB-q3YMfckYUMD6vl-U7n2hF3YAys2Mreplay-vision-cited-markdown--hostile-links--dark:hash: v1.k794b7964.d98b1851e8c4c695b87856379b85fd225d554c843086706f8d51fe5c060ad2d9.Nu73wfxltRa0Loo3i2L0DYIY_5NgIZwuP5RMTMyQGtsreplay-vision-cited-markdown--hostile-links--light:@@ -14111,9 +14111,9 @@ snapshots:scenes-app-notebooks--numbered-list--light:hash: v1.k794b7964.ea98fa6814bf6c76891c6388d8b778ba774f907259d54993487e56118aa971b5.3N7qzOULKNoMLZuwGfgEUrjYuPMEzGgEmQBTH_DEO6Qscenes-app-notebooks--recordings-playlist--dark:- hash: v1.k794b7964.04ae70f2328a562a1a92b7328ca42988176f5b75f646449df7601b38853ca2d0.zswyphw6SicUl1nBqJub2-5UedTBYh1OjJHBaUwPHv0+ hash: v1.k794b7964.a4a9ce19e0e20fe9e19fbecd0ff2ad0ea91a2895a6b047130405bd181b24cb11.fTeUAiGzD-nfW1WlRsG8CK3FkyCe3U3qQvjVeGFL85Qscenes-app-notebooks--recordings-playlist--light:- hash: v1.k794b7964.1534cca0a60310850b82045b2a830bf52f116f4ec2c65ca1111ed3e8516c4af1.ymK6pVoZD3SwpcPf76-YUVD8HnVQJk8u9AJY-przDzM+ hash: v1.k794b7964.0efa333b3965e37b6306cb2f1334730d95d182c8359b2bc82e3d27c60296b3ea.Rw-3GoyVQxQSD3IfTf5YIN3p5toZlAkyVSm2S0gqKr0scenes-app-notebooks--text-formats--dark:hash: v1.k794b7964.9aee0d4ed110f18b89a0582ba8921b09ff9f1f552bdca7194dece22095276e2b.iuSPrx27HlpPpQUUPtj2UxLCxn8oGwLZhea-l0G2ZqYscenes-app-notebooks--text-formats--light:@@ -14995,13 +14995,13 @@ snapshots:scenes-app-replay-vision--usage-tab--light:hash: v1.k794b7964.43595c3fb6282a80ca8aee0346ecfef1fad1777b29589a3d22d49a2132bbcd43.wySv2DQ6AsDsfonNurSn167gw_V9XO8bshMw1dR8tpwscenes-app-replay-vision-observations-tab-in-the-player--scans-without-a-summary--dark:- hash: v1.k794b7964.987f71747ad1d76951d200d2f38391d1d0e0892341d37174e2b379da329aeb1c.HAACdn9FvY9JgEH-aFfIXsg5TOKOFZcBdwcFQhqg4YI+ hash: v1.k794b7964.541ee5233b1f6805324b95d5d01de4cfec0b0012e0cceb100339735c9dcbd338.a66QPGNk0yvyiiaTOmkd2k1leqmyN9g85cLMJ8EWdXEscenes-app-replay-vision-observations-tab-in-the-player--scans-without-a-summary--light:- hash: v1.k794b7964.32eb4172ee1b8b1690a9ff53103d6ddc5bb42d0ff470b4ed6f077e4a366b3a45.72TcJgRHtYu4kse0aAICSEANcRwl0z5kr9G0ymTB3wc+ hash: v1.k794b7964.db23e0a097d8b126311d34389654c7e3e2a2f1eb070090d484b4977736db0b64.z7YTE4X2ZpMgVow1sWEijAXxKOH8UM-28wwDIiB7d8gscenes-app-replay-vision-observations-tab-in-the-player--timeline-with-scans--dark:- hash: v1.k794b7964.2e9ab8ecd76da1d15d90ad9fd421f81d14a94dcdd55977538899b75b26c97263.IlOJc3FzOL42hG1HXzE0NKVAnHDLTz7nVtRaJgMN0AA+ hash: v1.k794b7964.5d3dbd7b44baa14a4d441dab5a95f5160b9cdfc0d796f02be45a0774e6779c6c.xTMCRyvVbIEmXln90wTFTe3jZdBkIIZbi-V5TsQxVV4scenes-app-replay-vision-observations-tab-in-the-player--timeline-with-scans--light:- hash: v1.k794b7964.146f4d3e88a1e9cd4f60f1ba7d78f15b43879bc8d1795d61127a437824cb4014.Vn3KcIPqH7nd0pYuDEcH-OJi4lAkKY-a6SQo160sI8Q+ hash: v1.k794b7964.463f5bb598dc4ca9f8b5a5dee9ab539e7421fcb4a01a58f4a48c37747d611da3.zoCJWA8QvBTOWZsQDQpC2JIriaxj5Z_1qDakPn0nVKwscenes-app-replay-vision-observationthumbnail--frame--dark:hash: v1.k794b7964.25e0fc3a30206636572afe40dc1dece511909b329125acdd76d5cd6b70e4cebd.vUNWqzn2OcfR4oaaUWZaXz4aKxivNKx8scF34tw7JEEscenes-app-replay-vision-observationthumbnail--frame--light:diff --git a/frontend/src/lib/components/SettingsSnapshot.tsx b/frontend/src/lib/components/SettingsSnapshot.tsxindex b555ac928119..aefea581de96 100644--- a/frontend/src/lib/components/SettingsSnapshot.tsx+++ b/frontend/src/lib/components/SettingsSnapshot.tsx@@ -11,6 +11,7 @@ type Props = {title?: stringshowHeader?: booleanclassName?: string+ layout?: 'list' | 'grid'}export function SettingsSnapshot({@@ -19,6 +20,7 @@ export function SettingsSnapshot({title = 'Settings at the time of the event',showHeader = true,className,+ layout = 'list',}: Props): JSX.Element | null {const { loadSettingsAsOf } = useActions(settingsSnapshotLogic)const { settingsSnapshot, settingsSnapshotLoading } = useValues(settingsSnapshotLogic)@@ -75,7 +77,11 @@ export function SettingsSnapshot({<div className="text-muted text-xs">No settings to display.</div>) : null) : (- <div className="flex flex-col gap-2">+ <div+ className={+ layout === 'grid' ? 'grid grid-cols-3 gap-2 items-start [&>*]:min-w-0' : 'flex flex-col gap-2'+ }+ >{keysToRender.map((key) => {const label = key.replaceAll('_', ' ')diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex c02eaca10a25..f7a49718a3a8 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -498,12 +498,14 @@ export const FEATURE_FLAGS = {REPLAY_DEBUG_WITH_AI: 'replay-debug-with-ai', // owner: @clr182 #team-replay, player button that sends the recording JSON to PostHog AIREPLAY_EVENT_MATCH_SCOPE: 'replay-event-match-scope', // owner: @pauldambra #team-replay, shows the "Match the whole session / only during recording" filter selectREPLAY_FILTERS_REDESIGN: 'replay-filters-redesign', // owner: @ksvat #team-replay+ REPLAY_LAYOUT_SWITCHER: 'replay-layout-switcher', // owner: #team-replayREPLAY_NEGATIVE_EVENT_FILTERS: 'replay-negative-event-filters', // owner: @arnohillen #team-replayREPLAY_PLAYLIST_SURFACING_SCORE: 'replay-playlist-surfacing-score', // owner: #team-replayREPLAY_RECOMMENDED_RECORDINGS_FILTER_EXPERIMENT: 'replay-recommended-recordings-filter-experiment', // owner: @arnohillen #team-replay multivariate=control,testREPLAY_TRIGGERS_V2: 'replay-triggers-v2', // owner: #team-replayREPLAY_UI_REDESIGN_2026: 'replay-ui-redesign-2026', // owner: #team-replay, New UI layout for replayREPLAY_VISION_SCANNER_DASHBOARD: 'replay-vision-scanner-dashboard', // owner: #team-replay, one-click dashboard offer on the scanner overview and its MCP tool+ REPLAY_WATCH_LAYOUT: 'replay-watch-layout', // owner: #team-replay multivariate=control,compact,youtube,landing. The arm name is the layout; compare the variant string, a truthy check turns on for control tooREVAMPED_PY_NOTEBOOKS: 'revamped-py-notebooks', // owner: #team-data-toolsREVENUE_FIELDS_IN_POWER_USERS_TABLE: 'revenue-fields-in-power-users-table', // owner: @arthurdedeus #team-customer-analyticsREVIEW_HOG: 'review-hog', // owner: #team-devex, gates the Code review menu entry, scene, and API accessdiff --git a/frontend/src/lib/logic/featureFlagLogic.ts b/frontend/src/lib/logic/featureFlagLogic.tsindex 5d6a116b97cd..bc9fdfec4335 100644--- a/frontend/src/lib/logic/featureFlagLogic.ts+++ b/frontend/src/lib/logic/featureFlagLogic.ts@@ -98,6 +98,15 @@ function spyOnFeatureFlags(featureFlags: FeatureFlagsSet): FeatureFlagsSet {return flags}+export function peekFeatureFlag(featureFlags: FeatureFlagsSet, flag: FeatureFlagKey): boolean | string | undefined {+ const raw = (featureFlags as { toJSON?: () => FeatureFlagsSet }).toJSON?.() ?? featureFlags+ return raw[flag]+}++export function reportFeatureFlagExposure(featureFlags: FeatureFlagsSet, flag: FeatureFlagKey): void {+ notifyFlagIfNeeded(flag, peekFeatureFlag(featureFlags, flag))+}+export function getFeatureFlagPayload(flag: FeatureFlagKey): any {return posthog.getFeatureFlagResult(flag, { send_event: false })?.payload}diff --git a/frontend/src/scenes/session-recordings/SessionRecordings.tsx b/frontend/src/scenes/session-recordings/SessionRecordings.tsxindex 907df2feab33..3fd22577433d 100644--- a/frontend/src/scenes/session-recordings/SessionRecordings.tsx+++ b/frontend/src/scenes/session-recordings/SessionRecordings.tsx@@ -1,11 +1,11 @@-import { BindLogic, useValues } from 'kea'+import { BindLogic, useActions, useValues } from 'kea'import { router } from 'kea-router'import posthog from 'posthog-js'import { useState } from 'react'import * as explorerPng from '@posthog/brand/hoggies/png/explorer'import { IconDocument, IconGear, IconHeadset } from '@posthog/icons'-import { LemonButton, Link } from '@posthog/lemon-ui'+import { LemonButton, LemonSegmentedButton, Link } from '@posthog/lemon-ui'import { Button } from '@posthog/quill'import { PostHogCaptureOnViewed } from '@posthog/react'@@ -26,6 +26,8 @@ import { cn } from 'lib/utils/css-classes'import { sceneConfigurations } from 'scenes/scenes'import { Scene, SceneExport } from 'scenes/sceneTypes'import { LiveRecordingsCount } from 'scenes/session-recordings/components/LiveRecordingsCount'+import { playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'+import { NEW_REPLAY_LAYOUTS, ReplayLayout } from 'scenes/session-recordings/playlist/replayLayout'import { teamLogic } from 'scenes/teamLogic'import { urls } from 'scenes/urls'@@ -49,9 +51,18 @@ import { SCENE_PLAYLIST_LOGIC_PROPS, sessionReplaySceneLogic } from './sessionReconst HedgehogExplorer = pngHoggie(explorerPng)+const REPLAY_LAYOUT_LABELS: Record<ReplayLayout, string> = {+ classic: 'Legacy',+ compact: 'Compact',+ youtube: 'YouTube',+ landing: 'Landing',+}+function Header(): JSX.Element {const { tab } = useValues(sessionReplaySceneLogic)const { currentTeam } = useValues(teamLogic)+ const { watchLayoutOffered, replayLayout, canOverrideLayout, staffLayoutOverride } = useValues(playerSettingsLogic)+ const { setPreferClassicReplayLayout, setStaffLayoutOverride } = useActions(playerSettingsLogic)const recordingsDisabled = currentTeam && !currentTeam?.session_recording_opt_inconst [loading, setLoading] = useState(false)const todayRailNav = useFeatureFlag('TODAY_RAIL_NAV')@@ -81,6 +92,41 @@ function Header(): JSX.Element {<div className="flex items-center gap-2">{tab === ReplayTabs.Home && !recordingsDisabled && (<>+ {canOverrideLayout ? (+ <LemonSegmentedButton+ size="small"+ value={staffLayoutOverride ?? 'flag'}+ onChange={(value) => setStaffLayoutOverride(value === 'flag' ? null : value)}+ options={[+ {+ value: 'flag' as const,+ label: 'Flag',+ tooltip: 'Follow the feature flag',+ 'data-attr': 'replay-layout-override-flag',+ },+ {+ value: 'classic' as const,+ label: 'Legacy',+ 'data-attr': 'replay-layout-override-classic',+ },+ ...NEW_REPLAY_LAYOUTS.map((layout) => ({+ value: layout,+ label: REPLAY_LAYOUT_LABELS[layout],+ 'data-attr': `replay-layout-override-${layout}`,+ })),+ ]}+ />+ ) : watchLayoutOffered ? (+ <LemonSegmentedButton+ size="small"+ value={replayLayout === 'classic' ? 'classic' : 'new'}+ onChange={(value) => setPreferClassicReplayLayout(value === 'classic')}+ options={[+ { value: 'new', label: 'New layout', 'data-attr': 'replay-layout-switch-new' },+ { value: 'classic', label: 'Legacy', 'data-attr': 'replay-layout-switch-classic' },+ ]}+ />+ ) : null}<LiveRecordingsCount /><ScenePanel><ScenePanelActionsSection>@@ -266,7 +312,11 @@ function MainPanel(): JSX.Element {{isRedesignEnabled ? (<SessionRecordingsPlaylistRedesign {...SCENE_PLAYLIST_LOGIC_PROPS} />) : (- <SessionRecordingsPlaylist {...SCENE_PLAYLIST_LOGIC_PROPS} picksInList={picksInList} />+ <SessionRecordingsPlaylist+ {...SCENE_PLAYLIST_LOGIC_PROPS}+ picksInList={picksInList}+ watchLayout+ />)}</div>) : tab === ReplayTabs.Playlists ? (diff --git a/frontend/src/scenes/session-recordings/components/OverviewGrid.tsx b/frontend/src/scenes/session-recordings/components/OverviewGrid.tsxindex 448478fed1f7..82ea482bf866 100644--- a/frontend/src/scenes/session-recordings/components/OverviewGrid.tsx+++ b/frontend/src/scenes/session-recordings/components/OverviewGrid.tsx@@ -79,7 +79,7 @@ export function OverviewGridItem({return (<div className="group flex flex-1 w-full justify-between items-center deprecated-space-x-4">- <div className={clsx('text-sm', fadeLabel && 'font-light')}>+ <div className={clsx('text-sm shrink-0 truncate max-w-[60%]', fadeLabel && 'font-light')}><Tooltip title={itemKeyTooltip}>{icon} {label}</Tooltip>diff --git a/frontend/src/scenes/session-recordings/components/PaneTabBar.tsx b/frontend/src/scenes/session-recordings/components/PaneTabBar.tsxnew file mode 100644index 000000000000..dc439a72474f--- /dev/null+++ b/frontend/src/scenes/session-recordings/components/PaneTabBar.tsx@@ -0,0 +1,63 @@+import clsx from 'clsx'+import { ReactNode } from 'react'++import { LemonButton } from '@posthog/lemon-ui'++export interface PaneTab<K extends string> {+ key: K+ label: ReactNode+ icon?: ReactNode+ dataAttr: string+ disabledReason?: string+}++export function PaneTabBar<K extends string>({+ tabs,+ activeKey,+ onChange,+ fullWidth = false,+ className,+ children,+}: {+ tabs: PaneTab<K>[]+ activeKey: K+ onChange: (key: K) => void+ fullWidth?: boolean+ className?: string+ children?: ReactNode+}): JSX.Element {+ return (+ <div className={clsx('flex flex-row items-stretch shrink-0 border-b bg-surface-secondary', className)}>+ {tabs.map((tab) => {+ const active = activeKey === tab.key+ return (+ <LemonButton+ key={tab.key}+ noPadding+ active={active}+ onClick={() => onChange(tab.key)}+ disabledReason={tab.disabledReason}+ className={clsx(+ 'rounded-none border-b-2',+ active ? 'border-b-accent bg-surface-primary' : 'border-b-transparent',+ fullWidth && 'flex-auto'+ )}+ data-attr={tab.dataAttr}+ >+ <span+ className={clsx(+ 'flex items-center gap-1.5 px-3 py-1.5 text-xs',+ fullWidth && 'justify-center w-full'+ )}+ >+ {tab.icon && <span className="text-base">{tab.icon}</span>}+ <span className="flex items-center gap-1">{tab.label}</span>+ </span>+ </LemonButton>+ )+ })}+ {!fullWidth && <div className="flex-1" />}+ {children}+ </div>+ )+}diff --git a/frontend/src/scenes/session-recordings/filters/RecordingsUniversalFiltersEmbed.tsx b/frontend/src/scenes/session-recordings/filters/RecordingsUniversalFiltersEmbed.tsxindex 78b761dcff9c..5acd3286894c 100644--- a/frontend/src/scenes/session-recordings/filters/RecordingsUniversalFiltersEmbed.tsx+++ b/frontend/src/scenes/session-recordings/filters/RecordingsUniversalFiltersEmbed.tsx@@ -53,7 +53,7 @@ import { actionsModel } from '~/models/actionsModel'import { cohortsModel } from '~/models/cohortsModel'import { groupsModel } from '~/models/groupsModel'import { AndOrFilterSelect } from '~/queries/nodes/InsightViz/PropertyGroupFilters/AndOrFilterSelect'-import { NodeKind, ProductIntentContext, ProductKey, RecordingsQuery } from '~/queries/schema/schema-general'+import { NodeKind, ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'import {PropertyFilterType,PropertyOperator,@@ -62,8 +62,6 @@ import {UniversalFiltersGroup,} from '~/types'-import { useAttachedContext, useMcpToolApplyBack } from 'products/posthog_ai/frontend/api/logics'-import type { AttachedContextItem } from 'products/posthog_ai/frontend/api/types'import { scannerHandoffFromFilters } from 'products/replay_vision/frontend/replay_scanners/scannerHandoffFromFilters'import { sessionRecordingSavedFiltersLogic } from '../filters/sessionRecordingSavedFiltersLogic'@@ -77,38 +75,9 @@ import { FilterTemplates } from '../templates/FilterTemplates'import { CurrentFilterIndicator } from './CurrentFilterIndicator'import { DurationFilter } from './DurationFilter'import { ProductAnalyticsOverLimitBanner } from './ProductAnalyticsOverLimitBanner'-import {- DEFAULT_RECORDING_FILTERS_ORDER_BY,- DURATION_KEYS,- deriveOperand,- isValidRecordingOrder,- recordingsQueryToUniversalFilters,-} from './recordingsQueryConversions'+import { deriveOperand } from './recordingsQueryConversions'import { SavedFilters } from './SavedFilters'--// Static instruction rendered into the trusted context block — never interpolate user or ingested data.-const RECORDINGS_QUERY_TOOL_CONTEXT_ITEM: AttachedContextItem = {- type: 'instructions',- hidden: true,- value:- 'The user has the session replay list open. When you call query-session-recordings-list, the filters from ' +- 'your query (properties, duration, date range, ordering) are also applied to the open recordings list, so ' +- 'the user sees matching recordings both in this chat and on screen.',-}--// Recording-metric keys of the query's `properties` filters, whose `type: 'recording'` is a zod-// default the agent may omit from its raw args.-const RECORDING_METRIC_KEYS = new Set([- ...DURATION_KEYS,- 'console_error_count',- 'console_log_count',- 'console_warn_count',- 'click_count',- 'keypress_count',- 'activity_score',- 'visited_page',- 'snapshot_source',-])+import { useRecordingFiltersAssist } from './useRecordingFiltersAssist'export const RecordingsUniversalFiltersEmbedButton = ({filters,@@ -127,62 +96,7 @@ export const RecordingsUniversalFiltersEmbedButton = ({const { isFiltersExpanded } = useValues(playlistFiltersLogic)const { setIsFiltersExpanded } = useActions(playlistFiltersLogic)- useAttachedContext([- { type: 'recording_filters', value: JSON.stringify(filters), label: 'Current filters' },- RECORDINGS_QUERY_TOOL_CONTEXT_ITEM,- ...(currentSessionRecordingId- ? [{ type: 'session_recording', key: currentSessionRecordingId, label: 'Current session' } as const]- : []),- ] as AttachedContextItem[])-- const applyFilters = (toolOutput: Record<string, any>): void => {- // Improve type- setFilters(toolOutput.recordings_filters)- setIsFiltersExpanded(true)- }-- // The headless query tool's call input mirrored onto the open list. The input is a complete query:- // every field is applied, with omitted fields set to the query schema's defaults so the list shows- // the same recordings the tool returned. The args are raw agent-sent JSON (never zod-validated), so- // fields are coerced and the recording-metric `type` default is stamped back on before converting to- // the universal filter shape. person_uuid (query-level constraint), after (pagination cursor), and- // limit (the agent's page size, which shouldn't shrink the user's list) have no counterpart in the- // universal filters.- const applyRecordingsQuery = (input: Record<string, any>): void => {- const props = (Array.isArray(input.properties) ? input.properties : []).map((f: Record<string, any>) =>- f && !f.type && RECORDING_METRIC_KEYS.has(f.key) ? { ...f, type: 'recording' } : f- )- // Duration filters have their own control in the universal shape, so the converter expects- // them in `having_predicates` rather than `properties`.- const universal = recordingsQueryToUniversalFilters({- kind: NodeKind.RecordingsQuery,- properties: props.filter((f: Record<string, any>) => !DURATION_KEYS.has(f?.key)),- having_predicates: props.filter((f: Record<string, any>) => DURATION_KEYS.has(f?.key)),- } as RecordingsQuery)- setFilters({- filter_group: universal.filter_group,- duration: universal.duration,- date_from: input.date_from ?? '-3d',- date_to: input.date_to ?? null,- filter_test_accounts: !!input.filter_test_accounts,- order: isValidRecordingOrder(input.order) ? input.order : DEFAULT_RECORDING_FILTERS_ORDER_BY,- order_direction: input.order_direction === 'ASC' ? 'ASC' : 'DESC',- session_ids: Array.isArray(input.session_ids) ? input.session_ids : undefined,- })- setIsFiltersExpanded(true)- }-- useMcpToolApplyBack({- tools: ['query-session-recordings-list'],- targetKey: 'replay-playlist-filters',- onApply: (_event, { innerInput }) => {- if (!innerInput) {- return- }- applyRecordingsQuery(innerInput)- },- })-+ const { applyFilters } = useRecordingFiltersAssist({ filters, setFilters, currentSessionRecordingId })return (<><div className="flex gap-2">@@ -358,7 +272,7 @@ const RecordingsUniversalFilterGroup = ({ pinnedFilters }: { pinnedFilters?: Uni)}-const SaveFiltersModal = ({+export const SaveFiltersModal = ({isOpen,setIsOpen,filters,diff --git a/frontend/src/scenes/session-recordings/filters/sessionRecordingSavedFiltersLogic.test.ts b/frontend/src/scenes/session-recordings/filters/sessionRecordingSavedFiltersLogic.test.tsindex 850c23e718e5..5fade40fc16c 100644--- a/frontend/src/scenes/session-recordings/filters/sessionRecordingSavedFiltersLogic.test.ts+++ b/frontend/src/scenes/session-recordings/filters/sessionRecordingSavedFiltersLogic.test.ts@@ -1,6 +1,8 @@import { router } from 'kea-router'import { expectLogic } from 'kea-test-utils'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { removeProjectIdIfPresent } from 'lib/utils/kea-router'import { sessionRecordingSavedFiltersLogic } from 'scenes/session-recordings/filters/sessionRecordingSavedFiltersLogic'import { playlistFiltersLogic } from 'scenes/session-recordings/playlist/playlistFiltersLogic'@@ -13,6 +15,7 @@ import { ReplayTabs } from '~/types'describe('sessionRecordingSavedFiltersLogic', () => {let logic: ReturnType<typeof sessionRecordingSavedFiltersLogic.build>let savedFiltersRequestCount: number+ let savedFilterRequestCount: numberconst savedFilter = {id: 'abc',short_id: 'short_abc',@@ -21,18 +24,30 @@ describe('sessionRecordingSavedFiltersLogic', () => {filters: { events: [], date_from: '2022-10-18' },}+ let deleteSucceeds: boolean+beforeEach(() => {savedFiltersRequestCount = 0+ savedFilterRequestCount = 0+ deleteSucceeds = trueuseMocks({get: {'/api/projects/:team/session_recording_playlists': () => {savedFiltersRequestCount += 1return { results: [], count: 0 }},- '/api/projects/:team/session_recording_playlists/:id': savedFilter,+ '/api/projects/:team/session_recording_playlists/:id': () => {+ savedFilterRequestCount += 1+ return savedFilter+ },+ },+ patch: {+ '/api/projects/:team/session_recording_playlists/:id': () =>+ deleteSucceeds ? [200, savedFilter] : [500, { detail: 'nope' }],},})initKeaTests()+ featureFlagLogic.mount()logic = sessionRecordingSavedFiltersLogic()})@@ -87,6 +102,73 @@ describe('sessionRecordingSavedFiltersLogic', () => {expect(removeProjectIdIfPresent(router.values.location.pathname)).toBe(urls.replay())})+ it('applies a saved filter from a URL that already carries filters without redirecting', async () => {+ router.actions.push(urls.replay(ReplayTabs.Home), {+ savedFilterId: savedFilter.short_id,+ filters: { date_from: '-7d' },+ })++ logic.mount()++ await expectLogic(logic).toDispatchActions(['setAppliedSavedFilter'])+ expect(router.values.searchParams).toEqual({+ savedFilterId: savedFilter.short_id,+ filters: { date_from: '-7d' },+ })+ })++ it('fetches a saved filter once while the list rewrites the URL', async () => {+ router.actions.push(urls.replay(ReplayTabs.Home), { savedFilterId: savedFilter.short_id })+ logic.mount()+ router.actions.replace(urls.replay(ReplayTabs.Home), {+ savedFilterId: savedFilter.short_id,+ filters: { date_from: '-7d' },+ })++ await expectLogic(logic).toDispatchActions(['setAppliedSavedFilter'])+ expect(savedFilterRequestCount).toBe(1)+ })++ it('applies a saved filter link while already open', async () => {+ router.actions.push(urls.replay(ReplayTabs.Home))+ logic.mount()++ router.actions.push(urls.replay(ReplayTabs.Home), { savedFilterId: savedFilter.short_id })++ await expectLogic(logic).toDispatchActions(['setAppliedSavedFilter'])+ expect(logic.values.appliedSavedFilter).toEqual(savedFilter)+ })++ it.each([+ ['the replay home in the new layout', urls.replay(ReplayTabs.Home), 'compact', savedFilter.short_id],+ ['the replay home in the classic layout', urls.replay(ReplayTabs.Home), 'control', undefined],+ ['another page', urls.replayVision(), 'compact', undefined],+ ])('writes the applied saved filter into the URL of %s', (_, path, arm, expected) => {+ featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.REPLAY_WATCH_LAYOUT]: arm })+ router.actions.push(path)+ logic.mount()++ logic.actions.setAppliedSavedFilter(savedFilter as any)+ expect(router.values.searchParams.savedFilterId).toEqual(expected)++ logic.actions.setAppliedSavedFilter(null)+ expect(router.values.searchParams.savedFilterId).toBeUndefined()+ })++ it.each([+ ['clears the applied filter when its delete succeeds', true, null],+ ['keeps the applied filter when its delete fails', false, savedFilter],+ ])('%s', async (_, succeeds, expected) => {+ deleteSucceeds = succeeds+ logic.mount()+ logic.actions.setAppliedSavedFilter(savedFilter as any)++ logic.actions.deletePlaylist(savedFilter as any)+ await expectLogic(logic).toFinishAllListeners()++ expect(logic.values.appliedSavedFilter).toEqual(expected)+ })+it('does not redirect a saved filter load that resolves after the user navigated away', async () => {router.actions.push(urls.replay(ReplayTabs.Home), { savedFilterId: savedFilter.short_id })diff --git a/frontend/src/scenes/session-recordings/filters/sessionRecordingSavedFiltersLogic.ts b/frontend/src/scenes/session-recordings/filters/sessionRecordingSavedFiltersLogic.tsindex c4f3b0beae0d..27563607f385 100644--- a/frontend/src/scenes/session-recordings/filters/sessionRecordingSavedFiltersLogic.ts+++ b/frontend/src/scenes/session-recordings/filters/sessionRecordingSavedFiltersLogic.ts@@ -1,24 +1,31 @@import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, reducers, selectors } from 'kea'import { loaders } from 'kea-loaders'-import { router } from 'kea-router'+import { actionToUrl, router, urlToAction } from 'kea-router'import api from 'lib/api'import { PaginationManual } from 'lib/lemon-ui/PaginationControl'import { removeProjectIdIfPresent } from 'lib/utils/kea-router'import { objectClean } from 'lib/utils/objects'import { toParams } from 'lib/utils/url'+import { teamLogic } from 'scenes/teamLogic'import { urls } from 'scenes/urls'import {+ RecordingUniversalFilters,ReplayTabs,SavedSessionRecordingPlaylistsFilters,SavedSessionRecordingPlaylistsResult,SessionRecordingPlaylistType,} from '~/types'+import { sessionRecordingPlaylistsRetrieve } from 'products/replay/frontend/generated/api'++import { playerSettingsLogic } from '../player/playerSettingsLogic'import { playlistFiltersLogic } from '../playlist/playlistFiltersLogic'-import { deletePlaylist, stripSessionIds } from '../playlist/playlistUtils'-import { asUniversalFilters } from '../playlist/sessionRecordingsPlaylistLogic'+import { comparableRecordingFilters, deletePlaylist, stripSessionIds } from '../playlist/playlistUtils'+import { isNewReplayLayout } from '../playlist/replayLayout'+import type { ReplayLayout } from '../playlist/replayLayout'+import { asUniversalFilters, getDefaultFilters } from '../playlist/sessionRecordingsPlaylistLogic'export const PLAYLISTS_PER_PAGE = 30@@ -30,8 +37,11 @@ export const DEFAULT_PLAYLIST_FILTERS = {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface sessionRecordingSavedFiltersLogicValues {+ replayLayout: ReplayLayout // playerSettingsLogicisFiltersExpanded: boolean // playlistFiltersLogic+ currentProjectId: number | string // teamLogicappliedSavedFilter: SessionRecordingPlaylistType | null+ appliedSavedFilterFilters: RecordingUniversalFilters | nullfilters: Record<string, any> | SavedSessionRecordingPlaylistsFiltershasLoadedSavedFilters: booleanloadSavedFiltersFailed: boolean@@ -152,6 +162,9 @@ export interface sessionRecordingSavedFiltersLogicActions {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface sessionRecordingSavedFiltersLogicMeta {__keaTypeGenInternalSelectorTypes: {+ appliedSavedFilterFilters: (+ appliedSavedFilter: SessionRecordingPlaylistType | null+ ) => RecordingUniversalFilters | nullpaginationSavedFilters: (filters: Record<string, any> | SavedSessionRecordingPlaylistsFilters,savedFilters: SavedSessionRecordingPlaylistsResult@@ -169,7 +182,14 @@ export type sessionRecordingSavedFiltersLogicType = MakeLogicType<export const sessionRecordingSavedFiltersLogic = kea<sessionRecordingSavedFiltersLogicType>([path(() => ['scenes', 'session-recordings', 'filters', 'sessionRecordingSavedFiltersLogic']),connect(() => ({- values: [playlistFiltersLogic, ['isFiltersExpanded']],+ values: [+ playlistFiltersLogic,+ ['isFiltersExpanded'],+ playerSettingsLogic,+ ['replayLayout'],+ teamLogic,+ ['currentProjectId'],+ ],actions: [playlistFiltersLogic, ['setIsFiltersExpanded']],})),actions(() => ({@@ -267,19 +287,32 @@ export const sessionRecordingSavedFiltersLogic = kea<sessionRecordingSavedFilterreturn { ...values.playlists, results: [...values.playlists.results] }},deletePlaylist: async ({ playlist }) => {- await deletePlaylist(playlist, () => actions.loadSavedFilters())+ const wasApplied = values.appliedSavedFilter?.short_id === playlist.short_id+ await deletePlaylist(playlist, (undo) => {+ if (wasApplied) {+ actions.setAppliedSavedFilter(undo ? playlist : null)+ }+ actions.loadSavedFilters()+ })values.playlists.results = values.playlists.results.filter((x) => x.short_id !== playlist.short_id)actions.loadSavedFilters()return values.playlists},},})),- listeners(({ actions, values }) => ({+ listeners(({ actions, values, cache }) => ({setIsFiltersExpanded: ({ isFiltersExpanded }) => {if (isFiltersExpanded) {actions.loadSavedFiltersIfNeeded()}},+ loadSavedFiltersSuccess: ({ savedFilters }) => {+ const applied = values.appliedSavedFilter+ const fresh = applied && savedFilters.results.find((f) => f.short_id === applied.short_id)+ if (fresh && fresh !== applied) {+ actions.setAppliedSavedFilter(fresh)+ }+ },loadSavedFiltersIfNeeded: () => {if (!values.hasLoadedSavedFilters && !values.savedFiltersLoading) {actions.loadSavedFilters()@@ -290,23 +323,60 @@ export const sessionRecordingSavedFiltersLogic = kea<sessionRecordingSavedFilter},checkForSavedFilterRedirect: async () => {//If you want to load a saved filter via GET param, you can do it like this: ?savedFilterId=bndnfkxL- const { savedFilterId } = router.values.searchParams- if (savedFilterId) {+ const { savedFilterId, filters } = router.values.searchParams+ // The list rewrites the URL while the fetch is out.+ if (savedFilterId && cache.loadingSavedFilterId !== savedFilterId) {+ cache.loadingSavedFilterId = savedFilterId// Capture the route before the fetch. The load can resolve after the user has already// navigated elsewhere (e.g. to Replay vision) - only redirect if they are still here.const pathnameBeforeLoad = removeProjectIdIfPresent(router.values.location.pathname)- const savedFilter = await api.recordings.getPlaylist(savedFilterId)+ const savedFilter = (await sessionRecordingPlaylistsRetrieve(+ String(values.currentProjectId),+ savedFilterId+ ).finally(() => {+ cache.loadingSavedFilterId = null+ })) as unknown as SessionRecordingPlaylistTypeif (savedFilter && removeProjectIdIfPresent(router.values.location.pathname) === pathnameBeforeLoad) {- router.actions.push(- urls.replay(ReplayTabs.Home, stripSessionIds(asUniversalFilters(savedFilter.filters)))- )+ if (!filters) {+ router.actions.push(+ urls.replay(ReplayTabs.Home, stripSessionIds(asUniversalFilters(savedFilter.filters)))+ )+ }actions.setAppliedSavedFilter(savedFilter)}}},})),+ actionToUrl(({ values }) => ({+ setAppliedSavedFilter: ({ appliedSavedFilter }) => {+ const { pathname, searchParams, hashParams } = router.values.currentLocation+ const savedFilterId = appliedSavedFilter?.short_id+ if (+ !isNewReplayLayout(values.replayLayout) ||+ removeProjectIdIfPresent(pathname) !== urls.replay(ReplayTabs.Home) ||+ searchParams.savedFilterId === savedFilterId+ ) {+ return+ }+ return [pathname, { ...searchParams, savedFilterId }, hashParams, { replace: true }]+ },+ })),+ urlToAction(({ actions, values }) => ({+ [urls.replay(ReplayTabs.Home)]: (_, { savedFilterId }) => {+ if (savedFilterId && savedFilterId !== values.appliedSavedFilter?.short_id) {+ actions.checkForSavedFilterRedirect()+ }+ },+ })),selectors(({ actions }) => ({+ appliedSavedFilterFilters: [+ (s) => [s.appliedSavedFilter],+ (appliedSavedFilter: SessionRecordingPlaylistType | null): RecordingUniversalFilters | null => {+ const universal = appliedSavedFilter ? asUniversalFilters(appliedSavedFilter.filters) : undefined+ return universal ? comparableRecordingFilters({ ...getDefaultFilters(), ...universal }) : null+ },+ ],paginationSavedFilters: [(s) => [s.filters, s.savedFilters],(@@ -342,6 +412,5 @@ export const sessionRecordingSavedFiltersLogic = kea<sessionRecordingSavedFilterif (values.isFiltersExpanded) {actions.loadSavedFiltersIfNeeded()}- actions.checkForSavedFilterRedirect()}),])diff --git a/frontend/src/scenes/session-recordings/filters/useRecordingFiltersAssist.ts b/frontend/src/scenes/session-recordings/filters/useRecordingFiltersAssist.tsnew file mode 100644index 000000000000..3695658edbf3--- /dev/null+++ b/frontend/src/scenes/session-recordings/filters/useRecordingFiltersAssist.ts@@ -0,0 +1,113 @@+import { useActions } from 'kea'++import { playlistFiltersLogic } from 'scenes/session-recordings/playlist/playlistFiltersLogic'++import { NodeKind, RecordingsQuery } from '~/queries/schema/schema-general'+import { RecordingUniversalFilters } from '~/types'++import { useAttachedContext, useMcpToolApplyBack } from 'products/posthog_ai/frontend/api/logics'+import type { AttachedContextItem } from 'products/posthog_ai/frontend/api/types'++import {+ DEFAULT_RECORDING_FILTERS_ORDER_BY,+ DURATION_KEYS,+ isValidRecordingOrder,+ recordingsQueryToUniversalFilters,+} from './recordingsQueryConversions'++// Static instruction rendered into the trusted context block. Never interpolate user or ingested data.+const RECORDINGS_QUERY_TOOL_CONTEXT_ITEM: AttachedContextItem = {+ type: 'instructions',+ hidden: true,+ value:+ 'The user has the session replay list open. When you call query-session-recordings-list, the filters from ' ++ 'your query (properties, duration, date range, ordering) are also applied to the open recordings list, so ' ++ 'the user sees matching recordings both in this chat and on screen.',+}++// Recording-metric keys of the query's `properties` filters, whose `type: 'recording'` is a zod+// default the agent may omit from its raw args.+const RECORDING_METRIC_KEYS = new Set([+ ...DURATION_KEYS,+ 'console_error_count',+ 'console_log_count',+ 'console_warn_count',+ 'click_count',+ 'keypress_count',+ 'activity_score',+ 'visited_page',+ 'snapshot_source',+])++/**+ * Attaches the open list's filters to PostHog AI and mirrors the filters it produces back onto the list, for+ * whichever header holds the filter button.+ */+export function useRecordingFiltersAssist({+ filters,+ setFilters,+ currentSessionRecordingId,+}: {+ filters: RecordingUniversalFilters+ setFilters: (filters: Partial<RecordingUniversalFilters>) => void+ currentSessionRecordingId?: string+}): { applyFilters: (toolOutput: Record<string, any>) => void } {+ const { setIsFiltersExpanded } = useActions(playlistFiltersLogic)+ useAttachedContext([+ { type: 'recording_filters', value: JSON.stringify(filters), label: 'Current filters' },+ RECORDINGS_QUERY_TOOL_CONTEXT_ITEM,+ ...(currentSessionRecordingId+ ? [{ type: 'session_recording', key: currentSessionRecordingId, label: 'Current session' } as const]+ : []),+ ] as AttachedContextItem[])++ const applyFilters = (toolOutput: Record<string, any>): void => {+ // Improve type+ setFilters(toolOutput.recordings_filters)+ setIsFiltersExpanded(true)+ }++ // The headless query tool's call input mirrored onto the open list. The input is a complete query:+ // every field is applied, with omitted fields set to the query schema's defaults so the list shows+ // the same recordings the tool returned. The args are raw agent-sent JSON (never zod-validated), so+ // fields are coerced and the recording-metric `type` default is stamped back on before converting to+ // the universal filter shape. person_uuid (query-level constraint), after (pagination cursor), and+ // limit (the agent's page size, which shouldn't shrink the user's list) have no counterpart in the+ // universal filters.+ const applyRecordingsQuery = (input: Record<string, any>): void => {+ const props = (Array.isArray(input.properties) ? input.properties : []).map((f: Record<string, any>) =>+ f && !f.type && RECORDING_METRIC_KEYS.has(f.key) ? { ...f, type: 'recording' } : f+ )+ // Duration filters have their own control in the universal shape, so the converter expects+ // them in `having_predicates` rather than `properties`.+ const universal = recordingsQueryToUniversalFilters({+ kind: NodeKind.RecordingsQuery,+ properties: props.filter((f: Record<string, any>) => !DURATION_KEYS.has(f?.key)),+ having_predicates: props.filter((f: Record<string, any>) => DURATION_KEYS.has(f?.key)),+ } as RecordingsQuery)+ setFilters({+ filter_group: universal.filter_group,+ duration: universal.duration,+ date_from: input.date_from ?? '-3d',+ date_to: input.date_to ?? null,+ filter_test_accounts: !!input.filter_test_accounts,+ order: isValidRecordingOrder(input.order) ? input.order : DEFAULT_RECORDING_FILTERS_ORDER_BY,+ order_direction: input.order_direction === 'ASC' ? 'ASC' : 'DESC',+ session_ids: Array.isArray(input.session_ids) ? input.session_ids : undefined,+ })+ setIsFiltersExpanded(true)+ }++ useMcpToolApplyBack({+ tools: ['query-session-recordings-list'],+ targetKey: 'replay-playlist-filters',+ onApply: (_event, { innerInput }) => {+ if (!innerInput) {+ return+ }+ applyRecordingsQuery(innerInput)+ },+ })++ return { applyFilters }+}diff --git a/frontend/src/scenes/session-recordings/player/PlayerSidebar.tsx b/frontend/src/scenes/session-recordings/player/PlayerSidebar.tsxindex 939c5d85ba4b..b6acdf40d563 100644--- a/frontend/src/scenes/session-recordings/player/PlayerSidebar.tsx+++ b/frontend/src/scenes/session-recordings/player/PlayerSidebar.tsx@@ -20,14 +20,31 @@ import { playerSettingsLogic } from './playerSettingsLogic'import { sessionRecordingPlayerLogic } from './sessionRecordingPlayerLogic'import { playerSidebarLogic } from './sidebar/playerSidebarLogic'import { PlayerSidebarTab } from './sidebar/PlayerSidebarTab'--export function PlayerSidebar(): JSX.Element {+import { DebugTabBar } from './watch/DebugTabBar'++export function PlayerSidebar({+ tabs,+ stacking,+ onToggleStacking,+}: {+ tabs?: SessionRecordingSidebarTab[]+ stacking?: SessionRecordingSidebarStacking+ onToggleStacking?: () => void+} = {}): JSX.Element {const ref = useRef<HTMLDivElement>(null)const { activeTab } = useValues(playerSidebarLogic)const { setTab } = useActions(playerSidebarLogic)- const { sidebarOpen, preferredSidebarStacking, isVerticallyStacked } = useValues(playerSettingsLogic)- const { setSidebarOpen, setPreferredSidebarStacking } = useActions(playerSettingsLogic)+ const {+ sidebarOpen,+ debugMode,+ preferredSidebarStacking,+ isVerticallyStacked: preferredVertical,+ } = useValues(playerSettingsLogic)+ const isVerticallyStacked = stacking ? stacking === SessionRecordingSidebarStacking.Vertical : preferredVertical+ const { setSidebarOpen, setDebugMode, setPreferredSidebarStacking } = useActions(playerSettingsLogic)+ const open = tabs ? debugMode : sidebarOpen+ const setOpen = tabs ? setDebugMode : setSidebarOpenconst { getIntegrationsByKind } = useValues(integrationsLogic)const { sessionPlayerMetaData, logicProps } = useValues(sessionRecordingPlayerLogic)const { featureFlags } = useValues(featureFlagLogic)@@ -41,23 +58,26 @@ export function PlayerSidebar(): JSX.Element {persistPrefix: '2025-12-29',closeThreshold: 100,placement: isVerticallyStacked ? 'top' : 'left',- onToggleClosed: (shouldBeClosed) => setSidebarOpen(!shouldBeClosed),+ onToggleClosed: (shouldBeClosed) => setOpen(!shouldBeClosed),}const { desiredSize } = useValues(resizerLogic(resizerLogicProps))- const sidebarTabs = [- SessionRecordingSidebarTab.OVERVIEW,- SessionRecordingSidebarTab.INSPECTOR,- SessionRecordingSidebarTab.NETWORK_WATERFALL,- ]+ const debugTab = tabs?.includes(activeTab) ? activeTab : SessionRecordingSidebarTab.INSPECTOR+ const sidebarTabs = tabs+ ? [...tabs]+ : [+ SessionRecordingSidebarTab.OVERVIEW,+ SessionRecordingSidebarTab.INSPECTOR,+ SessionRecordingSidebarTab.NETWORK_WATERFALL,+ ]- if (visionSurfaceShown(logicProps)) {+ if (!tabs && visionSurfaceShown(logicProps)) {sidebarTabs.push(SessionRecordingSidebarTab.OBSERVATIONS)}// Show the person's other recordings once we know who they are- if (featureFlags[FEATURE_FLAGS.REPLAY_PLAYER_PERSON_SESSIONS_TAB] && sessionPlayerMetaData?.person) {+ if (!tabs && featureFlags[FEATURE_FLAGS.REPLAY_PLAYER_PERSON_SESSIONS_TAB] && sessionPlayerMetaData?.person) {sidebarTabs.push(SessionRecordingSidebarTab.SESSIONS)}@@ -65,20 +85,17 @@ export function PlayerSidebar(): JSX.Element {const sessionReplayIntegrations = getIntegrationsByKind(['linear', 'github', 'gitlab', 'jira'])const externalReferences = sessionPlayerMetaData?.external_references ?? []- if (sessionReplayIntegrations.length > 0 || externalReferences.length > 0) {+ if (!tabs && (sessionReplayIntegrations.length > 0 || externalReferences.length > 0)) {sidebarTabs.push(SessionRecordingSidebarTab.LINKED_ISSUES)}return (<div- className={clsx(- 'SessionRecordingPlayer__sidebar',- !sidebarOpen && 'SessionRecordingPlayer__sidebar--collapsed'- )}+ className={clsx('SessionRecordingPlayer__sidebar', !open && 'SessionRecordingPlayer__sidebar--collapsed')}ref={ref}// eslint-disable-next-line react/forbid-dom-propsstyle={- !sidebarOpen+ !open? {}: isVerticallyStacked? { height: desiredSize ?? undefined, minHeight: 210 }@@ -87,12 +104,41 @@ export function PlayerSidebar(): JSX.Element {><ResizerlogicKey={logicKey}- placement={sidebarOpen && isVerticallyStacked ? 'top' : 'left'}+ placement={open && isVerticallyStacked ? 'top' : 'left'}containerRef={ref}closeThreshold={100}offset="0.25rem"/>- {sidebarOpen && (+ {open && tabs && (+ <div className="SessionRecordingPlayer__sidebar__content">+ <div className="flex flex-col flex-1 min-h-0 h-full">+ <DebugTabBar tabs={sidebarTabs} activeTab={debugTab} onChange={setTab}>+ <LemonButton+ data-attr="player-sidebar-dock-toggle"+ size="small"+ icon={<IconBottomPanel />}+ onClick={() => onToggleStacking?.()}+ tooltip="Dock to bottom"+ aria-label="Dock to bottom"+ className="rounded-none"+ />+ <LemonButton+ data-attr="player-sidebar-close"+ size="small"+ icon={<IconX />}+ onClick={() => setDebugMode(false)}+ tooltip="Close sidebar"+ aria-label="Close sidebar"+ className="rounded-none"+ />+ </DebugTabBar>+ <div className="flex flex-col flex-1 min-w-0 overflow-hidden">+ <PlayerSidebarTab tab={debugTab} />+ </div>+ </div>+ </div>+ )}+ {open && !tabs && (<div className="SessionRecordingPlayer__sidebar__content"><div className="flex bg-surface-primary pt-[1px]"><div className="w-2.5 border-b shrink-0" />diff --git a/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.scss b/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.scssindex ae84fa9b36b6..23e62949d3fd 100644--- a/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.scss+++ b/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.scss@@ -35,6 +35,40 @@}}+ // The watch layout stacks the player over a scrolling panel. The player keeps a fixed share of the viewport.+ &--watch {+ flex-direction: column;+ overflow-y: auto;++ .SessionRecordingPlayerWrapper__column {+ display: flex;+ flex: 1;+ flex-direction: column;+ min-width: 0;+ }++ &-right-dock {+ flex-direction: row;+ overflow-y: hidden;++ .SessionRecordingPlayerWrapper__column {+ min-height: 0;+ overflow-y: auto;+ }+ }++ .SessionRecordingPlayerWrapper__player {+ display: flex;+ flex: none;+ height: clamp(24rem, 60vh, 48rem);++ &--fullscreen {+ flex: 1;+ height: auto;+ }+ }+ }+&--stacked-vertically {flex-direction: column;diff --git a/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.tsx b/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.tsxindex 36abda76a3bf..8a46cc57554e 100644--- a/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.tsx+++ b/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.tsx@@ -1,14 +1,17 @@import './SessionRecordingPlayer.scss'import clsx from 'clsx'-import { BindLogic, useValues } from 'kea'+import { BindLogic, useActions, useValues } from 'kea'import { useRef } from 'react'import { FEATURE_FLAGS } from 'lib/constants'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { playerUsesWatchLayout } from 'scenes/session-recordings/playlist/replayLayout'import { MatchingEventsMatchType } from 'scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic'import { userLogic } from 'scenes/userLogic'+import { SessionRecordingSidebarStacking } from '~/types'+import { SummarizeRecordingBar } from 'products/replay_vision/frontend/components/SummarizeRecordingBar'import { visionSurfaceShown } from 'products/replay_vision/frontend/utils/visionSurface'@@ -21,6 +24,8 @@ import {SessionRecordingPlayerMode,sessionRecordingPlayerLogic,} from './sessionRecordingPlayerLogic'+import { DEBUG_TAB_KEYS } from './watch/DebugTabBar'+import { WatchPanel } from './watch/WatchPanel'export { createPlaybackSpeedKey } from './PurePlayer'@@ -52,6 +57,7 @@ export function SessionRecordingPlayer(props: SessionRecordingPlayerProps): JSX.playNextRecording,skipToFirstMatchingEvent,exposureSkipExperimentId,+ watchLayout,} = propsconst playerRef = useRef<HTMLDivElement>(null)@@ -74,6 +80,7 @@ export function SessionRecordingPlayer(props: SessionRecordingPlayerProps): JSX.playNextRecording,skipToFirstMatchingEvent,exposureSkipExperimentId,+ watchLayout,}return (@@ -99,11 +106,45 @@ function SessionRecordingPlayerInternal({withSidebar: booleanplayerRef: React.RefObject<HTMLDivElement>}): JSX.Element {- const { isVerticallyStacked, sidebarOpen } = useValues(playerSettingsLogic)- const { logicProps } = useValues(sessionRecordingPlayerLogic)+ const { isVerticallyStacked, sidebarOpen, debugMode, replayLayout, watchDebugDock } = useValues(playerSettingsLogic)+ const { setWatchDebugDock } = useActions(playerSettingsLogic)+ const { logicProps, isFullScreen } = useValues(sessionRecordingPlayerLogic)const { featureFlags } = useValues(featureFlagLogic)const { user } = useValues(userLogic)const showDebugReplayButton = featureFlags[FEATURE_FLAGS.REPLAY_DEBUG_WITH_AI] || user?.is_impersonated+ // The player modal covers the side panel, so the conversation would open out of sight.+ const debugReplayAction = showDebugReplayButton && logicProps.playerKey !== 'modal' ? <DebugReplayButton /> : null++ if (playerUsesWatchLayout(replayLayout, logicProps)) {+ const rightDock = debugMode && watchDebugDock === 'right' && !isFullScreen+ return (+ <div+ ref={playerRef}+ className={clsx('SessionRecordingPlayerWrapper SessionRecordingPlayerWrapper--watch', {+ 'SessionRecordingPlayerWrapper--watch-right-dock': rightDock,+ })}+ >+ <div className="SessionRecordingPlayerWrapper__column">+ <div+ className={clsx(+ 'SessionRecordingPlayerWrapper__player',+ isFullScreen && 'SessionRecordingPlayerWrapper__player--fullscreen'+ )}+ >+ <PurePlayer noMeta={noMeta} noBorder={noBorder} />+ </div>+ {!isFullScreen && <WatchPanel summaryActions={debugReplayAction} />}+ </div>+ {rightDock && (+ <PlayerSidebar+ tabs={DEBUG_TAB_KEYS}+ stacking={SessionRecordingSidebarStacking.Horizontal}+ onToggleStacking={() => setWatchDebugDock('bottom')}+ />+ )}+ </div>+ )+ }return (<div@@ -114,14 +155,7 @@ function SessionRecordingPlayerInternal({><div className="relative flex flex-col flex-1 min-w-0 min-h-0"><PurePlayer noMeta={noMeta} noBorder={noBorder} />- {visionSurfaceShown(logicProps) && (- <SummarizeRecordingBar- // The player modal covers the side panel, so the conversation would open out of sight.- extraActions={- showDebugReplayButton && logicProps.playerKey !== 'modal' ? <DebugReplayButton /> : null- }- />- )}+ {visionSurfaceShown(logicProps) && <SummarizeRecordingBar extraActions={debugReplayAction} />}</div>{withSidebar && <PlayerSidebar />}</div>diff --git a/frontend/src/scenes/session-recordings/player/controller/UserActivity.tsx b/frontend/src/scenes/session-recordings/player/controller/UserActivity.tsxindex cd00ecc098fc..f04fdfc3e6f9 100644--- a/frontend/src/scenes/session-recordings/player/controller/UserActivity.tsx+++ b/frontend/src/scenes/session-recordings/player/controller/UserActivity.tsx@@ -3,18 +3,19 @@ import { useValues } from 'kea'import { MutableRefObject, useMemo, useRef } from 'react'import { cn } from 'lib/utils/css-classes'+import { playerUsesWatchLayout } from 'scenes/session-recordings/playlist/replayLayout'import useIsHovering from '~/lib/hooks/useIsHovering'+import { playerSettingsLogic } from '../playerSettingsLogic'import { sessionRecordingPlayerLogic } from '../sessionRecordingPlayerLogic'--interface ActivityPoint {- x: number- y: number-}+import { ActivityPoint, activityAreaPath } from './activityCurvePath'export function UserActivity({ hoverRef }: { hoverRef: MutableRefObject<HTMLDivElement | null> }): JSX.Element {- const { activityPerSecond } = useValues(sessionRecordingPlayerLogic)+ const { activityPerSecond, logicProps } = useValues(sessionRecordingPlayerLogic)+ const { replayLayout } = useValues(playerSettingsLogic)+ // The watch layout keeps the curve on screen. The classic seekbar reveals it on hover.+ const watchLayout = playerUsesWatchLayout(replayLayout, logicProps)const seekBarRef = useRef<HTMLDivElement | null>(null)const [width, height] = useSize(seekBarRef)@@ -35,7 +36,7 @@ export function UserActivity({ hoverRef }: { hoverRef: MutableRefObject<HTMLDivEclassName={cn('absolute bottom-0 w-full bg-gradient-to-t from-surface-primary via-surface-primary to-transparent from-0% via-96% to-100% transition-opacity duration-300',{- 'opacity-0': !isHovering,+ 'opacity-0': !isHovering && !watchLayout,})}ref={seekBarRef}@@ -45,16 +46,7 @@ export function UserActivity({ hoverRef }: { hoverRef: MutableRefObject<HTMLDivE><svg width="100%" height="100%" preserveAspectRatio="none"><path- d={- points.length- ? `- M 0,${height}- ${points.map((point) => `L ${point.x},${point.y}`).join(' ')}- L ${width},${height}- Z- `- : ''- }+ d={activityAreaPath(points, width, height, watchLayout)}fill="var(--color-bg-fill-highlight-200)"stroke="none"/>diff --git a/frontend/src/scenes/session-recordings/player/controller/activityCurvePath.test.ts b/frontend/src/scenes/session-recordings/player/controller/activityCurvePath.test.tsnew file mode 100644index 000000000000..741b9323478e--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/controller/activityCurvePath.test.ts@@ -0,0 +1,22 @@+import { activityAreaPath } from './activityCurvePath'++describe('activityAreaPath', () => {+ const points = [+ { x: 0, y: 10 },+ { x: 5, y: 2 },+ { x: 10, y: 8 },+ ]++ it.each([+ { name: 'no points', input: [], smooth: true, expected: /^$/ },+ { name: 'straight segments', input: points, smooth: false, expected: /^M 0,10 L 0,10 L 5,2 L 10,8 L 10,10 Z$/ },+ {+ name: 'a smooth curve through the same points',+ input: points,+ smooth: true,+ expected: /^M 0,10 L 0,10 C .* 5,2 C .* 10,8 L 10,10 Z$/,+ },+ ])('draws $name', ({ input, smooth, expected }) => {+ expect(activityAreaPath(input, 10, 10, smooth)).toMatch(expected)+ })+})diff --git a/frontend/src/scenes/session-recordings/player/controller/activityCurvePath.ts b/frontend/src/scenes/session-recordings/player/controller/activityCurvePath.tsnew file mode 100644index 000000000000..cff19c253382--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/controller/activityCurvePath.ts@@ -0,0 +1,34 @@+export interface ActivityPoint {+ x: number+ y: number+}++/**+ * The SVG path of an activity curve closed along the bottom edge, so it fills as an area. `smooth` joins the points+ * with a Catmull-Rom spline rendered as cubic Béziers. Otherwise they are joined with straight segments.+ */+export function activityAreaPath(points: ActivityPoint[], width: number, height: number, smooth: boolean): string {+ if (points.length === 0) {+ return ''+ }+ const segments: string[] = [`M 0,${height}`, `L ${points[0].x},${points[0].y}`]+ if (smooth && points.length > 2) {+ for (let i = 0; i < points.length - 1; i++) {+ const p0 = points[Math.max(i - 1, 0)]+ const p1 = points[i]+ const p2 = points[i + 1]+ const p3 = points[Math.min(i + 2, points.length - 1)]+ const c1x = p1.x + (p2.x - p0.x) / 6+ const c1y = p1.y + (p2.y - p0.y) / 6+ const c2x = p2.x - (p3.x - p1.x) / 6+ const c2y = p2.y - (p3.y - p1.y) / 6+ segments.push(`C ${c1x},${c1y} ${c2x},${c2y} ${p2.x},${p2.y}`)+ }+ } else {+ for (const point of points.slice(1)) {+ segments.push(`L ${point.x},${point.y}`)+ }+ }+ segments.push(`L ${width},${height}`, 'Z')+ return segments.join(' ')+}diff --git a/frontend/src/scenes/session-recordings/player/player-meta/PlayerMetaBar.tsx b/frontend/src/scenes/session-recordings/player/player-meta/PlayerMetaBar.tsxindex 31d6542501c8..a2634fc6f647 100644--- a/frontend/src/scenes/session-recordings/player/player-meta/PlayerMetaBar.tsx+++ b/frontend/src/scenes/session-recordings/player/player-meta/PlayerMetaBar.tsx@@ -1,8 +1,17 @@+import { useValues } from 'kea'++import { playerUsesWatchLayout } from 'scenes/session-recordings/playlist/replayLayout'++import { playerSettingsLogic } from '../playerSettingsLogic'+import { sessionRecordingPlayerLogic } from '../sessionRecordingPlayerLogic'+import { PlayerModeBar } from '../watch/PlayerModeBar'import { PlayerMeta } from './PlayerMeta'import { useReportLowTtlViewed } from './PlayerMetaTopSettings'export function PlayerMetaBar(): JSX.Element {useReportLowTtlViewed()+ const { replayLayout } = useValues(playerSettingsLogic)+ const { logicProps } = useValues(sessionRecordingPlayerLogic)- return <PlayerMeta />+ return playerUsesWatchLayout(replayLayout, logicProps) ? <PlayerModeBar /> : <PlayerMeta />}diff --git a/frontend/src/scenes/session-recordings/player/player-meta/PlayerMetaExperimentTags.tsx b/frontend/src/scenes/session-recordings/player/player-meta/PlayerMetaExperimentTags.tsxindex 47d618d9a655..a68cf5467fa0 100644--- a/frontend/src/scenes/session-recordings/player/player-meta/PlayerMetaExperimentTags.tsx+++ b/frontend/src/scenes/session-recordings/player/player-meta/PlayerMetaExperimentTags.tsx@@ -4,6 +4,7 @@ import { IconFlask } from '@posthog/icons'import { LemonTag } from '@posthog/lemon-ui'import { Tooltip } from 'lib/lemon-ui/Tooltip'+import { playerUsesWatchLayout } from 'scenes/session-recordings/playlist/replayLayout'import { SessionRecordingSidebarTab } from '~/types'@@ -22,7 +23,8 @@ export function PlayerMetaExperimentTags(): JSX.Element | null {sessionRecordingExperimentContextLogic({ sessionRecordingId: logicProps.sessionRecordingId }))const { setTab } = useActions(playerSidebarLogic)- const { setSidebarOpen } = useActions(playerSettingsLogic)+ const { setSidebarOpen, toggleWatchPanelSection } = useActions(playerSettingsLogic)+ const { replayLayout, watchPanelOpenSections } = useValues(playerSettingsLogic)// Only surface the chip when something experiment-related happened *in this recording*.// Enrollments without an in-session exposure event have nothing visible to watch, so they@@ -32,6 +34,13 @@ export function PlayerMetaExperimentTags(): JSX.Element | null {}const openOverview = (): void => {+ // In the watch layout the overview is a disclosure under the player, and the sidebar state means Debug mode.+ if (playerUsesWatchLayout(replayLayout, logicProps)) {+ if (!watchPanelOpenSections.includes('overview')) {+ toggleWatchPanelSection('overview')+ }+ return+ }setSidebarOpen(true)setTab(SessionRecordingSidebarTab.OVERVIEW)}diff --git a/frontend/src/scenes/session-recordings/player/playerSettingsLogic.test.ts b/frontend/src/scenes/session-recordings/player/playerSettingsLogic.test.tsindex c9c0e3671519..49ce7792fa0c 100644--- a/frontend/src/scenes/session-recordings/player/playerSettingsLogic.test.ts+++ b/frontend/src/scenes/session-recordings/player/playerSettingsLogic.test.ts@@ -1,6 +1,12 @@+import { router } from 'kea-router'import { expectLogic } from 'kea-test-utils'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { urls } from 'scenes/urls'+import { initKeaTests } from '~/test/init'+import { ReplayTabs } from '~/types'import { sessionRecordingEventUsageLogic } from '../sessionRecordingEventUsageLogic'import { playerSettingsLogic } from './playerSettingsLogic'@@ -10,6 +16,7 @@ describe('playerSettingsLogic', () => {let eventLogic: ReturnType<typeof sessionRecordingEventUsageLogic.build>beforeEach(() => {+ localStorage.clear()initKeaTests()eventLogic = sessionRecordingEventUsageLogic()eventLogic.mount()@@ -24,6 +31,74 @@ describe('playerSettingsLogic', () => {})})})+ describe('URL handling', () => {+ const home = urls.replay(ReplayTabs.Home)+ const watchLayout = (): void =>+ featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.REPLAY_WATCH_LAYOUT]: 'compact' })+ const openLink = (path: string, searchParams = {}, hashParams = {}): void => {+ logic.unmount()+ router.actions.push(path, searchParams, hashParams)+ logic.mount()+ }++ beforeEach(() => {+ featureFlagLogic.mount()+ })++ it.each([+ ['search', { inspectorSideBar: true }, {}],+ ['hash', {}, { inspectorSideBar: true }],+ ])('an old inspectorSideBar %s link opens Debug once', (_, searchParams, hashParams) => {+ watchLayout()+ openLink(home, searchParams, hashParams)+ expect(logic.values.debugMode).toBe(true)++ logic.actions.setDebugMode(false)+ expect(router.values.searchParams.inspectorSideBar).toBeUndefined()+ expect(router.values.hashParams.inspectorSideBar).toBeUndefined()++ router.actions.push(home, router.values.searchParams, router.values.hashParams)+ expect(logic.values.debugMode).toBe(false)+ })++ it('an old inspectorSideBar link waits for the flags before opening Debug', () => {+ openLink(home, { inspectorSideBar: true })+ expect(logic.values.debugMode).toBe(false)+ watchLayout()+ expect(logic.values.debugMode).toBe(true)+ })++ it('an old inspectorSideBar link leaves Debug off in the classic layout', () => {+ featureFlagLogic.actions.setFeatureFlags([], {})+ openLink(home, { inspectorSideBar: true })+ expect(logic.values.sidebarOpen).toBe(true)+ expect(logic.values.debugMode).toBe(false)+ })++ it('an old inspectorSideBar link to another page leaves Debug off', () => {+ watchLayout()+ openLink(urls.replaySingle('1'), { inspectorSideBar: true })+ expect(logic.values.sidebarOpen).toBe(true)+ expect(logic.values.debugMode).toBe(false)+ })++ it('opening the classic sidebar leaves Debug off', () => {+ watchLayout()+ openLink(home)+ logic.actions.setSidebarOpen(true)+ expect(router.values.searchParams.inspectorSideBar).toBe(true)+ expect(logic.values.debugMode).toBe(false)+ })++ it('the classic sidebar param carried onto the next recording leaves Debug off', () => {+ featureFlagLogic.actions.setFeatureFlags([], {})+ openLink(home)+ logic.actions.setSidebarOpen(true)+ watchLayout()+ router.actions.push(home, { ...router.values.searchParams, sessionRecordingId: '2' })+ expect(logic.values.debugMode).toBe(false)+ })+ })describe('setSpeed', () => {it('sets the speed', () => {expectLogic(logic, () => {diff --git a/frontend/src/scenes/session-recordings/player/playerSettingsLogic.ts b/frontend/src/scenes/session-recordings/player/playerSettingsLogic.tsindex 53a70255dd2a..ca2360b3db4a 100644--- a/frontend/src/scenes/session-recordings/player/playerSettingsLogic.ts+++ b/frontend/src/scenes/session-recordings/player/playerSettingsLogic.ts@@ -1,9 +1,22 @@-import { MakeLogicType, actions, kea, listeners, path, reducers, selectors } from 'kea'+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'import { actionToUrl, router, urlToAction } from 'kea-router'import { subscriptions } from 'kea-subscriptions'import posthog from 'posthog-js'-import { AutoplayDirection, SessionRecordingSidebarStacking } from '~/types'+import { FEATURE_FLAGS } from 'lib/constants'+import { FeatureFlagsSet, featureFlagLogic, peekFeatureFlag } from 'lib/logic/featureFlagLogic'+import {+ ReplayLayout,+ isNewReplayLayout,+ offeredReplayLayout,+ replayLayoutFrom,+} from 'scenes/session-recordings/playlist/replayLayout'+import { urls } from 'scenes/urls'++import { AutoplayDirection, ReplayTabs, SessionRecordingSidebarStacking } from '~/types'++export type WatchPanelSection = 'overview' | 'linked-issues'+export type WatchDebugDock = 'bottom' | 'right'export enum TimestampFormat {Relative = 'relative',@@ -15,35 +28,57 @@ export type HideViewedRecordingsOptions = 'current-user' | 'any-user' | false// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface playerSettingsLogicValues {+ featureFlags: FeatureFlagsSet // featureFlagLogic+ receivedFeatureFlags: boolean // featureFlagLogicautoplayDirection: AutoplayDirection+ canOverrideLayout: boolean+ debugHintDismissed: boolean+ debugMode: boolean+ debugModePreference: booleanhideRecordingsMenuLabelFor: (option: HideViewedRecordingsOptions) => 'All recordings' | 'Hide all viewed recordings' | 'Hide my viewed recordings'hideViewedRecordings: HideViewedRecordingsOptionsisPlaylistCollapsed: booleanisVerticallyStacked: boolean+ legacyDebugLinkPending: booleanplayerControlsOverlay: booleanplaylistOpen: booleanplaylistTimestampFormat: TimestampFormat+ preferClassicReplayLayout: booleanpreferredSidebarStacking: SessionRecordingSidebarStacking+ replayLayout: ReplayLayoutshowFilters: booleanshowMetadataFooter: booleansidebarOpen: booleanskipInactivitySetting: booleanspeed: number+ staffLayoutOverride: ReplayLayout | nulltimestampFormat: TimestampFormaturlOverrideSidebarOpen: boolean | nulluserPreferenceSidebarOpen: boolean+ watchDebugDock: WatchDebugDock+ watchLayoutOffered: boolean+ watchPanelOpenSections: WatchPanelSection[]}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface playerSettingsLogicActions {+ dismissDebugHint: () => {+ value: true+ }setAutoplayDirection: (autoplayDirection: AutoplayDirection) => {autoplayDirection: AutoplayDirection}+ setDebugMode: (open: boolean) => {+ open: boolean+ }setHideViewedRecordings: (hideViewedRecordings: HideViewedRecordingsOptions) => {hideViewedRecordings: HideViewedRecordingsOptions}+ setLegacyDebugLinkPending: (pending: boolean) => {+ pending: boolean+ }setPlayerControlsOverlay: (playerControlsOverlay: boolean) => {playerControlsOverlay: boolean}@@ -56,6 +91,9 @@ export interface playerSettingsLogicActions {setPlaylistTimestampFormat: (format: TimestampFormat) => {format: TimestampFormat}+ setPreferClassicReplayLayout: (preferClassicReplayLayout: boolean) => {+ preferClassicReplayLayout: boolean+ }setPreferredSidebarStacking: (stacking: SessionRecordingSidebarStacking) => {stacking: SessionRecordingSidebarStacking}@@ -74,17 +112,35 @@ export interface playerSettingsLogicActions {setSpeed: (speed: number) => {speed: number}+ setStaffLayoutOverride: (layout: ReplayLayout | null) => {+ layout: ReplayLayout | null+ }setTimestampFormat: (format: TimestampFormat) => {format: TimestampFormat}setURLOverrideSidebarOpen: (open: boolean) => {open: boolean}+ setWatchDebugDock: (dock: WatchDebugDock) => {+ dock: WatchDebugDock+ }+ toggleWatchPanelSection: (section: WatchPanelSection) => {+ section: WatchPanelSection+ }}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface playerSettingsLogicMeta {__keaTypeGenInternalSelectorTypes: {+ watchLayoutOffered: (featureFlags: FeatureFlagsSet) => boolean+ canOverrideLayout: (featureFlags: FeatureFlagsSet) => boolean+ replayLayout: (+ featureFlags: FeatureFlagsSet,+ preferClassicReplayLayout: boolean,+ staffLayoutOverride: ReplayLayout | null,+ canOverrideLayout: boolean+ ) => ReplayLayout+ debugMode: (debugModePreference: boolean, urlOverrideSidebarOpen: boolean | null) => booleansidebarOpen: (userPreferenceSidebarOpen: boolean, urlOverrideSidebarOpen: boolean | null) => booleanisVerticallyStacked: (preferredSidebarStacking: SessionRecordingSidebarStacking) => boolean}@@ -101,6 +157,9 @@ export type playerSettingsLogicType = MakeLogicType<// If key is not specified, it is global so it does not reset when recordings change in the main recordings pageexport const playerSettingsLogic = kea<playerSettingsLogicType>([path(['scenes', 'session-recordings', 'player', 'playerSettingsLogic']),+ connect(() => ({+ values: [featureFlagLogic, ['featureFlags', 'receivedFeatureFlags']],+ })),actions({setSkipInactivitySetting: (skipInactivitySetting: boolean) => ({ skipInactivitySetting }),setSpeed: (speed: number) => ({ speed }),@@ -113,11 +172,18 @@ export const playerSettingsLogic = kea<playerSettingsLogicType>([setPlaylistTimestampFormat: (format: TimestampFormat) => ({ format }),setPreferredSidebarStacking: (stacking: SessionRecordingSidebarStacking) => ({ stacking }),setSidebarOpen: (open: boolean) => ({ open }),+ setDebugMode: (open: boolean) => ({ open }),setPlaylistOpen: (open: boolean) => ({ open }),setURLOverrideSidebarOpen: (open: boolean) => ({ open }),setPlaylistCollapsed: (collapsed: boolean) => ({ collapsed }),setShowMetadataFooter: (showMetadataFooter: boolean) => ({ showMetadataFooter }),setPlayerControlsOverlay: (playerControlsOverlay: boolean) => ({ playerControlsOverlay }),+ setPreferClassicReplayLayout: (preferClassicReplayLayout: boolean) => ({ preferClassicReplayLayout }),+ setStaffLayoutOverride: (layout: ReplayLayout | null) => ({ layout }),+ toggleWatchPanelSection: (section: WatchPanelSection) => ({ section }),+ setWatchDebugDock: (dock: WatchDebugDock) => ({ dock }),+ dismissDebugHint: true,+ setLegacyDebugLinkPending: (pending: boolean) => ({ pending }),}),reducers(() => ({showFilters: [true, { persist: true }, { setShowFilters: (_, { showFilters }) => showFilters }],@@ -199,9 +265,77 @@ export const playerSettingsLogic = kea<playerSettingsLogicType>([setPlayerControlsOverlay: (_, { playerControlsOverlay }) => playerControlsOverlay,},],+ // Lets a person in the watch-layout experiment switch back to the classic page+ preferClassicReplayLayout: [+ false,+ { persist: true },+ {+ setPreferClassicReplayLayout: (_, { preferClassicReplayLayout }) => preferClassicReplayLayout,+ },+ ],+ staffLayoutOverride: [+ null as ReplayLayout | null,+ { persist: true },+ { setStaffLayoutOverride: (_, { layout }) => layout },+ ],+ watchDebugDock: ['right' as WatchDebugDock, { persist: true }, { setWatchDebugDock: (_, { dock }) => dock }],+ // Starts closed for everyone, whatever the legacy sidebar preference was.+ debugModePreference: [false, { persist: true }, { setDebugMode: (_, { open }) => open }],+ legacyDebugLinkPending: [+ false,+ {+ setLegacyDebugLinkPending: (_, { pending }) => pending,+ setDebugMode: () => false,+ },+ ],+ debugHintDismissed: [+ false,+ { persist: true },+ {+ dismissDebugHint: () => true,+ setDebugMode: (state, { open }) => state || open,+ },+ ],+ watchPanelOpenSections: [+ [] as WatchPanelSection[],+ { persist: true },+ {+ toggleWatchPanelSection: (state, { section }) =>+ state.includes(section) ? state.filter((s) => s !== section) : [...state, section],+ },+ ],})),selectors({+ watchLayoutOffered: [+ (s) => [s.featureFlags],+ (featureFlags: FeatureFlagsSet): boolean =>+ offeredReplayLayout(peekFeatureFlag(featureFlags, FEATURE_FLAGS.REPLAY_WATCH_LAYOUT)) !== null,+ ],+ canOverrideLayout: [+ (s) => [s.featureFlags],+ (featureFlags: FeatureFlagsSet): boolean =>+ !!peekFeatureFlag(featureFlags, FEATURE_FLAGS.REPLAY_LAYOUT_SWITCHER),+ ],+ replayLayout: [+ (s) => [s.featureFlags, s.preferClassicReplayLayout, s.staffLayoutOverride, s.canOverrideLayout],+ (+ featureFlags: FeatureFlagsSet,+ preferClassicReplayLayout: boolean,+ staffLayoutOverride: ReplayLayout | null,+ canOverrideLayout: boolean+ ): ReplayLayout =>+ replayLayoutFrom(+ peekFeatureFlag(featureFlags, FEATURE_FLAGS.REPLAY_WATCH_LAYOUT),+ preferClassicReplayLayout,+ canOverrideLayout ? staffLayoutOverride : null+ ),+ ],+ debugMode: [+ (s) => [s.debugModePreference, s.urlOverrideSidebarOpen],+ (debugModePreference: boolean, urlOverrideSidebarOpen: boolean | null): boolean =>+ urlOverrideSidebarOpen ?? debugModePreference,+ ],sidebarOpen: [(s) => [s.userPreferenceSidebarOpen, s.urlOverrideSidebarOpen],(userPreferenceSidebarOpen: boolean, urlOverrideSidebarOpen: boolean | null): boolean => {@@ -245,9 +379,22 @@ export const playerSettingsLogic = kea<playerSettingsLogicType>([player_controls_overlay: playerControlsOverlay,})},+ setPreferClassicReplayLayout: ({ preferClassicReplayLayout }) => {+ posthog.capture('session recording layout changed', {+ layout: preferClassicReplayLayout ? 'classic' : 'watch',+ })+ },}),- subscriptions(({ actions }) => ({+ subscriptions(({ actions, values }) => ({+ receivedFeatureFlags: (received: boolean) => {+ if (received && values.legacyDebugLinkPending) {+ actions.setLegacyDebugLinkPending(false)+ if (isNewReplayLayout(values.replayLayout) && !values.debugMode) {+ actions.setDebugMode(true)+ }+ }+ },hideViewedRecordings: ({ hideViewedRecordings }) => {// hideViewRecordings used to be flat boolean// if someone has it set to true, we should set it to 'current-user'@@ -259,50 +406,71 @@ export const playerSettingsLogic = kea<playerSettingsLogicType>([},})),- urlToAction(({ actions, values }) => ({- ['**/shared/*']: (_, searchParams) => {- // when sharing a recording, you can specify whether the inspector should be open.- // we should obey that regardless of the preference stored here.- // the sharing URLs historically added showInspector with no value.- // so we need to check for the presence of the key.- // if the key is present but "null", that is equivalent to true- const inspectorSideBarOpen = 'showInspector' in searchParams && (searchParams.showInspector ?? true)- if (inspectorSideBarOpen && inspectorSideBarOpen !== values.sidebarOpen) {- actions.setURLOverrideSidebarOpen(inspectorSideBarOpen)- }- },- ['**/exporter']: (_, searchParams) => {- const playerSpeed = Number(searchParams.playerSpeed ?? 1)- if (values.speed !== playerSpeed) {- actions.setSpeed(playerSpeed)- }- const showMetadataFooter =- 'showMetadataFooter' in searchParams && (searchParams.showMetadataFooter ?? false)- if (values.showMetadataFooter !== showMetadataFooter) {- actions.setShowMetadataFooter(showMetadataFooter)- // If we display metadata footer (for analysis purposes), we also want to skip inactivity to speed up rendering- actions.setSkipInactivitySetting(showMetadataFooter)- }- },- // Putting `*` last to match it only if more specific routes don't match, as the matching seems to be exclusive- '*': (_, searchParams, hashParams) => {+ urlToAction(({ actions, values }) => {+ const syncClassicSidebar = (searchParams: Record<string, any>, hashParams: Record<string, any>): boolean => {const inspectorSideBarOpen = searchParams.inspectorSideBar === true || hashParams.inspectorSideBar === trueif (inspectorSideBarOpen && inspectorSideBarOpen !== values.sidebarOpen) {actions.setSidebarOpen(inspectorSideBarOpen)}- },- })),+ return inspectorSideBarOpen+ }+ return {+ ['**/shared/*']: (_, searchParams) => {+ // when sharing a recording, you can specify whether the inspector should be open.+ // we should obey that regardless of the preference stored here.+ // the sharing URLs historically added showInspector with no value.+ // so we need to check for the presence of the key.+ // if the key is present but "null", that is equivalent to true+ const inspectorSideBarOpen = 'showInspector' in searchParams && (searchParams.showInspector ?? true)+ if (inspectorSideBarOpen && inspectorSideBarOpen !== values.sidebarOpen) {+ actions.setURLOverrideSidebarOpen(inspectorSideBarOpen)+ }+ },+ ['**/exporter']: (_, searchParams) => {+ const playerSpeed = Number(searchParams.playerSpeed ?? 1)+ if (values.speed !== playerSpeed) {+ actions.setSpeed(playerSpeed)+ }+ const showMetadataFooter =+ 'showMetadataFooter' in searchParams && (searchParams.showMetadataFooter ?? false)+ if (values.showMetadataFooter !== showMetadataFooter) {+ actions.setShowMetadataFooter(showMetadataFooter)+ // If we display metadata footer (for analysis purposes), we also want to skip inactivity to speed up rendering+ actions.setSkipInactivitySetting(showMetadataFooter)+ }+ },+ [urls.replay(ReplayTabs.Home)]: (_, searchParams, hashParams, { initial }) => {+ const inspectorSideBarOpen = syncClassicSidebar(searchParams, hashParams)+ // The page copies the param into every URL it writes.+ const legacyLink = inspectorSideBarOpen && !!initial+ if (legacyLink && !values.receivedFeatureFlags) {+ actions.setLegacyDebugLinkPending(true)+ }+ const legacyDebugLink = legacyLink && isNewReplayLayout(values.replayLayout)+ if ((searchParams.debug === true || legacyDebugLink) && !values.debugMode) {+ actions.setDebugMode(true)+ }+ },+ // Putting `*` last to match it only if more specific routes don't match, as the matching seems to be exclusive+ '*': (_, searchParams, hashParams) => {+ syncClassicSidebar(searchParams, hashParams)+ },+ }+ }),actionToUrl(() => ({setSidebarOpen: ({ open }) => {- const { currentLocation } = router.values+ const { pathname, searchParams, hashParams } = router.values.currentLocation+ return [pathname, { ...searchParams, inspectorSideBar: open }, hashParams, { replace: true }]+ },+ // Debug consumes the legacy param, or closing it would reopen it from the URL.+ setDebugMode: ({ open }) => {+ const { pathname, searchParams, hashParams } = router.values.currentLocationreturn [- currentLocation.pathname,- {- ...currentLocation.searchParams,- inspectorSideBar: open,- },- currentLocation.hashParams,+ pathname,+ { ...searchParams, debug: open || undefined, inspectorSideBar: undefined },+ { ...hashParams, inspectorSideBar: undefined },+ { replace: true },]},})),diff --git a/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts b/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.tsindex 20ec571ecbf9..73b0705cdb59 100644--- a/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts+++ b/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts@@ -370,6 +370,8 @@ export interface SessionRecordingPlayerLogicProps extends SessionRecordingDataCo// The experiment whose recordings list the player was opened from. Its first in-session exposure// becomes a target for the initial skip, alongside any filtered events.exposureSkipExperimentId?: number+ // Only the replay playlist offers the watch layout. Embedded, modal and single-recording players keep the classic chrome.+ watchLayout?: boolean}export type MatchingEventSkipTarget = 'filtered-event' | 'experiment-exposure'diff --git a/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarOverviewDeviceTab.tsx b/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarOverviewDeviceTab.tsxindex f78cefde13ea..52c7cb8aa7aa 100644--- a/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarOverviewDeviceTab.tsx+++ b/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarOverviewDeviceTab.tsx@@ -15,8 +15,8 @@ export function PlayerSidebarOverviewDeviceTab(): JSX.Element {// Pixel sizes instead of CSS aspect-ratio, so unknown or extreme resolutions still draw as a screen.const aspect = resolution && resolution.width > 0 ? resolution.height / resolution.width : 10 / 16- const frameWidth = aspect > 1 ? Math.round(56 / aspect) : 80- const frameHeight = aspect > 1 ? 56 : Math.round(80 * Math.min(Math.max(aspect, 0.45), 0.8))+ const frameWidth = aspect > 1 ? Math.round(34 / aspect) : 68+ const frameHeight = aspect > 1 ? 34 : Math.round(68 * Math.min(Math.max(aspect, 0.35), 0.56))const visiblePercent = Math.round(Math.min(Math.max(scale, 0), 1) * 80)return (@@ -46,7 +46,7 @@ export function PlayerSidebarOverviewDeviceTab(): JSX.Element {style={{ width: `${visiblePercent}%`, height: `${visiblePercent}%` }}/></div>- <div className="h-1.5 w-8 rounded-b-sm bg-muted" />+ <div className="h-1.5 w-7 rounded-b-sm bg-muted" /></div></Tooltip><div className="flex flex-col min-w-0 text-xs">diff --git a/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarOverviewPersonTab.tsx b/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarOverviewPersonTab.tsxindex 5eb70771e3e1..2ac1d5502d53 100644--- a/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarOverviewPersonTab.tsx+++ b/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarOverviewPersonTab.tsx@@ -25,12 +25,19 @@ export function PlayerSidebarOverviewPersonTab(): JSX.Element {return (<>- <div className="rounded border bg-surface-primary px-2 py-1.5 flex flex-col min-w-0">+ <div className="rounded border bg-surface-primary px-2 py-1.5 flex flex-col justify-center min-w-0">{loading ? (<LemonSkeleton.Row repeat={2} className="h-4" />) : (<>- <span className="font-semibold truncate">{displayName}</span>+ <CopyToClipboardInline+ description="person"+ explicitValue={displayName}+ className="font-semibold truncate"+ data-attr="replay-overview-copy-person"+ >+ {displayName}+ </CopyToClipboardInline>{distinctId && (<CopyToClipboardInlinedescription="distinct ID"diff --git a/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarOverviewSessionTab.tsx b/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarOverviewSessionTab.tsxindex d978463d230a..06a1d30b3220 100644--- a/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarOverviewSessionTab.tsx+++ b/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarOverviewSessionTab.tsx@@ -22,7 +22,7 @@ export function PlayerSidebarOverviewSessionTab(): JSX.Element {return (<>{statItems.length > 0 && (- <div className="rounded border bg-surface-primary flex flex-row justify-between px-2 py-1.5 gap-2">+ <div className="rounded border bg-surface-primary flex flex-row justify-between items-center px-2 py-1.5 gap-2">{loading? statItems.map((item) => <LemonSkeleton key={item.label} className="h-8 flex-1" />): statItems.map((item) => {diff --git a/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarOverviewTab.tsx b/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarOverviewTab.tsxindex f9055c7a25cf..a1de55909d27 100644--- a/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarOverviewTab.tsx+++ b/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarOverviewTab.tsx@@ -12,6 +12,7 @@ import { OverviewTab } from '../player-meta/overviewTabs'import { playerMetaLogic } from '../player-meta/playerMetaLogic'import { TTLWarning } from '../player-meta/PlayerMetaTopSettings'import { sessionRecordingPlayerLogic } from '../sessionRecordingPlayerLogic'+import { OVERVIEW_SNAPSHOT_SCOPE } from './overviewSnapshotScope'import { PlayerSidebarExperimentsSection } from './PlayerSidebarExperimentsSection'import { playerSidebarLogic } from './playerSidebarLogic'import { PlayerSidebarOverviewDeviceTab } from './PlayerSidebarOverviewDeviceTab'@@ -19,23 +20,6 @@ import { PlayerSidebarOverviewOtherWatchers } from './PlayerSidebarOverviewOtherimport { PlayerSidebarOverviewPersonTab } from './PlayerSidebarOverviewPersonTab'import { PlayerSidebarOverviewSessionTab } from './PlayerSidebarOverviewSessionTab'-const SNAPSHOT_SCOPE: string[] = [- 'session_recording_opt_in',- 'session_recording_sample_rate',- 'session_recording_minimum_duration_milliseconds',- 'session_recording_linked_flag',- 'session_recording_network_payload_capture_config',- 'session_recording_masking_config',- 'session_recording_url_trigger_config',- 'session_recording_url_blocklist_config',- 'session_recording_event_trigger_config',- 'session_recording_retention_period',- 'session_recording_trigger_match_type_config',- 'session_recording_trigger_groups',- 'session_replay_config',- 'recording_domains',-]-const OVERVIEW_TAB_OPTIONS: { value: OverviewTab; label: string; 'data-attr': string }[] = [{ value: 'session', label: 'Session', 'data-attr': 'replay-overview-tab-session' },{ value: 'person', label: 'Person', 'data-attr': 'replay-overview-tab-person' },@@ -103,7 +87,7 @@ export function PlayerSidebarOverviewTab(): JSX.Element {{key: 'replay-settings',header: 'Settings at the time of the recording',- content: <SettingsSnapshot at={snapshotAt} scope={SNAPSHOT_SCOPE} title="" />,+ content: <SettingsSnapshot at={snapshotAt} scope={OVERVIEW_SNAPSHOT_SCOPE} title="" />,},]}/>diff --git a/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarTab.tsx b/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarTab.tsxindex 8fe0011d99ab..293743d4b2b6 100644--- a/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarTab.tsx+++ b/frontend/src/scenes/session-recordings/player/sidebar/PlayerSidebarTab.tsx@@ -12,10 +12,10 @@ import { playerSidebarLogic } from './playerSidebarLogic'import { PlayerSidebarOverviewTab } from './PlayerSidebarOverviewTab'import { PlayerSidebarPersonRecordingsTab } from './PlayerSidebarPersonRecordingsTab'-export function PlayerSidebarTab(): JSX.Element | null {+export function PlayerSidebarTab({ tab }: { tab?: SessionRecordingSidebarTab } = {}): JSX.Element | null {const { activeTab } = useValues(playerSidebarLogic)- switch (activeTab) {+ switch (tab ?? activeTab) {case SessionRecordingSidebarTab.OVERVIEW:return <PlayerSidebarOverviewTab />case SessionRecordingSidebarTab.INSPECTOR:diff --git a/frontend/src/scenes/session-recordings/player/sidebar/overviewSnapshotScope.ts b/frontend/src/scenes/session-recordings/player/sidebar/overviewSnapshotScope.tsnew file mode 100644index 000000000000..ff9349905d86--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/sidebar/overviewSnapshotScope.ts@@ -0,0 +1,16 @@+export const OVERVIEW_SNAPSHOT_SCOPE: string[] = [+ 'session_recording_opt_in',+ 'session_recording_sample_rate',+ 'session_recording_minimum_duration_milliseconds',+ 'session_recording_linked_flag',+ 'session_recording_network_payload_capture_config',+ 'session_recording_masking_config',+ 'session_recording_url_trigger_config',+ 'session_recording_url_blocklist_config',+ 'session_recording_event_trigger_config',+ 'session_recording_retention_period',+ 'session_recording_trigger_match_type_config',+ 'session_recording_trigger_groups',+ 'session_replay_config',+ 'recording_domains',+]diff --git a/frontend/src/scenes/session-recordings/player/watch/DebugModeBanner.tsx b/frontend/src/scenes/session-recordings/player/watch/DebugModeBanner.tsxnew file mode 100644index 000000000000..1716333de1c2--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/watch/DebugModeBanner.tsx@@ -0,0 +1,37 @@+import { useActions, useValues } from 'kea'+import posthog from 'posthog-js'++import { LemonBanner } from '@posthog/lemon-ui'++import { playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'+import { playerSidebarLogic } from 'scenes/session-recordings/player/sidebar/playerSidebarLogic'++import { SessionRecordingSidebarTab } from '~/types'++export function DebugModeBanner(): JSX.Element | null {+ const { debugMode, debugHintDismissed, watchLayoutOffered } = useValues(playerSettingsLogic)+ const { setDebugMode, dismissDebugHint } = useActions(playerSettingsLogic)+ const { setTab } = useActions(playerSidebarLogic)++ if (debugMode || debugHintDismissed || !watchLayoutOffered) {+ return null+ }++ return (+ <LemonBanner+ type="info"+ onClose={dismissDebugHint}+ action={{+ children: 'Open Debug',+ 'data-attr': 'player-debug-hint-open',+ onClick: () => {+ posthog.capture('session recording mode changed', { mode: 'debug', source: 'hint' })+ setDebugMode(true)+ setTab(SessionRecordingSidebarTab.INSPECTOR)+ },+ }}+ >+ Looking for the inspector or network waterfall? They are under Debug now.+ </LemonBanner>+ )+}diff --git a/frontend/src/scenes/session-recordings/player/watch/DebugTabBar.tsx b/frontend/src/scenes/session-recordings/player/watch/DebugTabBar.tsxnew file mode 100644index 000000000000..f42435d88168--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/watch/DebugTabBar.tsx@@ -0,0 +1,45 @@+import { ReactNode } from 'react'++import { IconPulse } from '@posthog/icons'++import { IconUnverifiedEvent } from 'lib/lemon-ui/icons'+import { PaneTabBar } from 'scenes/session-recordings/components/PaneTabBar'++import { SessionRecordingSidebarTab } from '~/types'++export const DEBUG_TAB_KEYS = [SessionRecordingSidebarTab.INSPECTOR, SessionRecordingSidebarTab.NETWORK_WATERFALL]++const DEBUG_TABS: Partial<Record<SessionRecordingSidebarTab, { label: string; icon: ReactNode; dataAttr: string }>> = {+ [SessionRecordingSidebarTab.INSPECTOR]: {+ label: 'Inspector',+ icon: <IconUnverifiedEvent />,+ dataAttr: 'watch-panel-debug-inspector',+ },+ [SessionRecordingSidebarTab.NETWORK_WATERFALL]: {+ label: 'Network',+ icon: <IconPulse />,+ dataAttr: 'watch-panel-debug-network',+ },+}++export function DebugTabBar({+ tabs,+ activeTab,+ onChange,+ children,+}: {+ tabs: SessionRecordingSidebarTab[]+ activeTab: SessionRecordingSidebarTab+ onChange: (tab: SessionRecordingSidebarTab) => void+ children?: ReactNode+}): JSX.Element {+ const paneTabs = tabs.flatMap((tab) => {+ const debugTab = DEBUG_TABS[tab]+ return debugTab ? [{ key: tab, ...debugTab }] : []+ })+ return (+ <PaneTabBar tabs={paneTabs} activeKey={activeTab} onChange={onChange}>+ {children}+ </PaneTabBar>+ )+}diff --git a/frontend/src/scenes/session-recordings/player/watch/MomentTicker.tsx b/frontend/src/scenes/session-recordings/player/watch/MomentTicker.tsxnew file mode 100644index 000000000000..56c10dc58918--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/watch/MomentTicker.tsx@@ -0,0 +1,76 @@+import { useValues } from 'kea'++import { IconChevronRight, IconSparkles } from '@posthog/icons'+import { LemonButton } from '@posthog/lemon-ui'++import { colonDelimitedDuration } from 'lib/utils/durations'+import { replayListColumnLogic } from 'scenes/session-recordings/playlist/replayListColumnLogic'++import { observationsDockLogic } from 'products/replay_vision/frontend/logics/observationsDockLogic'+import {+ momentCount,+ surroundingMoments,+ timelineMoments,+} from 'products/replay_vision/frontend/utils/recordingTimeline'++import { sessionRecordingPlayerLogic } from '../sessionRecordingPlayerLogic'++const formatMs = (ms: number): string => colonDelimitedDuration(ms / 1000, ms >= 3_600_000 ? 3 : 2)++export function MomentTicker({ sessionId }: { sessionId: string }): JSX.Element | null {+ const { timeline } = useValues(observationsDockLogic({ sessionId }))+ const { logicProps, currentPlayerTime } = useValues(sessionRecordingPlayerLogic)+ const moments = timelineMoments(timeline)+ if (moments.length === 0) {+ return null+ }+ const { current, next } = surroundingMoments(moments, currentPlayerTime)+ const seek = (ms: number): void => {+ sessionRecordingPlayerLogic.findMounted(logicProps)?.actions.seekToTime(ms)+ }++ return (+ <div className="flex items-center gap-1 flex-wrap text-xs" data-attr="moment-ticker">+ {current && (+ <LemonButton+ size="xsmall"+ onClick={() => seek(current.atMs)}+ data-attr="moment-ticker-current"+ className="max-w-full"+ >+ <span className="truncate">+ <span className="text-secondary tabular-nums">{formatMs(current.atMs)}</span>{' '}+ <span>{current.label}</span>+ </span>+ </LemonButton>+ )}+ {next && (+ <LemonButton+ size="xsmall"+ sideIcon={<IconChevronRight />}+ onClick={() => seek(next.atMs)}+ data-attr="moment-ticker-next"+ className="max-w-full"+ >+ <span className="truncate">+ <span className="text-secondary">next</span>{' '}+ <span className="text-secondary tabular-nums">{formatMs(next.atMs)}</span>{' '}+ <span>{next.label}</span>+ </span>+ </LemonButton>+ )}+ <LemonButton+ size="xsmall"+ type="tertiary"+ icon={<IconSparkles />}+ className="ml-auto"+ onClick={() =>+ replayListColumnLogic.findMounted({ logicKey: logicProps.playerKey })?.actions.setSegment('moments')+ }+ data-attr="moment-ticker-open-moments"+ >+ <span>{momentCount(timeline)}</span> moments+ </LemonButton>+ </div>+ )+}diff --git a/frontend/src/scenes/session-recordings/player/watch/PlayerModeBar.tsx b/frontend/src/scenes/session-recordings/player/watch/PlayerModeBar.tsxnew file mode 100644index 000000000000..9bf01be63ac0--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/watch/PlayerModeBar.tsx@@ -0,0 +1,137 @@+import '../player-meta/PlayerMeta.scss'++import { useActions, useValues } from 'kea'+import posthog from 'posthog-js'++import { LemonSegmentedButton, LemonSelect, LemonSelectOption, Link } from '@posthog/lemon-ui'++import { CopyToClipboardInline } from 'lib/components/CopyToClipboard'+import { useResizeBreakpoints } from 'lib/hooks/useResizeObserver'+import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'+import { Tooltip } from 'lib/lemon-ui/Tooltip'+import { IconWindow } from 'scenes/session-recordings/player/icons'+import { parseUrl } from 'scenes/session-recordings/player/player-meta/PlayerMeta'+import {+ InsertInNotebookPlaylistButton,+ MenuActions,+} from 'scenes/session-recordings/player/player-meta/PlayerMetaLinks'+import { playerMetaLogic } from 'scenes/session-recordings/player/player-meta/playerMetaLogic'+import {+ InspectDOM,+ SetPlaybackSpeed,+ usePlayerChromeMenuItems,+} from 'scenes/session-recordings/player/player-meta/PlayerMetaTopSettings'+import { playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'+import { sessionRecordingPlayerLogic } from 'scenes/session-recordings/player/sessionRecordingPlayerLogic'+import { PlayerShareMenu } from 'scenes/session-recordings/player/share/PlayerShareMenu'+import { playerSidebarLogic } from 'scenes/session-recordings/player/sidebar/playerSidebarLogic'++import { SessionRecordingSidebarTab } from '~/types'++import { DEBUG_TAB_KEYS } from './DebugTabBar'++type PlayerMode = 'watch' | 'debug'++export function PlayerModeBar(): JSX.Element {+ const { logicProps, sessionRecordingId } = useValues(sessionRecordingPlayerLogic)+ const { windowIds, trackedWindow, currentURL, currentWindowIndex, loading } = useValues(playerMetaLogic(logicProps))+ const { setTrackedWindow } = useActions(playerMetaLogic(logicProps))+ const { debugMode } = useValues(playerSettingsLogic)+ const { setDebugMode } = useActions(playerSettingsLogic)+ const { activeTab } = useValues(playerSidebarLogic)+ const { setTab } = useActions(playerSidebarLogic)+ const chromeItems = usePlayerChromeMenuItems()+ const { ref, size } = useResizeBreakpoints({ 0: 'small', 600: 'normal' })++ const mode: PlayerMode = debugMode ? 'debug' : 'watch'+ const setMode = (next: PlayerMode): void => {+ posthog.capture('session recording mode changed', { mode: next })+ setDebugMode(next === 'debug')+ if (next === 'debug' && !DEBUG_TAB_KEYS.includes(activeTab)) {+ setTab(SessionRecordingSidebarTab.INSPECTOR)+ }+ }++ const windowOptions: LemonSelectOption<number | null>[] = [+ {+ label: <IconWindow value={currentWindowIndex} className="text-secondary" />,+ value: null,+ labelInMenu: <>Follow the user</>,+ },+ ...windowIds.map((windowId) => ({+ label: <IconWindow value={windowId} className="text-secondary" />,+ labelInMenu: (+ <div className="flex flex-row gap-x-1 items-center">+ Follow window: + <IconWindow value={windowId} className="text-secondary" />+ </div>+ ),+ value: windowId,+ })),+ ]+ const { urlToUse, isWebUrl } = parseUrl(currentURL)++ return (+ <div ref={ref} className="PlayerMeta relative">+ <div className="flex flex-row items-center gap-x-1 whitespace-nowrap overflow-hidden px-1 py-0.5 text-xs">+ <LemonSegmentedButton+ size="xsmall"+ value={mode}+ onChange={setMode}+ options={[+ { value: 'watch', label: 'Watch', 'data-attr': 'player-mode-watch' },+ { value: 'debug', label: 'Debug', 'data-attr': 'player-mode-debug' },+ ]}+ />+ {loading ? (+ <LemonSkeleton className="w-1/3 h-4 my-1" />+ ) : (+ <>+ {windowIds.length > 1 && (+ <LemonSelect+ size="xsmall"+ options={windowOptions}+ value={trackedWindow}+ onSelect={(value) => setTrackedWindow(value)}+ data-attr="player-meta-window-select"+ />+ )}+ {urlToUse && (+ <span className="flex items-center gap-x-1 truncate">+ <CopyToClipboardInline+ description={urlToUse}+ explicitValue={urlToUse}+ iconStyle={{ color: 'var(--color-text-secondary)' }}+ selectable={true}+ data-attr="player-meta-copy-url"+ />+ {isWebUrl ? (+ <Tooltip title={`Click to open url: ${urlToUse}`}>+ <Link+ data-attr="player-meta-open-url"+ to={urlToUse}+ target="_blank"+ className="truncate"+ >+ {urlToUse}+ </Link>+ </Tooltip>+ ) : (+ <span className="truncate">{urlToUse}</span>+ )}+ </span>+ )}+ </>+ )}+ <div className="flex-1 min-w-4" />+ <div className="flex items-center gap-0.5">+ {sessionRecordingId && <MenuActions size={size} extraItems={chromeItems} />}+ <SetPlaybackSpeed />+ {debugMode && <InspectDOM />}+ <InsertInNotebookPlaylistButton size={size} />+ <PlayerShareMenu />+ </div>+ </div>+ </div>+ )+}diff --git a/frontend/src/scenes/session-recordings/player/watch/RecordingCommentsList.tsx b/frontend/src/scenes/session-recordings/player/watch/RecordingCommentsList.tsxnew file mode 100644index 000000000000..20e3f4b184cf--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/watch/RecordingCommentsList.tsx@@ -0,0 +1,79 @@+import { useValues } from 'kea'++import { LemonButton } from '@posthog/lemon-ui'++import { TextContent } from 'lib/components/Cards/TextCard/TextCard'+import { TZLabel } from 'lib/components/TZLabel'+import { dayjs } from 'lib/dayjs'+import { RichContentPreview } from 'lib/lemon-ui/LemonRichContent/LemonRichContentEditor'+import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'+import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture'+import { colonDelimitedDuration } from 'lib/utils/durations'++import { CommentType } from '~/types'++import { sessionRecordingCommentsLogic } from '../sessionRecordingCommentsLogic'+import { sessionRecordingPlayerLogic } from '../sessionRecordingPlayerLogic'++export function RecordingCommentsList({ sessionId }: { sessionId: string }): JSX.Element | null {+ const { sessionComments, sessionCommentsLoading } = useValues(+ sessionRecordingCommentsLogic({ sessionRecordingId: sessionId })+ )+ const { logicProps, sessionPlayerData } = useValues(sessionRecordingPlayerLogic)++ const startMs = sessionPlayerData.start?.valueOf() ?? null+ const timeInRecordingMs = (comment: CommentType): number | null => {+ const at = comment.item_context?.time_in_recording+ return at && startMs !== null ? dayjs(at).valueOf() - startMs : null+ }+ const seek = (ms: number): void => {+ sessionRecordingPlayerLogic.findMounted(logicProps)?.actions.seekToTime(ms)+ }+ const comments = [...sessionComments].sort(+ (a, b) => (timeInRecordingMs(a) ?? Infinity) - (timeInRecordingMs(b) ?? Infinity)+ )+ if (comments.length === 0 && !sessionCommentsLoading) {+ return null+ }++ return (+ <div className="flex flex-col gap-2" data-attr="watch-panel-comments">+ {sessionCommentsLoading && comments.length === 0 ? (+ <LemonSkeleton className="w-2/3 h-4" />+ ) : (+ comments.map((comment) => {+ const atMs = timeInRecordingMs(comment)+ return (+ <div key={comment.id} className="flex items-start gap-2 text-sm">+ <ProfilePicture user={comment.created_by} size="sm" className="mt-0.5" />+ <div className="flex flex-col gap-0.5 min-w-0 flex-1">+ <div className="flex items-center gap-2 text-xs text-secondary">+ <span className="font-medium text-primary">+ {comment.created_by?.first_name || comment.created_by?.email || 'Someone'}+ </span>+ <TZLabel time={comment.created_at} showPopover={false} />+ {atMs !== null && (+ <LemonButton+ size="xsmall"+ onClick={() => seek(atMs)}+ data-attr="watch-panel-comment-seek"+ >+ <span className="tabular-nums">+ {colonDelimitedDuration(atMs / 1000, 2)}+ </span>+ </LemonButton>+ )}+ </div>+ {comment.rich_content ? (+ <RichContentPreview content={comment.rich_content} className="rounded-none" />+ ) : (+ <TextContent text={comment.content ?? ''} />+ )}+ </div>+ </div>+ )+ })+ )}+ </div>+ )+}diff --git a/frontend/src/scenes/session-recordings/player/watch/RecordingDebugSection.tsx b/frontend/src/scenes/session-recordings/player/watch/RecordingDebugSection.tsxnew file mode 100644index 000000000000..cf22e39042e5--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/watch/RecordingDebugSection.tsx@@ -0,0 +1,42 @@+import { useActions, useValues } from 'kea'++import { IconSidePanel } from '@posthog/icons'+import { LemonButton } from '@posthog/lemon-ui'++import { NetworkView } from 'scenes/session-recordings/apm/NetworkView'+import { PlayerInspector } from 'scenes/session-recordings/player/inspector/PlayerInspector'+import { playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'+import { playerSidebarLogic } from 'scenes/session-recordings/player/sidebar/playerSidebarLogic'++import { SessionRecordingSidebarTab } from '~/types'++import { DEBUG_TAB_KEYS, DebugTabBar } from './DebugTabBar'++export function RecordingDebugSection(): JSX.Element {+ const { activeTab } = useValues(playerSidebarLogic)+ const { setTab } = useActions(playerSidebarLogic)+ const { setWatchDebugDock } = useActions(playerSettingsLogic)+ const tab = DEBUG_TAB_KEYS.includes(activeTab) ? activeTab : SessionRecordingSidebarTab.INSPECTOR++ return (+ <div+ className="flex flex-col border rounded bg-surface-primary overflow-hidden h-[60vh] min-h-96"+ data-attr="watch-panel-debug"+ >+ <DebugTabBar tabs={DEBUG_TAB_KEYS} activeTab={tab} onChange={setTab}>+ <LemonButton+ size="small"+ icon={<IconSidePanel />}+ onClick={() => setWatchDebugDock('right')}+ tooltip="Dock to right"+ aria-label="Dock to right"+ className="rounded-none"+ data-attr="player-sidebar-dock-toggle"+ />+ </DebugTabBar>+ <div className="flex flex-col flex-1 min-w-0 overflow-hidden">+ {tab === SessionRecordingSidebarTab.NETWORK_WATERFALL ? <NetworkView /> : <PlayerInspector />}+ </div>+ </div>+ )+}diff --git a/frontend/src/scenes/session-recordings/player/watch/RecordingOverviewDisclosure.tsx b/frontend/src/scenes/session-recordings/player/watch/RecordingOverviewDisclosure.tsxnew file mode 100644index 000000000000..6c10e2ca5895--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/watch/RecordingOverviewDisclosure.tsx@@ -0,0 +1,38 @@+import { useActions, useValues } from 'kea'+import { ReactNode } from 'react'++import { LemonCollapse } from '@posthog/lemon-ui'++import { playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'++import { RecordingOverviewPanels } from './RecordingOverviewPanels'++export function RecordingOverviewDisclosure({ actions }: { actions?: ReactNode }): JSX.Element {+ const { watchPanelOpenSections } = useValues(playerSettingsLogic)+ const { toggleWatchPanelSection } = useActions(playerSettingsLogic)+ const open = watchPanelOpenSections.includes('overview')++ return (+ <div className="relative">+ <LemonCollapse+ size="small"+ panels={[+ {+ key: 'overview',+ header: 'Overview',+ content: <RecordingOverviewPanels />,+ dataAttr: 'watch-panel-section-overview',+ },+ ]}+ activeKey={open ? 'overview' : null}+ onChange={() => toggleWatchPanelSection('overview')}+ />+ {actions && (+ // Height of a small LemonButton, which is what the collapse header renders as.+ <div className="absolute right-1 top-0 h-[2.0625rem] max-w-[70%] flex items-center gap-2">+ {actions}+ </div>+ )}+ </div>+ )+}diff --git a/frontend/src/scenes/session-recordings/player/watch/RecordingOverviewPanels.tsx b/frontend/src/scenes/session-recordings/player/watch/RecordingOverviewPanels.tsxnew file mode 100644index 000000000000..064b6dfd3e56--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/watch/RecordingOverviewPanels.tsx@@ -0,0 +1,82 @@+import { useValues } from 'kea'+import { ReactNode } from 'react'++import { SettingsSnapshot } from 'lib/components/SettingsSnapshot'+import { useResizeBreakpoints } from 'lib/hooks/useResizeObserver'+import { LemonCollapse } from 'lib/lemon-ui/LemonCollapse'+import { playerMetaLogic } from 'scenes/session-recordings/player/player-meta/playerMetaLogic'+import { TTLWarning } from 'scenes/session-recordings/player/player-meta/PlayerMetaTopSettings'+import { sessionRecordingPlayerLogic } from 'scenes/session-recordings/player/sessionRecordingPlayerLogic'+import { OVERVIEW_SNAPSHOT_SCOPE } from 'scenes/session-recordings/player/sidebar/overviewSnapshotScope'+import { PlayerSidebarExperimentsSection } from 'scenes/session-recordings/player/sidebar/PlayerSidebarExperimentsSection'+import { PlayerSidebarOverviewDeviceTab } from 'scenes/session-recordings/player/sidebar/PlayerSidebarOverviewDeviceTab'+import { PlayerSidebarOverviewOtherWatchers } from 'scenes/session-recordings/player/sidebar/PlayerSidebarOverviewOtherWatchers'+import { PlayerSidebarOverviewPersonTab } from 'scenes/session-recordings/player/sidebar/PlayerSidebarOverviewPersonTab'+import { PlayerSidebarOverviewSessionTab } from 'scenes/session-recordings/player/sidebar/PlayerSidebarOverviewSessionTab'+import { PlayerSidebarOverviewTab } from 'scenes/session-recordings/player/sidebar/PlayerSidebarOverviewTab'++const WIDE_OVERVIEW_PX = 960++export function RecordingOverviewPanels(): JSX.Element {+ const { ref, size } = useResizeBreakpoints({ 0: 'narrow', [WIDE_OVERVIEW_PX]: 'wide' })++ return (+ <div ref={ref} data-attr="watch-panel-overview">+ {size === 'wide' ? <WideOverview /> : <PlayerSidebarOverviewTab />}+ </div>+ )+}++function WideOverview(): JSX.Element {+ const { logicProps } = useValues(sessionRecordingPlayerLogic)+ const { snapshotAt } = useValues(playerMetaLogic(logicProps))++ return (+ <div className="flex flex-col gap-2 bg-primary px-2 py-2">+ <TTLWarning />+ <div className="grid grid-cols-3 gap-x-2 gap-y-1">+ <OverviewColumn title="Session" dataAttr="watch-overview-session">+ <PlayerSidebarOverviewSessionTab />+ </OverviewColumn>+ <OverviewColumn title="Person" dataAttr="watch-overview-person">+ <PlayerSidebarOverviewPersonTab />+ </OverviewColumn>+ <OverviewColumn title="Device" dataAttr="watch-overview-device">+ <PlayerSidebarOverviewDeviceTab />+ </OverviewColumn>+ </div>+ <LemonCollapse+ size="small"+ panels={[+ {+ key: 'replay-settings',+ header: 'Settings at the time of the recording',+ content: (+ <SettingsSnapshot at={snapshotAt} scope={OVERVIEW_SNAPSHOT_SCOPE} title="" layout="grid" />+ ),+ },+ ]}+ />+ <PlayerSidebarExperimentsSection />+ <PlayerSidebarOverviewOtherWatchers />+ </div>+ )+}++function OverviewColumn({+ title,+ dataAttr,+ children,+}: {+ title: string+ dataAttr: string+ children: ReactNode+}): JSX.Element {+ // subgrid keeps the headings, top cards and row tables level across columns+ return (+ <div className="grid grid-cols-1 grid-rows-subgrid row-span-3 gap-1 min-w-0" data-attr={dataAttr}>+ <span className="text-xxs font-semibold uppercase tracking-wide text-secondary px-0.5">{title}</span>+ {children}+ </div>+ )+}diff --git a/frontend/src/scenes/session-recordings/player/watch/RecordingSections.tsx b/frontend/src/scenes/session-recordings/player/watch/RecordingSections.tsxnew file mode 100644index 000000000000..5b4032206c2b--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/watch/RecordingSections.tsx@@ -0,0 +1,50 @@+import { useActions, useValues } from 'kea'++import { LemonCollapse } from '@posthog/lemon-ui'++import { integrationsLogic } from 'lib/integrations/integrationsLogic'+import { WatchPanelSection, playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'+import { sessionRecordingPlayerLogic } from 'scenes/session-recordings/player/sessionRecordingPlayerLogic'+import { PlayerSidebarLinkedIssuesTab } from 'scenes/session-recordings/player/sidebar/PlayerSidebarLinkedIssuesTab'++export function RecordingSections(): JSX.Element | null {+ const { sessionPlayerMetaData } = useValues(sessionRecordingPlayerLogic)+ const { getIntegrationsByKind } = useValues(integrationsLogic)+ const { watchPanelOpenSections } = useValues(playerSettingsLogic)+ const { toggleWatchPanelSection } = useActions(playerSettingsLogic)++ const showLinkedIssues =+ getIntegrationsByKind(['linear', 'github', 'gitlab', 'jira']).length > 0 ||+ (sessionPlayerMetaData?.external_references ?? []).length > 0++ const panels = [+ showLinkedIssues && {+ key: 'linked-issues' as WatchPanelSection,+ header: 'Linked issues',+ content: <PlayerSidebarLinkedIssuesTab />,+ dataAttr: 'watch-panel-section-linked-issues',+ },+ ].filter((panel): panel is Exclude<typeof panel, false> => !!panel)++ if (panels.length === 0) {+ return null+ }+ const sectionKeys = panels.map((panel) => panel.key)+ const activeKeys = watchPanelOpenSections.filter((section) => sectionKeys.includes(section))++ return (+ <LemonCollapse+ size="small"+ multiple+ panels={panels}+ activeKeys={activeKeys}+ onChange={(next: WatchPanelSection[]) => {+ for (const key of sectionKeys) {+ if (activeKeys.includes(key) !== next.includes(key)) {+ toggleWatchPanelSection(key)+ }+ }+ }}+ />+ )+}diff --git a/frontend/src/scenes/session-recordings/player/watch/RecordingTitleBlock.tsx b/frontend/src/scenes/session-recordings/player/watch/RecordingTitleBlock.tsxnew file mode 100644index 000000000000..c901d8d526ed--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/watch/RecordingTitleBlock.tsx@@ -0,0 +1,74 @@+import { useValues } from 'kea'++import { PropertyIcon } from 'lib/components/PropertyIcon/PropertyIcon'+import { TZLabel } from 'lib/components/TZLabel'+import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'+import { Link } from 'lib/lemon-ui/Link'+import { humanFriendlyDuration } from 'lib/utils/durations'+import { PlayerMetaExperimentTags } from 'scenes/session-recordings/player/player-meta/PlayerMetaExperimentTags'+import { PinToPlaylistButton } from 'scenes/session-recordings/player/player-meta/PlayerMetaLinks'+import { playerMetaLogic } from 'scenes/session-recordings/player/player-meta/playerMetaLogic'+import { gatherIconProperties } from 'scenes/session-recordings/playlist/gatherIconProperties'+import { sessionRecordingsListPropertiesLogic } from 'scenes/session-recordings/playlist/sessionRecordingsListPropertiesLogic'++import { PersonIcon } from 'products/persons/frontend/components/PersonDisplay'+import { asDisplay, asLink } from 'products/persons/frontend/person-utils'++import { sessionRecordingPlayerLogic } from '../sessionRecordingPlayerLogic'++export function RecordingTitleBlock(): JSX.Element {+ const { logicProps, sessionPlayerMetaData } = useValues(sessionRecordingPlayerLogic)+ const { sessionPerson, loading, startTime } = useValues(playerMetaLogic(logicProps))+ const { recordingPropertiesById } = useValues(sessionRecordingsListPropertiesLogic)++ if (loading) {+ return (+ <div className="flex items-center gap-3">+ <LemonSkeleton.Circle className="w-10 h-10" />+ <div className="flex flex-col gap-1 flex-1">+ <LemonSkeleton className="w-1/3 h-5" />+ <LemonSkeleton className="w-1/2 h-4" />+ </div>+ </div>+ )+ }++ const recordingProperties = sessionPlayerMetaData?.id+ ? recordingPropertiesById[sessionPlayerMetaData.id]+ : undefined+ const iconProperties = gatherIconProperties(recordingProperties, sessionPlayerMetaData ?? undefined)+ const durationSeconds = sessionPlayerMetaData?.recording_duration+ const personName = sessionPerson ? asDisplay(sessionPerson) : 'Unknown user'+ const personHref = asLink(sessionPerson)++ return (+ <div className="flex items-start gap-3 min-w-0" data-attr="watch-panel-title">+ {sessionPerson && <PersonIcon person={sessionPerson} size="lg" className="mr-0 shrink-0" />}+ <div className="flex flex-col gap-0.5 min-w-0 flex-1">+ <h2 className="text-base font-semibold truncate m-0 ph-no-capture">+ {personHref ? (+ <Link to={personHref} subtle data-attr="watch-panel-title-person">+ {personName}+ </Link>+ ) : (+ personName+ )}+ </h2>+ <div className="flex items-center gap-x-2 gap-y-0.5 flex-wrap text-xs text-secondary ph-no-capture">+ {durationSeconds !== undefined && <span>{humanFriendlyDuration(durationSeconds)}</span>}+ {startTime && <TZLabel time={startTime} showPopover={false} />}+ {iconProperties.map(({ property, value, label }) => (+ <span key={property} className="flex items-center gap-x-1">+ <PropertyIcon property={property} value={value} />+ <span>{label}</span>+ </span>+ ))}+ <PlayerMetaExperimentTags />+ </div>+ </div>+ <div className="shrink-0">+ <PinToPlaylistButton />+ </div>+ </div>+ )+}diff --git a/frontend/src/scenes/session-recordings/player/watch/WatchPanel.tsx b/frontend/src/scenes/session-recordings/player/watch/WatchPanel.tsxnew file mode 100644index 000000000000..a05b18039540--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/watch/WatchPanel.tsx@@ -0,0 +1,43 @@+import { useValues } from 'kea'++import { playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'++import { SummarizeRecordingBar } from 'products/replay_vision/frontend/components/SummarizeRecordingBar'+import { visionSurfaceShown } from 'products/replay_vision/frontend/utils/visionSurface'++import { sessionRecordingPlayerLogic } from '../sessionRecordingPlayerLogic'+import { DebugModeBanner } from './DebugModeBanner'+import { MomentTicker } from './MomentTicker'+import { RecordingCommentsList } from './RecordingCommentsList'+import { RecordingDebugSection } from './RecordingDebugSection'+import { RecordingOverviewDisclosure } from './RecordingOverviewDisclosure'+import { RecordingSections } from './RecordingSections'+import { RecordingTitleBlock } from './RecordingTitleBlock'++export function WatchPanel({+ summaryActions,+}: {+ /** Recording actions the host places beside the summarize button. */+ summaryActions?: React.ReactNode+}): JSX.Element | null {+ const { logicProps, sessionRecordingId } = useValues(sessionRecordingPlayerLogic)+ const { debugMode, watchDebugDock } = useValues(playerSettingsLogic)+ if (!sessionRecordingId) {+ return null+ }+ const vision = visionSurfaceShown(logicProps)++ return (+ <div className="flex flex-col gap-4 px-1 pt-3 pb-6" data-attr="watch-panel">+ <DebugModeBanner />+ {vision && <MomentTicker sessionId={sessionRecordingId} />}+ <RecordingTitleBlock />+ <RecordingOverviewDisclosure+ actions={vision ? <SummarizeRecordingBar inline extraActions={summaryActions} /> : summaryActions}+ />+ <RecordingCommentsList sessionId={sessionRecordingId} />+ {debugMode && watchDebugDock === 'bottom' && <RecordingDebugSection />}+ <RecordingSections />+ </div>+ )+}diff --git a/frontend/src/scenes/session-recordings/playlist/FilterChips.tsx b/frontend/src/scenes/session-recordings/playlist/FilterChips.tsxnew file mode 100644index 000000000000..eb69aa7620ca--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/FilterChips.tsx@@ -0,0 +1,139 @@+import { useActions, useValues } from 'kea'+import { ReactNode, useState } from 'react'++import { IconClock, IconEye, IconX } from '@posthog/icons'+import { LemonButton } from '@posthog/lemon-ui'++import { convertSecondsToDuration } from 'lib/components/DurationPicker/DurationPicker'+import { UniversalFilterButton } from 'lib/components/UniversalFilters/UniversalFilterButton'+import { playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'++import { PropertyOperator, RecordingDurationFilter, RecordingUniversalFilters } from '~/types'++import { filterLeaves, removeFilterLeaf } from './filterChipLeaves'+import { defaultRecordingDurationFilter } from './sessionRecordingsPlaylistLogic'++const MAX_VISIBLE_CHIPS = 4++const DURATION_TYPE_LABEL: Record<RecordingDurationFilter['key'], string> = {+ duration: '',+ active_seconds: ' active',+ inactive_seconds: ' inactive',+}++function compactDurationLabel(duration: RecordingDurationFilter): string {+ const operator = duration.operator === PropertyOperator.GreaterThan ? '>' : '<'+ const { timeValue, unit } = convertSecondsToDuration(duration.value || 0)+ return `${operator} ${timeValue}${unit[0]}${DURATION_TYPE_LABEL[duration.key]}`+}++function isDefaultDuration(duration: RecordingDurationFilter): boolean {+ return (+ duration.key === defaultRecordingDurationFilter.key &&+ duration.value === defaultRecordingDurationFilter.value &&+ duration.operator === defaultRecordingDurationFilter.operator+ )+}++export function FilterChips({+ filters,+ setFilters,+}: {+ filters: RecordingUniversalFilters+ setFilters: (filters: Partial<RecordingUniversalFilters>) => void+}): JSX.Element | null {+ const { hideViewedRecordings } = useValues(playerSettingsLogic)+ const { setHideViewedRecordings } = useActions(playerSettingsLogic)+ const [expanded, setExpanded] = useState(false)+ const leaves = filterLeaves(filters.filter_group)++ const chips: ReactNode[] = [+ ...leaves.map(({ path, filter }) => (+ <UniversalFilterButton+ key={path.join('.')}+ filter={filter}+ onClose={() => setFilters({ filter_group: removeFilterLeaf(filters.filter_group, path) })}+ />+ )),+ ...filters.duration.flatMap((duration, index) =>+ isDefaultDuration(duration)+ ? []+ : [+ <FilterChip+ key={`${duration.key}-${index}`}+ icon={<IconClock />}+ onClose={() =>+ setFilters({+ duration: filters.duration.map((d, i) =>+ i === index ? defaultRecordingDurationFilter : d+ ),+ })+ }+ dataAttr="list-filter-chip-duration"+ >+ {compactDurationLabel(duration)}+ </FilterChip>,+ ]+ ),+ ...(hideViewedRecordings+ ? [+ <FilterChip+ key="unwatched"+ icon={<IconEye />}+ onClose={() => setHideViewedRecordings(false)}+ dataAttr="list-filter-chip-unwatched"+ >+ {hideViewedRecordings === 'any-user' ? 'Unwatched by anyone' : 'Unwatched'}+ </FilterChip>,+ ]+ : []),+ ]++ if (chips.length === 0) {+ return null+ }++ const hiddenCount = chips.length - MAX_VISIBLE_CHIPS+ const visible = expanded || hiddenCount <= 0 ? chips : chips.slice(0, MAX_VISIBLE_CHIPS)++ return (+ <div className="flex items-center gap-1 flex-wrap min-w-0" data-attr="list-filter-chips">+ {visible}+ {hiddenCount > 0 && (+ <LemonButton+ size="xsmall"+ type="tertiary"+ onClick={() => setExpanded(!expanded)}+ data-attr={expanded ? 'list-filter-chips-collapse' : 'list-filter-chips-expand'}+ >+ {expanded ? 'Show less' : `+${hiddenCount} more`}+ </LemonButton>+ )}+ </div>+ )+}++function FilterChip({+ icon,+ onClose,+ dataAttr,+ children,+}: {+ icon: ReactNode+ onClose: () => void+ dataAttr: string+ children: ReactNode+}): JSX.Element {+ return (+ <div+ className="UniversalFilterButton UniversalFilterButton--closeable inline-flex items-center ph-no-capture"+ data-attr={dataAttr}+ >+ <div className="flex items-center flex-1 truncate gap-1">+ <span className="shrink-0 text-secondary">{icon}</span>+ <span className="truncate">{children}</span>+ </div>+ <LemonButton size="xsmall" icon={<IconX className="w-3 h-3" />} onClick={onClose} className="p-0.5" />+ </div>+ )+}diff --git a/frontend/src/scenes/session-recordings/playlist/ItemCheckbox.tsx b/frontend/src/scenes/session-recordings/playlist/ItemCheckbox.tsxnew file mode 100644index 000000000000..bfabb9802256--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/ItemCheckbox.tsx@@ -0,0 +1,34 @@+import { useActions, useValues } from 'kea'++import { LemonCheckbox } from 'lib/lemon-ui/LemonCheckbox'++import { SessionRecordingType } from '~/types'++import { MAX_SELECTED_RECORDINGS, sessionRecordingsPlaylistLogic } from './sessionRecordingsPlaylistLogic'++export function ItemCheckbox({ recording }: { recording: SessionRecordingType }): JSX.Element {+ const { selectedRecordingsIds } = useValues(sessionRecordingsPlaylistLogic)+ const { setSelectedRecordingsIds } = useActions(sessionRecordingsPlaylistLogic)++ const checked = selectedRecordingsIds.some((s) => s === recording.id)+ return (+ <LemonCheckbox+ checked={checked}+ data-attr="select-recording"+ aria-label="Select recording"+ disabledReason={+ !checked && selectedRecordingsIds.length >= MAX_SELECTED_RECORDINGS+ ? `Cannot select more than ${MAX_SELECTED_RECORDINGS} recordings at once`+ : undefined+ }+ onChange={() => {+ if (checked) {+ setSelectedRecordingsIds(selectedRecordingsIds.filter((r) => r !== recording.id))+ } else {+ setSelectedRecordingsIds([...selectedRecordingsIds, recording.id])+ }+ }}+ stopPropagation+ />+ )+}diff --git a/frontend/src/scenes/session-recordings/playlist/OngoingRecordingsGroup.tsx b/frontend/src/scenes/session-recordings/playlist/OngoingRecordingsGroup.tsxnew file mode 100644index 000000000000..368d490c2fde--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/OngoingRecordingsGroup.tsx@@ -0,0 +1,48 @@+import { ReactNode, useState } from 'react'++import { IconChevronDown, IconChevronRight, IconLive } from '@posthog/icons'+import { LemonBadge, LemonButton } from '@posthog/lemon-ui'++export function OngoingRecordingsGroup({+ count,+ holdsActive,+ children,+}: {+ count: number+ holdsActive: boolean+ children: ReactNode+}): JSX.Element | null {+ // null follows the selection. A click pins a choice until the selection next moves into the group+ const [choice, setChoice] = useState<boolean | null>(null)+ const [wasHoldingActive, setWasHoldingActive] = useState(holdsActive)+ if (holdsActive !== wasHoldingActive) {+ setWasHoldingActive(holdsActive)+ if (holdsActive) {+ setChoice(null)+ }+ }+ if (count === 0) {+ return null+ }+ const expanded = choice ?? holdsActive++ return (+ <div className="border-b">+ <LemonButton+ fullWidth+ size="xsmall"+ className="rounded-none bg-surface-secondary"+ icon={<IconLive className="text-primary-3000" />}+ sideIcon={expanded ? <IconChevronDown /> : <IconChevronRight />}+ onClick={() => setChoice(!expanded)}+ data-attr="list-ongoing-toggle"+ >+ <span className="flex items-center gap-1 text-[11px] uppercase tracking-wide text-secondary font-semibold">+ Still recording+ <LemonBadge.Number count={count} status="muted" size="small" />+ </span>+ </LemonButton>+ {expanded && children}+ </div>+ )+}diff --git a/frontend/src/scenes/session-recordings/playlist/Playlist.scss b/frontend/src/scenes/session-recordings/playlist/Playlist.scssindex 5f35c4be8a48..cd8d69aef6e2 100644--- a/frontend/src/scenes/session-recordings/playlist/Playlist.scss+++ b/frontend/src/scenes/session-recordings/playlist/Playlist.scss@@ -14,6 +14,10 @@}}+.Playlist__main--stacked .SessionRecordingPlayerWrapper--watch .SessionRecordingPlayerWrapper__player {+ height: clamp(14rem, 34vh, 32rem);+}+.NotebookNode__box .Playlist__list {border-right: 1px solid var(--color-border-primary);}@@ -34,6 +38,10 @@border-left-color: var(--color-accent);}+ &--compact.SessionRecordingPreview--active {+ background-color: var(--color-accent-highlight-secondary);+ }+&:hover {background-color: var(--color-accent-highlight-secondary);}diff --git a/frontend/src/scenes/session-recordings/playlist/Playlist.tsx b/frontend/src/scenes/session-recordings/playlist/Playlist.tsxindex 55f32c05abba..2631818063fd 100644--- a/frontend/src/scenes/session-recordings/playlist/Playlist.tsx+++ b/frontend/src/scenes/session-recordings/playlist/Playlist.tsx@@ -27,8 +27,13 @@ import { DraggableToNotebook } from 'scenes/notebooks/AddToNotebook/DraggableToNimport { useNotebookNode } from 'scenes/notebooks/Nodes/NotebookNodeContext'import { RecordingsUniversalFiltersEmbedButton } from 'scenes/session-recordings/filters/RecordingsUniversalFiltersEmbed'import { playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'+import { OngoingRecordingsGroup } from 'scenes/session-recordings/playlist/OngoingRecordingsGroup'import { playlistFiltersLogic } from 'scenes/session-recordings/playlist/playlistFiltersLogic'+import { ReplayFilterBar } from 'scenes/session-recordings/playlist/ReplayFilterBar'+import { isNewReplayLayout } from 'scenes/session-recordings/playlist/replayLayout'+import { ReplayListHeader } from 'scenes/session-recordings/playlist/ReplayListHeader'import { SessionRecordingPreview } from 'scenes/session-recordings/playlist/SessionRecordingPreview'+import { SessionRecordingPreviewCompact } from 'scenes/session-recordings/playlist/SessionRecordingPreviewCompact'import { sessionRecordingsPlaylistLogic } from 'scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic'import { SessionRecordingsPlaylistTopSettings } from 'scenes/session-recordings/playlist/SessionRecordingsPlaylistSettings'import { SessionRecordingsPlaylistTroubleshooting } from 'scenes/session-recordings/playlist/SessionRecordingsPlaylistTroubleshooting'@@ -71,6 +76,7 @@ export type PlaylistProps = {* offer the generic replay hints. Collections keep their own empty state.*/listEmptyState?: JSX.Element+ watchLayout?: boolean}export function Playlist({@@ -81,8 +87,10 @@ export function Playlist({description,selectInitialItem,listEmptyState,+ watchLayout = false,}: PlaylistProps): JSX.Element {- const { isPlaylistCollapsed } = useValues(playerSettingsLogic)+ const { isPlaylistCollapsed, replayLayout } = useValues(playerSettingsLogic)+ const newLayout = watchLayout && isNewReplayLayout(replayLayout)const { setPlaylistCollapsed } = useActions(playerSettingsLogic)const collapseButton = (<LemonButton@@ -106,6 +114,8 @@ export function Playlist({const notebookNode = useNotebookNode()const embedded = !!notebookNode+ const watchListHeader = newLayout && !notebookNode+ const watchFilterBar = watchListHeader && type !== 'collection'// bound outside hereconst {@@ -117,6 +127,7 @@ export function Playlist({otherRecordings,hasNext,selectedRecordingOutsideFilters,+ selectMode,} = useValues(sessionRecordingsPlaylistLogic)const { maybeLoadSessionRecordings, setFilters, setSelectedRecordingId } =useActions(sessionRecordingsPlaylistLogic)@@ -147,6 +158,18 @@ export function Playlist({lastScrollPositionRef.current = e.currentTarget.scrollTop}+ const renderRow = ({ item, isActive }: { item: SessionRecordingType; isActive: boolean }): JSX.Element =>+ newLayout ? (+ <SessionRecordingPreviewCompact recording={item} isActive={isActive} selectable={selectMode} />+ ) : (+ <SessionRecordingPreview recording={item} isActive={isActive} selectable />+ )++ // Still-ingesting recordings fold above the results in the watch layout, so the list opens on finished ones.+ const ongoingRecordings = newLayout ? otherRecordings.filter((r) => r.ongoing) : []+ const finishedRecordings =+ ongoingRecordings.length > 0 ? otherRecordings.filter((r) => !r.ongoing) : otherRecordings+const sections: PlaylistSection[] = []if (type === 'collection' || pinnedRecordings.length > 0) {@@ -159,7 +182,7 @@ export function Playlist({</div>),items: pinnedRecordings,- render: ({ item, isActive }) => <SessionRecordingPreview recording={item} isActive={isActive} selectable />,+ render: renderRow,initiallyOpen: true,})} else {@@ -168,12 +191,12 @@ export function Playlist({title: (<div className="flex flex-row deprecated-space-x-1 items-center"><span>Results</span>- <LemonBadge.Number count={otherRecordings.length} status="muted" size="small" />+ <LemonBadge.Number count={finishedRecordings.length} status="muted" size="small" /></div>),- items: otherRecordings,+ items: finishedRecordings,initiallyOpen: !pinnedRecordings.length,- render: ({ item, isActive }) => <SessionRecordingPreview recording={item} isActive={isActive} selectable />,+ render: renderRow,footer: (<div className="p-4"><div className="h-10 flex items-center justify-center gap-2 text-secondary">@@ -280,7 +303,18 @@ export function Playlist({return (<div className="flex flex-col min-w-60 h-full">- {!notebookNode && type !== 'collection' && (+ {watchFilterBar && (+ <div className="mb-2">+ <ReplayFilterBar+ filters={filters}+ setFilters={setFilters}+ totalFiltersCount={totalFiltersCount}+ currentSessionRecordingId={activeSessionRecordingId}+ onReload={() => maybeLoadSessionRecordings()}+ />+ </div>+ )}+ {!watchFilterBar && !notebookNode && type !== 'collection' && (<div className="mb-2 flex gap-2"><DraggableToNotebook className="flex-1" href={urls.replay(ReplayTabs.Home, filters)}><RecordingsUniversalFiltersEmbedButton@@ -314,7 +348,7 @@ export function Playlist({ref={playlistRef}data-attr="session-recordings-playlist"className={clsx(- 'Playlist flex flex-row items-start justify-start h-full w-full min-w-60 min-h-82 overflow-hidden border rounded',+ 'Playlist flex flex-row items-start justify-start h-full w-full min-w-60 min-h-82 [[data-stacked]_&]:min-h-0 overflow-hidden border rounded',{'Playlist--wide': size !== 'small','Playlist--embedded border-0': embedded,@@ -327,21 +361,32 @@ export function Playlist({><div className="flex flex-col relative w-full bg-bg-light overflow-hidden h-full Playlist__list"><div className="relative">- <DraggableToNotebook href={urls.replay(ReplayTabs.Home, filters)}>- <div className="shrink-0 bg-bg-3000 flex justify-between items-center gap-0.5 whitespace-nowrap border-b">- {title && <TitleWithCount title={title} count={itemsCount} />}- <div className="flex items-center gap-0.5 flex-1 min-w-0">- <SessionRecordingsPlaylistTopSettings- filters={filters}- setFilters={setFilters}- type={type}- shortId={type === 'collection' ? logicKey : undefined}- />- <LemonDivider vertical className="my-1 mx-0.5" />- {collapseButton}+ {watchListHeader && (+ <ReplayListHeader+ filters={filters}+ setFilters={setFilters}+ collapseButton={collapseButton}+ type={type}+ shortId={type === 'collection' ? logicKey : undefined}+ />+ )}+ {!watchListHeader && (+ <DraggableToNotebook href={urls.replay(ReplayTabs.Home, filters)}>+ <div className="shrink-0 bg-bg-3000 flex justify-between items-center gap-0.5 whitespace-nowrap border-b">+ {title && <TitleWithCount title={title} count={itemsCount} />}+ <div className="flex items-center gap-0.5 flex-1 min-w-0">+ <SessionRecordingsPlaylistTopSettings+ filters={filters}+ setFilters={setFilters}+ type={type}+ shortId={type === 'collection' ? logicKey : undefined}+ />+ <LemonDivider vertical className="my-1 mx-0.5" />+ {collapseButton}+ </div></div>- </div>- </DraggableToNotebook>+ </DraggableToNotebook>+ )}<LemonTableLoader loading={sessionRecordingsResponseLoading} /></div>{selectedRecordingOutsideFilters && (@@ -350,7 +395,24 @@ export function Playlist({until you close it.</LemonBanner>)}- <div className="overflow-y-auto flex-1 min-h-0" onScroll={handleScroll} ref={setScrollEl}>+ <div+ className="overflow-y-auto flex-1 min-h-0 [scrollbar-gutter:stable] [scrollbar-width:thin]"+ onScroll={handleScroll}+ ref={setScrollEl}+ >+ <OngoingRecordingsGroup+ count={ongoingRecordings.length}+ holdsActive={ongoingRecordings.some((r) => r.id === activeItemId)}+ >+ <ListSection+ key="ongoing"+ items={ongoingRecordings}+ render={renderRow}+ onClick={onChangeActiveItem}+ activeItemId={activeItemId}+ scrollEl={scrollEl}+ />+ </OngoingRecordingsGroup>{sectionCount > 1 ? (<LemonCollapsedefaultActiveKeys={openSections}diff --git a/frontend/src/scenes/session-recordings/playlist/ReplayBulkBar.tsx b/frontend/src/scenes/session-recordings/playlist/ReplayBulkBar.tsxnew file mode 100644index 000000000000..61d06559417d--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/ReplayBulkBar.tsx@@ -0,0 +1,81 @@+import { useActions, useValues } from 'kea'++import { IconEllipsis } from '@posthog/icons'+import { LemonButton } from '@posthog/lemon-ui'++import { LemonMenu, LemonMenuItem } from 'lib/lemon-ui/LemonMenu/LemonMenu'+import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'++import { AccessControlLevel, AccessControlResourceType } from '~/types'++import { sessionRecordingsPlaylistLogic } from './sessionRecordingsPlaylistLogic'+import { AddToCollectionModal, BulkScanMenuItem, ConfirmDeleteRecordings } from './SessionRecordingsPlaylistSettings'++export function ReplayBulkBar({ type, shortId }: { type: 'filters' | 'collection'; shortId?: string }): JSX.Element {+ const { selectedRecordingsIds } = useValues(sessionRecordingsPlaylistLogic)+ const {+ setIsAddToCollectionModalOpen,+ setIsDeleteSelectedRecordingsDialogOpen,+ handleBulkMarkAsViewed,+ handleBulkMarkAsNotViewed,+ handleBulkDeleteFromPlaylist,+ } = useActions(sessionRecordingsPlaylistLogic)+ const accessControlDisabledReason = getAccessControlDisabledReason(+ AccessControlResourceType.SessionRecording,+ AccessControlLevel.Editor+ )+ const moreItems: LemonMenuItem[] = [+ {+ label: 'Mark as not viewed',+ onClick: () => handleBulkMarkAsNotViewed(shortId),+ 'data-attr': 'mark-as-not-viewed',+ },+ ...(type === 'collection' && shortId+ ? [+ {+ label: 'Remove from this collection',+ onClick: () => handleBulkDeleteFromPlaylist(shortId),+ 'data-attr': 'remove-from-collection',+ disabledReason: accessControlDisabledReason,+ },+ ]+ : []),+ { key: 'bulk-scan-recordings', label: () => <BulkScanMenuItem />, custom: true },+ ]++ return (+ <div className="flex flex-1 items-center gap-1 flex-wrap text-xs" data-attr="list-bulk-bar">+ <span className="font-semibold px-1">{selectedRecordingsIds.length} selected</span>+ <LemonButton+ size="xsmall"+ onClick={() => setIsAddToCollectionModalOpen(true)}+ disabledReason={accessControlDisabledReason}+ data-attr="add-to-collection"+ >+ Add to collection+ </LemonButton>+ <LemonButton size="xsmall" onClick={() => handleBulkMarkAsViewed(shortId)} data-attr="mark-as-viewed">+ Mark watched+ </LemonButton>+ <LemonButton+ size="xsmall"+ status="danger"+ onClick={() => setIsDeleteSelectedRecordingsDialogOpen(true)}+ disabledReason={accessControlDisabledReason}+ data-attr="delete-recordings"+ >+ Delete+ </LemonButton>+ <LemonMenu items={moreItems} placement="bottom-end" buttonSize="xsmall">+ <LemonButton+ size="xsmall"+ icon={<IconEllipsis />}+ aria-label="More actions"+ data-attr="bulk-action-menu"+ />+ </LemonMenu>+ <ConfirmDeleteRecordings shortId={shortId} />+ <AddToCollectionModal shortId={shortId} />+ </div>+ )+}diff --git a/frontend/src/scenes/session-recordings/playlist/ReplayFilterBar.tsx b/frontend/src/scenes/session-recordings/playlist/ReplayFilterBar.tsxnew file mode 100644index 000000000000..c076c105675e--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/ReplayFilterBar.tsx@@ -0,0 +1,92 @@+import { deepEqual as equal } from 'fast-equals'+import { useActions, useValues } from 'kea'+import { useState } from 'react'++import { IconFilter, IconRefresh } from '@posthog/icons'+import { LemonBadge, LemonButton } from '@posthog/lemon-ui'++import { useMaxTool } from 'scenes/max/useMaxTool'+import { SaveFiltersModal } from 'scenes/session-recordings/filters/RecordingsUniversalFiltersEmbed'+import { sessionRecordingSavedFiltersLogic } from 'scenes/session-recordings/filters/sessionRecordingSavedFiltersLogic'+import { useRecordingFiltersAssist } from 'scenes/session-recordings/filters/useRecordingFiltersAssist'++import { RecordingUniversalFilters } from '~/types'++import { FilterChips } from './FilterChips'+import { playlistFiltersLogic } from './playlistFiltersLogic'+import { comparableRecordingFilters } from './playlistUtils'+import { SavedFilterEditedBar } from './SavedFilterEditedBar'+import { SavedFilterSelect } from './SavedFilterSelect'+import { sessionRecordingsPlaylistLogic } from './sessionRecordingsPlaylistLogic'++export function ReplayFilterBar({+ filters,+ setFilters,+ totalFiltersCount,+ currentSessionRecordingId,+ onReload,+}: {+ filters: RecordingUniversalFilters+ setFilters: (filters: Partial<RecordingUniversalFilters>) => void+ totalFiltersCount?: number+ currentSessionRecordingId?: string+ onReload: () => void+}): JSX.Element {+ const { sessionRecordingsResponseLoading } = useValues(sessionRecordingsPlaylistLogic)+ const { isFiltersExpanded } = useValues(playlistFiltersLogic)+ const { setIsFiltersExpanded } = useActions(playlistFiltersLogic)+ const { appliedSavedFilter, appliedSavedFilterFilters } = useValues(sessionRecordingSavedFiltersLogic)+ const { applyFilters } = useRecordingFiltersAssist({ filters, setFilters, currentSessionRecordingId })+ // registers the filter tool so the PostHog AI side panel can drive this list+ useMaxTool({+ identifier: 'filter_session_recordings',+ context: { current_filters: filters, current_session_id: currentSessionRecordingId },+ callback: applyFilters,+ initialMaxPrompt: 'Show me recordings where ',+ suggestions: [+ 'Show recordings of people who visited signup in the last 24 hours',+ 'Show recordings showing user frustration',+ 'Show recordings of people who faced bugs',+ ],+ onMaxOpen: () => setIsFiltersExpanded(false),+ })+ const [saveModalOpen, setSaveModalOpen] = useState(false)++ const edited = !!appliedSavedFilter && !equal(appliedSavedFilterFilters, comparableRecordingFilters(filters))++ return (+ <div className="flex flex-col gap-1">+ <div className="flex items-start gap-1" data-attr="list-filter-bar">+ <div className="flex flex-1 min-w-0 items-center gap-1 flex-wrap">+ <LemonButton+ size="small"+ type="secondary"+ active={isFiltersExpanded}+ icon={<IconFilter />}+ onClick={() => setIsFiltersExpanded(!isFiltersExpanded)}+ tooltip={isFiltersExpanded ? 'Hide filters' : 'Add a filter'}+ aria-label="Add a filter"+ data-attr="filter-recordings-button"+ >+ {totalFiltersCount ? <LemonBadge.Number count={totalFiltersCount} size="small" /> : null}+ </LemonButton>+ <SavedFilterSelect edited={edited} onSaveCurrent={() => setSaveModalOpen(true)} />+ <FilterChips filters={filters} setFilters={setFilters} />+ </div>+ <LemonButton+ size="small"+ type="secondary"+ className="shrink-0"+ icon={<IconRefresh />}+ loading={sessionRecordingsResponseLoading}+ onClick={onReload}+ tooltip="Refresh list"+ aria-label="Refresh list"+ data-attr="refresh-recordings-list"+ />+ </div>+ {edited && <SavedFilterEditedBar filters={filters} onSaveAsCopy={() => setSaveModalOpen(true)} />}+ <SaveFiltersModal isOpen={saveModalOpen} setIsOpen={setSaveModalOpen} filters={filters} />+ </div>+ )+}diff --git a/frontend/src/scenes/session-recordings/playlist/ReplayListColumn.tsx b/frontend/src/scenes/session-recordings/playlist/ReplayListColumn.tsxnew file mode 100644index 000000000000..5ad3de25a416--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/ReplayListColumn.tsx@@ -0,0 +1,190 @@+import { useActions, useValues } from 'kea'+import { ReactNode, useEffect } from 'react'++import { IconSparkles } from '@posthog/icons'+import { LemonBadge, LemonSegmentedButton, Spinner } from '@posthog/lemon-ui'++import { colonDelimitedDuration } from 'lib/utils/durations'+import { SessionRecordingPlayerLogicProps } from 'scenes/session-recordings/player/sessionRecordingPlayerLogic'++import { SessionRecordingType } from '~/types'++import { PersonIcon } from 'products/persons/frontend/components/PersonDisplay'+import { asDisplay } from 'products/persons/frontend/person-utils'+import { RecordingMoments } from 'products/replay_vision/frontend/components/RecordingMoments'+import { observationsDockLogic } from 'products/replay_vision/frontend/logics/observationsDockLogic'+import { momentCount } from 'products/replay_vision/frontend/utils/recordingTimeline'++import { ReplayListPicksMode, ReplayListSegment, replayListColumnLogic } from './replayListColumnLogic'+import { sessionRecordingsPlaylistLogic } from './sessionRecordingsPlaylistLogic'+import { usePlayerMounted } from './usePlayerMounted'++export interface ReplayListColumnProps {+ logicKey: string+ recordingsList: ReactNode+ /** The What to watch list, when the picks experiment offers one. */+ picksList?: ReactNode+ picksMode: ReplayListPicksMode+ unwatchedPicksCount?: number+ onPicksSelected?: (selected: boolean) => void+}++export function ReplayListColumn(props: ReplayListColumnProps): JSX.Element {+ const { activeSessionRecording } = useValues(sessionRecordingsPlaylistLogic)+ return activeSessionRecording ? (+ <ReplayListColumnForRecording {...props} recording={activeSessionRecording} />+ ) : (+ <ReplayListColumnView {...props} recording={null} momentsAvailable={null} />+ )+}++/** Scans shows once the recording has an observation or a summary on the way, so an empty pane never opens. */+function ReplayListColumnForRecording({+ recording,+ ...props+}: ReplayListColumnProps & { recording: SessionRecordingType }): JSX.Element {+ const { observations, summarizePending, hasLoadedObservations } = useValues(+ observationsDockLogic({ sessionId: recording.id })+ )+ const momentsAvailable = observations.length > 0 || summarizePending ? true : hasLoadedObservations ? false : null+ return <ReplayListColumnView {...props} recording={recording} momentsAvailable={momentsAvailable} />+}++function ReplayListColumnView({+ logicKey,+ recordingsList,+ picksList,+ picksMode,+ unwatchedPicksCount = 0,+ onPicksSelected,+ recording,+ momentsAvailable,+}: ReplayListColumnProps & { recording: SessionRecordingType | null; momentsAvailable: boolean | null }): JSX.Element {+ const logic = replayListColumnLogic({ logicKey })+ const { effectiveSegmentFor } = useValues(logic)+ const { setSegment, settleSegment } = useActions(logic)++ const playerLogicProps: SessionRecordingPlayerLogicProps | null = recording+ ? { playerKey: logicKey, sessionRecordingId: recording.id, watchLayout: true }+ : null+ const segment = effectiveSegmentFor(picksMode, momentsAvailable)+ useEffect(() => {+ settleSegment(picksMode, momentsAvailable)+ }, [picksMode, momentsAvailable, settleSegment])++ const options = [+ ...(picksList+ ? [+ {+ value: 'picks' as const,+ label: (+ <span className="flex items-center gap-1">+ <span>What to watch</span>+ {unwatchedPicksCount > 0 && (+ <LemonBadge.Number count={unwatchedPicksCount} size="small" status="muted" />+ )}+ </span>+ ),+ 'data-attr': 'list-segment-picks',+ },+ ]+ : []),+ {+ value: 'recordings' as const,+ label: picksList && momentsAvailable ? 'All' : 'All recordings',+ 'data-attr': 'list-segment-recordings',+ },+ ...(momentsAvailable && playerLogicProps+ ? [+ {+ value: 'moments' as const,+ label: (+ <span className="flex items-center gap-1">+ <IconSparkles />+ <span>Scans</span>+ <MomentsBadge sessionId={playerLogicProps.sessionRecordingId} />+ </span>+ ),+ 'data-attr': 'list-segment-moments',+ },+ ]+ : []),+ ]++ return (+ <div className="flex flex-col h-full min-h-0">+ {options.length > 1 && (+ <LemonSegmentedButton+ size="small"+ fullWidth+ className="mb-2"+ value={segment}+ onChange={(next: ReplayListSegment) => {+ setSegment(next)+ if ((next === 'picks') !== (segment === 'picks')) {+ onPicksSelected?.(next === 'picks')+ }+ }}+ options={options}+ />+ )}+ <div className="flex flex-col flex-1 min-h-0">+ {segment === 'picks' ? (+ picksList+ ) : segment === 'moments' && playerLogicProps && recording ? (+ <MomentsSegment+ key={recording.id}+ playerLogicProps={playerLogicProps}+ personDisplay={asDisplay(recording.person)}+ person={recording.person}+ durationSeconds={recording.recording_duration}+ />+ ) : (+ recordingsList+ )}+ </div>+ </div>+ )+}++function MomentsBadge({ sessionId }: { sessionId: string }): JSX.Element | null {+ const { timeline } = useValues(observationsDockLogic({ sessionId }))+ const count = momentCount(timeline)+ return count > 0 ? <LemonBadge.Number count={count} size="small" status="muted" /> : null+}++function MomentsSegment({+ playerLogicProps,+ personDisplay,+ person,+ durationSeconds,+}: {+ playerLogicProps: SessionRecordingPlayerLogicProps+ personDisplay: string+ person: SessionRecordingType['person']+ durationSeconds: number | undefined+}): JSX.Element {+ const playerState = usePlayerMounted(playerLogicProps)+ if (playerState === 'waiting') {+ return (+ <div className="flex items-center gap-2 text-muted p-4">+ <Spinner /> Loading…+ </div>+ )+ }+ if (playerState === 'missing') {+ return <p className="text-muted text-sm p-4 m-0">Open a recording to see its scans.</p>+ }+ return (+ <div className="flex flex-col flex-1 min-h-0 border rounded bg-surface-primary overflow-hidden">+ <div className="flex items-center gap-2 px-2 py-1.5 border-b text-xs ph-no-capture">+ <PersonIcon person={person} size="sm" className="mr-0" />+ <span className="font-medium truncate flex-1">{personDisplay}</span>+ {durationSeconds !== undefined && (+ <span className="text-secondary tabular-nums">{colonDelimitedDuration(durationSeconds)}</span>+ )}+ </div>+ <RecordingMoments sessionId={playerLogicProps.sessionRecordingId} playerLogicProps={playerLogicProps} />+ </div>+ )+}diff --git a/frontend/src/scenes/session-recordings/playlist/ReplayListColumnWithPicks.tsx b/frontend/src/scenes/session-recordings/playlist/ReplayListColumnWithPicks.tsxnew file mode 100644index 000000000000..4ec2f02d568a--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/ReplayListColumnWithPicks.tsx@@ -0,0 +1,32 @@+import { useActions, useMountedLogic, useValues } from 'kea'+import { ReactNode } from 'react'++import { WatchPicksList } from 'products/replay_vision/frontend/replay_scanners/components/WatchPicksList'+import { watchPicksLogic } from 'products/replay_vision/frontend/replay_scanners/watchPicksLogic'+import { watchPicksStarterLogic } from 'products/replay_vision/frontend/replay_scanners/watchPicksStarterLogic'++import { ReplayListColumn } from './ReplayListColumn'++export function ReplayListColumnWithPicks({+ logicKey,+ recordingsList,+}: {+ logicKey: string+ recordingsList: ReactNode+}): JSX.Element {+ const picksLogic = useMountedLogic(watchPicksLogic)+ const { effectiveListMode, unwatchedCount } = useValues(picksLogic)+ const { setListMode } = useActions(picksLogic)+ useMountedLogic(watchPicksStarterLogic(picksLogic.props))++ return (+ <ReplayListColumn+ logicKey={logicKey}+ recordingsList={recordingsList}+ picksList={<WatchPicksList />}+ picksMode={effectiveListMode}+ unwatchedPicksCount={unwatchedCount}+ onPicksSelected={(selected) => setListMode(selected ? 'picks' : 'recordings')}+ />+ )+}diff --git a/frontend/src/scenes/session-recordings/playlist/ReplayListHeader.tsx b/frontend/src/scenes/session-recordings/playlist/ReplayListHeader.tsxnew file mode 100644index 000000000000..d7bbcfe7f9cd--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/ReplayListHeader.tsx@@ -0,0 +1,148 @@+import { useActions, useValues } from 'kea'+import { ReactNode, useEffect } from 'react'++import { IconCheckbox, IconChevronDown, IconGear } from '@posthog/icons'+import { LemonButton, LemonCheckbox, LemonDivider } from '@posthog/lemon-ui'++import { LemonMenu } from 'lib/lemon-ui/LemonMenu/LemonMenu'+import { Tooltip } from 'lib/lemon-ui/Tooltip'++import { RecordingUniversalFilters } from '~/types'++import { ReplayBulkBar } from './ReplayBulkBar'+import { MAX_SELECTED_RECORDINGS, sessionRecordingsPlaylistLogic } from './sessionRecordingsPlaylistLogic'+import { useWatchSettingsMenuItems, useWatchViewMenuItems, watchSortLabel } from './watchListViewMenuItems'++export function ReplayListHeader({+ filters,+ setFilters,+ collapseButton,+ type = 'filters',+ shortId,+}: {+ filters: RecordingUniversalFilters+ setFilters: (filters: Partial<RecordingUniversalFilters>) => void+ collapseButton: ReactNode+ type?: 'filters' | 'collection'+ shortId?: string+}): JSX.Element {+ const { selectedRecordingsIds, otherRecordings, visiblePinnedRecordings, listSort, selectMode } =+ useValues(sessionRecordingsPlaylistLogic)+ const { setSelectedRecordingsIds, setSelectMode } = useActions(sessionRecordingsPlaylistLogic)+ const viewItems = useWatchViewMenuItems(filters, setFilters)+ const settingsItems = useWatchSettingsMenuItems()++ useEffect(() => {+ if (!selectMode) {+ return+ }+ const onKeyDown = (event: KeyboardEvent): void => {+ // An open dialog or menu owns Escape.+ if (event.key === 'Escape' && !document.querySelector('.LemonModal, .Popover')) {+ setSelectMode(false)+ }+ }+ document.addEventListener('keydown', onKeyDown)+ return () => document.removeEventListener('keydown', onKeyDown)+ }, [selectMode, setSelectMode])++ const recordings = type === 'filters' ? otherRecordings.filter((r) => !r.ongoing) : visiblePinnedRecordings+ const hasOngoing = type === 'filters' && recordings.length < otherRecordings.length+ const allSelected = recordings.length > 0 && recordings.every((r) => selectedRecordingsIds.includes(r.id))+ const selectAllDisabledReason =+ recordings.length === 0+ ? 'No recordings'+ : recordings.length > MAX_SELECTED_RECORDINGS+ ? `Cannot select more than ${MAX_SELECTED_RECORDINGS} recordings at once`+ : undefined++ return (+ <div+ className="shrink-0 bg-bg-3000 flex items-center gap-0.5 whitespace-nowrap border-b text-xs"+ data-attr="list-header-bar"+ >+ {selectMode ? (+ <>+ <Tooltip+ title={+ selectAllDisabledReason+ ? undefined+ : hasOngoing+ ? 'Select all finished recordings'+ : 'Select all recordings'+ }+ >+ <span className="flex ml-[7px] mr-1">+ <LemonCheckbox+ disabledReason={selectAllDisabledReason}+ checked={allSelected}+ onChange={(checked) =>+ setSelectedRecordingsIds(checked ? recordings.map((r) => r.id) : [])+ }+ stopPropagation+ data-attr="select-all-recordings"+ aria-label="Select all recordings"+ />+ </span>+ </Tooltip>+ {selectedRecordingsIds.length > 0 ? (+ <ReplayBulkBar type={type} shortId={shortId} />+ ) : (+ <span className="text-secondary px-1">Select recordings</span>+ )}+ <LemonButton+ size="xsmall"+ type="secondary"+ className="ml-auto mr-1"+ onClick={() => setSelectMode(false)}+ tooltip="Done selecting (Esc)"+ data-attr="list-select-done"+ >+ Done+ </LemonButton>+ </>+ ) : (+ <>+ <LemonButton+ size="xsmall"+ icon={<IconCheckbox />}+ className="ml-1"+ onClick={() => setSelectMode(true)}+ disabledReason={recordings.length === 0 ? 'No recordings' : undefined}+ data-attr="list-select-mode"+ >+ Select+ </LemonButton>+ <div className="ml-auto flex items-center gap-0.5">+ <LemonMenu+ items={viewItems}+ placement="bottom-end"+ buttonSize="xsmall"+ closeOnClickInside={false}+ >+ <LemonButton size="xsmall" sideIcon={<IconChevronDown />} data-attr="list-view-menu">+ {watchSortLabel(listSort.order ?? filters.order)}+ </LemonButton>+ </LemonMenu>+ <LemonMenu+ items={settingsItems}+ placement="bottom-end"+ buttonSize="xsmall"+ closeOnClickInside={false}+ >+ <LemonButton+ size="xsmall"+ icon={<IconGear />}+ tooltip="List settings"+ aria-label="List settings"+ data-attr="list-settings-menu"+ />+ </LemonMenu>+ <LemonDivider vertical className="my-1 mx-0.5" />+ {collapseButton}+ </div>+ </>+ )}+ </div>+ )+}diff --git a/frontend/src/scenes/session-recordings/playlist/SavedFilterEditedBar.tsx b/frontend/src/scenes/session-recordings/playlist/SavedFilterEditedBar.tsxnew file mode 100644index 000000000000..c29150d7a493--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/SavedFilterEditedBar.tsx@@ -0,0 +1,79 @@+import { useActions, useValues } from 'kea'+import { useState } from 'react'++import { LemonButton, lemonToast } from '@posthog/lemon-ui'++import { sessionRecordingSavedFiltersLogic } from 'scenes/session-recordings/filters/sessionRecordingSavedFiltersLogic'++import { RecordingUniversalFilters } from '~/types'++import { updatePlaylist } from './playlistUtils'+import { stripSessionIds } from './playlistUtils'+import { sessionRecordingsPlaylistLogic } from './sessionRecordingsPlaylistLogic'++export function SavedFilterEditedBar({+ filters,+ onSaveAsCopy,+}: {+ filters: RecordingUniversalFilters+ onSaveAsCopy: () => void+}): JSX.Element | null {+ const { appliedSavedFilter, appliedSavedFilterFilters } = useValues(sessionRecordingSavedFiltersLogic)+ const { loadSavedFilters, setAppliedSavedFilter } = useActions(sessionRecordingSavedFiltersLogic)+ const { applySavedFilter } = useActions(sessionRecordingsPlaylistLogic)+ const [updating, setUpdating] = useState(false)+ if (!appliedSavedFilter) {+ return null+ }++ const update = async (): Promise<void> => {+ setUpdating(true)+ try {+ const updated = await updatePlaylist(+ appliedSavedFilter.short_id,+ { filters: stripSessionIds(filters), type: 'filters' },+ false+ )+ loadSavedFilters()+ setAppliedSavedFilter(updated)+ } catch {+ lemonToast.error('Could not update the saved filter. Please try again.')+ } finally {+ setUpdating(false)+ }+ }++ return (+ <div+ className="flex items-center gap-2 flex-wrap rounded border border-warning bg-warning-highlight px-2 py-1 text-xs"+ data-attr="list-saved-filter-edited"+ >+ <span className="text-secondary">Saved filter changed.</span>+ <LemonButton+ size="xsmall"+ type="secondary"+ loading={updating}+ onClick={() => void update()}+ className="max-w-60"+ truncate+ data-attr="list-saved-filter-update"+ >+ Update "{appliedSavedFilter.name || 'Unnamed'}"+ </LemonButton>+ <LemonButton size="xsmall" onClick={onSaveAsCopy} data-attr="list-saved-filter-save-copy">+ Save as copy+ </LemonButton>+ <LemonButton+ size="xsmall"+ onClick={() => {+ if (appliedSavedFilterFilters) {+ applySavedFilter(appliedSavedFilterFilters)+ }+ }}+ data-attr="list-saved-filter-revert"+ >+ Revert+ </LemonButton>+ </div>+ )+}diff --git a/frontend/src/scenes/session-recordings/playlist/SavedFilterSelect.tsx b/frontend/src/scenes/session-recordings/playlist/SavedFilterSelect.tsxnew file mode 100644index 000000000000..0acf58aed669--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/SavedFilterSelect.tsx@@ -0,0 +1,104 @@+import { useActions, useValues } from 'kea'+import { useEffect } from 'react'++import { IconChevronDown, IconFilter } from '@posthog/icons'+import { LemonButton } from '@posthog/lemon-ui'++import { LemonMenu, LemonMenuItems } from 'lib/lemon-ui/LemonMenu/LemonMenu'+import { sessionRecordingSavedFiltersLogic } from 'scenes/session-recordings/filters/sessionRecordingSavedFiltersLogic'++import { SessionRecordingPlaylistType } from '~/types'++import { playlistFiltersLogic } from './playlistFiltersLogic'+import { stripSessionIds } from './playlistUtils'+import { asUniversalFilters, sessionRecordingsPlaylistLogic } from './sessionRecordingsPlaylistLogic'++const savedFilterName = (filter: SessionRecordingPlaylistType): string =>+ filter.name || filter.derived_name || 'Unnamed'++export function SavedFilterSelect({+ edited,+ onSaveCurrent,+}: {+ edited: boolean+ onSaveCurrent: () => void+}): JSX.Element {+ const { savedFilters, appliedSavedFilter } = useValues(sessionRecordingSavedFiltersLogic)+ const { setAppliedSavedFilter, loadSavedFiltersIfNeeded } = useActions(sessionRecordingSavedFiltersLogic)+ const { resetFilters, applySavedFilter } = useActions(sessionRecordingsPlaylistLogic)+ const { setIsFiltersExpanded, setActiveFilterTab } = useActions(playlistFiltersLogic)++ useEffect(() => {+ loadSavedFiltersIfNeeded()+ }, [loadSavedFiltersIfNeeded])++ const apply = (filter: SessionRecordingPlaylistType): void => {+ const universal = asUniversalFilters(filter.filters)+ if (!universal) {+ return+ }+ applySavedFilter(stripSessionIds(universal))+ setAppliedSavedFilter(filter)+ }++ const items: LemonMenuItems = [+ {+ items: [+ {+ label: 'All recordings',+ active: !appliedSavedFilter,+ onClick: () => {+ resetFilters()+ setAppliedSavedFilter(null)+ },+ 'data-attr': 'list-saved-filter-reset',+ },+ ],+ },+ ...(savedFilters.results.length > 0+ ? [+ {+ title: 'Saved filters',+ items: savedFilters.results.map((filter) => ({+ label: savedFilterName(filter),+ active: filter.short_id === appliedSavedFilter?.short_id,+ onClick: () => apply(filter),+ 'data-attr': 'list-saved-filter-apply',+ })),+ },+ ]+ : []),+ {+ items: [+ { label: 'Save current filters', onClick: onSaveCurrent, 'data-attr': 'list-saved-filter-save' },+ {+ label: 'Manage saved filters',+ onClick: () => {+ setActiveFilterTab('saved')+ setIsFiltersExpanded(true)+ },+ 'data-attr': 'list-saved-filter-manage',+ },+ ],+ },+ ]++ return (+ <LemonMenu items={items} placement="bottom-start" buttonSize="small">+ <LemonButton+ size="small"+ type="secondary"+ active={!!appliedSavedFilter}+ icon={appliedSavedFilter ? <IconFilter /> : undefined}+ sideIcon={<IconChevronDown />}+ className="max-w-60"+ truncate+ data-attr="list-saved-filter-select"+ >+ {appliedSavedFilter+ ? `${savedFilterName(appliedSavedFilter)}${edited ? ' (edited)' : ''}`+ : 'All recordings'}+ </LemonButton>+ </LemonMenu>+ )+}diff --git a/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreview.tsx b/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreview.tsxindex c18ddbe5b4bf..a13c41d3d560 100644--- a/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreview.tsx+++ b/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreview.tsx@@ -1,7 +1,7 @@import './SessionRecordingPreview.scss'import clsx from 'clsx'-import { useActions, useValues } from 'kea'+import { useValues } from 'kea'import { memo } from 'react'import { IconBug, IconCursorClick, IconHourglass, IconKeyboard, IconLive } from '@posthog/icons'@@ -9,7 +9,6 @@ import { LemonTag } from '@posthog/lemon-ui'import { TZLabel } from 'lib/components/TZLabel'import { SESSION_RECORDINGS_TTL_WARNING_THRESHOLD_DAYS } from 'lib/constants'-import { LemonCheckbox } from 'lib/lemon-ui/LemonCheckbox'import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'import { Tooltip } from 'lib/lemon-ui/Tooltip'import { colonDelimitedDuration } from 'lib/utils/durations'@@ -24,13 +23,10 @@ import { SessionRecordingType } from '~/types'import { asDisplay } from 'products/persons/frontend/person-utils'import { gatherIconProperties } from './gatherIconProperties'+import { ItemCheckbox } from './ItemCheckbox'import { PropertyIcons } from './PropertyIcons'import { sessionRecordingsListPropertiesLogic } from './sessionRecordingsListPropertiesLogic'-import {- DEFAULT_RECORDING_FILTERS_ORDER_BY,- MAX_SELECTED_RECORDINGS,- sessionRecordingsPlaylistLogic,-} from './sessionRecordingsPlaylistLogic'+import { DEFAULT_RECORDING_FILTERS_ORDER_BY, sessionRecordingsPlaylistLogic } from './sessionRecordingsPlaylistLogic'import { UnwatchedIndicator } from './UnwatchedIndicator'export interface SessionRecordingPreviewProps {@@ -133,32 +129,6 @@ function durationToShow(recording: SessionRecordingType, order: RecordingsQuery[: recording.recording_duration}-function ItemCheckbox({ recording }: { recording: SessionRecordingType }): JSX.Element {- const { selectedRecordingsIds } = useValues(sessionRecordingsPlaylistLogic)- const { setSelectedRecordingsIds } = useActions(sessionRecordingsPlaylistLogic)-- return (- <LemonCheckbox- checked={selectedRecordingsIds.some((s) => s === recording.id)}- data-attr="select-recording"- aria-label="Select recording"- disabledReason={- selectedRecordingsIds.length >= MAX_SELECTED_RECORDINGS- ? `Cannot select more than ${MAX_SELECTED_RECORDINGS} recordings at once`- : undefined- }- onChange={() => {- if (selectedRecordingsIds.some((r) => r === recording.id)) {- setSelectedRecordingsIds(selectedRecordingsIds.filter((r) => r !== recording.id))- } else {- setSelectedRecordingsIds([...selectedRecordingsIds, recording.id])- }- }}- stopPropagation- />- )-}-const SessionRecordingPreviewBase = memo(function SessionRecordingPreviewBase({recording,diff --git a/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreviewCompact.tsx b/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreviewCompact.tsxnew file mode 100644index 000000000000..e7677045d590--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreviewCompact.tsx@@ -0,0 +1,239 @@+import clsx from 'clsx'+import { useValues } from 'kea'+import { memo } from 'react'++import { IconBug, IconCursorClick, IconHourglass, IconKeyboard, IconLive } from '@posthog/icons'+import { LemonTag } from '@posthog/lemon-ui'++import { PropertyIcon } from 'lib/components/PropertyIcon/PropertyIcon'+import { TZLabel } from 'lib/components/TZLabel'+import { SESSION_RECORDINGS_TTL_WARNING_THRESHOLD_DAYS } from 'lib/constants'+import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'+import { Tooltip } from 'lib/lemon-ui/Tooltip'+import { colonDelimitedDuration } from 'lib/utils/durations'+import { DraggableToNotebook } from 'scenes/notebooks/AddToNotebook/DraggableToNotebook'+import { SimpleTimeLabel } from 'scenes/session-recordings/components/SimpleTimeLabel'+import { TimestampFormat, playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'+import { urls } from 'scenes/urls'++import { RecordingsQuery } from '~/queries/schema/schema-general'+import { SessionRecordingType } from '~/types'++import { asDisplay } from 'products/persons/frontend/person-utils'++import { gatherIconProperties } from './gatherIconProperties'+import { ItemCheckbox } from './ItemCheckbox'+import { sessionRecordingsListPropertiesLogic } from './sessionRecordingsListPropertiesLogic'+import { DEFAULT_RECORDING_FILTERS_ORDER_BY, sessionRecordingsPlaylistLogic } from './sessionRecordingsPlaylistLogic'+import { UnwatchedIndicator } from './UnwatchedIndicator'++export interface SessionRecordingPreviewCompactProps {+ recording: SessionRecordingType+ isActive?: boolean+ selectable?: boolean+}++function formatDuration(seconds: number): string {+ const [hours, minutes, rest] = colonDelimitedDuration(seconds).split(':')+ return hours === '00' ? `${minutes}:${rest}` : `${hours}:${minutes}:${rest}`+}++function SortMetric({+ recording,+ order,+}: {+ recording: SessionRecordingType+ order: RecordingsQuery['order']+}): JSX.Element {+ if (order === 'console_error_count') {+ return (+ <span className="flex items-center gap-x-0.5 font-semibold">+ <IconBug className="text-secondary" />+ {recording.console_error_count ?? '-'}+ </span>+ )+ }+ if (order === 'recording_ttl') {+ const ttl = recording.recording_ttl+ const ttlColor =+ ttl !== undefined && ttl <= SESSION_RECORDINGS_TTL_WARNING_THRESHOLD_DAYS ? 'text-danger' : undefined+ return (+ <span className={clsx('flex items-center gap-x-0.5', ttlColor)}>+ <IconHourglass />+ {ttl === undefined ? '-' : `${ttl}d`}+ </span>+ )+ }+ const seconds =+ order === 'active_seconds'+ ? recording.active_seconds+ : order === 'inactive_seconds'+ ? recording.inactive_seconds+ : recording.recording_duration+ return <span className="tabular-nums">{seconds === undefined ? '-' : formatDuration(seconds)}</span>+}++export const SessionRecordingPreviewCompact = memo(+ function SessionRecordingPreviewCompact({+ recording,+ isActive,+ selectable = false,+ }: SessionRecordingPreviewCompactProps): JSX.Element {+ const { playlistTimestampFormat } = useValues(playerSettingsLogic)+ const { filters } = useValues(sessionRecordingsPlaylistLogic)+ const { recordingPropertiesById, recordingPropertiesLoading } = useValues(sessionRecordingsListPropertiesLogic)++ const order = filters.order || DEFAULT_RECORDING_FILTERS_ORDER_BY+ const recordingProperties = recordingPropertiesById[recording.id]+ const loading = !recordingProperties && recordingPropertiesLoading+ const iconProperties = gatherIconProperties(recordingProperties, recording)+ const errorCount = recording.console_error_count ?? 0+ const tileDetails: { label: string; value: string | undefined }[] = [+ {+ label: 'Location',+ value: [+ recordingProperties?.['$geoip_city_name'],+ iconProperties.find((p) => p.property === '$geoip_country_code')?.label,+ ]+ .filter(Boolean)+ .join(', '),+ },+ { label: 'Browser', value: iconProperties.find((p) => p.property === '$browser')?.label },+ {+ label: 'OS',+ value: iconProperties.find((p) => p.property === '$os' || p.property === '$os_name')?.label,+ },+ { label: 'Device', value: iconProperties.find((p) => p.property === '$device_type')?.label },+ { label: 'First URL', value: recording.start_url },+ { label: 'Referrer', value: recordingProperties?.['$entry_referring_domain'] },+ ].filter((detail) => !!detail.value)++ return (+ <DraggableToNotebook href={urls.replaySingle(recording.id)}>+ <div+ className={clsx(+ 'SessionRecordingPreview SessionRecordingPreview--compact group flex items-center gap-x-2 overflow-hidden cursor-pointer py-1.5 px-2 text-[11px]',+ isActive && 'SessionRecordingPreview--active'+ )}+ >+ {selectable && (+ <span className="shrink-0 flex items-center [&_label]:min-h-0">+ <ItemCheckbox recording={recording} />+ </span>+ )}+ {loading ? (+ <LemonSkeleton className="w-8 h-8 shrink-0 rounded" />+ ) : (+ <Tooltip+ placement="right"+ title={+ <div className="flex flex-col gap-0.5 text-xs">+ {tileDetails.map(({ label, value }) => (+ <span key={label} className="break-all">+ <span className="text-secondary">{label}: </span>+ {value}+ </span>+ ))}+ </div>+ }+ >+ <div className="grid grid-cols-2 gap-0.5 p-0.5 w-8 h-8 shrink-0 rounded border bg-surface-secondary ph-no-capture">+ {iconProperties.map(({ property, value }) => (+ <span+ key={property}+ className="flex items-center justify-center rounded-sm bg-surface-primary leading-none text-[11px]"+ >+ <PropertyIcon property={property} value={value} />+ </span>+ ))}+ </div>+ </Tooltip>+ )}++ <div className="grow min-w-0 flex flex-col gap-y-0.5">+ <div className="flex items-center gap-x-1.5">+ <span+ className={clsx(+ 'truncate grow text-xs ph-no-capture',+ recording.viewed ? 'font-medium' : 'font-semibold'+ )}+ >+ {asDisplay(recording.person)}+ </span>+ {recording.matches_filters === false && (+ <Tooltip title="This recording is listed only because it's open. It doesn't match the current filters.">+ <LemonTag type="warning" size="small" className="shrink-0">+ Doesn't match filters+ </LemonTag>+ </Tooltip>+ )}+ {playlistTimestampFormat === TimestampFormat.Relative ? (+ <TZLabel+ className="text-secondary shrink-0"+ time={recording.start_time}+ placement="right"+ />+ ) : (+ <SimpleTimeLabel+ startTime={recording.start_time}+ timestampFormat={playlistTimestampFormat}+ />+ )}+ </div>++ <div className="flex items-center gap-x-2 text-secondary">+ <Tooltip title="Clicks">+ <span className="flex items-center gap-x-0.5 shrink-0">+ <IconCursorClick />+ {recording.click_count}+ </span>+ </Tooltip>+ <Tooltip title="Key presses">+ <span className="flex items-center gap-x-0.5 shrink-0">+ <IconKeyboard />+ {recording.keypress_count}+ </span>+ </Tooltip>+ {errorCount > 0 && order !== 'console_error_count' && (+ <Tooltip title="Console errors">+ <span className="flex items-center gap-x-0.5 shrink-0 text-danger">+ <IconBug />+ {errorCount}+ </span>+ </Tooltip>+ )}+ <span className="grow" />+ <SortMetric recording={recording} order={order} />+ </div>+ {isActive && recording.start_url && (+ <span+ title={`First URL: ${recording.start_url}`}+ className="truncate text-secondary ph-no-capture"+ >+ {recording.start_url.replace(/https?:\/\//g, '').split(/[?|#]/)[0]}+ </span>+ )}+ </div>++ <div className="min-w-4 flex flex-col items-center gap-y-1">+ {recording.ongoing ? (+ <Tooltip title="This recording is still ongoing - we received data within the last 5 minutes.">+ <IconLive className="animate-[pulse_1s_ease-out_infinite] text-primary-3000" />+ </Tooltip>+ ) : null}+ {!recording.viewed ? (+ <UnwatchedIndicator otherViewersCount={recording.viewers?.length || 0} />+ ) : null}+ </div>+ </div>+ </DraggableToNotebook>+ )+ },+ (prevProps, nextProps) =>+ prevProps.recording.id === nextProps.recording.id &&+ // The row renders matches_filters, and the same recording flips in and out of matching+ // as filters change around an open player, so comparing only the id would keep it stale.+ prevProps.recording.matches_filters === nextProps.recording.matches_filters &&+ prevProps.isActive === nextProps.isActive &&+ prevProps.selectable === nextProps.selectable+)diff --git a/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsxindex 4760dd73e455..1abe394b826a 100644--- a/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx+++ b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx@@ -1,5 +1,5 @@-import { BindLogic, useActions, useValues } from 'kea'-import { useCallback, useRef } from 'react'+import { BindLogic, useActions, useMountedLogic, useValues } from 'kea'+import { useCallback, useEffect, useRef } from 'react'import * as directorPng from '@posthog/brand/hoggies/png/director'@@ -7,9 +7,11 @@ import { pngHoggie } from 'lib/brand/hoggies'import { EmptyMessage } from 'lib/components/EmptyMessage/EmptyMessage'import { Resizer } from 'lib/components/Resizer/Resizer'import { ResizerLogicProps, resizerLogic } from 'lib/components/Resizer/resizerLogic'+import { FEATURE_FLAGS } from 'lib/constants'import { useWindowSize } from 'lib/hooks/useWindowSize'import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'import { Spinner } from 'lib/lemon-ui/Spinner'+import { featureFlagLogic, reportFeatureFlagExposure } from 'lib/logic/featureFlagLogic'import { cn } from 'lib/utils/css-classes'import { Playlist } from 'scenes/session-recordings/playlist/Playlist'@@ -22,6 +24,10 @@ import { RecordingsUniversalFiltersEmbed } from '../filters/RecordingsUniversalFimport { playerSettingsLogic } from '../player/playerSettingsLogic'import { SessionRecordingPlayer } from '../player/SessionRecordingPlayer'import { playlistFiltersLogic } from './playlistFiltersLogic'+import { isNewReplayLayout } from './replayLayout'+import { ReplayListColumn } from './ReplayListColumn'+import { replayListColumnLogic } from './replayListColumnLogic'+import { ReplayListColumnWithPicks } from './ReplayListColumnWithPicks'import { SessionRecordingPlaylistLogicProps, sessionRecordingsPlaylistLogic } from './sessionRecordingsPlaylistLogic'const HedgehogDirector = pngHoggie(directorPng)@@ -33,10 +39,12 @@ type SessionRecordingsPlaylistProps = SessionRecordingPlaylistLogicProps & {/** Replaces the shared replay troubleshooting panel when the list comes back empty. */listEmptyState?: JSX.ElementpicksInList?: boolean+ watchLayout?: boolean}export function SessionRecordingsPlaylist({picksInList = false,+ watchLayout = false,...props}: SessionRecordingsPlaylistProps): JSX.Element {const logicProps: SessionRecordingPlaylistLogicProps = {@@ -44,6 +52,18 @@ export function SessionRecordingsPlaylist({autoPlay: props.autoPlay ?? true,onlyPinned: props.type === 'collection',}+ const { featureFlags, receivedFeatureFlags } = useValues(featureFlagLogic)+ const { canOverrideLayout, staffLayoutOverride } = useValues(playerSettingsLogic)+ const layoutOverridden = canOverrideLayout && !!staffLayoutOverride+ useEffect(() => {+ // Opening the Replay page is the exposure. An override is not the flag's arm.+ if (watchLayout && receivedFeatureFlags && !layoutOverridden) {+ reportFeatureFlagExposure(featureFlags, FEATURE_FLAGS.REPLAY_WATCH_LAYOUT)+ }+ }, [watchLayout, receivedFeatureFlags, featureFlags, layoutOverridden])++ // The column unmounts while the list is collapsed.+ useMountedLogic(replayListColumnLogic({ logicKey: props.logicKey ?? 'playlist' }))const { sidePanelWidth } = useValues(panelLayoutLogic)const { isWindowLessThan } = useWindowSize({ widthOffset: sidePanelWidth })@@ -59,9 +79,9 @@ export function SessionRecordingsPlaylist({const layout = (<div className={cn('w-full h-full flex', isVerticalLayout ? 'flex-col' : 'flex-row gap-2')}>{isVerticalLayout ? (- <VerticalLayout {...props} picksInList={picksInList} />+ <VerticalLayout {...props} picksInList={picksInList} watchLayout={watchLayout} />) : (- <HorizontalLayout {...props} picksInList={picksInList} />+ <HorizontalLayout {...props} picksInList={picksInList} watchLayout={watchLayout} />)}</div>)@@ -82,11 +102,25 @@ export function SessionRecordingsPlaylist({)}-type LayoutProps = Omit<SessionRecordingsPlaylistProps, 'picksInList'> & { picksInList: boolean }+type LayoutProps = Omit<SessionRecordingsPlaylistProps, 'picksInList' | 'watchLayout'> & {+ picksInList: boolean+ watchLayout: boolean+}function PlaylistColumn({ picksInList, ...props }: LayoutProps): JSX.Element {- const { isPlaylistCollapsed } = useValues(playerSettingsLogic)- if (picksInList && !isPlaylistCollapsed) {+ const { isPlaylistCollapsed, replayLayout } = useValues(playerSettingsLogic)+ if (isPlaylistCollapsed) {+ return <Playlist {...props} />+ }+ if (props.watchLayout && isNewReplayLayout(replayLayout)) {+ const logicKey = props.logicKey ?? 'playlist'+ return picksInList ? (+ <ReplayListColumnWithPicks logicKey={logicKey} recordingsList={<Playlist {...props} />} />+ ) : (+ <ReplayListColumn logicKey={logicKey} recordingsList={<Playlist {...props} />} picksMode={null} />+ )+ }+ if (picksInList) {return <WatchPicksListColumn recordingsList={<Playlist {...props} />} />}return <Playlist {...props} />@@ -140,8 +174,9 @@ function HorizontalLayout({ picksInList, ...props }: LayoutProps): JSX.Element {function VerticalLayout({ picksInList, ...props }: LayoutProps): JSX.Element {const playerRef = useRef<HTMLDivElement>(null)- const { isPlaylistCollapsed } = useValues(playerSettingsLogic)+ const { isPlaylistCollapsed, replayLayout } = useValues(playerSettingsLogic)const { setPlaylistCollapsed } = useActions(playerSettingsLogic)+ const watchStack = props.watchLayout && isNewReplayLayout(replayLayout)const resizerLogicProps: ResizerLogicProps = {logicKey: 'playlist-resizer-vertical',@@ -160,8 +195,15 @@ function VerticalLayout({ picksInList, ...props }: LayoutProps): JSX.Element {<PlayerWrapper{...props}containerRef={playerRef}- style={isPlaylistCollapsed ? {} : { height: desiredSize ?? undefined, minHeight: 300 }}- className={isPlaylistCollapsed ? 'flex-1' : 'pb-2 shrink-0'}+ style={+ isPlaylistCollapsed+ ? {}+ : { height: desiredSize ?? (watchStack ? '50vh' : undefined), minHeight: 300 }+ }+ className={cn(+ isPlaylistCollapsed ? 'flex-1' : 'pb-2 shrink-0',+ watchStack && 'Playlist__main--stacked'+ )}resizer={!isPlaylistCollapsed ? (<Resizer@@ -173,7 +215,10 @@ function VerticalLayout({ picksInList, ...props }: LayoutProps): JSX.Element {) : null}/>- <div className={cn('relative flex flex-col min-h-0', isPlaylistCollapsed ? 'h-5' : 'flex-1')}>+ <div+ className={cn('relative flex flex-col min-h-0', isPlaylistCollapsed ? 'h-5' : 'flex-1')}+ data-stacked={watchStack || undefined}+ ><PlaylistColumn {...props} picksInList={picksInList} /></div></>@@ -189,6 +234,7 @@ function PlayerWrapper({...props}: SessionRecordingPlaylistLogicProps & {showContent?: boolean+ watchLayout?: booleantype?: 'filters' | 'collection'isSynthetic?: booleandescription?: string@@ -263,6 +309,7 @@ function PlayerWrapper({: undefined}playNextRecording={nextSessionRecording?.id ? onPlayNextRecording : undefined}+ watchLayout={props.watchLayout}/></div>) : sessionRecordingsResponseLoading ? (diff --git a/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistScene.tsx b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistScene.tsxindex 2022f01a5527..e144934e39a5 100644--- a/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistScene.tsx+++ b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistScene.tsx@@ -271,6 +271,7 @@ export function SessionRecordingsPlaylistScene(): JSX.Element {pinnedRecordings={pinnedRecordings ?? []}updateSearchParams={true}type={playlist.type === 'filters' ? 'filters' : 'collection'}+ watchLayoutisSynthetic={playlist.is_synthetic}description={playlist.description}/>diff --git a/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistSettings.tsx b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistSettings.tsxindex 69d2e30a02e2..07de1a184211 100644--- a/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistSettings.tsx+++ b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistSettings.tsx@@ -20,7 +20,12 @@ import { bulkScanLogic } from 'products/replay_vision/frontend/logics/bulkScanLoimport { visionQuotaLogic } from 'products/replay_vision/frontend/logics/visionQuotaLogic'import { quotaUx } from 'products/replay_vision/frontend/utils/quotaProjection'-import { useAutoplayMenuItems, useHideRecordingsMenuItems, useTimestampFormatMenuItems } from './listViewMenuItems'+import {+ useAutoplayMenuItems,+ useHideRecordingsMenuItems,+ useLayoutMenuItems,+ useTimestampFormatMenuItems,+} from './listViewMenuItems'import {DELETE_CONFIRMATION_TEXT,MAX_SELECTED_RECORDINGS,@@ -220,11 +225,13 @@ function ListViewMenu({const recommendedItem = useRecommendedOnlyMenuItem(filters, setFilters)const hideItems = useHideRecordingsMenuItems()const timestampItems = useTimestampFormatMenuItems()+ const layoutItems = useLayoutMenuItems()const items: LemonMenuItems = [{ title: 'Sort by', items: sortItems },{ title: 'Show', items: [recommendedItem, ...hideItems] },{ title: 'Timestamps', items: timestampItems },+ ...(layoutItems.length ? [{ title: 'Layout', items: layoutItems }] : []),]return (@@ -241,7 +248,7 @@ function ListViewMenu({)}-function ConfirmDeleteRecordings({ shortId }: { shortId?: string }): JSX.Element {+export function ConfirmDeleteRecordings({ shortId }: { shortId?: string }): JSX.Element {const {selectedRecordingsIds,isDeleteSelectedRecordingsDialogOpen,@@ -472,7 +479,7 @@ export function AddToCollectionModal({ shortId }: { shortId?: string }): JSX.Ele}/** Bulk "Scan these recordings" row whose scanner list opens on hover (a nested `items` menu is click-only). */-function BulkScanMenuItem(): JSX.Element {+export function BulkScanMenuItem(): JSX.Element {const { selectedRecordingsIds } = useValues(sessionRecordingsPlaylistLogic)const { scanners, scannersLoading, scanning } = useValues(bulkScanLogic)const { scanRecordings } = useActions(bulkScanLogic)@@ -553,7 +560,7 @@ export function SessionRecordingsPlaylistTopSettings({} = useActions(sessionRecordingsPlaylistLogic)const recordings = type === 'filters' ? otherRecordings : pinnedRecordings- const checked = recordings.length > 0 && selectedRecordingsIds.length === recordings.length+ const checked = recordings.length > 0 && recordings.every((r) => selectedRecordingsIds.includes(r.id))const accessControlDisabledReason = getAccessControlDisabledReason(AccessControlResourceType.SessionRecording,diff --git a/frontend/src/scenes/session-recordings/playlist/filterChipLeaves.test.ts b/frontend/src/scenes/session-recordings/playlist/filterChipLeaves.test.tsnew file mode 100644index 000000000000..5dcab7155ba6--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/filterChipLeaves.test.ts@@ -0,0 +1,35 @@+import { FilterLogicalOperator, PropertyFilterType, PropertyOperator, UniversalFiltersGroup } from '~/types'++import { filterLeaves, removeFilterLeaf } from './filterChipLeaves'++const leaf = (key: string): any => ({+ key,+ value: '1',+ operator: PropertyOperator.Exact,+ type: PropertyFilterType.Event,+})++const group: UniversalFiltersGroup = {+ type: FilterLogicalOperator.And,+ values: [{ type: FilterLogicalOperator.And, values: [leaf('a'), leaf('b')] }, leaf('c')],+}++describe('filter chips', () => {+ it('lists every condition with its path through the nested groups', () => {+ expect(filterLeaves(group).map((l) => [l.path, (l.filter as { key?: string }).key])).toEqual([+ [[0, 0], 'a'],+ [[0, 1], 'b'],+ [[1], 'c'],+ ])+ })++ it.each([+ { name: 'a nested leaf', path: [0, 1], remaining: ['a', 'c'], rootValues: 2 },+ { name: 'a root leaf', path: [1], remaining: ['a', 'b'], rootValues: 1 },+ { name: 'a leaf inside a group, keeping the group', path: [0, 0], remaining: ['b', 'c'], rootValues: 2 },+ ])('removes $name', ({ path, remaining, rootValues }) => {+ const next = removeFilterLeaf(group, path)+ expect(filterLeaves(next).map((l) => (l.filter as { key?: string }).key)).toEqual(remaining)+ expect(next.values.length).toBe(rootValues)+ })+})diff --git a/frontend/src/scenes/session-recordings/playlist/filterChipLeaves.ts b/frontend/src/scenes/session-recordings/playlist/filterChipLeaves.tsnew file mode 100644index 000000000000..4b53654003a2--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/filterChipLeaves.ts@@ -0,0 +1,35 @@+import { isUniversalGroupFilterLike } from 'lib/components/UniversalFilters/utils'++import { UniversalFilterValue, UniversalFiltersGroup } from '~/types'++export interface FilterLeaf {+ /** Indexes into nested `values` arrays, from the root group down to the leaf. */+ path: number[]+ filter: UniversalFilterValue+}++/** Every condition in the group tree, in display order. */+export function filterLeaves(group: UniversalFiltersGroup, path: number[] = []): FilterLeaf[] {+ return group.values.flatMap((value, index) =>+ isUniversalGroupFilterLike(value)+ ? filterLeaves(value, [...path, index])+ : [{ path: [...path, index], filter: value }]+ )+}++/** The group tree without the leaf at `path`. A group that empties stays, so the editor's structure is kept. */+export function removeFilterLeaf(group: UniversalFiltersGroup, path: number[]): UniversalFiltersGroup {+ const [index, ...rest] = path+ return {+ ...group,+ values: group.values.flatMap((value, i) => {+ if (i !== index) {+ return [value]+ }+ if (rest.length === 0 || !isUniversalGroupFilterLike(value)) {+ return []+ }+ return [removeFilterLeaf(value, rest)]+ }),+ }+}diff --git a/frontend/src/scenes/session-recordings/playlist/listViewMenuItems.tsx b/frontend/src/scenes/session-recordings/playlist/listViewMenuItems.tsxindex 4c98adcadef9..a85de14b0790 100644--- a/frontend/src/scenes/session-recordings/playlist/listViewMenuItems.tsx+++ b/frontend/src/scenes/session-recordings/playlist/listViewMenuItems.tsx@@ -51,6 +51,30 @@ export function useTimestampFormatMenuItems(): LemonMenuItem[] {}))}+export function useLayoutMenuItems(): LemonMenuItem[] {+ const { watchLayoutOffered, replayLayout, canOverrideLayout, staffLayoutOverride } = useValues(playerSettingsLogic)+ const { setPreferClassicReplayLayout } = useActions(playerSettingsLogic)++ if (!watchLayoutOffered || (canOverrideLayout && staffLayoutOverride)) {+ return []+ }++ return [+ {+ label: 'New',+ onClick: () => setPreferClassicReplayLayout(false),+ active: replayLayout !== 'classic',+ 'data-attr': 'list-layout-new',+ },+ {+ label: 'Legacy',+ onClick: () => setPreferClassicReplayLayout(true),+ active: replayLayout === 'classic',+ 'data-attr': 'list-layout-classic',+ },+ ]+}+export function useAutoplayMenuItems(): LemonMenuItem[] {const { autoplayDirection } = useValues(playerSettingsLogic)const { setAutoplayDirection } = useActions(playerSettingsLogic)diff --git a/frontend/src/scenes/session-recordings/playlist/playlistUtils.test.ts b/frontend/src/scenes/session-recordings/playlist/playlistUtils.test.tsindex c0740b510ee0..bfcde8d6c3a5 100644--- a/frontend/src/scenes/session-recordings/playlist/playlistUtils.test.ts+++ b/frontend/src/scenes/session-recordings/playlist/playlistUtils.test.ts@@ -1,4 +1,8 @@-import { stripSessionIds, summarizePlaylistFilters } from 'scenes/session-recordings/playlist/playlistUtils'+import {+ comparableRecordingFilters,+ stripSessionIds,+ summarizePlaylistFilters,+} from 'scenes/session-recordings/playlist/playlistUtils'import {CohortType,@@ -220,3 +224,21 @@ describe('stripSessionIds()', () => {expect(stripSessionIds(input as any)).toBe(input)})})++describe('comparableRecordingFilters()', () => {+ it.each([+ [+ 'drops recommended_only when the list wrote it back as false',+ { recommended_only: false, date_from: '-7d' },+ { date_from: '-7d' },+ ],+ [+ 'keeps recommended_only when it is on',+ { recommended_only: true, date_from: '-7d' },+ { recommended_only: true, date_from: '-7d' },+ ],+ ['drops session ids', { session_ids: ['a'], date_from: '-7d' }, { date_from: '-7d' }],+ ])('%s', (_, filters, expected) => {+ expect(comparableRecordingFilters(filters as any)).toEqual(expected)+ })+})diff --git a/frontend/src/scenes/session-recordings/playlist/playlistUtils.ts b/frontend/src/scenes/session-recordings/playlist/playlistUtils.tsindex da29f7e1ff62..78dd08e0bed1 100644--- a/frontend/src/scenes/session-recordings/playlist/playlistUtils.ts+++ b/frontend/src/scenes/session-recordings/playlist/playlistUtils.ts@@ -36,6 +36,12 @@ export function stripSessionIds<T extends Partial<RecordingUniversalFilters> | ureturn rest as T}+// The list writes recommended_only false back. A saved filter never holds it.+export function comparableRecordingFilters<T extends Partial<RecordingUniversalFilters>>(filters: T): T {+ const { recommended_only, ...rest } = stripSessionIds(filters)+ return (recommended_only ? { ...rest, recommended_only } : rest) as T+}+function getOperatorSymbol(operator: PropertyOperator | null): string {if (!operator) {return '?'@@ -143,7 +149,7 @@ export async function createPlaylist(export async function deletePlaylist(playlist: SessionRecordingPlaylistType,- undoCallback?: () => void+ undoCallback?: (undo: boolean) => void): Promise<SessionRecordingPlaylistType> {await deleteWithUndo({object: playlist,@@ -155,7 +161,7 @@ export async function deletePlaylist(} else {deleteFromTree('session_recording_playlist', playlist.short_id)}- undoCallback?.()+ undoCallback?.(undo)},})return playlistdiff --git a/frontend/src/scenes/session-recordings/playlist/replayLayout.test.ts b/frontend/src/scenes/session-recordings/playlist/replayLayout.test.tsnew file mode 100644index 000000000000..634b23a06016--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/replayLayout.test.ts@@ -0,0 +1,16 @@+import { replayLayoutFrom } from './replayLayout'++describe('replayLayoutFrom', () => {+ it.each([+ [undefined, false, null, 'classic'],+ ['control', false, null, 'classic'],+ ['test', false, null, 'classic'],+ ['compact', false, null, 'compact'],+ ['youtube', false, null, 'youtube'],+ ['landing', true, null, 'classic'],+ ['control', false, 'landing', 'landing'],+ ['compact', true, 'classic', 'classic'],+ ])('flag %p, preferClassic %p, staff override %p gives %s', (flagValue, preferClassic, override, expected) => {+ expect(replayLayoutFrom(flagValue, preferClassic, override as any)).toBe(expected)+ })+})diff --git a/frontend/src/scenes/session-recordings/playlist/replayLayout.ts b/frontend/src/scenes/session-recordings/playlist/replayLayout.tsnew file mode 100644index 000000000000..d1a9b2578e2a--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/replayLayout.ts@@ -0,0 +1,31 @@+export type ReplayLayout = 'classic' | 'compact' | 'youtube' | 'landing'++export const NEW_REPLAY_LAYOUTS: ReplayLayout[] = ['compact', 'youtube', 'landing']++export function offeredReplayLayout(flagValue: string | boolean | undefined): ReplayLayout | null {+ return typeof flagValue === 'string' && (NEW_REPLAY_LAYOUTS as string[]).includes(flagValue)+ ? (flagValue as ReplayLayout)+ : null+}++export function replayLayoutFrom(+ flagValue: string | boolean | undefined,+ preferClassicLayout: boolean,+ staffOverride: ReplayLayout | null = null+): ReplayLayout {+ if (staffOverride) {+ return staffOverride+ }+ const offered = offeredReplayLayout(flagValue)+ return offered && !preferClassicLayout ? offered : 'classic'+}++/** Every arm shares the compact list, the filter header and the watch player until its own surfaces exist. */+export function isNewReplayLayout(layout: ReplayLayout): boolean {+ return layout !== 'classic'+}++/** The watch layout only shapes players whose host opted in, which is the replay playlist. */+export function playerUsesWatchLayout(layout: ReplayLayout, logicProps: { watchLayout?: boolean }): boolean {+ return isNewReplayLayout(layout) && !!logicProps.watchLayout+}diff --git a/frontend/src/scenes/session-recordings/playlist/replayListColumnLogic.test.ts b/frontend/src/scenes/session-recordings/playlist/replayListColumnLogic.test.tsnew file mode 100644index 000000000000..b0427d6da919--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/replayListColumnLogic.test.ts@@ -0,0 +1,59 @@+import { expectLogic } from 'kea-test-utils'++import { initKeaTests } from '~/test/init'+import { SessionRecordingSidebarTab } from '~/types'++import { playerSidebarLogic } from '../player/sidebar/playerSidebarLogic'+import { replayListColumnLogic } from './replayListColumnLogic'++describe('replayListColumnLogic', () => {+ let logic: ReturnType<typeof replayListColumnLogic.build>++ beforeEach(() => {+ initKeaTests()+ logic = replayListColumnLogic({ logicKey: 'test' })+ logic.mount()+ })++ it.each([+ { chosen: null, picksMode: null, moments: false, expected: 'recordings' },+ { chosen: null, picksMode: 'picks', moments: false, expected: 'picks' },+ { chosen: null, picksMode: 'picks', moments: true, expected: 'picks' },+ { chosen: null, picksMode: null, moments: true, expected: 'recordings' },+ { chosen: 'recordings', picksMode: null, moments: true, expected: 'recordings' },+ { chosen: 'picks', picksMode: null, moments: false, expected: 'recordings' },+ { chosen: 'moments', picksMode: 'picks', moments: true, expected: 'moments' },+ { chosen: 'moments', picksMode: 'picks', moments: false, expected: 'recordings' },+ { chosen: 'moments', picksMode: null, moments: null, expected: 'recordings' },+ { chosen: 'recordings', picksMode: 'picks', moments: true, expected: 'recordings' },+ ] as const)(+ 'chosen $chosen with picks $picksMode and moments $moments shows $expected',+ ({ chosen, picksMode, moments, expected }) => {+ if (chosen) {+ logic.actions.setSegment(chosen)+ }+ expect(logic.values.effectiveSegmentFor(picksMode, moments)).toBe(expected)+ }+ )++ it.each([+ { chosen: 'moments', picksMode: null, moments: null, kept: 'moments' },+ { chosen: 'moments', picksMode: null, moments: true, kept: 'moments' },+ { chosen: 'moments', picksMode: null, moments: false, kept: null },+ { chosen: 'picks', picksMode: 'picks', moments: null, kept: 'picks' },+ { chosen: 'picks', picksMode: null, moments: null, kept: null },+ ] as const)(+ 'chosen $chosen settles to $kept with picks $picksMode and moments $moments',+ ({ chosen, picksMode, moments, kept }) => {+ logic.actions.setSegment(chosen)+ logic.actions.settleSegment(picksMode, moments)+ expect(logic.values.segment).toBe(kept)+ }+ )++ it('switches to moments when something asks for the observations tab', async () => {+ await expectLogic(logic, () => {+ playerSidebarLogic.actions.setTab(SessionRecordingSidebarTab.OBSERVATIONS)+ }).toMatchValues({ segment: 'moments' })+ })+})diff --git a/frontend/src/scenes/session-recordings/playlist/replayListColumnLogic.ts b/frontend/src/scenes/session-recordings/playlist/replayListColumnLogic.tsnew file mode 100644index 000000000000..43c8f64f3ef7--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/replayListColumnLogic.ts@@ -0,0 +1,119 @@+import { MakeLogicType, actions, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'+import posthog from 'posthog-js'++import { playerSidebarLogic } from 'scenes/session-recordings/player/sidebar/playerSidebarLogic'++import { SessionRecordingSidebarTab } from '~/types'++export type ReplayListSegment = 'picks' | 'recordings' | 'moments'+export type ReplayListSegmentSource = 'user' | 'observations'+export type ReplayListPicksMode = 'picks' | 'recordings' | null++export interface ReplayListColumnLogicProps {+ logicKey: string+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface replayListColumnLogicValues {+ effectiveSegmentFor: (picksMode: ReplayListPicksMode, momentsAvailable: boolean | null) => ReplayListSegment+ segment: ReplayListSegment | null+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface replayListColumnLogicActions {+ setSidebarTab: (tab: SessionRecordingSidebarTab) => {+ tab: SessionRecordingSidebarTab+ } // playerSidebarLogic+ dropSegmentChoice: () => {+ value: true+ }+ setSegment: (+ segment: ReplayListSegment,+ source?: ReplayListSegmentSource+ ) => {+ segment: ReplayListSegment+ source: ReplayListSegmentSource+ }+ settleSegment: (+ picksMode: ReplayListPicksMode,+ momentsAvailable: boolean | null+ ) => {+ momentsAvailable: boolean | null+ picksMode: ReplayListPicksMode+ }+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface replayListColumnLogicMeta {+ key: string+ __keaTypeGenInternalSelectorTypes: {+ effectiveSegmentFor: (+ segment: ReplayListSegment | null+ ) => (picksMode: ReplayListPicksMode, momentsAvailable: boolean | null) => ReplayListSegment+ }+}++export type replayListColumnLogicType = MakeLogicType<+ replayListColumnLogicValues,+ replayListColumnLogicActions,+ ReplayListColumnLogicProps,+ replayListColumnLogicMeta+>++export const replayListColumnLogic = kea<replayListColumnLogicType>([+ path((key) => ['scenes', 'session-recordings', 'playlist', 'replayListColumnLogic', key]),+ props({} as ReplayListColumnLogicProps),+ key((props) => props.logicKey),+ connect(() => ({+ actions: [playerSidebarLogic, ['setTab as setSidebarTab']],+ })),+ actions({+ setSegment: (segment: ReplayListSegment, source: ReplayListSegmentSource = 'user') => ({ segment, source }),+ // Or the choice resurfaces on a later recording.+ dropSegmentChoice: true,+ settleSegment: (picksMode: ReplayListPicksMode, momentsAvailable: boolean | null) => ({+ picksMode,+ momentsAvailable,+ }),+ }),+ reducers({+ // Null until the viewer picks one, so the picks logic keeps deciding where a fresh page lands.+ segment: [+ null as ReplayListSegment | null,+ { setSegment: (_, { segment }) => segment, dropSegmentChoice: () => null },+ ],+ }),+ selectors({+ effectiveSegmentFor: [+ (s) => [s.segment],+ (segment: ReplayListSegment | null) =>+ (picksMode: ReplayListPicksMode, momentsAvailable: boolean | null): ReplayListSegment => {+ const chosen = segment ?? picksMode ?? 'recordings'+ if (chosen === 'picks' && picksMode === null) {+ return 'recordings'+ }+ if (chosen === 'moments' && !momentsAvailable) {+ return 'recordings'+ }+ return chosen+ },+ ],+ }),+ listeners(({ actions, values }) => ({+ setSegment: ({ segment, source }) => {+ posthog.capture('session recording list segment changed', { segment, source })+ },+ settleSegment: ({ picksMode, momentsAvailable }) => {+ const chosen = values.segment+ if ((chosen === 'picks' && picksMode === null) || (chosen === 'moments' && momentsAvailable === false)) {+ actions.dropSegmentChoice()+ }+ },+ // Summarize and View details still ask for the Observations tab. In this layout that content is the Moments segment.+ setSidebarTab: ({ tab }) => {+ if (tab === SessionRecordingSidebarTab.OBSERVATIONS && values.segment !== 'moments') {+ actions.setSegment('moments', 'observations')+ }+ },+ })),+])diff --git a/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.test.ts b/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.test.tsindex f73ebebd57a9..6a1fb59a539d 100644--- a/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.test.ts+++ b/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.test.ts@@ -1418,6 +1418,23 @@ describe('sessionRecordingsPlaylistLogic', () => {})})+ describe('applying a saved filter', () => {+ beforeEach(() => {+ logic = sessionRecordingsPlaylistLogic({ logicKey: 'saved_filter', updateSearchParams: true })+ logic.mount()+ })++ it('replaces the filters with the defaults plus the saved keys in one load', async () => {+ logic.actions.setFilters({ filter_test_accounts: true, date_from: '-30d' })+ await expectLogic(logic, () => {+ logic.actions.applySavedFilter({ date_from: '-7d' })+ })+ .toDispatchActions(['applySavedFilter', 'loadSessionRecordings'])+ .toNotHaveDispatchedActions(['resetFilters', 'setFilters'])+ .toMatchValues({ filters: { ...getDefaultFilters(), date_from: '-7d' } })+ })+ })+describe('rehydrating persisted filters', () => {const props = { logicKey: 'persist_regression', personUUID: 'persist_regression', updateSearchParams: false }diff --git a/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.ts b/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.tsindex dfbe60ec43f4..5d6bcb69e3a2 100644--- a/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.ts+++ b/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.ts@@ -649,6 +649,7 @@ export interface sessionRecordingsPlaylistLogicValues {pinnedRecordingsLoading: booleanrecordings: SessionRecordingType[]recordingsCount: number+ selectMode: booleanselectedRecordingId: SessionRecordingType['id'] | nullselectedRecordingOutsideFilters: booleanselectedRecordingsIds: string[]@@ -720,6 +721,9 @@ export interface sessionRecordingsPlaylistLogicActions {propertyKey: stringpropertyValue: string | undefined}+ applySavedFilter: (filters: Partial<RecordingUniversalFilters>) => {+ filters: Partial<RecordingUniversalFilters>+ }handleBulkAddToPlaylist: (short_id: string) => {short_id: string}@@ -908,6 +912,9 @@ export interface sessionRecordingsPlaylistLogicActions {setNewCollectionName: (newCollectionName: string) => {newCollectionName: string}+ setSelectMode: (selectMode: boolean) => {+ selectMode: boolean+ }setSelectedRecordingId: (id: SessionRecordingType['id'] | null) => {id: string | null}@@ -1053,6 +1060,7 @@ export const sessionRecordingsPlaylistLogic = kea<sessionRecordingsPlaylistLogicsetShowFilters: (showFilters: boolean) => ({ showFilters }),setShowSettings: (showSettings: boolean) => ({ showSettings }),resetFilters: true,+ applySavedFilter: (filters: Partial<RecordingUniversalFilters>) => ({ filters }),applyPropertyFilter: (propertyKey: string, propertyValue: string | undefined) => ({propertyKey,propertyValue,@@ -1081,6 +1089,7 @@ export const sessionRecordingsPlaylistLogic = kea<sessionRecordingsPlaylistLogicloadNext: true,loadPrev: true,setSelectedRecordingsIds: (recordingsIds: string[]) => ({ recordingsIds }),+ setSelectMode: (selectMode: boolean) => ({ selectMode }),handleBulkAddToPlaylist: (short_id: string) => ({ short_id }),handleBulkDeleteFromPlaylist: (short_id: string) => ({ short_id }),handleSelectUnselectAll: (checked: boolean, type: 'filters' | 'collection') => ({ checked, type }),@@ -1391,6 +1400,8 @@ export const sessionRecordingsPlaylistLogic = kea<sessionRecordingsPlaylistLogic}},resetFilters: () => getResetFilters(props),+ applySavedFilter: (_, { filters }) =>+ applyFilterUpdate(getResetFilters(props), filters, props.pinnedFilters),},],/**@@ -1416,6 +1427,7 @@ export const sessionRecordingsPlaylistLogic = kea<sessionRecordingsPlaylistLogicreturn added.length ? [...state, ...added] : state},resetFilters: () => [],+ applySavedFilter: () => [],},],showFilters: [@@ -1496,20 +1508,29 @@ export const sessionRecordingsPlaylistLogic = kea<sessionRecordingsPlaylistLogicloadSessionRecordingsFailure: () => true,loadSessionRecordingsSuccess: () => false,setFilters: () => false,+ applySavedFilter: () => false,setAdvancedFilters: () => false,loadNext: () => false,loadPrev: () => false,},],+ selectMode: [+ false,+ {+ setSelectMode: (_, { selectMode }) => selectMode,+ },+ ],selectedRecordingsIds: [[] as string[],{setSelectedRecordingsIds: (_, { recordingsIds }) => recordingsIds,+ setSelectMode: (state, { selectMode }) => (selectMode ? state : []),// The filtered/pinned lists reload from scratch on a filter change, so a prior selection// can no longer be matched against what's on screen - drop it rather than risk deleting// recordings the user can't see.setFilters: () => [],resetFilters: () => [],+ applySavedFilter: () => [],},],isDeleteSelectedRecordingsDialogOpen: [@@ -1638,6 +1659,12 @@ export const sessionRecordingsPlaylistLogic = kea<sessionRecordingsPlaylistLogicprops.onFiltersChange?.(values.filters)},+ applySavedFilter: () => {+ actions.loadSessionRecordings()+ props.onFiltersChange?.(values.filters)+ actions.loadEventsHaveSessionId()+ },+applyPropertyFilter: ({ propertyKey, propertyValue }) => {// Validate property valueif (propertyValue === undefined || propertyValue === null) {@@ -2469,6 +2496,7 @@ export const sessionRecordingsPlaylistLogic = kea<sessionRecordingsPlaylistLogicsetSelectedRecordingId: () => buildURL(false),setFilters: () => buildURL(true),resetFilters: () => buildURL(true),+ applySavedFilter: () => buildURL(true),}}),diff --git a/frontend/src/scenes/session-recordings/playlist/usePlayerMounted.ts b/frontend/src/scenes/session-recordings/playlist/usePlayerMounted.tsnew file mode 100644index 000000000000..17c7062e71f4--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/usePlayerMounted.ts@@ -0,0 +1,28 @@+import { useEffect, useState } from 'react'++import {+ SessionRecordingPlayerLogicProps,+ sessionRecordingPlayerLogic,+} from 'scenes/session-recordings/player/sessionRecordingPlayerLogic'++const PLAYER_MOUNT_WAIT_FRAMES = 20++export type PlayerMountState = 'mounted' | 'waiting' | 'missing'++/**+ * The player logic is keyed, and the list column renders before the player in the same commit, so the first frame+ * after a recording changes can find no instance yet. Building one from the list would start a second player, so wait+ * a few frames instead, and give up when a host renders the list without a player at all.+ */+export function usePlayerMounted(playerLogicProps: SessionRecordingPlayerLogicProps): PlayerMountState {+ const [attempts, setAttempts] = useState(0)+ const mounted = !!sessionRecordingPlayerLogic.findMounted(playerLogicProps)+ useEffect(() => {+ if (mounted || attempts >= PLAYER_MOUNT_WAIT_FRAMES) {+ return+ }+ const frame = requestAnimationFrame(() => setAttempts((n) => n + 1))+ return () => cancelAnimationFrame(frame)+ }, [mounted, attempts])+ return mounted ? 'mounted' : attempts >= PLAYER_MOUNT_WAIT_FRAMES ? 'missing' : 'waiting'+}diff --git a/frontend/src/scenes/session-recordings/playlist/watchListViewMenuItems.tsx b/frontend/src/scenes/session-recordings/playlist/watchListViewMenuItems.tsxnew file mode 100644index 000000000000..6a83489bd4ac--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/watchListViewMenuItems.tsx@@ -0,0 +1,121 @@+import { useValues } from 'kea'+import posthog from 'posthog-js'++import { LemonMenuItem, LemonMenuItems } from 'lib/lemon-ui/LemonMenu/LemonMenu'++import { RecordingUniversalFilters } from '~/types'++import {+ useAutoplayMenuItems,+ useHideRecordingsMenuItems,+ useLayoutMenuItems,+ useTimestampFormatMenuItems,+} from './listViewMenuItems'+import {+ RecordingSort,+ preferredRecordingsSortStorage,+ sessionRecordingsPlaylistLogic,+} from './sessionRecordingsPlaylistLogic'+import { getRecommendedFilterChange, getSortChangedEvent } from './SessionRecordingsPlaylistSettings'++/**+ * The watch layout's sort options. Clicks, keystrokes, mouse activity, expiration, active and inactive duration+ * were dropped for low use. A list already sorted by one of them keeps it until the sort changes.+ */+const WATCH_SORTS: { label: string; order: NonNullable<RecordingUniversalFilters['order']> }[] = [+ { label: 'Latest', order: 'start_time' },+ { label: 'Activity', order: 'activity_score' },+ { label: 'Duration', order: 'duration' },+ { label: 'Errors', order: 'console_error_count' },+]++export function watchSortLabel(order: RecordingUniversalFilters['order']): string {+ if (order === 'surfacing_score') {+ return 'Relevance'+ }+ return WATCH_SORTS.find((sort) => sort.order === (order ?? 'start_time'))?.label ?? 'Sorted'+}++export function useWatchViewMenuItems(+ filters: RecordingUniversalFilters,+ setFilters: (filters: Partial<RecordingUniversalFilters>) => void+): LemonMenuItems {+ const { canSortByRelevance, canFilterByRelevance, listSort } = useValues(sessionRecordingsPlaylistLogic)+ const hideItems = useHideRecordingsMenuItems()+ const current = { ...filters, ...listSort }+ const order = current.order ?? 'start_time'+ const direction = current.order_direction ?? 'DESC'++ const changeSort = (sort: RecordingSort): void => {+ const event = getSortChangedEvent(current, sort)+ if (event) {+ posthog.capture('session recording list sort changed', event)+ }+ preferredRecordingsSortStorage.set(sort)+ setFilters(sort)+ }++ const sortItems: LemonMenuItem[] = [+ ...(canSortByRelevance+ ? [+ {+ label: 'Relevance',+ onClick: () => changeSort({ order: 'surfacing_score', order_direction: 'DESC' }),+ active: order === 'surfacing_score',+ 'data-attr': 'list-sort-surfacing-score',+ },+ ]+ : []),+ ...WATCH_SORTS.map((sort) => ({+ label: sort.label,+ onClick: () => changeSort({ order: sort.order, order_direction: 'DESC' }),+ active: order === sort.order,+ 'data-attr': `list-sort-${sort.order.replace(/_/g, '-')}`,+ })),+ ]+ const directionItems: LemonMenuItem[] = [+ {+ label: order === 'start_time' ? 'Newest first' : 'Highest first',+ onClick: () => changeSort({ order, order_direction: 'DESC' }),+ active: direction === 'DESC',+ 'data-attr': 'list-sort-direction-desc',+ },+ {+ label: order === 'start_time' ? 'Oldest first' : 'Lowest first',+ onClick: () => changeSort({ order, order_direction: 'ASC' }),+ active: direction === 'ASC',+ 'data-attr': 'list-sort-direction-asc',+ },+ ]+ const showItems: LemonMenuItem[] = [+ ...(canFilterByRelevance+ ? [+ {+ label: 'High relevance only',+ active: !!filters.recommended_only,+ onClick: () => {+ posthog.capture('session recording recommended filter changed', {+ enabled: !filters.recommended_only,+ })+ setFilters(getRecommendedFilterChange(!filters.recommended_only))+ },+ 'data-attr': 'session-recordings-recommended-only',+ },+ ]+ : []),+ ...hideItems,+ ]++ return [{ title: 'Sort by', items: sortItems }, { items: directionItems }, { title: 'Show', items: showItems }]+}++export function useWatchSettingsMenuItems(): LemonMenuItems {+ const timestampItems = useTimestampFormatMenuItems()+ const autoplayItems = useAutoplayMenuItems()+ const layoutItems = useLayoutMenuItems()+ return [+ { title: 'Timestamps', items: timestampItems },+ { title: 'Autoplay', items: autoplayItems },+ ...(layoutItems.length ? [{ title: 'Layout', items: layoutItems }] : []),+ ]+}diff --git a/products/replay_vision/frontend/components/PlayerSidebarObservationsTab.tsx b/products/replay_vision/frontend/components/PlayerSidebarObservationsTab.tsxindex b0dccb937dcd..141f0c0eef23 100644--- a/products/replay_vision/frontend/components/PlayerSidebarObservationsTab.tsx+++ b/products/replay_vision/frontend/components/PlayerSidebarObservationsTab.tsx@@ -1,38 +1,9 @@-import { useActions, useValues } from 'kea'-import { router } from 'kea-router'-import { useEffect, useMemo, useRef } from 'react'+import { useValues } from 'kea'-import { IconChevronDown, IconChevronRight, IconEye } from '@posthog/icons'-import { LemonButton, LemonInput, LemonSwitch, LemonTag, Link, Spinner, Tooltip } from '@posthog/lemon-ui'--import { useResizeObserver } from 'lib/hooks/useResizeObserver'-import { LemonDropdown } from 'lib/lemon-ui/LemonDropdown/LemonDropdown'-import { cn } from 'lib/utils/css-classes'import { sessionRecordingPlayerLogic } from 'scenes/session-recordings/player/sessionRecordingPlayerLogic'-import { urls } from 'scenes/urls'-import type { ReplayObservationApi, ReplayScannerApi } from '../generated/api.schemas'-import { observationsDockLogic } from '../logics/observationsDockLogic'-import { visionQuotaLogic } from '../logics/visionQuotaLogic'-import { SCANNER_TYPE_TAG_TYPE, scannerTypeLabel } from '../replay_scanners/types'-import { RECORDING_ORIGIN, currentReturnPath, observationFromOriginUrl } from '../utils/breadcrumbs'-import { isSummaryObservation, readModelOutput, readReasoning, scannerLabel } from '../utils/observation'-import { quotaUx } from '../utils/quotaProjection'-import { currentRowIndex, nextTimelineStopMs, timelineRows as buildTimelineRows } from '../utils/recordingTimeline'-import { ScanBlock, recordingScanBlock } from '../utils/scanEligibility'import { visionSurfaceShown } from '../utils/visionSurface'-import { CitedMarkdown } from './CitedMarkdown'-import {- FailureDetail,- IneligibleDetail,- ObservationPrimaryOutput,- ObservationResultSummary,- ObservationStatusTag,-} from './ObservationCard'-import { ObservationProgressBar } from './ObservationProgressBar'-import { ObservationRetryButton } from './ObservationRetryButton'-import { RecordingTimeline } from './RecordingTimeline'-import { ScannerTypeBadge, scannerTypeIcon } from './ScannerTypeBadge'+import { RecordingMoments } from './RecordingMoments'export function PlayerSidebarObservationsTab(): JSX.Element | null {const { sessionRecordingId, logicProps } = useValues(sessionRecordingPlayerLogic)@@ -41,398 +12,5 @@ export function PlayerSidebarObservationsTab(): JSX.Element | null {if (!visionSurfaceShown(logicProps) || !sessionRecordingId) {return null}- return <ObservationsTabContent key={sessionRecordingId} sessionId={sessionRecordingId} />-}--function ScannerPicker({- sessionId,- scanBlock,- type = 'primary',- placement = 'bottom-start',-}: {- sessionId: string- scanBlock: ScanBlock | null- type?: 'primary' | 'secondary'- placement?: 'bottom-start' | 'top-start'-}): JSX.Element {- const logic = observationsDockLogic({ sessionId })- const { scanners, scannersLoading, filteredScanners, scannerSearch, scannerPickerOpen, observing } =- useValues(logic)- const { observe, setScannerSearch, setScannerPickerOpen } = useActions(logic)- const { quota } = useValues(visionQuotaLogic)- const { disabledReason: quotaDisabledReason, tooltip: quotaTooltip } = quotaUx(quota)-- return (- <LemonDropdown- visible={scannerPickerOpen}- onVisibilityChange={setScannerPickerOpen}- closeOnClickInside={false}- placement={placement}- overlay={- <div className="w-80">- <div className="p-1 border-b">- <LemonInput- data-attr="vision-observations-tab-search"- type="search"- size="small"- placeholder="Search scanners…"- value={scannerSearch}- onChange={setScannerSearch}- autoFocus- />- </div>- <div className="max-h-80 overflow-y-auto p-1">- {scanners.length === 0 && scannersLoading ? (- <div className="flex items-center gap-2 px-2 py-3 text-sm text-muted">- <Spinner /> Loading scanners…- </div>- ) : scanners.length === 0 ? (- <Link- data-attr="vision-observations-open-scanners"- to={urls.replayVision()}- target="_blank"- className="block px-2 py-3 text-sm"- >- No scanners yet — create one- </Link>- ) : filteredScanners.length === 0 ? (- <div className="px-2 py-3 text-sm text-muted">No scanners match your search.</div>- ) : (- filteredScanners.map((scanner: ReplayScannerApi) => (- <LemonButton- key={scanner.id}- fullWidth- size="small"- onClick={() => observe(scanner.id)}- disabledReason={observing ? 'Starting an observation…' : undefined}- data-attr="vision-scan-pick-scanner"- data-ph-capture-attribute-scanner-type={scanner.scanner_type}- >- <span className="flex items-center justify-between gap-2 w-full">- <span className="truncate">{scanner.name}</span>- <span className="shrink-0">- <ScannerTypeBadge scannerType={scanner.scanner_type} size="small" />- </span>- </span>- </LemonButton>- ))- )}- </div>- </div>- }- >- <LemonButton- size="small"- type={type}- icon={<IconEye />}- sideIcon={<IconChevronDown />}- loading={observing}- disabledReason={scanBlock?.reason ?? quotaDisabledReason}- tooltip={quotaTooltip}- data-attr="vision-scan-recording"- >- Scan this recording- </LemonButton>- </LemonDropdown>- )-}--const CURRENT_MOMENT_SELECTOR = '[data-current-moment]'--const isInFlight = (o: ReplayObservationApi): boolean => o.status === 'pending' || o.status === 'running'--function defaultFocus(observations: ReplayObservationApi[]): ReplayObservationApi | null {- return (- observations.find(isInFlight) ?? observations.find((o) => o.status === 'succeeded') ?? observations[0] ?? null- )-}--function ObservationRuns({- sessionId,- observations,- onSeek,-}: {- sessionId: string- observations: ReplayObservationApi[]- onSeek: (timestampMs: number) => void-}): JSX.Element | null {- const logic = observationsDockLogic({ sessionId })- const { focusedObservationId, retryingObservationIds } = useValues(logic)- const { focusObservation, retryObservation } = useActions(logic)- if (observations.length === 0) {- return null- }- const focused = observations.find((o) => o.id === focusedObservationId) ?? defaultFocus(observations)- return (- <>- <SectionHeader label="Observations" />- <div>- {observations.map((observation) => {- const scannerType = observation.scanner_snapshot?.scanner_type- return (- <div key={observation.id} className="border-b border-primary">- <LemonButton- fullWidth- size="small"- className="rounded-none"- active={observation.id === focused?.id}- icon={- scannerType ? (- <Tooltip title={scannerTypeLabel(scannerType)}>- <LemonTag type={SCANNER_TYPE_TAG_TYPE[scannerType]} size="small">- {scannerTypeIcon(scannerType)}- </LemonTag>- </Tooltip>- ) : undefined- }- onClick={() => focusObservation(observation.id)}- data-attr="vision-run-row"- >- <span className="flex items-center gap-2 min-w-0 w-full font-normal">- <span className="text-sm truncate flex-1">{scannerLabel(observation)}</span>- <span className="flex items-center gap-2 min-w-0 max-w-[60%]">- <RunResult observation={observation} />- </span>- </span>- </LemonButton>- {observation.id === focused?.id && (- <FocusPane- observation={observation}- onSeek={onSeek}- onRetry={() => retryObservation(observation.id)}- retrying={retryingObservationIds.includes(observation.id)}- />- )}- </div>- )- })}- </div>- </>- )-}--function SectionHeader({ label, className }: { label: string; className?: string }): JSX.Element {- return (- <div- className={cn(- 'flex items-center gap-2 px-3 py-1.5 border-y border-primary bg-surface-tertiary dark:bg-surface-secondary text-xs font-semibold uppercase tracking-wide text-secondary',- className- )}- >- {label}- </div>- )-}--function RunResult({ observation }: { observation: ReplayObservationApi }): JSX.Element | null {- if (observation.status !== 'succeeded') {- return <ObservationStatusTag status={observation.status} errorReason={observation.error_reason} />- }- if (isSummaryObservation(observation)) {- return null- }- return <ObservationResultSummary observation={observation} />-}--function FocusPane({- observation,- onSeek,- onRetry,- retrying,-}: {- observation: ReplayObservationApi- onSeek: (timestampMs: number) => void- onRetry: () => void- retrying: boolean-}): JSX.Element {- const { height: contentHeight, ref: contentRef } = useResizeObserver<HTMLDivElement>({ box: 'border-box' })- const { location } = useValues(router)- const isSummary = isSummaryObservation(observation)- const reasoning = observation.status === 'succeeded' && !isSummary ? readReasoning(observation) : null- const hasText = observation.status === 'succeeded' && (isSummary || reasoning !== null)- return (- <div- className="overflow-hidden transition-[height] duration-200 ease-in-out border-t bg-surface-primary"- // eslint-disable-next-line react/forbid-dom-props- style={{ height: contentHeight }}- data-attr="vision-focus-run"- >- <div ref={contentRef}>- {(observation.error_reason || isInFlight(observation)) && (- <div className="flex flex-col gap-2 px-2 pb-2">- {observation.status === 'failed' && observation.error_reason && (- <FailureDetail errorReason={observation.error_reason} />- )}- {observation.status === 'ineligible' && observation.error_reason && (- <IneligibleDetail errorReason={observation.error_reason} />- )}- {observation.error_reason && (- <div>- <ObservationRetryButton- status={observation.status}- errorReason={observation.error_reason}- onRetry={onRetry}- loading={retrying}- size="xsmall"- dataAttr="vision-tab-retry-observation"- />- </div>- )}- {isInFlight(observation) && (- <ObservationProgressBar observationId={observation.id} sessionId={observation.session_id} />- )}- </div>- )}- <div className="flex flex-col gap-2 px-2 py-2">- {hasText && (- <div className="text-sm">- {isSummary ? (- <ObservationPrimaryOutput- observation={observation}- showPrompt={false}- expandSummary- copyable- onSeek={onSeek}- />- ) : (- <CitedMarkdown- text={reasoning ?? ''}- segments={readModelOutput(observation)?.reasoning_segments}- onSeek={onSeek}- />- )}- </div>- )}- <Link- data-attr="vision-observation-open-from-sidebar"- to={observationFromOriginUrl(observation.id, RECORDING_ORIGIN, currentReturnPath(location))}- className="text-xs self-end"- >- View details- </Link>- </div>- </div>- </div>- )-}--function ObservationsTabContent({ sessionId }: { sessionId: string }): JSX.Element {- const logic = observationsDockLogic({ sessionId })- const { observations, observationsLoading, timeline, followMoments, summarizePending } = useValues(logic)- const { setFollowMoments, summarize } = useActions(logic)- const { quota } = useValues(visionQuotaLogic)- const { disabledReason: quotaDisabledReason } = quotaUx(quota)- const lastJumpMs = useRef<number | null>(null)- const timelineRef = useRef<HTMLDivElement>(null)- const followedIndex = useRef<number | null>(null)- // The player logic is keyed; seek the exact mounted instance, not a propless default- const { logicProps, sessionPlayerMetaData, currentPlayerTime, sessionPlayerData } =- useValues(sessionRecordingPlayerLogic)- const durationMs = sessionPlayerData.durationMs > 0 ? sessionPlayerData.durationMs : null- const timelineRows = useMemo(() => buildTimelineRows(timeline, durationMs), [timeline, durationMs])- const seekToTime = (ms: number): void => {- sessionRecordingPlayerLogic.findMounted(logicProps)?.actions.seekToTime(ms)- }- const scanBlock = recordingScanBlock(sessionPlayerMetaData)- // A seek can land short of its target; step from the last jump while still on it.- const nextFrom =- lastJumpMs.current !== null && Math.abs(currentPlayerTime - lastJumpMs.current) < 1000- ? lastJumpMs.current- : currentPlayerTime- const nextStopMs = nextTimelineStopMs(timeline, nextFrom)- const jumpToNext = (): void => {- if (nextStopMs === null) {- return- }- lastJumpMs.current = nextStopMs- seekToTime(nextStopMs)- }- const currentIndex = currentRowIndex(timelineRows, currentPlayerTime)-- useEffect(() => {- if (!followMoments) {- followedIndex.current = null- return- }- if (currentIndex < 0 || followedIndex.current === currentIndex) {- return- }- followedIndex.current = currentIndex- timelineRef.current?.querySelector<HTMLElement>(CURRENT_MOMENT_SELECTOR)?.scrollIntoView({ block: 'nearest' })- }, [currentIndex, followMoments])-- return (- // A container, so long observation text wraps at the sidebar's width instead of widening the sidebar.- <div className="@container flex flex-col flex-1 min-h-0" data-attr="vision-observations-tab">- {observationsLoading && observations.length === 0 ? (- <div className="flex items-center gap-2 text-muted p-4">- <Spinner /> Loading observations…- </div>- ) : observations.length === 0 ? (- <div className="flex flex-col flex-1 items-center justify-center gap-2 p-4 text-center">- {scanBlock ? (- // No scanner can clear the gate for this recording, so offering the picker would- // only lead to an ineligible result.- <>- <p className="text-muted text-sm mb-0" data-attr="vision-observations-tab-skipped">- Replay vision skipped this recording, so it has no summary.- </p>- <p className="text-muted text-xs mb-0">{scanBlock.reason}</p>- </>- ) : (- <>- <p className="text-muted text-sm mb-0">- No observations yet. Pick a scanner to run on this recording.- </p>- <ScannerPicker sessionId={sessionId} scanBlock={scanBlock} />- </>- )}- </div>- ) : (- <>- <div className="@container flex items-center gap-2 p-2 border-b bg-surface-secondary">- <ScannerPicker sessionId={sessionId} scanBlock={scanBlock} type="secondary" />- {timelineRows.length > 0 && (- <div className="ml-auto flex items-center gap-2">- <LemonSwitch- size="xsmall"- checked={followMoments}- onChange={setFollowMoments}- label="Follow"- data-attr="vision-follow-moments"- />- <span className="hidden @[400px]:block">- <LemonButton- size="small"- type="secondary"- sideIcon={<IconChevronRight />}- disabledReason={- nextStopMs !== null ? undefined : 'Nothing later in the recording'- }- onClick={jumpToNext}- data-attr="vision-next-moment"- >- Next- </LemonButton>- </span>- </div>- )}- </div>- <div className="flex-1 min-h-0 overflow-y-auto" ref={timelineRef}>- <SectionHeader label="Timeline" />- <RecordingTimeline- timeline={timeline}- rows={timelineRows}- currentTimeMs={currentPlayerTime}- onSeek={seekToTime}- onSummarize={summarize}- summarizing={summarizePending}- summarizeDisabledReason={scanBlock?.reason ?? quotaDisabledReason}- />- <ObservationRuns sessionId={sessionId} observations={observations} onSeek={seekToTime} />- </div>- </>- )}- </div>- )+ return <RecordingMoments key={sessionRecordingId} sessionId={sessionRecordingId} playerLogicProps={logicProps} />}diff --git a/products/replay_vision/frontend/components/RecordingMoments.tsx b/products/replay_vision/frontend/components/RecordingMoments.tsxnew file mode 100644index 000000000000..a38e843cf135--- /dev/null+++ b/products/replay_vision/frontend/components/RecordingMoments.tsx@@ -0,0 +1,441 @@+import { useActions, useValues } from 'kea'+import { router } from 'kea-router'+import { useEffect, useMemo, useRef } from 'react'++import { IconChevronDown, IconChevronRight, IconEye } from '@posthog/icons'+import { LemonButton, LemonInput, LemonSwitch, LemonTag, Link, Spinner, Tooltip } from '@posthog/lemon-ui'++import { useResizeObserver } from 'lib/hooks/useResizeObserver'+import { LemonDropdown } from 'lib/lemon-ui/LemonDropdown/LemonDropdown'+import { cn } from 'lib/utils/css-classes'+import { playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'+import {+ SessionRecordingPlayerLogicProps,+ sessionRecordingPlayerLogic,+} from 'scenes/session-recordings/player/sessionRecordingPlayerLogic'+import { playerUsesWatchLayout } from 'scenes/session-recordings/playlist/replayLayout'+import { urls } from 'scenes/urls'++import type { ReplayObservationApi, ReplayScannerApi } from '../generated/api.schemas'+import { observationsDockLogic } from '../logics/observationsDockLogic'+import { visionQuotaLogic } from '../logics/visionQuotaLogic'+import { SCANNER_TYPE_TAG_TYPE, scannerTypeLabel } from '../replay_scanners/types'+import { RECORDING_ORIGIN, currentReturnPath, observationFromOriginUrl } from '../utils/breadcrumbs'+import { isSummaryObservation, readModelOutput, readReasoning, scannerLabel } from '../utils/observation'+import { quotaUx } from '../utils/quotaProjection'+import { currentRowIndex, nextTimelineStopMs, timelineRows as buildTimelineRows } from '../utils/recordingTimeline'+import { ScanBlock, recordingScanBlock } from '../utils/scanEligibility'+import { CitedMarkdown } from './CitedMarkdown'+import {+ FailureDetail,+ IneligibleDetail,+ ObservationPrimaryOutput,+ ObservationResultSummary,+ ObservationStatusTag,+} from './ObservationCard'+import { ObservationProgressBar } from './ObservationProgressBar'+import { ObservationRetryButton } from './ObservationRetryButton'+import { RecordingTimeline } from './RecordingTimeline'+import { ScannerTypeBadge, scannerTypeIcon } from './ScannerTypeBadge'++function ScannerPicker({+ sessionId,+ scanBlock,+ type = 'primary',+ placement = 'bottom-start',+}: {+ sessionId: string+ scanBlock: ScanBlock | null+ type?: 'primary' | 'secondary'+ placement?: 'bottom-start' | 'top-start'+}): JSX.Element {+ const logic = observationsDockLogic({ sessionId })+ const { scanners, scannersLoading, filteredScanners, scannerSearch, scannerPickerOpen, observing } =+ useValues(logic)+ const { observe, setScannerSearch, setScannerPickerOpen } = useActions(logic)+ const { quota } = useValues(visionQuotaLogic)+ const { disabledReason: quotaDisabledReason, tooltip: quotaTooltip } = quotaUx(quota)++ return (+ <LemonDropdown+ visible={scannerPickerOpen}+ onVisibilityChange={setScannerPickerOpen}+ closeOnClickInside={false}+ placement={placement}+ overlay={+ <div className="w-80">+ <div className="p-1 border-b">+ <LemonInput+ data-attr="vision-observations-tab-search"+ type="search"+ size="small"+ placeholder="Search scanners…"+ value={scannerSearch}+ onChange={setScannerSearch}+ autoFocus+ />+ </div>+ <div className="max-h-80 overflow-y-auto p-1">+ {scanners.length === 0 && scannersLoading ? (+ <div className="flex items-center gap-2 px-2 py-3 text-sm text-muted">+ <Spinner /> Loading scanners…+ </div>+ ) : scanners.length === 0 ? (+ <Link+ data-attr="vision-observations-open-scanners"+ to={urls.replayVision()}+ target="_blank"+ className="block px-2 py-3 text-sm"+ >+ No scanners yet. Create one+ </Link>+ ) : filteredScanners.length === 0 ? (+ <div className="px-2 py-3 text-sm text-muted">No scanners match your search.</div>+ ) : (+ filteredScanners.map((scanner: ReplayScannerApi) => (+ <LemonButton+ key={scanner.id}+ fullWidth+ size="small"+ onClick={() => observe(scanner.id)}+ disabledReason={observing ? 'Starting an observation…' : undefined}+ data-attr="vision-scan-pick-scanner"+ data-ph-capture-attribute-scanner-type={scanner.scanner_type}+ >+ <span className="flex items-center justify-between gap-2 w-full">+ <span className="truncate">{scanner.name}</span>+ <span className="shrink-0">+ <ScannerTypeBadge scannerType={scanner.scanner_type} size="small" />+ </span>+ </span>+ </LemonButton>+ ))+ )}+ </div>+ </div>+ }+ >+ <LemonButton+ size="small"+ type={type}+ icon={<IconEye />}+ sideIcon={<IconChevronDown />}+ loading={observing}+ disabledReason={scanBlock?.reason ?? quotaDisabledReason}+ tooltip={quotaTooltip}+ data-attr="vision-scan-recording"+ >+ Scan this recording+ </LemonButton>+ </LemonDropdown>+ )+}++const CURRENT_MOMENT_SELECTOR = '[data-current-moment]'++const isInFlight = (o: ReplayObservationApi): boolean => o.status === 'pending' || o.status === 'running'++function defaultFocus(observations: ReplayObservationApi[]): ReplayObservationApi | null {+ return (+ observations.find(isInFlight) ?? observations.find((o) => o.status === 'succeeded') ?? observations[0] ?? null+ )+}++function ObservationRuns({+ sessionId,+ observations,+ onSeek,+}: {+ sessionId: string+ observations: ReplayObservationApi[]+ onSeek: (timestampMs: number) => void+}): JSX.Element | null {+ const logic = observationsDockLogic({ sessionId })+ const { focusedObservationId, retryingObservationIds } = useValues(logic)+ const { focusObservation, retryObservation } = useActions(logic)+ if (observations.length === 0) {+ return null+ }+ const focused = observations.find((o) => o.id === focusedObservationId) ?? defaultFocus(observations)+ return (+ <>+ <SectionHeader label="Observations" />+ <div>+ {observations.map((observation) => {+ const scannerType = observation.scanner_snapshot?.scanner_type+ return (+ <div key={observation.id} className="border-b border-primary">+ <LemonButton+ fullWidth+ size="small"+ className="rounded-none"+ active={observation.id === focused?.id}+ icon={+ scannerType ? (+ <Tooltip title={scannerTypeLabel(scannerType)}>+ <LemonTag type={SCANNER_TYPE_TAG_TYPE[scannerType]} size="small">+ {scannerTypeIcon(scannerType)}+ </LemonTag>+ </Tooltip>+ ) : undefined+ }+ onClick={() => focusObservation(observation.id)}+ data-attr="vision-run-row"+ >+ <span className="flex items-center gap-2 min-w-0 w-full font-normal">+ <span className="text-sm truncate flex-1">{scannerLabel(observation)}</span>+ <span className="flex items-center gap-2 min-w-0 max-w-[60%]">+ <RunResult observation={observation} />+ </span>+ </span>+ </LemonButton>+ {observation.id === focused?.id && (+ <FocusPane+ observation={observation}+ onSeek={onSeek}+ onRetry={() => retryObservation(observation.id)}+ retrying={retryingObservationIds.includes(observation.id)}+ />+ )}+ </div>+ )+ })}+ </div>+ </>+ )+}++function SectionHeader({ label, className }: { label: string; className?: string }): JSX.Element {+ return (+ <div+ className={cn(+ 'flex items-center gap-2 px-3 py-1.5 border-y border-primary bg-surface-tertiary dark:bg-surface-secondary text-xs font-semibold uppercase tracking-wide text-secondary',+ className+ )}+ >+ {label}+ </div>+ )+}++function RunResult({ observation }: { observation: ReplayObservationApi }): JSX.Element | null {+ if (observation.status !== 'succeeded') {+ return <ObservationStatusTag status={observation.status} errorReason={observation.error_reason} />+ }+ if (isSummaryObservation(observation)) {+ return null+ }+ return <ObservationResultSummary observation={observation} />+}++function FocusPane({+ observation,+ onSeek,+ onRetry,+ retrying,+}: {+ observation: ReplayObservationApi+ onSeek: (timestampMs: number) => void+ onRetry: () => void+ retrying: boolean+}): JSX.Element {+ const { height: contentHeight, ref: contentRef } = useResizeObserver<HTMLDivElement>({ box: 'border-box' })+ const { location } = useValues(router)+ const isSummary = isSummaryObservation(observation)+ const reasoning = observation.status === 'succeeded' && !isSummary ? readReasoning(observation) : null+ const hasText = observation.status === 'succeeded' && (isSummary || reasoning !== null)+ return (+ <div+ className="overflow-hidden transition-[height] duration-200 ease-in-out border-t bg-surface-primary"+ // eslint-disable-next-line react/forbid-dom-props+ style={{ height: contentHeight }}+ data-attr="vision-focus-run"+ >+ <div ref={contentRef}>+ {(observation.error_reason || isInFlight(observation)) && (+ <div className="flex flex-col gap-2 px-2 pb-2">+ {observation.status === 'failed' && observation.error_reason && (+ <FailureDetail errorReason={observation.error_reason} />+ )}+ {observation.status === 'ineligible' && observation.error_reason && (+ <IneligibleDetail errorReason={observation.error_reason} />+ )}+ {observation.error_reason && (+ <div>+ <ObservationRetryButton+ status={observation.status}+ errorReason={observation.error_reason}+ onRetry={onRetry}+ loading={retrying}+ size="xsmall"+ dataAttr="vision-tab-retry-observation"+ />+ </div>+ )}+ {isInFlight(observation) && (+ <ObservationProgressBar observationId={observation.id} sessionId={observation.session_id} />+ )}+ </div>+ )}+ <div className="flex flex-col gap-2 px-2 py-2">+ {hasText && (+ <div className="text-sm">+ {isSummary ? (+ <ObservationPrimaryOutput+ observation={observation}+ showPrompt={false}+ expandSummary+ copyable+ onSeek={onSeek}+ />+ ) : (+ <CitedMarkdown+ text={reasoning ?? ''}+ segments={readModelOutput(observation)?.reasoning_segments}+ onSeek={onSeek}+ />+ )}+ </div>+ )}+ <Link+ data-attr="vision-observation-open-from-sidebar"+ to={observationFromOriginUrl(observation.id, RECORDING_ORIGIN, currentReturnPath(location))}+ className="text-xs self-end"+ >+ View details+ </Link>+ </div>+ </div>+ </div>+ )+}++export interface RecordingMomentsProps {+ sessionId: string+ /** The player this column seeks and follows. It is keyed, so the exact mounted instance is named. */+ playerLogicProps: SessionRecordingPlayerLogicProps+}++/** The chapter timeline and observation runs of one recording: the Observations tab, and the Moments list segment. */+export function RecordingMoments({ sessionId, playerLogicProps }: RecordingMomentsProps): JSX.Element {+ const logic = observationsDockLogic({ sessionId })+ const { observations, observationsLoading, timeline, followMoments, summarizePending } = useValues(logic)+ const { setFollowMoments, summarize } = useActions(logic)+ const { replayLayout } = useValues(playerSettingsLogic)+ const inWatchLayout = playerUsesWatchLayout(replayLayout, playerLogicProps)+ const { quota } = useValues(visionQuotaLogic)+ const { disabledReason: quotaDisabledReason } = quotaUx(quota)+ const lastJumpMs = useRef<number | null>(null)+ const timelineRef = useRef<HTMLDivElement>(null)+ const followedIndex = useRef<number | null>(null)+ const { logicProps, sessionPlayerMetaData, currentPlayerTime, sessionPlayerData } = useValues(+ sessionRecordingPlayerLogic(playerLogicProps)+ )+ const durationMs = sessionPlayerData.durationMs > 0 ? sessionPlayerData.durationMs : null+ const timelineRows = useMemo(() => buildTimelineRows(timeline, durationMs), [timeline, durationMs])+ const seekToTime = (ms: number): void => {+ sessionRecordingPlayerLogic.findMounted(logicProps)?.actions.seekToTime(ms)+ }+ const scanBlock = recordingScanBlock(sessionPlayerMetaData)+ // A seek can land short of its target. Step from the last jump while still on it.+ const nextFrom =+ lastJumpMs.current !== null && Math.abs(currentPlayerTime - lastJumpMs.current) < 1000+ ? lastJumpMs.current+ : currentPlayerTime+ const nextStopMs = nextTimelineStopMs(timeline, nextFrom)+ const jumpToNext = (): void => {+ if (nextStopMs === null) {+ return+ }+ lastJumpMs.current = nextStopMs+ seekToTime(nextStopMs)+ }+ const currentIndex = currentRowIndex(timelineRows, currentPlayerTime)++ useEffect(() => {+ if (!followMoments) {+ followedIndex.current = null+ return+ }+ if (currentIndex < 0 || followedIndex.current === currentIndex) {+ return+ }+ followedIndex.current = currentIndex+ timelineRef.current?.querySelector<HTMLElement>(CURRENT_MOMENT_SELECTOR)?.scrollIntoView({ block: 'nearest' })+ }, [currentIndex, followMoments])++ return (+ // A container, so long observation text wraps at the sidebar's width instead of widening the sidebar.+ <div className="@container flex flex-col flex-1 min-h-0" data-attr="vision-observations-tab">+ {observationsLoading && observations.length === 0 ? (+ <div className="flex items-center gap-2 text-muted p-4">+ <Spinner /> Loading observations…+ </div>+ ) : observations.length === 0 ? (+ <div className="flex flex-col flex-1 items-center justify-center gap-2 p-4 text-center">+ {scanBlock ? (+ // No scanner can clear the gate for this recording, so offering the picker would+ // only lead to an ineligible result.+ <>+ <p className="text-muted text-sm mb-0" data-attr="vision-observations-tab-skipped">+ Replay vision skipped this recording, so it has no summary.+ </p>+ <p className="text-muted text-xs mb-0">{scanBlock.reason}</p>+ </>+ ) : (+ <>+ <p className="text-muted text-sm mb-0">+ No observations yet. Pick a scanner to run on this recording.+ </p>+ <ScannerPicker sessionId={sessionId} scanBlock={scanBlock} />+ </>+ )}+ </div>+ ) : (+ <>+ <div className="@container flex items-center gap-2 p-2 border-b bg-surface-secondary">+ <ScannerPicker sessionId={sessionId} scanBlock={scanBlock} type="secondary" />+ {timelineRows.length > 0 && (+ <div className="ml-auto flex items-center gap-2">+ <LemonSwitch+ size="xsmall"+ checked={followMoments}+ onChange={setFollowMoments}+ label="Follow"+ data-attr="vision-follow-moments"+ />+ <span className="hidden @[400px]:block">+ <LemonButton+ size="small"+ type="secondary"+ sideIcon={<IconChevronRight />}+ disabledReason={+ nextStopMs !== null ? undefined : 'Nothing later in the recording'+ }+ onClick={jumpToNext}+ data-attr="vision-next-moment"+ >+ Next+ </LemonButton>+ </span>+ </div>+ )}+ </div>+ <div className="flex-1 min-h-0 overflow-y-auto" ref={timelineRef}>+ <SectionHeader label="Timeline" />+ <RecordingTimeline+ timeline={timeline}+ rows={timelineRows}+ currentTimeMs={currentPlayerTime}+ onSeek={seekToTime}+ onSummarize={() => summarize(inWatchLayout)}+ summarizing={summarizePending}+ summarizeDisabledReason={scanBlock?.reason ?? quotaDisabledReason}+ />+ <ObservationRuns sessionId={sessionId} observations={observations} onSeek={seekToTime} />+ </div>+ </>+ )}+ </div>+ )+}diff --git a/products/replay_vision/frontend/components/SummarizeButton.tsx b/products/replay_vision/frontend/components/SummarizeButton.tsxnew file mode 100644index 000000000000..978ee2f30257--- /dev/null+++ b/products/replay_vision/frontend/components/SummarizeButton.tsx@@ -0,0 +1,152 @@+import { useActions, useValues } from 'kea'+import posthog from 'posthog-js'+import { useState } from 'react'++import { IconChevronDown, IconLogomark, IconNotebook } from '@posthog/icons'+import { LemonButton } from '@posthog/lemon-ui'++import { LemonMenuItem, LemonMenuOverlay } from 'lib/lemon-ui/LemonMenu/LemonMenu'+import { aiConsentLogic } from 'scenes/settings/organization/aiConsentLogic'+import { AIConsentPopoverWrapper } from 'scenes/settings/organization/AIConsentPopoverWrapper'++import type { ReplayScannerApi } from '../generated/api.schemas'+import { observationsDockLogic } from '../logics/observationsDockLogic'+import { visionQuotaLogic } from '../logics/visionQuotaLogic'+import { BUILT_IN_SUMMARY_LABEL, isSummaryObservation } from '../utils/observation'+import { quotaUx } from '../utils/quotaProjection'+import { ScanBlock } from '../utils/scanEligibility'+import { useSummarizeBlockedReason } from './useSummarizeBlockedReason'++/** Runs whichever summarizer `resolveSummarizer` settles on, and lets the user pick another. */+export function SummarizeButton({+ sessionId,+ scanBlock,+ inWatchLayout = false,+}: {+ sessionId: string+ scanBlock: ScanBlock | null+ inWatchLayout?: boolean+}): JSX.Element {+ const logic = observationsDockLogic({ sessionId })+ 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)+ const { tooltip: quotaTooltip } = quotaUx(quota)+ const blockedReason = useSummarizeBlockedReason(scanBlock)+ // `loading` only disables the button itself. The caret and the menu rows are their own buttons, so+ // without this a second summarizer is one click away mid-run, and it spends the quota again.+ const inFlightDisabledReason = summarizePending ? 'A summary is already running' : null+ const builtInDisabledReason = inFlightDisabledReason ?? blockedReason()+ const scannerDisabledReason = (scanner: ReplayScannerApi): string | null | undefined =>+ inFlightDisabledReason ?? 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 = hasSummary+ ? 'Summarize again'+ : defaultSummarizer+ ? `Summarize with ${defaultSummarizer.name}`+ : 'Summarize this recording'+ const label = summarizePending ? 'Summarizing…' : idleLabel+ const summarizerTooltip = summarizePending+ ? `Watching this recording. The summary appears in the ${inWatchLayout ? 'Scans segment' : 'Observations tab'} when it is ready.`+ : defaultSummarizer+ ? `Runs your "${defaultSummarizer.name}" scanner on this recording.`+ : 'Writes a summary using a built-in prompt.'++ const menuItems: LemonMenuItem[] = [+ ...summarizerScanners.map((scanner) => ({+ key: scanner.id,+ label: scanner.name,+ active: scanner.id === defaultSummarizer?.id,+ disabledReason: scannerDisabledReason(scanner),+ onClick: () => summarizeWith(scanner.id, inWatchLayout),+ 'data-attr': 'vision-summarize-pick-scanner',+ })),+ {+ key: 'built-in',+ // Every other row is a scanner the team owns and can open. This one is PostHog's, so it+ // carries the logomark and says so, rather than reading as a scanner they cannot find.+ label: (+ <span className="flex items-center justify-between gap-2 w-full">+ <span className="truncate">{BUILT_IN_SUMMARY_LABEL}</span>+ <span className="flex items-center gap-1.5 text-xs shrink-0">+ <IconLogomark className="text-base text-primary" />+ <span className="text-muted">Built in</span>+ </span>+ </span>+ ),+ tooltip: 'Uses a built-in prompt. Nothing is saved to your scanners, so there is nothing to open or edit.',+ active: !defaultSummarizer,+ disabledReason: builtInDisabledReason,+ onClick: () => summarizeWith(null, inWatchLayout),+ 'data-attr': 'vision-summarize-pick-built-in',+ },+ ]++ const button = (+ <LemonButton+ size="small"+ 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.+ onClick={() => {+ posthog.capture('replay_vision_summarize_clicked', {+ // Repeat clicks are the point of this event, and `$session_id` cannot tell them+ // apart from one click each on two recordings.+ recording_id: sessionId,+ summarizer: defaultSummarizer ? 'configured' : 'built-in',+ consent_needed: !dataProcessingAccepted,+ })+ if (dataProcessingAccepted) {+ summarize(inWatchLayout)+ } else {+ setConsentRequested(true)+ }+ }}+ disabledReason={defaultSummarizer ? scannerDisabledReason(defaultSummarizer) : builtInDisabledReason}+ tooltip={quotaTooltip ?? summarizerTooltip}+ data-attr="vision-summarize-recording"+ data-ph-capture-attribute-summarizer={defaultSummarizer ? 'configured' : 'built-in'}+ // The dropdown is the only way to reach a second summarizer, so it appears once one exists.+ sideAction={+ summarizerScanners.length > 0 && dataProcessingAccepted+ ? {+ icon: <IconChevronDown />,+ dropdown: { placement: 'bottom-end', overlay: <LemonMenuOverlay items={menuItems} /> },+ divider: false,+ disabledReason: inFlightDisabledReason,+ 'aria-label': 'Choose a summarizer',+ 'data-attr': 'vision-summarize-choose',+ }+ : null+ }+ >+ <span className="truncate">{dataProcessingAccepted ? label : 'Allow AI analysis and summarize'}</span>+ </LemonButton>+ )++ if (dataProcessingAccepted) {+ return button+ }++ return (+ <AIConsentPopoverWrapper+ placement="bottom-end"+ showArrow+ ignoreDismissal+ hideTrainingDisclaimer+ hidden={!consentRequested}+ onApprove={() => {+ setConsentRequested(false)+ summarize(inWatchLayout)+ }}+ onDismiss={() => setConsentRequested(false)}+ >+ {button}+ </AIConsentPopoverWrapper>+ )+}diff --git a/products/replay_vision/frontend/components/SummarizeExplainer.tsx b/products/replay_vision/frontend/components/SummarizeExplainer.tsxnew file mode 100644index 000000000000..2bd756ae332a--- /dev/null+++ b/products/replay_vision/frontend/components/SummarizeExplainer.tsx@@ -0,0 +1,32 @@+import { IconInfo } from '@posthog/icons'+import { Tooltip } from '@posthog/lemon-ui'++import { visionDocsUrl } from './DocsLink'++/**+ * The bar sits on every standard replay player, so it reaches people who have never heard of Replay+ * vision and meet the summarize button with no idea what it is or what it will spend.+ */+export function SummarizeExplainer(): JSX.Element {+ return (+ <Tooltip+ placement="bottom"+ // Base UI opens tooltips on hover only, which leaves this unreachable on a touch device.+ openOnClick+ title={+ <>+ <p className="mb-1">Replay vision uses AI to watch recordings for you.</p>+ <p className="mb-0">+ Summarizing writes up what the user did in this session, so you can read it instead of watching+ it.+ </p>+ </>+ }+ docLink={`${visionDocsUrl()}?utm_medium=in-product&utm_campaign=summarize-explainer`}+ >+ <span className="inline-flex items-center text-muted" data-attr="vision-summarize-info">+ <IconInfo />+ </span>+ </Tooltip>+ )+}diff --git a/products/replay_vision/frontend/components/SummarizeRecordingBar.tsx b/products/replay_vision/frontend/components/SummarizeRecordingBar.tsxindex 1183f8d9acac..e2ed462df3a6 100644--- a/products/replay_vision/frontend/components/SummarizeRecordingBar.tsx+++ b/products/replay_vision/frontend/components/SummarizeRecordingBar.tsx@@ -1,33 +1,26 @@-import { useActions, useValues } from 'kea'-import posthog from 'posthog-js'-import { useState } from 'react'+import { useValues } from 'kea'-import { IconChevronDown, IconInfo, IconLogomark, IconNotebook } from '@posthog/icons'-import { LemonButton, Tooltip } from '@posthog/lemon-ui'+import { Tooltip } from '@posthog/lemon-ui'-import { LemonMenuItem, LemonMenuOverlay } from 'lib/lemon-ui/LemonMenu/LemonMenu'+import { playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'import { sessionRecordingDataCoordinatorLogic } from 'scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic'import { sessionRecordingPlayerLogic } from 'scenes/session-recordings/player/sessionRecordingPlayerLogic'-import { aiConsentLogic } from 'scenes/settings/organization/aiConsentLogic'-import { AIConsentPopoverWrapper } from 'scenes/settings/organization/AIConsentPopoverWrapper'+import { playerUsesWatchLayout } from 'scenes/session-recordings/playlist/replayLayout'-import { AccessControlLevel } from '~/types'--import type { ReplayScannerApi } from '../generated/api.schemas'import { observationsDockLogic } from '../logics/observationsDockLogic'-import { visionQuotaLogic } from '../logics/visionQuotaLogic'-import { limitReachedTooltip } from '../replay_scanners/scannerCopy'-import { getReplayVisionEditDisabledReason } from '../utils/accessControl'-import { BUILT_IN_SUMMARY_LABEL, isSummaryObservation } from '../utils/observation'-import { quotaUx } from '../utils/quotaProjection'-import { ScanBlock, recordingScanBlock } from '../utils/scanEligibility'-import { visionDocsUrl } from './DocsLink'+import { recordingScanBlock } from '../utils/scanEligibility'+import { SummarizeButton } from './SummarizeButton'+import { SummarizeExplainer } from './SummarizeExplainer'+import { useSummarizeBlockedReason } from './useSummarizeBlockedReason'export function SummarizeRecordingBar({extraActions,+ inline = false,}: {/** Recording actions the host places beside the summarize button. */extraActions?: React.ReactNode+ /** Just the controls, for a host that places them inside its own row. */+ inline?: boolean}): JSX.Element | null {const { sessionRecordingId, logicProps } = useValues(sessionRecordingPlayerLogic)const { isNotFound, isRecordingDeleted } = useValues(sessionRecordingDataCoordinatorLogic(logicProps))@@ -35,208 +28,39 @@ export function SummarizeRecordingBar({if (!sessionRecordingId || isNotFound || isRecordingDeleted) {return null}- return <SummarizeRecordingBarContent sessionId={sessionRecordingId} extraActions={extraActions} />-}--/**- * Why a summary cannot run on this recording right now, whatever summarizer would run it.- *- * Both paths are scanner writes: an inline scan mints a scanner, and `observe` is a write action on- * the scanner it runs. Each also exposes recording contents, so both need recording read as well. A- * recording the scan-time gate would refuse is refused for every summarizer, so it blocks the button- * and each menu row rather than spending a scan that comes back ineligible. Pass a scanner for the- * object-level check, so one this user cannot edit is refused here rather than by a 403.- *- * The bar reads this too: a disabled button explains itself on hover only, which is why people kept- * clicking one that could never run.- */-function useSummarizeBlockedReason(- scanBlock: ScanBlock | null-): (scanner?: ReplayScannerApi | null) => string | null | undefined {- const { quota } = useValues(visionQuotaLogic)- const { disabledReason: quotaDisabledReason } = quotaUx(quota)- return (scanner) =>- getReplayVisionEditDisabledReason((scanner?.user_access_level as AccessControlLevel | null) ?? undefined) ??- // `observe` answers 402 for a scanner that has spent its own credit limit, so a capped one is- // refused here rather than by a failed request. The built-in prompt has no per-scanner limit.- (scanner?.limit_reached ? limitReachedTooltip(scanner) : null) ??- scanBlock?.reason ??- quotaDisabledReason-}--/** 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, 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)- const { tooltip: quotaTooltip } = quotaUx(quota)- const blockedReason = useSummarizeBlockedReason(scanBlock)- // `loading` only disables the button itself. The caret and the menu rows are their own buttons, so- // without this a second summarizer is one click away mid-run, and it spends the quota again.- const inFlightDisabledReason = summarizePending ? 'A summary is already running' : null- const builtInDisabledReason = inFlightDisabledReason ?? blockedReason()- const scannerDisabledReason = (scanner: ReplayScannerApi): string | null | undefined =>- inFlightDisabledReason ?? 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 = hasSummary- ? 'Summarize again'- : defaultSummarizer- ? `Summarize with ${defaultSummarizer.name}`- : 'Summarize this recording'- const label = summarizePending ? 'Summarizing…' : idleLabel- const summarizerTooltip = summarizePending- ? 'Watching this recording. The summary appears in the Observations tab when it is ready.'- : defaultSummarizer- ? `Runs your "${defaultSummarizer.name}" scanner on this recording.`- : 'Writes a summary using a built-in prompt.'-- const menuItems: LemonMenuItem[] = [- ...summarizerScanners.map((scanner) => ({- key: scanner.id,- label: scanner.name,- active: scanner.id === defaultSummarizer?.id,- disabledReason: scannerDisabledReason(scanner),- onClick: () => summarizeWith(scanner.id),- 'data-attr': 'vision-summarize-pick-scanner',- })),- {- key: 'built-in',- // Every other row is a scanner the team owns and can open. This one is PostHog's, so it- // carries the logomark and says so, rather than reading as a scanner they cannot find.- label: (- <span className="flex items-center justify-between gap-2 w-full">- <span className="truncate">{BUILT_IN_SUMMARY_LABEL}</span>- <span className="flex items-center gap-1.5 text-xs shrink-0">- <IconLogomark className="text-base text-primary" />- <span className="text-muted">Built in</span>- </span>- </span>- ),- tooltip: 'Uses a built-in prompt. Nothing is saved to your scanners, so there is nothing to open or edit.',- active: !defaultSummarizer,- disabledReason: builtInDisabledReason,- onClick: () => summarizeWith(null),- 'data-attr': 'vision-summarize-pick-built-in',- },- ]-- const button = (- <LemonButton- size="small"- 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.- onClick={() => {- posthog.capture('replay_vision_summarize_clicked', {- // Repeat clicks are the point of this event, and `$session_id` cannot tell them- // apart from one click each on two recordings.- recording_id: sessionId,- summarizer: defaultSummarizer ? 'configured' : 'built-in',- consent_needed: !dataProcessingAccepted,- })- if (dataProcessingAccepted) {- summarize()- } else {- setConsentRequested(true)- }- }}- disabledReason={defaultSummarizer ? scannerDisabledReason(defaultSummarizer) : builtInDisabledReason}- tooltip={quotaTooltip ?? summarizerTooltip}- data-attr="vision-summarize-recording"- data-ph-capture-attribute-summarizer={defaultSummarizer ? 'configured' : 'built-in'}- // The dropdown is the only way to reach a second summarizer, so it appears once one exists.- sideAction={- summarizerScanners.length > 0 && dataProcessingAccepted- ? {- icon: <IconChevronDown />,- dropdown: { placement: 'bottom-end', overlay: <LemonMenuOverlay items={menuItems} /> },- divider: false,- disabledReason: inFlightDisabledReason,- 'aria-label': 'Choose a summarizer',- 'data-attr': 'vision-summarize-choose',- }- : null- }- >- <span className="truncate">{dataProcessingAccepted ? label : 'Allow AI analysis and summarize'}</span>- </LemonButton>- )-- if (dataProcessingAccepted) {- return button- }-- return (- <AIConsentPopoverWrapper- placement="bottom-end"- showArrow- ignoreDismissal- hideTrainingDisclaimer- hidden={!consentRequested}- onApprove={() => {- setConsentRequested(false)- summarize()- }}- onDismiss={() => setConsentRequested(false)}- >- {button}- </AIConsentPopoverWrapper>- )-}--/**- * The bar sits on every standard replay player, so it reaches people who have never heard of Replay- * vision and meet the summarize button with no idea what it is or what it will spend.- */-function SummarizeExplainer(): JSX.Element {- return (- <Tooltip- placement="bottom"- // Base UI opens tooltips on hover only, which leaves this unreachable on a touch device.- openOnClick- title={- <>- <p className="mb-1">Replay vision uses AI to watch recordings for you.</p>- <p className="mb-0">- Summarizing writes up what the user did in this session, so you can read it instead of watching- it.- </p>- </>- }- docLink={`${visionDocsUrl()}?utm_medium=in-product&utm_campaign=summarize-explainer`}- >- <span className="inline-flex items-center text-muted" data-attr="vision-summarize-info">- <IconInfo />- </span>- </Tooltip>- )+ return <SummarizeRecordingBarContent sessionId={sessionRecordingId} extraActions={extraActions} inline={inline} />}function SummarizeRecordingBarContent({sessionId,extraActions,+ inline,}: {sessionId: stringextraActions?: React.ReactNode+ inline: boolean}): JSX.Element {const { defaultSummarizer } = useValues(observationsDockLogic({ sessionId }))- const { sessionPlayerMetaData } = useValues(sessionRecordingPlayerLogic)+ const { sessionPlayerMetaData, logicProps } = useValues(sessionRecordingPlayerLogic)+ const { replayLayout } = useValues(playerSettingsLogic)const scanBlock = recordingScanBlock(sessionPlayerMetaData)const summarizeBlockedReason = useSummarizeBlockedReason(scanBlock)(defaultSummarizer)return (<div- className="flex items-center gap-2 lg:gap-3 h-11 px-3 shrink-0 border-t bg-surface-primary"+ className={+ inline+ ? 'flex items-center gap-2 min-w-0'+ : 'flex items-center gap-2 lg:gap-3 h-11 px-3 shrink-0 border-t bg-surface-primary'+ }// Frozen: dashboards and selectors still find the bar under its old name.data-attr="vision-observations-dock">- <SummarizeButton sessionId={sessionId} scanBlock={scanBlock} />+ <SummarizeButton+ sessionId={sessionId}+ scanBlock={scanBlock}+ inWatchLayout={playerUsesWatchLayout(replayLayout, logicProps)}+ /><SummarizeExplainer />{extraActions}{summarizeBlockedReason && (diff --git a/products/replay_vision/frontend/components/useSummarizeBlockedReason.ts b/products/replay_vision/frontend/components/useSummarizeBlockedReason.tsnew file mode 100644index 000000000000..b9fecda6682b--- /dev/null+++ b/products/replay_vision/frontend/components/useSummarizeBlockedReason.ts@@ -0,0 +1,36 @@+import { useValues } from 'kea'++import { AccessControlLevel } from '~/types'++import type { ReplayScannerApi } from '../generated/api.schemas'+import { visionQuotaLogic } from '../logics/visionQuotaLogic'+import { limitReachedTooltip } from '../replay_scanners/scannerCopy'+import { getReplayVisionEditDisabledReason } from '../utils/accessControl'+import { quotaUx } from '../utils/quotaProjection'+import { ScanBlock } from '../utils/scanEligibility'++/**+ * Why a summary cannot run on this recording right now, whatever summarizer would run it.+ *+ * Both paths are scanner writes: an inline scan mints a scanner, and `observe` is a write action on+ * the scanner it runs. Each also exposes recording contents, so both need recording read as well. A+ * recording the scan-time gate would refuse is refused for every summarizer, so it blocks the button+ * and each menu row rather than spending a scan that comes back ineligible. Pass a scanner for the+ * object-level check, so one this user cannot edit is refused here rather than by a 403.+ *+ * The bar reads this too: a disabled button explains itself on hover only, which is why people kept+ * clicking one that could never run.+ */+export function useSummarizeBlockedReason(+ scanBlock: ScanBlock | null+): (scanner?: ReplayScannerApi | null) => string | null | undefined {+ const { quota } = useValues(visionQuotaLogic)+ const { disabledReason: quotaDisabledReason } = quotaUx(quota)+ return (scanner) =>+ getReplayVisionEditDisabledReason((scanner?.user_access_level as AccessControlLevel | null) ?? undefined) ??+ // `observe` answers 402 for a scanner that has spent its own credit limit, so a capped one is+ // refused here rather than by a failed request. The built-in prompt has no per-scanner limit.+ (scanner?.limit_reached ? limitReachedTooltip(scanner) : null) ??+ scanBlock?.reason ??+ quotaDisabledReason+}diff --git a/products/replay_vision/frontend/logics/observationsDockLogic.ts b/products/replay_vision/frontend/logics/observationsDockLogic.tsindex 63d63b49b803..21cd019e9aaf 100644--- a/products/replay_vision/frontend/logics/observationsDockLogic.ts+++ b/products/replay_vision/frontend/logics/observationsDockLogic.ts@@ -49,6 +49,7 @@ export interface observationsDockLogicValues {filteredScanners: ReplayScannerApi[]focusedObservationId: string | nullfollowMoments: boolean+ hasLoadedObservations: booleanhasObservationsInFlight: booleanhoveredMarkMs: number | nullobservations: ReplayObservationApi[]@@ -125,11 +126,11 @@ export interface observationsDockLogicActions {setScannerSearch: (search: string) => {search: string}- showObservations: () => {- value: true+ showObservations: (inWatchLayout: boolean) => {+ inWatchLayout: boolean}- summarize: () => {- value: true+ summarize: (inWatchLayout?: boolean) => {+ inWatchLayout: boolean}summarizeFailure: () => {value: true@@ -140,7 +141,11 @@ export interface observationsDockLogicActions {summarizeSuccess: () => {value: true}- summarizeWith: (scannerId: string | null) => {+ summarizeWith: (+ scannerId: string | null,+ inWatchLayout?: boolean+ ) => {+ inWatchLayout: booleanscannerId: string | null}}@@ -202,14 +207,14 @@ export const observationsDockLogic = kea<observationsDockLogicType>([retryObservation: (observationId: string) => ({ observationId }),retryObservationSuccess: (observationId: string) => ({ observationId }),retryObservationFailure: (observationId: string) => ({ observationId }),- showObservations: true,+ showObservations: (inWatchLayout: boolean) => ({ inWatchLayout }),focusObservation: (observationId: string) => ({ observationId }),setFollowMoments: (follow: boolean) => ({ follow }),setHoveredMark: (timestampMs: number | null) => ({ timestampMs }),setScannerPickerOpen: (open: boolean) => ({ open }),setScannerSearch: (search: string) => ({ search }),- summarize: true,- summarizeWith: (scannerId: string | null) => ({ scannerId }),+ summarize: (inWatchLayout: boolean = false) => ({ inWatchLayout }),+ summarizeWith: (scannerId: string | null, inWatchLayout: boolean = false) => ({ scannerId, inWatchLayout }),summarizeSuccess: true,summarizeFailure: true,summarizeSettled: true,@@ -230,6 +235,13 @@ export const observationsDockLogic = kea<observationsDockLogicType>([loadObservationsFailure: () => false,},],+ hasLoadedObservations: [+ false,+ {+ loadObservationsSuccess: () => true,+ loadObservationsFailure: () => true,+ },+ ],observing: [false,{@@ -396,8 +408,8 @@ export const observationsDockLogic = kea<observationsDockLogicType>([}// Run a summary, through one of the team's own scanners or the built-in prompt. A named scanner// is just `observe`, which already owns its double-click guard and its already-run check.- const runSummary = async (scannerId: string | null): Promise<void> => {- actions.showObservations()+ const runSummary = async (scannerId: string | null, inWatchLayout: boolean): Promise<void> => {+ actions.showObservations(inWatchLayout)if (scannerId) {// Flagged as the summary's run, so only this one settles the button.actions.observe(scannerId, true)@@ -528,8 +540,12 @@ export const observationsDockLogic = kea<observationsDockLogicType>([reschedulePoll()},- showObservations: () => {- actions.setSidebarOpen(true)+ showObservations: ({ inWatchLayout }) => {+ // In the watch layout the observations live in the list column's Moments segment, which follows the+ // tab change on its own. Opening the sidebar there would switch the page into Debug mode instead.+ if (!inWatchLayout) {+ actions.setSidebarOpen(true)+ }actions.setTab(SessionRecordingSidebarTab.OBSERVATIONS)},@@ -593,12 +609,12 @@ export const observationsDockLogic = kea<observationsDockLogicType>([},// Runs whatever the button currently resolves to, without disturbing the stored preference.- summarize: () => runSummary(values.defaultSummarizer?.id ?? null),+ summarize: ({ inWatchLayout }) => runSummary(values.defaultSummarizer?.id ?? null, inWatchLayout),// An explicit pick from the dropdown, which also becomes the preference for next time.- summarizeWith: ({ scannerId }) => {+ summarizeWith: ({ scannerId, inWatchLayout }) => {actions.setPreferredSummarizerId(scannerId ?? BUILT_IN_SUMMARIZER)- return runSummary(scannerId)+ return runSummary(scannerId, inWatchLayout)},retryObservation: async ({ observationId }) => {diff --git a/products/replay_vision/frontend/replay_scanners/watchPicksLogic.test.ts b/products/replay_vision/frontend/replay_scanners/watchPicksLogic.test.tsindex e5b1e369c945..7e2310b4f3bb 100644--- a/products/replay_vision/frontend/replay_scanners/watchPicksLogic.test.ts+++ b/products/replay_vision/frontend/replay_scanners/watchPicksLogic.test.ts@@ -2,6 +2,7 @@ import { router } from 'kea-router'import { expectLogic } from 'kea-test-utils'import posthog from 'posthog-js'+import { replayListColumnLogic } from 'scenes/session-recordings/playlist/replayListColumnLogic'import { sessionRecordingsPlaylistLogic } from 'scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic'import { useMocks } from '~/mocks/jest'@@ -171,6 +172,17 @@ describe('watchPicksLogic', () => {expect(shownEvents()).toEqual([])})+ it('opens the Scans segment on every pick', async () => {+ const column = replayListColumnLogic({ logicKey: 'test-picks' })+ column.mount()+ for (const position of [0, 1]) {+ column.actions.setSegment('picks')+ logic.actions.watchPick(logic.values.picks![position], position)+ expect(column.values.segment).toBe('moments')+ }+ column.unmount()+ })+it('selects the pick, seeks ahead of its key moment, and marks it viewed for this person', async () => {expect(logic.values.unwatchedCount).toBe(3)await expectLogic(logic, () => {diff --git a/products/replay_vision/frontend/replay_scanners/watchPicksLogic.ts b/products/replay_vision/frontend/replay_scanners/watchPicksLogic.tsindex b19178925cf9..72cf69a35039 100644--- a/products/replay_vision/frontend/replay_scanners/watchPicksLogic.ts+++ b/products/replay_vision/frontend/replay_scanners/watchPicksLogic.ts@@ -19,6 +19,7 @@ import { z } from 'zod'import posthog from 'lib/posthog-typed'import { localStorageSlot } from 'lib/utils/localStorageSlot'+import { replayListColumnLogic } from 'scenes/session-recordings/playlist/replayListColumnLogic'import {SessionRecordingPlaylistLogicProps,sessionRecordingsPlaylistLogic,@@ -332,6 +333,10 @@ export const watchPicksLogic: LogicWrapper<watchPicksLogicType> = kea<watchPickssessionRecordingsPlaylistLogic(props.playlistLogicProps).actions.setSelectedRecordingId(observation.session_id)+ // The URL tab above is skipped when it matches the viewer's last tab.+ replayListColumnLogic+ .findMounted({ logicKey: props.playlistLogicProps.logicKey ?? 'playlist' })+ ?.actions.setSegment('moments', 'observations')if (!markViewed) {return}diff --git a/products/replay_vision/frontend/utils/recordingTimeline.test.ts b/products/replay_vision/frontend/utils/recordingTimeline.test.tsindex 8f6c0b422e3f..64da774dad70 100644--- a/products/replay_vision/frontend/utils/recordingTimeline.test.ts+++ b/products/replay_vision/frontend/utils/recordingTimeline.test.ts@@ -1,5 +1,5 @@import type { ReplayObservationApi } from '../generated/api.schemas'-import { recordingTimeline, timelineRows } from './recordingTimeline'+import { momentCount, recordingTimeline, surroundingMoments, timelineMoments, timelineRows } from './recordingTimeline'function summary(output: Record<string, unknown> | null,@@ -175,4 +175,33 @@ describe('recordingTimeline', () => {expect(rows).toEqual(['boundary start', 'chapter Browses', 'inactive 20000-90000', 'chapter Buys'])expect(timeline.chapters.find((c) => c.title === 'Buys')?.inactiveMs).toBe(5_000)})++ it.each([+ { name: 'nothing', observations: [], count: 0, at: 5_000, current: null, next: null },+ {+ name: 'chapters and a cited moment, interleaved by time',+ observations: [+ summary({ chapters: [chapter(0, 10_000, 'A'), chapter(10_000, 20_000, 'B')] }),+ monitor('m1', 5_000),+ ],+ count: 3,+ at: 6_000,+ current: 'm1: Yes',+ next: 'B',+ },+ {+ name: 'before the first moment',+ observations: [summary({ chapters: [chapter(1_000, 10_000, 'A')] })],+ count: 1,+ at: 0,+ current: null,+ next: 'A',+ },+ ])('counts and surrounds the moments of $name', ({ observations, count, at, current, next }) => {+ const timeline = recordingTimeline(observations)+ expect(momentCount(timeline)).toBe(count)+ const around = surroundingMoments(timelineMoments(timeline), at)+ expect(around.current?.label ?? null).toBe(current)+ expect(around.next?.label ?? null).toBe(next)+ })})diff --git a/products/replay_vision/frontend/utils/recordingTimeline.ts b/products/replay_vision/frontend/utils/recordingTimeline.tsindex 6aa1708068f9..b4bebcd9e2c1 100644--- a/products/replay_vision/frontend/utils/recordingTimeline.ts+++ b/products/replay_vision/frontend/utils/recordingTimeline.ts@@ -240,6 +240,43 @@ export function currentRowIndex(rows: TimelineRow[], playerTimeMs: number): numbreturn current}+/** A chapter start or a cited observation moment, the stops the ticker and the Moments badge count. */+export interface TimelineMoment {+ atMs: number+ label: string+}++export function timelineMoments(timeline: RecordingTimeline): TimelineMoment[] {+ return [+ ...timeline.chapters.map((c) => ({ atMs: c.startMs, label: c.title })),+ ...timeline.markers.map((m) => ({+ atMs: m.timestampMs,+ label: m.result ? `${m.scannerName}: ${m.result}` : m.scannerName,+ })),+ ].sort((a, b) => a.atMs - b.atMs)+}++export function momentCount(timeline: RecordingTimeline): number {+ return timeline.chapters.length + timeline.markers.length+}++/** The moment the player is in and the one after it, for the now/next ticker. */+export function surroundingMoments(+ moments: TimelineMoment[],+ playerTimeMs: number+): { current: TimelineMoment | null; next: TimelineMoment | null } {+ let current: TimelineMoment | null = null+ let next: TimelineMoment | null = null+ for (const moment of moments) {+ if (moment.atMs <= playerTimeMs) {+ current = moment+ } else if (!next) {+ next = moment+ }+ }+ return { current, next }+}+/** The next chapter start after the player's position. */export function nextTimelineStopMs(timeline: RecordingTimeline, playerTimeMs: number): number | null {const later = timeline.chapters.map((c) => c.startMs).filter((ms) => ms > playerTimeMs)