@@ -119,26 +119,24 @@ describeWithEnvironment('PerformanceAgent', () => {
119119describeWithEnvironment ( 'PerformanceAgent – call tree focus' , ( ) => {
120120 describe ( 'getOrigin()' , ( ) => {
121121 it ( 'calculates the origin of the selected node when it has a URL associated with it' , async function ( ) {
122- const { parsedTrace } = await TraceLoader . traceEngine ( this , 'web-dev-with-commit.json.gz' ) ;
122+ const { data } = await TraceLoader . traceEngine ( this , 'web-dev-with-commit.json.gz' ) ;
123123 // An Evaluate Script event, picked because it has a URL of googletagmanager.com/...
124- const evalScriptEvent =
125- allThreadEntriesInTrace ( parsedTrace )
126- . find ( event => event . name === Trace . Types . Events . Name . EVALUATE_SCRIPT && event . ts === 122411195649 ) ;
124+ const evalScriptEvent = allThreadEntriesInTrace ( data ) . find (
125+ event => event . name === Trace . Types . Events . Name . EVALUATE_SCRIPT && event . ts === 122411195649 ) ;
127126 assert . exists ( evalScriptEvent ) ;
128- const aiCallTree = TimelineUtils . AICallTree . AICallTree . fromEvent ( evalScriptEvent , parsedTrace ) ;
127+ const aiCallTree = TimelineUtils . AICallTree . AICallTree . fromEvent ( evalScriptEvent , data ) ;
129128 assert . isOk ( aiCallTree ) ;
130129 const context = PerformanceTraceContext . fromCallTree ( aiCallTree ) ;
131130 assert . strictEqual ( context . getOrigin ( ) , 'https://www.googletagmanager.com' ) ;
132131 } ) ;
133132
134133 it ( 'returns a random but deterministic "origin" for nodes that have no URL associated' , async function ( ) {
135- const { parsedTrace } = await TraceLoader . traceEngine ( this , 'web-dev-with-commit.json.gz' ) ;
134+ const { data } = await TraceLoader . traceEngine ( this , 'web-dev-with-commit.json.gz' ) ;
136135 // A random layout event with no URL associated
137- const layoutEvent =
138- allThreadEntriesInTrace ( parsedTrace )
139- . find ( event => event . name === Trace . Types . Events . Name . LAYOUT && event . ts === 122411130078 ) ;
136+ const layoutEvent = allThreadEntriesInTrace ( data ) . find (
137+ event => event . name === Trace . Types . Events . Name . LAYOUT && event . ts === 122411130078 ) ;
140138 assert . exists ( layoutEvent ) ;
141- const aiCallTree = TimelineUtils . AICallTree . AICallTree . fromEvent ( layoutEvent , parsedTrace ) ;
139+ const aiCallTree = TimelineUtils . AICallTree . AICallTree . fromEvent ( layoutEvent , data ) ;
142140 assert . isOk ( aiCallTree ) ;
143141 const context = PerformanceTraceContext . fromCallTree ( aiCallTree ) ;
144142 assert . strictEqual ( context . getOrigin ( ) , 'Layout_90829_259_122411130078' ) ;
@@ -147,11 +145,11 @@ describeWithEnvironment('PerformanceAgent – call tree focus', () => {
147145
148146 describe ( 'run' , function ( ) {
149147 it ( 'generates an answer' , async function ( ) {
150- const { parsedTrace } = await TraceLoader . traceEngine ( this , 'web-dev-outermost-frames.json.gz' ) ;
148+ const { data } = await TraceLoader . traceEngine ( this , 'web-dev-outermost-frames.json.gz' ) ;
151149 // A basic Layout.
152- const layoutEvt = allThreadEntriesInTrace ( parsedTrace ) . find ( event => event . ts === 465457096322 ) ;
150+ const layoutEvt = allThreadEntriesInTrace ( data ) . find ( event => event . ts === 465457096322 ) ;
153151 assert . exists ( layoutEvt ) ;
154- const aiCallTree = TimelineUtils . AICallTree . AICallTree . fromEvent ( layoutEvt , parsedTrace ) ;
152+ const aiCallTree = TimelineUtils . AICallTree . AICallTree . fromEvent ( layoutEvt , data ) ;
155153 assert . exists ( aiCallTree ) ;
156154
157155 const agent = new PerformanceAgent (
@@ -268,7 +266,7 @@ const FAKE_INP_MODEL = {
268266} as const ;
269267const FAKE_PARSED_TRACE = {
270268 Meta : { traceBounds : { min : 0 , max : 10 } , mainFrameURL : 'https://www.example.com' } ,
271- } as unknown as Trace . Handlers . Types . ParsedTrace ;
269+ } as unknown as Trace . Handlers . Types . HandlerData ;
272270const FAKE_INSIGHTS = new Map ( [ [ '' , { model : { LCPBreakdown : FAKE_LCP_MODEL , INPBreakdown : FAKE_INP_MODEL } } ] ] ) as
273271 unknown as Trace . Insights . Types . TraceInsightSets ;
274272const FAKE_METADATA = { } as unknown as Trace . Types . File . MetaData ;
@@ -279,11 +277,11 @@ function createAgentForInsightConversation(opts: {aidaClient?: Host.AidaClient.A
279277
280278describeWithEnvironment ( 'PerformanceAgent – insight focus' , ( ) => {
281279 it ( 'uses the min and max bounds of the trace as the origin' , async function ( ) {
282- const { parsedTrace , insights, metadata} = await TraceLoader . traceEngine ( this , 'lcp-images.json.gz' ) ;
280+ const { data , insights, metadata} = await TraceLoader . traceEngine ( this , 'lcp-images.json.gz' ) ;
283281 assert . isOk ( insights ) ;
284- const [ firstNav ] = parsedTrace . Meta . mainFrameNavigations ;
282+ const [ firstNav ] = data . Meta . mainFrameNavigations ;
285283 const lcpBreakdown = getInsightOrError ( 'LCPBreakdown' , insights , firstNav ) ;
286- const context = PerformanceTraceContext . fromInsight ( parsedTrace , insights , metadata , lcpBreakdown ) ;
284+ const context = PerformanceTraceContext . fromInsight ( data , insights , metadata , lcpBreakdown ) ;
287285 assert . strictEqual ( context . getOrigin ( ) , 'trace-658799706428-658804825864' ) ;
288286 } ) ;
289287
340338
341339 describe ( 'handleContextDetails' , ( ) => {
342340 it ( 'outputs the right context for the initial query from the user' , async function ( ) {
343- const { parsedTrace , insights, metadata} = await TraceLoader . traceEngine ( this , 'lcp-images.json.gz' ) ;
341+ const { data , insights, metadata} = await TraceLoader . traceEngine ( this , 'lcp-images.json.gz' ) ;
344342 assert . isOk ( insights ) ;
345- const context = PerformanceTraceContext . fromInsight ( parsedTrace , insights , metadata , FAKE_LCP_MODEL ) ;
343+ const context = PerformanceTraceContext . fromInsight ( data , insights , metadata , FAKE_LCP_MODEL ) ;
346344 const agent = createAgentForInsightConversation ( {
347345 aidaClient : mockAidaClient ( [ [ {
348346 explanation : 'This is the answer' ,
@@ -436,11 +434,11 @@ Help me understand?`;
436434 describe ( 'function calls' , ( ) => {
437435 it ( 'can call getNetworkTrackSummary' , async function ( ) {
438436 const metricsSpy = sinon . spy ( Host . userMetrics , 'performanceAINetworkSummaryResponseSize' ) ;
439- const { parsedTrace , insights, metadata} = await TraceLoader . traceEngine ( this , 'lcp-images.json.gz' ) ;
437+ const { data , insights, metadata} = await TraceLoader . traceEngine ( this , 'lcp-images.json.gz' ) ;
440438 assert . isOk ( insights ) ;
441- const [ firstNav ] = parsedTrace . Meta . mainFrameNavigations ;
439+ const [ firstNav ] = data . Meta . mainFrameNavigations ;
442440 const lcpBreakdown = getInsightOrError ( 'LCPBreakdown' , insights , firstNav ) ;
443- const bounds = parsedTrace . Meta . traceBounds ;
441+ const bounds = data . Meta . traceBounds ;
444442 const agent = createAgentForInsightConversation ( {
445443 aidaClient : mockAidaClient ( [
446444 [ {
@@ -450,7 +448,7 @@ Help me understand?`;
450448 [ { explanation : 'done' } ]
451449 ] )
452450 } ) ;
453- const context = PerformanceTraceContext . fromInsight ( parsedTrace , insights , metadata , lcpBreakdown ) ;
451+ const context = PerformanceTraceContext . fromInsight ( data , insights , metadata , lcpBreakdown ) ;
454452
455453 const responses = await Array . fromAsync ( agent . run ( 'test' , { selected : context } ) ) ;
456454 const action = responses . find ( response => response . type === ResponseType . ACTION ) ;
@@ -464,7 +462,7 @@ Help me understand?`;
464462 ] ;
465463
466464 expectedRequestUrls . forEach ( url => {
467- const match = parsedTrace . NetworkRequests . byTime . find ( r => r . args . data . url === url ) ;
465+ const match = data . NetworkRequests . byTime . find ( r => r . args . data . url === url ) ;
468466 assert . isOk ( match , `no request found for ${ url } ` ) ;
469467 } ) ;
470468
@@ -491,11 +489,11 @@ Help me understand?`;
491489 it ( 'can call getMainThreadTrackSummary' , async function ( ) {
492490 const metricsSpy = sinon . spy ( Host . userMetrics , 'performanceAIMainThreadActivityResponseSize' ) ;
493491
494- const { parsedTrace , insights, metadata} = await TraceLoader . traceEngine ( this , 'lcp-discovery-delay.json.gz' ) ;
492+ const { data , insights, metadata} = await TraceLoader . traceEngine ( this , 'lcp-discovery-delay.json.gz' ) ;
495493 assert . isOk ( insights ) ;
496- const [ firstNav ] = parsedTrace . Meta . mainFrameNavigations ;
494+ const [ firstNav ] = data . Meta . mainFrameNavigations ;
497495 const lcpBreakdown = getInsightOrError ( 'LCPBreakdown' , insights , firstNav ) ;
498- const bounds = parsedTrace . Meta . traceBounds ;
496+ const bounds = data . Meta . traceBounds ;
499497 const agent = createAgentForInsightConversation ( {
500498 aidaClient : mockAidaClient ( [
501499 [ {
@@ -505,7 +503,7 @@ Help me understand?`;
505503 [ { explanation : 'done' } ]
506504 ] )
507505 } ) ;
508- const context = PerformanceTraceContext . fromInsight ( parsedTrace , insights , metadata , lcpBreakdown ) ;
506+ const context = PerformanceTraceContext . fromInsight ( data , insights , metadata , lcpBreakdown ) ;
509507
510508 const responses = await Array . fromAsync ( agent . run ( 'test' , { selected : context } ) ) ;
511509 const titleResponse = responses . find ( response => response . type === ResponseType . TITLE ) ;
@@ -533,19 +531,18 @@ Help me understand?`;
533531 } ) ;
534532
535533 it ( 'will not send facts from a previous insight if the context changes' , async function ( ) {
536- const { parsedTrace , insights, metadata} = await TraceLoader . traceEngine ( this , 'lcp-discovery-delay.json.gz' ) ;
534+ const { data , insights, metadata} = await TraceLoader . traceEngine ( this , 'lcp-discovery-delay.json.gz' ) ;
537535 assert . isOk ( insights ) ;
538- const [ firstNav ] = parsedTrace . Meta . mainFrameNavigations ;
536+ const [ firstNav ] = data . Meta . mainFrameNavigations ;
539537 const lcpBreakdown = getInsightOrError ( 'LCPBreakdown' , insights , firstNav ) ;
540538 const renderBlocking = getInsightOrError ( 'RenderBlocking' , insights , firstNav ) ;
541539 const agent = createAgentForInsightConversation ( {
542540 aidaClient : mockAidaClient ( [
543541 [ { explanation : '' , functionCalls : [ { name : 'getMainThreadTrackSummary' , args : { } } ] } ] ,
544542 ] )
545543 } ) ;
546- const lcpContext = PerformanceTraceContext . fromInsight ( parsedTrace , insights , metadata , lcpBreakdown ) ;
547- const renderBlockingContext =
548- PerformanceTraceContext . fromInsight ( parsedTrace , insights , metadata , renderBlocking ) ;
544+ const lcpContext = PerformanceTraceContext . fromInsight ( data , insights , metadata , lcpBreakdown ) ;
545+ const renderBlockingContext = PerformanceTraceContext . fromInsight ( data , insights , metadata , renderBlocking ) ;
549546
550547 // Populate the function calls for the LCP Context
551548 await Array . fromAsync ( agent . run ( 'test 1 LCP' , { selected : lcpContext } ) ) ;
@@ -558,17 +555,17 @@ Help me understand?`;
558555 } ) ;
559556
560557 it ( 'will cache function calls as facts' , async function ( ) {
561- const { parsedTrace , insights, metadata} = await TraceLoader . traceEngine ( this , 'lcp-discovery-delay.json.gz' ) ;
558+ const { data , insights, metadata} = await TraceLoader . traceEngine ( this , 'lcp-discovery-delay.json.gz' ) ;
562559 assert . isOk ( insights ) ;
563- const [ firstNav ] = parsedTrace . Meta . mainFrameNavigations ;
560+ const [ firstNav ] = data . Meta . mainFrameNavigations ;
564561 const lcpBreakdown = getInsightOrError ( 'LCPBreakdown' , insights , firstNav ) ;
565562 const agent = createAgentForInsightConversation ( {
566563 aidaClient : mockAidaClient ( [
567564 [ { explanation : '' , functionCalls : [ { name : 'getMainThreadTrackSummary' , args : { } } ] } ] ,
568565 [ { explanation : '' , functionCalls : [ { name : 'getNetworkTrackSummary' , args : { } } ] } ] , [ { explanation : 'done' } ]
569566 ] )
570567 } ) ;
571- const context = PerformanceTraceContext . fromInsight ( parsedTrace , insights , metadata , lcpBreakdown ) ;
568+ const context = PerformanceTraceContext . fromInsight ( data , insights , metadata , lcpBreakdown ) ;
572569 await Array . fromAsync ( agent . run ( 'test 1' , { selected : context } ) ) ;
573570 await Array . fromAsync ( agent . run ( 'test 2' , { selected : context } ) ) ;
574571 // First 6 are the always included high-level facts. The rests are from the function calls.
@@ -589,9 +586,9 @@ Help me understand?`;
589586
590587describeWithEnvironment ( 'PerformanceAgent – all focus' , ( ) => {
591588 it ( 'uses the min and max bounds of the trace as the origin' , async function ( ) {
592- const { parsedTrace , insights, metadata} = await TraceLoader . traceEngine ( this , 'lcp-images.json.gz' ) ;
589+ const { data , insights, metadata} = await TraceLoader . traceEngine ( this , 'lcp-images.json.gz' ) ;
593590 assert . isOk ( insights ) ;
594- const context = PerformanceTraceContext . full ( parsedTrace , insights , metadata ) ;
591+ const context = PerformanceTraceContext . full ( data , insights , metadata ) ;
595592 assert . strictEqual ( context . getOrigin ( ) , 'trace-658799706428-658804825864' ) ;
596593 } ) ;
597594} ) ;
0 commit comments