Skip to content

Commit c961037

Browse files
committed
cleanup
1 parent 0768dff commit c961037

File tree

5 files changed

+32
-13
lines changed

5 files changed

+32
-13
lines changed

apps/webapp/app/components/logs/LogDetailView.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { XMarkIcon, ArrowTopRightOnSquareIcon, CheckIcon, ClockIcon } from "@heroicons/react/20/solid";
1+
import { XMarkIcon, ArrowTopRightOnSquareIcon, CheckIcon } from "@heroicons/react/20/solid";
22
import { Link } from "@remix-run/react";
33
import {
44
type MachinePresetName,
55
formatDurationMilliseconds,
66
} from "@trigger.dev/core/v3";
7-
import { useEffect, useState, type ReactNode } from "react";
7+
import { useEffect, useState } from "react";
88
import { useTypedFetcher } from "remix-typedjson";
99
import { cn } from "~/utils/cn";
1010
import { Button } from "~/components/primitives/Buttons";
@@ -22,7 +22,7 @@ import { useOrganization } from "~/hooks/useOrganizations";
2222
import { useProject } from "~/hooks/useProject";
2323
import type { LogEntry } from "~/presenters/v3/LogsListPresenter.server";
2424
import { getLevelColor } from "~/utils/logUtils";
25-
import { v3RunSpanPath, v3RunsPath, v3BatchPath, v3RunPath, v3DeploymentVersionPath } from "~/utils/pathBuilder";
25+
import { v3RunSpanPath, v3RunsPath, v3DeploymentVersionPath } from "~/utils/pathBuilder";
2626
import type { loader as logDetailLoader } from "~/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.logs.$logId";
2727
import { TaskRunStatusCombo, descriptionForTaskRunStatus } from "~/components/runs/v3/TaskRunStatus";
2828
import { MachineLabelCombo } from "~/components/MachineLabelCombo";
@@ -48,6 +48,12 @@ type LogDetailViewProps = {
4848

4949
type TabType = "details" | "run";
5050

51+
type LogAttributes = Record<string, unknown> & {
52+
error?: {
53+
message?: string;
54+
};
55+
};
56+
5157
// Event kind badge color styles
5258
function getKindColor(kind: string): string {
5359
if (kind === "SPAN") {
@@ -109,6 +115,7 @@ export function LogDetailView({ logId, initialLog, onClose, searchTerm }: LogDet
109115
fetcher.load(
110116
`/resources/orgs/${organization.slug}/projects/${project.slug}/env/${environment.slug}/logs/${encodeURIComponent(logId)}`
111117
);
118+
// eslint-disable-next-line react-hooks/exhaustive-deps
112119
}, [organization.slug, project.slug, environment.slug, logId]);
113120

114121
const isLoading = fetcher.state === "loading";
@@ -226,7 +233,7 @@ export function LogDetailView({ logId, initialLog, onClose, searchTerm }: LogDet
226233

227234
function DetailsTab({ log, runPath, searchTerm }: { log: LogEntry; runPath: string; searchTerm?: string }) {
228235
const logWithExtras = log as LogEntry & {
229-
attributes?: Record<string, unknown>;
236+
attributes?: LogAttributes;
230237
};
231238

232239

@@ -242,7 +249,7 @@ function DetailsTab({ log, runPath, searchTerm }: { log: LogEntry; runPath: stri
242249
// Determine message to show
243250
let message = log.message ?? "";
244251
if (log.level === "ERROR") {
245-
const maybeErrorMessage = (logWithExtras.attributes as any)?.error?.message;
252+
const maybeErrorMessage = logWithExtras.attributes?.error?.message;
246253
if (typeof maybeErrorMessage === "string" && maybeErrorMessage.length > 0) {
247254
message = maybeErrorMessage;
248255
}
@@ -298,6 +305,7 @@ function RunTab({ log, runPath }: { log: LogEntry; runPath: string }) {
298305
fetcher.load(
299306
`/resources/orgs/${organization.slug}/projects/${project.slug}/env/${environment.slug}/logs/${encodeURIComponent(log.id)}/run?runId=${encodeURIComponent(log.runId)}`
300307
);
308+
// eslint-disable-next-line react-hooks/exhaustive-deps
301309
}, [organization.slug, project.slug, environment.slug, log.id, log.runId]);
302310

303311
const isLoading = !requested || fetcher.state === "loading";

apps/webapp/app/components/logs/LogsSearchInput.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export function LogsSearchInput() {
2525
if (urlSearch !== text && !isFocused) {
2626
setText(urlSearch);
2727
}
28+
// eslint-disable-next-line react-hooks/exhaustive-deps
2829
}, [location.search]);
2930

3031
const handleSubmit = useCallback(() => {

apps/webapp/app/components/logs/LogsTable.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ArrowPathIcon, ArrowTopRightOnSquareIcon } from "@heroicons/react/20/solid";
2-
import { formatDurationNanoseconds } from "@trigger.dev/core/v3";
3-
import { type ReactNode, useEffect, useRef, useState } from "react";
2+
import { useEffect, useRef, useState } from "react";
43
import { cn } from "~/utils/cn";
54
import { Button } from "~/components/primitives/Buttons";
65
import { useEnvironment } from "~/hooks/useEnvironment";

apps/webapp/app/presenters/v3/LogsListPresenter.server.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,19 @@ function convertDateToNanoseconds(date: Date): bigint {
110110
return BigInt(date.getTime()) * 1_000_000n;
111111
}
112112

113+
function formatNanosecondsForClickhouse(ns: bigint): string {
114+
const nsString = ns.toString();
115+
// Handle negative numbers (dates before 1970-01-01)
116+
if (nsString.startsWith("-")) {
117+
const absString = nsString.slice(1);
118+
const padded = absString.padStart(19, "0");
119+
return "-" + padded.slice(0, 10) + "." + padded.slice(10);
120+
}
121+
// Pad positive numbers to 19 digits to ensure correct slicing
122+
const padded = nsString.padStart(19, "0");
123+
return padded.slice(0, 10) + "." + padded.slice(10);
124+
}
125+
113126
export class LogsListPresenter {
114127
constructor(
115128
private readonly replica: PrismaClientOrTransaction,
@@ -324,23 +337,23 @@ export class LogsListPresenter {
324337

325338
// Time filters - inserted_at in PREWHERE for partition pruning, start_time in WHERE
326339
if (effectiveFrom) {
327-
const fromNs = convertDateToNanoseconds(effectiveFrom).toString();
340+
const fromNs = convertDateToNanoseconds(effectiveFrom);
328341
queryBuilder.prewhere("inserted_at >= {insertedAtStart: DateTime64(3)}", {
329342
insertedAtStart: convertDateToClickhouseDateTime(effectiveFrom),
330343
});
331344
queryBuilder.where("start_time >= {fromTime: String}", {
332-
fromTime: fromNs.slice(0, 10) + "." + fromNs.slice(10),
345+
fromTime: formatNanosecondsForClickhouse(fromNs),
333346
});
334347
}
335348

336349
if (effectiveTo) {
337350
const clampedTo = effectiveTo > new Date() ? new Date() : effectiveTo;
338-
const toNs = convertDateToNanoseconds(clampedTo).toString();
351+
const toNs = convertDateToNanoseconds(clampedTo);
339352
queryBuilder.prewhere("inserted_at <= {insertedAtEnd: DateTime64(3)}", {
340353
insertedAtEnd: convertDateToClickhouseDateTime(clampedTo),
341354
});
342355
queryBuilder.where("start_time <= {toTime: String}", {
343-
toTime: toNs.slice(0, 10) + "." + toNs.slice(10),
356+
toTime: formatNanosecondsForClickhouse(toNs),
344357
});
345358
}
346359

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.logs/route.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { Suspense, useCallback, useEffect, useMemo, useState, useTransition } fr
2626
import { Spinner } from "~/components/primitives/Spinner";
2727
import { Paragraph } from "~/components/primitives/Paragraph";
2828
import { Callout } from "~/components/primitives/Callout";
29-
import type { TaskRunListSearchFilters } from "~/components/runs/v3/RunFilters";
3029
import { RunsFilters } from "~/components/runs/v3/RunFilters";
3130
import { LogsTable } from "~/components/logs/LogsTable";
3231
import type { LogEntry } from "~/presenters/v3/LogsListPresenter.server";
@@ -39,7 +38,6 @@ import {
3938
ResizablePanelGroup,
4039
} from "~/components/primitives/Resizable";
4140
import { Switch } from "~/components/primitives/Switch";
42-
import { getUserById } from "~/models/user.server";
4341

4442
// Valid log levels for filtering
4543
const validLevels: LogLevel[] = ["TRACE", "DEBUG", "INFO", "WARN", "ERROR", "CANCELLED"];

0 commit comments

Comments
 (0)