Files
archie/ui/src/settings/SystemTasksPage.vue
T
sam c6f70de82d
Quality / check (push) Successful in 7m32s
deploy / gate (push) Successful in 4m59s
deploy / archied-image (push) Successful in 3m27s
deploy / agent-image (push) Successful in 11s
deploy / dist-zip (push) Skipped
fix(ui): settings pages show a skeleton or the error until their draft loads (#1743)
New settings/KindGate renders the store's per-kind loading/error state
where the form would be: a skeleton while loading, ReadError with Retry
on a failed read. Wired into Tools, SystemModels, SystemRepos,
SchedulingPolicy, ContainerRuntime, OrgAlerts, Instructions, Plugins,
SystemTasks, UpdateSettings, IdentityGrants, OrgModels, Channels and
Authentication pages, which no longer render blank until the draft
exists.
2026-11-07 00:42:28 +11:00

199 lines
8.3 KiB
Vue

<script setup lang="ts">
import { Alert, AlertDescription } from "@/components/ui/alert";
import ApplyStatusRows from "./ApplyStatusRows.vue";
import KindGate from "./KindGate.vue";
import { computed, onMounted, ref } from "vue";
import { RotateCcw } from "@lucide/vue";
import { storeToRefs } from "pinia";
import { Button } from "@/components/ui/button";
import PageHeader from "@/base/PageHeader.vue";
import { DurationInput, formatGoDuration, parseGoDuration } from "@/components/ui/duration-input";
import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel } from "@/components/ui/field";
import {
NumberField,
NumberFieldContent,
NumberFieldDecrement,
NumberFieldIncrement,
NumberFieldInput,
} from "@/components/ui/number-field";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { cloneControlPlaneValue, resourcesForPage, useSettingsStore } from "@/stores/settings";
import { restoreShippedDefinitions, useWorkflowsStore } from "@/stores/workflows";
import DraftHint from "./DraftHint.vue";
import HistoryLink from "./HistoryLink.vue";
const KIND = "workflow-execution-settings";
interface ExecutionSettings {
max_model_tool_steps: number;
max_runtime_seconds: number;
max_consecutive_gate_failures: number;
max_task_runtime_seconds: number | null;
}
const store = useSettingsStore();
const { catalog, catalogError } = storeToRefs(store);
onMounted(store.load);
const resources = computed(() => resourcesForPage(catalog.value, "tasks"));
const limitsForm = computed(() => store.formFor(KIND));
const limits = computed(() => store.draftValue(KIND) as ExecutionSettings | undefined);
const error = computed(() => store.pageErrorFor(KIND));
// The document counts seconds; the input speaks durations.
function durationText(seconds: number | null | undefined): string {
return formatGoDuration((seconds ?? 0) * 1000);
}
// Undefined for text that is not a duration, so the draft keeps its last value.
const durationErrors = ref<Record<string, string>>({});
function commitDuration(field: { handleChange: (value: number) => void }, id: string, text: string): void {
const seconds = durationSeconds(text);
if (seconds === undefined) {
durationErrors.value = { ...durationErrors.value, [id]: "Enter a duration like 30m or 2h." };
return;
}
const next = { ...durationErrors.value };
delete next[id];
durationErrors.value = next;
field.handleChange(seconds);
}
function durationSeconds(text: string): number | undefined {
const ms = parseGoDuration(text);
return ms === null ? undefined : Math.round(ms / 1000);
}
const workflows = useWorkflowsStore();
const confirmRestore = ref(false);
async function restoreWorkflows(): Promise<void> {
await workflows.save(cloneControlPlaneValue(restoreShippedDefinitions(workflows.collection, workflows.shipped)));
}
</script>
<template>
<div>
<PageHeader title="Task execution">
<HistoryLink :kinds="resources.map((r) => r.kind)" />
</PageHeader>
<ApplyStatusRows v-for="resource in resources" :key="resource.kind" :kind="resource.kind" class="mb-4" />
<Alert v-if="catalogError || error" variant="destructive" class="mb-4"><AlertDescription>
{{ catalogError || error }}
</AlertDescription></Alert>
<KindGate v-if="!limitsForm" :kind="KIND" />
<FieldGroup v-if="limitsForm && limits" class="@container/field-group">
<limitsForm.Field v-slot="{ field }" name="max_task_runtime_seconds">
<Field orientation="responsive">
<FieldContent>
<FieldLabel for="te-task">Task time limit</FieldLabel>
<FieldDescription>Parked after this. 0 disables.</FieldDescription>
</FieldContent>
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
<DurationInput
id="te-task"
:model-value="durationText(field.state.value)"
:units="['m', 'h']"
@update:model-value="(text: string) => commitDuration(field, 'te-task', text)"
/>
<p v-if="durationErrors['te-task']" class="text-caption text-danger" role="alert">{{ durationErrors['te-task'] }}</p>
<DraftHint :kind="KIND" path="max_task_runtime_seconds" />
</div>
</Field>
</limitsForm.Field>
<limitsForm.Field v-slot="{ field }" name="max_runtime_seconds">
<Field orientation="responsive">
<FieldContent>
<FieldLabel for="te-call">Agent call time limit</FieldLabel>
<FieldDescription>0 disables.</FieldDescription>
</FieldContent>
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
<DurationInput
id="te-call"
:model-value="durationText(field.state.value)"
:units="['s', 'm', 'h']"
@update:model-value="(text: string) => commitDuration(field, 'te-call', text)"
/>
<p v-if="durationErrors['te-call']" class="text-caption text-danger" role="alert">{{ durationErrors['te-call'] }}</p>
<DraftHint :kind="KIND" path="max_runtime_seconds" />
</div>
</Field>
</limitsForm.Field>
<limitsForm.Field v-slot="{ field }" name="max_model_tool_steps">
<Field orientation="responsive">
<FieldContent>
<FieldLabel>Model tool steps</FieldLabel>
<FieldDescription>Per agent call. 0 disables.</FieldDescription>
</FieldContent>
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
<NumberField :model-value="field.state.value" :min="0" class="w-32" @update:model-value="field.handleChange">
<NumberFieldContent>
<NumberFieldDecrement />
<NumberFieldInput class="font-mono" aria-label="Model tool steps" />
<NumberFieldIncrement />
</NumberFieldContent>
</NumberField>
<DraftHint :kind="KIND" path="max_model_tool_steps" />
</div>
</Field>
</limitsForm.Field>
<limitsForm.Field v-slot="{ field }" name="max_consecutive_gate_failures">
<Field orientation="responsive">
<FieldContent>
<FieldLabel>Gate failures in a row</FieldLabel>
<FieldDescription>Then parked.</FieldDescription>
</FieldContent>
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
<NumberField :model-value="field.state.value" :min="0" class="w-32" @update:model-value="field.handleChange">
<NumberFieldContent>
<NumberFieldDecrement />
<NumberFieldInput class="font-mono" aria-label="Gate failures in a row" />
<NumberFieldIncrement />
</NumberFieldContent>
</NumberField>
<DraftHint :kind="KIND" path="max_consecutive_gate_failures" />
</div>
</Field>
</limitsForm.Field>
</FieldGroup>
<FieldGroup v-if="workflows.shipped.definitions.length" class="@container/field-group">
<Field orientation="responsive">
<FieldContent>
<FieldLabel>Workflows</FieldLabel>
<FieldDescription>Resets every shipped workflow. Custom workflows are kept.</FieldDescription>
</FieldContent>
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
<Button variant="outline" size="sm" :disabled="workflows.state.saving" @click="confirmRestore = true"><RotateCcw data-icon="inline-start" />Restore default</Button>
</div>
</Field>
</FieldGroup>
<AlertDialog v-model:open="confirmRestore">
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Restore default workflows?</AlertDialogTitle>
<AlertDialogDescription>Edits to shipped workflows are discarded.</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction @click="restoreWorkflows">Restore</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
<Alert v-if="workflows.state.error" variant="destructive"><AlertDescription>{{ workflows.state.error }}</AlertDescription></Alert>
</div>
</template>