Unified · Split
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | import { useState } from "react"; |
| 2 | 2 | import { useAtomValue, useAtomSet } from "@effect/atom-react"; |
| 3 | 3 | import * as AsyncResult from "effect/unstable/reactivity/AsyncResult"; |
| 4 | +import * as Exit from "effect/Exit"; | |
| 4 | 5 | import { mcpSourceAtom, updateMcpSource } from "./atoms"; |
| 5 | 6 | import { useScope } from "@executor-js/react/api/scope-context"; |
| 6 | 7 | import { sourceWriteKeys } from "@executor-js/react/api/reactivity-keys"; |
| @@ -35,7 +36,7 @@ function RemoteEditForm(props: { · 28 unmodified lines | ||
| 35 | 36 | onSave: () => void; |
| 36 | 37 | }) { |
| 37 | 38 | const scopeId = useScope(); |
| 38 | − const doUpdate = useAtomSet(updateMcpSource, { mode: "promise" }); | |
| 39 | + const doUpdate = useAtomSet(updateMcpSource, { mode: "promiseExit" }); | |
| 39 | 40 | const secretList = useSecretPickerSecrets(); |
| 40 | 41 | |
| 41 | 42 | const identity = useSourceIdentity({ |
| @@ -64,24 +65,24 @@ function RemoteEditForm(props: { · 22 unmodified lines | ||
| 64 | 65 | setSaving(true); |
| 65 | 66 | setError(null); |
| 66 | 67 | const { headers, queryParams } = serializeHttpCredentials(credentials); |
| 67 | − try { | |
| 68 | − await doUpdate({ | |
| 69 | − params: { scopeId, namespace: props.sourceId }, | |
| 70 | − payload: { | |
| 71 | − name: identity.name.trim() || undefined, | |
| 72 | − endpoint: endpoint.trim() || undefined, | |
| 73 | − headers, | |
| 74 | − queryParams, | |
| 75 | − }, | |
| 76 | − reactivityKeys: sourceWriteKeys, | |
| 77 | − }); | |
| 78 | − setDirty(false); | |
| 79 | − props.onSave(); | |
| 80 | − } catch (e) { | |
| 81 | − setError(e instanceof Error ? e.message : "Failed to update source"); | |
| 82 | − } finally { | |
| 68 | + const exit = await doUpdate({ | |
| 69 | + params: { scopeId, namespace: props.sourceId }, | |
| 70 | + payload: { | |
| 71 | + name: identity.name.trim() || undefined, | |
| 72 | + endpoint: endpoint.trim() || undefined, | |
| 73 | + headers, | |
| 74 | + queryParams, | |
| 75 | + }, | |
| 76 | + reactivityKeys: sourceWriteKeys, | |
| 77 | + }); | |
| 78 | + if (Exit.isFailure(exit)) { | |
| 79 | + setError("Failed to update source"); | |
| 83 | 80 | setSaving(false); |
| 81 | + return; | |
| 84 | 82 | } |
| 83 | + setDirty(false); | |
| 84 | + setSaving(false); | |
| 85 | + props.onSave(); | |
| 85 | 86 | }; |
| 86 | 87 | |
| 87 | 88 | return ( |