import { toString as qrToString } from 'qrcode' import * as React from 'react' import { useEffect, useState } from 'react' import { Pane } from '../../components/design-system/Pane.js' import { Box, Text } from '../../ink.js' import { useKeybinding } from '../../keybindings/useKeybinding.js' import { useAppState } from '../../state/AppState.js' import type { LocalJSXCommandCall } from '../../types/command.js' import { logForDebugging } from '../../utils/debug.js' type Props = { onDone: () => void } function SessionInfo({ onDone }: Props): React.ReactNode { const remoteSessionUrl = useAppState(s => s.remoteSessionUrl) const [qrCode, setQrCode] = useState('') // Generate QR code when URL is available useEffect(() => { if (!remoteSessionUrl) return const url = remoteSessionUrl async function generateQRCode(): Promise { const qr = await qrToString(url, { type: 'utf8', errorCorrectionLevel: 'L', }) setQrCode(qr) } // Intentionally silent fail - URL is still shown so QR is non-critical generateQRCode().catch(e => { logForDebugging('QR code generation failed', e) }) }, [remoteSessionUrl]) // Handle ESC to dismiss useKeybinding('confirm:no', onDone, { context: 'Confirmation' }) // Not in remote mode if (!remoteSessionUrl) { return ( Not in remote mode. Start with `claude --remote` to use this command. (press esc to close) ) } const lines = qrCode.split('\n').filter(line => line.length > 0) const isLoading = lines.length === 0 return ( Remote session {/* QR Code - silently fails if generation errors, URL is still shown */} {isLoading ? ( Generating QR code… ) : ( lines.map((line, i) => {line}) )} {/* URL */} Open in browser: {remoteSessionUrl} (press esc to close) ) } export const call: LocalJSXCommandCall = async onDone => { return }