Skip to content

Terminal reconnects and replays its history every time you return to its side-panel tab #7724

Description

@danteregis

Summary

Open a terminal in a thread's side panel and let it collect some output. Switch to the Browser tab in the same panel, then back to the terminal. The terminal is rebuilt from scratch: it reconnects and replays its recent history, and you watch it scroll through that history before it reaches the prompt. The same happens when you switch to another thread and back. Expected: the terminal comes back as you left it, at once.

Versions and environment

  • bb 0.49.0 (latest release), desktop app on macOS.
  • The desktop app connects to a bb server on a remote Linux machine through bb Connect. Node 26.12.1 on the server.
  • Code references below are against main at 7889bd2.

Steps to reproduce

  1. Open any thread and open a terminal in the side panel.
  2. Run a command that prints a few thousand lines, for example seq 1 50000.
  3. Click the Browser tab in the same panel, then click the terminal tab again.
  4. Switch to another thread, then back to the first thread.

Expected vs actual

Expected: after steps 3 and 4 the terminal shows its last screen immediately, with no reconnect.

Actual: after steps 3 and 4 the terminal starts empty and scrolls through the replayed history until it reaches the bottom. With a long history this takes a visible moment every time.

Evidence

Cause, read from the source:

  1. The secondary panel renders content only for the active tab. Other tabs unmount. ThreadSecondaryPanel.tsx#L678-L681
  2. The Browser deck avoids this with keepMounted: true. The terminal panel loader does not have it. lazySecondaryPanelComponents.tsx#L186
  3. When ThreadTerminalView unmounts, its effect cleanup disposes both the WebSocket transport and the xterm instance. ThreadTerminalView.tsx#L1062-L1063
  4. On the next mount a new transport starts at nextOutputSeq = 0 and connects with sinceSeq=0. terminal-websocket-transport.ts#L84, #L227
  5. The server replays up to BROWSER_TERMINAL_REPLAY_MAX_BYTES (512 KB) as separate output messages. The client writes each one to the visible terminal as it arrives, so the user sees the scroll. terminal-session-lifecycle.ts#L65, ThreadTerminalView.tsx#L618

Two fixes were tried on a local 0.49.0 build:

  • Hiding the terminal until the replay finished removed the visible scroll. Returning to the terminal was still just as slow, because the reconnect and the replay still happen.
  • Keeping the xterm instance and its transport alive while the terminal is not shown made returning instant, for both tab switches and thread switches. A PR with this approach follows.

What you ruled out

Suggested priority and effort

Hits everyone who uses the built-in terminal next to other panel tabs. No data loss. Workaround: use an external terminal.

Checks

  • I reproduced this on the latest release or on main, or I say above that I could not.
  • I searched open and closed issues for the same problem.
  • If an agent wrote this, the body ends with > AGENT GENERATED and links the thread or report.

Investigated in a local bb thread. There is no public report.

AGENT GENERATED

Activity

  1. added theissue type on Nov 17, 2026
  2. added
    ui
    partial-repro
    on Nov 17, 2026
  3. bb-slop-cop commented on Nov 17, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: Medium. Labels: ui, perf, partial-repro.
    • Report: https://get-bb.github.io/reports/issues/7724.html
    • Verdict: PARTIALLY REPRODUCED · root-cause confidence: high.
    • Root cause: selecting another panel tab unmounts the terminal client; cleanup disposes xterm and its transport. A new transport starts at sinceSeq=0 and replays retained output.
    • Evidence: the panel-lifecycle regression fails identically in two trusted-main checkouts; real transport checks against two fresh server/daemon instances each replay roughly 518 KB on successive attachments. Desktop scrolling and thread-navigation timing remain unverified because no local browser was available.
    • No PR: cross-thread runtime ownership and bounded eviction require lifecycle/architecture decisions outside the simple-fix rule. Closed, unmerged fix(app): keep side panel terminals alive across panel and thread switches #7726 received a static-only review in the report; its code was not run.

    AGENT GENERATED

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

    partial-reproperfui

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions