Skip to content

Commit b65ff02

Browse files
Jonas Hallinisakstenstrom
authored andcommitted
Compare two browser actions
Add the ability to compare two different actions in the browser view. It shows difference in action properties, command, input files, and some basic overview of difference in output files.
1 parent 148900e commit b65ff02

43 files changed

Lines changed: 3288 additions & 681 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.aspect/rules/external_repository_action_cache/npm_translate_lock_LTUzNjQ2NjY3

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Input hashes for repository rule npm_translate_lock(name = "npm", pnpm_lock = "@@//frontend:pnpm-lock.yaml").
33
# This file should be checked into version control along with the pnpm-lock.yaml file.
44
frontend/.npmrc=2124455649
5-
frontend/package-lock.json=2050410766
6-
frontend/package.json=1484839624
5+
frontend/package-lock.json=-1601984742
6+
frontend/package.json=-2053760216
77
frontend/patches/vite.patch=-1261363333
8-
frontend/pnpm-lock.yaml=-1152862257
8+
frontend/pnpm-lock.yaml=-689001559

frontend/package-lock.json

Lines changed: 13 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"ansi_up": "^6.0.2",
3434
"antd": "^5.21.3",
3535
"dayjs": "^1.11.11",
36+
"diff": "^9.0.0",
3637
"graphql": "^16.8.1",
3738
"nice-grpc-common": "^2.0.2",
3839
"nice-grpc-web": "^3.3.5",

frontend/pnpm-lock.yaml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
import { Descriptions, Grid, theme } from "antd";
2+
import CopyBbClientdActionButton from "@/components/BrowserActionGrid/CopyBbClientdActionButton";
3+
import type { fetchBrowserActionGrid } from "@/components/BrowserActionGrid/fetch";
4+
import type { BrowserPageParams } from "@/types/BrowserPageParams";
5+
import { readableDurationFromProtobufDuration } from "@/utils/time";
6+
import { styleMap } from "../BrowserDirectory/utils";
7+
import PropertyTagList from "../PropertyTagList";
8+
import ComparePropertyTagList from "../PropertyTagList/comparePropertyTagList";
9+
10+
const { useToken } = theme;
11+
12+
interface Params {
13+
browserPageParams: BrowserPageParams;
14+
actionData: Awaited<ReturnType<typeof fetchBrowserActionGrid>>;
15+
compareActionData?: Awaited<ReturnType<typeof fetchBrowserActionGrid>>;
16+
mergedMode?: boolean;
17+
}
18+
const InnerActionProperties: React.FC<Params> = ({
19+
browserPageParams,
20+
actionData,
21+
compareActionData,
22+
mergedMode, // For comparing actions
23+
}) => {
24+
const screens = Grid.useBreakpoint();
25+
const { token } = useToken();
26+
return (
27+
<>
28+
<Descriptions
29+
layout={screens.md ? "horizontal" : "vertical"}
30+
column={1}
31+
size="small"
32+
bordered
33+
styles={{ label: { width: "25%" }, content: { width: "75%" } }}
34+
>
35+
{actionData.action.timeout && (
36+
<Descriptions.Item
37+
label="Timeout:"
38+
style={
39+
compareActionData &&
40+
actionData.action.timeout !== compareActionData?.action.timeout
41+
? styleMap("diff_with_borders", token)
42+
: {}
43+
}
44+
>
45+
{readableDurationFromProtobufDuration(actionData.action.timeout)}
46+
</Descriptions.Item>
47+
)}
48+
<Descriptions.Item
49+
label="Do not cache"
50+
style={
51+
compareActionData &&
52+
actionData.action.doNotCache !==
53+
compareActionData?.action.doNotCache
54+
? styleMap("diff_with_borders", token)
55+
: {}
56+
}
57+
>
58+
{actionData.action.doNotCache ? "Yes" : "No"}
59+
</Descriptions.Item>
60+
{actionData.action.platform &&
61+
(compareActionData?.action.platform ? (
62+
<Descriptions.Item label="Platform properties">
63+
<ComparePropertyTagList
64+
propertyList={actionData.action.platform.properties}
65+
comparePropertyList={
66+
compareActionData?.action.platform?.properties
67+
}
68+
mergedMode={mergedMode}
69+
/>
70+
</Descriptions.Item>
71+
) : (
72+
<Descriptions.Item label="Platform properties">
73+
<PropertyTagList
74+
propertyList={actionData.action.platform.properties}
75+
/>
76+
</Descriptions.Item>
77+
))}
78+
</Descriptions>
79+
{actionData.action.commandDigest &&
80+
actionData.action.inputRootDigest &&
81+
!mergedMode && (
82+
<CopyBbClientdActionButton
83+
instanceName={browserPageParams.instanceName}
84+
digestFunction={browserPageParams.digestFunction}
85+
actionDigest={actionData.actionDigest}
86+
commandDigest={actionData.action.commandDigest}
87+
inputRootDigest={actionData.action.inputRootDigest}
88+
/>
89+
)}
90+
</>
91+
);
92+
};
93+
94+
interface ActionPropertiesParams {
95+
browserPageParams: BrowserPageParams;
96+
actionData: Awaited<ReturnType<typeof fetchBrowserActionGrid>>;
97+
}
98+
const ActionProperties = ({
99+
browserPageParams,
100+
actionData,
101+
}: ActionPropertiesParams) => {
102+
return (
103+
<InnerActionProperties
104+
browserPageParams={browserPageParams}
105+
actionData={actionData}
106+
/>
107+
);
108+
};
109+
interface ActionPropertiesDeltaParams {
110+
browserPageParams: BrowserPageParams;
111+
actionData: Awaited<ReturnType<typeof fetchBrowserActionGrid>>;
112+
compareActionData: Awaited<ReturnType<typeof fetchBrowserActionGrid>>;
113+
mergedMode: boolean;
114+
}
115+
const ActionPropertiesDelta = ({
116+
browserPageParams,
117+
actionData,
118+
compareActionData,
119+
mergedMode,
120+
}: ActionPropertiesDeltaParams) => {
121+
return (
122+
<InnerActionProperties
123+
browserPageParams={browserPageParams}
124+
actionData={actionData}
125+
compareActionData={compareActionData}
126+
mergedMode={mergedMode}
127+
/>
128+
);
129+
};
130+
131+
export { ActionProperties, ActionPropertiesDelta };

