Skip to content

fix(ssh): remote PTY keystroke injection races with SSH MOTD #1289

@rabanspiegel

Description

@rabanspiegel

Problem

When pty:startDirect opens a remote SSH session, init keystrokes (cd, export, provider launch) are written to the PTY immediately after startSshPty() returns. This races with the SSH login banner/MOTD output, which can interleave with and corrupt the injected commands.

This affects both pty:start and pty:startDirect remote paths.

Current behavior

Commands typed into the PTY can get garbled when the MOTD is still being printed, especially with multiple lines of init commands.

Suggested fix

Detect the shell prompt in PTY output before injecting keystrokes, rather than writing immediately. Prompt detection patterns could be derived from the existing activityClassifier.ts idle patterns (e.g. $, %, >).

A fixed-delay workaround (e.g. setTimeout(1500)) is fragile — too short for slow connections, unnecessarily slow for fast ones.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions