Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions packages/ui/src/features/loops/components/LoopDetailView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ import { TimezoneTimestamp } from "@posthog/ui/primitives/TimezoneTimestamp";
import { systemTimezone } from "@posthog/ui/primitives/timezone";
import { toast } from "@posthog/ui/primitives/toast";
import {
canGoBackInHistory,
goBackInHistory,
navigateToEditLoop,
navigateToLoops,
} from "@posthog/ui/router/navigationBridge";
import { track } from "@posthog/ui/shell/analytics";
import { useHostCapabilities } from "@posthog/ui/shell/useHostCapabilities";
import { Flex, Text } from "@radix-ui/themes";
import { useQuery } from "@tanstack/react-query";
import { useLocation } from "@tanstack/react-router";
import { useEffect, useRef, useState } from "react";
import { useLoop } from "../hooks/useLoop";
import {
Expand Down Expand Up @@ -62,6 +65,9 @@ import { LoopLoadError } from "./LoopFallbacks";
import { LoopRunRow } from "./LoopRunRow";

export function LoopDetailView({ loopId }: { loopId: string }) {
const hasLoopListOrigin = useLocation({
select: (location) => location.state.loopListOrigin === true,
});
const { data: loop, isLoading, isError } = useLoop(loopId);
const updateLoop = useUpdateLoop(loopId);
const deleteLoop = useDeleteLoop();
Expand Down Expand Up @@ -207,11 +213,17 @@ export function LoopDetailView({ loopId }: { loopId: string }) {
<Button
variant="link-muted"
size="sm"
onClick={navigateToLoops}
onClick={() => {
if (hasLoopListOrigin && canGoBackInHistory()) {
goBackInHistory();
return;
}
navigateToLoops();
}}
className="w-fit px-0"
>
<ArrowLeftIcon size={15} />
Loops
Back
</Button>

<Flex align="center" justify="between" gap="3" wrap="wrap">
Expand Down
7 changes: 7 additions & 0 deletions packages/ui/src/features/loops/components/LoopRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ import {
summarizeNotificationDestinations,
} from "../loopDisplay";

declare module "@tanstack/react-router" {
interface HistoryState {
loopListOrigin?: boolean;
}
}

export function LoopRow({
loop,
creator,
Expand Down Expand Up @@ -55,6 +61,7 @@ export function LoopRow({
<Link
to="/code/loops/$loopId"
params={{ loopId: loop.id }}
state={{ loopListOrigin: true }}
className="flex items-center justify-between gap-3 rounded-(--radius-2) border border-border bg-(--color-panel-solid) px-4 py-3.5 no-underline transition-colors duration-150 hover:border-(--gray-6) hover:bg-(--gray-2)"
>
<Flex align="center" gap="3" className="min-w-0">
Expand Down
Loading