@@ -2,7 +2,13 @@ import type { Page } from "@playwright/test"
22import { expectSessionTitle } from "../../utils/waits"
33import { benchmark , expect , withBenchmarkPage } from "../benchmark"
44import { fixture } from "./session-timeline-stress.fixture"
5- import { installStressSessionTabs , mockStressTimeline , stressSessionHref } from "./timeline-test-helpers"
5+ import {
6+ createReviewDiffs ,
7+ installStressSessionTabs ,
8+ installTimelineSettings ,
9+ mockStressTimeline ,
10+ stressSessionHref ,
11+ } from "./timeline-test-helpers"
612import { measureSessionSwitch , waitForStableTimeline } from "./session-tab-switch-probe"
713
814type Result = Awaited < ReturnType < typeof measureSessionSwitch > >
@@ -20,8 +26,41 @@ benchmark("benchmarks cold and hot session tab switching", async ({ browser, rep
2026 report ( { results, summary : summarize ( results ) } )
2127} )
2228
23- async function trial ( page : Page , mode : "cold" | "hot" ) {
24- await mockStressTimeline ( page )
29+ benchmark (
30+ "benchmarks v2 session tab switching with and without the review pane" ,
31+ async ( { browser, report } , testInfo ) => {
32+ benchmark . setTimeout ( 360_000 )
33+ const runs = Number ( process . env . SESSION_TAB_SWITCH_RUNS ?? 5 )
34+ const results = {
35+ closed : { cold : [ ] as Result [ ] , hot : [ ] as Result [ ] } ,
36+ open : { cold : [ ] as Result [ ] , hot : [ ] as Result [ ] } ,
37+ }
38+ for ( const reviewPane of [ "closed" , "open" ] as const ) {
39+ for ( const mode of [ "cold" , "hot" ] as const ) {
40+ for ( let run = 0 ; run < runs ; run ++ ) {
41+ results [ reviewPane ] [ mode ] . push (
42+ await withBenchmarkPage (
43+ browser ,
44+ `session-tab-switch-v2-${ reviewPane } -${ mode } -${ run } ` ,
45+ ( page ) => trial ( page , mode , { newLayoutDesigns : true , reviewPane } ) ,
46+ testInfo ,
47+ ) ,
48+ )
49+ }
50+ }
51+ }
52+ report ( { results, summary : summarizeReviewPane ( results ) } , { runs, reviewDiffs : createReviewDiffs ( ) . length } )
53+ } ,
54+ )
55+
56+ async function trial (
57+ page : Page ,
58+ mode : "cold" | "hot" ,
59+ options ?: { newLayoutDesigns ?: boolean ; reviewPane ?: "closed" | "open" } ,
60+ ) {
61+ const reviewDiffs = options ?. newLayoutDesigns ? createReviewDiffs ( ) : undefined
62+ await mockStressTimeline ( page , { vcsDiff : reviewDiffs } )
63+ if ( options ?. newLayoutDesigns ) await installTimelineSettings ( page )
2564 await installStressSessionTabs ( page )
2665 if ( mode === "hot" ) {
2766 await page . goto ( stressSessionHref ( fixture . targetID ) )
@@ -33,6 +72,10 @@ async function trial(page: Page, mode: "cold" | "hot") {
3372 await expectSessionTitle ( page , fixture . expected . sourceTitle )
3473 }
3574 await waitForStableTimeline ( page , fixture . expected . sourceMessageIDs . at ( - 1 ) ! )
75+ if ( options ?. reviewPane === "open" ) {
76+ await openReviewPane ( page )
77+ await waitForStableTimeline ( page , fixture . expected . sourceMessageIDs . at ( - 1 ) ! )
78+ }
3679
3780 const destinationIDs = fixture . messages [ fixture . targetID ] . map ( ( message ) => message . info . id )
3881 const sourceIDs = fixture . messages [ fixture . sourceID ] . map ( ( message ) => message . info . id )
@@ -70,10 +113,32 @@ function summarize(results: Record<"cold" | "hot", Result[]>) {
70113 )
71114}
72115
116+ function summarizeReviewPane ( results : Record < "closed" | "open" , Record < "cold" | "hot" , Result [ ] > > ) {
117+ return Object . fromEntries (
118+ Object . entries ( results ) . map ( ( [ reviewPane , values ] ) => [
119+ reviewPane ,
120+ summarize ( values as Record < "cold" | "hot" , Result [ ] > ) ,
121+ ] ) ,
122+ )
123+ }
124+
73125async function switchSession ( page : Page , sessionID : string , title : string ) {
74126 const href = stressSessionHref ( sessionID )
75127 const tab = page . locator ( `[data-slot="titlebar-tabs"] a[href="${ href } "]` ) . first ( )
76128 await expect ( tab ) . toBeVisible ( )
77129 await tab . click ( )
78130 await expectSessionTitle ( page , title )
79131}
132+
133+ async function openReviewPane ( page : Page ) {
134+ await page . getByRole ( "button" , { name : "Toggle review" } ) . click ( )
135+ const panel = page . locator ( "#review-panel" )
136+ await expect ( panel ) . toBeVisible ( )
137+ // Text-based readiness works across review implementations; the legacy list mounts
138+ // diff viewers lazily while V2 mounts the active preview eagerly.
139+ await page . waitForFunction ( ( ) => {
140+ const panel = document . querySelector < HTMLElement > ( "#review-panel" )
141+ const text = panel ?. textContent ?? ""
142+ return text . includes ( "generated-000.ts" ) && text . includes ( "+3" )
143+ } )
144+ }
0 commit comments