Skip to content

Overlapping terminal reads duplicate scrollback on slow connections #934

Closed

Description

@currentbits

Priority: P2. Reproduced at commit 6c7a6fbe on 2026-09-05.

TerminalPane can append the same output multiple times when a read takes longer than its 250 ms polling interval. This makes test/log output unreliable even when replies arrive in order.

Reproduction

  1. Mount the actual TerminalPane with a running session and cursor 0.
  2. Fire two 250 ms polling ticks before resolving the first read.
  3. Both read requests carry since=0.
  4. Return the first snapshot as text="first\n", cursor=6, reset=false.
  5. Return the second as text="first\nsecond\n", cursor=13, reset=false.
  6. The pane renders "first\nfirst\nsecond\n", although the shell produced each line once.

The audit drives the real polling callback deterministically and uses fake transport replies matching electron/terminal.js toState's delta contract. This models read latency over 250 ms; no response reordering is needed.

Cause

src/components/TerminalPane.tsx:85 uses setInterval without an in-flight guard. Each request reads cursorRef before the previous reply advances it. applyState always appends state.text for reset=false; it does not reconcile overlapping cursor ranges. Command writes also return deltas and share this consumer, so read/write overlap should be covered by the fix.

Acceptance

  • Each output byte/line appears once when reads overlap or read/write replies overlap.
  • Cursor never regresses when an older reply arrives.
  • Preserve reset handling and trimmed-buffer recovery.
  • Add delayed-reply coverage alongside the existing sequential cursor tests.

Related #147 introduced the terminal; this is a concrete delta-consumption bug.
Sources: TerminalPane polling, delta contract.

Runnable audit evidence

Local artifact: docs/issue-drafts/2026-09-05-actions-reproduce.mjs.

node --import=./test/support/disable-grok-mcp.mjs --import=./test/support/render.mjs --experimental-strip-types docs/issue-drafts/2026-09-05-actions-reproduce.mjs

Exited 0 with three CONFIRMED assertions against actual app modules. The assertions demonstrate existing defects, not implemented fixes. Artifact currently exists in the audit checkout; the reproduction above stands alone.

Requested disposition: separate Planboard issue, plan:todo.

Activity

  1. added and removed on Sep 5, 2026
  2. currentbits commented on Sep 10, 2026

    @currentbits
    OwnerAuthor

    Landed from Solenta thread "Overlapping terminal reads duplicate scrollback on slow conn". Closed on merge.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions