Skip to content

Commit 7da933d

Browse files
committed
Root only toggle stay active when filtering by task
1 parent f782a43 commit 7da933d

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -672,9 +672,20 @@ function TasksDropdown({
672672
}) {
673673
const { values, replace } = useSearchParams();
674674

675-
const handleChange = (values: string[]) => {
675+
const handleChange = (newValues: string[]) => {
676676
clearSearchValue();
677-
replace({ tasks: values, cursor: undefined, direction: undefined });
677+
const previousTasks = values("tasks");
678+
const wasEmpty = previousTasks.length === 0 || previousTasks.every((v) => v === "");
679+
const isEmpty = newValues.length === 0 || newValues.every((v) => v === "");
680+
// When transitioning from no tasks to tasks, force rootOnly off so users
681+
// see the runs of the task they just selected (root or otherwise).
682+
const transitioningToTasks = wasEmpty && !isEmpty;
683+
replace({
684+
tasks: newValues,
685+
cursor: undefined,
686+
direction: undefined,
687+
...(transitioningToTasks ? { rootOnly: "false" } : {}),
688+
});
678689
};
679690

680691
const filtered = useMemo(() => {
@@ -1456,16 +1467,15 @@ function AppliedVersionsFilter() {
14561467
const rootOnlyShortcut = { key: "o" };
14571468

14581469
function RootOnlyToggle({ defaultValue }: { defaultValue: boolean }) {
1459-
const { value, values, replace } = useSearchParams();
1470+
const { value, replace } = useSearchParams();
14601471
const searchValue = value("rootOnly");
14611472
const rootOnly = searchValue !== undefined ? searchValue === "true" : defaultValue;
14621473

14631474
const batchId = value("batchId");
14641475
const runId = value("runId");
14651476
const scheduleId = value("scheduleId");
1466-
const tasks = values("tasks");
14671477

1468-
const disabled = !!batchId || !!runId || !!scheduleId || tasks.length > 0;
1478+
const disabled = !!batchId || !!runId || !!scheduleId;
14691479

14701480
return (
14711481
<Ariakit.TooltipProvider timeout={200}>

apps/webapp/app/services/runsRepository/runsRepository.server.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,9 @@ export async function convertRunListInputOptionsToFilterRunsOptions(
295295
convertedOptions.runId = options.runId.map((r) => RunId.toFriendlyId(r));
296296
}
297297

298-
// Show all runs if we are filtering by batchId or runId
299-
if (options.batchId || options.runId?.length || options.scheduleId || options.tasks?.length) {
298+
// batchId/runId/scheduleId target specific runs, so rootOnly is meaningless and forced off.
299+
// tasks is intentionally excluded so rootOnly can narrow a task filter to root runs only.
300+
if (options.batchId || options.runId?.length || options.scheduleId) {
300301
convertedOptions.rootOnly = false;
301302
}
302303

0 commit comments

Comments
 (0)