frontend/src/components/BrowserActionGrid/CopyBbClientdActionButton.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,39 @@
11
import { Button } from "antd";
22
import type React from "react";
33
import { useBbPortalMessage } from "@/context/MessageContext";
4-
import type { Digest } from "@/lib/grpc-client/build/bazel/remote/execution/v2/remote_execution";
5-
import type { BrowserPageParams } from "@/types/BrowserPageType";
4+
import type {
5+
Digest,
6+
DigestFunction_Value,
7+
} from "@/lib/grpc-client/build/bazel/remote/execution/v2/remote_execution";
68
import { getBBClientdPath } from "@/utils/getBbClientdPath";
79

810
interface Params {
9-
browserPageParams: BrowserPageParams;
11+
instanceName: string;
12+
digestFunction: DigestFunction_Value;
1013
actionDigest: Digest;
1114
commandDigest: Digest;
1215
inputRootDigest: Digest;
1316
}
1417

1518
const CopyBbClientdActionButton: React.FC<Params> = ({
16-
browserPageParams,
19+
instanceName,
20+
digestFunction,
1721
actionDigest,
1822
commandDigest,
1923
inputRootDigest,
2024
}) => {
2125
const { copyToClipboard } = useBbPortalMessage();
2226

2327
const commandBbClientdPath = getBBClientdPath(
24-
browserPageParams.instanceName,
25-
browserPageParams.digestFunction,
28+
instanceName,
29+
digestFunction,
2630
commandDigest,
2731
"command",
2832
);
2933

3034
const inputRootBbClientdPath = getBBClientdPath(
31-
browserPageParams.instanceName,
32-
browserPageParams.digestFunction,
35+
instanceName,
36+
digestFunction,
3337
inputRootDigest,
3438
"directory",
3539
);

frontend/src/components/BrowserActionGrid/fetch.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ import {
2424
POSIXResourceUsage,
2525
} from "@/lib/grpc-client/buildbarn/resourceusage/resourceusage";
2626
import type { ByteStreamClient } from "@/lib/grpc-client/google/bytestream/bytestream";
27-
import {
28-
type BrowserPageParams,
29-
BrowserPageType,
30-
} from "@/types/BrowserPageType";
27+
import type { BrowserPageParams } from "@/types/BrowserPageParams";
28+
import { BrowserPageType } from "@/types/BrowserPageType";
3129
import { ProtobufTypeUrls } from "@/types/protobufTypeUrls";
3230
import { getReducedActionDigest_SHA256 } from "@/utils/digestFunctionUtils";
3331
import { fetchCasObjectAndParse } from "@/utils/fetchCasObject";
@@ -53,6 +51,7 @@ export const fetchBrowserActionGrid = async (
5351
casDirectory: Directory | undefined;
5452
previousExecutionStats: PreviousExecutionStats | undefined;
5553
fileSystemAccessProfile: FileSystemAccessProfile | undefined;
54+
reducedActionDigest: Digest | undefined;
5655
}> => {
5756
const { actionDigest, executeResponse } = await fetchExecuteResponse(
5857
browserPageParams,
@@ -82,6 +81,7 @@ export const fetchBrowserActionGrid = async (
8281
casDirectory,
8382
previousExecutionStats,
8483
fileSystemAccessProfile,
84+
reducedActionDigest,
8585
] = await Promise.all([
8686
// Fetch Command
8787
action.commandDigest
@@ -118,6 +118,11 @@ export const fetchBrowserActionGrid = async (
118118
fileSystemAccessCacheClient,
119119
browserPageParams,
120120
),
121+
122+
// Generate Reduced Action Digest (No fetching, but is async)
123+
action.commandDigest && action.platform
124+
? getReducedActionDigest_SHA256(action.commandDigest, action.platform)
125+
: undefined,
121126
]);
122127

123128
return {
@@ -134,6 +139,7 @@ export const fetchBrowserActionGrid = async (
134139
casDirectory,
135140
previousExecutionStats,
136141
fileSystemAccessProfile,
142+
reducedActionDigest,
137143
};
138144
};
139145

0 commit comments

Comments
 (0)