Skip to content

Commit 65f960e

Browse files
committed
Move the max live reload setting into an env var instead of hardcoding it
1 parent ccbeff4 commit 65f960e

File tree

2 files changed

+13
-5
lines changed
  • apps/webapp/app

2 files changed

+13
-5
lines changed

apps/webapp/app/env.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ const EnvironmentSchema = z.object({
205205
USAGE_OPEN_METER_API_KEY: z.string().optional(),
206206
USAGE_OPEN_METER_BASE_URL: z.string().optional(),
207207
EVENT_LOOP_MONITOR_ENABLED: z.string().default("1"),
208+
MAXIMUM_LIVE_RELOADING_EVENTS: z.coerce.number().int().default(1000),
208209
});
209210

210211
export type Environment = z.infer<typeof EnvironmentSchema>;

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.v3.$projectParam.runs.$runParam/route.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ import {
7070
} from "~/utils/pathBuilder";
7171
import { SpanView } from "../resources.orgs.$organizationSlug.projects.v3.$projectParam.runs.$runParam.spans.$spanParam/route";
7272
import { SimpleTooltip } from "~/components/primitives/Tooltip";
73-
74-
const MAX_LIVE_RELOADING_EVENTS = 500;
73+
import { env } from "~/env.server";
7574

7675
type TraceEvent = NonNullable<SerializeFrom<typeof loader>["trace"]>["events"][0];
7776

@@ -93,6 +92,7 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
9392
return {
9493
run: result.run,
9594
trace: result.trace,
95+
maximumLiveReloadingSetting: env.MAXIMUM_LIVE_RELOADING_EVENTS,
9696
resizeSettings,
9797
};
9898
};
@@ -103,7 +103,8 @@ function getSpanId(location: Location<any>): string | undefined {
103103
}
104104

105105
export default function Page() {
106-
const { run, trace, resizeSettings } = useLoaderData<typeof loader>();
106+
const { run, trace, resizeSettings, maximumLiveReloadingSetting } =
107+
useLoaderData<typeof loader>();
107108
const organization = useOrganization();
108109
const project = useProject();
109110
const user = useUser();
@@ -173,7 +174,7 @@ export default function Page() {
173174
}
174175

175176
const { events, parentRunFriendlyId, duration, rootSpanStatus, rootStartedAt } = trace;
176-
const shouldLiveReload = events.length <= MAX_LIVE_RELOADING_EVENTS;
177+
const shouldLiveReload = events.length <= maximumLiveReloadingSetting;
177178

178179
const changeToSpan = useDebounce((selectedSpan: string) => {
179180
replaceSearchParam("span", selectedSpan);
@@ -263,6 +264,7 @@ export default function Page() {
263264
rootStartedAt={rootStartedAt ? new Date(rootStartedAt) : undefined}
264265
environmentType={run.environment.type}
265266
shouldLiveReload={shouldLiveReload}
267+
maximumLiveReloadingSetting={maximumLiveReloadingSetting}
266268
/>
267269
</ResizablePanel>
268270
<ResizableHandle withHandle />
@@ -292,6 +294,7 @@ type TasksTreeViewProps = {
292294
rootStartedAt: Date | undefined;
293295
environmentType: RuntimeEnvironmentType;
294296
shouldLiveReload: boolean;
297+
maximumLiveReloadingSetting: number;
295298
};
296299

297300
function TasksTreeView({
@@ -304,6 +307,7 @@ function TasksTreeView({
304307
rootStartedAt,
305308
environmentType,
306309
shouldLiveReload,
310+
maximumLiveReloadingSetting,
307311
}: TasksTreeViewProps) {
308312
const [filterText, setFilterText] = useState("");
309313
const [errorsOnly, setErrorsOnly] = useState(false);
@@ -381,6 +385,7 @@ function TasksTreeView({
381385
<LiveReloadingStatus
382386
rootSpanCompleted={rootSpanStatus !== "executing"}
383387
isLiveReloading={shouldLiveReload}
388+
settingValue={maximumLiveReloadingSetting}
384389
/>
385390
</div>
386391
<TreeView
@@ -851,9 +856,11 @@ function ShowParentLink({ runFriendlyId }: { runFriendlyId: string }) {
851856
function LiveReloadingStatus({
852857
rootSpanCompleted,
853858
isLiveReloading,
859+
settingValue,
854860
}: {
855861
rootSpanCompleted: boolean;
856862
isLiveReloading: boolean;
863+
settingValue: number;
857864
}) {
858865
if (rootSpanCompleted) return null;
859866

@@ -868,7 +875,7 @@ function LiveReloadingStatus({
868875
</div>
869876
) : (
870877
<SimpleTooltip
871-
content={`Live reloading is disabled because you've exceeded ${MAX_LIVE_RELOADING_EVENTS} logs.`}
878+
content={`Live reloading is disabled because you've exceeded ${settingValue} logs.`}
872879
button={
873880
<div className="flex items-center gap-1">
874881
<BoltSlashIcon className="size-3.5 text-text-dimmed" />

0 commit comments

Comments
 (0)