graykode / graykode/abtop

abtop did not see my claude code sessions

Open
#135 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
3.6k
Forks
322
Avg merge
7d 22h
Merged PRs (30d)
3

Description

abtop didn't see my Claude Code sessions. I had it fixed, here is what was changed. Maybe it's useful:
----
`abtop` (v0.4.8) showed no sessions despite Claude Code running.

## Root cause

abtop discovers sessions by reading `~/.claude/sessions/.json` — a per-process
JSON file containing `pid`, `sessionId`, `cwd`, and `startedAt`. Older Claude Code
versions wrote these files automatically. Claude Code 2.x (standalone ELF binary,
`~/.local/share/claude/versions/2.1.42`) never does — it only writes to
`~/.claude/projects//.jsonl`.

Two compounding issues:

1. `~/.claude/sessions/` didn't exist, so `is_claude_config_root()` returned false
(abtop requires **both** `sessions/` and `projects/` to treat a directory as a
valid Claude config root — see [graykode/abtop#126](https://github.com/graykode/abtop/pull/126)).
2. Even after creating the directory, it was empty — so `find_session_file_for_pid()`
found nothing and returned no sessions.

## Fix

**1. Create the missing directory** (`~/.claude/sessions/`)

Required for abtop's config-root detection to pass.

**2. Add `~/.config/abtop/config.toml`**

```toml
claude_config_dirs = ["~/.claude"]
```

Belt-and-suspenders explicit config in case auto-discovery changes again.

**3. `SessionStart` hook: `~/.pilot/hooks/abtop_session_register.py`**

Writes the expected session file on every Claude Code startup. Walks up the
`/proc` tree from the hook subprocess to find the `claude` ancestor PID, then
writes `~/.claude/sessions/.json` with the correct structure. Also cleans
up stale files for processes that no longer exist.

Registered in `~/.claude/settings.json` under `SessionStart / startup`, async.
----

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.