From dccfefa0c593d1f05d862cd2c5126c071b3a6818 Mon Sep 17 00:00:00 2001 From: Steve Golton Date: Mon, 14 Oct 2024 13:12:26 +0100 Subject: [PATCH] ui: Add area selections to permalinks Note: This CL breaks compatibility with older versions of the UI when permalinks are created containing area selections. This is not as disruptive as it used to be since Primiano's explicit deserialization change - i.e. the trace can still be loaded but none of the permalink data will be restored. Change-Id: I880eb3a8c052fefc5d394e916dcad817ff9c1eb4 --- ui/src/core/load_trace.ts | 4 ++-- ui/src/core/state_serialization.ts | 13 +++++++++++++ ui/src/public/state_serialization_schema.ts | 6 ++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ui/src/core/load_trace.ts b/ui/src/core/load_trace.ts index 98685cd4f8..614d2dda0b 100644 --- a/ui/src/core/load_trace.ts +++ b/ui/src/core/load_trace.ts @@ -288,6 +288,8 @@ async function loadTraceIntoEngine( } } + await trace.plugins.onTraceReady(); + if (serializedAppState !== undefined) { // Wait that plugins have completed their actions and then proceed with // the final phase of app state restore. @@ -296,8 +298,6 @@ async function loadTraceIntoEngine( deserializeAppStatePhase2(serializedAppState, trace); } - await trace.plugins.onTraceReady(); - return trace; } diff --git a/ui/src/core/state_serialization.ts b/ui/src/core/state_serialization.ts index 56a0f5c580..38b8727637 100644 --- a/ui/src/core/state_serialization.ts +++ b/ui/src/core/state_serialization.ts @@ -83,6 +83,13 @@ export function serializeAppState(trace: TraceImpl): SerializedAppState { trackKey: stateSel.trackUri, eventId: stateSel.eventId.toString(), }); + } else if (stateSel.kind === 'area') { + selection.push({ + kind: 'AREA', + trackUris: stateSel.trackUris, + start: stateSel.start, + end: stateSel.end, + }); } const plugins = new Array(); @@ -202,6 +209,12 @@ export function deserializeAppStatePhase2( case 'TRACK_EVENT': selMgr.selectTrackEvent(sel.trackKey, parseInt(sel.eventId)); break; + case 'AREA': + selMgr.selectArea({ + start: sel.start, + end: sel.end, + trackUris: sel.trackUris, + }); } } } diff --git a/ui/src/public/state_serialization_schema.ts b/ui/src/public/state_serialization_schema.ts index c1a37af2a6..51fee6e5d9 100644 --- a/ui/src/public/state_serialization_schema.ts +++ b/ui/src/public/state_serialization_schema.ts @@ -35,6 +35,12 @@ const SELECTION_SCHEMA = z.discriminatedUnion('kind', [ trackKey: z.string(), eventId: z.string(), }), + z.object({ + kind: z.literal('AREA'), + start: zTime, + end: zTime, + trackUris: z.array(z.string()), + }), ]); export type SerializedSelection = z.infer;