fix(ui): startup failure is a centred panel that retries on its own (#1738)
When /api/auth/status fails, App.vue now shows a centred card with the logo, a plain 'Can't reach Archie' statement and the detail in a destructive Alert (role=alert), and retries the read every 5s until it succeeds instead of offering only a manual Retry link. errorMessage in api.ts only reads text/plain bodies, so a proxy's HTML error page no longer passes through as the detail; other content types fall back to the status line.
This commit is contained in:
2 files changed
+32
-9
No files matched your search
+23
-3
@@ -1,6 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Button } from "@/components/ui/button";
|
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
||||||
import { computed, nextTick, onMounted, ref, watch } from "vue";
|
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
|
|
||||||
import AccountEntry from "@/accounts/AccountEntry.vue";
|
import AccountEntry from "@/accounts/AccountEntry.vue";
|
||||||
@@ -11,7 +10,10 @@ import AlertsBell from "@/alerts/AlertsBell.vue";
|
|||||||
import AppSidebar from "@/components/AppSidebar.vue";
|
import AppSidebar from "@/components/AppSidebar.vue";
|
||||||
import CommandPalette from "@/components/command-palette/CommandPalette.vue";
|
import CommandPalette from "@/components/command-palette/CommandPalette.vue";
|
||||||
import Brand from "@/components/topbar/Brand.vue";
|
import Brand from "@/components/topbar/Brand.vue";
|
||||||
|
import Logo from "@/components/topbar/Logo.vue";
|
||||||
import ConnectionPill from "@/components/topbar/ConnectionPill.vue";
|
import ConnectionPill from "@/components/topbar/ConnectionPill.vue";
|
||||||
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||||
|
import { Card } from "@/components/ui/card";
|
||||||
import { SidebarInset, SidebarProvider, SidebarTrigger } from "@/components/ui/sidebar";
|
import { SidebarInset, SidebarProvider, SidebarTrigger } from "@/components/ui/sidebar";
|
||||||
import NewTaskDialog from "@/tasks/NewTaskDialog.vue";
|
import NewTaskDialog from "@/tasks/NewTaskDialog.vue";
|
||||||
import SettingsShell from "@/settings/SettingsShell.vue";
|
import SettingsShell from "@/settings/SettingsShell.vue";
|
||||||
@@ -45,6 +47,14 @@ watch(() => route.path, async () => {
|
|||||||
}, { flush: "post" });
|
}, { flush: "post" });
|
||||||
|
|
||||||
onMounted(() => {void accounts.load();});
|
onMounted(() => {void accounts.load();});
|
||||||
|
// A failed startup read retries on an interval, so a proxy or daemon that
|
||||||
|
// comes back does not need a manual reload.
|
||||||
|
let retryTimer: ReturnType<typeof setInterval> | undefined;
|
||||||
|
watch(() => accounts.error, (message) => {
|
||||||
|
if (message && retryTimer === undefined) retryTimer = setInterval(() => void accounts.load(), 5000);
|
||||||
|
if (!message && retryTimer !== undefined) { clearInterval(retryTimer); retryTimer = undefined; }
|
||||||
|
});
|
||||||
|
onBeforeUnmount(() => { if (retryTimer !== undefined) clearInterval(retryTimer); });
|
||||||
watch(() => accounts.status?.user, (user) => {
|
watch(() => accounts.status?.user, (user) => {
|
||||||
if (!user || reauthenticate) return;
|
if (!user || reauthenticate) return;
|
||||||
session.initialize();
|
session.initialize();
|
||||||
@@ -64,7 +74,17 @@ watch(() => accounts.status?.user, (user) => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="!accounts.status" class="mx-auto max-w-md p-8" role="status"><p>{{accounts.error||'Connecting to Archie…'}}</p><Button v-if="accounts.error" variant="link" class="mt-3 px-0" @click="accounts.load">Retry</Button></div>
|
<main v-if="!accounts.status" class="mx-auto flex min-h-[90dvh] max-w-md flex-col justify-center px-5 py-10">
|
||||||
|
<Card class="gap-0 px-6 py-6 shadow-sm">
|
||||||
|
<div class="mb-2"><Logo /></div>
|
||||||
|
<template v-if="accounts.error">
|
||||||
|
<h1 class="text-2xl font-medium">Can't reach Archie</h1>
|
||||||
|
<Alert variant="destructive" class="mt-4"><AlertDescription>{{ accounts.error }}</AlertDescription></Alert>
|
||||||
|
<p class="text-caption mt-3 text-fg-muted">Retrying automatically…</p>
|
||||||
|
</template>
|
||||||
|
<p v-else class="mt-2" role="status">Connecting to Archie…</p>
|
||||||
|
</Card>
|
||||||
|
</main>
|
||||||
<AccountEntry v-else-if="!accounts.status.user || accounts.status.setup_required || reauthenticate" />
|
<AccountEntry v-else-if="!accounts.status.user || accounts.status.setup_required || reauthenticate" />
|
||||||
<TooltipProvider v-else :delay-duration="350">
|
<TooltipProvider v-else :delay-duration="350">
|
||||||
<SidebarProvider class="bg-[var(--workspace)]">
|
<SidebarProvider class="bg-[var(--workspace)]">
|
||||||
|
|||||||
+9
-6
@@ -47,13 +47,16 @@ function qs(params?: QueryParams): string {
|
|||||||
// with http.Error, i.e. a plain-text reason -- "task is not awaiting
|
// with http.Error, i.e. a plain-text reason -- "task is not awaiting
|
||||||
// approval", "max retries reached (3/3)", "Content-Type must be
|
// approval", "max retries reached (3/3)", "Content-Type must be
|
||||||
// application/json" -- and discarding it in favour of "409 Conflict" throws
|
// application/json" -- and discarding it in favour of "409 Conflict" throws
|
||||||
// away the only part an operator can act on.
|
// away the only part an operator can act on. Only a text/plain body is read:
|
||||||
|
// a proxy's HTML error page must not pass through as the reason.
|
||||||
async function errorMessage(res: Response): Promise<string> {
|
async function errorMessage(res: Response): Promise<string> {
|
||||||
try {
|
if ((res.headers.get("Content-Type") ?? "").includes("text/plain")) {
|
||||||
const body = (await res.text()).trim();
|
try {
|
||||||
if (body) return body.split("\n")[0].slice(0, 200);
|
const body = (await res.text()).trim();
|
||||||
} catch {
|
if (body) return body.split("\n")[0].slice(0, 200);
|
||||||
// Body already consumed or unreadable; fall through to the status.
|
} catch {
|
||||||
|
// Body already consumed or unreadable; fall through to the status.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return `${res.status} ${res.statusText}`;
|
return `${res.status} ${res.statusText}`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user