Skip to content

Commit c2384e2

Browse files
committed
perf(webapp): sample only the selected source in the Add smart column dialog
The preview endpoint hydrated payload, metadata and output for 10 runs on every open (~3 blobs x 10, up to the 512KB inline limit each). It now fetches only the currently-selected source; the dialog passes its source and refetches when the user switches, cutting the worst-case transfer roughly threefold.
1 parent 4fda2b8 commit c2384e2

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

apps/webapp/app/components/runs/v3/AddSmartColumnDialog.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,11 @@ export function AddSmartColumnDialog({
9292
if (sampleFilters) {
9393
for (const [key, val] of Object.entries(sampleFilters)) params.set(key, val);
9494
}
95+
params.set("source", source);
9596
const qs = params.toString();
9697
return qs ? `${base}?${qs}` : base;
9798
// eslint-disable-next-line react-hooks/exhaustive-deps
98-
}, [organization.slug, project.slug, environment.slug, currentSearch, sampleFiltersKey]);
99+
}, [organization.slug, project.slug, environment.slug, currentSearch, sampleFiltersKey, source]);
99100

100101
useEffect(() => {
101102
if (open && sample.state === "idle") {

apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.smart-column-sample.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type LoaderFunctionArgs } from "@remix-run/server-runtime";
2-
import { deriveRunSelect } from "~/components/runs/v3/runColumns";
2+
import { deriveRunSelect, type SmartColumnSource } from "~/components/runs/v3/runColumns";
33
import { getRunFiltersFromRequest } from "~/presenters/RunFilters.server";
44
import { clickhouseFactory } from "~/services/clickhouse/clickhouseFactoryInstance.server";
55
import { loadProjectEnvironmentFromRequest } from "~/services/loadProjectEnvironmentFromRequest.server";
@@ -10,6 +10,14 @@ import { isFinalRunStatus } from "~/v3/taskStatus";
1010
/** How many recent runs the smart-column preview can page through. */
1111
const SAMPLE_RUN_COUNT = 10;
1212

13+
const SAMPLE_SOURCES: SmartColumnSource[] = ["payload", "metadata", "output"];
14+
15+
function parseSampleSource(value: string | null): SmartColumnSource {
16+
return SAMPLE_SOURCES.includes(value as SmartColumnSource)
17+
? (value as SmartColumnSource)
18+
: "payload";
19+
}
20+
1321
/**
1422
* The most recent runs for the current filters, with their raw
1523
* payload/metadata/output packets, feeding the "Add smart column" preview. The
@@ -19,6 +27,7 @@ const SAMPLE_RUN_COUNT = 10;
1927
export async function loader({ request, params }: LoaderFunctionArgs) {
2028
const { project, environment } = await loadProjectEnvironmentFromRequest(request, params);
2129
const filters = await getRunFiltersFromRequest(request);
30+
const source = parseSampleSource(new URL(request.url).searchParams.get("source"));
2231

2332
const clickhouse = await clickhouseFactory.getClickhouseForOrganization(
2433
project.organizationId,
@@ -45,7 +54,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
4554
queues: filters.queues,
4655
machines: filters.machines,
4756
errorId: filters.errorId,
48-
runSelect: deriveRunSelect([], ["payload", "metadata", "output"]),
57+
runSelect: deriveRunSelect([], [source]),
4958
page: { size: SAMPLE_RUN_COUNT },
5059
});
5160

0 commit comments

Comments
 (0)