Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

feat(dashboard): add link-with-phone-number pairing code UI (#551)

Akash sge957700426ed
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2634fb40e..4db4b8c3d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Added
+
+- **Link a WhatsApp session by pairing code from the dashboard.** The session connect modal now offers a "Link with Phone Number" tab next to the QR code: enter a phone number in international format and the dashboard requests an 8-character pairing code — via the existing `POST /sessions/:id/pairing-code` endpoint — to type into WhatsApp on the phone, a QR-free way to link a device. The phone field is constrained to digits with a numeric keypad, the code/instructions are fully localized across all 10 dashboard locales, and the pairing panel is keyboard- and screen-reader-accessible. (#551) Thanks @akash247777.
+
## [0.7.15] - 2026-06-30
### Added
diff --git a/dashboard/src/i18n/locales/ar.json b/dashboard/src/i18n/locales/ar.json
index 69fc6cec2..aac9e5b04 100644
--- a/dashboard/src/i18n/locales/ar.json
+++ b/dashboard/src/i18n/locales/ar.json
@@ -289,6 +289,24 @@
"success": "تم إنهاء الجلسة قسريًا. يمكنك إعادة تشغيلها الآن.",
"failedTitle": "فشل الإنهاء القسري",
"failed": "فشل إنهاء الجلسة قسريًا."
+ },
+ "pairing": {
+ "tabQr": "رمز QR",
+ "tabPhone": "الربط عبر رقم الهاتف",
+ "phoneLabel": "رقم الهاتف",
+ "phonePlaceholder": "مثال: 919876543210",
+ "phoneHint": "أرقام فقط (بدون + أو مسافات أو شرطات) بالصيغة الدولية (رمز الدولة + الرقم).",
+ "invalidPhone": "أدخل رقم هاتف صالحاً: من 6 إلى 15 رقماً، يبدأ برمز الدولة، بدون رموز.",
+ "generateButton": "إنشاء رمز الربط",
+ "generating": "جارٍ إنشاء رمز الربط...",
+ "codeLabel": "رمز الربط الخاص بك",
+ "changeNumber": "تغيير الرقم / طلب رمز جديد",
+ "instructions": "تعليمات الربط",
+ "step1": "<strong>1.</strong> افتح واتساب على هاتفك",
+ "step2": "<strong>2.</strong> اضغط على <strong>القائمة</strong> أو <strong>الإعدادات</strong> واختر <strong>الأجهزة المرتبطة</strong>",
+ "step3": "<strong>3.</strong> اضغط على <strong>ربط جهاز</strong>، ثم اضغط على <strong>الربط عبر رقم الهاتف بدلاً من ذلك</strong>",
+ "step4": "<strong>4.</strong> أدخل الرمز المكوّن من 8 أحرف المعروض أعلاه في هاتفك",
+ "waitingConnection": "في انتظار ربط هاتفك…"
}
},
"webhooks": {
diff --git a/dashboard/src/i18n/locales/en.json b/dashboard/src/i18n/locales/en.json
index 019721794..f58f1fab6 100644
--- a/dashboard/src/i18n/locales/en.json
+++ b/dashboard/src/i18n/locales/en.json
@@ -289,6 +289,24 @@
"success": "Session has been force-killed. You can restart it now.",
"failedTitle": "Force-Kill Failed",
"failed": "Failed to force-kill the session."
+ },
+ "pairing": {
+ "tabQr": "QR Code",
+ "tabPhone": "Link with Phone Number",
+ "phoneLabel": "Phone Number",
+ "phonePlaceholder": "e.g., 919876543210",
+ "phoneHint": "Digits only (no +, spaces, or dashes) in international format (country code + number).",
+ "invalidPhone": "Enter a valid phone number: 6–15 digits, country code first, no symbols.",
+ "generateButton": "Generate Pairing Code",
+ "generating": "Generating pairing code...",
+ "codeLabel": "Your Pairing Code",
+ "changeNumber": "Change Number / Request New Code",
+ "instructions": "Pairing Instructions",
+ "step1": "<strong>1.</strong> Open WhatsApp on your phone",
+ "step2": "<strong>2.</strong> Tap <strong>Menu</strong> or <strong>Settings</strong> and select <strong>Linked Devices</strong>",
+ "step3": "<strong>3.</strong> Tap <strong>Link a Device</strong>, then tap <strong>Link with phone number instead</strong>",
+ "step4": "<strong>4.</strong> Enter the 8-character code shown above on your phone",
+ "waitingConnection": "Waiting for your phone to link…"
}
},
"webhooks": {
diff --git a/dashboard/src/i18n/locales/es.json b/dashboard/src/i18n/locales/es.json
index 3d1130644..125e957ae 100644
--- a/dashboard/src/i18n/locales/es.json
+++ b/dashboard/src/i18n/locales/es.json
@@ -289,6 +289,24 @@
"success": "La sesión se cerró de forma forzada. Ya puedes reiniciarla.",
"failedTitle": "Error al forzar el cierre",
"failed": "No se pudo forzar el cierre de la sesión."
+ },
+ "pairing": {
+ "tabQr": "Código QR",
+ "tabPhone": "Vincular con número de teléfono",
+ "phoneLabel": "Número de teléfono",
+ "phonePlaceholder": "ej., 919876543210",
+ "phoneHint": "Solo dígitos (sin +, espacios ni guiones) en formato internacional (código de país + número).",
+ "invalidPhone": "Introduce un número de teléfono válido: 6-15 dígitos, primero el código de país, sin símbolos.",
+ "generateButton": "Generar código de vinculación",
+ "generating": "Generando código de vinculación...",
+ "codeLabel": "Tu código de vinculación",
+ "changeNumber": "Cambiar número / Solicitar nuevo código",
+ "instructions": "Instrucciones de vinculación",
+ "step1": "<strong>1.</strong> Abre WhatsApp en tu teléfono",
+ "step2": "<strong>2.</strong> Toca <strong>Menú</strong> o <strong>Ajustes</strong> y selecciona <strong>Dispositivos vinculados</strong>",
+ "step3": "<strong>3.</strong> Toca <strong>Vincular dispositivo</strong> y luego toca <strong>Vincular con número de teléfono</strong>",
+ "step4": "<strong>4.</strong> Introduce en tu teléfono el código de 8 caracteres que se muestra arriba",
+ "waitingConnection": "Esperando a que tu teléfono se vincule…"
}
},
"webhooks": {
diff --git a/dashboard/src/i18n/locales/fr.json b/dashboard/src/i18n/locales/fr.json
index 40df105f8..22a4e7545 100644
--- a/dashboard/src/i18n/locales/fr.json
+++ b/dashboard/src/i18n/locales/fr.json
@@ -289,6 +289,24 @@
"success": "L'arrêt forcé de la session a réussi. Vous pouvez la redémarrer maintenant.",
"failedTitle": "Échec de l'arrêt forcé",
"failed": "Échec de l'arrêt forcé de la session."
+ },
+ "pairing": {
+ "tabQr": "Code QR",
+ "tabPhone": "Lier avec un numéro de téléphone",
+ "phoneLabel": "Numéro de téléphone",
+ "phonePlaceholder": "ex. : 919876543210",
+ "phoneHint": "Chiffres uniquement (sans +, espaces ni tirets) au format international (indicatif du pays + numéro).",
+ "invalidPhone": "Saisissez un numéro de téléphone valide : 6 à 15 chiffres, indicatif du pays en premier, sans symboles.",
+ "generateButton": "Générer le code de liaison",
+ "generating": "Génération du code de liaison...",
+ "codeLabel": "Votre code de liaison",
+ "changeNumber": "Changer de numéro / Demander un nouveau code",
+ "instructions": "Instructions de liaison",
+ "step1": "<strong>1.</strong> Ouvrez WhatsApp sur votre téléphone",
+ "step2": "<strong>2.</strong> Appuyez sur <strong>Menu</strong> ou <strong>Paramètres</strong> et sélectionnez <strong>Appareils connectés</strong>",
+ "step3": "<strong>3.</strong> Appuyez sur <strong>Connecter un appareil</strong>, puis sur <strong>Lier avec un numéro de téléphone</strong>",
+ "step4": "<strong>4.</strong> Saisissez sur votre téléphone le code à 8 caractères affiché ci-dessus",
+ "waitingConnection": "En attente de la liaison de votre téléphone…"
}
},
"webhooks": {
diff --git a/dashboard/src/i18n/locales/he.json b/dashboard/src/i18n/locales/he.json
index 5f6292beb..0e56f53ec 100644
--- a/dashboard/src/i18n/locales/he.json
+++ b/dashboard/src/i18n/locales/he.json
@@ -289,6 +289,24 @@
"success": "הסשן נסגר בכוח. ניתן להפעיל אותו מחדש כעת.",
"failedTitle": "הסגירה בכוח נכשלה",
"failed": "סגירת הסשן בכוח נכשלה."
+ },
+ "pairing": {
+ "tabQr": "קוד QR",
+ "tabPhone": "קישור עם מספר טלפון",
+ "phoneLabel": "מספר טלפון",
+ "phonePlaceholder": "לדוגמה: 919876543210",
+ "phoneHint": "ספרות בלבד (ללא +, רווחים או מקפים) בפורמט בין-לאומי (קידומת מדינה + מספר).",
+ "invalidPhone": "יש להזין מספר טלפון תקין: 6–15 ספרות, קידומת המדינה תחילה, ללא סימנים.",
+ "generateButton": "יצירת קוד קישור",
+ "generating": "יוצר קוד קישור...",
+ "codeLabel": "קוד הקישור שלך",
+ "changeNumber": "שינוי מספר / בקשת קוד חדש",
+ "instructions": "הוראות קישור",
+ "step1": "<strong>1.</strong> יש לפתוח את WhatsApp במכשיר",
+ "step2": "<strong>2.</strong> יש להקיש על <strong>תפריט</strong> או <strong>הגדרות</strong> ולבחור <strong>מכשירים מקושרים</strong>",
+ "step3": "<strong>3.</strong> יש להקיש על <strong>קישור מכשיר</strong>, ולאחר מכן על <strong>קישור עם מספר טלפון במקום זאת</strong>",
+ "step4": "<strong>4.</strong> יש להזין במכשיר את הקוד בן 8 התווים המוצג למעלה",
+ "waitingConnection": "ממתין לקישור המכשיר שלך…"
}
},
"webhooks": {
diff --git a/dashboard/src/i18n/locales/it.json b/dashboard/src/i18n/locales/it.json
index 1b852dde7..7db90d1b5 100644
--- a/dashboard/src/i18n/locales/it.json
+++ b/dashboard/src/i18n/locales/it.json
@@ -289,6 +289,24 @@
"success": "La sessione è stata terminata forzatamente. Puoi riavviarla ora.",
"failedTitle": "Terminazione forzata non riuscita",
"failed": "Impossibile terminare forzatamente la sessione."
+ },
+ "pairing": {
+ "tabQr": "Codice QR",
+ "tabPhone": "Collega con numero di telefono",
+ "phoneLabel": "Numero di Telefono",
+ "phonePlaceholder": "es., 919876543210",
+ "phoneHint": "Solo cifre (senza +, spazi o trattini) in formato internazionale (prefisso del paese + numero).",
+ "invalidPhone": "Inserisci un numero di telefono valido: 6–15 cifre, prefisso del paese per primo, senza simboli.",
+ "generateButton": "Genera codice di abbinamento",
+ "generating": "Generazione del codice di abbinamento in corso...",
+ "codeLabel": "Il tuo codice di abbinamento",
+ "changeNumber": "Cambia numero / Richiedi nuovo codice",
+ "instructions": "Istruzioni per l'abbinamento",
+ "step1": "<strong>1.</strong> Apri WhatsApp sul tuo telefono",
+ "step2": "<strong>2.</strong> Tocca <strong>Menu</strong> o <strong>Impostazioni</strong> e seleziona <strong>Dispositivi collegati</strong>",
+ "step3": "<strong>3.</strong> Tocca <strong>Collega un dispositivo</strong>, poi tocca <strong>Collega con numero di telefono</strong>",
+ "step4": "<strong>4.</strong> Inserisci sul tuo telefono il codice di 8 caratteri mostrato sopra",
+ "waitingConnection": "In attesa del collegamento del tuo telefono…"
}
},
"webhooks": {
diff --git a/dashboard/src/i18n/locales/pt-BR.json b/dashboard/src/i18n/locales/pt-BR.json
index b75ef4e1a..82bb65d63 100644
--- a/dashboard/src/i18n/locales/pt-BR.json
+++ b/dashboard/src/i18n/locales/pt-BR.json
@@ -289,6 +289,24 @@
"success": "A sessão foi encerrada forçadamente. Você pode reiniciá-la agora.",
"failedTitle": "Falha no encerramento forçado",
"failed": "Não foi possível forçar o encerramento da sessão."
+ },
+ "pairing": {
+ "tabQr": "Código QR",
+ "tabPhone": "Vincular com número de telefone",
+ "phoneLabel": "Número de telefone",
+ "phonePlaceholder": "ex.: 919876543210",
+ "phoneHint": "Apenas dígitos (sem +, espaços ou hífens) no formato internacional (código do país + número).",
+ "invalidPhone": "Informe um número de telefone válido: 6–15 dígitos, com o código do país primeiro e sem símbolos.",
+ "generateButton": "Gerar código de conexão",
+ "generating": "Gerando código de conexão...",
+ "codeLabel": "Seu código de conexão",
+ "changeNumber": "Alterar número / Solicitar novo código",
+ "instructions": "Instruções de conexão",
+ "step1": "<strong>1.</strong> Abra o WhatsApp no seu celular",
+ "step2": "<strong>2.</strong> Toque em <strong>Menu</strong> ou <strong>Configurações</strong> e selecione <strong>Dispositivos conectados</strong>",
+ "step3": "<strong>3.</strong> Toque em <strong>Conectar dispositivo</strong> e depois em <strong>Vincular com número de telefone</strong>",
+ "step4": "<strong>4.</strong> Digite no seu celular o código de 8 caracteres mostrado acima",
+ "waitingConnection": "Aguardando a conexão do seu celular…"
}
},
"webhooks": {
diff --git a/dashboard/src/i18n/locales/te.json b/dashboard/src/i18n/locales/te.json
index 912279b4d..070fb8a12 100644
--- a/dashboard/src/i18n/locales/te.json
+++ b/dashboard/src/i18n/locales/te.json
@@ -289,6 +289,24 @@
"success": "సెషన్ బలవంతంగా ఆపబడింది. మీరు ఇప్పుడు దాన్ని పునఃప్రారంభించవచ్చు.",
"failedTitle": "బలవంతంగా ఆపడం విఫలమైంది",
"failed": "సెషన్‌ను బలవంతంగా ఆపడం విఫలమైంది."
+ },
+ "pairing": {
+ "tabQr": "QR కోడ్",
+ "tabPhone": "ఫోన్ నంబర్‌తో లింక్ చేయండి",
+ "phoneLabel": "ఫోన్ నంబర్",
+ "phonePlaceholder": "ఉదాహరణకు, 919876543210",
+ "phoneHint": "అంతర్జాతీయ ఆకృతిలో (కంట్రీ కోడ్ + నంబర్) సంఖ్యలు మాత్రమే (+, ఖాళీలు, లేదా డాష్‌లు లేకుండా).",
+ "invalidPhone": "చెల్లుబాటు అయ్యే ఫోన్ నంబర్‌ను నమోదు చేయండి: 6–15 సంఖ్యలు, ముందుగా కంట్రీ కోడ్, ఎలాంటి చిహ్నాలు లేకుండా.",
+ "generateButton": "పెయిరింగ్ కోడ్‌ను రూపొందించండి",
+ "generating": "పెయిరింగ్ కోడ్‌ను రూపొందిస్తోంది...",
+ "codeLabel": "మీ పెయిరింగ్ కోడ్",
+ "changeNumber": "నంబర్ మార్చు / కొత్త కోడ్‌ను అభ్యర్థించు",
+ "instructions": "పెయిరింగ్ సూచనలు",
+ "step1": "<strong>1.</strong> మీ ఫోన్‌లో వాట్సాప్ తెరవండి",
+ "step2": "<strong>2.</strong> <strong>మెనూ</strong> లేదా <strong>Settings</strong> పై నొక్కి, <strong>Linked Devices</strong> ఎంచుకోండి",
+ "step3": "<strong>3.</strong> <strong>Link a Device</strong> పై నొక్కి, ఆపై <strong>Link with phone number instead</strong> పై నొక్కండి",
+ "step4": "<strong>4.</strong> పైన చూపిన 8-అక్షరాల కోడ్‌ను మీ ఫోన్‌లో నమోదు చేయండి",
+ "waitingConnection": "మీ ఫోన్ లింక్ అయ్యే వరకు వేచి ఉంది…"
}
},
"webhooks": {
diff --git a/dashboard/src/i18n/locales/zh-CN.json b/dashboard/src/i18n/locales/zh-CN.json
index 8494dbba6..78c45be7b 100644
--- a/dashboard/src/i18n/locales/zh-CN.json
+++ b/dashboard/src/i18n/locales/zh-CN.json
@@ -289,6 +289,24 @@
"success": "会话已被强制终止。您现在可以重新启动它。",
"failedTitle": "强制终止失败",
"failed": "强制终止会话失败。"
+ },
+ "pairing": {
+ "tabQr": "QR 码",
+ "tabPhone": "使用电话号码关联",
+ "phoneLabel": "电话号码",
+ "phonePlaceholder": "例如:919876543210",
+ "phoneHint": "仅填数字(不含 +、空格或连字符),使用国际格式(国家/地区代码 + 号码)。",
+ "invalidPhone": "请输入有效的电话号码:6–15 位数字,国家/地区代码在前,不含任何符号。",
+ "generateButton": "生成配对码",
+ "generating": "正在生成配对码...",
+ "codeLabel": "您的配对码",
+ "changeNumber": "更换号码 / 重新获取配对码",
+ "instructions": "配对说明",
+ "step1": "<strong>1.</strong> 在手机上打开 WhatsApp",
+ "step2": "<strong>2.</strong> 点击<strong>菜单</strong>或<strong>设置</strong>,然后选择<strong>已关联设备</strong>",
+ "step3": "<strong>3.</strong> 点击<strong>关联设备</strong>,然后点击<strong>改用电话号码关联</strong>",
+ "step4": "<strong>4.</strong> 在手机上输入上方显示的 8 位字符配对码",
+ "waitingConnection": "正在等待您的手机完成关联…"
}
},
"webhooks": {
diff --git a/dashboard/src/i18n/locales/zh-HK.json b/dashboard/src/i18n/locales/zh-HK.json
index 729f0f408..45fc479f8 100644
--- a/dashboard/src/i18n/locales/zh-HK.json
+++ b/dashboard/src/i18n/locales/zh-HK.json
@@ -289,6 +289,24 @@
"success": "工作階段已強制終止。你現在可以重新啟動它。",
"failedTitle": "強制終止失敗",
"failed": "無法強制終止工作階段。"
+ },
+ "pairing": {
+ "tabQr": "QR 碼",
+ "tabPhone": "以電話號碼連結",
+ "phoneLabel": "電話號碼",
+ "phonePlaceholder": "例如:919876543210",
+ "phoneHint": "只可輸入數字(不可有 +、空格或連字號),須為國際格式(國家代碼 + 號碼)。",
+ "invalidPhone": "請輸入有效的電話號碼:6 至 15 位數字,國家代碼在前,不可有符號。",
+ "generateButton": "產生配對碼",
+ "generating": "正在產生配對碼...",
+ "codeLabel": "你的配對碼",
+ "changeNumber": "更改號碼/重新索取配對碼",
+ "instructions": "配對說明",
+ "step1": "<strong>1.</strong> 在手機上開啟 WhatsApp",
+ "step2": "<strong>2.</strong> 點按<strong>選單</strong>或<strong>設定</strong>,然後選擇<strong>已連結裝置</strong>",
+ "step3": "<strong>3.</strong> 點按<strong>連結裝置</strong>,然後點按<strong>改用電話號碼連結</strong>",
+ "step4": "<strong>4.</strong> 在手機上輸入上方顯示的 8 位字元配對碼",
+ "waitingConnection": "正在等待你的手機完成連結…"
}
},
"webhooks": {
diff --git a/dashboard/src/pages/Sessions.css b/dashboard/src/pages/Sessions.css
index 1d5160e22..d79f0c1da 100644
--- a/dashboard/src/pages/Sessions.css
+++ b/dashboard/src/pages/Sessions.css
@@ -1,15 +1,15 @@
-.sessions-page{
+.sessions-page {
padding: 2rem;
width: 100%;
box-sizing: border-box;
}
-.sessions-page .page-header{
+.sessions-page .page-header {
margin-bottom: 2rem;
width: 100%;
}
-.sessions-page .header-content{
+.sessions-page .header-content {
display: flex;
justify-content: space-between;
align-items: center;
@@ -19,7 +19,7 @@
/* H1 inherited from global */
-.sessions-page .btn-primary{
+.sessions-page .btn-primary {
display: flex;
align-items: center;
gap: 0.5rem;
@@ -34,17 +34,17 @@
transition: background 0.2s;
}
-.sessions-page .btn-primary:hover{
+.sessions-page .btn-primary:hover {
background: var(--primary-hover);
}
-.sessions-page .filters-bar{
+.sessions-page .filters-bar {
display: flex;
gap: 1rem;
margin-bottom: 1.5rem;
}
-.sessions-page .search-input{
+.sessions-page .search-input {
display: flex;
align-items: center;
gap: 0.75rem;
@@ -56,12 +56,12 @@
border-radius: var(--radius);
}
-.sessions-page .search-input svg{
+.sessions-page .search-input svg {
color: var(--text-muted);
flex-shrink: 0;
}
-.sessions-page .search-input input{
+.sessions-page .search-input input {
flex: 1;
border: none;
background: none;
@@ -69,11 +69,11 @@
color: var(--text-primary);
}
-.sessions-page .search-input input:focus{
+.sessions-page .search-input input:focus {
outline: none;
}
-.sessions-page .filter-group{
+.sessions-page .filter-group {
display: flex;
align-items: center;
gap: 0.5rem;
@@ -83,11 +83,11 @@
border-radius: var(--radius);
}
-.sessions-page .filter-group svg{
+.sessions-page .filter-group svg {
color: var(--text-muted);
}
-.sessions-page .filter-group select{
+.sessions-page .filter-group select {
padding: 0.75rem 0;
border: none;
background: none;
@@ -97,19 +97,19 @@
cursor: pointer;
}
-.sessions-page .filter-group select:focus{
+.sessions-page .filter-group select:focus {
outline: none;
box-shadow: none;
}
-.sessions-page .sessions-grid{
+.sessions-page .sessions-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 1.5rem;
width: 100%;
}
-.sessions-page .session-card{
+.sessions-page .session-card {
background: var(--bg-white);
border-radius: 12px;
padding: 1.5rem;
@@ -117,14 +117,14 @@
border: 1px solid var(--border);
}
-.sessions-page .card-header{
+.sessions-page .card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1.25rem;
}
-.sessions-page .card-header h3{
+.sessions-page .card-header h3 {
/* Inherits from H3 */
margin: 0;
white-space: nowrap;
@@ -133,7 +133,7 @@
max-width: 180px;
}
-.sessions-page .qr-placeholder{
+.sessions-page .qr-placeholder {
display: flex;
flex-direction: column;
align-items: center;
@@ -144,33 +144,33 @@
margin-bottom: 1rem;
}
-.sessions-page .qr-icon{
+.sessions-page .qr-icon {
color: var(--text-muted);
margin-bottom: 0.75rem;
}
-.sessions-page .qr-placeholder p{
+.sessions-page .qr-placeholder p {
margin: 0;
color: var(--text-secondary);
font-size: 0.875rem;
}
-.sessions-page .session-info{
+.sessions-page .session-info {
margin-bottom: 1rem;
}
-.sessions-page .info-row{
+.sessions-page .info-row {
display: flex;
justify-content: space-between;
padding: 0.5rem 0;
border-bottom: 1px solid var(--border);
}
-.sessions-page .info-row:last-child{
+.sessions-page .info-row:last-child {
border-bottom: none;
}
-.sessions-page .info-label{
+.sessions-page .info-label {
font-size: 0.7rem;
font-weight: 600;
text-transform: uppercase;
@@ -178,17 +178,17 @@
color: var(--text-secondary);
}
-.sessions-page .info-value{
+.sessions-page .info-value {
font-size: 0.8125rem;
color: var(--text-primary);
font-weight: 500;
}
-.sessions-page .info-value.mono{
+.sessions-page .info-value.mono {
font-family: monospace;
}
-.sessions-page .info-value.error-text{
+.sessions-page .info-value.error-text {
color: var(--color-danger, #dc2626);
font-weight: 500;
max-width: 60%;
@@ -198,13 +198,13 @@
white-space: nowrap;
}
-.sessions-page .card-actions{
+.sessions-page .card-actions {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
}
-.sessions-page .btn-action{
+.sessions-page .btn-action {
display: flex;
align-items: center;
gap: 0.375rem;
@@ -219,91 +219,91 @@
color: var(--text-secondary);
}
-.sessions-page .btn-action:hover{
+.sessions-page .btn-action:hover {
background: var(--bg-white);
color: var(--text-primary);
}
-.sessions-page .btn-action.danger{
+.sessions-page .btn-action.danger {
color: #dc2626;
}
-.sessions-page .btn-action.danger:hover{
+.sessions-page .btn-action.danger:hover {
background: #fee2e2;
border-color: #fecaca;
}
@media (max-width: 1400px) {
- .sessions-page .sessions-grid{
+ .sessions-page .sessions-grid {
grid-template-columns: repeat(3, 1fr);
}
}
@media (max-width: 1000px) {
- .sessions-page .sessions-grid{
+ .sessions-page .sessions-grid {
grid-template-columns: repeat(2, 1fr);
}
}
@media (max-width: 600px) {
- .sessions-page .sessions-grid{
+ .sessions-page .sessions-grid {
grid-template-columns: 1fr;
}
- .sessions-page{
+ .sessions-page {
padding: 1rem;
}
- .sessions-page .filters-bar{
+ .sessions-page .filters-bar {
flex-direction: column;
gap: 0.75rem;
}
- .sessions-page .search-input{
+ .sessions-page .search-input {
max-width: none;
}
- .sessions-page .filter-group{
+ .sessions-page .filter-group {
width: 100%;
justify-content: space-between;
}
- .sessions-page .filter-group select{
+ .sessions-page .filter-group select {
flex: 1;
}
- .sessions-page .header-content{
+ .sessions-page .header-content {
flex-direction: column;
align-items: stretch;
gap: 1rem;
}
- .sessions-page .btn-primary{
+ .sessions-page .btn-primary {
width: 100%;
justify-content: center;
}
- .sessions-page .session-card{
+ .sessions-page .session-card {
padding: 1rem;
}
- .sessions-page .card-actions{
+ .sessions-page .card-actions {
flex-direction: column;
}
- .sessions-page .card-actions .btn-action{
+ .sessions-page .card-actions .btn-action {
justify-content: center;
}
}
@media (max-width: 480px) {
- .sessions-page{
+ .sessions-page {
padding: 0.75rem;
}
}
/* Modal Overlay */
-.sessions-page .modal-overlay{
+.sessions-page .modal-overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.5);
@@ -325,7 +325,7 @@
}
/* Modal Card */
-.sessions-page .modal{
+.sessions-page .modal {
background: var(--bg-white);
border-radius: 16px;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
@@ -346,7 +346,7 @@
}
}
-.sessions-page .modal-header{
+.sessions-page .modal-header {
display: flex;
justify-content: space-between;
align-items: center;
@@ -354,30 +354,30 @@
border-bottom: 1px solid var(--border);
}
-.sessions-page .modal-header h2{
+.sessions-page .modal-header h2 {
font-size: 1.25rem;
font-weight: 700;
color: var(--text-primary);
margin: 0;
}
-.sessions-page .modal-title{
+.sessions-page .modal-title {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
-.sessions-page .session-name{
+.sessions-page .session-name {
font-size: 0.875rem;
font-weight: 500;
color: var(--text-muted);
}
-.sessions-page .modal-body{
+.sessions-page .modal-body {
padding: 1.5rem;
}
-.sessions-page .modal-body > label{
+.sessions-page .modal-body > label {
display: block;
font-size: 0.875rem;
font-weight: 600;
@@ -385,7 +385,7 @@
margin-bottom: 0.5rem;
}
-.sessions-page .modal-body input{
+.sessions-page .modal-body input {
width: 100%;
padding: 0.875rem 1rem;
border: 1px solid var(--border);
@@ -396,24 +396,24 @@
box-sizing: border-box;
}
-.sessions-page .modal-body input:focus{
+.sessions-page .modal-body input:focus {
outline: none;
border-color: var(--primary);
background: var(--bg-white);
box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}
-.sessions-page .modal-body input::placeholder{
+.sessions-page .modal-body input::placeholder {
color: var(--text-muted);
}
-.sessions-page .input-hint{
+.sessions-page .input-hint {
margin: 0.5rem 0 0;
font-size: 0.75rem;
color: var(--text-muted);
}
-.sessions-page .input-hint code{
+.sessions-page .input-hint code {
background: var(--bg-light);
padding: 0.125rem 0.375rem;
border-radius: 4px;
@@ -421,14 +421,14 @@
font-size: 0.7rem;
}
-.sessions-page .input-error{
+.sessions-page .input-error {
margin: 0.5rem 0 0;
font-size: 0.75rem;
color: #dc2626;
font-weight: 500;
}
-.sessions-page .modal-footer{
+.sessions-page .modal-footer {
display: flex;
justify-content: flex-end;
gap: 0.75rem;
@@ -436,7 +436,7 @@
}
/* Secondary Button */
-.sessions-page .btn-secondary{
+.sessions-page .btn-secondary {
padding: 0.75rem 1.25rem;
background: var(--bg-light);
color: var(--text-secondary);
@@ -448,13 +448,13 @@
transition: all 0.2s;
}
-.sessions-page .btn-secondary:hover{
+.sessions-page .btn-secondary:hover {
background: var(--bg-white);
border-color: var(--text-muted);
color: var(--text-primary);
}
-.sessions-page .btn-danger{
+.sessions-page .btn-danger {
padding: 0.75rem 1.25rem;
background: #dc2626;
color: white;
@@ -465,25 +465,25 @@
transition: all 0.2s;
}
-.sessions-page .btn-danger:hover{
+.sessions-page .btn-danger:hover {
background: #b91c1c;
}
-.sessions-page .confirm-modal{
+.sessions-page .confirm-modal {
max-width: 400px;
}
-.sessions-page .confirm-modal .modal-body p{
+.sessions-page .confirm-modal .modal-body p {
margin: 0 0 0.5rem 0;
}
-.sessions-page .text-muted{
+.sessions-page .text-muted {
color: var(--text-muted);
font-size: 0.875rem;
}
/* Icon Button */
-.sessions-page .btn-icon{
+.sessions-page .btn-icon {
display: flex;
align-items: center;
justify-content: center;
@@ -497,13 +497,13 @@
transition: all 0.2s;
}
-.sessions-page .btn-icon:hover{
+.sessions-page .btn-icon:hover {
background: var(--bg-light);
color: var(--text-primary);
}
/* Empty State */
-.sessions-page .empty-state{
+.sessions-page .empty-state {
grid-column: 1 / -1;
display: flex;
flex-direction: column;
@@ -514,25 +514,25 @@
color: var(--text-muted);
}
-.sessions-page .empty-state svg{
+.sessions-page .empty-state svg {
margin-bottom: 1rem;
opacity: 0.5;
}
-.sessions-page .empty-state h3{
+.sessions-page .empty-state h3 {
font-size: 1.125rem;
font-weight: 600;
color: var(--text-secondary);
margin: 0 0 0.5rem;
}
-.sessions-page .empty-state p{
+.sessions-page .empty-state p {
margin: 0;
font-size: 0.875rem;
}
/* Status Badge */
-.sessions-page .status-badge{
+.sessions-page .status-badge {
display: inline-flex;
align-items: center;
gap: 0.375rem;
@@ -544,22 +544,22 @@
letter-spacing: 0.03em;
}
-.sessions-page .status-badge.connected{
+.sessions-page .status-badge.connected {
background: rgba(34, 197, 94, 0.1);
color: #16a34a;
}
-.sessions-page .status-badge.disconnected{
+.sessions-page .status-badge.disconnected {
background: rgba(107, 114, 128, 0.1);
color: #6b7280;
}
-.sessions-page .status-badge.connecting{
+.sessions-page .status-badge.connecting {
background: rgba(234, 179, 8, 0.1);
color: #ca8a04;
}
-.sessions-page .status-badge::before{
+.sessions-page .status-badge::before {
content: '';
width: 6px;
height: 6px;
@@ -568,18 +568,18 @@
}
/* Detail Grid for Session Modal */
-.sessions-page .detail-grid{
+.sessions-page .detail-grid {
display: grid;
gap: 1rem;
}
-.sessions-page .detail-item{
+.sessions-page .detail-item {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
-.sessions-page .detail-label{
+.sessions-page .detail-label {
font-size: 0.75rem;
font-weight: 600;
text-transform: uppercase;
@@ -587,13 +587,13 @@
color: var(--text-muted);
}
-.sessions-page .detail-value{
+.sessions-page .detail-value {
font-size: 0.9375rem;
color: var(--text-primary);
word-break: break-all;
}
-.sessions-page .detail-value.mono{
+.sessions-page .detail-value.mono {
font-family: 'JetBrains Mono', monospace;
font-size: 0.8125rem;
background: var(--bg-light);
@@ -602,7 +602,7 @@
}
/* Close Button - Always Visible */
-.sessions-page .btn-close{
+.sessions-page .btn-close {
display: flex;
align-items: center;
justify-content: center;
@@ -617,29 +617,29 @@
flex-shrink: 0;
}
-.sessions-page .btn-close svg{
+.sessions-page .btn-close svg {
width: 20px !important;
height: 20px !important;
min-width: 20px;
flex-shrink: 0;
}
-.sessions-page .btn-close:hover{
+.sessions-page .btn-close:hover {
background: #fee2e2;
border-color: #fecaca;
color: #dc2626;
}
-.sessions-page .btn-close:hover svg{
+.sessions-page .btn-close:hover svg {
stroke: #dc2626;
}
/* QR Modal Specific */
-.sessions-page .qr-modal .modal-body{
+.sessions-page .qr-modal .modal-body {
padding: 1.5rem;
}
-.sessions-page .qr-instructions{
+.sessions-page .qr-instructions {
margin-top: 1.5rem;
text-align: left;
background: var(--bg-light);
@@ -647,7 +647,7 @@
padding: 1rem 1.25rem;
}
-.sessions-page .qr-step{
+.sessions-page .qr-step {
margin: 0;
padding: 0.5rem 0;
font-size: 0.875rem;
@@ -655,15 +655,15 @@
border-bottom: 1px solid var(--border);
}
-.sessions-page .qr-step:last-child{
+.sessions-page .qr-step:last-child {
border-bottom: none;
}
-.sessions-page .qr-step strong{
+.sessions-page .qr-step strong {
color: var(--text-primary);
}
-.sessions-page .qr-auto-refresh{
+.sessions-page .qr-auto-refresh {
display: flex;
align-items: center;
justify-content: center;
@@ -673,7 +673,7 @@
color: var(--text-muted);
}
-.sessions-page .spin-slow{
+.sessions-page .spin-slow {
animation: spin 2s linear infinite;
}
@@ -687,7 +687,7 @@
}
/* Status Pill for Card Headers */
-.sessions-page .status-pill{
+.sessions-page .status-pill {
display: inline-flex;
padding: 0.25rem 0.75rem;
border-radius: 20px;
@@ -696,33 +696,35 @@
text-transform: capitalize;
}
-.sessions-page .status-pill.created, .sessions-page .status-pill.idle{
+.sessions-page .status-pill.created,
+.sessions-page .status-pill.idle {
background: rgba(107, 114, 128, 0.1);
color: #6b7280;
}
-.sessions-page .status-pill.initializing, .sessions-page .status-pill.connecting{
+.sessions-page .status-pill.initializing,
+.sessions-page .status-pill.connecting {
background: rgba(234, 179, 8, 0.1);
color: #ca8a04;
}
-.sessions-page .status-pill.qr_ready{
+.sessions-page .status-pill.qr_ready {
background: rgba(59, 130, 246, 0.1);
color: #2563eb;
}
-.sessions-page .status-pill.ready{
+.sessions-page .status-pill.ready {
background: rgba(34, 197, 94, 0.1);
color: #16a34a;
}
-.sessions-page .status-pill.disconnected{
+.sessions-page .status-pill.disconnected {
background: rgba(239, 68, 68, 0.1);
color: #dc2626;
}
/* Small Button for QR Placeholder */
-.sessions-page .btn-sm{
+.sessions-page .btn-sm {
padding: 0.5rem 1rem;
font-size: 0.8125rem;
font-weight: 600;
@@ -735,6 +737,94 @@
transition: background 0.2s;
}
-.sessions-page .btn-sm:hover{
+.sessions-page .btn-sm:hover {
background: var(--primary-hover);
}
+
+/* Pairing Code Mode Specific Styles */
+.sessions-page .pairing-tabs {
+ display: flex;
+ gap: 0.5rem;
+ margin-bottom: 1.5rem;
+ background: var(--bg-light);
+ padding: 0.25rem;
+ border-radius: 8px;
+}
+
+.sessions-page .pairing-tab-btn {
+ flex: 1;
+ padding: 0.5rem;
+ background: transparent;
+ border: none;
+ border-radius: 6px;
+ font-size: 0.875rem;
+ font-weight: 600;
+ color: var(--text-secondary);
+ cursor: pointer;
+ transition: all 0.2s;
+}
+
+.sessions-page .pairing-tab-btn.active {
+ background: var(--bg-white);
+ color: var(--text-primary);
+ box-shadow: var(--shadow-sm);
+}
+
+.sessions-page .pairing-container {
+ padding: 0.5rem 0;
+}
+
+.sessions-page .pairing-error {
+ margin-bottom: 1rem;
+ padding: 0.75rem;
+ border-radius: 8px;
+ font-size: 0.875rem;
+ text-align: left;
+ color: var(--error);
+ background: rgb(239 68 68 / 0.12);
+}
+
+.sessions-page .pairing-form {
+ text-align: left;
+}
+
+.sessions-page .pairing-label {
+ display: block;
+ margin-bottom: 0.5rem;
+ font-weight: 600;
+}
+
+.sessions-page .pairing-input {
+ width: 100%;
+ padding: 0.875rem 1rem;
+ border: 1px solid var(--border);
+ border-radius: var(--radius);
+ font-size: 0.9375rem;
+ background: var(--bg-light);
+ margin-bottom: 0.5rem;
+ box-sizing: border-box;
+}
+
+.sessions-page .pairing-code-display {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 0.75rem;
+ font-size: 2rem;
+ font-weight: 700;
+ color: var(--primary);
+ background: var(--bg-light);
+ border: 2px dashed var(--border);
+ padding: 1rem 2rem;
+ border-radius: 12px;
+ letter-spacing: 0.1em;
+ font-family: 'JetBrains Mono', monospace;
+ margin: 1.5rem 0;
+}
+
+.sessions-page .pairing-instructions-title {
+ margin: 0 0 0.5rem;
+ font-weight: 600;
+ font-size: 0.9375rem;
+ color: var(--text-primary);
+}
diff --git a/dashboard/src/pages/Sessions.tsx b/dashboard/src/pages/Sessions.tsx
index 17e89c21e..c2df97ba4 100644
--- a/dashboard/src/pages/Sessions.tsx
+++ b/dashboard/src/pages/Sessions.tsx
@@ -24,6 +24,11 @@ export function Sessions() {
const [newSessionName, setNewSessionName] = useState('');
const [creating, setCreating] = useState(false);
const [qrData, setQrData] = useState<{ sessionId: string; sessionName: string; qrCode: string } | null>(null);
+ const [pairingMode, setPairingMode] = useState(false);
+ const [phoneNumber, setPhoneNumber] = useState('');
+ const [pairingCode, setPairingCode] = useState<string | null>(null);
+ const [requestingPairing, setRequestingPairing] = useState(false);
+ const [pairingError, setPairingError] = useState<string | null>(null);
const [searchQuery, setSearchQuery] = useState('');
const [statusFilter, setStatusFilter] = useState('all');
const [selectedSession, setSelectedSession] = useState<Session | null>(null);
@@ -102,37 +107,39 @@ export function Sessions() {
const qrRefreshInterval = useRef<ReturnType<typeof setInterval> | null>(null);
const currentSessionName = useRef<string>('');
- const fetchQR = useCallback(async (sessionId: string) => {
- // Guard: if session is already connected, stop polling immediately. Read the ref (not `sessions`)
- // so fetchQR keeps a stable identity — otherwise the polling interval is torn down and restarted on
- // every sessions update.
- const currentSession = sessionsRef.current.find(s => s.id === sessionId);
- if (currentSession?.status === 'ready') {
- setQrData(null);
- currentSessionName.current = '';
- return;
- }
- try {
- const qr = await sessionApi.getQR(sessionId);
- setQrData({ sessionId, sessionName: currentSessionName.current, qrCode: qr.qrCode });
- if (qr.status === 'ready') {
+ const fetchQR = useCallback(
+ async (sessionId: string) => {
+ // Guard: if session is already connected, stop polling immediately. Read the ref (not `sessions`)
+ // so fetchQR keeps a stable identity — otherwise the polling interval is torn down and restarted on
+ // every sessions update.
+ const currentSession = sessionsRef.current.find(s => s.id === sessionId);
+ if (currentSession?.status === 'ready') {
setQrData(null);
currentSessionName.current = '';
- fetchSessions();
+ return;
}
- } catch {
- // Keep qrData alive so the polling interval keeps retrying until the QR
- // is ready. Only stop polling if the session itself has failed.
- const updated = await sessionApi.get(sessionId).catch(() => null);
- const stillInitializing = updated &&
- ['initializing', 'connecting', 'qr_ready'].includes(updated.status);
- if (!stillInitializing) {
- setQrData(null);
- currentSessionName.current = '';
- fetchSessions();
+ try {
+ const qr = await sessionApi.getQR(sessionId);
+ setQrData({ sessionId, sessionName: currentSessionName.current, qrCode: qr.qrCode });
+ if (qr.status === 'ready') {
+ setQrData(null);
+ currentSessionName.current = '';
+ fetchSessions();
+ }
+ } catch {
+ // Keep qrData alive so the polling interval keeps retrying until the QR
+ // is ready. Only stop polling if the session itself has failed.
+ const updated = await sessionApi.get(sessionId).catch(() => null);
+ const stillInitializing = updated && ['initializing', 'connecting', 'qr_ready'].includes(updated.status);
+ if (!stillInitializing) {
+ setQrData(null);
+ currentSessionName.current = '';
+ fetchSessions();
+ }
}
- }
- }, [fetchSessions]);
+ },
+ [fetchSessions],
+ );
useEffect(() => {
if (qrData) {
@@ -146,6 +153,32 @@ export function Sessions() {
};
}, [qrData, fetchQR]);
+ const handleCloseQRModal = useCallback(() => {
+ setQrData(null);
+ setPairingMode(false);
+ setPhoneNumber('');
+ setPairingCode(null);
+ setPairingError(null);
+ }, []);
+
+ const handleGeneratePairingCode = async () => {
+ if (!qrData || !phoneNumber.trim()) return;
+ if (!/^[0-9]{6,15}$/.test(phoneNumber.trim())) {
+ setPairingError(t('sessions.pairing.invalidPhone'));
+ return;
+ }
+ try {
+ setRequestingPairing(true);
+ setPairingError(null);
+ const res = await sessionApi.requestPairingCode(qrData.sessionId, phoneNumber.trim());
+ setPairingCode(res.pairingCode);
+ } catch (err) {
+ setPairingError(err instanceof Error ? err.message : t('common.errorGeneric'));
+ } finally {
+ setRequestingPairing(false);
+ }
+ };
+
const handleCreate = async () => {
if (!newSessionName.trim()) return;
try {
@@ -171,7 +204,9 @@ export function Sessions() {
setSessions(sessions.filter(s => s.id !== id));
toast.success(
t('sessions.delete.successTitle'),
- session ? t('sessions.delete.successDescNamed', { name: session.name }) : t('sessions.delete.successDescGeneric'),
+ session
+ ? t('sessions.delete.successDescNamed', { name: session.name })
+ : t('sessions.delete.successDescGeneric'),
);
} catch (err) {
const msg = err instanceof Error ? err.message : t('sessions.delete.errorDefault');
@@ -207,6 +242,12 @@ export function Sessions() {
// Nothing to show for an already-connected session.
if (session?.status === 'ready') return;
const sessionName = session?.name || '';
+ // Reset any pairing sub-state from a previous open so a freshly opened modal never shows a
+ // stale code/phone belonging to a different session.
+ setPairingMode(false);
+ setPhoneNumber('');
+ setPairingCode(null);
+ setPairingError(null);
// Show loading state immediately so the modal opens and polling starts
// even before Chromium has finished initializing.
setQrData({ sessionId: id, sessionName, qrCode: '' });
@@ -390,34 +431,154 @@ export function Sessions() {
)}
{qrData && (
- <div className="modal-overlay" onClick={() => setQrData(null)}>
+ <div className="modal-overlay" onClick={handleCloseQRModal}>
<div className="modal qr-modal" onClick={e => e.stopPropagation()}>
<div className="modal-header">
<div className="modal-title">
- <h2>{t('sessions.qr.title')}</h2>
+ <h2>{pairingMode ? t('sessions.pairing.tabPhone') : t('sessions.qr.title')}</h2>
<span className="session-name">{qrData.sessionName}</span>
</div>
- <button className="btn-close" onClick={() => setQrData(null)} aria-label={t('common.close')}>
+ <button className="btn-close" onClick={handleCloseQRModal} aria-label={t('common.close')}>
<X size={20} color="#64748b" />
</button>
</div>
<div className="modal-body" style={{ textAlign: 'center' }}>
- {qrData.qrCode ? (
- <>
- <img src={qrData.qrCode} alt="QR" style={{ maxWidth: '280px', borderRadius: '12px' }} />
- <div className="qr-instructions">
- <p className="qr-step"><Trans i18nKey="sessions.qr.step1" components={{ strong: <strong /> }} /></p>
- <p className="qr-step"><Trans i18nKey="sessions.qr.step2" components={{ strong: <strong /> }} /></p>
- <p className="qr-step"><Trans i18nKey="sessions.qr.step3" components={{ strong: <strong /> }} /></p>
+ {!pairingCode && (
+ <div className="pairing-tabs" role="tablist">
+ <button
+ role="tab"
+ aria-selected={!pairingMode}
+ className={`pairing-tab-btn ${!pairingMode ? 'active' : ''}`}
+ onClick={() => {
+ setPairingMode(false);
+ setPairingError(null);
+ }}
+ >
+ {t('sessions.pairing.tabQr')}
+ </button>
+ <button
+ role="tab"
+ aria-selected={pairingMode}
+ className={`pairing-tab-btn ${pairingMode ? 'active' : ''}`}
+ onClick={() => {
+ setPairingMode(true);
+ setPairingError(null);
+ }}
+ >
+ {t('sessions.pairing.tabPhone')}
+ </button>
+ </div>
+ )}
+
+ {!pairingMode ? (
+ // QR Code Content
+ qrData.qrCode ? (
+ <>
+ <img src={qrData.qrCode} alt="QR" style={{ maxWidth: '280px', borderRadius: '12px' }} />
+ <div className="qr-instructions">
+ <p className="qr-step">
+ <Trans i18nKey="sessions.qr.step1" components={{ strong: <strong /> }} />
+ </p>
+ <p className="qr-step">
+ <Trans i18nKey="sessions.qr.step2" components={{ strong: <strong /> }} />
+ </p>
+ <p className="qr-step">
+ <Trans i18nKey="sessions.qr.step3" components={{ strong: <strong /> }} />
+ </p>
+ </div>
+ <p className="qr-auto-refresh">
+ <RefreshCw size={14} className="spin-slow" /> {t('sessions.qr.autoRefresh')}
+ </p>
+ </>
+ ) : (
+ <div style={{ padding: '2rem' }}>
+ <Loader2 className="animate-spin" size={48} />
+ <p>{t('sessions.qr.generating')}</p>
</div>
- <p className="qr-auto-refresh">
- <RefreshCw size={14} className="spin-slow" /> {t('sessions.qr.autoRefresh')}
- </p>
- </>
+ )
) : (
- <div style={{ padding: '2rem' }}>
- <Loader2 className="animate-spin" size={48} />
- <p>{t('sessions.qr.generating')}</p>
+ // Pairing Code Content
+ <div className="pairing-container" role="tabpanel">
+ {pairingError && <div className="pairing-error">{pairingError}</div>}
+
+ {!pairingCode ? (
+ <div className="pairing-form">
+ <label htmlFor="pairing-phone" className="pairing-label">
+ {t('sessions.pairing.phoneLabel')}
+ </label>
+ <input
+ id="pairing-phone"
+ className="pairing-input"
+ type="tel"
+ inputMode="numeric"
+ maxLength={15}
+ placeholder={t('sessions.pairing.phonePlaceholder')}
+ value={phoneNumber}
+ onChange={e => setPhoneNumber(e.target.value.replace(/\D/g, ''))}
+ onKeyDown={e => e.key === 'Enter' && handleGeneratePairingCode()}
+ />
+ <p className="input-hint" style={{ marginBottom: '1.5rem' }}>
+ {t('sessions.pairing.phoneHint')}
+ </p>
+ <button
+ className="btn-primary"
+ onClick={handleGeneratePairingCode}
+ disabled={requestingPairing || !/^[0-9]{6,15}$/.test(phoneNumber.trim())}
+ style={{ width: '100%', justifyContent: 'center' }}
+ >
+ {requestingPairing ? (
+ <>
+ <Loader2 className="animate-spin" size={16} />
+ <span style={{ marginLeft: '0.5rem' }}>{t('sessions.pairing.generating')}</span>
+ </>
+ ) : (
+ t('sessions.pairing.generateButton')
+ )}
+ </button>
+ </div>
+ ) : (
+ <>
+ <label style={{ display: 'block', fontWeight: 600, color: 'var(--text-secondary)' }}>
+ {t('sessions.pairing.codeLabel')}
+ </label>
+ <div className="pairing-code-display">
+ {pairingCode.substring(0, 4)} - {pairingCode.substring(4)}
+ </div>
+
+ <div className="qr-instructions">
+ <p className="pairing-instructions-title">{t('sessions.pairing.instructions')}</p>
+ <p className="qr-step">
+ <Trans i18nKey="sessions.pairing.step1" components={{ strong: <strong /> }} />
+ </p>
+ <p className="qr-step">
+ <Trans i18nKey="sessions.pairing.step2" components={{ strong: <strong /> }} />
+ </p>
+ <p className="qr-step">
+ <Trans i18nKey="sessions.pairing.step3" components={{ strong: <strong /> }} />
+ </p>
+ <p className="qr-step">
+ <Trans i18nKey="sessions.pairing.step4" components={{ strong: <strong /> }} />
+ </p>
+ </div>
+
+ <div style={{ marginTop: '1.5rem' }}>
+ <button
+ className="btn-secondary"
+ onClick={() => {
+ setPairingCode(null);
+ setPhoneNumber('');
+ }}
+ style={{ width: '100%' }}
+ >
+ {t('sessions.pairing.changeNumber')}
+ </button>
+ </div>
+
+ <p className="qr-auto-refresh">
+ <RefreshCw size={14} className="spin-slow" /> {t('sessions.pairing.waitingConnection')}
+ </p>
+ </>
+ )}
</div>
)}
</div>
@@ -442,7 +603,9 @@ export function Sessions() {
</div>
<div className="detail-item">
<span className="detail-label">{t('sessions.details.status')}</span>
- <span className={`status-badge ${selectedSession.status}`}>{formatStatus(selectedSession.status)}</span>
+ <span className={`status-badge ${selectedSession.status}`}>
+ {formatStatus(selectedSession.status)}
+ </span>
</div>
<div className="detail-item">
<span className="detail-label">{t('sessions.details.sessionId')}</span>
@@ -459,7 +622,9 @@ export function Sessions() {
<div className="detail-item">
<span className="detail-label">{t('sessions.details.lastActive')}</span>
<span className="detail-value">
- {selectedSession.lastActive ? new Date(selectedSession.lastActive).toLocaleString() : t('common.never')}
+ {selectedSession.lastActive
+ ? new Date(selectedSession.lastActive).toLocaleString()
+ : t('common.never')}
</span>
</div>
</div>
diff --git a/dashboard/src/services/api.ts b/dashboard/src/services/api.ts
index 6f55958f9..b4a355033 100644
--- a/dashboard/src/services/api.ts
+++ b/dashboard/src/services/api.ts
@@ -392,6 +392,11 @@ export const sessionApi = {
stop: (id: string) => request<Session>(`/sessions/${id}/stop`, { method: 'POST' }),
forceKill: (id: string) => request<Session>(`/sessions/${id}/force-kill`, { method: 'POST' }),
getQR: (id: string) => request<{ qrCode: string; status: string }>(`/sessions/${id}/qr`),
+ requestPairingCode: (id: string, phoneNumber: string) =>
+ request<{ pairingCode: string; status: string }>(`/sessions/${id}/pairing-code`, {
+ method: 'POST',
+ body: JSON.stringify({ phoneNumber }),
+ }),
getStats: () => request<SessionStats>('/sessions/stats/overview'),
getGroups: (id: string) =>
request<{ id: string; name: string; linkedParentJID?: string | null }[]>(`/sessions/${id}/groups`),