Skip to content

feat: streaming drafts, rich formatting, follow-up interrupts, and UX improvements#152

Open
Fr4nzz wants to merge 2 commits intoRichardAtCT:mainfrom
Fr4nzz:feat/all-improvements
Open

feat: streaming drafts, rich formatting, follow-up interrupts, and UX improvements#152
Fr4nzz wants to merge 2 commits intoRichardAtCT:mainfrom
Fr4nzz:feat/all-improvements

Conversation

@Fr4nzz
Copy link

@Fr4nzz Fr4nzz commented Mar 15, 2026

Summary

  • Streaming draft responses via sendMessageDraft — real-time token streaming in private chats with fallback to editMessageText for groups. Draft cleared before final response to prevent stale bubbles; draft text reset after each 💬 message to avoid accumulation
  • Rich HTML formatting — parse Claude's markdown into Telegram HTML (bold, italic, code, links) with smart message splitting
  • Follow-up message interrupts — send a new message while Claude is working to redirect, like vanilla Claude Code
  • Per-event verbose messages — tool calls, thinking, and assistant text shown as individual messages with configurable verbosity (0/1/2)
  • Image sending via MCP — intercept send_file_to_user tool calls, validate paths, send as Telegram photos
  • SDK integration — use setting_sources=["project"] to avoid plugin MCP conflicts, support SSE-based MCP servers
  • Keep progress messages visible after response with elapsed time

Test plan

  • Send a text message and verify streaming draft appears in real-time
  • Send a follow-up message while Claude is working — verify it interrupts
  • Test /verbose 0, /verbose 1, /verbose 2 — verify output levels
  • Test image sending via Playwright screenshot + MCP send_file_to_user
  • Verify draft bubble clears before final response appears
  • Test in group chat (editMessageText fallback)
  • Run pytest tests/unit/ -o "addopts=" — all tests pass

🤖 Generated with Claude Code

Fr4nzz and others added 2 commits March 15, 2026 21:01
… improvements

Major improvements to the Telegram bot UX:

**Streaming draft responses**
- Real-time token streaming via sendMessageDraft (private chats)
- Falls back to editMessageText for group chats
- Draft cleared before final response to prevent stale bubbles
- Draft text reset after each 💬 message to avoid accumulation

**Rich HTML formatting**
- Parse Claude's markdown into Telegram HTML (bold, italic, code, links)
- Smart message splitting for long responses
- Proper escaping of HTML entities

**Follow-up message interrupts**
- Send a new message while Claude is working to interrupt and redirect
- Like vanilla Claude Code's behavior

**Per-event verbose messages**
- Tool calls, thinking, and assistant text shown as individual messages
- Configurable verbosity (0=quiet, 1=normal, 2=detailed)
- Progress timer shows elapsed seconds

**Image sending via MCP**
- Intercept send_file_to_user MCP tool calls
- Validate image paths (approved directory + /tmp for Playwright screenshots)
- Send as Telegram photos with optional captions

**SDK integration improvements**
- Use setting_sources=["project"] to avoid plugin MCP conflicts
- Support SSE-based MCP servers (persistent Playwright)
- Improved error handling and stderr capture

**Other**
- Keep progress messages visible after response
- Telegram MCP server improvements (file sending, better error handling)
- Updated tests for image path validation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move 🧠 thinking and 💬 assistant text processing BEFORE tool calls
  so messages appear in chronological order (💬 before 💻/✏️)
- Remove draft_streamer.clear() calls that caused "Deleted message"
  ghost and empty [] messages — upstream never clears drafts, the
  bubble disappears naturally when the final message arrives
- Only use the LAST AssistantMessage text for the final response,
  preventing intermediate reasoning from being repeated at the end

Co-Authored-By: Claude Opus 4.6 (1M context) <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