Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function FlowRunsAccordionContent({
},
page: targetPage,
limit: ITEMS_PER_PAGE,
sort: "START_TIME_DESC" as const,
sort: "EXPECTED_START_TIME_DESC" as const,
};
},
[filter, flowId],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function FlowRunsAccordionHeader({
const lastFlowRunFilter: FlowRunsFilter = useMemo(() => {
return {
...flowFilter,
sort: "START_TIME_DESC",
sort: "EXPECTED_START_TIME_DESC",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Render header timestamp from expected start when sorting by it

Sorting the header query by EXPECTED_START_TIME_DESC can now select scheduled/paused runs whose start_time is null, but the header only renders a timestamp when lastFlowRun.start_time is present. In the SCHEDULED/PAUSED tab (or any flow whose newest run has not started), this regresses the header to showing no “last run” time even though a run exists. Consider falling back to expected_start_time (or selecting the most recent run with a non-null start_time) so the header remains informative.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — addressed in a379b12. The header now falls back to expected_start_time when start_time is null, so scheduled/paused runs still show a timestamp.

limit: 1,
offset: 0,
};
Expand All @@ -63,9 +63,14 @@ export function FlowRunsAccordionHeader({
className="text-sm font-medium text-foreground hover:underline flex items-center gap-1"
onClick={(e) => e.stopPropagation()}
/>
{lastFlowRun?.start_time && (
{(lastFlowRun?.start_time ?? lastFlowRun?.expected_start_time) && (
<FormattedDate
date={new Date(lastFlowRun.start_time)}
date={
new Date(
(lastFlowRun?.start_time ??
lastFlowRun?.expected_start_time) as string,
)
}
format="relative"
className="text-xs text-muted-foreground"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ describe("FlowRunsAccordionHeader", () => {
render(
<FlowRunsAccordionHeaderRouter
flow={flow}
filter={{ sort: "START_TIME_DESC", offset: 0 }}
filter={{ sort: "EXPECTED_START_TIME_DESC", offset: 0 }}
/>,
{
wrapper: createWrapper(),
Expand Down Expand Up @@ -285,7 +285,7 @@ describe("FlowRunsAccordionHeader", () => {
render(
<FlowRunsAccordionHeaderRouter
flow={flow}
filter={{ sort: "START_TIME_DESC", offset: 0 }}
filter={{ sort: "EXPECTED_START_TIME_DESC", offset: 0 }}
/>,
{
wrapper: createWrapper(),
Expand Down Expand Up @@ -319,7 +319,7 @@ describe("FlowRunsAccordionHeader", () => {
render(
<FlowRunsAccordionHeaderRouter
flow={flow}
filter={{ sort: "START_TIME_DESC", offset: 0 }}
filter={{ sort: "EXPECTED_START_TIME_DESC", offset: 0 }}
/>,
{
wrapper: createWrapper(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function FlowRunsAccordion({
// Build the flow runs filter with state type
const flowRunsFilter: FlowRunsFilter = useMemo(() => {
const baseFilter: FlowRunsFilter = {
sort: "START_TIME_DESC",
sort: "EXPECTED_START_TIME_DESC",
offset: 0,
...filter,
};
Expand Down
30 changes: 15 additions & 15 deletions ui-v2/src/components/dashboard/flow-runs-card/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ describe("FlowRunsCard", () => {

const queryClient = new QueryClient();
const queryOptions = buildFilterFlowRunsQuery({
sort: "START_TIME_DESC",
sort: "EXPECTED_START_TIME_DESC",
offset: 0,
});
queryClient.setQueryData(queryOptions.queryKey, [flowRun1, flowRun2]);
Expand All @@ -188,7 +188,7 @@ describe("FlowRunsCard", () => {

const queryClient = new QueryClient();
const filter: FlowRunsFilter = {
sort: "START_TIME_DESC",
sort: "EXPECTED_START_TIME_DESC",
offset: 0,
};
const queryOptions = buildFilterFlowRunsQuery(filter);
Expand All @@ -205,7 +205,7 @@ describe("FlowRunsCard", () => {
it("does not display count when no flow runs exist", async () => {
const queryClient = new QueryClient();
const queryOptions = buildFilterFlowRunsQuery({
sort: "START_TIME_DESC",
sort: "EXPECTED_START_TIME_DESC",
offset: 0,
});
queryClient.setQueryData(queryOptions.queryKey, []);
Expand All @@ -221,7 +221,7 @@ describe("FlowRunsCard", () => {
it("shows chart and state tabs when no flow runs", async () => {
const queryClient = new QueryClient();
const queryOptions = buildFilterFlowRunsQuery({
sort: "START_TIME_DESC",
sort: "EXPECTED_START_TIME_DESC",
offset: 0,
});
queryClient.setQueryData(queryOptions.queryKey, []);
Expand All @@ -241,7 +241,7 @@ describe("FlowRunsCard", () => {

const queryClient = new QueryClient();
const filter: FlowRunsFilter = {
sort: "START_TIME_DESC",
sort: "EXPECTED_START_TIME_DESC",
offset: 0,
};
const queryOptions = buildFilterFlowRunsQuery(filter);
Expand Down Expand Up @@ -271,11 +271,11 @@ describe("FlowRunsCard", () => {

const queryClient = new QueryClient();
const filter: FlowRunsFilter = {
sort: "START_TIME_DESC",
sort: "EXPECTED_START_TIME_DESC",
offset: 0,
flow_runs: {
operator: "and_",
start_time: {
expected_start_time: {
after_: startDate,
before_: endDate,
},
Expand Down Expand Up @@ -310,7 +310,7 @@ describe("FlowRunsCard", () => {

const queryClient = new QueryClient();
const filter: FlowRunsFilter = {
sort: "START_TIME_DESC",
sort: "EXPECTED_START_TIME_DESC",
offset: 0,
flow_runs: {
operator: "and_",
Expand Down Expand Up @@ -348,7 +348,7 @@ describe("FlowRunsCard", () => {

const queryClient = new QueryClient();
const filter: FlowRunsFilter = {
sort: "START_TIME_DESC",
sort: "EXPECTED_START_TIME_DESC",
offset: 0,
flow_runs: {
operator: "and_",
Expand Down Expand Up @@ -390,11 +390,11 @@ describe("FlowRunsCard", () => {

const queryClient = new QueryClient();
const filter: FlowRunsFilter = {
sort: "START_TIME_DESC",
sort: "EXPECTED_START_TIME_DESC",
offset: 0,
flow_runs: {
operator: "and_",
start_time: {
expected_start_time: {
after_: startDate,
before_: endDate,
},
Expand Down Expand Up @@ -434,7 +434,7 @@ describe("FlowRunsCard", () => {

const queryClient = new QueryClient();
const filter: FlowRunsFilter = {
sort: "START_TIME_DESC",
sort: "EXPECTED_START_TIME_DESC",
offset: 0,
};
const queryOptions = buildFilterFlowRunsQuery(filter);
Expand Down Expand Up @@ -466,7 +466,7 @@ describe("FlowRunsCard", () => {

const queryClient = new QueryClient();
const filter: FlowRunsFilter = {
sort: "START_TIME_DESC",
sort: "EXPECTED_START_TIME_DESC",
offset: 0,
};
const queryOptions = buildFilterFlowRunsQuery(filter);
Expand All @@ -492,7 +492,7 @@ describe("FlowRunsCard", () => {

const queryClient = new QueryClient();
const filter: FlowRunsFilter = {
sort: "START_TIME_DESC",
sort: "EXPECTED_START_TIME_DESC",
offset: 0,
};
const queryOptions = buildFilterFlowRunsQuery(filter);
Expand All @@ -516,7 +516,7 @@ describe("FlowRunsCard", () => {

const queryClient = new QueryClient();
const filter: FlowRunsFilter = {
sort: "START_TIME_DESC",
sort: "EXPECTED_START_TIME_DESC",
offset: 0,
};
const queryOptions = buildFilterFlowRunsQuery(filter);
Expand Down
4 changes: 2 additions & 2 deletions ui-v2/src/components/dashboard/flow-runs-card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function FlowRunsCard({

const flowRunsFilter: FlowRunsFilter = useMemo(() => {
const baseFilter: FlowRunsFilter = {
sort: "START_TIME_DESC",
sort: "EXPECTED_START_TIME_DESC",
offset: 0,
};

Expand All @@ -76,7 +76,7 @@ export function FlowRunsCard({
};

if (filter?.startDate && filter?.endDate) {
flowRunsFilterObj.start_time = {
flowRunsFilterObj.expected_start_time = {
after_: filter.startDate,
before_: filter.endDate,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function useGetNextRun(deployment: Deployment) {
});

return useMemo(() => {
if (!data || !data[0]) {
if (!data?.[0]) {
return undefined;
}
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type EventsTooltipProps = {
};

const EventsTooltipContent = ({ active, payload }: EventsTooltipProps) => {
if (!active || !payload || !payload.length) return null;
if (!active || !payload?.length) return null;

const firstPayloadItem = payload[0];
const point = firstPayloadItem?.payload;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ FlowRunActivityBarChart.displayName = "FlowRunActivityBarChart";
type FlowRunTooltipProps = Partial<TooltipContentProps<number, string>>;

const FlowRunTooltip = ({ payload, active }: FlowRunTooltipProps) => {
if (!active || !payload || !payload.length) {
if (!active || !payload?.length) {
return null;
}
const firstPayloadItem = payload[0] as { payload?: unknown } | undefined;
Expand All @@ -306,7 +306,7 @@ const FlowRunTooltip = ({ payload, active }: FlowRunTooltipProps) => {
return null;
}
const flowRun = nestedPayload.flowRun as EnrichedFlowRun;
if (!flowRun || !flowRun.id) {
if (!flowRun?.id) {
return null;
}

Expand Down
6 changes: 3 additions & 3 deletions ui-v2/src/routes/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,15 @@
const { tags, hideSubflows } = search;

const baseFilter: FlowRunsFilter = {
sort: "START_TIME_DESC",
sort: "EXPECTED_START_TIME_DESC",
offset: 0,
};

const flowRunsFilterObj: NonNullable<FlowRunsFilter["flow_runs"]> = {
operator: "and_",
};

flowRunsFilterObj.start_time = {
flowRunsFilterObj.expected_start_time = {
after_: from,
before_: to,
};
Expand Down Expand Up @@ -364,7 +364,7 @@
["CANCELLED"],
] as const;

export const Route = createFileRoute("/dashboard")({

Check warning on line 367 in ui-v2/src/routes/dashboard.tsx

View workflow job for this annotation

GitHub Actions / Lint

Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components
validateSearch: zodValidator(searchParams),
component: RouteComponent,
pendingComponent: PrefectLoading,
Expand Down Expand Up @@ -535,7 +535,7 @@
// Prefetch last flow run for this flow (matches FlowRunsAccordionHeader.lastFlowRunFilter)
const lastFlowRunFilter: FlowRunsFilter = {
...flowFilter,
sort: "START_TIME_DESC",
sort: "EXPECTED_START_TIME_DESC",
limit: 1,
offset: 0,
};
Expand Down
Loading