feat(eda): pause and resume a binding; resuming goes back through approval

This commit is contained in:
sam committed 2026-10-05 20:44:25 +11:00
1 parent 3ec0cc9b10
commit 0788f5ab8a
24 files changed
+1032 -542

No files matched your search

+23 -1
View File
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { computed } from "vue";
import { Check, Pencil, Trash2 } from "@lucide/vue";
import { Check, Pause, Pencil, Play, Trash2 } from "@lucide/vue";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
@@ -29,6 +29,8 @@ const failing = computed(() => {
const emit = defineEmits<{
edit: [binding: Binding];
approve: [binding: Binding];
pause: [binding: Binding];
resume: [binding: Binding];
delete: [binding: Binding];
}>();
</script>
@@ -90,6 +92,26 @@ const emit = defineEmits<{
<Check data-icon="inline-start" />
Approve
</Button>
<Button
v-if="props.binding.status === 'armed'"
variant="outline"
size="sm"
@click="emit('pause', props.binding)"
>
<Pause data-icon="inline-start" />
Pause
</Button>
<!-- Resuming returns the binding to pending approval, so it is
approved again before it fires. -->
<Button
v-if="props.binding.status === 'paused'"
variant="outline"
size="sm"
@click="emit('resume', props.binding)"
>
<Play data-icon="inline-start" />
Resume
</Button>
<Button
variant="outline"
size="sm"
+1 -1
View File
@@ -2,7 +2,7 @@
import { Badge } from "@/components/ui/badge";
import { statusKind, statusLabel } from "./binding-draft";
/** A binding's lifecycle state: pending approval or armed. The
/** A binding's lifecycle state: pending approval, armed or paused. The
* colour ramp is shared with every other status in the dashboard, so the
* same colour means the same thing here as it does on a task. */
const props = defineProps<{ status?: string }>();
+4
View File
@@ -34,6 +34,8 @@ const {
resetSaveFailure,
save,
approve,
pause,
resume,
remove,
} = useBindings();
@@ -96,6 +98,8 @@ async function handleDelete(binding: Binding): Promise<void> {
:failure="failure"
@edit="startEdit"
@approve="approve"
@pause="pause"
@resume="resume"
@delete="deleting = $event"
/>
+4
View File
@@ -32,6 +32,8 @@ const props = defineProps<{
const emit = defineEmits<{
edit: [binding: Binding];
approve: [binding: Binding];
pause: [binding: Binding];
resume: [binding: Binding];
delete: [binding: Binding];
}>();
@@ -98,6 +100,8 @@ const failureTitle = computed(() =>
:event-types="props.eventTypes"
@edit="emit('edit', $event)"
@approve="emit('approve', $event)"
@pause="emit('pause', $event)"
@resume="emit('resume', $event)"
@delete="emit('delete', $event)"
/>
</template>
+2
View File
@@ -128,11 +128,13 @@ export type StatusKind = "ok" | "warn" | "idle";
const STATUS_LABELS: Record<string, string> = {
pending_approval: "pending approval",
armed: "armed",
paused: "paused",
};
const STATUS_KINDS: Record<string, StatusKind> = {
pending_approval: "warn",
armed: "ok",
paused: "idle",
};
/** A status the daemon grows later renders as itself in the neutral kind,
+7 -2
View File
@@ -99,15 +99,18 @@ export function useBindings() {
}
}
async function approve(binding: Binding): Promise<void> {
async function transition(command: (id: string) => Promise<unknown>, binding: Binding): Promise<void> {
actionFailure.value = null;
try {
await api.bindingApprove(String(binding.id));
await command(String(binding.id));
await load();
} catch (err) {
actionFailure.value = failureFor(err);
}
}
const approve = (binding: Binding) => transition(api.bindingApprove, binding);
const pause = (binding: Binding) => transition(api.bindingPause, binding);
const resume = (binding: Binding) => transition(api.bindingResume, binding);
async function remove(binding: Binding): Promise<void> {
actionFailure.value = null;
@@ -132,6 +135,8 @@ export function useBindings() {
resetSaveFailure,
save,
approve,
pause,
resume,
remove,
};
}
+6
View File
@@ -283,6 +283,12 @@ export const api = {
request<T>(`/api/bindings/${encodeURIComponent(id)}/approve`, {
method: "POST",
}),
// bindingPause stops an armed binding; bindingResume returns it to pending
// approval.
bindingPause: <T = unknown>(id: string) =>
request<T>(`/api/bindings/${encodeURIComponent(id)}/pause`, { method: "POST" }),
bindingResume: <T = unknown>(id: string) =>
request<T>(`/api/bindings/${encodeURIComponent(id)}/resume`, { method: "POST" }),
harnessBindings: <T = unknown>() => request<T>("/api/harness/bindings"),
sources: <T = unknown>() => request<T>("/api/sources"),
sourceCreate: <T = unknown>(path: string) =>
+9 -3
View File
@@ -204,17 +204,21 @@ async function save(): Promise<void> {
}
}
async function approve(): Promise<void> {
// transition runs one lifecycle command and shows the status it leads to.
async function transition(command: (id: string) => Promise<unknown>, next: string): Promise<void> {
if (!props.binding) return;
error.value = "";
try {
await api.bindingApprove(props.binding.id);
status.value = "armed";
await command(props.binding.id);
status.value = next;
emit("saved");
} catch (err) {
error.value = err instanceof Error ? err.message : String(err);
}
}
const approve = () => transition(api.bindingApprove, "armed");
const pause = () => transition(api.bindingPause, "paused");
const resume = () => transition(api.bindingResume, "pending_approval");
</script>
<template>
@@ -313,6 +317,8 @@ async function approve(): Promise<void> {
<div class="flex gap-2">
<Button type="submit" size="sm" :disabled="saving || !!blockers.length"><Spinner v-if="saving" />Save binding</Button>
<Button v-if="binding && status === 'pending_approval'" type="button" size="sm" variant="outline" @click="approve">Approve</Button>
<Button v-if="binding && status === 'armed'" type="button" size="sm" variant="outline" @click="pause">Pause</Button>
<Button v-if="binding && status === 'paused'" type="button" size="sm" variant="outline" @click="resume">Resume</Button>
</div>
</div>
</form>