diff --git a/tabby-serial/src/api.ts b/tabby-serial/src/api.ts index d8e27a1ee..3a74c5e77 100644 --- a/tabby-serial/src/api.ts +++ b/tabby-serial/src/api.ts @@ -11,7 +11,7 @@ export interface SerialProfile extends ConnectableTerminalProfile { } export interface SerialProfileOptions extends StreamProcessingOptions, LoginScriptsOptions { - port: string + port: string | null baudrate: number | null databits: 5 | 6 | 7 | 8 stopbits: 1 | 1.5 | 2 diff --git a/tabby-serial/src/components/serialProfileSettings.component.pug b/tabby-serial/src/components/serialProfileSettings.component.pug index b17658a26..fbf422e98 100644 --- a/tabby-serial/src/components/serialProfileSettings.component.pug +++ b/tabby-serial/src/components/serialProfileSettings.component.pug @@ -9,6 +9,7 @@ ul.nav-tabs(ngbNav, #nav='ngbNav') input.form-control( type='text', alwaysVisibleTypeahead, + placeholder='Ask every time', [(ngModel)]='profile.options.port', [ngbTypeahead]='portsAutocomplete', [resultFormatter]='portsFormatter' diff --git a/tabby-serial/src/profiles.ts b/tabby-serial/src/profiles.ts index c049fed21..86378d66e 100644 --- a/tabby-serial/src/profiles.ts +++ b/tabby-serial/src/profiles.ts @@ -83,6 +83,30 @@ export class SerialProfilesService extends ConnectableProfileProvider> { + // Show port selector first if not set + if (!profile.options.port) { + profile = deepClone(profile) + let port: string|undefined = undefined + + try { + const ports = await this.serial.listPorts() + + port = await this.selector.show( + this.translate.instant('Select port'), + [ + ...ports.map(x => ({ + name: x.description ? `${x.name} (${x.description})` : x.name, result: x.name, weight: 0, + })), + ], + ) + } catch { + throw new Error('Port selection canceled') + } + + profile.options.port = port + } + + // Then show baudrate selector if not set if (!profile.options.baudrate) { profile = deepClone(profile) let baudrate: number|undefined = undefined @@ -132,6 +156,6 @@ export class SerialProfilesService extends ConnectableProfileProvider