Skip to content

Commit cf082b4

Browse files
committed
chore(fe): fmt
1 parent c352b7a commit cf082b4

File tree

177 files changed

+854
-782
lines changed

Some content is hidden

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

177 files changed

+854
-782
lines changed

biome.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
"**/*.js",
66
"**/*.json",
77
"**/*.ts",
8+
"**/*.tsx",
89
"!engine/artifacts",
910
"!engine/sdks",
1011
"!engine/sdks/typescript/api-full",
1112
"!engine/sdks/typescript/runner-protocol",
12-
"!frontend",
13+
"!frontend/packages",
14+
"!examples",
1315
"!rivetkit-openapi/openapi.json",
1416
"!scripts",
1517
"!website"

frontend/packages/components/src/actors/actor-config-tab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Button, DocsSheet, ScrollArea } from "@rivet-gg/components";
2-
import { Icon, faBooks } from "@rivet-gg/icons";
2+
import { faBooks, Icon } from "@rivet-gg/icons";
33
import type { ActorAtom } from "./actor-context";
44
import { ActorGeneral } from "./actor-general";
55
import { ActorNetwork } from "./actor-network";

frontend/packages/components/src/actors/actor-details-settings-button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
DropdownMenuTrigger,
77
WithTooltip,
88
} from "@rivet-gg/components";
9-
import { Icon, faCog } from "@rivet-gg/icons";
9+
import { faCog, Icon } from "@rivet-gg/icons";
1010
import { useActorDetailsSettings } from "./actor-details-settings";
1111

1212
export function ActorDetailsSettingsButton() {

frontend/packages/components/src/actors/actor-details-settings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {
2+
createContext,
23
type Dispatch,
34
type ReactNode,
45
type SetStateAction,
5-
createContext,
66
useContext,
77
} from "react";
88
import { useLocalStorage } from "usehooks-ts";

frontend/packages/components/src/actors/actor-download-logs-button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Button, WithTooltip } from "@rivet-gg/components";
2-
import { Icon, faSave } from "@rivet-gg/icons";
2+
import { faSave, Icon } from "@rivet-gg/icons";
33
import { useAtomValue } from "jotai";
44
import type { ActorAtom } from "./actor-context";
55
import type { LogsTypeFilter } from "./actor-logs";

frontend/packages/components/src/actors/actor-editable-state.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
EditorView,
55
JsonCode,
66
} from "@rivet-gg/components/code-mirror";
7-
import { Icon, faRotateLeft, faSave } from "@rivet-gg/icons";
7+
import { faRotateLeft, faSave, Icon } from "@rivet-gg/icons";
88
import { AnimatePresence, motion } from "framer-motion";
99
import { useMemo, useRef, useState } from "react";
1010
import { ActorStateChangeIndicator } from "./actor-state-change-indicator";

frontend/packages/components/src/actors/actor-general.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Dd, DiscreteCopyButton, Dl, Dt, Flex, cn } from "@rivet-gg/components";
1+
import { cn, Dd, DiscreteCopyButton, Dl, Dt, Flex } from "@rivet-gg/components";
22
import { formatISO } from "date-fns";
33
import equal from "fast-deep-equal";
44
import { useAtomValue } from "jotai";

