History

Merge remote-tracking branch 'origin/codex/split-mcp-edit-source-promise-exit' into codex/effect-lint-integration

Rhys Sullivan committed 6 months ago

Commit 2194f3d2 parents 6c44b34 de10d6d1 file · +18 −17Browse files

Unified · Split

packages/plugins/mcp/src/react/EditMcpSource.tsx+18−17
@@ -1,6 +1,7 @@
11 import { useState } from "react";
22 import { useAtomValue, useAtomSet } from "@effect/atom-react";
33 import * as AsyncResult from "effect/unstable/reactivity/AsyncResult";
4+import * as Exit from "effect/Exit";
45 import { mcpSourceAtom, updateMcpSource } from "./atoms";
56 import { useScope } from "@executor-js/react/api/scope-context";
67 import { sourceWriteKeys } from "@executor-js/react/api/reactivity-keys";
@@ -35,7 +36,7 @@ function RemoteEditForm(props: { · 28 unmodified lines
3536 onSave: () => void;
3637 }) {
3738 const scopeId = useScope();
38− const doUpdate = useAtomSet(updateMcpSource, { mode: "promise" });
39+ const doUpdate = useAtomSet(updateMcpSource, { mode: "promiseExit" });
3940 const secretList = useSecretPickerSecrets();
4041
4142 const identity = useSourceIdentity({
@@ -64,24 +65,24 @@ function RemoteEditForm(props: { · 22 unmodified lines
6465 setSaving(true);
6566 setError(null);
6667 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");
8380 setSaving(false);
81+ return;
8482 }
83+ setDirty(false);
84+ setSaving(false);
85+ props.onSave();
8586 };
8687
8788 return (