Skip to content

fix(input): centralize and persist terminal input - #188

Draft
Lint111 wants to merge 8 commits into
Ark0N:masterfrom
Lint111:agent/split-persistent-terminal-input
Draft

fix(input): centralize and persist terminal input#188
Lint111 wants to merge 8 commits into
Ark0N:masterfrom
Lint111:agent/split-persistent-terminal-input

Conversation

@Lint111

@Lint111 Lint111 commented Jul 29, 2026

Copy link
Copy Markdown

Summary

  • Make TerminalInputController the single pre-delivery owner for native xterm
    data, Android helper-textarea mutations, IME composition, CJK/voice input,
    paste, accessory controls, and modified Enter.
  • Persist editable drafts independently per session across session switches,
    page reloads, browser minimization/tab discard, and phone sleep without
    submitting restored text.
  • Queue submitted input durably before transport, preserve ordering across
    WebSocket/HTTP reconnects, and remove frames only after the server confirms an
    accepted PTY write.
  • Extend xterm-zerolag-input at its source package with serializable,
    grapheme-aware multiline state and atomic restoration against stale terminal
    frames.

User-visible fixes

  • Prevent delayed Android/Gboard composition replays such as cdcd and
    homecd.
  • Keep Backspace at one action per character instead of consuming an invisible
    autocomplete/helper-textarea buffer first.
  • Preserve multiline and blank-line paste data, including bracketed-paste
    framing for large payloads.
  • Keep unfinished input attached to the correct session and editable after
    lifecycle or session transitions.
  • Preserve drafts while permission/elicitation dialogs use navigation and
    selection controls.
  • Keep local echo, cursor placement, and multiline viewport positioning
    coherent while terminal output arrives.

Delivery model

Each browser has a stable clientId; each session gets monotonic input sequence
numbers. Pending frames are stored before delivery and retried after reconnect.
The WebSocket route ACKs tagged input only after the PTY accepts it, while the
HTTP route uses a successful response as its ACK. Duplicate (clientId, seq)
frames are acknowledged without a second write.

Deduplication is intentionally server-memory-only. A server restart in the
narrow interval between a successful write and client ACK can produce a retry;
the design favors retaining user input over losing it.

Review scope

This is the IME, paste, draft, and input-delivery slice requested in the review
of #173. It does not include the mobile navigation pad, shutdown endpoint,
repository viewer, response viewer, history streaming, hook changes, or case
actions; those are separate PRs.

The diff is 45 files and +7,283/-1,006. Of the added lines, 4,032 (55%) are
focused tests. Generated dist/ and vendor bundles are not committed; the
zero-lag overlay remains sourced from packages/xterm-zerolag-input/.

Commit structure

  1. feat(zerolag): add serializable multiline input state
  2. feat(input): add per-session terminal draft store
  3. refactor(input): centralize terminal input arbitration
  4. feat(input): integrate persistent terminal drafts
  5. refactor(input): route producers through controller
  6. test(mobile): cover persistent terminal input
  7. fix(input): acknowledge only accepted terminal writes
  8. docs(input): document persistent delivery invariants

Validation

  • Input/controller/transport suites: 12 files, 223 tests passed
  • Mobile keyboard browser suite: 1 file, 57 tests passed
  • xterm-zerolag-input: 5 files, 194 tests passed; typecheck and package build
    passed
  • Root typecheck, ESLint, Prettier, frontend syntax (28 files), and public asset
    checks (45 files): passed
  • Production build, including minified/content-hashed input state and controller
    assets: passed
  • Full CI-equivalent run on the audited combined stack with the isolated test
    harness from test: isolate runtime state and PTY integration #175: 190 files passed, 1 skipped; 3,860 tests passed, 12 skipped

Related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant