fix(ui): distinguish loading, failed and empty lists, one role label set, en dash for no value

This commit is contained in:
sam committed 2026-10-18 15:54:31 +11:00
1 parent 5fdac53ca5
commit c67d475a92
16 files changed
+95 -46

No files matched your search

+4 -1
View File
@@ -4,7 +4,10 @@ import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { api } from "@/lib/api";
import { ROLE_LABELS, ROLES } from "@/org/org";
const emit=defineEmits<{created:[]}>();
// Owner is granted from the member table, not when creating an account.
const assignable = ROLES.filter((role) => role !== "owner");
const name=ref("");const email=ref("");const password=ref("");const role=ref("viewer");const busy=ref(false);const error=ref("");
async function create(){busy.value=true;error.value="";try{await api.createAccount({display_name:name.value,email:email.value,password:password.value,role:role.value});name.value=email.value=password.value="";emit("created")}catch(cause){error.value=String((cause as Error).message||cause)}finally{busy.value=false}}
</script>
@@ -15,7 +18,7 @@ async function create(){busy.value=true;error.value="";try{await api.createAccou
<label for="new-account-name" class="block space-y-1 text-sm">Name<Input id="new-account-name" v-model="name" required maxlength="200" autocomplete="off" /></label>
<label for="new-account-email" class="block space-y-1 text-sm">Email<Input id="new-account-email" v-model="email" type="email" required autocomplete="off" :spellcheck="false" /></label>
<label for="new-account-password" class="block space-y-1 text-sm">Initial password<Input id="new-account-password" v-model="password" type="password" required minlength="15" maxlength="1024" autocomplete="new-password" /></label>
<div class="block space-y-1 text-sm"><label for="new-account-role">Role</label><Select v-model="role"><SelectTrigger id="new-account-role" class="w-full"><SelectValue /></SelectTrigger><SelectContent><SelectItem value="viewer">Viewer</SelectItem><SelectItem value="developer">Developer</SelectItem><SelectItem value="admin">Admin</SelectItem></SelectContent></Select></div>
<div class="block space-y-1 text-sm"><label for="new-account-role">Role</label><Select v-model="role"><SelectTrigger id="new-account-role" class="w-full"><SelectValue /></SelectTrigger><SelectContent><SelectItem v-for="choice in assignable" :key="choice" :value="choice">{{ ROLE_LABELS[choice] }}</SelectItem></SelectContent></Select></div>
<p v-if="error" role="alert" class="text-sm text-danger">{{error}} <a class="underline" href="/?reauth=1">Sign in again</a></p>
<Button type="submit" :disabled="busy">Create account</Button>
</form>
+4 -1
View File
@@ -46,6 +46,7 @@ import {
eventTypes,
eventTypesEnabled,
eventTypesError,
eventTypesLoading,
nameProposal,
pasteExample,
pendingDelete,
@@ -159,7 +160,9 @@ function fieldCount(schema: Record<string, string> | null | undefined): number {
</TableBody>
</Table>
<Empty v-if="!proposals.length && !eventTypes.length">
<p v-if="eventTypesLoading" class="text-sm text-fg-muted" role="status">Loading event types…</p>
<Empty v-else-if="!eventTypesError && !proposals.length && !eventTypes.length">
<EmptyHeader>
<EmptyTitle>No event types yet</EmptyTitle>
</EmptyHeader>
+5
View File
@@ -27,6 +27,9 @@ export const eventTypes = ref<EventType[]>([]);
export const proposals = ref<Proposal[]>([]);
export const eventTypesEnabled = ref(true);
export const eventTypesError = ref<string | null>(null);
/** True until the first read settled, so the list can wait instead of
* presenting a pending read as an empty one. */
export const eventTypesLoading = ref(true);
/** The editor's modes: naming a proposal, pasting an example, editing a type. */
export type DraftMode = "proposal" | "paste" | "edit";
@@ -55,6 +58,8 @@ export async function loadEventTypes(): Promise<void> {
eventTypesError.value = null;
} catch (err) {
eventTypesError.value = (err as Error).message || String(err);
} finally {
eventTypesLoading.value = false;
}
}
+3 -3
View File
@@ -30,10 +30,10 @@ function open() {
if (taskID.value > 0) emit("open", taskID.value);
}
// A missing timestamp gets an em-dash, not a call to ago(): substituting
// A missing timestamp gets a dash, not a call to ago(): substituting
// Date.now() would render "just now" for an event whose time the daemon never
// recorded -- a claim the row cannot back.
const when = computed(() => (props.event.at ? ago(props.event.at) : "\u2014"));
const when = computed(() => (props.event.at ? ago(props.event.at) : "\u2013"));
</script>
<template>
@@ -50,7 +50,7 @@ const when = computed(() => (props.event.at ? ago(props.event.at) : "\u2014"));
describeTimelineEvent({ ...props.event, at: undefined, detail: undefined }).title
}}</TableCell>
<TableCell class="font-mono">{{
taskID > 0 ? `#${taskID}` : "—"
taskID > 0 ? `#${taskID}` : "–"
}}</TableCell>
<TableCell class="w-[55%] max-w-0">
<span
+3 -3
View File
@@ -90,7 +90,7 @@ function groupDetail(group: ActivityGroup) {
}
function groupWhen(group: ActivityGroup) {
return group.representative.at ? ago(group.representative.at) : "\u2014";
return group.representative.at ? ago(group.representative.at) : "\u2013";
}
function openTask(taskID: number) {
@@ -142,7 +142,7 @@ function openTask(taskID: number) {
<Badge v-if="alert.count > 1" variant="idle">×{{ alert.count }}</Badge>
</span>
</TableCell>
<TableCell class="font-mono">—</TableCell>
<TableCell class="font-mono">–</TableCell>
<TableCell class="w-[55%] max-w-0">
<span class="flex items-center gap-3">
<span class="min-w-0 flex-1 truncate" :title="alert.body || undefined">{{ alert.title }}</span>
@@ -212,7 +212,7 @@ function openTask(taskID: number) {
</button>
</TableCell>
<TableCell class="font-mono">{{
group.taskID > 0 ? `#${group.taskID}` : "—"
group.taskID > 0 ? `#${group.taskID}` : "–"
}}</TableCell>
<TableCell class="w-[55%] max-w-0">
<span
+3 -3
View File
@@ -5,10 +5,10 @@
/** Humanised relative time: "2 min ago". Raw timestamps make people do maths. */
export function ago(value: string | number | Date | null | undefined): string {
if (!value) return "—";
if (!value) return "–";
const then = value instanceof Date ? value : new Date(value);
const secs = Math.floor((Date.now() - then.getTime()) / 1000);
if (!Number.isFinite(secs)) return "—";
if (!Number.isFinite(secs)) return "–";
if (secs < 45) return "just now";
const units: Array<[string, number]> = [
["min", 60],
@@ -27,7 +27,7 @@ export function ago(value: string | number | Date | null | undefined): string {
/** Compact number: 2_400_000 -> "2.4M". Long digit strings do not scan. */
export function compact(n: number | null | undefined): string {
if (n == null || Number.isNaN(n)) return "—";
if (n == null || Number.isNaN(n)) return "–";
return new Intl.NumberFormat(undefined, {
notation: "compact",
maximumFractionDigits: 1,
+2 -1
View File
@@ -181,7 +181,8 @@ const isAgent = (value: Identity) =>
<Button variant="ghost" size="sm" class="text-danger" :disabled="!!store.identityBusy" @click="retiring = value">Retire</Button>
</div>
</li>
<li v-if="!store.identities.length">
<li v-if="!store.identitiesLoaded" class="px-4 py-3 text-sm text-fg-muted" role="status">Loading agents…</li>
<li v-else-if="!store.identities.length && !store.identityError">
<Empty class="py-6">
<EmptyHeader>
<EmptyTitle>No identities yet</EmptyTitle>
+19 -13
View File
@@ -4,7 +4,7 @@ import CreateAccount from "@/accounts/CreateAccount.vue";
import { Card, CardContent } from "@/components/ui/card";
import { storeToRefs } from "pinia";
import { computed, onMounted, ref } from "vue";
import { Plus } from "@lucide/vue";
import { Plus, Trash2 } from "@lucide/vue";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
@@ -26,7 +26,7 @@ import {
} from "@/components/ui/table";
import { api } from "@/lib/api";
import { useOrgStore } from "@/stores/org";
import { ROLES, type Member, type Role } from "./org";
import { ROLE_LABELS, ROLES, type Member, type Role } from "./org";
/**
* The org's members and the role each holds. A membership is org-wide, or
@@ -35,6 +35,7 @@ import { ROLES, type Member, type Role } from "./org";
*/
const members = ref<Member[]>([]);
const error = ref("");
const loading = ref(true);
const busy = ref("");
const identities = useOrgStore();
const { org } = storeToRefs(identities);
@@ -61,12 +62,13 @@ async function load(): Promise<void> {
onMounted(async () => {
try {
await identities.loadOrg();
identities.watchIdentities();
await load();
} catch (cause) {
error.value = String((cause as Error).message || cause);
return;
} finally {
loading.value = false;
}
identities.watchIdentities();
await load();
});
// Active identities that hold no org-wide membership yet, so Add cannot pick
@@ -159,22 +161,26 @@ const remove = (member: Member) =>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem v-for="role in ROLES" :key="role" :value="role">{{ role }}</SelectItem>
<SelectItem v-for="role in ROLES" :key="role" :value="role">{{ ROLE_LABELS[role] }}</SelectItem>
</SelectContent>
</Select>
</TableCell>
<TableCell class="text-right">
<Button
variant="ghost"
size="sm"
class="text-danger"
size="icon"
:aria-label="`Remove ${member.display_name}`"
title="Remove"
:disabled="busy !== ''"
@click="remove(member)"
>Remove</Button
>
><Trash2
/></Button>
</TableCell>
</TableRow>
<TableRow v-if="!members.length">
<TableRow v-if="loading">
<TableCell colspan="5" class="text-sm text-fg-muted" role="status">Loading members…</TableCell>
</TableRow>
<TableRow v-else-if="!members.length && !error">
<TableCell colspan="5">
<Empty class="py-6">
<EmptyHeader>
@@ -208,7 +214,7 @@ const remove = (member: Member) =>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem v-for="role in ROLES" :key="role" :value="role">{{ role }}</SelectItem>
<SelectItem v-for="role in ROLES" :key="role" :value="role">{{ ROLE_LABELS[role] }}</SelectItem>
</SelectContent>
</Select>
<Button type="submit" size="sm" :disabled="!picked || busy !== ''">
@@ -230,7 +236,7 @@ const remove = (member: Member) =>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem v-for="role in ROLES" :key="role" :value="role">{{ role }}</SelectItem>
<SelectItem v-for="role in ROLES" :key="role" :value="role">{{ ROLE_LABELS[role] }}</SelectItem>
</SelectContent>
</Select>
<Button type="submit" size="sm" :disabled="!person.trim() || busy !== ''">
+8 -3
View File
@@ -30,6 +30,7 @@ const id = ref("");
const name = ref("");
const environment = ref("");
const error = ref("");
const loading = ref(true);
const busy = ref(false);
async function load(): Promise<void> {
@@ -47,11 +48,12 @@ async function load(): Promise<void> {
onMounted(async () => {
try {
await orgStore.loadOrg();
await load();
} catch (cause) {
error.value = String((cause as Error).message || cause);
return;
} finally {
loading.value = false;
}
await load();
});
async function create(): Promise<void> {
@@ -98,7 +100,10 @@ async function create(): Promise<void> {
<TableCell class="font-medium">{{ workspace.name }}</TableCell>
<TableCell class="text-fg-subtle">{{ workspace.environment || "–" }}</TableCell>
</TableRow>
<TableRow v-if="!workspaces.length">
<TableRow v-if="loading">
<TableCell colspan="3" class="text-sm text-fg-muted" role="status">Loading workspaces…</TableCell>
</TableRow>
<TableRow v-else-if="!workspaces.length && !error">
<TableCell colspan="3">
<Empty class="py-6">
<EmptyHeader>
+8
View File
@@ -16,6 +16,14 @@ export type Role = "owner" | "admin" | "developer" | "viewer";
/** The roles the domain accepts, in descending authority. */
export const ROLES: Role[] = ["owner", "admin", "developer", "viewer"];
/** How a role reads wherever the dashboard offers one. */
export const ROLE_LABELS: Record<Role, string> = {
owner: "Owner",
admin: "Admin",
developer: "Developer",
viewer: "Viewer",
};
export interface Member {
identity_id: string;
kind: string;
+24 -13
View File
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { computed, onMounted, ref } from "vue";
import { Plus } from "@lucide/vue";
import { Plus, Trash2 } from "@lucide/vue";
import PageHeader from "@/base/PageHeader.vue";
import {
@@ -24,7 +24,11 @@ import ApplyStatusRows from "./ApplyStatusRows.vue";
const KIND = "extension-settings";
const store = useExtensionsStore();
onMounted(store.load);
const loading = ref(true);
onMounted(async () => {
await store.load();
loading.value = false;
});
const available = computed(() => store.catalogue.filter((entry) => !entry.installed));
@@ -72,10 +76,10 @@ const tones = {
<TabsContent value="installed">
<ul class="divide-y divide-border rounded-lg border border-border bg-card" aria-label="Extensions">
<li v-for="extension in store.extensions" :key="extension.name" class="flex flex-wrap items-center gap-3 px-4 py-3">
<div class="min-w-0 flex-1">
<div class="min-w-0 w-full lg:w-auto lg:flex-1">
<p class="truncate text-sm font-medium">
{{ extension.display_name || extension.name }}
<span class="font-mono text-xs text-fg-subtle">{{ extension.name }} {{ extension.version }}</span>
<span class="font-mono text-xs text-fg-subtle">{{ extension.version }}</span>
</p>
<p class="text-xs text-fg-subtle">{{ extension.description }}</p>
<p class="truncate font-mono text-xs text-fg-subtle">{{ extension.digest }}</p>
@@ -89,14 +93,12 @@ const tones = {
<Button size="sm" class="mt-2" :disabled="!!store.busy" @click="store.approveUpdate(extension.name)">Approve</Button>
</div>
<Button variant="ghost" size="sm" :disabled="!!store.busy" @click="store.update(extension.name)">Update</Button>
<Button
variant="ghost"
size="sm"
<Switch
:model-value="extension.update_policy === 'auto'"
:disabled="!!store.busy"
:aria-pressed="extension.update_policy === 'auto'"
@click="store.setUpdatePolicy(extension.name, extension.update_policy === 'auto' ? 'manual' : 'auto')"
>{{ extension.update_policy === "auto" ? "Auto-update on" : "Auto-update off" }}</Button
>
:aria-label="`Auto-update ${extension.name}`"
@update:model-value="(value: boolean) => store.setUpdatePolicy(extension.name, value ? 'auto' : 'manual')"
/>
<Button v-if="extension.can_rollback" variant="ghost" size="sm" :disabled="!!store.busy" @click="store.rollback(extension.name)"
>Roll back</Button
>
@@ -115,9 +117,18 @@ const tones = {
:aria-label="`Enable ${extension.name}`"
@update:model-value="(value: boolean) => store.setEnabled(extension.name, value)"
/>
<Button variant="ghost" size="sm" class="text-danger" :disabled="!!store.busy" @click="(removing = extension), (removeOpen = true)">Remove</Button>
<Button
variant="ghost"
size="icon"
:aria-label="`Remove ${extension.name}`"
title="Remove"
:disabled="!!store.busy"
@click="(removing = extension), (removeOpen = true)"
><Trash2
/></Button>
</li>
<li v-if="!store.extensions.length">
<li v-if="loading" class="px-4 py-3 text-sm text-fg-muted" role="status">Loading extensions…</li>
<li v-else-if="!store.extensions.length && !store.error">
<Empty class="py-6">
<EmptyHeader>
<EmptyTitle>Nothing installed</EmptyTitle>
+1 -1
View File
@@ -21,7 +21,7 @@ useIntervalFn(store.load, 15_000);
<Empty v-else-if="store.engines && !store.engines.length"><EmptyHeader><EmptyTitle>No secret engines installed</EmptyTitle></EmptyHeader></Empty>
<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>
<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>
+7
View File
@@ -58,6 +58,9 @@ export const useOrgStore = defineStore("org", () => {
}
const identities = ref<Identity[]>([]);
/** True once the first identity read settled, so a list can wait without
* showing its empty state. */
const identitiesLoaded = ref(false);
const identityError = ref("");
const identityBusy = ref("");
const session = useSessionStore();
@@ -74,6 +77,8 @@ export const useOrgStore = defineStore("org", () => {
identityError.value = "";
} catch (cause) {
identityError.value = message(cause);
} finally {
identitiesLoaded.value = true;
}
}
/** watchIdentities reads the list once and then follows the live stream. */
@@ -83,6 +88,7 @@ export const useOrgStore = defineStore("org", () => {
stop = session.subscribe("identities", (data) => {
identities.value = (data as { identities: Identity[] }).identities;
identityError.value = "";
identitiesLoaded.value = true;
});
}
async function mutate(key: string, action: () => Promise<unknown>): Promise<boolean> {
@@ -116,6 +122,7 @@ export const useOrgStore = defineStore("org", () => {
loadOrg,
viewOrg,
identities,
identitiesLoaded,
activeIdentities,
identityName,
identityError,
+2 -2
View File
@@ -57,10 +57,10 @@ const total = computed(
>
</TableCell>
<TableCell class="text-right font-mono whitespace-nowrap">
{{ file.additions ? `+${file.additions}` : "—" }}
{{ file.additions ? `+${file.additions}` : "–" }}
</TableCell>
<TableCell class="text-right font-mono whitespace-nowrap">
{{ file.deletions ? `−${file.deletions}` : "—" }}
{{ file.deletions ? `−${file.deletions}` : "–" }}
</TableCell>
</TableRow>
</TableBody>
+1 -1
View File
@@ -187,7 +187,7 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
<span class="flex items-baseline gap-2">
<span class="min-w-0 flex-1 truncate font-mono text-[13px]" :class="row.id === selected && 'font-medium'">{{ row.id }}</span>
<Badge v-if="store.drafts.some((draft) => draft.id === row.id)" variant="outline">Draft</Badge>
<span class="font-mono text-xs text-fg-subtle">{{ row.avg_tokens ? compact(row.avg_tokens) : "–" }}</span>
<span v-if="row.avg_tokens" class="font-mono text-xs text-fg-subtle">{{ compact(row.avg_tokens) }}</span>
</span>
<span v-if="row.runs" class="mt-1.5 flex items-center gap-2 text-xs text-fg-subtle">
<span v-if="live.get(row.id)?.running" class="flex w-20 shrink-0 items-center gap-1.5 text-info">
+1 -1
View File
@@ -26,7 +26,7 @@ export function pct(
}
export function formatMs(ms: number | undefined | null): string {
if (!ms) return "—";
if (!ms) return "–";
if (ms < 1000) return `${ms} ms`;
const secs = ms / 1000;
if (secs < 60) return `${secs.toFixed(1)} s`;