Why
When Claude Code and Codex are both part of your workflow, their sessions live in
different products and expose different metadata. It becomes easy to miss an
approval, forget an idle session, or assume one provider exposes a number that it
does not.
Agent Session Monitor keeps both providers visible while preserving those
differences instead of flattening them into misleading data.
Features
- One provider-aware session list — filter All / Claude / Codex, group sessions
by Limited / Waiting / Your turn / Working / Ended, and keep provider-qualified
session identities distinct.
- Official Codex integration — launches the configured Codex CLI as
codex app-server --stdio and uses its supported thread and account-usage
methods. It does not scrape the Codex state database.
- Precise live state through provider hooks — small lifecycle records add exact
working, waiting, permission-request, and ended signals for each provider.
- Honest provider-specific usage — Claude transcript usage and Anthropic account
gauges stay Claude data; Codex rate-limit/account totals stay Codex data.
- Provider-aware actions — switch provider from the title bar, jump to matching
tabs, open transcripts when available, or resume a selected session in a terminal.
Claude-only bulk model/effort/resume sweeps remain explicitly Claude-only.
- CPU/RAM and attention signals — process-tree resource sampling, Activity Bar
badges, transition notifications, and stuck-session warnings where the provider
exposes enough process metadata.
- Safe degradation — either provider can be disabled, unavailable, or missing
hooks without hiding the other provider.
Install
From the Marketplace
Search "Agent Session Monitor: Claude + Codex" in the Extensions view, or
upgrade/install it with the existing Marketplace identifier:
code --install-extension softween.claude-code-session-monitor
The Marketplace id is intentionally unchanged, so existing Claude Session Monitor
installations upgrade in place.
Provider prerequisites
- Claude: install and sign in to Claude Code if you want Claude sessions.
- Codex: install and sign in to the Codex CLI, then confirm
codex --version
works in the environment VS Code inherits. If it does not, set
claudeSessionMonitor.codexExecutable to the absolute executable path.
Either provider can be disabled independently in Settings.
Install the provider hooks
The official Codex app-server and Claude transcript discovery provide baseline
metadata without hooks. The hooks add the exact lifecycle signals needed for
working, waiting-for-input/permission, and ended state.
From a source checkout:
git clone https://github.com/Softween/claude-session-monitor.git
cd claude-session-monitor
bash scripts/install.sh
The installer is idempotent and:
- copies the shared hook implementation into
~/.claude/session-monitor/;
- merges Claude lifecycle hooks into
~/.claude/settings.json;
- merges Codex lifecycle hooks into
~/.codex/hooks.json;
- writes provider-scoped status files under
~/.claude/session-monitor/ and
~/.codex/session-monitor/;
- backs up a config before changing it and preserves already-installed hook command
strings; bounded timeout updates may still require Codex trust to be reviewed again;
- refuses to modify malformed settings, writes valid changes atomically, and keeps
monitor directories/status records private (
0700 / 0600).
Review Codex hook trust
Codex requires new or changed hooks to be reviewed before they run. Installation
also bounds hook timeouts, which changes the trusted hook definition when migrating
an older entry. After installation, open Codex and run:
/hooks
Inspect every Agent Session Monitor lifecycle hook shown as added or modified and
approve it only if it points to the expected local session-monitor/hook.py. Do
not bypass hook trust globally. An added or modified hook remains inactive until
this review is complete. Then start a new Codex session and reload the VS Code
window.
Claude auto-resume and bulk-input actions need a one-time macOS Accessibility
permission for VS Code. The Codex app-server integration itself does not need that
permission.
How it works
The extension normalizes provider observations into one UI while retaining
provider-qualified ids and capability flags.
Claude provider
- Lifecycle records in
~/.claude/session-monitor/<id>.json provide exact state
and, when available, the dedicated worker PID.
- Bounded tails of
~/.claude/projects/.../<id>.jsonl provide titles, recent
conversational state, limit detection, models, and real transcript usage.
- Anthropic account gauges are fetched with the local Claude credential on macOS.
Multi-account tokens are stored only in VS Code Secret Storage.
Codex provider
- The extension launches the configured executable as
codex app-server --stdio.
- It uses the official local JSON-RPC interface for thread listing, thread state,
rate limits, and account usage. It does not read or reverse-engineer Codex's
SQLite state database.
- Codex hooks write small provider-scoped lifecycle records to
~/.codex/session-monitor/<id>.json, adding exact waiting/permission and
process signals where available.
No invented Codex per-session tokens: the Codex app-server methods used here
can expose account rate-limit gauges and account-level usage, but they do not
currently provide a trustworthy token total for each individual session. Codex
session rows therefore leave that value unavailable. The extension never copies
Claude totals, divides an account total across sessions, or labels an estimate as
measured usage.
Privacy
- No telemetry.
- Codex communication stays on local stdio with the official Codex app-server.
- Claude's account-usage request is a read-only request to Anthropic using the
locally stored Claude credential; the token is never logged.
- Multi-account: with
trackAllAccounts on (default), each login's OAuth tokens
(access and refresh token) are kept in VS Code Secret Storage (your OS keychain — same protection as the
original) so the panel can keep refreshing the account you logged out of; account
identity (uuid + email) lives in ~/.claude/session-monitor/accounts.json. Tokens
never touch plain files or logs, unless the optional claude-switch integration
below is active (it shares a 0600 file vault). Disable the setting to stop this, and run
Agent Sessions: Forget Other Claude Accounts to delete anything already stored.
- Hook files contain bounded status metadata, not full transcripts. Codex prompt
text is not copied into its status file. Provider monitor directories are
0700
and status records are atomically replaced as 0600.
- CPU/RAM come from a local
ps; Claude bulk-input automation uses local
osascript keystrokes.
Compatibility with 1.x
Version 2 changes the product name, not its installed identity:
- package name remains
claude-code-session-monitor;
- publisher remains
softween;
- Marketplace id remains
softween.claude-code-session-monitor;
- command, setting, and view ids retain the
claudeSessionMonitor.* namespace;
- the Activity Bar container id remains
claudeSessionMonitor.
Existing keybindings, workspace settings, Marketplace upgrades, and extension
automation therefore continue to work. New provider-aware commands use the same
legacy namespace: claudeSessionMonitor.toggleProvider and
claudeSessionMonitor.resumeSession.
Configuration
All settings are under claudeSessionMonitor.*:
| Setting |
Default |
Description |
enableClaude |
true |
Enable the Claude provider |
enableCodex |
true |
Enable the Codex provider |
codexExecutable |
"codex" |
Machine-level executable used for the local Codex app-server |
codexPollSeconds |
5 |
Codex app-server refresh cadence (minimum 3 seconds) |
notifyOnWaiting |
true |
Notify when a session starts waiting for you |
notifyOnLimited |
true |
Notify when a session hits a limit |
notifyOnDone |
false |
Notify when a session finishes its turn |
closingStatusMarkers |
false |
On a Your turn row, show ✅ / ⏳ / 🟡 instead of the dot when the final reply ends with a line starting with that marker (done, waiting on a background job, needs your decision). Turn on only if your assistant is told to end every turn with such a line |
nativeNotifications |
true |
Native macOS notification on limit/waiting |
stuckAlertMinutes |
5 |
Alert when a working session is silent this long (0 = off) |
cpuHogThreshold |
60 |
CPU% above which a session is flagged 🔥 |
resumeAutoType |
true |
Auto-type resume + Enter (needs Accessibility) |
resumePrompt |
"resume" |
Text typed during a resume sweep |
resumeStaggerSeconds |
60 |
Seconds between sessions in a resume sweep |
resourceSampleMs |
3000 |
CPU/RAM sampling interval |
pollIntervalMs |
1500 |
Status refresh interval |
recentScanMaxAgeHours |
6 |
Show sessions active within the last N hours |
hideEndedAfterMinutes |
30 |
Hide ended sessions after this long |
workspaceOnly |
false |
Only show this workspace's sessions |
trackAllAccounts |
true |
Remember each Claude login + refresh non-active accounts in the background |
autoRotate |
false |
Auto-switch to the account with the most headroom when the active one is nearly spent |
rotateAtPercent |
90 |
Usage percent at which auto-rotate may switch (50-100) |
Account rotation (multiple logins)
- Log in once with each account (
claude /login) while the extension is running, so
its token is captured in VS Code Secret Storage.
- Switch from the account names in the Usage limits panel, the command
Agent Sessions: Switch Claude account, or Switch to Claude account with most
headroom (the star marks that account). Enable
autoRotate to switch
automatically at rotateAtPercent usage.
- Inactive accounts stay usable because the extension refreshes their tokens in the
background. If an account's token has fully expired it shows "needs /login".
Only Claude Code's own login is switched (the keychain item Claude Code-credentials
and the identity in ~/.claude.json); nothing else on your machine is touched. New
Claude Code sessions use the new account, running sessions switch at their next token
refresh. macOS only.
Remote bridge (optional)
Off by default. When you run a relay that implements the /fleet/* routes, the extension can mirror the panel to it and take a few commands back, so a phone app or another client can see your sessions.
- Set
claudeSessionMonitor.remote.url in your user settings to the relay's base URL, without a trailing /fleet (for example https://<your-relay>/). It must be https:// (plain http:// only for localhost / 127.0.0.1). Workspace settings are ignored for remote.url and remote.host, so a repository cannot redirect the bridge.
- Run Agent Sessions: Set remote bridge token and paste the relay's bridge token. It is kept in VS Code Secret Storage, bound to the URL's origin: if you later point
remote.url at another origin the bridge stays off until you set the token again. An empty input clears it.
- Optional:
claudeSessionMonitor.remote.host names this machine (default: the OS host name).
With both the URL and the token set, the extension:
- posts a snapshot (sessions, accounts, a CPU / memory sample) to
POST <url>/fleet/ingest when it changes, at most every 10 s, plus a heartbeat every 2 minutes;
- long-polls
GET <url>/fleet/commands?host=<host>&wait=25 (about one request every 25 s) and runs resume, kill, resumeAll, switchAccount (best, an account id or email) and send (a message into a running Claude session), then posts each result to POST <url>/fleet/commands/<id>/result.
A send takes exactly one path: the session's VS Code terminal (matched by its process tree or name, else the terminal this window resumed the session in); else keystrokes into its Claude Code tab (made active first), only when this VS Code window is focused, the tab is the window's one tab matching the title (exactly, or as Claude Code's 24-character … cut of it, and no other listed session's) and VS Code is the frontmost app; else the session's local uds-messaging inbox. Text written or typed is refused when it has control characters, starts with !, / or #, or is longer than 2000 characters. A command older than 2 minutes is answered expired, one that runs past 60 s timed out, and no remote command opens a prompt here. claudeSessionMonitor.remote.acceptCommands: false keeps the snapshot uploads but answers every command with remote commands disabled on this Mac; claudeSessionMonitor.remote.typeFallback: false never types into a tab. Secret-looking strings in uploaded titles and last lines are replaced with [redacted].
resumeAll still asks for confirmation on this machine before it types anything. Network errors back off from 2 s to 60 s. Agent Sessions: Remote bridge status shows the last push, the last poll and the last error. Clearing the URL or the token stops the bridge.
| Feature |
macOS |
Linux |
Windows |
| Claude + Codex session list |
✅ |
✅ |
✅ |
| Codex official app-server metadata |
✅ |
✅ |
✅ |
| Claude per-session transcript tokens |
✅ |
✅ |
✅ |
| Codex per-session tokens |
Not exposed |
Not exposed |
Not exposed |
| Per-session CPU / RAM |
✅ |
✅ |
⚠️ |
| Claude account usage gauges |
✅ |
➖ |
➖ |
| Native notifications + Claude bulk-input automation |
✅ |
➖ |
➖ |
Cross-platform support for the macOS-only pieces is welcome via PRs.
Development
npm ci
npm run typecheck
npm test
npm run build
npm run package
npm run build bundles src/extension.ts to dist/extension.js.
npm run watch rebuilds during Extension Development Host work. npm run verify
reads real local Claude transcripts and prints diagnostic session metadata; do not
use or share its output when transcript titles are sensitive.
License
MIT © Softween
Optional: claude-switch integration
This section applies only when the separate claude-switch CLI is installed at
~/.claude/bin/claude-switch; it is not part of this extension. Without that
executable the extension never runs it, never reads or creates
~/.claude/state/claude-switch/, shows no claude-switch block or badges, and keeps
refreshing inactive accounts itself as described under Account rotation.
Shared vault with claude-switch
Passive (non-active) account tokens are read from the file vault of claude-switch: ~/.claude/state/claude-switch/vault/<accountUuid>.json (directory mode 0700, files 0600, one JSON blob per account). The extension does not refresh them while that file exists, because refresh tokens rotate and two refreshers break each other.
If the vault lacks an account, the extension seeds it once per refresh token from its own SecretStorage (temp file in the same directory, then atomic rename, mode 0600); without the CLI vault at all it falls back to its own refresh. The active login is still captured from the login keychain as before.
claude-switch block
The top of the Usage Limits view shows what the claude-switch CLI is doing, read from ~/.claude/state/claude-switch/panel.json: claude-switch · <active email> · #<rank> · auto|PAUSED, a muted next: hint, and a collapsed Activity (n) row (click or Enter/Space) listing the last 8 meaningful events with local time. Account cards follow the claude-switch priority order and collapse to one header line (#rank name, status chip, worst gauge); the active one starts open, clicking a header toggles it, and both choices are remembered. Clicking never switches accounts: an open non-active card offers Use this account, which runs claude-switch use <email>. Accounts known only to claude-switch are added to the registry (no token) so their gauges show. Without fresh panel data the view behaves as before (name click switches, Rotate). If the file is missing or older than 10 minutes the block reads claude-switch: no data. The file holds no tokens.