Skip to content

Expose session working directory in daemon /list endpoint #132

@lucharo

Description

@lucharo

Summary

The daemon's /list endpoint only returns startedBy, happySessionId, and pid for each session. The working directory is available in memory (TrackedSession.spawnOptions.directory) but not exposed in the response.

Why

External tools (TUIs, scripts, dashboards) that list sessions need the working directory to:

  1. Resume sessions correctlyclaude --resume must run from the original directory since session files are stored per-project (~/.claude/projects/<encoded-cwd>/)
  2. Display useful context — showing which project a session is working in
  3. Avoid brittle workarounds — currently requires reading /proc/{pid}/cwd (Linux-only, fails for dead processes) or reverse-engineering Claude's project directory encoding

Current state

controlServer.ts /list response:

children: z.array(z.object({
  startedBy: z.string(),
  happySessionId: z.string(),
  pid: z.number()
}))

TrackedSession already has:

spawnOptions?: SpawnSessionOptions;  // contains directory: string

And the /session-started webhook receives metadata which may also contain the path.

Suggested change

Add directory (optional) to the /list response:

children: z.array(z.object({
  startedBy: z.string(),
  happySessionId: z.string(),
  pid: z.number(),
  directory: z.string().optional(),
}))

Populated from child.spawnOptions?.directory for daemon-spawned sessions, and from webhook metadata for terminal-started sessions.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions