Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions packages/plugins/mcp/src/react/EditMcpSource.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useState } from "react";
import { useAtomValue, useAtomSet } from "@effect/atom-react";
import * as AsyncResult from "effect/unstable/reactivity/AsyncResult";
import * as Exit from "effect/Exit";
import { mcpSourceAtom, updateMcpSource } from "./atoms";
import { useScope } from "@executor-js/react/api/scope-context";
import { sourceWriteKeys } from "@executor-js/react/api/reactivity-keys";
Expand Down Expand Up @@ -35,7 +36,7 @@ function RemoteEditForm(props: {
onSave: () => void;
}) {
const scopeId = useScope();
const doUpdate = useAtomSet(updateMcpSource, { mode: "promise" });
const doUpdate = useAtomSet(updateMcpSource, { mode: "promiseExit" });
const secretList = useSecretPickerSecrets();

const identity = useSourceIdentity({
Expand Down Expand Up @@ -64,24 +65,24 @@ function RemoteEditForm(props: {
setSaving(true);
setError(null);
const { headers, queryParams } = serializeHttpCredentials(credentials);
try {
await doUpdate({
params: { scopeId, namespace: props.sourceId },
payload: {
name: identity.name.trim() || undefined,
endpoint: endpoint.trim() || undefined,
headers,
queryParams,
},
reactivityKeys: sourceWriteKeys,
});
setDirty(false);
props.onSave();
} catch (e) {
setError(e instanceof Error ? e.message : "Failed to update source");
} finally {
const exit = await doUpdate({
params: { scopeId, namespace: props.sourceId },
payload: {
name: identity.name.trim() || undefined,
endpoint: endpoint.trim() || undefined,
headers,
queryParams,
},
reactivityKeys: sourceWriteKeys,
});
if (Exit.isFailure(exit)) {
setError("Failed to update source");
setSaving(false);
return;
}
setDirty(false);
setSaving(false);
props.onSave();
};

return (
Expand Down
Loading