[BUG] Switching focus between local Code sessions kills the unfocused session's CLI process (SIGTERM, exit 143) instead of leaving it running in the background

Resolved 💬 2 comments Opened May 26, 2026 by jwbenning Closed Jun 30, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Environment

  • Claude Desktop: 1.8555.0 (8245b7) 2026-05-21
  • Claude Code (embedded): 2.1.149
  • macOS

What's wrong
Switching focus from local session A to local session B in the
desktop sidebar causes session A's CLI subprocess to be terminated
with SIGTERM (exit code 143) within ~1 second. If the terminate
doesn't complete promptly, the supervisor escalates to SIGKILL and
LocalSessions.clearSession runs, removing the session from the
in-memory map. Any in-progress turn on session A is interrupted
(reason=system_error in CycleHealth). Sending a new message later
causes a fresh CLI process to spawn via "Resuming session ...
Mapping internal session ... to CLI session ...".

What Should Happen?

Expected: switching focus changes which session is visible, but
leaves the previously-focused session's CLI running, so in-progress
work continues.

Error Messages/Logs

Log signature (timestamps from one cycle)
13:17:11 [CCD] LocalSessions.setFocusedSession: sessionId=null
13:17:11 [CCD] LocalSessions.setFocusedSession: sessionId=local_6496a249...
13:17:11 LocalSessions.stopShellPty: sessionId=local_6c12069e...
13:17:12 [error] Session local_6c12069e... query error: Claude Code
        process exited with code 143

Steps to Reproduce

  1. Open two local Code sessions in different folders.
  2. Submit a prompt in session A that will run for ~30s+.
  3. Click session B in the sidebar before A finishes.
  4. Watch main.log: setFocusedSession=null → setFocusedSession=<B>

→ stopShellPty on A → "Claude Code process exited with code 143"
on A.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.149

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Possibly related: #51649, #57361, #60790.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