Skip to content

Commit

Permalink
Merge "ui: Add area selections to permalinks" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
stevegolton authored and Gerrit Code Review committed Oct 21, 2024
2 parents 842f9c1 + dccfefa commit 2a3a762
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 @@ -257,6 +257,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 @@ -265,8 +267,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 2a3a762

Please sign in to comment.