fix(activity): an ad-hoc run's row is one run's, a rollback keeps a run whole, Back reads one entry's filters

- The channel-backfill row says "running" from the runs this process has open, not from the table:
  a row whose outcome failed to write no longer reads as running until a restart. The run still
  going leads the row, so a newer run's outcome never sits under the older one's channel.
- Migration 0109's downgrade carries every run's trigger, spend and start in the audit row, and the
  upgrade restores them: a manual run whose admin was deleted stays manual.
- Back/Forward is read by the page's one popstate listener, both halves in one render; the server
  log adopts its half during that render, so no read goes out with one entry's filters and the
  other's range.
- The server log's failed facets use the other tabs' words (the menus may be short); the accounts
  message shows only when the menu really lacks them.
This commit is contained in:
2026-10-18 17:32:22 +02:00
parent fad656988a
commit 13b7577d9f
12 changed files with 188 additions and 72 deletions
+20 -18
View File
@@ -1,4 +1,4 @@
import { useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
import { useMemo, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import {
keepPreviousData,
@@ -57,9 +57,12 @@ export type LogPivot = Pick<LogsUrlState, "requestId" | "jobId" | "runId">;
export default function AdminLogs({
shared,
landed,
onPivot,
}: {
shared: Shared;
/** The filters of the entry Back/Forward landed on (the page reads the address bar, once). */
landed: { logs: LogsUrlState } | null;
/** Show only one request's, job's or run's lines (the page clears every other filter). */
onPivot: (pivot: LogPivot) => void;
}) {
@@ -84,18 +87,16 @@ export default function AdminLogs({
const [open, setOpen] = useState<number | null>(null);
useUrlMirror(logsParamUpdates(state));
// Back/Forward lands on another entry's filters; a dialog closing lands on these same ones, and
// changes nothing (Live and the open line stay).
const onLanded = useEffectEvent(() => {
const landed = logsParamsToState(new URLSearchParams(window.location.search));
if (JSON.stringify(landed) === JSON.stringify(state)) return;
setOpen(null);
setState(landed);
});
useEffect(() => {
const onPop = () => onLanded();
window.addEventListener("popstate", onPop);
return () => window.removeEventListener("popstate", onPop);
}, []);
// changes nothing (Live and the open line stay). Adopted during the render that brings it, with
// the page's half.
const [seen, setSeen] = useState(landed);
if (landed !== seen) {
setSeen(landed);
if (landed && JSON.stringify(landed.logs) !== JSON.stringify(state)) {
setOpen(null);
setState(landed.logs);
}
}
const update = (patch: Partial<LogsUrlState>) => {
setOpen(null);
setState((s) => ({ ...s, ...patch }));
@@ -127,15 +128,16 @@ export default function AdminLogs({
? null
: (logs.data?.pages[logs.data.pages.length - 1]?.next_cursor ?? null);
// A read that failed while lines were on screen: they are kept, and the message says what the
// failure means for them. (With no lines, the list's own error state says it.)
// failure means for them. (With no lines, the list's own error state says it.) Without the facets
// the Source and Event menus offer only "Any", as on the other tabs, so the same words say it.
const failure = !logs.data
? null
: logs.isFetchNextPageError
? "olderFailed"
? "adminLogs.olderFailed"
: logs.isError || (facets.isError && facets.data)
? "stale"
? "adminLogs.stale"
: facets.isError
? "countsFailed"
? "activity.filtersFailed"
: null;
const retryFailed = () => {
if (logs.isFetchNextPageError)
@@ -229,7 +231,7 @@ export default function AdminLogs({
list={logs}
rowCount={rows.length}
rowsClassName="font-mono text-2xs"
failure={failure && { text: t(`adminLogs.${failure}`), onRetry: retryFailed }}
failure={failure && { text: t(failure), onRetry: retryFailed }}
older={
olderCursor !== null
? { label: t("adminLogs.older"), onClick: loadOlder, disabled: logs.isFetchingNextPage }