frontend/packages/components/src/actors/actor-logs.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,11 @@ export function filterLogs({
193193
typeFilter,
194194
filter,
195195
logs,
196-
}: { typeFilter: LogsTypeFilter; filter: string; logs: Logs }) {
196+
}: {
197+
typeFilter: LogsTypeFilter;
198+
filter: string;
199+
logs: Logs;
200+
}) {
197201
const output = logs?.filter((log) => {
198202
if (typeFilter === "errors") {
199203
return log.level === "error";

frontend/packages/components/src/actors/actor-metrics-tab.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Button, ScrollArea } from "@rivet-gg/components";
2-
import { Icon, faBooks } from "@rivet-gg/icons";
3-
import { ActorMetrics } from "./actor-metrics";
2+
import { faBooks, Icon } from "@rivet-gg/icons";
43
import type { ActorAtom } from "./actor-context";
4+
import { ActorMetrics } from "./actor-metrics";
55

66
interface ActorMetricsTabProps {
77
actor: ActorAtom;
@@ -22,4 +22,4 @@ export function ActorMetricsTab(props: ActorMetricsTabProps) {
2222
<ActorMetrics {...props} />
2323
</ScrollArea>
2424
);
25-
}
25+
}

frontend/packages/components/src/actors/actor-metrics.tsx

Lines changed: 64 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1+
import { useQuery } from "@tanstack/react-query";
2+
import equal from "fast-deep-equal";
13
import { useAtomValue, useSetAtom } from "jotai";
24
import { selectAtom } from "jotai/utils";
3-
import equal from "fast-deep-equal";
4-
import { useState, useMemo } from "react";
5+
import { useMemo, useState } from "react";
6+
import { actorMetricsQueryOptions } from "@/domains/project/queries/actors/query-options";
7+
import { Button } from "../ui/button";
8+
import { Flex } from "../ui/flex";
9+
import {
10+
Select,
11+
SelectContent,
12+
SelectItem,
13+
SelectTrigger,
14+
SelectValue,
15+
} from "../ui/select";
16+
import { Dd, Dl, Dt } from "../ui/typography";
517
import type { Actor, ActorAtom } from "./actor-context";
18+
import {
19+
actorEnvironmentAtom,
20+
actorMetricsTimeWindowAtom,
21+
} from "./actor-context";
622
import { ActorCpuStats } from "./actor-cpu-stats";
723
import { ActorMemoryStats } from "./actor-memory-stats";
8-
import { Dd, Dl, Dt } from "../ui/typography";
9-
import { Button } from "../ui/button";
10-
import { Flex } from "../ui/flex";
11-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/select";
12-
import { actorMetricsTimeWindowAtom, actorEnvironmentAtom } from "./actor-context";
13-
import { useQuery } from "@tanstack/react-query";
14-
import { actorMetricsQueryOptions } from "@/domains/project/queries/actors/query-options";
1524

1625
const selector = (a: Actor) => ({
1726
metrics: a.metrics,
@@ -42,16 +51,19 @@ export function ActorMetrics({ actor }: ActorMetricsProps) {
4251
);
4352
const defaultMetricsData = useAtomValue(metrics);
4453
const [showAdvanced, setShowAdvanced] = useState(false);
45-
54+
4655
const timeWindowMs = useAtomValue(actorMetricsTimeWindowAtom);
4756
const setTimeWindowMs = useSetAtom(actorMetricsTimeWindowAtom);
4857
const environment = useAtomValue(actorEnvironmentAtom);
49-
50-
const currentTimeWindow = timeWindowOptions.find(option => option.milliseconds === timeWindowMs) || timeWindowOptions[1];
58+
59+
const currentTimeWindow =
60+
timeWindowOptions.find(
61+
(option) => option.milliseconds === timeWindowMs,
62+
) || timeWindowOptions[1];
5163
const [timeWindow, setTimeWindow] = useState(currentTimeWindow.value);
5264

5365
const isActorRunning = status === "running";
54-
66+
5567
// Create a query for time window-specific metrics
5668
const { data: customMetricsData, status: customMetricsStatus } = useQuery({
5769
...actorMetricsQueryOptions(
@@ -61,23 +73,27 @@ export function ActorMetrics({ actor }: ActorMetricsProps) {
6173
actorId: id,
6274
timeWindowMs: timeWindowMs,
6375
},
64-
{ refetchInterval: 5000 }
76+
{ refetchInterval: 5000 },
6577
),
6678
enabled: !!environment && !!id,
6779
});
68-
80+
6981
// Use custom metrics if available, otherwise fall back to default
70-
const metricsData = customMetricsData ? {
71-
metrics: customMetricsData.metrics,
72-
rawData: customMetricsData.rawData,
73-
interval: customMetricsData.interval,
74-
status: customMetricsStatus,
75-
updatedAt: Date.now(),
76-
} : defaultMetricsData;
82+
const metricsData = customMetricsData
83+
? {
84+
metrics: customMetricsData.metrics,
85+
rawData: customMetricsData.rawData,
86+
interval: customMetricsData.interval,
87+
status: customMetricsStatus,
88+
updatedAt: Date.now(),
89+
}
90+
: defaultMetricsData;
7791

7892
const handleTimeWindowChange = (value: string) => {
7993
setTimeWindow(value);
80-
const selectedOption = timeWindowOptions.find(option => option.value === value);
94+
const selectedOption = timeWindowOptions.find(
95+
(option) => option.value === value,
96+
);
8197
if (selectedOption) {
8298
setTimeWindowMs(selectedOption.milliseconds);
8399
}
@@ -150,9 +166,7 @@ export function ActorMetrics({ actor }: ActorMetricsProps) {
150166
return `${Math.min(cpuRate, 100).toFixed(2)}%`;
151167
}, [metricsData, isActorRunning]);
152168

153-
const calculateMemoryPercentage = (
154-
usage: number | null | undefined,
155-
) => {
169+
const calculateMemoryPercentage = (usage: number | null | undefined) => {
156170
if (
157171
!isActorRunning ||
158172
usage === null ||
@@ -192,15 +206,16 @@ export function ActorMetrics({ actor }: ActorMetricsProps) {
192206
);
193207
}
194208

195-
const memoryPercentage = calculateMemoryPercentage(
196-
data.memory_usage_bytes,
197-
);
209+
const memoryPercentage = calculateMemoryPercentage(data.memory_usage_bytes);
198210

199211
return (
200212
<div className="px-4 my-8">
201213
<div className="flex items-center justify-between mb-4">
202214
<h3 className="font-semibold">Container Metrics</h3>
203-
<Select value={timeWindow} onValueChange={handleTimeWindowChange}>
215+
<Select
216+
value={timeWindow}
217+
onValueChange={handleTimeWindowChange}
218+
>
204219
<SelectTrigger className="w-32">
205220
<SelectValue />
206221
</SelectTrigger>
@@ -222,7 +237,8 @@ export function ActorMetrics({ actor }: ActorMetricsProps) {
222237
<Dd className="text-lg font-semibold flex flex-col gap-1">
223238
<span>{cpuPercentage}</span>
224239
{metricsData.rawData?.cpu_usage_seconds_total &&
225-
metricsData.rawData.cpu_usage_seconds_total.length > 0 ? (
240+
metricsData.rawData.cpu_usage_seconds_total.length >
241+
0 ? (
226242
<ActorCpuStats
227243
syncId="actor-stats"
228244
interval={metricsData.interval / 1000}
@@ -248,7 +264,8 @@ export function ActorMetrics({ actor }: ActorMetricsProps) {
248264
)}
249265
</span>
250266
{metricsData.rawData?.memory_usage_bytes &&
251-
metricsData.rawData.memory_usage_bytes.length > 0 ? (
267+
metricsData.rawData.memory_usage_bytes.length >
268+
0 ? (
252269
<ActorMemoryStats
253270
syncId="actor-stats"
254271
interval={metricsData.interval / 1000}
@@ -258,7 +275,9 @@ export function ActorMetrics({ actor }: ActorMetricsProps) {
258275
.memory_usage_bytes ?? []
259276
}
260277
allocatedMemory={
261-
resources?.memory ? resources.memory * 1024 * 1024 : 0
278+
resources?.memory
279+
? resources.memory * 1024 * 1024
280+
: 0
262281
}
263282
isRunning={isActorRunning}
264283
/>
@@ -369,9 +388,17 @@ export function ActorMetrics({ actor }: ActorMetricsProps) {
369388
<h4 className="font-medium mb-2">Resource Limits</h4>
370389
<Dl>
371390
<Dt>Memory Limit</Dt>
372-
<Dd>{resources?.memory ? `${resources.memory} MB` : "n/a"}</Dd>
391+
<Dd>
392+
{resources?.memory
393+
? `${resources.memory} MB`
394+
: "n/a"}
395+
</Dd>
373396
<Dt>CPU Limit</Dt>
374-
<Dd>{resources?.cpu ? `${resources.cpu / 1000} cores` : "n/a"}</Dd>
397+
<Dd>
398+
{resources?.cpu
399+
? `${resources.cpu / 1000} cores`
400+
: "n/a"}
401+
</Dd>
375402
</Dl>
376403
</div>
377404

@@ -537,9 +564,7 @@ export function ActorMetrics({ actor }: ActorMetricsProps) {
537564
</Dd>
538565
<Dt>Close Wait</Dt>
539566
<Dd>
540-
{formatNumber(
541-
data.network_tcp_usage_closewait,
542-
)}
567+
{formatNumber(data.network_tcp_usage_closewait)}
543568
</Dd>
544569
<Dt>Closing</Dt>
545570
<Dd>
@@ -701,4 +726,4 @@ export function ActorMetrics({ actor }: ActorMetricsProps) {
701726
)}
702727
</div>
703728
);
704-
}
729+
}

0 commit comments

Comments
 (0)