Skip to content

Feature request: Show session names in /sessions + Windows path fix #4

@deedeeharris

Description

@deedeeharris

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:

  1. customTitle from sessions-index.json (user-renamed via /rename, already indexed)
  2. customTitle from JSONL transcript {"type":"custom-title","customTitle":"..."} entry (active sessions not yet indexed)
  3. summary from sessions-index.json (auto-generated)
  4. 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-projectC--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.

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