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