Skip to content

Commit de92843

Browse files
committed
refactor(cloud): polish (#3009)
1 parent 7f257de commit de92843

31 files changed

+419
-290
lines changed

frontend/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"dev:engine": "vite --config vite.engine.config.ts",
1010
"dev:cloud": "vite --config vite.cloud.config.ts",
1111
"ts-check": "tsc --noEmit",
12-
"build": "echo 'Please use build:engine or build:inspector' && exit 1",
12+
"build": "echo 'Please use build:engine or build:inspector or build:cloud' && exit 1",
1313
"build:inspector": "vite build --mode=production --config vite.inspector.config.ts",
1414
"build:engine": "vite build --mode=production --config vite.engine.config.ts",
1515
"build:cloud": "vite build --mode=production --config vite.cloud.config.ts",
@@ -21,7 +21,7 @@
2121
"@clerk/clerk-js": "^5.92.1",
2222
"@clerk/clerk-react": "^5.47.0",
2323
"@clerk/elements": "^0.23.63",
24-
"@clerk/shared": "3.25.0",
24+
"@clerk/shared": "*",
2525
"@clerk/themes": "^2.4.18",
2626
"@codemirror/autocomplete": "^6.18.7",
2727
"@codemirror/commands": "^6.8.1",

frontend/src/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function CloudApp() {
7979
colorModalBackdrop: "rgb(0 0 0 / 0.8)",
8080
},
8181
}}
82-
publishableKey={cloudEnv().VITE_CLERK_PUBLISHABLE_KEY}
82+
publishableKey={cloudEnv().VITE_APP_CLERK_PUBLISHABLE_KEY}
8383
>
8484
<RouterProvider router={router} />
8585
</ClerkProvider>

