fix(ui): failed reads show an error with Retry, not an empty view (#1733)
Chat: a failed conversation load sets sessionError, shown in the transcript with Retry instead of the empty invitation (it no longer goes to statusText in the settings popover). Command palette: failed task or workflow reads render a "Couldn't load … — Retry" item in that group. Denials: the table no longer shows "No denials recorded" under an error. Mapping form: failed captures/event-types reads show an error row with Retry instead of "No captured events yet." or a silently empty select. Channels: a failed status read keeps the last badges and shows an error with Retry. Sources: read failures are separate from write failures, shown with Retry, and a loaded-but-empty list gets an empty state.
This commit is contained in:
9 files changed
+85
-14
No files matched your search
@@ -49,7 +49,7 @@ onMounted(() => void store.load());
|
||||
<EmptyHeader><EmptyTitle>No denials recorded</EmptyTitle></EmptyHeader>
|
||||
</Empty>
|
||||
<DataTable
|
||||
v-else
|
||||
v-else-if="!error || denials.length"
|
||||
:columns="columns"
|
||||
:rows="denials"
|
||||
:row-key="(d) => `${d.at}:${d.principal}:${d.action}:${d.kind}:${d.resource}`"
|
||||
|
||||
@@ -90,11 +90,15 @@ const agentOptions = computed(() => {
|
||||
});
|
||||
|
||||
const statuses = ref<ChannelStatus[]>([]);
|
||||
// A failed status read keeps the last known badges and flags the error, so a
|
||||
// transient failure neither clears every badge nor passes as "all idle".
|
||||
const statusError = ref(false);
|
||||
async function loadStatus() {
|
||||
try {
|
||||
statuses.value = (await api.channels<{ channels?: ChannelStatus[] }>())?.channels ?? [];
|
||||
statusError.value = false;
|
||||
} catch {
|
||||
statuses.value = [];
|
||||
statusError.value = true;
|
||||
}
|
||||
}
|
||||
useLiveResource(null, () => void loadStatus());
|
||||
@@ -147,6 +151,11 @@ function setModels(list: string[]) {
|
||||
{{ catalogError || error }}
|
||||
</AlertDescription></Alert>
|
||||
|
||||
<Alert v-if="statusError" variant="destructive" class="mb-4"><AlertDescription>
|
||||
Couldn't load channel status
|
||||
<Button variant="link" size="xs" @click="loadStatus">Retry</Button>
|
||||
</AlertDescription></Alert>
|
||||
|
||||
<template v-if="chat">
|
||||
<Section v-for="channel in channels" :key="channel.id" :title="channel.title" :class="!shown(channel.id) && 'gap-0'">
|
||||
<template #action>
|
||||
|
||||
@@ -16,11 +16,15 @@ import ChatBubble from "./ChatBubble.vue";
|
||||
import ChatChooseCard from "./ChatChooseCard.vue";
|
||||
import ChatUpdateCard from "./ChatUpdateCard.vue";
|
||||
import ChatEmptyState from "./ChatEmptyState.vue";
|
||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
currentSession,
|
||||
isLoadingSession,
|
||||
messages,
|
||||
selectSession,
|
||||
sendMessage,
|
||||
sessionError,
|
||||
streamingTurn,
|
||||
type ChatMessage,
|
||||
reloadTranscript,
|
||||
@@ -90,6 +94,14 @@ useLiveResource("chat", () => void reloadTranscript());
|
||||
<Skeleton class="h-10 w-2/5 self-end rounded-xl" />
|
||||
</template>
|
||||
|
||||
<div
|
||||
v-else-if="sessionError && !bubbles.length"
|
||||
class="flex flex-col items-center gap-3 p-4"
|
||||
>
|
||||
<Alert variant="destructive" class="max-w-md"><AlertDescription>{{ sessionError }}</AlertDescription></Alert>
|
||||
<Button variant="outline" size="sm" @click="selectSession(currentSession)">Retry</Button>
|
||||
</div>
|
||||
|
||||
<ChatEmptyState
|
||||
v-else-if="!bubbles.length && !streamingTurn"
|
||||
@prompt="emit('prompt', $event)"
|
||||
|
||||
@@ -183,6 +183,9 @@ export const composerText = ref("");
|
||||
export const statusText = ref("Ready");
|
||||
export const isSending = ref(false);
|
||||
export const isLoadingSession = ref(false);
|
||||
// A failed conversation load: shown in the transcript itself, with a Retry,
|
||||
// rather than in the settings popover where statusText renders.
|
||||
export const sessionError = ref("");
|
||||
export const streamingTurn = ref<StreamingTurn | null>(null);
|
||||
|
||||
export const selectorData = ref<ChatSelectorData>({});
|
||||
@@ -255,7 +258,7 @@ export async function selectSession(id: string): Promise<void> {
|
||||
streamingTurn.value = null;
|
||||
queuedMessages.value = [];
|
||||
isLoadingSession.value = true;
|
||||
|
||||
sessionError.value = "";
|
||||
|
||||
try {
|
||||
// Resuming is the server's own command, so the transcript read below is of
|
||||
@@ -263,8 +266,9 @@ export async function selectSession(id: string): Promise<void> {
|
||||
await api.chatMessage(channelID(), `/resume ${id}`);
|
||||
messages.value = await readTranscript(id);
|
||||
} catch (err) {
|
||||
statusText.value =
|
||||
(err as Error).message || "Could not load session messages";
|
||||
if (isCurrentSession(id))
|
||||
sessionError.value =
|
||||
(err as Error).message || "Could not load session messages";
|
||||
} finally {
|
||||
if (isCurrentSession(id)) isLoadingSession.value = false;
|
||||
}
|
||||
|
||||
@@ -46,8 +46,10 @@ const workflows = ref<string[]>([]);
|
||||
const shortcut = navigator.platform.startsWith("Mac") ? "⌘K" : "Ctrl K";
|
||||
const showWorkflows = computed(() => !props.hidden.includes("/workflows"));
|
||||
|
||||
// A failed read leaves that group empty: the pages still work, and the
|
||||
// palette is not the place to report a broken task list.
|
||||
// A failed read shows as an error item with Retry in that group, not as a
|
||||
// missing group: the pages still work either way.
|
||||
const tasksError = ref(false);
|
||||
const workflowsError = ref(false);
|
||||
async function loadEntries(): Promise<void> {
|
||||
const [taskPage, workflowList] = await Promise.all([
|
||||
api.taskPage<TaskEntry>({ limit: 100 }).catch(() => null),
|
||||
@@ -55,7 +57,9 @@ async function loadEntries(): Promise<void> {
|
||||
? api.workflows<{ definitions?: { id: string }[] }>().catch(() => null)
|
||||
: null,
|
||||
]);
|
||||
tasksError.value = taskPage === null;
|
||||
tasks.value = taskPage?.tasks ?? [];
|
||||
workflowsError.value = showWorkflows.value && workflowList === null;
|
||||
workflows.value = (workflowList?.definitions ?? []).map(({ id }) => id);
|
||||
}
|
||||
|
||||
@@ -129,7 +133,10 @@ onUnmounted(() => document.removeEventListener("keydown", onGlobalKeydown));
|
||||
{{ entry.label }}
|
||||
</CommandItem>
|
||||
</CommandGroup>
|
||||
<CommandGroup v-if="workflows.length" heading="Workflows">
|
||||
<CommandGroup v-if="workflowsError" heading="Workflows">
|
||||
<CommandItem value="workflows-error" @select="loadEntries">Couldn't load workflows — Retry</CommandItem>
|
||||
</CommandGroup>
|
||||
<CommandGroup v-else-if="workflows.length" heading="Workflows">
|
||||
<CommandItem
|
||||
v-for="id in workflows"
|
||||
:key="id"
|
||||
@@ -139,7 +146,10 @@ onUnmounted(() => document.removeEventListener("keydown", onGlobalKeydown));
|
||||
{{ id }}
|
||||
</CommandItem>
|
||||
</CommandGroup>
|
||||
<CommandGroup v-if="tasks.length" heading="Tasks">
|
||||
<CommandGroup v-if="tasksError" heading="Tasks">
|
||||
<CommandItem value="tasks-error" @select="loadEntries">Couldn't load tasks — Retry</CommandItem>
|
||||
</CommandGroup>
|
||||
<CommandGroup v-else-if="tasks.length" heading="Tasks">
|
||||
<CommandItem
|
||||
v-for="task in tasks"
|
||||
:key="task.id"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
@@ -16,8 +17,11 @@ import { eventTypeLabel } from "@/captures/event-types";
|
||||
import {
|
||||
captures,
|
||||
capturesEnabled,
|
||||
capturesError,
|
||||
draft,
|
||||
eventTypes,
|
||||
eventTypesError,
|
||||
loadMappings,
|
||||
selectCapture,
|
||||
type Capture,
|
||||
} from "./state";
|
||||
@@ -49,9 +53,11 @@ function captureLabel(capture: Capture): string {
|
||||
return `${capture.source || "(unknown)"} · ${ago(capture.received_at)}`;
|
||||
}
|
||||
|
||||
/** What an empty picker means, which is not the same on every deployment. */
|
||||
/** What an empty picker means, which is not the same on every deployment.
|
||||
* A failed read is not an empty store, so it shows no hint here -- the error
|
||||
* row below says so and offers Retry. */
|
||||
const captureHint = computed(() => {
|
||||
if (captures.value.length) return null;
|
||||
if (capturesError.value || captures.value.length) return null;
|
||||
return capturesEnabled.value
|
||||
? "No captured events yet."
|
||||
: "Capture is not configured on this deployment.";
|
||||
@@ -83,6 +89,10 @@ const captureHint = computed(() => {
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<p v-if="eventTypesError" class="flex items-center gap-2 text-xs text-danger">
|
||||
Couldn't load event types
|
||||
<Button variant="link" size="xs" class="px-0" @click="loadMappings">Retry</Button>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
@@ -112,6 +122,10 @@ const captureHint = computed(() => {
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<p v-if="captureHint" class="text-xs text-fg-subtle">{{ captureHint }}</p>
|
||||
<p v-if="capturesError" class="flex items-center gap-2 text-xs text-danger">
|
||||
Couldn't load captured events
|
||||
<Button variant="link" size="xs" class="px-0" @click="loadMappings">Retry</Button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -103,6 +103,10 @@ export const listLoading = ref(true);
|
||||
/** A failed list load. Distinct from an action failure: the list is unusable,
|
||||
* where a refused action leaves it perfectly readable. */
|
||||
export const loadError = ref<string | null>(null);
|
||||
// The optional legs fail on their own: the flag says the picker's data is a
|
||||
// failed read, not an empty store, so the form can offer Retry.
|
||||
export const capturesError = ref(false);
|
||||
export const eventTypesError = ref(false);
|
||||
|
||||
/** Whether the editor overlay is showing the draft. */
|
||||
export const editorOpen = ref(false);
|
||||
@@ -136,8 +140,8 @@ export async function loadMappings(): Promise<void> {
|
||||
listLoading.value = true;
|
||||
try {
|
||||
// Capture storage is optional infrastructure -- a deployment can serve
|
||||
// mappings without it -- so a failing capture leg degrades to an empty
|
||||
// picker instead of taking the mappings list down with it.
|
||||
// mappings without it -- so a failing capture leg flags the picker instead
|
||||
// of taking the mappings list down with it.
|
||||
const [listed, captured, types] = await Promise.all([
|
||||
api.mappings<{ mappings?: Mapping[] }>(useEventsStore().workspace),
|
||||
api
|
||||
@@ -149,6 +153,8 @@ export async function loadMappings(): Promise<void> {
|
||||
eventTypes.value = types?.event_types || [];
|
||||
captures.value = captured?.captures || [];
|
||||
capturesEnabled.value = captured?.enabled !== false;
|
||||
capturesError.value = captured === null;
|
||||
eventTypesError.value = types === null;
|
||||
loadError.value = null;
|
||||
} catch (err) {
|
||||
loadError.value = String((err as Error).message || err);
|
||||
|
||||
@@ -7,6 +7,7 @@ import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
@@ -37,6 +38,7 @@ import { useSources } from "./use-sources";
|
||||
*/
|
||||
const {
|
||||
sources,
|
||||
loadError,
|
||||
failure,
|
||||
revealed,
|
||||
busy,
|
||||
@@ -96,6 +98,11 @@ function url(source: Source): string {
|
||||
<AlertDescription>{{ failure }}</AlertDescription>
|
||||
</Alert>
|
||||
|
||||
<Alert v-if="loadError" variant="destructive">
|
||||
<AlertTitle>Couldn't load sources</AlertTitle>
|
||||
<AlertDescription>{{ loadError }} <Button variant="link" size="xs" @click="load">Retry</Button></AlertDescription>
|
||||
</Alert>
|
||||
|
||||
<SourceSecret v-if="revealed" :source="revealed" @dismiss="revealed = null" />
|
||||
|
||||
<Section v-if="sources && sources.length">
|
||||
@@ -220,5 +227,9 @@ function url(source: Source): string {
|
||||
</TableBody>
|
||||
</Table>
|
||||
</Section>
|
||||
|
||||
<Empty v-else-if="sources && !loadError">
|
||||
<EmptyHeader><EmptyTitle>No sources yet</EmptyTitle></EmptyHeader>
|
||||
</Empty>
|
||||
</section>
|
||||
</template>
|
||||
@@ -12,6 +12,9 @@ import type { Source, SourceRefusals } from "./source-signing";
|
||||
export function useSources() {
|
||||
// null means loading, [] means loaded and empty.
|
||||
const sources = ref<Source[] | null>(null);
|
||||
// Read failures are kept apart from write failures: a failed load is not "a
|
||||
// write that did not take effect", and belongs next to the list, with Retry.
|
||||
const loadError = ref<string | null>(null);
|
||||
const failure = ref<string | null>(null);
|
||||
const revealed = ref<Source | null>(null);
|
||||
const refusals = ref<Record<string, SourceRefusals>>({});
|
||||
@@ -30,8 +33,9 @@ export function useSources() {
|
||||
sources.value = res.sources || [];
|
||||
refusals.value = res.refusals || {};
|
||||
failure.value = null;
|
||||
loadError.value = null;
|
||||
} catch (err) {
|
||||
failure.value = message(err);
|
||||
loadError.value = message(err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +55,7 @@ export function useSources() {
|
||||
|
||||
return {
|
||||
sources,
|
||||
loadError,
|
||||
failure,
|
||||
revealed,
|
||||
refusals,
|
||||
|
||||
Reference in new issue
Block a user