@@ -13,6 +13,7 @@ import * as PerfUI from '../../ui/legacy/components/perf_ui/perf_ui.js';
1313import * as UI from '../../ui/legacy/legacy.js' ;
1414
1515import * as Timeline from './timeline.js' ;
16+ import * as Utils from './utils/utils.js' ;
1617
1718const { urlString} = Platform . DevToolsPath ;
1819
@@ -778,6 +779,27 @@ describeWithEnvironment('TimelineFlameChartView', function() {
778779 } ) ;
779780 } ) ;
780781
782+ describe ( 'updating the active AI call tree' , ( ) => {
783+ it ( 'updates the UI Context with the active AI Call tree for the selected event' , async function ( ) {
784+ const { parsedTrace, metadata} = await TraceLoader . traceEngine ( this , 'web-dev-with-commit.json.gz' ) ;
785+ const mockViewDelegate = new MockViewDelegate ( ) ;
786+ const flameChartView = new Timeline . TimelineFlameChartView . TimelineFlameChartView ( mockViewDelegate ) ;
787+ flameChartView . setModel ( parsedTrace , metadata ) ;
788+ // Find some task in the main thread that we can build an AI Call Tree from
789+ const task = parsedTrace . Renderer . allTraceEntries . find ( event => {
790+ return Trace . Types . Events . isRunTask ( event ) && event . dur > 5_000 &&
791+ Utils . AICallTree . AICallTree . from ( event , parsedTrace ) !== null ;
792+ } ) ;
793+
794+ assert . isOk ( task ) ;
795+ UI . Context . Context . instance ( ) . setFlavor ( Utils . AICallTree . AICallTree , null ) ;
796+ const selection = Timeline . TimelineSelection . selectionFromEvent ( task ) ;
797+ flameChartView . setSelectionAndReveal ( selection ) ;
798+ const flavor = UI . Context . Context . instance ( ) . flavor ( Utils . AICallTree . AICallTree ) ;
799+ assert . instanceOf ( flavor , Utils . AICallTree . AICallTree ) ;
800+ } ) ;
801+ } ) ;
802+
781803 describe ( 'Link between entries annotation in progress' , function ( ) {
782804 let flameChartView : Timeline . TimelineFlameChartView . TimelineFlameChartView ;
783805 let parsedTrace : Trace . Handlers . Types . ParsedTrace ;
0 commit comments