fix(webui): stop empty states re-deriving their own titles

A title that states the fact does not need a description that derives it:
the log, panels, lifecycle lists, dashboard cards, stages, skills and
captures empty states now say the fact once, and keep only the
descriptions that carry an action, a cause, or a distinct reading.
This commit is contained in:
sam committed 2026-09-21 00:56:24 +10:00
1 parent 578c0f5a2d
commit 050f833a23
43 files changed
+239 -315

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
export type LiveResource = "tasks" | "captures" | "curators" | "skills" | "updates";
export interface LiveEvent {
id?: number;
kind?: string;
type?: string;
task_id?: number | string;
repo?: string;
issue?: number | string;
at?: string | number;
detail?: string;
data?: Record<string, unknown>;
}
const taskKinds = new Set([
"stage_start",
"stage_finish",
"agent_finish",
"tool_call",
"parked",
"outcome",
"pr_merged",
"pr_rejected",
"human_approved",
"human_rejected",
"changes_captured",
"config_captured",
"work_request_submitted",
]);
/** Map a durable backend event to the read projections it invalidates. */
export function resourcesForEvent(raw: unknown): LiveResource[] {
const event = raw as LiveEvent | null;
const kind = event?.kind ?? "";
const resources = new Set<LiveResource>();
if (event?.task_id || kind.startsWith("task_") || taskKinds.has(kind)) resources.add("tasks");
if (kind === "capture") resources.add("captures");
if (kind.startsWith("curator_")) resources.add("curators");
if (kind === "curator_action") resources.add("skills");
if (kind === "update_report") resources.add("updates");
return [...resources];
}
+72
View File
@@ -0,0 +1,72 @@
import { defineStore } from "pinia";
import { computed, onUnmounted, reactive, ref, watch, type ComputedRef } from "vue";
import { setAuthenticationStateHandler, subscribeEvents } from "@/lib/api";
import type { StatusKind } from "@/lib/status";
import type { StreamState } from "@/lib/stream-state";
import { resourcesForEvent, type LiveEvent, type LiveResource } from "./live-events";
export const useLiveUpdatesStore = defineStore("live-updates", () => {
const streamState = ref<StreamState | "connecting">("connecting");
const connectionRevision = ref(0);
const authenticationRequired = ref(false);
const activity = ref<LiveEvent[]>([]);
const revisions = reactive<Record<LiveResource, number>>({
tasks: 0,
captures: 0,
curators: 0,
skills: 0,
updates: 0,
});
let unsubscribe: (() => void) | undefined;
const streamKind: ComputedRef<StatusKind> = computed(() => {
if (streamState.value === "live") return "ok";
return streamState.value === "unavailable" ? "danger" : "warn";
});
function receive(raw: unknown): void {
const event = raw as LiveEvent;
activity.value = [event, ...activity.value].slice(0, 50);
for (const resource of resourcesForEvent(event)) revisions[resource] += 1;
}
function initialize(): void {
if (unsubscribe) return;
setAuthenticationStateHandler((required) => {
authenticationRequired.value = required;
});
unsubscribe = subscribeEvents(receive, (state) => {
streamState.value = state;
if (state === "live") connectionRevision.value += 1;
});
}
return {
activity,
authenticationRequired,
connectionRevision,
revisions,
streamKind,
streamState,
initialize,
receive,
};
});
/** Re-read one mounted projection when SSE says its backend resource changed. */
export function useLiveResource(resource: LiveResource | null, load: () => void, debounceMs = 100): void {
const live = useLiveUpdatesStore();
let timer: ReturnType<typeof setTimeout> | undefined;
const revision = () => resource === null
? live.connectionRevision
: [live.revisions[resource], live.connectionRevision];
const stop = watch(revision, () => {
clearTimeout(timer);
timer = setTimeout(load, debounceMs);
});
onUnmounted(() => {
clearTimeout(timer);
stop();
});
}