Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jump to network response #10617

Open
wants to merge 7 commits into
base: supplemental-recordings
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/replay-next/src/suspense/NetworkRequestsCache.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {

Check failure on line 1 in packages/replay-next/src/suspense/NetworkRequestsCache.ts

View workflow job for this annotation

GitHub Actions / Trunk Check

prettier

Incorrect formatting, autoformat by running 'trunk fmt'
ExecutionPoint,
RequestBodyData,
RequestBodyEvent,
Expand Down Expand Up @@ -41,6 +41,7 @@
};
timeStampedPoint: TimeStampedPoint;
triggerPoint: TimeStampedPoint | null;
serverPoint: { point: ExecutionPoint, supplementalIndex: number } | null;
};

export type NetworkRequestsCacheData = {
Expand All @@ -57,7 +58,7 @@
getKey: () => "single-entry-cache",
load: async (
options: StreamingCacheLoadOptions<RequestId[], Record<RequestId, NetworkRequestsData>>,
replayClient
replayClient: ReplayClientInterface
) => {
const { update, resolve } = options;

Expand All @@ -69,7 +70,7 @@
// Use the createOnRequestsReceived() adapter to ensure that RequestInfo objects
// are always received before any associated RequestEventInfo objects
const onRequestsReceived = createOnRequestsReceived(function onRequestsReceived(data) {
data.requests.forEach(({ id, point, time, triggerPoint }) => {
data.requests.forEach(({ id, point, time, triggerPoint },) => {
assert(
previousExecutionPoint === null || comparePoints(previousExecutionPoint, point) <= 0,
"Requests should be in order"
Expand All @@ -79,6 +80,11 @@

ids.push(id);

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




records[id] = {
id,
events: {
Expand All @@ -92,6 +98,7 @@
responseEvent: null,
responseRawHeaderEvent: null,
},
serverPoint: targetPoint,
requestBodyData: null,
responseBodyData: null,
timeStampedPoint: {
Expand Down
22 changes: 17 additions & 5 deletions packages/shared/client/ReplayClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {

Check failure on line 1 in packages/shared/client/ReplayClient.ts

View workflow job for this annotation

GitHub Actions / Trunk Check

prettier

Incorrect formatting, autoformat by running 'trunk fmt'
Result as EvaluationResult,
ExecutionPoint,
FrameId,
Expand Down Expand Up @@ -611,7 +611,9 @@
});
}

private async maybeGetConnectionStepTarget(point: ExecutionPoint, pointSupplementalIndex: number): Promise<PauseDescription | null> {
getTargetPoint(point: ExecutionPoint, pointSupplementalIndex: number): {
point: ExecutionPoint | undefined, supplementalIndex: number
} | null {
const recordingId = this.getSupplementalIndexRecordingId(pointSupplementalIndex);

let targetPoint: ExecutionPoint | undefined;
Expand All @@ -636,11 +638,21 @@
return null;
}

const sessionId = await this.getSupplementalIndexSession(targetSupplementalIndex);
return { point: targetPoint, supplementalIndex: targetSupplementalIndex };
}

private async maybeGetConnectionStepTarget(point: ExecutionPoint, pointSupplementalIndex: number): Promise<PauseDescription | null> {

const targetPoint = this.getTargetPoint(point, pointSupplementalIndex);
if (!targetPoint) {
return null;
}

const sessionId = await this.getSupplementalIndexSession(targetPoint.supplementalIndex);

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

this.transformSupplementalPointDescription(desc, sessionId);
Expand Down Expand Up @@ -1542,7 +1554,7 @@
assert(previous.clientPoint.time <= next.clientPoint.time);
assert(previous.serverPoint.time <= next.serverPoint.time);
if (supplementalTime >= previous.serverPoint.time &&
supplementalTime <= next.serverPoint.time) {
supplementalTime <= next.serverPoint.time) {
const clientElapsed = next.clientPoint.time - previous.clientPoint.time;
const serverElapsed = next.serverPoint.time - previous.serverPoint.time;
const fraction = (supplementalTime - previous.serverPoint.time) / serverElapsed;
Expand Down
1 change: 1 addition & 0 deletions packages/shared/client/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {

Check failure on line 1 in packages/shared/client/types.ts

View workflow job for this annotation

GitHub Actions / Trunk Check

prettier

Incorrect formatting, autoformat by running 'trunk fmt'
Annotation,
ContentType,
Result as EvaluationResult,
Expand Down Expand Up @@ -207,6 +207,7 @@
events: RequestEventInfo[];
requests: RequestInfo[];
}>;
getTargetPoint(point: ExecutionPoint, pointSupplementalIndex: number): { point: ExecutionPoint | undefined, supplementalIndex: number } | null;
findPaints(): Promise<TimeStampedPointWithPaintHash[]>;
findPoints(selector: PointSelector, limits?: PointLimits): Promise<PointDescription[]>;

Expand Down
31 changes: 31 additions & 0 deletions src/ui/components/NetworkMonitor/NetworkMonitorListRow.module.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.HeaderRow,

Check failure on line 1 in src/ui/components/NetworkMonitor/NetworkMonitorListRow.module.css

View workflow job for this annotation

GitHub Actions / Trunk Check

prettier

Incorrect formatting, autoformat by running 'trunk fmt'
.FooterRow,
.Row {
display: flex;
Expand Down Expand Up @@ -89,6 +89,7 @@
color: #fff;
font-weight: bold;
}

.Row:hover .SeekButton {
display: flex;
}
Expand All @@ -97,6 +98,36 @@
outline: none;
}


.ServerSeekButton {
display: none;
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);

padding: 0.25rem;
padding-right: 1ch;
border-top-right-radius: 0.5rem;
border-bottom-right-radius: 0.5rem;

flex-direction: row;
align-items: center;
gap: 1ch;

background: red !important;
color: #fff;
font-weight: bold;
}

.Row:hover .ServerSeekButton {
display: flex;
}
.Server:focus,
.Server:hover {
outline: none;
}

.SeekButtonIcon {
flex: 0 0 auto;
color: currentColor;
Expand Down
34 changes: 32 additions & 2 deletions src/ui/components/NetworkMonitor/NetworkMonitorListRow.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CSSProperties, MouseEvent, useContext, useEffect, useState } from "react";

Check failure on line 1 in src/ui/components/NetworkMonitor/NetworkMonitorListRow.tsx

View workflow job for this annotation

GitHub Actions / Trunk Check

prettier

Incorrect formatting, autoformat by running 'trunk fmt'

import Icon from "replay-next/components/Icon";
import { SessionContext } from "replay-next/src/contexts/SessionContext";
Expand Down Expand Up @@ -116,9 +116,16 @@
start: startTime,
status,
triggerPoint,
serverPoint,
url,
} = request;


if (serverPoint) {
console.log("serverPoint!!", serverPoint);
}


let type = documentType || cause;
if (type === "unknown") {
type = "";
Expand Down Expand Up @@ -225,7 +232,10 @@
)}
{columns.name && (
<div className={styles.Column} data-name="name">
{name} {graphqlOperationName && `(${graphqlOperationName})`}
{serverPoint && (
<span style={{ color: "red" }}>Server {serverPoint.supplementalIndex} {serverPoint.point}</span>
)}
{/* {name} {graphqlOperationName && `(${graphqlOperationName})`} */}
</div>
)}
{columns.method && (
Expand Down Expand Up @@ -254,7 +264,27 @@
</div>
)}

{triggerPoint && triggerPoint.time !== currentTime && (
{serverPoint && (
<button
className={styles.ServerSeekButton}
data-test-name="Network-RequestRow-SeekButton"
onClick={() => seekToRequestWrapper(request)}
tabIndex={0}
style={{
backgroundColor: "red !important",
}}
>
<Icon
className={styles.SeekButtonIcon}
type={isAfterCurrentTime ? "fast-forward" : "rewind"}
/>
<span className={styles.SeekButtonText}>
{isAfterCurrentTime ? "Fast-forward" : "Rewind"}
</span>
</button>
)}

{!serverPoint && triggerPoint && triggerPoint.time !== currentTime && (
<button
className={styles.SeekButton}
data-test-name="Network-RequestRow-SeekButton"
Expand Down
3 changes: 3 additions & 0 deletions src/ui/components/NetworkMonitor/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
ExecutionPoint,
Header,
RequestBodyEvent,
RequestDoneEvent,
Expand Down Expand Up @@ -46,6 +47,7 @@ export type RequestSummary = {
requestHeaders: Header[];
responseHeaders: Header[];
start: number;
serverPoint: { point: ExecutionPoint; supplementalIndex: number } | null;
status: number | undefined;
type: CanonicalRequestType;
url: string;
Expand Down Expand Up @@ -168,6 +170,7 @@ export const partialRequestsToCompleteSummaries = (
start: record.timeStampedPoint.time,
status: responseEvent?.responseStatus,
triggerPoint: record.triggerPoint,
serverPoint: record.serverPoint,
type: REQUEST_TYPES[openEvent.requestCause || ""] ?? CanonicalRequestType.OTHER,
url: openEvent.requestUrl,
};
Expand Down
Loading