feat(webui): finish redesign dashboard task and secret settings
This commit is contained in:
42 files changed
+1090
-502
No files matched your search
@@ -33,7 +33,7 @@ const fields = () => Object.entries(props.entry.fields ?? {});
|
||||
{{ (props.entry.level || "info").toUpperCase() }}
|
||||
</span>
|
||||
<span class="flex min-w-0 flex-wrap items-baseline gap-2">
|
||||
<span class="break-words text-foreground">{{
|
||||
<span class="break-words font-mono text-foreground">{{
|
||||
props.entry.message || props.entry.msg || ""
|
||||
}}</span>
|
||||
<span
|
||||
|
||||
@@ -23,6 +23,7 @@ import { statusLabel } from "@/lib/task-meta";
|
||||
* read when the palette opens, so it never shows a stale list for long.
|
||||
*/
|
||||
const props = defineProps<{ hidden: string[] }>();
|
||||
const emit = defineEmits<{ newTask: [] }>();
|
||||
|
||||
const router = useRouter();
|
||||
const open = ref(false);
|
||||
@@ -61,6 +62,11 @@ function go(path: string): void {
|
||||
void router.push(path);
|
||||
}
|
||||
|
||||
function newTask(): void {
|
||||
open.value = false;
|
||||
emit("newTask");
|
||||
}
|
||||
|
||||
// '/' opens only when the keystroke was not meant for a field.
|
||||
function isEditableTarget(event: KeyboardEvent): boolean {
|
||||
const el = event.target;
|
||||
@@ -100,6 +106,9 @@ onUnmounted(() => document.removeEventListener("keydown", onGlobalKeydown));
|
||||
<CommandInput placeholder="Find a page, task or workflow" />
|
||||
<CommandList>
|
||||
<CommandEmpty>No matches.</CommandEmpty>
|
||||
<CommandGroup v-if="showWorkflows" heading="Actions">
|
||||
<CommandItem value="New task" @select="newTask">New task</CommandItem>
|
||||
</CommandGroup>
|
||||
<CommandGroup heading="Pages">
|
||||
<CommandItem
|
||||
v-for="entry in pages"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import AlertsBell from "@/alerts/AlertsBell.vue";
|
||||
import CommandPalette from "@/components/command-palette/CommandPalette.vue";
|
||||
import NewTaskButton from "@/tasks/NewTaskButton.vue";
|
||||
@@ -8,6 +9,7 @@ import Nav from "./Nav.vue";
|
||||
import ProfileDropdown from "./ProfileDropdown.vue";
|
||||
|
||||
const props = defineProps<{ hidden: string[] }>();
|
||||
const newTaskOpen = ref(false);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -18,8 +20,8 @@ const props = defineProps<{ hidden: string[] }>();
|
||||
<Nav :hidden="props.hidden" />
|
||||
<div class="flex shrink-0 items-center gap-2">
|
||||
<ConnectionPill />
|
||||
<CommandPalette :hidden="props.hidden" />
|
||||
<NewTaskButton v-if="!props.hidden.includes('/workflows')" />
|
||||
<CommandPalette :hidden="props.hidden" @new-task="newTaskOpen = true" />
|
||||
<NewTaskButton v-if="!props.hidden.includes('/workflows')" v-model:open="newTaskOpen" />
|
||||
<AlertsBell />
|
||||
<ProfileDropdown />
|
||||
</div>
|
||||
|
||||
@@ -4,6 +4,7 @@ import { computed } from "vue";
|
||||
import { TableCell, TableRow } from "@/components/ui/table";
|
||||
import { ago } from "@/lib/format";
|
||||
import { activityDetail } from "./activity-detail";
|
||||
import { describeTimelineEvent } from "@/tasks/timeline-event";
|
||||
import { useTasksStore, type ActivityEvent } from "@/stores/tasks";
|
||||
|
||||
/**
|
||||
@@ -42,7 +43,7 @@ const when = computed(() => (props.event.at ? ago(props.event.at) : "\u2014"));
|
||||
@keydown.space.prevent="open"
|
||||
>
|
||||
<TableCell class="font-medium">{{
|
||||
props.event.kind || props.event.type || "event"
|
||||
describeTimelineEvent({ ...props.event, at: undefined, detail: undefined }).title
|
||||
}}</TableCell>
|
||||
<TableCell class="font-mono">{{
|
||||
taskID > 0 ? `#${taskID}` : "—"
|
||||
|
||||
@@ -33,6 +33,7 @@ import {
|
||||
type ActivityFilter,
|
||||
} from "./activity-filter";
|
||||
import { groupActivity, type ActivityGroup } from "./activity-group";
|
||||
import { describeTimelineEvent } from "@/tasks/timeline-event";
|
||||
|
||||
/**
|
||||
* The last 50 events, newest first, with the stream's own state on the card and
|
||||
@@ -177,7 +178,7 @@ function openTask(taskID: number) {
|
||||
v-else
|
||||
class="size-3.5 shrink-0 text-fg-subtle"
|
||||
/>
|
||||
{{ group.label }}
|
||||
{{ describeTimelineEvent({ ...group.representative, at: undefined, detail: undefined }).title }}
|
||||
<Badge variant="idle">×{{ group.count }}</Badge>
|
||||
</button>
|
||||
</TableCell>
|
||||
|
||||
@@ -14,7 +14,7 @@ const { tasks } = storeToRefs(useTasksStore());
|
||||
const loadDashboard = useTasksStore().load;
|
||||
|
||||
/** Tasks waiting on a human, each with the reason and the next action. */
|
||||
type AttentionTask = Task & { park_reason?: string };
|
||||
type AttentionTask = Task & { park_reason?: string; plan?: string };
|
||||
|
||||
const waiting = computed(() => {
|
||||
const ids = attentionStatusIds();
|
||||
@@ -23,7 +23,7 @@ const waiting = computed(() => {
|
||||
|
||||
function meta(task: AttentionTask): string {
|
||||
const where = task.owner && task.repo ? `${task.owner}/${task.repo}${task.issue_number && task.source !== "chat" ? ` #${task.issue_number}` : ""}` : "";
|
||||
return [where, task.workflow, task.park_reason].filter(Boolean).join(" · ");
|
||||
return [where, task.workflow, task.park_reason || task.plan].filter(Boolean).join(" · ");
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -2,26 +2,25 @@
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed } from "vue";
|
||||
|
||||
import SegmentBar from "@/base/SegmentBar.vue";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { compact } from "@/lib/format";
|
||||
import { useTasksStore } from "@/stores/tasks";
|
||||
|
||||
const { summary } = storeToRefs(useTasksStore());
|
||||
|
||||
/** What the current rate projects to over the next 30 days. */
|
||||
|
||||
const days = computed(() => summary.value?.tokens_by_day ?? []);
|
||||
const used = computed(() =>
|
||||
days.value.reduce((a, d) => a + (d.tokens || 0), 0),
|
||||
);
|
||||
const recent = computed(() =>
|
||||
days.value.slice(-7).reduce((a, d) => a + (d.tokens || 0), 0),
|
||||
);
|
||||
const perDay = computed(() =>
|
||||
days.value.length ? used.value / days.value.length : 0,
|
||||
);
|
||||
const projected = computed(() => Math.round(perDay.value * 30));
|
||||
// The API returns usage days newest first and omits days without usage.
|
||||
const week = computed(() => {
|
||||
const today = new Date().toISOString().slice(0, 10);
|
||||
return Array.from({ length: 7 }, (_, i) => {
|
||||
const day = new Date(Date.parse(today) - (6 - i) * 86_400_000).toISOString().slice(0, 10);
|
||||
return { day, tokens: days.value.find((d) => d.day === day)?.tokens ?? 0 };
|
||||
});
|
||||
});
|
||||
const recent = computed(() => week.value.reduce((sum, day) => sum + day.tokens, 0));
|
||||
const maximum = computed(() => Math.max(1, ...week.value.map((day) => day.tokens)));
|
||||
const recorded = computed(() => week.value.filter((day) => days.value.some((d) => d.day === day.day)).length);
|
||||
const projected = computed(() => Math.round(recent.value / 7 * 30));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -30,25 +29,17 @@ const projected = computed(() => Math.round(perDay.value * 30));
|
||||
<CardTitle>Token outlook</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div class="mb-1 text-3xl font-semibold tracking-[-0.03em]">
|
||||
{{ compact(projected) }}
|
||||
</div>
|
||||
<div class="mb-4 text-xs text-fg-subtle">Based on {{ compact(Math.round(perDay)) }} per day over
|
||||
{{ days.length }} days</div>
|
||||
<SegmentBar
|
||||
:segments="[
|
||||
{
|
||||
label: `Last 7 days (${compact(recent)})`,
|
||||
value: recent,
|
||||
kind: 'info',
|
||||
},
|
||||
{
|
||||
label: `Earlier (${compact(used - recent)})`,
|
||||
value: Math.max(used - recent, 0),
|
||||
kind: 'idle',
|
||||
},
|
||||
]"
|
||||
/>
|
||||
<p class="text-xs text-fg-subtle">Today · UTC</p>
|
||||
<p class="mb-3 font-mono text-3xl font-semibold">{{ compact(week[6]?.tokens ?? 0) }}</p>
|
||||
<p class="text-sm">{{ compact(projected) }} over the next 30 days</p>
|
||||
<p class="mb-4 text-xs text-fg-subtle">At the last seven calendar days’ rate</p>
|
||||
<ul class="flex h-28 items-end gap-2" aria-label="Token usage over the last seven UTC days">
|
||||
<li v-for="day in week" :key="day.day" class="flex h-full min-w-0 flex-1 flex-col justify-end gap-1" :aria-label="`${day.day}: ${day.tokens} tokens`" :title="`${day.day}: ${day.tokens} tokens`">
|
||||
<span class="min-h-px rounded-sm bg-primary" :style="{ height: `${day.tokens / maximum * 80}%` }" aria-hidden="true" />
|
||||
<span class="text-center font-mono text-[10px] text-fg-subtle">{{ day.day.slice(5) }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
<p v-if="recorded < 7" class="mt-3 text-xs text-fg-subtle">Usage recorded on {{ recorded }} of the last seven days; missing days count as zero.</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</template>
|
||||
@@ -138,6 +138,8 @@ async function request<T = unknown>(
|
||||
}
|
||||
|
||||
export const api = {
|
||||
secretEngines: <T = unknown>() => request<T>("/api/secret-engines"),
|
||||
checkSecret: (ref: { engine: string; key: string }) => request<{ resolved: boolean; process: string }>("/api/secret-references/check", { method: "POST", body: ref }),
|
||||
health: <T = unknown>() => request<T>("/health/detailed"),
|
||||
services: <T = unknown>() => request<T>("/api/services"),
|
||||
policies: <T = unknown>() => request<T>("/api/access/policies"),
|
||||
|
||||
@@ -23,6 +23,7 @@ export type LevelKind = Exclude<StatusKind, "ok">;
|
||||
|
||||
/** One entry as internal/logging serialises it. */
|
||||
export interface LogEntry {
|
||||
id?: number;
|
||||
time: string | number | Date;
|
||||
level?: string | null;
|
||||
message?: string;
|
||||
|
||||
@@ -69,6 +69,7 @@ const settings: NavSpec = {
|
||||
"/settings/tools",
|
||||
"/settings/extensions",
|
||||
"/settings/plugins",
|
||||
"/settings/secret-engines",
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -21,6 +21,7 @@ import SoulPage from "@/settings/SoulPage.vue";
|
||||
import SchedulesPage from "@/settings/SchedulesPage.vue";
|
||||
import ExtensionsPage from "@/settings/ExtensionsPage.vue";
|
||||
import PluginsPage from "@/settings/PluginsPage.vue";
|
||||
import SecretEnginesPage from "@/settings/SecretEnginesPage.vue";
|
||||
import ContainerRuntimePage from "@/settings/ContainerRuntimePage.vue";
|
||||
import SystemAppearancePage from "@/settings/SystemAppearancePage.vue";
|
||||
import SystemModelsPage from "@/settings/SystemModelsPage.vue";
|
||||
@@ -338,6 +339,12 @@ const routes = [
|
||||
section: "settings",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/settings/secret-engines",
|
||||
name: "settings-secret-engines",
|
||||
component: SecretEnginesPage,
|
||||
meta: { navPath: "/settings", settings: true, label: "Secret engines", description: "Available secret engines.", section: "settings" },
|
||||
},
|
||||
{
|
||||
path: "/settings/container-runtime",
|
||||
name: "settings-container-runtime",
|
||||
|
||||
@@ -63,13 +63,13 @@ const pullPolicy = computed({
|
||||
<p v-if="catalogError || error" class="mb-4 text-sm text-danger" role="alert">{{ catalogError || error }}</p>
|
||||
|
||||
<template v-if="runtime">
|
||||
<SettingRow label="Image" for="cr-image">
|
||||
<SettingRow label="Image" for="cr-image" hint="Container image used for agent runs.">
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<Input id="cr-image" v-model="runtime.image" class="font-mono" />
|
||||
<DraftHint :kind="KIND" path="image" />
|
||||
</div>
|
||||
</SettingRow>
|
||||
<SettingRow label="Pull policy">
|
||||
<SettingRow label="Pull policy" hint="When to refresh the agent image.">
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<ToggleGroup type="single" variant="outline" size="sm" :model-value="pullPolicy" aria-label="Pull policy" @update:model-value="(value) => { if (value) pullPolicy = value as typeof pullPolicy; }">
|
||||
<ToggleGroupItem v-for="option in pullPolicies" :key="option.value" :value="option.value">{{ option.label }}</ToggleGroupItem>
|
||||
@@ -89,13 +89,13 @@ const pullPolicy = computed({
|
||||
<DraftHint :kind="KIND" path="max_concurrency" />
|
||||
</div>
|
||||
</SettingRow>
|
||||
<SettingRow label="Max uptime" for="cr-uptime">
|
||||
<SettingRow label="Max uptime" for="cr-uptime" hint="Maximum time an agent container may run.">
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<DurationInput id="cr-uptime" v-model="runtime.max_uptime" :units="['m', 'h']" />
|
||||
<DraftHint :kind="KIND" path="max_uptime" />
|
||||
</div>
|
||||
</SettingRow>
|
||||
<SettingRow label="Volume retention" for="cr-ttl">
|
||||
<SettingRow label="Volume retention" for="cr-ttl" hint="How long to retain volumes after a run.">
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<DurationInput id="cr-ttl" v-model="runtime.volume_ttl" :units="['h']" />
|
||||
<DraftHint :kind="KIND" path="volume_ttl" />
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from "vue";
|
||||
import { useIntervalFn } from "@vueuse/core";
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||||
import { useSecretEnginesStore } from "@/stores/secret-engines";
|
||||
|
||||
const store = useSecretEnginesStore();
|
||||
onMounted(store.load);
|
||||
useIntervalFn(store.load, 15_000);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<PageHeader title="Secret engines">
|
||||
<Button variant="outline" size="sm" @click="store.load">Refresh</Button>
|
||||
</PageHeader>
|
||||
<p class="mb-4 text-sm text-fg-muted">Engines registered by archied. Manage extension engines under <RouterLink to="/settings/extensions" class="underline">Extensions</RouterLink>.</p>
|
||||
<p v-if="store.error" class="text-sm text-danger" role="alert">{{ store.error }}</p>
|
||||
<Table v-else-if="store.engines">
|
||||
<TableHeader><TableRow><TableHead>Engine</TableHead><TableHead>Version</TableHead><TableHead>Source</TableHead></TableRow></TableHeader>
|
||||
<TableBody><TableRow v-for="engine in store.engines" :key="engine.name"><TableCell class="font-mono">{{ engine.name }}</TableCell><TableCell class="font-mono">{{ engine.version || '—' }}</TableCell><TableCell>{{ engine.source }}</TableCell></TableRow></TableBody>
|
||||
</Table>
|
||||
<p v-else class="text-sm text-fg-subtle" role="status">Loading engine report…</p>
|
||||
</template>
|
||||
@@ -1,9 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { useIntervalFn } from "@vueuse/core";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { SecretReference } from "@/components/ui/secret-reference";
|
||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { api } from "@/lib/api";
|
||||
import { useSecretEnginesStore } from "@/stores/secret-engines";
|
||||
|
||||
/** Where a secret lives. Archie resolves it; the value never reaches the UI. */
|
||||
interface SecretRef {
|
||||
@@ -21,6 +25,26 @@ withDefaults(
|
||||
);
|
||||
const model = defineModel<SecretRef>({ required: true });
|
||||
const editing = ref(false);
|
||||
const engines = useSecretEnginesStore();
|
||||
const missing = computed(() => !!engines.engines && !!model.value.engine && !engines.engines.some((engine) => engine.name === model.value.engine));
|
||||
watch(editing, (open) => { if (open) void engines.load(); });
|
||||
useIntervalFn(() => { if (editing.value) void engines.load(); }, 15_000);
|
||||
const checked = ref<boolean>();
|
||||
const checking = ref(false);
|
||||
const checkError = ref("");
|
||||
watch(() => `${model.value.engine}\n${model.value.key}`, () => { checked.value = undefined; checkError.value = ""; });
|
||||
async function check() {
|
||||
const ref = { ...model.value };
|
||||
checking.value = true;
|
||||
checked.value = undefined;
|
||||
checkError.value = "";
|
||||
try {
|
||||
const result = await api.checkSecret(ref);
|
||||
if (ref.engine === model.value.engine && ref.key === model.value.key) checked.value = result.resolved;
|
||||
} catch (cause) {
|
||||
if (ref.engine === model.value.engine && ref.key === model.value.key) checkError.value = String((cause as Error).message || cause);
|
||||
} finally { checking.value = false; }
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -39,11 +63,24 @@ const editing = ref(false);
|
||||
</div>
|
||||
<div v-else class="flex flex-wrap items-end gap-2">
|
||||
<label class="grid gap-1 text-xs text-fg-subtle">Engine
|
||||
<Input :id="`${idPrefix}-engine`" v-model="model.engine" class="w-28 font-mono" />
|
||||
<Select v-model="model.engine" :disabled="disabled">
|
||||
<SelectTrigger :id="`${idPrefix}-engine`" class="font-mono"><SelectValue placeholder="Choose engine" /></SelectTrigger>
|
||||
<SelectContent><SelectGroup>
|
||||
<SelectItem v-for="engine in engines.engines ?? []" :key="engine.name" :value="engine.name">{{ engine.name }}</SelectItem>
|
||||
<SelectItem v-if="model.engine && (missing || engines.engines === null)" :value="model.engine">{{ model.engine }}{{ missing ? ' · not installed' : '' }}</SelectItem>
|
||||
</SelectGroup></SelectContent>
|
||||
</Select>
|
||||
</label>
|
||||
<label class="grid min-w-48 flex-1 gap-1 text-xs text-fg-subtle">Key
|
||||
<Input :id="`${idPrefix}-key`" v-model="model.key" class="font-mono" />
|
||||
<Input :id="`${idPrefix}-key`" v-model="model.key" class="font-mono" :disabled="disabled" />
|
||||
</label>
|
||||
<Button variant="ghost" size="sm" @click="editing = false">Done</Button>
|
||||
</div>
|
||||
<p v-if="editing && engines.error" class="mt-1 text-xs text-danger" role="alert">{{ engines.error }}</p>
|
||||
<div v-if="model.engine && model.key" class="mt-1 flex flex-wrap items-center gap-2 text-xs">
|
||||
<Button variant="ghost" size="sm" :disabled="disabled || checking" @click="check">Check reference</Button>
|
||||
<span v-if="checking" role="status">Checking…</span>
|
||||
<span v-else-if="checked !== undefined" role="status">{{ checked ? 'Resolved by archie-gateway' : 'Not resolved by archie-gateway' }}</span>
|
||||
<span v-if="checkError" class="text-danger" role="alert">{{ checkError }}</span>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
import { api } from "@/lib/api";
|
||||
|
||||
export interface SecretEngine { name: string; version?: string; source: string }
|
||||
|
||||
export const useSecretEnginesStore = defineStore("secret-engines", () => {
|
||||
const engines = ref<SecretEngine[] | null>(null);
|
||||
const error = ref("");
|
||||
async function load() {
|
||||
try {
|
||||
engines.value = (await api.secretEngines<{ engines: SecretEngine[] }>()).engines;
|
||||
error.value = "";
|
||||
} catch (cause) {
|
||||
engines.value = null;
|
||||
error.value = String((cause as Error).message || cause);
|
||||
}
|
||||
}
|
||||
return { engines, error, load };
|
||||
});
|
||||
@@ -7,7 +7,7 @@ import { api } from "../lib/api.ts";
|
||||
|
||||
export interface Summary {
|
||||
statuses?: Record<string, number>;
|
||||
tokens_by_day?: Array<{ tokens?: number }>;
|
||||
tokens_by_day?: Array<{ day: string; tokens?: number }>;
|
||||
}
|
||||
|
||||
export interface WorkflowStat {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { Plus } from "@lucide/vue";
|
||||
|
||||
@@ -14,7 +13,7 @@ import {
|
||||
import NewTaskForm from "./NewTaskForm.vue";
|
||||
|
||||
const router = useRouter();
|
||||
const open = ref(false);
|
||||
const open = defineModel<boolean>("open", { default: false });
|
||||
|
||||
function started(taskId: number) {
|
||||
open.value = false;
|
||||
|
||||
+60
-12
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import { computed, nextTick, ref, watch } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { ArrowUpRight, CircleAlert } from "@lucide/vue";
|
||||
|
||||
import {
|
||||
@@ -11,7 +12,12 @@ import {
|
||||
BreadcrumbSeparator,
|
||||
} from "@/components/ui/breadcrumb";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { api } from "@/lib/api";
|
||||
import { runQuery, type LogState } from "./task-run";
|
||||
import { statusKind, statusLabel } from "@/lib/task-meta";
|
||||
import { cn } from "@/lib/utils";
|
||||
import DispatchLinks from "@/bindings/DispatchLinks.vue";
|
||||
import StartNewRun from "./StartNewRun.vue";
|
||||
import TaskRowActions from "./TaskRowActions.vue";
|
||||
@@ -28,7 +34,45 @@ const run = useTaskRun();
|
||||
|
||||
const title = computed(() => run.task?.title || `Task #${props.id}`);
|
||||
const status = computed(() => run.task?.status ?? "");
|
||||
const parked = computed(() => status.value === "parked" && !!run.task?.park_reason);
|
||||
const router = useRouter();
|
||||
const attempt = computed(() => run.attempts?.attempts?.find((a) => a.attempt === run.attemptNumber));
|
||||
const failure = computed(() => {
|
||||
const stage = attempt.value?.stages?.find((s) => s.error);
|
||||
const current = run.attemptNumber === run.currentAttempt;
|
||||
if (current && status.value === "parked") return { title: "Parked: this run needs your attention", detail: run.task?.park_reason || stage?.error || "", parked: true };
|
||||
if (attempt.value?.status === "failed" || (current && status.value === "dead")) return { title: `Attempt ${run.attemptNumber} failed${stage?.name ? ` during ${stage.name}` : ""}`, detail: stage?.error || run.task?.park_reason || "", parked: false };
|
||||
return null;
|
||||
});
|
||||
const jumping = ref(false);
|
||||
const jumpError = ref("");
|
||||
watch(() => run.attemptNumber, () => { jumpError.value = ""; });
|
||||
|
||||
async function jumpToLog(): Promise<void> {
|
||||
const selected = run.attemptNumber;
|
||||
if (selected == null) return;
|
||||
jumping.value = true;
|
||||
jumpError.value = "";
|
||||
try {
|
||||
const logs = await api.taskLogs<LogState>(props.id, { attempt: selected, level: "ERROR", limit: 1 });
|
||||
if (selected !== run.attemptNumber) return;
|
||||
const entry = logs.entries?.[0];
|
||||
if (!entry?.id) {
|
||||
jumpError.value = "No error log line was recorded for this attempt.";
|
||||
return;
|
||||
}
|
||||
run.setFilters({ level: "ERROR", stage: "" });
|
||||
run.setTab("log");
|
||||
await nextTick();
|
||||
await router.replace({ query: runQuery("log", selected), hash: `#log-line-${entry.id}` });
|
||||
const line = document.querySelector<HTMLElement>(`[data-log-id="${entry.id}"]`);
|
||||
line?.scrollIntoView({ block: "center" });
|
||||
line?.focus({ preventScroll: true });
|
||||
} catch {
|
||||
if (selected === run.attemptNumber) jumpError.value = "Could not read this attempt’s error log.";
|
||||
} finally {
|
||||
jumping.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// The head has room for one control: the reap an operator reaches for once a
|
||||
// task is finished with. Whether this task offers it at all is the server's
|
||||
@@ -112,16 +156,20 @@ const headerActions = computed(() =>
|
||||
</template>
|
||||
</dl>
|
||||
|
||||
<div
|
||||
v-if="parked"
|
||||
role="status"
|
||||
class="mt-4 flex items-start gap-3 rounded-md border border-warn/40 bg-warn-soft px-4 py-3"
|
||||
<Alert
|
||||
v-if="failure"
|
||||
:variant="failure.parked ? 'default' : 'destructive'"
|
||||
:class="cn('mt-4', failure.parked && 'border-warn/40 bg-warn-soft')"
|
||||
>
|
||||
<CircleAlert class="mt-0.5 size-4 shrink-0 text-warn" aria-hidden="true" />
|
||||
<div class="min-w-0">
|
||||
<p class="text-sm font-medium text-warn">Parked</p>
|
||||
<p class="mt-0.5 font-mono text-xs break-words text-fg-muted">{{ run.task?.park_reason }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<CircleAlert aria-hidden="true" />
|
||||
<AlertTitle class="flex flex-wrap items-center justify-between gap-2">
|
||||
<span>{{ failure.title }}</span>
|
||||
<Button variant="ghost" size="sm" :disabled="jumping || run.attemptNumber == null" @click="jumpToLog">Jump to log line</Button>
|
||||
</AlertTitle>
|
||||
<AlertDescription>
|
||||
<p v-if="failure.detail" class="mt-0.5 font-mono text-xs break-words text-fg-muted">{{ failure.detail }}</p>
|
||||
<p v-if="jumpError" class="mt-1 text-xs" role="alert">{{ jumpError }}</p>
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { computed, nextTick, ref, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import LogRow from "@/base/LogRow.vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -121,6 +122,7 @@ async function loadOlder(): Promise<void> {
|
||||
if (!shown?.more_available || before <= 0) return;
|
||||
const older = await fetchPage(before);
|
||||
if (!older) return;
|
||||
await router.replace({ hash: "" });
|
||||
newerPages.value.push({ before: page.value?.before ?? 0, state: shown });
|
||||
page.value = { before, state: older };
|
||||
}
|
||||
@@ -183,6 +185,22 @@ const download = computed(() =>
|
||||
)
|
||||
: null,
|
||||
);
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const logFrame = ref<HTMLElement>();
|
||||
let focusedHash = "";
|
||||
watch([() => route.hash, current], async () => {
|
||||
const match = /^#log-line-(\d+)$/.exec(route.hash);
|
||||
if (!match) { focusedHash = ""; return; }
|
||||
if (focusedHash === route.hash) return;
|
||||
if (page.value) { page.value = null; newerPages.value = []; }
|
||||
await nextTick();
|
||||
const line = logFrame.value?.querySelector<HTMLElement>(`[data-log-id="${match[1]}"]`);
|
||||
if (!line) return;
|
||||
focusedHash = route.hash;
|
||||
line?.scrollIntoView({ block: "center" });
|
||||
line?.focus({ preventScroll: true });
|
||||
}, { immediate: true, flush: "post" });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -242,9 +260,10 @@ const download = computed(() =>
|
||||
<!-- The detail page's log is the primary content, so it takes a framed
|
||||
read surface of its own and the tallest one on the page. -->
|
||||
<div
|
||||
ref="logFrame"
|
||||
class="max-h-[62vh] overflow-y-auto rounded-sm border border-border bg-card px-2"
|
||||
>
|
||||
<LogRow v-for="(entry, i) in view.entries" :key="i" :entry="entry" />
|
||||
<LogRow v-for="(entry, i) in view.entries" :key="entry.id ?? i" :entry="entry" :data-log-id="entry.id" tabindex="-1" />
|
||||
</div>
|
||||
<!-- Below the frame, not inside it: the log scrolls, and where an attempt
|
||||
ended is the one line that must stay put while it does. -->
|
||||
|
||||
Reference in new issue
Block a user