fix: hide SDK stream-json sessions from the session list - #172
Open
Alexander-kniit wants to merge 1 commit into
Open
fix: hide SDK stream-json sessions from the session list#172Alexander-kniit wants to merge 1 commit into
Alexander-kniit wants to merge 1 commit into
Conversation
abtop surfaces every live `claude` process, including non-interactive sessions driven over the Agent SDK's bidirectional stream-json protocol (`--input-format stream-json`). These are background infrastructure, not interactive agent sessions the user is running — for example claude-mem's observer holds such a session open continuously, cluttering the sessions, projects, and context panels, and even registers its transient CLAUDE_CONFIG_DIR as a scanned config root. This mirrors the existing filter that skips abtop's own `claude --print` summary children: add `process::is_sdk_stream_session`, which matches only the programmatic stream-json *input* protocol, and skip such procs in both `find_claude_pids` (the live row) and the `/proc`-environ config-root discovery loop (the dynamically-discovered historical row). A human `claude --print "q"` never feeds an input stream, so interactive and one-shot `--print` sessions are still surfaced unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
abtop surfaces every live
claudeprocess. That includes non-interactive sessions driven over the Agent SDK's bidirectional stream-json protocol (--input-format stream-json) — background infrastructure, not interactive agent sessions the user is running.Concretely: claude-mem's "observer" holds such an SDK session open continuously. On Linux it shows up permanently in the sessions, projects, and context panels, and — because abtop reads each live claude proc's
CLAUDE_CONFIG_DIRfrom/proc/<pid>/environ— it also registers the observer's transient config dir as a scanned config root, producing a phantom project row. Any tool built on the Agent SDK (CI agents, background summarizers, etc.) causes the same clutter.Fix
This mirrors the filter abtop already has for its own
claude --printsummary children (is_descendant_of):process::is_sdk_stream_session(cmd)— true only when the cmdline carries--input-format stream-json(space or=form).find_claude_pids→ removes the live session row/proc-environ config-root discovery loop → stops the SDK session'sCLAUDE_CONFIG_DIRfrom being added as a scanned root (removes the phantom project row)Why
--input-format stream-jsonspecificallyA human
claude --print "q"never feeds an input stream —--input-format stream-jsonis exclusively the programmatic SDK/bidirectional protocol. So this preserves the existing, deliberate behavior of surfacing user-launched--printsessions (see the comment onfind_claude_pids): interactive and one-shot--printsessions are still shown unchanged. Only programmatic stream-json driven sessions are hidden.Tests
is_sdk_stream_session_matches_stream_json_input— matches both arg forms; rejects interactive,--print, and--output-format stream-json-only cmdlines.test_find_claude_pids_excludes_sdk_stream_sessions— an SDK observer proc is filtered; an interactive session and a humanclaude --printone-shot are still surfaced.cargo test --lib→ 202 passed, 0 failed.Scope
Live-proc discovery is Linux-only in abtop (non-Linux
read_env_var_from_procis a stub), so this affects the Linux path where the clutter actually appears; behavior on other platforms is unchanged.