Skip to content

Commit cf41072

Browse files
committed
root friendlyId works
1 parent 6f4d713 commit cf41072

File tree

2 files changed

+64
-30
lines changed

2 files changed

+64
-30
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ export class RunPresenter {
6161
createdAt: true,
6262
},
6363
},
64+
parentTaskRun: {
65+
select: {
66+
friendlyId: true,
67+
taskIdentifier: true,
68+
spanId: true,
69+
createdAt: true,
70+
},
71+
},
6472
runtimeEnvironment: {
6573
select: {
6674
id: true,
@@ -109,6 +117,7 @@ export class RunPresenter {
109117
completedAt: run.completedAt,
110118
logsDeletedAt: showDeletedLogs ? null : run.logsDeletedAt,
111119
rootTaskRun: run.rootTaskRun,
120+
parentTaskRun: run.parentTaskRun,
112121
environment: {
113122
id: run.runtimeEnvironment.id,
114123
organizationId: run.runtimeEnvironment.organizationId,
@@ -199,8 +208,6 @@ export class RunPresenter {
199208
trace: {
200209
rootSpanStatus,
201210
events: events,
202-
parentRunFriendlyId:
203-
tree?.id === traceSummary.rootSpan.id ? undefined : traceSummary.rootSpan.runId,
204211
duration: totalDuration,
205212
rootStartedAt: tree?.data.startTime,
206213
startedAt: run.startedAt,

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

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
MagnifyingGlassPlusIcon,
1212
StopCircleIcon,
1313
} from "@heroicons/react/20/solid";
14-
import { useLoaderData, useParams, useRevalidator } from "@remix-run/react";
14+
import { useLoaderData, useRevalidator } from "@remix-run/react";
1515
import { type LoaderFunctionArgs, type SerializeFrom, json } from "@remix-run/server-runtime";
1616
import { type Virtualizer } from "@tanstack/react-virtual";
1717
import {
@@ -25,7 +25,8 @@ import { motion } from "framer-motion";
2525
import { useCallback, useEffect, useRef, useState } from "react";
2626
import { useHotkeys } from "react-hotkeys-hook";
2727
import { redirect } from "remix-typedjson";
28-
import { ShowParentIcon, ShowParentIconSelected } from "~/assets/icons/ShowParentIcon";
28+
import { MoveToTopIcon } from "~/assets/icons/MoveToTopIcon";
29+
import { MoveUpIcon } from "~/assets/icons/MoveUpIcon";
2930
import tileBgPath from "~/assets/images/error-banner-tile@2x.png";
3031
import { DevDisconnectedBanner, useCrossEngineIsConnected } from "~/components/DevPresence";
3132
import { WarmStartIconWithTooltip } from "~/components/WarmStarts";
@@ -87,15 +88,13 @@ import {
8788
docsPath,
8889
v3BillingPath,
8990
v3RunParamsSchema,
90-
v3RunPath,
9191
v3RunRedirectPath,
9292
v3RunSpanPath,
9393
v3RunStreamingPath,
9494
v3RunsPath,
9595
} from "~/utils/pathBuilder";
9696
import { useCurrentPlan } from "../_app.orgs.$organizationSlug/route";
9797
import { SpanView } from "../resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam/route";
98-
import { TextLink } from "~/components/primitives/TextLink";
9998

10099
const resizableSettings = {
101100
parent: {
@@ -297,8 +296,7 @@ function TraceView({ run, trace, maximumLiveReloadingSetting, resizable }: Loade
297296
return <></>;
298297
}
299298

300-
const { events, parentRunFriendlyId, duration, rootSpanStatus, rootStartedAt, queuedDuration } =
301-
trace;
299+
const { events, duration, rootSpanStatus, rootStartedAt, queuedDuration } = trace;
302300
const shouldLiveReload = events.length <= maximumLiveReloadingSetting;
303301

304302
const changeToSpan = useDebounce((selectedSpan: string) => {
@@ -335,7 +333,6 @@ function TraceView({ run, trace, maximumLiveReloadingSetting, resizable }: Loade
335333
selectedId={selectedSpanId}
336334
key={events[0]?.id ?? "-"}
337335
events={events}
338-
parentRunFriendlyId={parentRunFriendlyId}
339336
onSelectedIdChanged={(selectedSpan) => {
340337
//instantly close the panel if no span is selected
341338
if (!selectedSpan) {
@@ -353,6 +350,7 @@ function TraceView({ run, trace, maximumLiveReloadingSetting, resizable }: Loade
353350
shouldLiveReload={shouldLiveReload}
354351
maximumLiveReloadingSetting={maximumLiveReloadingSetting}
355352
rootRun={run.rootTaskRun}
353+
parentRun={run.parentTaskRun}
356354
isCompleted={run.completedAt !== null}
357355
/>
358356
</ResizablePanel>
@@ -471,7 +469,6 @@ function NoLogsView({ run, resizable }: LoaderData) {
471469
type TasksTreeViewProps = {
472470
events: TraceEvent[];
473471
selectedId?: string;
474-
parentRunFriendlyId?: string;
475472
onSelectedIdChanged: (selectedId: string | undefined) => void;
476473
totalDuration: number;
477474
rootSpanStatus: "executing" | "completed" | "failed";
@@ -485,13 +482,17 @@ type TasksTreeViewProps = {
485482
taskIdentifier: string;
486483
spanId: string;
487484
} | null;
485+
parentRun: {
486+
friendlyId: string;
487+
taskIdentifier: string;
488+
spanId: string;
489+
} | null;
488490
isCompleted: boolean;
489491
};
490492

491493
function TasksTreeView({
492494
events,
493495
selectedId,
494-
parentRunFriendlyId,
495496
onSelectedIdChanged,
496497
totalDuration,
497498
rootSpanStatus,
@@ -501,6 +502,7 @@ function TasksTreeView({
501502
shouldLiveReload,
502503
maximumLiveReloadingSetting,
503504
rootRun,
505+
parentRun,
504506
isCompleted,
505507
}: TasksTreeViewProps) {
506508
const isAdmin = useHasAdminAccess();
@@ -584,35 +586,32 @@ function TasksTreeView({
584586
id={resizableSettings.tree.tree.id}
585587
default={resizableSettings.tree.tree.default}
586588
min={resizableSettings.tree.tree.min}
587-
className="pl-3"
588589
>
589590
<div className="grid h-full grid-rows-[2rem_1fr] overflow-hidden">
590-
<div className="flex items-center pr-2">
591-
{rootRun || parentRunFriendlyId ? (
591+
<div className="flex items-center pl-1 pr-2">
592+
{rootRun || parentRun ? (
592593
<ShowParentOrRootLinks
593594
relationships={{
594595
root: rootRun
595596
? {
596597
friendlyId: rootRun.friendlyId,
597598
taskIdentifier: rootRun.taskIdentifier,
598599
spanId: rootRun.spanId,
599-
isParent: parentRunFriendlyId
600-
? rootRun.friendlyId === parentRunFriendlyId
601-
: true,
600+
isParent: parentRun ? rootRun.friendlyId === parentRun.friendlyId : true,
602601
}
603602
: undefined,
604603
parent:
605-
parentRunFriendlyId && rootRun?.friendlyId !== parentRunFriendlyId
604+
parentRun && rootRun?.friendlyId !== parentRun.friendlyId
606605
? {
607-
friendlyId: parentRunFriendlyId,
606+
friendlyId: parentRun.friendlyId,
608607
taskIdentifier: "",
609608
spanId: "",
610609
}
611610
: undefined,
612611
}}
613612
/>
614613
) : (
615-
<Paragraph variant="extra-small" className="flex-1 text-charcoal-500">
614+
<Paragraph variant="extra-small" className="flex-1 pl-3 text-charcoal-500">
616615
This is the root task
617616
</Paragraph>
618617
)}
@@ -631,6 +630,7 @@ function TasksTreeView({
631630
nodes={nodes}
632631
getNodeProps={getNodeProps}
633632
getTreeProps={getTreeProps}
633+
parentClassName="pl-3"
634634
renderNode={({ node, state, index }) => (
635635
<>
636636
<div
@@ -1166,54 +1166,81 @@ function ShowParentOrRootLinks({
11661166
// Case 1: Root is also the parent
11671167
if (relationships.root?.isParent === true) {
11681168
return (
1169-
<TextLink
1169+
<LinkButton
1170+
variant="minimal/small"
11701171
to={v3RunSpanPath(
11711172
organization,
11721173
project,
11731174
environment,
11741175
{ friendlyId: relationships.root.friendlyId },
11751176
{ spanId: relationships.root.spanId }
11761177
)}
1178+
LeadingIcon={MoveToTopIcon}
11771179
shortcut={{ key: "t" }}
1180+
hideShortcutKey
1181+
tooltip={
1182+
<div className="-mr-1 flex items-center gap-1">
1183+
<Paragraph variant="extra-small">Jump to root/parent run</Paragraph>
1184+
<ShortcutKey shortcut={{ key: "t" }} variant="small" />
1185+
</div>
1186+
}
11781187
className="text-xs"
11791188
>
1180-
Jump to Root & Parent
1181-
</TextLink>
1189+
Root/parent
1190+
</LinkButton>
11821191
);
11831192
}
11841193

11851194
// Case 2: Root and Parent are different runs
11861195
return (
1187-
<div className="flex flex-1 items-center gap-2">
1196+
<div className="flex items-center">
11881197
{relationships.root && (
1189-
<TextLink
1198+
<LinkButton
1199+
variant="minimal/small"
11901200
to={v3RunSpanPath(
11911201
organization,
11921202
project,
11931203
environment,
11941204
{ friendlyId: relationships.root.friendlyId },
11951205
{ spanId: relationships.root.spanId }
11961206
)}
1207+
LeadingIcon={MoveToTopIcon}
11971208
shortcut={{ key: "t" }}
1209+
hideShortcutKey
1210+
tooltip={
1211+
<div className="-mr-1 flex items-center gap-1">
1212+
<Paragraph variant="extra-small">Jump to root run</Paragraph>
1213+
<ShortcutKey shortcut={{ key: "t" }} variant="small" />
1214+
</div>
1215+
}
11981216
className="text-xs"
11991217
>
1200-
Jump to Root
1201-
</TextLink>
1218+
Root
1219+
</LinkButton>
12021220
)}
12031221
{relationships.parent && (
1204-
<TextLink
1222+
<LinkButton
1223+
variant="minimal/small"
12051224
to={v3RunSpanPath(
12061225
organization,
12071226
project,
12081227
environment,
12091228
{ friendlyId: relationships.parent.friendlyId },
12101229
{ spanId: relationships.parent.spanId }
12111230
)}
1231+
LeadingIcon={MoveUpIcon}
12121232
shortcut={{ key: "p" }}
1233+
hideShortcutKey
1234+
tooltip={
1235+
<div className="-mr-1 flex items-center gap-1">
1236+
<Paragraph variant="extra-small">Jump to parent run</Paragraph>
1237+
<ShortcutKey shortcut={{ key: "p" }} variant="small" />
1238+
</div>
1239+
}
12131240
className="text-xs"
12141241
>
1215-
Jump to Parent
1216-
</TextLink>
1242+
Parent
1243+
</LinkButton>
12171244
)}
12181245
</div>
12191246
);

0 commit comments

Comments
 (0)