Files
sorsfonalak/services/frontend/src/components/AnalysisLoading.tsx
T
fecoandClaude Opus 5.5 02e4e225f0
CI / test (push) Successful in 1m8s
CI / build (push) Successful in 5m13s
CI / deploy (push) Skipped
Error log, retry notice, a waiting counter that keeps counting
- 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
2026-11-18 21:47:37 +00:00

49 lines
1.4 KiB
TypeScript

"use client";
import { useEffect, useState } from "react";
import { ZodiacWheel } from "./ZodiacWheel";
/**
* 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(Math.floor((Date.now() - start) / 1000)), 1000);
return () => clearInterval(t);
}, [start]);
const elapsed = `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`;
return (
<div className={compact ? "loading loading-compact" : "loading"}>
<ZodiacWheel className="loading-wheel" />
<div className="loading-text">
{title && <strong>{title}</strong>}
<p className="muted" role="status">
{text}
</p>
<p className="hint" aria-hidden="true" suppressHydrationWarning>
{elapsed}
</p>
</div>
</div>
);
}