[FEATURE] Claude Desktop Terminal panel: expose the owning Code session's id in the tab environment

Status Open
Reported on v2.1.280
Maintainer reply None cached
Activity 0 comments · opened Sep 25, 2026

Summary

A shell opened in the Claude Desktop Terminal panel of a Code session cannot tell which session it belongs to. Please expose the owning session's id in the terminal tab's environment, the way Codex sets CODEX_THREAD_ID in its terminals.

Observed (macOS, Claude Desktop 2.7032.0, bundled Claude Code 2.1.280)

| | Bash tool shell | Terminal panel tab |
|---|---|---|
| Parent process | the session's own claude process | Claude Helper, shared by every session in the app |
| CLAUDE_CODE_SESSION_ID | set | absent |
| CLAUDE_CODE_HOST_SESSION_ID (local_<uuid>) | set | absent |
| Other markers | CLAUDE_CODE_ENTRYPOINT=claude-desktop, ... | only TERM_PROGRAM=claude-desktop and the profile's CLAUDE_CONFIG_DIR |

Process ancestry of a terminal tab: zsh → Claude Helper → Claude (app). No claude CLI process is above it, so <config dir>/sessions/<pid>.json cannot be used either, and a profile usually has several live sessions, so the config dir does not identify one.

Why it matters

Tools that attribute a command to the session that ran it (notification senders, "reply to the session that asked", idempotent operation ids keyed on the caller) work from the Bash tool shell but not from the Terminal panel beside the same conversation. From the terminal tab they can only fall back to "the OS user", which merges every session's work into one identity.

Request

When a Terminal panel tab opens for a Code session, set an environment variable naming that session — the CLI session id, the Desktop local_<uuid>, or both, matching what the Bash tool shell receives.

One caution from #68534 and #67603: an inherited CLAUDE_CODE_SESSION_ID / CLAUDE_CODE_CHILD_SESSION has broken a nested claude started from such a shell. If reusing those names would make a claude launched from the terminal tab adopt the parent's session, a terminal-specific name (for example CLAUDE_CODE_TERMINAL_SESSION_ID) that claude itself ignores would give tools the same information without that hazard.

Repro

  1. Open a Code session in Claude Desktop and open its Terminal panel.
  2. Run env | grep -E '^(CLAUDE|TERM_PROGRAM)' and ps -o ppid= -p $$ | xargs ps -o comm= -p.
  3. Compare with the same commands run through the Bash tool in that session.

View original on GitHub ↗