* e2e: reproduce health-probe churn on the integrations list Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Probe connection health through a per-connection atom Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * e2e: bound the churn scenario to its own connections Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> ---------
Showing the changes to packages/react/src/api (1 of 3 files). Show all
Unified · Split
| @@ -17,6 +17,7 @@ import { · 16 unmodified lines | ||
| 17 | 17 | } from "@executor-js/sdk/shared"; |
| 18 | 18 | import * as Atom from "effect/unstable/reactivity/Atom"; |
| 19 | 19 | import * as AsyncResult from "effect/unstable/reactivity/AsyncResult"; |
| 20 | +import * as Reactivity from "effect/unstable/reactivity/Reactivity"; | |
| 20 | 21 | import * as Effect from "effect/Effect"; |
| 21 | 22 | |
| 22 | 23 | import { ExecutorApiClient } from "./client"; |
| @@ -198,6 +199,37 @@ export const refreshConnection = ExecutorApiClient.mutation("connections", "refr · 175 unmodified lines | ||
| 198 | 199 | * cache on every load). */ |
| 199 | 200 | export const checkConnectionHealth = ExecutorApiClient.mutation("connections", "checkHealth"); |
| 200 | 201 | |
| 202 | +export interface CheckConnectionHealthArgs { | |
| 203 | + readonly params: { | |
| 204 | + readonly owner: Owner; | |
| 205 | + readonly integration: IntegrationSlug; | |
| 206 | + readonly name: ConnectionName; | |
| 207 | + }; | |
| 208 | + readonly query: { readonly ifStaleMs?: number }; | |
| 209 | + readonly reactivityKeys?: ReadonlyArray<unknown>; | |
| 210 | +} | |
| 211 | + | |
| 212 | +/** The AUTOMATIC health probe, one atom PER CONNECTION. | |
| 213 | + * | |
| 214 | + * `checkConnectionHealth` above is one shared mutation atom. Awaiting it | |
| 215 | + * (`useAtomSet(..., { mode: "promiseExit" })`) resolves with the atom's next | |
| 216 | + * settled result, whichever call produced it, and a new call interrupts the | |
| 217 | + * one in flight. A surface that probes every row of a list in one pass | |
| 218 | + * therefore cancels all but the last probe and hands every row the LAST | |
| 219 | + * row's verdict. Each row then reads a foreign verdict as a change to its own | |
| 220 | + * connection, refreshes the connections cache, and re-probes: the probe storm | |
| 221 | + * the automatic path was built to avoid. Keying the atom by connection address | |
| 222 | + * gives every probe its own fiber and its own result. */ | |
| 223 | +export const checkConnectionHealthFor = Atom.family((address: ConnectionAddress) => | |
| 224 | + ExecutorApiClient.runtime.fn<CheckConnectionHealthArgs>()((args) => { | |
| 225 | + const probe = Effect.gen(function* () { | |
| 226 | + const client = yield* ExecutorApiClient; | |
| 227 | + return yield* client.connections.checkHealth({ params: args.params, query: args.query }); | |
| 228 | + }).pipe(Effect.withSpan("connection.health.probe", { attributes: { address } })); | |
| 229 | + return args.reactivityKeys ? Reactivity.mutation(probe, args.reactivityKeys) : probe; | |
| 230 | + }), | |
| 231 | +); | |
| 232 | + | |
| 201 | 233 | /** Validate an IN-FLIGHT credential without saving it (the key-first connect |
| 202 | 234 | * flow). Returns the probe result the UI derives a connection name from. */ |
| 203 | 235 | export const validateConnection = ExecutorApiClient.mutation("connections", "validate"); |