hyperhive/frontend/packages/shared/src/api-error-panel/api-error-panel.css
iris f60aab4717 frontend: shared ApiErrorPanel component, promote readApiError from credentials.js
Closes #3410.

`ApiErrorPanel` renders a ProblemDetails (RFC 9457) error nicely, with a
copy button so the full text can be pasted straight into a bug report.
No truncation of `detail` — on the #3363 incident that motivated this
issue, that string was the entire diagnosis.

`readApiError`/`problemMessage`/`ProblemDetails` are promoted out of
credentials.js's original `readErrorBody` into `@hive/shared/api-error.js`
(comment rewritten: the RFC 9457 rework has already landed everywhere
except swarm-controller's status route, #3412 in flight, so the raw-text
fallback is a compat shim for that one gap, not a general transition).
credentials.js's 4 call sites switch to the shared reader (kept as
one-line messages there, its result slots are single-line aria-live
regions, not a panel context).

Wired ApiErrorPanel into OverviewPage.tsx (the issue's own worked
example) and CreateAgentPage.tsx (second real call site).

Not built on <hive-warn> despite matching its visual language — that
custom element's CSS-as-text import only works under a build with
loader: 'text' for .css (dashboard's), and silently renders unstyled
under swarm-ui's default css loader (filed separately as #3415).
ApiErrorPanel is a self-contained light-DOM component instead, per
mara's own suggestion to keep it independent of the old UI's shapes.
2026-08-17 23:11:11 +02:00

55 lines
1.7 KiB
CSS

/* api-error-panel.css — `<ApiErrorPanel>`'s own styling, colour + layout
both. Not slotted into `<hive-warn>` (see the component's own header
for why) — the border/background/pulse below are deliberately copied
from `hive-warn.css`'s `level="error"` rule rather than invented fresh,
so this still reads as "the same error banner" everywhere it appears,
just declared locally instead of shared through a shadow root. Reuses
theme.css's own documented semantics (`--red` = "errors, fail state"),
same as `hive-warn.css` does. */
.api-error-panel {
display: block;
margin-top: 1em;
margin-bottom: 0.6em;
border: 1px solid var(--red);
border-radius: 4px;
padding: 0.5em 0.8em;
color: var(--red);
background: color-mix(in srgb, var(--red) 8%, transparent);
text-shadow: 0 0 6px color-mix(in srgb, currentColor 40%, transparent);
animation: api-error-panel-pulse 2.4s ease-in-out infinite;
}
@keyframes api-error-panel-pulse {
0%, 100% { box-shadow: 0 0 12px -4px color-mix(in srgb, currentColor 55%, transparent); }
50% { box-shadow: 0 0 22px -2px color-mix(in srgb, currentColor 95%, transparent); }
}
.api-error-heading {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 0.8em;
}
.api-error-title {
font-weight: 600;
}
.api-error-copy {
flex: none;
background: transparent;
color: inherit;
border: 1px solid currentColor;
border-radius: 0.3em;
padding: 0.1em 0.6em;
font: inherit;
font-size: 0.85em;
cursor: pointer;
}
.api-error-copy:hover {
background: color-mix(in srgb, currentColor 12%, transparent);
}
.api-error-detail {
margin: 0.5em 0 0;
white-space: pre-wrap;
word-break: break-word;
font-size: 0.9em;
opacity: 0.9;
}