Unified · Split
| @@ -134,6 +134,7 @@ export { · 133 unmodified lines | ||
| 134 | 134 | pathNamesASecret, |
| 135 | 135 | REDACTED_SAMPLE_VALUE, |
| 136 | 136 | identityPathTier, |
| 137 | + isToolSyncHealth, | |
| 137 | 138 | rankResponseSample, |
| 138 | 139 | } from "./health-check"; |
| 139 | 140 | |
| @@ -143,6 +143,7 @@ export { · 142 unmodified lines | ||
| 143 | 143 | candidateIdentityTier, |
| 144 | 144 | sortHealthCheckCandidatesByIdentity, |
| 145 | 145 | identityPathTier, |
| 146 | + isToolSyncHealth, | |
| 146 | 147 | rankResponseSample, |
| 147 | 148 | } from "./health-check"; |
| 148 | 149 | |
| @@ -4,6 +4,7 @@ import * as AsyncResult from "effect/unstable/reactivity/AsyncResult"; · 3 unmodified lines | ||
| 4 | 4 | import * as Exit from "effect/Exit"; |
| 5 | 5 | import { |
| 6 | 6 | IntegrationSlug, |
| 7 | + isToolSyncHealth, | |
| 7 | 8 | type Connection, |
| 8 | 9 | type OAuthClientSummary, |
| 9 | 10 | type Owner, |
| @@ -172,6 +173,12 @@ function AccountRow(props: { · 162 unmodified lines | ||
| 172 | 173 | const misconfigured = status === "misconfigured"; |
| 173 | 174 | const needsHealthAttention = status === "expired" || status === "degraded"; |
| 174 | 175 | const healthDetail = needsHealthAttention ? probe?.detail : undefined; |
| 176 | + // A "Tool sync failing" stamp is about the CATALOG (tools may be stale or | |
| 177 | + // missing), not the credential — the health hook excludes it from `status`, | |
| 178 | + // so surface it as its own muted note instead of an unhealthy row. | |
| 179 | + const syncFailureDetail = isToolSyncHealth(connection.lastHealth) | |
| 180 | + ? connection.lastHealth?.detail | |
| 181 | + : undefined; | |
| 175 | 182 | const missingOAuthScopes = connection.missingOAuthScopes ?? []; |
| 176 | 183 | |
| 177 | 184 | const handleCheck = async () => { |
| @@ -252,6 +259,11 @@ function AccountRow(props: { · 74 unmodified lines | ||
| 252 | 259 | {healthDetail} |
| 253 | 260 | </CardStackEntryDescription> |
| 254 | 261 | ) : null} |
| 262 | + {syncFailureDetail ? ( | |
| 263 | + <CardStackEntryDescription className="mt-1 overflow-visible whitespace-normal text-clip text-xs text-muted-foreground"> | |
| 264 | + {syncFailureDetail} | |
| 265 | + </CardStackEntryDescription> | |
| 266 | + ) : null} | |
| 255 | 267 | {needsReconsent ? ( |
| 256 | 268 | <CardStackEntryDescription className="mt-1 text-xs text-muted-foreground"> |
| 257 | 269 | This connection wasn't granted all the access this integration now needs. |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | import { describe, expect, it } from "@effect/vitest"; |
| 2 | 2 | import type { HealthCheckResult } from "@executor-js/sdk/shared"; |
| 3 | 3 | |
| 4 | −import { HEALTH_REVALIDATE_MS, revalidateQuery } from "./use-connection-health"; | |
| 4 | +import { HEALTH_REVALIDATE_MS, presentableHealth, revalidateQuery } from "./use-connection-health"; | |
| 5 | 5 | |
| 6 | 6 | const verdict = (status: HealthCheckResult["status"]): HealthCheckResult => ({ |
| 7 | 7 | status, |
| @@ -46,3 +46,55 @@ describe("revalidateQuery", () => { · 38 unmodified lines | ||
| 46 | 46 | expect(windows, "only the healthy path is gated").toEqual([undefined, undefined, undefined]); |
| 47 | 47 | }); |
| 48 | 48 | }); |
| 49 | + | |
| 50 | +// --------------------------------------------------------------------------- | |
| 51 | +// Tool-sync stamps are not connection health. `toolSyncHealth` writes a | |
| 52 | +// degraded verdict with the "Tool sync failing" detail prefix into | |
| 53 | +// `last_health` when catalog production fails; presenting that as the | |
| 54 | +// connection's health painted whole integration rows "Degraded" (one bad | |
| 55 | +// sweep stamps many connections at once) for credentials that were fine. | |
| 56 | +// --------------------------------------------------------------------------- | |
| 57 | + | |
| 58 | +describe("presentableHealth", () => { | |
| 59 | + it("passes genuine probe verdicts through untouched", () => { | |
| 60 | + const expired: HealthCheckResult = { | |
| 61 | + status: "expired", | |
| 62 | + checkedAt: Date.now(), | |
| 63 | + detail: "HTTP 401", | |
| 64 | + }; | |
| 65 | + expect(presentableHealth(expired), "a probe verdict presents as-is").toBe(expired); | |
| 66 | + }); | |
| 67 | + | |
| 68 | + it("hides a tool-sync stamp, old (detail-only) and new (reason) alike", () => { | |
| 69 | + const stamped: HealthCheckResult = { | |
| 70 | + status: "degraded", | |
| 71 | + checkedAt: Date.now(), | |
| 72 | + detail: "Tool sync failing: upstream returned HTTP 429", | |
| 73 | + reason: "tool_sync_failed", | |
| 74 | + }; | |
| 75 | + // Stamps written before `reason` existed carry only the detail prefix. | |
| 76 | + const legacy: HealthCheckResult = { | |
| 77 | + status: "degraded", | |
| 78 | + checkedAt: Date.now(), | |
| 79 | + detail: "Tool sync failing: plugin returned an incomplete tool catalog", | |
| 80 | + }; | |
| 81 | + expect(presentableHealth(stamped), "a sync stamp is not connection health").toBeNull(); | |
| 82 | + expect(presentableHealth(legacy), "pre-reason stamps hide the same way").toBeNull(); | |
| 83 | + }); | |
| 84 | + | |
| 85 | + it("treats missing verdicts as missing", () => { | |
| 86 | + expect(presentableHealth(null)).toBeNull(); | |
| 87 | + expect(presentableHealth(undefined)).toBeNull(); | |
| 88 | + }); | |
| 89 | + | |
| 90 | + it("does not hide a probe verdict whose upstream text merely mentions syncing", () => { | |
| 91 | + // The marker is the detail PREFIX, owned by the sync stamp writer — an | |
| 92 | + // upstream error that contains similar words elsewhere stays visible. | |
| 93 | + const probeVerdict: HealthCheckResult = { | |
| 94 | + status: "degraded", | |
| 95 | + checkedAt: Date.now(), | |
| 96 | + detail: "Health check request failed: upstream sync service unavailable", | |
| 97 | + }; | |
| 98 | + expect(presentableHealth(probeVerdict)).toBe(probeVerdict); | |
| 99 | + }); | |
| 100 | +}); | |
| @@ -9,6 +9,7 @@ · 8 unmodified lines | ||
| 9 | 9 | import { useCallback, useContext, useEffect, useRef, useState } from "react"; |
| 10 | 10 | import { RegistryContext, useAtomSet } from "@effect/atom-react"; |
| 11 | 11 | import * as Exit from "effect/Exit"; |
| 12 | +import { isToolSyncHealth } from "@executor-js/sdk/shared"; | |
| 12 | 13 | import type { Connection, HealthCheckResult, HealthStatus, Owner } from "@executor-js/sdk/shared"; |
| 13 | 14 | |
| 14 | 15 | import { checkConnectionHealth, connectionsOptimisticAtom } from "../api/atoms"; |
| @@ -54,6 +55,17 @@ export const revalidateQuery = ( · 39 unmodified lines | ||
| 54 | 55 | ): { readonly ifStaleMs?: number } => |
| 55 | 56 | last?.status === "healthy" ? { ifStaleMs: HEALTH_REVALIDATE_MS } : {}; |
| 56 | 57 | |
| 58 | +/** The verdict a HEALTH surface may present, or null when the persisted | |
| 59 | + * verdict is a tool-sync stamp (`isToolSyncHealth`). A "Tool sync failing" | |
| 60 | + * verdict describes the CATALOG — tools may be stale or missing — not the | |
| 61 | + * credential, so rendering it as the connection's health painted whole rows | |
| 62 | + * "Degraded" (an entire integrations list, when one bad sweep stamped many | |
| 63 | + * connections at once) for connections whose credentials were fine. | |
| 64 | + * Surfaces show the stamp as its own muted note instead. */ | |
| 65 | +export const presentableHealth = ( | |
| 66 | + last: HealthCheckResult | null | undefined, | |
| 67 | +): HealthCheckResult | null => (last == null || isToolSyncHealth(last) ? null : last); | |
| 68 | + | |
| 57 | 69 | /** Identity of a persisted verdict, for detecting the reconnect transition. |
| 58 | 70 | * An OAuth re-mint clears `last_health`, so a verdict giving way to `null` |
| 59 | 71 | * means the grant was replaced and the row must re-probe even though it never |
| @@ -115,7 +127,7 @@ export function useConnectionHealth(connection: Connection): { · 55 unmodified lines | ||
| 115 | 127 | const doCheck = useAtomSet(checkConnectionHealth, { mode: "promiseExit" }); |
| 116 | 128 | const invalidateConnections = useInvalidateConnections(); |
| 117 | 129 | |
| 118 | − const probe = freshestVerdict(liveProbe, connection.lastHealth); | |
| 130 | + const probe = freshestVerdict(liveProbe, presentableHealth(connection.lastHealth)); | |
| 119 | 131 | const status: HealthStatus = probe?.status ?? "unknown"; |
| 120 | 132 | |
| 121 | 133 | // Health checks are AUTOMATIC: loading the list revalidates any verdict |
| @@ -137,6 +149,10 @@ export function useConnectionHealth(connection: Connection): { · 15 unmodified lines | ||
| 137 | 149 | seenEpoch.current = epoch; |
| 138 | 150 | if (!firstSight && !cleared) return; |
| 139 | 151 | if (healthyAndFresh(last)) return; |
| 152 | + // A tool-sync stamp still PROBES (it is non-healthy, and the probe is | |
| 153 | + // what discovers the credential's real state — a never-probed connection | |
| 154 | + // whose first sync failed must still surface Expired); it just never | |
| 155 | + // RENDERS as connection health (see `presentableHealth`). | |
| 140 | 156 | void doCheck({ |
| 141 | 157 | params: connectionParams(connection), |
| 142 | 158 | query: revalidateQuery(last), |
| @@ -226,7 +242,10 @@ export function useConnectionsHealth( · 83 unmodified lines | ||
| 226 | 242 | |
| 227 | 243 | return useCallback( |
| 228 | 244 | (connection: Connection) => |
| 229 | − freshestVerdict(liveProbes.get(probeKey(connection)) ?? null, connection.lastHealth), | |
| 245 | + freshestVerdict( | |
| 246 | + liveProbes.get(probeKey(connection)) ?? null, | |
| 247 | + presentableHealth(connection.lastHealth), | |
| 248 | + ), | |
| 230 | 249 | [liveProbes], |
| 231 | 250 | ); |
| 232 | 251 | } |