You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inject CSM_SESSION_ID into session environments (self-reported state now covered by OSC 7501, #190) #163
Let the program running in a session report its own agent state (working / idle / blocked), rather than CSM having to guess from the screen. Also inject per-session environment variables so a hook or script knows which session it belongs to.
--seq must increase with every report (a timestamp works). Reports that aren't newer are dropped, so a slow hook can't overwrite a fresher state.
--source identifies the reporter. A user's custom reporter (custom:…) can't clobber a built-in integration.
pane release-agent clears the state when the agent quits. As a safety net, Herdr also clears it once the pane is back at an idle shell prompt.
Herdr separates done ("finished, not yet looked at") from idle ("finished and seen"). Seen-state is per viewer, and focusing the pane marks it seen.
Proposal for CSM
Environment. Start every session with CSM_ENV=1, CSM_SESSION_ID and TERM_PROGRAM=CodeShellManager (+ TERM_PROGRAM_VERSION). This depends on the environment-block work in the env-leak issue filed alongside this one.
Transport (v1). Extend OSC 9001 with state=working|idle|blocked, state-msg=… and seq=N. Validate it in ShellIntegrationPayload like every other field: a strict allowlist, with the message length-capped and stripped of control characters.
A Claude Code hook (optional install). Claude's UserPromptSubmit / Stop / Notification hooks print the OSC. This gives exact "working" and "done" state for Claude without screen-scraping.
Done vs idle. Add an unseen-completion state that clears when the session becomes ActiveSession.
Precedence. Reported state beats screen detection for as long as the reporter holds the session. Screen detection (AlertDetector) remains the fallback.
Trust note
OSC 9001 is untrusted: any cat of a file can emit it. A forged state= only affects display, which is acceptable. It must never drive an action such as auto-answering a prompt or resuming.
Mostly superseded by #190. That PR implemented OSC 7501 (the Program Status Protocol), and it covers the "self-reported state" half of this issue better than the CLI/OSC I proposed above:
it is a published spec;
Claude Code already emits it;
it has blocked kinds, progress, child records and done/error.
Building a CSM-specific report-agent channel next to it would only duplicate it.
What's left: inject CSM_SESSION_ID (and possibly CSM_SESSION_NAME) into each session's environment. A program then knows which CSM session it is running in. #132 (MCP self-control) and #170 (hooks) both need this. I've narrowed the title to match. It is still blocked on #162: environment injection should happen in the same place we start building the child process's environment explicitly.
changed the title [-]Let a session report its own agent state (working/idle/blocked/done) and inject CSM_SESSION_ID[/-][+]Inject CSM_SESSION_ID into session environments (self-reported state now covered by OSC 7501, #190)[/+]on Nov 10, 2026
Activity
AThraen commentedon Nov 5, 2026
Cross-links for the Herdr-inspired batch:
Orchestration semantics were added to #132, and detection notes to #154.
AThraen commentedon Nov 10, 2026
Mostly superseded by #190. That PR implemented OSC 7501 (the Program Status Protocol), and it covers the "self-reported state" half of this issue better than the CLI/OSC I proposed above:
blockedkinds, progress, child records and done/error.Building a CSM-specific
report-agentchannel next to it would only duplicate it.What's left: inject
CSM_SESSION_ID(and possiblyCSM_SESSION_NAME) into each session's environment. A program then knows which CSM session it is running in. #132 (MCP self-control) and #170 (hooks) both need this. I've narrowed the title to match. It is still blocked on #162: environment injection should happen in the same place we start building the child process's environment explicitly.[-]Let a session report its own agent state (working/idle/blocked/done) and inject CSM_SESSION_ID[/-][+]Inject CSM_SESSION_ID into session environments (self-reported state now covered by OSC 7501, #190)[/+]