From f7a8776265c9ae919f637d7563c1eba00ee6aa8e Mon Sep 17 00:00:00 2001 From: Gab Date: Thu, 9 Apr 2026 23:08:01 +1000 Subject: [PATCH] fix: dialog --- .../src/cli/cmd/tui/component/dialog-tf-mcp.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/tfcode/src/cli/cmd/tui/component/dialog-tf-mcp.tsx b/packages/tfcode/src/cli/cmd/tui/component/dialog-tf-mcp.tsx index 03c1d5a58..2e412edd6 100644 --- a/packages/tfcode/src/cli/cmd/tui/component/dialog-tf-mcp.tsx +++ b/packages/tfcode/src/cli/cmd/tui/component/dialog-tf-mcp.tsx @@ -143,9 +143,17 @@ export function DialogTfMcp() { duration: 3000, }) } - const status = await sdk.client.mcp.status() - if (status.data) { - sync.set("mcp", reconcile(status.data)) + + // Poll until status reflects the change (MCP SSE handshake is async) + const wantConnected = !isEnabled() + for (let i = 0; i < 10; i++) { + await new Promise((r) => setTimeout(r, 500)) + const status = await sdk.client.mcp.status() + if (status.data) { + sync.set("mcp", reconcile(status.data)) + const current = status.data[TF_MCP_NAME]?.status === "connected" + if (current === wantConnected) break + } } } catch (error) { toast.show({