A test run pins a validated draft, runs with forge and push writes suppressed and recorded per step, and is excluded from workflow stats. The History tab lists revisions that changed a workflow, diffs them as YAML and on the canvas, restores into the editor, and ties runs to the revision they used.
217 lines
7.5 KiB
Vue
217 lines
7.5 KiB
Vue
<script lang="ts">
|
|
// The shell's global reduced-motion rule switches CSS transitions and
|
|
// animations, NOT the JS smooth scroll this page performs when it reveals a
|
|
// deep-linked row. The decision therefore has to be made here, in JavaScript,
|
|
// and is exported so it can be tested directly (jsdom implements neither
|
|
// matchMedia nor scrollIntoView).
|
|
export function prefersReducedMotion(): boolean {
|
|
return (
|
|
typeof window !== "undefined" &&
|
|
window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches === true
|
|
);
|
|
}
|
|
|
|
export function revealBehavior(): ScrollBehavior {
|
|
return prefersReducedMotion() ? "auto" : "smooth";
|
|
}
|
|
</script>
|
|
|
|
<script setup lang="ts">
|
|
import { computed, nextTick, onMounted, ref, watch } from "vue";
|
|
import { useRoute, useRouter } from "vue-router";
|
|
|
|
import PageHeader from "@/base/PageHeader.vue";
|
|
import { Card, CardContent } from "@/components/ui/card";
|
|
import { Button } from "@/components/ui/button";
|
|
import { api } from "@/lib/api";
|
|
import { statusList } from "@/lib/task-meta";
|
|
import { useLiveResource } from "@/stores/session";
|
|
import TaskFilters from "./TaskFilters.vue";
|
|
import { boardStatus, initialTaskFilter } from "./task-filter";
|
|
import type { Task } from "./TaskRow.vue";
|
|
import TaskTable from "./TaskTable.vue";
|
|
import TasksState from "./TasksState.vue";
|
|
|
|
/**
|
|
* The task board: every issue archied has picked up, and where it stands. It
|
|
* owns the two things the query string names -- which status is filtered and
|
|
* which task a link pointed at -- and composes the rest.
|
|
*/
|
|
|
|
const route = useRoute();
|
|
const router = useRouter();
|
|
|
|
// null means loading: an empty list and a list that has not arrived are
|
|
// different states, and only one of them is worth a spinner.
|
|
const tasks = ref<Task[] | null>(null);
|
|
const next = ref<string | null>(null);
|
|
const loadingMore = ref(false);
|
|
const error = ref<string | null>(null);
|
|
const search = ref("");
|
|
|
|
const statusQuery = computed(() =>
|
|
typeof route.query.status === "string" ? route.query.status : "",
|
|
);
|
|
const requestedTaskId = computed(() => {
|
|
const raw = route.query.task;
|
|
const id = Number(typeof raw === "string" ? raw : NaN);
|
|
return Number.isSafeInteger(id) && id > 0 ? id : null;
|
|
});
|
|
|
|
// The filter follows the URL as well as writing to it: a dashboard link or a
|
|
// back-button step has to move the control, not just load the page behind it.
|
|
// It is derived rather than captured, and the catalog is read inside the
|
|
// computed: the served catalog lands after this page sets up, so a drop to the
|
|
// freeze-dried defaults here would drop a shared link to a status the server
|
|
// serves.
|
|
const status = computed(() => boardStatus(statusQuery.value, statusList()));
|
|
|
|
// The server filters by status; search narrows the rows already loaded.
|
|
const visible = computed(() =>
|
|
(tasks.value ?? []).filter((task) => {
|
|
const needle = search.value.trim().toLowerCase();
|
|
if (!needle) return true;
|
|
return `${task.title ?? ""} ${task.repo ?? ""}`
|
|
.toLowerCase()
|
|
.includes(needle);
|
|
}),
|
|
);
|
|
|
|
// The repo column only earns its width when the rows differ. On a
|
|
// single-repository deployment it repeated one value down every row while the
|
|
// title was squeezed, so it goes when every visible row shares it.
|
|
const showRepo = computed(() => {
|
|
const rows = visible.value;
|
|
return rows.length < 2 || rows.some((task) => task.repo !== rows[0].repo);
|
|
});
|
|
|
|
// Chat tasks carry a placeholder issue number, so the column goes when no
|
|
// visible row names a real issue.
|
|
const showIssue = computed(() =>
|
|
visible.value.some((task) => task.source !== "chat" && task.source !== "test" && task.issue_number),
|
|
);
|
|
|
|
const state = computed<"loading" | "error" | "empty" | "no-match">(() => {
|
|
if (error.value) return "error";
|
|
if (tasks.value === null) return "loading";
|
|
if (!tasks.value.length) return "empty";
|
|
return "no-match";
|
|
});
|
|
|
|
const PAGE = 100;
|
|
|
|
// load re-reads the board from the top, as many rows as are showing, so a live
|
|
// update or a row action does not collapse pages the operator loaded.
|
|
async function load() {
|
|
error.value = null;
|
|
const limit = Math.min(Math.max(tasks.value?.length ?? 0, PAGE), 500);
|
|
try {
|
|
const page = await api.taskPage<Task>({ status: status.value || undefined, limit });
|
|
tasks.value = page.tasks;
|
|
next.value = page.next;
|
|
} catch (err) {
|
|
error.value = String((err as Error).message || err);
|
|
tasks.value = null;
|
|
}
|
|
}
|
|
|
|
async function loadMore() {
|
|
if (!next.value || loadingMore.value) return;
|
|
loadingMore.value = true;
|
|
try {
|
|
const page = await api.taskPage<Task>({
|
|
status: status.value || undefined,
|
|
limit: PAGE,
|
|
cursor: next.value,
|
|
});
|
|
tasks.value = [...(tasks.value ?? []), ...page.tasks];
|
|
next.value = page.next;
|
|
} catch (err) {
|
|
error.value = String((err as Error).message || err);
|
|
} finally {
|
|
loadingMore.value = false;
|
|
}
|
|
}
|
|
|
|
useLiveResource("tasks", () => void load(), 500);
|
|
onMounted(load);
|
|
watch(status, () => {
|
|
tasks.value = null;
|
|
void load();
|
|
});
|
|
|
|
// A filter change is a query-only route change, so it must not remount the
|
|
// list: the table keeps its identity and only its rows move. The query is the
|
|
// only filter state -- the control re-derives from it -- and an empty status is
|
|
// dropped from the query rather than written as `?status=`.
|
|
function setStatus(value: string) {
|
|
const requested = initialTaskFilter(value, statusList());
|
|
const query = { ...route.query };
|
|
if (requested) query.status = requested;
|
|
else delete query.status;
|
|
void router.replace({ query });
|
|
}
|
|
|
|
function clearFilters() {
|
|
search.value = "";
|
|
setStatus("");
|
|
}
|
|
|
|
// A deep link (?task=<id>) reveals the row it names: focus it, so keyboard and
|
|
// screen-reader users land where the link pointed, then scroll it into view.
|
|
// Once per id -- a reload after a row action must not move the page under the
|
|
// operator.
|
|
const revealed = ref<number | null>(null);
|
|
|
|
watch([requestedTaskId, tasks], () => {
|
|
const id = requestedTaskId.value;
|
|
if (id === null || tasks.value === null || revealed.value === id) return;
|
|
revealed.value = id;
|
|
void reveal(id);
|
|
});
|
|
|
|
async function reveal(id: number) {
|
|
// The row has to be in the DOM before it can be found or scrolled to.
|
|
await nextTick();
|
|
requestAnimationFrame(() => {
|
|
const row = document.getElementById(`task-row-${id}`);
|
|
if (!row) return;
|
|
row.focus({ preventScroll: true });
|
|
// Optional call: focusing a deep-linked row is a nicety, and not every
|
|
// environment implements scrollIntoView on an element.
|
|
row.scrollIntoView?.({ block: "center", behavior: revealBehavior() });
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<PageHeader title="Tasks">
|
|
<TaskFilters
|
|
v-if="!error"
|
|
:status="status"
|
|
:search="search"
|
|
@update:status="setStatus"
|
|
@update:search="search = $event"
|
|
/>
|
|
</PageHeader>
|
|
<Card>
|
|
<CardContent class="flex flex-col gap-3">
|
|
<TasksState v-if="error" kind="error" :detail="error" />
|
|
<template v-else>
|
|
<!--
|
|
An action can change what a task is and what it still offers, so the
|
|
list is re-read from the server rather than patched in place: the
|
|
server owns both the status vocabulary and the controls a status
|
|
allows.
|
|
-->
|
|
<TaskTable :tasks="visible" :show-repo="showRepo" :show-issue="showIssue" @done="load">
|
|
<template #state>
|
|
<TasksState :kind="state" @clear="clearFilters" />
|
|
</template>
|
|
</TaskTable>
|
|
<Button v-if="next" variant="outline" class="self-center" :disabled="loadingMore" @click="loadMore">Load more</Button>
|
|
</template>
|
|
</CardContent>
|
|
</Card>
|
|
</template>
|