Skip to content

Commit 701d5af

Browse files
committed
Hide the root badge if the task isn’t the root
1 parent 35bb7a2 commit 701d5af

File tree

4 files changed

+48
-9
lines changed

4 files changed

+48
-9
lines changed

apps/webapp/app/components/primitives/Badge.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const variants = {
66
"grid place-items-center rounded-full px-2 h-5 tracking-wider text-xxs bg-charcoal-750 text-text-bright uppercase whitespace-nowrap",
77
small:
88
"grid place-items-center rounded-full px-[0.4rem] h-4 tracking-wider text-xxs bg-background-dimmed text-text-dimmed uppercase whitespace-nowrap",
9+
"extra-small":
10+
"grid place-items-center rounded-full px-1.5 h-4 border-tracking-wider text-xxs bg-background-bright text-blue-500 whitespace-nowrap",
911
outline:
1012
"grid place-items-center rounded-sm px-1.5 h-5 tracking-wider text-xxs border border-dimmed text-text-dimmed uppercase whitespace-nowrap",
1113
"outline-rounded":

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,10 @@ export function TaskRunsTable({
280280
/>
281281
</TableCell>
282282
<TableCell to={path}>
283-
{run.taskIdentifier} {run.rootTaskRunId === null ? <Badge>Root</Badge> : null}
283+
<span className="flex items-center gap-x-1">
284+
{run.taskIdentifier}
285+
{run.rootTaskRunId === null ? <Badge variant="extra-small">Root</Badge> : null}
286+
</span>
284287
</TableCell>
285288
<TableCell to={path}>{run.version ?? "–"}</TableCell>
286289
<TableCell to={path}>

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ export class RunPresenter {
3737
status: true,
3838
completedAt: true,
3939
logsDeletedAt: true,
40+
rootTaskRun: {
41+
select: {
42+
friendlyId: true,
43+
taskIdentifier: true,
44+
spanId: true,
45+
},
46+
},
4047
runtimeEnvironment: {
4148
select: {
4249
id: true,
@@ -80,6 +87,7 @@ export class RunPresenter {
8087
isFinished: isFinalRunStatus(run.status),
8188
completedAt: run.completedAt,
8289
logsDeletedAt: run.logsDeletedAt,
90+
rootTaskRun: run.rootTaskRun,
8391
environment: {
8492
id: run.runtimeEnvironment.id,
8593
organizationId: run.runtimeEnvironment.organizationId,
@@ -141,6 +149,7 @@ export class RunPresenter {
141149
isFinished: isFinalRunStatus(run.status),
142150
completedAt: run.completedAt,
143151
logsDeletedAt: run.logsDeletedAt,
152+
rootTaskRun: run.rootTaskRun,
144153
environment: {
145154
id: run.runtimeEnvironment.id,
146155
organizationId: run.runtimeEnvironment.organizationId,

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

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import { useProject } from "~/hooks/useProject";
6565
import { useReplaceLocation } from "~/hooks/useReplaceLocation";
6666
import { Shortcut, useShortcutKeys } from "~/hooks/useShortcutKeys";
6767
import { useUser } from "~/hooks/useUser";
68-
import { RunPresenter } from "~/presenters/v3/RunPresenter.server";
68+
import { Run, RunPresenter } from "~/presenters/v3/RunPresenter.server";
6969
import { requireUserId } from "~/services/session.server";
7070
import { cn } from "~/utils/cn";
7171
import { lerp } from "~/utils/lerp";
@@ -316,6 +316,7 @@ function TraceView({ run, trace, maximumLiveReloadingSetting, resizable }: Loade
316316
environmentType={run.environment.type}
317317
shouldLiveReload={shouldLiveReload}
318318
maximumLiveReloadingSetting={maximumLiveReloadingSetting}
319+
rootRun={run.rootTaskRun}
319320
/>
320321
</ResizablePanel>
321322
<ResizableHandle id={resizableSettings.parent.handleId} />
@@ -438,6 +439,11 @@ type TasksTreeViewProps = {
438439
environmentType: RuntimeEnvironmentType;
439440
shouldLiveReload: boolean;
440441
maximumLiveReloadingSetting: number;
442+
rootRun: {
443+
friendlyId: string;
444+
taskIdentifier: string;
445+
spanId: string;
446+
} | null;
441447
};
442448

443449
function TasksTreeView({
@@ -451,6 +457,7 @@ function TasksTreeView({
451457
environmentType,
452458
shouldLiveReload,
453459
maximumLiveReloadingSetting,
460+
rootRun,
454461
}: TasksTreeViewProps) {
455462
const [filterText, setFilterText] = useState("");
456463
const [errorsOnly, setErrorsOnly] = useState(false);
@@ -517,8 +524,14 @@ function TasksTreeView({
517524
>
518525
<div className="grid h-full grid-rows-[2rem_1fr] overflow-hidden">
519526
<div className="flex items-center pr-2">
520-
{parentRunFriendlyId ? (
521-
<ShowParentLink runFriendlyId={parentRunFriendlyId} />
527+
{rootRun ? (
528+
<ShowParentLink
529+
runFriendlyId={rootRun.friendlyId}
530+
isRoot={true}
531+
spanId={rootRun.spanId}
532+
/>
533+
) : parentRunFriendlyId ? (
534+
<ShowParentLink runFriendlyId={parentRunFriendlyId} isRoot={false} />
522535
) : (
523536
<Paragraph variant="small" className="flex-1 text-charcoal-500">
524537
This is the root task
@@ -599,7 +612,9 @@ function TasksTreeView({
599612
className="h-4 min-h-4 w-4 min-w-4"
600613
/>
601614
<NodeText node={node} />
602-
{node.data.isRoot && <Badge variant="outline-rounded">Root</Badge>}
615+
{node.data.isRoot && !rootRun && (
616+
<Badge variant="outline-rounded">Root</Badge>
617+
)}
603618
</div>
604619
<div className="flex items-center gap-1">
605620
<NodeStatusIcon node={node} />
@@ -954,24 +969,34 @@ function TaskLine({ isError, isSelected }: { isError: boolean; isSelected: boole
954969
return <div className={cn("h-8 w-2 border-r border-grid-bright")} />;
955970
}
956971

957-
function ShowParentLink({ runFriendlyId }: { runFriendlyId: string }) {
972+
function ShowParentLink({
973+
runFriendlyId,
974+
spanId,
975+
isRoot,
976+
}: {
977+
runFriendlyId: string;
978+
spanId?: string;
979+
isRoot: boolean;
980+
}) {
958981
const [mouseOver, setMouseOver] = useState(false);
959982
const organization = useOrganization();
960983
const project = useProject();
961984
const { spanParam } = useParams();
962985

986+
const span = spanId ? spanId : spanParam;
987+
963988
return (
964989
<LinkButton
965990
variant="minimal/medium"
966991
to={
967-
spanParam
992+
span
968993
? v3RunSpanPath(
969994
organization,
970995
project,
971996
{
972997
friendlyId: runFriendlyId,
973998
},
974-
{ spanId: spanParam }
999+
{ spanId: span }
9751000
)
9761001
: v3RunPath(organization, project, {
9771002
friendlyId: runFriendlyId,
@@ -993,7 +1018,7 @@ function ShowParentLink({ runFriendlyId }: { runFriendlyId: string }) {
9931018
variant="small"
9941019
className={cn(mouseOver ? "text-indigo-500" : "text-charcoal-500")}
9951020
>
996-
Show parent items
1021+
{isRoot ? "Show root run" : "Show parent run"}
9971022
</Paragraph>
9981023
</LinkButton>
9991024
);

0 commit comments

Comments
 (0)