Skip to content
4 changes: 4 additions & 0 deletions application/i18n/locales/en/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,10 @@ export const enTerminalMessages: Messages = {
'serial.field.configLabelPlaceholder': 'e.g. Arduino Uno',
'serial.connectAndSave': 'Connect & Save',
'serial.edit.title': 'Serial Port Settings',
'serial.field.username': 'Username',
'serial.field.password': 'Password',
'serial.field.autoLoginDesc': 'When set, Login/Password prompts on the serial console are answered automatically with these saved credentials.',
'serial.field.clearPassword': 'Clear saved password',

// Keyboard Interactive Authentication (2FA/MFA)
'keyboard.interactive.title': 'Authentication Required',
Expand Down
4 changes: 4 additions & 0 deletions application/i18n/locales/es/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,10 @@ export const esTerminalMessages: Messages = {
'serial.field.configLabelPlaceholder': 'p. ej., Arduino Uno',
'serial.connectAndSave': 'Conectar y guardar',
'serial.edit.title': 'Configuración del puerto serial',
'serial.field.username': 'Usuario',
'serial.field.password': 'Contraseña',
'serial.field.autoLoginDesc': 'Si se establecen, los mensajes Login/Password de la consola serial se responden automáticamente con estas credenciales guardadas.',
'serial.field.clearPassword': 'Borrar la contraseña guardada',

// Keyboard Interactive Authentication (2FA/MFA)
'keyboard.interactive.title': 'Se requiere autenticación',
Expand Down
4 changes: 4 additions & 0 deletions application/i18n/locales/ru/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,10 @@ export const ruTerminalMessages: Messages = {
'serial.field.configLabelPlaceholder': 'например, Arduino Uno',
'serial.connectAndSave': 'Подключить и сохранить',
'serial.edit.title': 'Настройки последовательного порта',
'serial.field.username': 'Имя пользователя',
'serial.field.password': 'Пароль',
'serial.field.autoLoginDesc': 'Если задано, запросы Login/Password в последовательной консоли автоматически заполняются этими сохранёнными учётными данными.',
'serial.field.clearPassword': 'Очистить сохранённый пароль',

// Keyboard Interactive Authentication (2FA/MFA)
'keyboard.interactive.title': 'Требуется аутентификация',
Expand Down
4 changes: 4 additions & 0 deletions application/i18n/locales/zh-CN/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,10 @@ export const zhCNTerminalMessages: Messages = {
'serial.field.configLabelPlaceholder': '例如 Arduino Uno',
'serial.connectAndSave': '连接并保存',
'serial.edit.title': '串口设置',
'serial.field.username': '用户名',
'serial.field.password': '密码',
'serial.field.autoLoginDesc': '设置后,串口终端出现 Login/Password 登录提示时,会自动填充此处保存的用户名和密码。',
'serial.field.clearPassword': '清除已保存的密码',

// Keyboard Interactive Authentication (2FA/MFA)
'keyboard.interactive.title': '需要验证',
Expand Down
4 changes: 4 additions & 0 deletions application/i18n/locales/zh-TW/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,10 @@ export const zhTWTerminalMessages: Messages = {
'serial.field.configLabelPlaceholder': '例如 Arduino Uno',
'serial.connectAndSave': '連線並儲存',
'serial.edit.title': '序列埠設定',
'serial.field.username': '使用者名稱',
'serial.field.password': '密碼',
'serial.field.autoLoginDesc': '設定後,序列埠終端出現 Login/Password 登入提示時,會自動填入此處儲存的使用者名稱和密碼。',
'serial.field.clearPassword': '清除已儲存的密碼',

// Keyboard Interactive Authentication (2FA/MFA)
'keyboard.interactive.title': '需要驗證',
Expand Down
7 changes: 7 additions & 0 deletions application/state/useTerminalBackend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ export const useTerminalBackend = () => {
bridge?.writeToSession?.(sessionId, data, options);
}, []);

const notifyUserInput = useCallback((sessionId: string) => {
const bridge = netcattyBridge.get();
bridge?.notifySessionUserInput?.(sessionId);
}, []);

const interruptSession = useCallback((sessionId: string, trace?: NetcattyTerminalInterruptTrace) => {
const bridge = netcattyBridge.get();
if (bridge?.interruptSession) {
Expand Down Expand Up @@ -593,6 +598,7 @@ export const useTerminalBackend = () => {
getSessionDistroInfo,
getServerStats,
writeToSession,
notifyUserInput,
interruptSession,
resizeSession,
clearSessionPtyBuffer,
Expand Down Expand Up @@ -675,6 +681,7 @@ export const useTerminalBackend = () => {
getSessionDistroInfo,
getServerStats,
writeToSession,
notifyUserInput,
interruptSession,
resizeSession,
clearSessionPtyBuffer,
Expand Down
81 changes: 80 additions & 1 deletion components/SerialHostDetailsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Serial Host Details Panel
* A dedicated editor for serial port hosts (distinct from SSH HostDetailsPanel)
*/
import { ChevronDown, ChevronUp, Save, Tag, Usb } from 'lucide-react';
import { ChevronDown, ChevronUp, Eye, EyeOff, Save, Tag, Usb, X } from 'lucide-react';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useI18n } from '../application/i18n/I18nProvider';
import { useTerminalBackend } from '../application/state/useTerminalBackend';
Expand Down Expand Up @@ -75,9 +75,22 @@ export const SerialHostDetailsPanel: React.FC<SerialHostDetailsPanelPropsWithRes
const [ports, setPorts] = useState<SerialPort[]>([]);
const [isLoadingPorts, setIsLoadingPorts] = useState(false);
const [showAdvanced, setShowAdvanced] = useState(false);
const [showPassword, setShowPassword] = useState(false);

// Form state
const [label, setLabel] = useState(initialData.label);
const [username, setUsername] = useState(initialData.username || '');
const [password, setPassword] = useState(initialData.password || '');
// Tracks whether the user edited the password field this session. An empty
// password is a meaningful serial credential (the auto-login detector
// submits a blank line at a Password prompt), so an explicit edit to blank
// must be saved as '' while an untouched field preserves the stored value.
const [passwordChanged, setPasswordChanged] = useState(false);
// Explicit "remove the saved credential" flag. An empty password field is a
// meaningful serial credential (a present blank password), so blanking the
// input alone cannot restore `password` to undefined — the user needs a
// dedicated control to delete the credential entirely.
const [passwordCleared, setPasswordCleared] = useState(false);
const [selectedPort, setSelectedPort] = useState(initialData.hostname || initialData.serialConfig?.path || '');
const [baudRate, setBaudRate] = useState(initialData.serialConfig?.baudRate || initialData.port || 115200);
const [dataBits, setDataBits] = useState<5 | 6 | 7 | 8>(initialData.serialConfig?.dataBits || 8);
Expand Down Expand Up @@ -140,6 +153,16 @@ export const SerialHostDetailsPanel: React.FC<SerialHostDetailsPanelPropsWithRes
label: label.trim() || `Serial: ${portName}`,
hostname: selectedPort,
port: baudRate,
username: username.trim() || undefined,
// An empty password is meaningful for serial auto-login: the detector
// distinguishes an absent password from a present empty string and
// submits the required blank line at a Password prompt. An explicit edit
// saves exactly what the user typed (including a blank line); the
// dedicated clear control removes the credential entirely (undefined);
// an untouched field preserves the stored credential as-is.
password: passwordChanged
? (passwordCleared ? undefined : password)
: (initialData.password ?? undefined),
tags,
group,
charset,
Expand Down Expand Up @@ -276,6 +299,62 @@ export const SerialHostDetailsPanel: React.FC<SerialHostDetailsPanelPropsWithRes
)}
</div>

{/* Login credentials (auto-login) */}
<div className="space-y-2">
<Label htmlFor="serial-username">{t('serial.field.username')}</Label>
<Input
id="serial-username"
value={username}
onChange={(e) => setUsername(e.target.value)}
placeholder={t('serial.field.username')}
autoComplete="off"
/>
<div className="relative">
<Input
id="serial-password"
value={password}
type={showPassword ? 'text' : 'password'}
onChange={(e) => {
setPassword(e.target.value);
setPasswordChanged(true);
if (e.target.value !== '') {
setPasswordCleared(false);
}
}}
placeholder={t('serial.field.password')}
autoComplete="off"
className="pr-16"
/>
<div className="absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-0.5">
{(initialData.password !== undefined || password !== '') && (
<button
type="button"
onClick={() => {
setPassword('');
setPasswordChanged(true);
setPasswordCleared(true);
}}
title={t('serial.field.clearPassword')}
aria-label={t('serial.field.clearPassword')}
className="p-1 text-muted-foreground hover:text-foreground transition-colors"
>
<X size={14} />
</button>
)}
<button
type="button"
onClick={() => setShowPassword(!showPassword)}
className="p-1 text-muted-foreground hover:text-foreground transition-colors"
>
{showPassword ? <EyeOff size={16} /> : <Eye size={16} />}
</button>
</div>
</div>
<p className="text-xs text-muted-foreground">
{t('serial.field.autoLoginDesc')}
</p>
</div>

{/* Tags */}
<div className="space-y-2">
<Label className="flex items-center gap-2">
Expand Down
Loading
Loading