frontend/src/app/actor-builds-list.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
// @ts-expect-error
3-
faActorsBorderless,
4-
Icon,
5-
} from "@rivet-gg/icons";
1+
import { faActorsBorderless, Icon } from "@rivet-gg/icons";
62
import { useInfiniteQuery } from "@tanstack/react-query";
73
import { Link, useNavigate } from "@tanstack/react-router";
84
import { Fragment } from "react";
@@ -22,8 +18,8 @@ export function ActorBuildsList() {
2218
<div className="h-full">
2319
<div className="flex flex-col gap-[1px]">
2420
{data?.length === 0 ? (
25-
<p className="text-xs text-muted-foreground ms-1">
26-
No instances found.
21+
<p className="text-xs text-muted-foreground ms-1 px-1">
22+
Connect RivetKit to see instances.
2723
</p>
2824
) : null}
2925
{data?.map((build) => (
@@ -84,3 +80,19 @@ export function ActorBuildsList() {
8480
</div>
8581
);
8682
}
83+
84+
export function ActorBuildsListSkeleton() {
85+
return (
86+
<div className="h-full">
87+
<div className="flex flex-col gap-[1px]">
88+
{Array(RECORDS_PER_PAGE)
89+
.fill(null)
90+
.map((_, i) => (
91+
<Fragment key={i}>
92+
<Skeleton className="w-full h-6 my-1" />
93+
</Fragment>
94+
))}
95+
</div>
96+
</div>
97+
);
98+
}

frontend/src/app/context-switcher.tsx

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ import { VisibilitySensor } from "@/components/visibility-sensor";
2424
export function ContextSwitcher() {
2525
const [isOpen, setIsOpen] = useState(false);
2626

27+
const match = useContextSwitchMatch();
28+
29+
if (!match) {
30+
return null;
31+
}
32+
2733
return (
2834
<>
2935
<Popover open={isOpen} onOpenChange={setIsOpen}>
@@ -47,45 +53,69 @@ export function ContextSwitcher() {
4753
);
4854
}
4955

50-
function Breadcrumbs() {
56+
const useContextSwitchMatch = ():
57+
| {
58+
project: string;
59+
namespace: string;
60+
organization: string;
61+
}
62+
| { organization: string; project: string }
63+
| false => {
5164
const match = useMatchRoute();
5265

5366
const matchNamespace = match({
5467
to: "/orgs/$organization/projects/$project/ns/$namespace",
5568
fuzzy: true,
5669
});
70+
5771
if (matchNamespace) {
72+
return matchNamespace;
73+
}
74+
75+
const matchProject = match({
76+
to: "/orgs/$organization/projects/$project",
77+
fuzzy: true,
78+
});
79+
80+
if (matchProject) {
81+
return matchProject;
82+
}
83+
84+
return false;
85+
};
86+
87+
function Breadcrumbs() {
88+
const match = useContextSwitchMatch();
89+
90+
if (match && "project" in match && "namespace" in match) {
5891
return (
5992
<div className="flex flex-col items-center min-w-0 w-full">
6093
<div className="text-left text-xs text-muted-foreground min-w-0 flex w-full">
6194
<ProjectBreadcrumb
62-
project={matchNamespace.project}
95+
project={match.project}
6396
className="truncate min-w-0 max-w-full block h-4"
6497
/>
6598
</div>
6699
<div className="min-w-0 w-full">
67100
<NamespaceBreadcrumb
68101
className="text-left truncate block"
69-
namespace={matchNamespace.namespace}
70-
project={matchNamespace.project}
102+
namespace={match.namespace}
103+
project={match.project}
71104
/>
72105
</div>
73106
</div>
74107
);
75108
}
76109

77-
const matchProject = match({
78-
to: "/orgs/$organization/projects/$project",
79-
fuzzy: true,
80-
});
81-
82-
if (matchProject) {
110+
if (match && "project" in match) {
83111
return (
84112
<>
85-
<ProjectBreadcrumb project={matchProject.project} />
113+
<ProjectBreadcrumb project={match.project} />
86114
</>
87115
);
88116
}
117+
118+
return null;
89119
}
90120

91121
function ProjectBreadcrumb({
@@ -102,7 +132,7 @@ function ProjectBreadcrumb({
102132
return <Skeleton className={cn("h-5 w-32", className)} />;
103133
}
104134

105-
return <span className={className}>{data?.name}</span>;
135+
return <span className={className}>{data?.displayName}</span>;
106136
}
107137

108138
function NamespaceBreadcrumb({
@@ -124,7 +154,7 @@ function NamespaceBreadcrumb({
124154
return <Skeleton className="h-5 w-32" />;
125155
}
126156

127-
return <span className={className}>{data?.name}</span>;
157+
return <span className={className}>{data?.displayName}</span>;
128158
}
129159

130160
function Content({ onClose }: { onClose?: () => void }) {

frontend/src/app/data-providers/cloud-data-provider.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Clerk } from "@clerk/clerk-js";
22
import { type Rivet, RivetClient } from "@rivet-gg/cloud";
3+
import { type FetchFunction, fetcher } from "@rivetkit/engine-api-full/core";
34
import { infiniteQueryOptions, queryOptions } from "@tanstack/react-query";
45
import { cloudEnv } from "@/lib/env";
56
import { RECORDS_PER_PAGE } from "./default-data-provider";
@@ -17,6 +18,14 @@ function createClient({ clerk }: { clerk: Clerk }) {
1718
token: async () => {
1819
return (await clerk.session?.getToken()) || "";
1920
},
21+
fetcher: async (args) => {
22+
if (args.headers) {
23+
delete args.headers["X-Fern-Language"];
24+
delete args.headers["X-Fern-Runtime"];
25+
delete args.headers["X-Fern-Runtime-Version"];
26+
}
27+
return await fetcher(args);
28+
},
2029
});
2130
}
2231

frontend/src/app/data-providers/engine-data-provider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import {
88
} from "@/components/actors";
99
import { engineEnv } from "@/lib/env";
1010
import { convertStringToId } from "@/lib/utils";
11+
import { noThrow, shouldRetryAllExpect403 } from "@/queries/utils";
1112
import {
1213
ActorQueryOptionsSchema,
1314
createDefaultGlobalContext,
1415
type DefaultDataProvider,
1516
RECORDS_PER_PAGE,
1617
} from "./default-data-provider";
17-
import { noThrow, shouldRetryAllExpect403 } from "./utils";
1818

1919
export type CreateNamespace = {
2020
displayName: string;

0 commit comments

Comments
 (0)