Skip to content

Held terminal input: three input paths still decide outside the capture-time gate #4249

Done

Description

@devswha

Follow-up to the change that holds terminal keys captured while the link is known to be down (HerdrSocket.takesKey
in src/lib/ws.ts, src/lib/inputMarks.ts, src/lib/sendInOrder.ts). Each path below reaches the socket on its
own schedule, so its keys are not dated where they were captured. The reproductions use the unit harness of
src/lib/ws.test.ts (a fake socket, navigator.onLine switched by the test) or synthetic events in the mount's
callbacks. None was reproduced on a native device.

1. The composer's Stop sends its second Escape on a timer

  • Where: src/lib/useTypedKeys.ts (the delayed second Escape of a Stop).
  • Steps: invoke Stop on a pane whose agent needs two Escapes while the browser reports offline and the socket stays
    open. The first Escape is refused. Restore the network and answer the probe on the same socket within 150 ms.
  • Now: the delayed second Escape reaches the pane without another action.
  • Expected: the second Escape is sent with the mark of the Stop (typedAt, from markTyped() when Stop is
    pressed), so it is refused when the link was lost since, and the user is told the Stop did not go.

2. New Terminal holds fresh keys after an empty catch spans a socket replacement

  • Where: src/lib/useTerminalMount.ts, adoptTypeAhead (held from socket.connectedSince > at).
  • Steps: choose New terminal; before typing anything, let the socket be replaced (dropped and reconnected within
    five seconds); then type text and Enter into the new tab's catch.
  • Now: the keys go to the held draft and nothing is sent, although every key was typed with the new connection up.
    (A composition that commits nothing no longer causes this; that case is covered.)
  • Expected: adoption decides from each caught key's own mark (CaughtKey.typedAt), not from when the catch opened,
    so keys typed after the replacement are sent.

3. Text an input method, dictation or a paste lets out after recovery is dated when it comes out

  • Where: src/lib/useTerminalMount.ts (onData: typedAt is markTyped() when xterm emits the text).
  • Steps: with the link up, start a composition (or a dictation, a key reported as 229, a paste xterm finishes later)
    in the terminal; let the browser report offline; bring the network back and let the connection answer; then let
    the composition commit.
  • Now: the committed text is sent without Send. Keys the terminal takes as they are typed, Enter included, are held.
    docs/terminal-input.md states this limit.
  • Expected: such text is dated to when it began (its beforeinput, compositionstart or paste), and text begun
    after the link came back is not held. A rule that dates it to when xterm's field was last seen empty held too much
    input typed after recovery, because xterm keeps a half-typed line in that field.

Follows #4245.

Activity

  1. added a commit that references this issue on Nov 25, 2026
    4e108e5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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