Skip to content

Commit

Permalink
switch to timestamped points
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonLaster committed Sep 20, 2024
1 parent 4f94a70 commit 9609b0c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
7 changes: 2 additions & 5 deletions packages/replay-next/src/suspense/NetworkRequestsCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export type NetworkRequestsData = {
};
timeStampedPoint: TimeStampedPoint;
triggerPoint: TimeStampedPoint | null;
serverPoint: { point: ExecutionPoint, supplementalIndex: number } | null;
serverPoint: TimeStampedPoint | null;
};

export type NetworkRequestsCacheData = {
Expand Down Expand Up @@ -82,9 +82,6 @@ export const networkRequestsCache = createStreamingCache<

const targetPoint = replayClient.getTargetPoint(point, 0);




records[id] = {
id,
events: {
Expand All @@ -98,7 +95,7 @@ export const networkRequestsCache = createStreamingCache<
responseEvent: null,
responseRawHeaderEvent: null,
},
serverPoint: targetPoint,
serverPoint: targetPoint?.point ?? null,
requestBodyData: null,
responseBodyData: null,
timeStampedPoint: {
Expand Down
10 changes: 5 additions & 5 deletions packages/shared/client/ReplayClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,23 +612,23 @@ export class ReplayClient implements ReplayClientInterface {
}

getTargetPoint(point: ExecutionPoint, pointSupplementalIndex: number): {
point: ExecutionPoint | undefined, supplementalIndex: number
point: TimeStampedPoint, supplementalIndex: number
} | null {
const recordingId = this.getSupplementalIndexRecordingId(pointSupplementalIndex);

let targetPoint: ExecutionPoint | undefined;
let targetPoint: TimeStampedPoint | undefined;
let targetSupplementalIndex = 0;
this.forAllConnections((serverRecordingId, connection, supplementalIndex) => {
const { clientFirst, clientRecordingId, clientPoint, serverPoint } = connection;
if (clientFirst) {
if (clientRecordingId == recordingId && clientPoint.point == point) {
targetPoint = serverPoint.point;
targetPoint = serverPoint;
targetSupplementalIndex = supplementalIndex;
}
} else {
if (serverRecordingId == recordingId && serverPoint.point == point) {
assert(clientRecordingId == this._recordingId, "NYI");
targetPoint = clientPoint.point;
targetPoint = clientPoint;
targetSupplementalIndex = 0;
}
}
Expand All @@ -652,7 +652,7 @@ export class ReplayClient implements ReplayClientInterface {

const response = await sendMessage("Session.getPointFrameSteps" as any, { point: targetPoint.point }, sessionId);
const { steps } = response;
const desc = steps.find((step: PointDescription) => step.point == targetPoint.point);
const desc = steps.find((step: PointDescription) => step.point == targetPoint.point?.point);
assert(desc);

this.transformSupplementalPointDescription(desc, sessionId);
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export interface ReplayClientInterface {
events: RequestEventInfo[];
requests: RequestInfo[];
}>;
getTargetPoint(point: ExecutionPoint, pointSupplementalIndex: number): { point: ExecutionPoint | undefined, supplementalIndex: number } | null;
getTargetPoint(point: ExecutionPoint, pointSupplementalIndex: number): { point: TimeStampedPoint | undefined, supplementalIndex: number } | null;
findPaints(): Promise<TimeStampedPointWithPaintHash[]>;
findPoints(selector: PointSelector, limits?: PointLimits): Promise<PointDescription[]>;

Expand Down
15 changes: 8 additions & 7 deletions src/ui/components/NetworkMonitor/NetworkMonitorListRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Nag } from "shared/graphql/types";
import useNetworkContextMenu from "ui/components/NetworkMonitor/useNetworkContextMenu";
import { EnabledColumns } from "ui/components/NetworkMonitor/useNetworkMonitorColumns";
import { RequestSummary, findHeader } from "ui/components/NetworkMonitor/utils";
import { TimeStampedPoint } from "@replayio/protocol";

import {
BodyPartsToUInt8Array,
Expand All @@ -29,7 +30,7 @@ export type ItemData = {
filteredBeforeCount: number;
firstRequestIdAfterCurrentTime: string | null;
requests: RequestSummary[];
seekToRequest: (row: RequestSummary) => void;
seekToRequest: ({point, id}: {point: TimeStampedPoint, id: string}) => void;
selectRequest: (row: RequestSummary | null) => void;
selectedRequestId: string | null;
};
Expand Down Expand Up @@ -182,8 +183,8 @@ function RequestRow({
getGraphqlOperationNameIfRelevant();
}, [path, replayClient, request]);

const seekToRequestWrapper = (request: RequestSummary) => {
seekToRequest(request);
const seekToRequestWrapper = ({point, id}: {point: TimeStampedPoint, id: string}) => {
seekToRequest({point, id});
dismissJumpToNetworkRequestNag(); // Replay Passport
};

Expand Down Expand Up @@ -233,9 +234,9 @@ function RequestRow({
{columns.name && (
<div className={styles.Column} data-name="name">
{serverPoint && (
<span style={{ color: "red" }}>Server {serverPoint.supplementalIndex} {serverPoint.point}</span>
<span style={{ color: "red" }}>Server</span>
)}
{/* {name} {graphqlOperationName && `(${graphqlOperationName})`} */}
{name} {graphqlOperationName && `(${graphqlOperationName})`}
</div>
)}
{columns.method && (
Expand Down Expand Up @@ -268,7 +269,7 @@ function RequestRow({
<button
className={styles.ServerSeekButton}
data-test-name="Network-RequestRow-SeekButton"
onClick={() => seekToRequestWrapper(request)}
onClick={() => seekToRequestWrapper({point: serverPoint, id: id})}
tabIndex={0}
style={{
backgroundColor: "red !important",
Expand All @@ -288,7 +289,7 @@ function RequestRow({
<button
className={styles.SeekButton}
data-test-name="Network-RequestRow-SeekButton"
onClick={() => seekToRequestWrapper(request)}
onClick={() => seekToRequestWrapper({point: request.point, id: request.id})}
tabIndex={0}
>
<Icon
Expand Down
8 changes: 4 additions & 4 deletions src/ui/components/NetworkMonitor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,20 +142,20 @@ export default function NetworkMonitor() {
filteredAfterCount={countAfter}
filteredBeforeCount={countBefore}
requests={filteredRequests}
seekToRequest={request => {
seekToRequest={({point, id}) => {
trackEvent("net_monitor.seek_to_request");
dispatch(
seek({
executionPoint: request.point.point,
executionPoint: point.point,
openSource: true,
time: request.point.time,
time: point.time,
})
);

dismissInspectNetworkRequestNag();

trackEvent("net_monitor.select_request_row");
dispatch(selectNetworkRequest(request.id));
dispatch(selectNetworkRequest(id));
}}
selectedRequestId={selectedRequestId}
selectRequest={request => {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/NetworkMonitor/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export type RequestSummary = {
requestHeaders: Header[];
responseHeaders: Header[];
start: number;
serverPoint: { point: ExecutionPoint; supplementalIndex: number } | null;
serverPoint: TimeStampedPoint | null;
status: number | undefined;
type: CanonicalRequestType;
url: string;
Expand Down

0 comments on commit 9609b0c

Please sign in to comment.