Repository navigation
Conversation
When Switchboard is started from inside a Claude Code session (a terminal in a session, or a session restarting the app), it inherits CLAUDECODE, CLAUDE_CODE_SESSION_ID, CLAUDE_CODE_CHILD_SESSION and the other variables Claude gives its children, and passed them to every session it started. A CLI started with them takes itself for a child of that old session and writes no transcript of its own, so a new session never got its title, never got a row from the index and could not be resumed. They are now left out of every PTY's environment; the settings a user puts in env stay.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When Switchboard itself is started from inside a Claude Code session (from a terminal in a session, or by a session that restarts the app), every new Claude session it starts afterwards gets no title, never shows up as a real row (it stays "New session"), keeps ignoring a rename and cannot be resumed. This fixes it.
Why
Claude Code exports variables describing its own session to every child process:
CLAUDECODE,CLAUDE_CODE_SESSION_ID,CLAUDE_CODE_CHILD_SESSION,CLAUDE_CODE_ENTRYPOINT,CLAUDE_PID, the bridge and messaging ones,CLAUDE_CODE_SSE_PORT… An Electron app launched from there inherits them, andbuildPtyEnvpassed them on to every PTY. Plain terminals already dropCLAUDECODE, but Claude sessions got everything.A
claudestarted withCLAUDE_CODE_CHILD_SESSION=1and another session'sCLAUDE_CODE_SESSION_IDtakes itself for a child of that session: it writes no transcript of its own. Seen here with Claude Code 2.1.317: a session started with--session-id <id>ran for over an hour and~/.claude/projects/**/<id>.jsonlnever appeared (onlysession-env/<id>andfile-history/<id>), while sessions started from a Switchboard launched from the Dock wrote theirs as usual. With no transcript there is noai-title, nothing for the index to pick up, and nothing for--resume.What it does
pty-env.jsonly:buildPtyEnvleaves out the variables that describe the session Switchboard was started from. Settings a user puts inenv(CLAUDE_CODE_MAX_OUTPUT_TOKENS,CLAUDE_CONFIG_DIR, …) are kept.CLAUDE_CODE_SSE_PORTis dropped too, since it points at that session's IDE server; Switchboard still sets its own for--ideright after.Testing
test/pty-env.test.js: the inherited session variables are dropped and user settings are kept.electron .with an isolatedSWITCHBOARD_DATA_DIR), then a terminal opened in it echoing$CLAUDECODE|$CLAUDE_CODE_SESSION_ID|$CLAUDE_CODE_CHILD_SESSION: before, the parent session's id and1; after, all empty, withCLAUDE_CODE_MAX_OUTPUT_TOKENSstill there.npm test: the only failures arefileDiff reads tracked and untracked changes…andprojectGitInfo and projectGitDiff expose read-only data…, which fail the same way on currentmainon my machine (they trip over a globalcolor.ui = always).