Skip to content

New Claude Code tab receives another panel's screen/scrollback as its first prompt (duplicate agent runs the same brief in the same worktree) #457

Description

@parsakhaz

Summary

Opening a new Claude Code tab inside a pane that already has a running agent panel, then typing a short message like continue, delivered a ~9–12 KB dump of another panel's terminal screen/scrollback as the new agent's first prompt, with the typed text appended at the end. Because that dump contained the earlier panel's task brief, the new agent silently started working the same task in the same worktree as the still-running agent. This happened twice in one evening, in two different panes, with two different "source" panels (a Codex CLI panel and a plain Terminal panel).

Impact: two agents editing one worktree (one overwrote the other's Playwright spec mid-run), double pushes averted only because the agents happened to notice each other; ~10 KB of noise burned in the new session's context; the user has no idea it happened.

Environment

  • Pane 2.4.48 (packaged, macOS arm64, Electron 41.10.3), data dir ~/.pane
  • Panes created by RunPane (runpane@2.4.59 via npx): panes create --repo 2 --name … --agent claude|codex --initial-input-file … --source agent --no-focus --pinned --wait-ready --yes --json, later panels create --pane … --agent claude --initial-input-file … --source agent --no-focus --wait-ready --yes --json
  • Agent panels launch claude --dangerously-skip-permissions

Occurrence 1 — pane feedback-pill-github-issue (session 7c2d4309-40ca-4a19-92c5-36ed1e518950)

Timeline (UTC, from ~/.pane/logs/pane-2026-08-18.log and sessions.db.tool_panels):

time event
03:04:55 Pane created by RunPane with a Codex panel b20718d6… + initial input (brief). Codex ran ~29 min, opened PR #433.
~05:16 Follow-up brief sent to the Codex panel via panels input + submit-composer (verifiedSubmitted:true, strategy codex-ctrl-enter). Codex printed the brief, then ■ You've hit your usage limit ….
05:21:20 RunPane panels create --agent claude → panel 48fff33a… created; initial input (takeover brief) delivered, verifiedSubmitted:true. Its tool_panels.state still carries initialInput and hasBeenViewed:false.
05:27:25 User focuses the pane ([GitStatus] Active session changed … to 7c2d4309…); renderer loads the Codex panel b20718d6 (WebGL renderer loaded … reason=visible); sessions:get-output … Retrieved 0 outputs.
05:27:30 [PanelManager] Created panel d6dbb784-d8ab-429e-85c7-ad43a699d1fa of type terminal for session 7c2d4309… — new Claude Code tab.
05:27:39 First user record in ~/.claude/projects/-Users-parsas-allGitHubRepos-dcouple-Pane-worktrees-feedback-pill-github-issue/d6dbb784….jsonl12,492 chars. It begins with the Codex panel's spinner garbage and ends with the usage-limit banner, followed by the typed text:
──────────────────────────────────────────────────────────•Working•Working•Working•Workingorking•rking•king•ingngg1

• The live issue is valid and contains the richer OS/
  runtime details. One blocker remains before merge: the
  refreshed PR has a single failed Quality Checks + Smoke
  job while e…
   … (~12 KB of the Codex panel's screen, including the full follow-up brief) …
■ You've hit your usage limit. Visit
https://chatgpt.com/codex/settings/usage to purchase more
credits or try again at Aug 19th, 2026 8:42 PM.  1 background trminal running ·/psto view · /stop to c continue from where we left off

Note the mangled runs (Workingorking•rking•king•ingngg, trminal, /psto) — the dump looks like a screen-buffer serialization, not clean scrollback. The new session (d6dbb784) then executed the brief it found in that dump; the RunPane-created panel 48fff33a was working the same brief. Their sessions later noticed each other ("a second Claude session … overwrote my Playwright spec while I was running it") and split write ownership manually.

Occurrence 2 — pane themes-a11y (session 6f5fb594-dcb6-4c81-ab16-edaae6962c58)

time event
05:48:10 Pane created by RunPane with Claude panel 0be25ffa… + initial input (theme brief); a plain Terminal panel 8c436913… was created alongside by pane creation.
05:50:36, 05:51:23 Renderer loads 0be25ffa (reason=visible) — the RunPane panel was visible this time.
05:51:38 [PanelManager] Created panel e069dee8-d231-4867-b235-128b96867ec8 of type terminal for session 6f5fb594… — new Claude Code tab; 0be25ffa detached reason=panel-hidden.
05:51:51 First user record in …/worktrees-themes-a11y/e069dee8….jsonl8,748 chars: the plain Terminal panel's pnpm install output, ending with the shell prompt and the typed text:
Scope: all 5 workspace projects
Lockfile is up to date, resolution step is skipped
Progress: resolved 1, reused 0, downloaded 0, added 0
Packages: +1408
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   …
└─ Done in 5.4s
Done in 31s using pnpm v10.19.0
parsas@MacBookPro themes-a11y %  continue

This session then also picked up the a11y theme work in the same worktree (its context grew to 375 k tokens while 0be25ffa was still finishing), and it reports "peer session themes-a11y-9b" itself.

What the two occurrences have in common

  • A pane whose agent panel(s) were created by RunPane with --source agent and an --initial-input-file.
  • The user opens the pane in the UI and creates a new Claude Code tab, then types a short message (continue / continue from where we left off).
  • The new agent's first prompt = <large screen/scrollback text of a different panel in the same pane> + <typed text>. Source panel differs (Codex CLI panel in feat: add git committer attribution for Pane IDE #1, plain Terminal panel in Auto-rename sessions to PR title, status indicator, sidebar cleanup #2), so it's not agent-specific.
  • Nothing about this is visible in the UI; the only trace is the agent's session JSONL and the resulting behavior.

Repro (as observed; not yet minimized)

  1. In Pane 2.4.48, create a pane through RunPane with an agent and an initial prompt: runpane panes create --repo <repo> --name repro --agent claude --initial-input-file brief.md --source agent --no-focus --wait-ready --yes --json. Let the agent start working (it echoes the brief on screen).
  2. Optionally run something noisy in the pane's plain Terminal panel (e.g. pnpm install) so it has scrollback.
  3. Click into the pane in the UI. Add a new Claude Code tab.
  4. Type continue and press Enter.
  5. Inspect the new session's JSONL under ~/.claude/projects/<cwd-slug>/<panelId>.jsonl: the first user message is several KB of another panel's screen text with continue appended.

Expected: the new panel's first prompt is exactly what the user typed. Actual: another panel's screen/scrollback is prepended.

Notes / hypotheses (for whoever picks this up)

  • Candidate paths I did not have time to confirm: terminal selection → clipboard (TerminalPanel.tsx:~1003 copyTerminalText(terminal.getSelection())) if a stale selection is being auto-pasted into the new panel; scrollback replay to the frontend (terminalPanelManager.ts:~1610 "Send scrollback to frontend") being routed to the wrong (new) panel's PTY input; or an intentional "carry context into a new agent" feature that should never fire while the source panel is running. The mangled overlapping text in occurrence 1 suggests a screen-buffer serialization (terminalStateEmulator) rather than raw PTY output.
  • Related dogfood observation: RunPane-created panels stay hasBeenViewed:false and (in occurrence 1) had never been rendered when the user opened the pane, so the user had no cue that an agent was already working there. A "working" indicator on agent tabs, or a warning when a second agent panel starts in a worktree that already has an active agent, would have prevented the duplicate work even with the paste bug present.

Filed from Pane Chat (orchestrator session) after observing both cases live; happy to provide the full JSONL excerpts or log slices on request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions