feat(ui): start tasks from the dashboard and slim it to activity and setup

This commit is contained in:
sam committed 2026-10-14 23:28:37 +11:00
1 parent c1554d63c0
commit 88ef6ca5b2
23 files changed
+297 -487

No files matched your search

+3 -33
View File
@@ -1,46 +1,16 @@
<script setup lang="ts">
import { computed, onMounted, ref, watch } from "vue";
import { storeToRefs } from "pinia";
import { computed, ref } from "vue";
import { Bell } from "@lucide/vue";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { api } from "@/lib/api";
import { useSessionStore } from "@/stores/session";
import { groupBySeverity, type AlertSeverity, type OperatorAlert } from "./alerts";
import { useAlerts } from "./use-alerts";
const alerts = ref<OperatorAlert[]>([]);
const failed = ref(false);
const { alerts, failed, dismiss } = useAlerts();
const open = ref(false);
async function load() {
try {
alerts.value = (await api.alerts<{ alerts: OperatorAlert[] }>()).alerts;
failed.value = false;
} catch {
failed.value = true;
}
}
async function dismiss(alert: OperatorAlert) {
alerts.value = alerts.value.filter((a) => a.id !== alert.id);
try {
await api.dismissAlert(alert.id);
} catch {
await load();
}
}
// The bell follows the event stream: the store records every alert change as
// an event, so the newest alert event's id moving means the list moved. A
// reconnect re-reads, since events may have been missed while it was down.
const live = useSessionStore();
const { activity, connectionRevision } = storeToRefs(live);
watch(() => activity.value.find((event) => event.kind === "alert")?.id, load);
watch(connectionRevision, load);
onMounted(load);
const groups = computed(() => groupBySeverity(alerts.value));
const tone: Record<AlertSeverity, "danger" | "warn" | "info"> = { action: "danger", warning: "warn", info: "info" };
const label = computed(() =>
+41
View File
@@ -0,0 +1,41 @@
import { storeToRefs } from "pinia";
import { onMounted, ref, watch } from "vue";
import { api } from "@/lib/api";
import { useSessionStore } from "@/stores/session";
import type { OperatorAlert } from "./alerts";
/**
* The open alerts, following the event stream: the store records every alert
* change as an event, so the newest alert event's id moving means the list
* moved. A reconnect re-reads, since events may have been missed.
*/
export function useAlerts() {
const alerts = ref<OperatorAlert[]>([]);
const failed = ref(false);
async function load() {
try {
alerts.value = (await api.alerts<{ alerts: OperatorAlert[] }>()).alerts;
failed.value = false;
} catch {
failed.value = true;
}
}
async function dismiss(alert: OperatorAlert) {
alerts.value = alerts.value.filter((a) => a.id !== alert.id);
try {
await api.dismissAlert(alert.id);
} catch {
await load();
}
}
const { activity, connectionRevision } = storeToRefs(useSessionStore());
watch(() => activity.value.find((event) => event.kind === "alert")?.id, load);
watch(connectionRevision, load);
onMounted(load);
return { alerts, failed, dismiss };
}