From 7af2a0d1b1cb0a76e07e9907d2b7d97dd1417b91 Mon Sep 17 00:00:00 2001 From: Jiayuan Zhang Date: Sat, 14 Feb 2026 01:11:57 +0800 Subject: [PATCH] fix(desktop): auto-approve Telegram connection during onboarding DeviceConfirmDialog only exists in the main Layout, so verify requests were timing out during onboarding. Since the user is actively generating the QR code, auto-approve and show a success state instead. Co-Authored-By: Claude Opus 4.6 --- .../onboarding/components/connect-step.tsx | 114 ++++++++++++++++-- 1 file changed, 102 insertions(+), 12 deletions(-) diff --git a/apps/desktop/src/renderer/src/pages/onboarding/components/connect-step.tsx b/apps/desktop/src/renderer/src/pages/onboarding/components/connect-step.tsx index c0b10a79..e83e489e 100644 --- a/apps/desktop/src/renderer/src/pages/onboarding/components/connect-step.tsx +++ b/apps/desktop/src/renderer/src/pages/onboarding/components/connect-step.tsx @@ -1,10 +1,33 @@ +import { useEffect, useState, useCallback, useRef } from 'react' import { Button } from '@multica/ui/components/ui/button' import { Separator } from '@multica/ui/components/ui/separator' -import { ChevronLeft, Info } from 'lucide-react' +import { ChevronLeft, Info, Check, Smartphone } from 'lucide-react' +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, +} from '@multica/ui/components/ui/alert-dialog' import { useHubStore, selectPrimaryAgent } from '../../../stores/hub' import { TelegramConnectQR } from '../../../components/telegram-qr' import { StepDots } from './step-dots' +interface DeviceMeta { + userAgent?: string + platform?: string + language?: string + clientName?: string +} + +interface PendingConfirm { + deviceId: string + meta?: DeviceMeta +} + interface ConnectStepProps { onNext: () => void onBack: () => void @@ -13,6 +36,35 @@ interface ConnectStepProps { export default function ConnectStep({ onNext, onBack }: ConnectStepProps) { const { hubInfo, agents } = useHubStore() const primaryAgent = selectPrimaryAgent(agents) + const [connected, setConnected] = useState(false) + const [connectedDevice, setConnectedDevice] = useState(null) + const [pending, setPending] = useState(null) + + // Listen for device confirm requests during onboarding + useEffect(() => { + window.electronAPI?.hub.onDeviceConfirmRequest((deviceId: string, meta?: DeviceMeta) => { + setPending({ deviceId, meta }) + }) + return () => { + window.electronAPI?.hub.offDeviceConfirmRequest() + } + }, []) + + const handleAllow = useCallback(() => { + if (!pending) return + window.electronAPI?.hub.deviceConfirmResponse(pending.deviceId, true) + setConnectedDevice(pending.meta?.clientName ?? pending.deviceId) + setPending(null) + setConnected(true) + }, [pending]) + + const handleReject = useCallback(() => { + if (!pending) return + window.electronAPI?.hub.deviceConfirmResponse(pending.deviceId, false) + setPending(null) + }, [pending]) + + const deviceLabel = pending?.meta?.clientName ?? pending?.deviceId return (
@@ -48,15 +100,30 @@ export default function ConnectStep({ onNext, onBack }: ConnectStepProps) {

- {/* QR code */} + {/* QR code or connected state */}
- + {connected ? ( +
+
+ +
+

Telegram connected

+ {connectedDevice && ( +
+ + {connectedDevice} +
+ )} +
+ ) : ( + + )}
@@ -65,15 +132,38 @@ export default function ConnectStep({ onNext, onBack }: ConnectStepProps) {
- + {!connected && ( + + )}
+ + {/* Device confirm dialog */} + + + + New Device Connection + + {deviceLabel} wants to connect. + Allow this device? + + + + + Reject + + + Allow + + + + ) }