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). A ⏳ row moves to an In background group right after Your turn, soonest finish first (finish time read from bitiş ~HH:MM, also finish / due), and returns to Your turn flagged late 5 min past that time, or after 90 min idle without one. 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 |
tabAutomation |
true |
Master switch for everything that shows, moves or types into tabs on its own: wakeDeadTabs, continuityChannel, the resume and command sweeps, autoResumeAfterReset and remote typing (each still needs its own setting). Off stops them all at once, a wake, tab restore or sweep in progress included. They also stay off while the Claude Code extension lacks a command they call or its session tabs are not claudeVSCodePanel webviews; the Sessions view then says so. Tab wakes (wakeDeadTabs, continuityChannel) also wait while macOS reports memory pressure (warn or worse) and stop at 3 per 5 minutes per window, backing off after a refusal; user settings only |
wakeDeadTabs |
false |
After a restart, briefly activate each restored Claude Code tab whose session stopped on a usage limit (last reply a 429 API error, at most 24 h old) so its process runs again, then restore your tabs and focus. Uses Claude Code's claude-vscode.editor.open; user settings only. Wake limit-stopped tabs now runs it at once |
continuityChannel |
false |
The window end of the continuity daemon (part of the ~/.claude tooling, not of this extension), which decides which dormant Claude Code tabs are owed a resume after a restart. When on, the monitor reads the daemon's requests for this window from ~/.claude/state/continuity/requests.json every 10 s and makes each session's existing tab (label = the request's title) the active tab of its group, ahead of the wakeDeadTabs wakes: one tab per step, only while the window is unfocused or you are idle, then your tabs and focus come back. It never creates a tab or types anything, gives each request two tries and writes a heartbeat with the results to ~/.claude/state/continuity/ext/. Independent of wakeDeadTabs; user settings only. Without the daemon it does nothing |
restartGuard |
false |
When on, keep a small Claude restart guard tab (Restart stops Claude sessions.claudeguard) open in the first editor group. While it is open, VS Code asks Please confirm restart of extensions. before it restarts extensions (to apply an extension update, say), because that restart stops every Claude Code session in the window. Window reloads and VS Code restarts are not covered. When a window opens the guard tab is shown once, so VS Code loads it, and the tab you had open comes back |
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.
Limit burn
The Burn tab at the bottom of the Usage limits view ranks Claude sessions by how fast they spend your subscription
limits over the last 5m, 15m, 1h or 5h. Subagent work counts toward the session that
started it, and each row names what drives the burn (subagents, a large context, cache writes).
+18%/h is the session's pace over the last 5 minutes, in points of the 5-hour limit
per hour. ≈ 23% is how much of the 5-hour limit it used in the selected window.
- These are estimates: Anthropic does not publish how subscription limits weigh tokens,
so tokens are weighted by API list prices as a proxy and scaled against the account's
own 5-hour gauge. Until that gauge has moved 3 points, figures stay in API-equivalent
dollars.
Terminal view: npm run burn -- [--window 5m|15m|1h|5h] [--once] [--json].
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), send (a message into a running Claude session), newSession (a new Claude session in one of the snapshot's allowedCwds), autoResume (one limited session in or out of the auto-resume sweep) and answer (an answer to a waiting AskUserQuestion), 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].
A newSession { cwd, text? } runs only when cwd is exactly one of the snapshot's allowedCwds: the workspace folders of VS Code windows that trust their workspace, plus the folders of sessions seen in the last 7 days inside one of them (newest first, at most 30). It starts claude --session-id <new id> by its absolute path in a new background terminal in that folder, and writes the optional first message (same rules as send, at most 4 KB) only after the session's SessionStart hook record appears; a session that has not started after 35 s has its terminal closed. Without a first message the new session is listed at once as Your turn (waitReason idle, titled session <first 8 characters of its id>) and stays listed while its terminal's process runs.
Each session row also says why it waits and where it works. waitReason (waiting and Your turn rows, else null): question while Claude's newest tool call is an AskUserQuestion without an answer, permission while the newest hook event is a permission prompt notification, otherwise idle. git: the branch and the number of changed files of the session's folder (git status, every 30 s) and, for a branch other than main / master / develop, its pull request with state and checks (gh pr view, every 3 minutes, at most 10 gh calls a minute); null outside a repository, pr null without gh or a pull request. autoResume (limited rows, else null): {enabled, at}, whether the auto-resume sweep resumes this session after the limit resets and when the sweep is scheduled (epoch seconds). An autoResume { sessionId, enabled } command switches one limited Claude session in or out of that sweep, also while claudeSessionMonitor.autoResumeAfterReset is off; the choice is shared by every window and ends once the session is no longer limited.
Answering a question from the phone needs scripts/answer_hook.py copied to ~/.claude/session-monitor/answer_hook.py and registered in your Claude Code user settings with the matcher AskUserQuestion for PermissionRequest (timeout 610) and, for its log only, PreToolUse (timeout 5). In a session that runs in the Claude Code panel (or an Agent SDK host) the PermissionRequest hook runs next to the question dialog: it writes ~/.claude/session-monitor/answers/<session>.waiting.json (0600) and waits up to 10 minutes; whichever answer comes first, the dialog's or the phone's, applies. While that marker is live and the transcript still shows the question open, the row carries answerable: {deadline} (epoch seconds). An answer { sessionId, toolUseId?, answers } command (answers maps each question text to an option label, labels joined with , for a multi-select question, or a free text of at most 500 characters without line breaks; question texts and labels may also come redacted and cut the way the Agent Fleet chat tailer shows them) is checked against the marker and written as <session>.answer.json (0600) for the hook, which hands it to Claude. The reply is Cevap iletildi, or a Turkish reason such as Mac'te cevaplandı or Süre doldu; soruyu Mac'te cevapla. A terminal (cli) session never waits for the phone, and an off file in that answers folder turns the waiting off (the hook then only logs).
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 and a muted next: hint, on every tab. A tab bar pinned to the bottom of the view switches between Accounts (the cards below), Burn (see Limit burn), Resets N (each account's limit resets, with a Use button per kind) and Activity N (the last 8 meaningful events with local time); the chosen tab is remembered per workspace. 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.