Skip to content

Commit

Permalink
ui: Add area selections to permalinks
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stevegolton committed Oct 21, 2024
1 parent bc99b0c commit dccfefa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ui/src/core/load_trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -296,8 +298,6 @@ async function loadTraceIntoEngine(
deserializeAppStatePhase2(serializedAppState, trace);
}

await trace.plugins.onTraceReady();

return trace;
}

Expand Down
13 changes: 13 additions & 0 deletions ui/src/core/state_serialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<SerializedPluginState>();
Expand Down Expand Up @@ -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,
});
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions ui/src/public/state_serialization_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof SELECTION_SCHEMA>;
Expand Down

0 comments on commit dccfefa

Please sign in to comment.