Skip to content

feat: enhance /sessions with message preview and sorted listing#25

Open
yuxiaoyang2007-prog wants to merge 2 commits intoop7418:mainfrom
yuxiaoyang2007-prog:feat/sessions-preview
Open

feat: enhance /sessions with message preview and sorted listing#25
yuxiaoyang2007-prog wants to merge 2 commits intoop7418:mainfrom
yuxiaoyang2007-prog:feat/sessions-preview

Conversation

@yuxiaoyang2007-prog
Copy link
Copy Markdown

Summary

Enhances the /sessions command to help users identify and distinguish between sessions:

  • Message preview: Shows the last message (user or assistant) for each session, similar to how claude --resume displays session context in the terminal
  • Sorted by activity: Sessions are sorted by most recently active first (updatedAt desc) instead of insertion order
  • Current session marker: The active session is marked with a ◀ indicator
  • Increased limit: Shows up to 15 sessions (was 10)

Before

Sessions:

abc12345... [active] ~/projects/foo
def67890... [inactive] ~/projects/bar

After

Sessions:

1. abc12345 ◀
    💬 那 iPhone 上试试?打开 Tailscale app → Exit Node…
2. def67890
    💬 这个库不是我自己的github库,是别人的对吧

Implementation details

  • Reads the tail (last 64KB) of each session's JSONL file for performance
  • Strips markdown formatting (bold, headers, code, lists, links) and collapses to single-line preview
  • Filters out system/meta messages (commands, timestamps, system reminders)
  • Works cross-platform (uses os.homedir() and path.join())

Test plan

  • Verify /sessions shows message previews on Feishu
  • Verify current session is marked with ◀
  • Verify sessions are sorted by most recent first
  • Verify on Telegram and Discord adapters
  • Verify performance with many sessions (reads only file tail)

🤖 Generated with Claude Code

yuxiaoyang2007-prog and others added 2 commits April 1, 2026 14:28
- Show last message preview (user or assistant) for each session
- Sort sessions by most recently active first (updatedAt desc)
- Mark current session with ◀ indicator
- Increase display limit from 10 to 15 sessions
- Clean markdown/HTML from preview text for single-line display
- Read only tail of JSONL files (64KB) for performance

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- /sessions now shows both IM-bound and terminal CLI sessions
- CLI sessions display [CLI] tag with working directory
- /switch <n> switches to any session (IM or CLI) by number
- IM switch: rebinds current chat via bindToSession
- CLI switch: creates new binding with sdkSessionId for resume
- Aborts running task on old session before switching
- Updated /start and /help to list /switch

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant