Skip to content

Conversation

@remorses
Copy link
Contributor

@remorses remorses commented Jan 21, 2026

Adds support for the draft session/list RFD spec by reading Claude Code's local session files.

  • Implement unstable_listSessions method that parses JSONL session files from ~/.claude/projects/
  • Advertise list capability in sessionCapabilities
  • Support filtering by cwd parameter
  • Implement cursor-based pagination (50 sessions per page)
  • Extract title from first user message, use file mtime as updatedAt

Related: https://agentclientprotocol.com/rfds/session-list

What do you think @benbrandt? Is it ok to do the json files parsing ourselves? I also opened an issue in the claude agent sdk repo but I doubt they will add that functionality in the sdk npm package

@cla-bot cla-bot bot added the cla-signed label Jan 21, 2026
@remorses remorses marked this pull request as ready for review January 22, 2026 09:13
Copilot AI review requested due to automatic review settings January 22, 2026 09:13
@benbrandt
Copy link
Member

@remorses thanks for this! I was planning to just deal with file parsing as well in the meantime. I'll give this a look, but would be great to have for sure, thanks for taking a look!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements the draft session/list RFD specification by adding the ability to list Claude Code sessions stored in the local filesystem. The implementation reads and parses JSONL session files from ~/.claude/projects/, extracts session metadata (title, timestamp, cwd), and provides pagination support.

Changes:

  • Added unstable_listSessions method that parses session files from local storage
  • Advertised list capability in the sessionCapabilities initialization response
  • Implemented cursor-based pagination with page size of 50 sessions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@remorses
Copy link
Contributor Author

Ok I will add tests. I wanted to make sure this feature was welcome first

remorses and others added 9 commits February 2, 2026 15:38
Adds support for the draft session/list RFD spec by reading Claude Code's
local session files from ~/.claude/projects/.

- Parse JSONL session files to extract sessionId, cwd, title, updatedAt
- Support filtering by cwd parameter
- Implement cursor-based pagination (50 sessions per page)
- Advertise list capability in sessionCapabilities
Tests cover:
- Empty/missing projects directory
- Session file parsing (sessionId, cwd, title, updatedAt)
- Title extraction from string and array message formats
- Filtering by cwd parameter
- Sorting by updatedAt descending
- Skipping agent-* files and malformed files
- Cursor-based pagination
Claude encodes paths as: /Users/morse/project -> -Users-morse-project
(leading dash, all slashes become dashes)
- Add comment explaining agent-*.jsonl file filtering
- Use safer firstLine variable instead of lines[0]! assertion
- Improve title extraction with explicit type guards for array content
- Add decodeProjectPath() helper that handles both Unix and Windows paths
- Unix: '-Users-morse-project' -> '/Users/morse/project'
- Windows: 'C-Users-morse-project' -> 'C:\Users\morse\project'
- Update test helper to encode Windows paths correctly
- Add 3 new tests for Windows path handling
The upstream codebase uses process.env.CLAUDE to override the config dir,
but this is undocumented and could conflict with user env vars.
Tests save/restore the original value to avoid side effects.
- Use CLAUDE_CONFIG_DIR const instead of runtime env check
- Use async fs.promises for non-blocking operations
- Add this.logger.error() for error logging
- Add comment explaining pagination rationale
- Update tests to use vi.resetModules() for proper CLAUDE_CONFIG_DIR handling
@benbrandt
Copy link
Member

thanks! It is working for me, so I'll merge and we can see what feedback we get

@benbrandt benbrandt enabled auto-merge (squash) February 2, 2026 15:13
@benbrandt benbrandt merged commit 87fa0a2 into zed-industries:main Feb 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants