Error log, retry notice, a waiting counter that keeps counting
CI / test (push) Successful in 1m8s
CI / build (push) Successful in 5m13s
CI / deploy (push) Skipped

- generation_errors: every failed attempt (model, attempt, outcome, duration); admin
  Hibanapló page and GET /v1/admin/errors; kept 90 days
- The waiting page counts from when the text was asked for (requested_at), not from
  the page load, so a reload no longer restarts it
- It says when an attempt failed and is retried, and when a failed text's unit was
  given back; admins see the error

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-18 21:47:37 +00:00
co-authored by Claude Opus 5.5
parent cf2fb9d454
commit 02e4e225f0
22 changed files with 569 additions and 25 deletions
@@ -5,6 +5,7 @@ const PAGES = [
{ href: "/admin/meghivok", label: "Meghívók" },
{ href: "/admin/promptok", label: "Promptok" },
{ href: "/admin/modellek", label: "Modellek" },
{ href: "/admin/hibak", label: "Hibanapló" },
];
/** Switches between the admin pages. */
@@ -4,13 +4,31 @@ import { useEffect, useState } from "react";
import { ZodiacWheel } from "./ZodiacWheel";
/** Slowly turning wheel with the elapsed time, while the LLM writes. */
export function AnalysisLoading({ title, text, compact = false }: { title?: string; text: string; compact?: boolean }) {
const [seconds, setSeconds] = useState(0);
/**
* Slowly turning wheel with the elapsed time, while the LLM writes. The time
* counts from `since` (when the text was asked for), so it does not start
* again from zero after a reload; without it, from when the wheel appeared.
*/
export function AnalysisLoading({
title,
text,
compact = false,
since,
}: {
title?: string;
text: string;
compact?: boolean;
since?: string;
}) {
const [start] = useState(() => {
const t = since ? Date.parse(since) : NaN;
return Number.isNaN(t) ? Date.now() : Math.min(t, Date.now());
});
const [seconds, setSeconds] = useState(() => Math.floor((Date.now() - start) / 1000));
useEffect(() => {
const t = setInterval(() => setSeconds((s) => s + 1), 1000);
const t = setInterval(() => setSeconds(Math.floor((Date.now() - start) / 1000)), 1000);
return () => clearInterval(t);
}, []);
}, [start]);
const elapsed = `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`;
return (
@@ -21,7 +39,7 @@ export function AnalysisLoading({ title, text, compact = false }: { title?: stri
<p className="muted" role="status">
{text}
</p>
<p className="hint" aria-hidden="true">
<p className="hint" aria-hidden="true" suppressHydrationWarning>
{elapsed}
</p>
</div>
@@ -8,6 +8,7 @@ import type { Question, UnitBalance } from "@/lib/types";
import { AnalysisLoading } from "./AnalysisLoading";
import { PackageChooser } from "./PackageCards";
import { RegenerateButton } from "./RegenerateButton";
import { RetryNotice } from "./RetryNotice";
import { Paragraphs } from "./Rich";
const MAX_CHARS = 600;
@@ -139,12 +140,21 @@ export function AnalysisQuestions({
<RegenerateButton<Question> url={`/admin/questions/${q.id}/regenerate`} onStarted={replace} />
)}
<p className="msg msg-error" role="alert">
Erre most nem sikerült válaszolni{q.credits_charged > 0 ? ", a kérdést visszaadtuk" : ""}. Kérdezz újra
egy kicsit később.
Erre többszöri próbálkozás után sem sikerült válaszolni
{q.credits_charged > 0 ? ". A kérdést visszaadtuk, így ingyen újra felteheted" : ""}. Kérdezz újra egy
kicsit később.
</p>
{isAdmin && q.error && <p className="hint">Hiba: {q.error}</p>}
</div>
) : (
<AnalysisLoading compact text="Készül a válasz, ez általában fél perc…" />
<>
<AnalysisLoading
compact
text="Készül a válasz, ez általában fél perc…"
since={q.requested_at ?? q.created_at}
/>
<RetryNotice status={q.status} error={q.error} nextAttemptAt={q.next_attempt_at} isAdmin={isAdmin} />
</>
)}
</article>
))}
@@ -7,6 +7,7 @@ import type { Analysis } from "@/lib/types";
import { AnalysisLoading } from "./AnalysisLoading";
import { RegenerateButton } from "./RegenerateButton";
import { RetryNotice } from "./RetryNotice";
import { Rich } from "./Rich";
import { openTab } from "./Tabs";
@@ -102,7 +103,21 @@ export function ChartSummary({
Az összefoglaló most nem készült el. Töltsd újra az oldalt egy kicsit később.
</p>
) : (
<AnalysisLoading compact text="Az összefoglalód készül, ez néhány másodperc…" />
<>
<AnalysisLoading
compact
text="Az összefoglalód készül, ez néhány másodperc…"
since={summary?.requested_at ?? summary?.created_at}
/>
{summary && (
<RetryNotice
status={summary.status}
error={summary.error}
nextAttemptAt={summary.next_attempt_at}
isAdmin={isAdmin}
/>
)}
</>
)}
</>
)}
@@ -11,6 +11,7 @@ import { AnalysisLoading } from "./AnalysisLoading";
import { AnalysisQuestions } from "./AnalysisQuestions";
import { PackageChooser } from "./PackageCards";
import { RegenerateButton } from "./RegenerateButton";
import { RetryNotice } from "./RetryNotice";
import { AnalysisView } from "./AnalysisView";
const POLL_MS = 5000;
@@ -172,7 +173,15 @@ export function DetailedAnalysis({
return (
<section className="analysis-card" aria-label={t.eyebrow} aria-busy="true">
<span className="eyebrow">{t.eyebrow}</span>
<AnalysisLoading title={t.loadingTitle} text={t.loading} />
<AnalysisLoading title={t.loadingTitle} text={t.loading} since={analysis?.requested_at ?? analysis?.created_at} />
{analysis && (
<RetryNotice
status={analysis.status}
error={analysis.error}
nextAttemptAt={analysis.next_attempt_at}
isAdmin={isAdmin}
/>
)}
</section>
);
}
@@ -186,9 +195,15 @@ export function DetailedAnalysis({
<p className="muted">{t.about}</p>
<p className="ai-line">{AI_SHORT}</p>
{analysis?.status === "failed" && (
<p className="msg msg-error" role="alert">
Az előző kérés nem sikerült{isAdmin ? "" : ", az elemzést visszaadtuk a keretedbe"}. Próbáld újra.
</p>
<div className="msg msg-error" role="alert">
<p style={{ margin: 0 }}>
Az elemzés többszöri próbálkozás után sem készült el.
{isAdmin || analysis.credits_charged === 0
? " Próbáld újra."
: " A felhasznált egységet visszaadtuk, így ingyen újra kérheted."}
</p>
{isAdmin && analysis.error && <p className="hint">Hiba: {analysis.error}</p>}
</div>
)}
{error && (
<p className="msg msg-error" role="alert">
@@ -0,0 +1,28 @@
/**
* Shown while a text is being written again after a failed attempt: it is
* retried on its own, nothing to do. Admins also see the error.
*/
export function RetryNotice({
status,
error,
nextAttemptAt,
isAdmin = false,
}: {
status: string;
error?: string | null;
nextAttemptAt?: string;
isAdmin?: boolean;
}) {
if (!error || (status !== "pending" && status !== "running")) return null;
const wait = nextAttemptAt ? Math.round((Date.parse(nextAttemptAt) - Date.now()) / 60_000) : 0;
return (
<div className="msg retry-notice" role="status">
<p>
Az előző próbálkozás nem sikerült, ezért automatikusan újrapróbáljuk. Nem kell újra kérned, és nem kerül
többe.
{status === "pending" && wait >= 1 ? ` A következő próbálkozás kb. ${wait} perc múlva indul.` : ""}
</p>
{isAdmin && <p className="hint">Hiba: {error}</p>}
</div>
);
}