feat(web): red border on a server card whose connection attempt failed (#1621)

Flags the server whose last connection attempt failed with a red card
border, cleared when another server is connected or a new connection is
attempted — a persistent, at-a-glance companion to the failure toast and
the auto-opened monitoring column.

- App tracks `failedServerId`: set in onToggleConnection's non-auth
  handshake catch, cleared at the start of any new connect attempt. It is
  deliberately kept out of resetSessionScopedUiState, since the failure's
  own `disconnect` event would otherwise clear it the same tick (that same
  event clears `activeServer`, which is why the flag is tracked separately).
- New `errored` Card theme variant (red border via a new
  `--inspector-error-border` token), mirroring the `highlighted` green
  border. Precedence: disabled (dimmed) > errored > highlighted.
- Plumbed `erroredServerId` through InspectorView → ServerListScreen →
  ServerCard (`errored` prop).

Full `npm run ci` passes (validate + coverage + smoke + storybook).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BrihGWcrM9JGRyu41nzZYw
This commit is contained in:
cliffhall 2026-07-09 14:48:17 -04:00
commit c6999dff96

View file

@ -635,6 +635,16 @@ function App() {
undefined,
);
// Id of the server whose last connection attempt failed (#1621). Drives the
// red border on that ServerCard. It is deliberately NOT reset by
// `resetSessionScopedUiState` (a failed connect fires the `disconnect` event,
// which would otherwise clear the flag the same tick we set it); instead it is
// cleared when a new connection attempt starts, and re-set if that attempt
// also fails.
const [failedServerId, setFailedServerId] = useState<string | undefined>(
undefined,
);
// InspectorClient + per-primitive state managers. All recreated together
// whenever the user switches active servers, then destroyed when the
// next switch happens (or when the component unmounts).
@ -2318,6 +2328,10 @@ function App() {
if (id !== activeServerId) {
setActiveServerId(id);
}
// A new connection attempt has begun: clear any previous failure flag so
// the red border on the last-failed card is removed (#1621). If this
// attempt also fails, the catch below re-sets it for this server.
setFailedServerId(undefined);
connectStartRef.current = Date.now();
try {
@ -2407,7 +2421,8 @@ function App() {
// Non-auth handshake error: toast so the user sees what went wrong
// instead of the ConnectionToggle silently reverting to
// "disconnected".
// "disconnected", and flag the card with a red border (#1621).
setFailedServerId(id);
const message = err instanceof Error ? err.message : String(err);
notifications.show({
title: `Failed to connect to "${target.name}"`,
@ -3657,6 +3672,7 @@ function App() {
servers={servers}
serverListWritable={serverListWritable}
activeServer={activeServerId}
erroredServerId={failedServerId}
connectionStatus={connectionStatus}
initializeResult={initializeResult}
latencyMs={latencyMs}