Skip to content

Commit 2ce55c4

Browse files
authored
todo: Implement MCP connection status polling (#788)
1 parent 239fc12 commit 2ce55c4

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

apps/web/components/connect-ai-modal.tsx

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,18 @@ export function ConnectAIModal({
160160
staleTime: 30 * 1000,
161161
})
162162

163+
const { data: connectionStatus, isLoading: isCheckingConnection } = useQuery({
164+
queryKey: ["mcp-connection"],
165+
queryFn: async () => {
166+
const response = await $fetch("@get/mcp/has-login")
167+
if (response.error) {
168+
throw new Error(response.error?.message || "Failed to check connection")
169+
}
170+
return response.data
171+
},
172+
refetchInterval: 5000,
173+
})
174+
163175
const mcpMigrationForm = useForm({
164176
defaultValues: { url: "" },
165177
onSubmit: async ({ value, formApi }) => {
@@ -733,15 +745,40 @@ export function ConnectAIModal({
733745
</div>
734746
</div>
735747

736-
{/* TODO: Show when connection successful or not */}
737-
{/*<div>
748+
<div className="bg-muted/50 rounded-lg p-4 border border-border">
749+
<div className="flex items-center justify-between mb-3">
750+
<h3 className="text-sm font-medium">Connection Status</h3>
751+
<div className="flex items-center gap-2 text-xs">
752+
{isCheckingConnection ? (
753+
<>
754+
<Loader2 className="w-3 h-3 animate-spin text-muted-foreground" />
755+
<span className="text-muted-foreground">Checking...</span>
756+
</>
757+
) : connectionStatus?.previousLogin ? (
758+
<>
759+
<div className="w-2 h-2 rounded-full bg-green-500" />
760+
<span className="text-green-600 font-medium">
761+
Connected
762+
</span>
763+
</>
764+
) : (
765+
<>
766+
<div className="w-2 h-2 rounded-full bg-yellow-500" />
767+
<span className="text-yellow-600 font-medium">
768+
Waiting for connection...
769+
</span>
770+
</>
771+
)}
772+
</div>
773+
</div>
774+
738775
<h3 className="text-sm font-medium mb-3">What You Can Do</h3>
739776
<ul className="space-y-2 text-sm text-muted-foreground">
740777
<li>• Ask your AI to save important information as memories</li>
741778
<li>• Search through your saved memories during conversations</li>
742779
<li>• Get contextual information from your knowledge base</li>
743780
</ul>
744-
</div>*/}
781+
</div>
745782

746783
<div className="flex justify-between items-center pt-4">
747784
<div className="flex items-center gap-4">

0 commit comments

Comments
 (0)