Summary
The /sessions command currently shows session IDs and project names but not session names (the name set via /rename in Claude Code, or the auto-generated summary). This makes it hard to identify sessions at a glance.
Additionally, ClaudeSessionScanner has a bug on Windows where project directory paths are not resolved correctly, causing session file lookups to fail entirely.
I implemented and tested these fixes locally - here's what I found and what I'd suggest adding.
Proposed Changes
1. Add session name display to /sessions
Add a sessionName field to ExistingClaudeSession and enrich session listings with display names.
Name resolution priority:
customTitle from sessions-index.json (user-renamed via /rename, already indexed)
customTitle from JSONL transcript {"type":"custom-title","customTitle":"..."} entry (active sessions not yet indexed)
summary from sessions-index.json (auto-generated)
slug from JSONL transcript (auto-generated session slug)
Key discovery: Active/running sessions are not in sessions-index.json (it's updated lazily on session close). However, /rename writes a {"type":"custom-title","customTitle":"..."} entry directly to the session JSONL transcript file. Both sources need to be checked.
Proposed display format:
📁 my-project
🏷️ my-session-name
ID: `5df6045e-21aa-4e6f-ba84-fb43e5f2afed`
3m ago
"last message preview..."
2. Fix Windows path handling (bug)
getSessionFilePath() uses project.replace(/\//g, '-') which only replaces forward slashes. On Windows, project paths like C:\ai\my-project contain backslashes and colons, so the replacement produces an incorrect directory name and session lookups fail.
Claude Code CLI converts project paths to directory names by replacing all non-alphanumeric characters with -. For example:
C:\ai\my-project → C--ai-my-project
Suggested fix: Change to project.replace(/[^a-zA-Z0-9]/g, '-') to match Claude CLI's actual behavior.
Same fix needed in getProjectSessions() and projectName extraction (split('/') → split(/[\/]/)).
3. Add Telegram Markdown escaping (bug)
Session messages and names can contain Markdown-special characters (e.g., _ in post_type). When /sessions sends the response with parse_mode: 'Markdown', unescaped characters cause Telegram API 400 Bad Request: can't parse entities errors.
Suggested fix: Add escapeMarkdown() to sanitize dynamic content in formatSession().
4. Show full session ID
Currently truncated to 8 chars (5df6045e...) which makes it impossible to copy-paste for /attach. Should show the full UUID.
Files That Need Changes
src/utils/ClaudeSessionScanner.ts — Session name resolution, Windows path fix, Markdown escaping
src/bot/TelegramBot.ts — Remove parse_mode: 'Markdown' from /attach response (Windows paths with backslashes break Markdown parsing)
How Claude Code Stores Session Names
For reference, here's where session names live in ~/.claude/:
| Source |
File |
Field |
When Available |
Custom title (via /rename) |
projects/<dir>/sessions-index.json |
entries[].customTitle |
After session is indexed (closed) |
Custom title (via /rename) |
projects/<dir>/<sessionId>.jsonl |
{"type":"custom-title","customTitle":"..."} |
Immediately after rename (including active sessions) |
| Auto-generated summary |
projects/<dir>/sessions-index.json |
entries[].summary |
After session is indexed |
| Auto-generated slug |
projects/<dir>/<sessionId>.jsonl |
slug field on message entries |
Always present |
I have a working implementation locally and happy to submit a PR if you'd like.
Summary
The
/sessionscommand currently shows session IDs and project names but not session names (the name set via/renamein Claude Code, or the auto-generated summary). This makes it hard to identify sessions at a glance.Additionally,
ClaudeSessionScannerhas a bug on Windows where project directory paths are not resolved correctly, causing session file lookups to fail entirely.I implemented and tested these fixes locally - here's what I found and what I'd suggest adding.
Proposed Changes
1. Add session name display to
/sessionsAdd a
sessionNamefield toExistingClaudeSessionand enrich session listings with display names.Name resolution priority:
customTitlefromsessions-index.json(user-renamed via/rename, already indexed)customTitlefrom JSONL transcript{"type":"custom-title","customTitle":"..."}entry (active sessions not yet indexed)summaryfromsessions-index.json(auto-generated)slugfrom JSONL transcript (auto-generated session slug)Key discovery: Active/running sessions are not in
sessions-index.json(it's updated lazily on session close). However,/renamewrites a{"type":"custom-title","customTitle":"..."}entry directly to the session JSONL transcript file. Both sources need to be checked.Proposed display format:
2. Fix Windows path handling (bug)
getSessionFilePath()usesproject.replace(/\//g, '-')which only replaces forward slashes. On Windows, project paths likeC:\ai\my-projectcontain backslashes and colons, so the replacement produces an incorrect directory name and session lookups fail.Claude Code CLI converts project paths to directory names by replacing all non-alphanumeric characters with
-. For example:C:\ai\my-project→C--ai-my-projectSuggested fix: Change to
project.replace(/[^a-zA-Z0-9]/g, '-')to match Claude CLI's actual behavior.Same fix needed in
getProjectSessions()andprojectNameextraction (split('/')→split(/[\/]/)).3. Add Telegram Markdown escaping (bug)
Session messages and names can contain Markdown-special characters (e.g.,
_inpost_type). When/sessionssends the response withparse_mode: 'Markdown', unescaped characters cause Telegram API400 Bad Request: can't parse entitieserrors.Suggested fix: Add
escapeMarkdown()to sanitize dynamic content informatSession().4. Show full session ID
Currently truncated to 8 chars (
5df6045e...) which makes it impossible to copy-paste for/attach. Should show the full UUID.Files That Need Changes
src/utils/ClaudeSessionScanner.ts— Session name resolution, Windows path fix, Markdown escapingsrc/bot/TelegramBot.ts— Removeparse_mode: 'Markdown'from/attachresponse (Windows paths with backslashes break Markdown parsing)How Claude Code Stores Session Names
For reference, here's where session names live in
~/.claude/:/rename)projects/<dir>/sessions-index.jsonentries[].customTitle/rename)projects/<dir>/<sessionId>.jsonl{"type":"custom-title","customTitle":"..."}projects/<dir>/sessions-index.jsonentries[].summaryprojects/<dir>/<sessionId>.jsonlslugfield on message entriesI have a working implementation locally and happy to submit a PR if you'd like.