Skip to content

Add streaming output via editMessageText + /verbose tool display#21

Open
1872-svg wants to merge 1 commit intomoazbuilds:masterfrom
1872-svg:feature/streaming
Open

Add streaming output via editMessageText + /verbose tool display#21
1872-svg wants to merge 1 commit intomoazbuilds:masterfrom
1872-svg:feature/streaming

Conversation

@1872-svg
Copy link
Copy Markdown

@1872-svg 1872-svg commented Mar 11, 2026

Summary

  • Live streaming responses: Claude's output streams to Telegram in real time using editMessageText. Sends a placeholder on the first chunk, then progressively edits it as text arrives (throttled to 500ms). Final edit applies full HTML formatting.
  • Race condition fix: waitForStreamMsg() ensures the placeholder sendMessage resolves before the handler decides to edit-vs-send, eliminating duplicate messages when Claude responds faster than the API round-trip.
  • /verbose mode: Toggle per-chat display of tool calls. When on, the streaming message shows tool activity above the response text:
    ● Write(tcp_tls.py)
      ⎿  [Write] Wrote 117 lines
    ● Bash(python3 test.py)
      ⎿  [Bash] all tests passed
    
    Final response text here...
    
  • /verbose is off by default — normal users see clean responses, power users can opt in.

Implementation details

runner.ts: switched main execution from --output-format json to --output-format stream-json --verbose. Added runClaudeStreaming() which parses NDJSON line-by-line, delivers text deltas via onChunk, and fires onToolEvent(line) for tool_use/tool_result events.

telegram.ts: makeStreamCallback() builds a closure that manages the streaming message lifecycle. In verbose mode it maintains separate toolLines and textAcc buffers and rebuilds the display on each flush.

Note: This PR depends on the fork-agent PR (#20) — it uses isMainBusy() and killActive() for auto-routing.

Test plan

  • Send any message — response should stream live instead of appearing all at once
  • /verbose → send a prompt that uses tools — tool calls should appear in the message as they happen
  • /verbose again — should toggle off, responses go back to clean text
  • Send a very fast one-word prompt — verify no duplicate messages

@1872-svg 1872-svg force-pushed the feature/streaming branch from 262862d to b60ba09 Compare March 11, 2026 03:37
- Stream-json output with real-time Telegram message editing
- /verbose command to show tool calls in streaming message
- Sliding window display (last 8 tool lines, 15 text lines) to stay within 4096 limit
- Newline separation between successive assistant message turns
- Fork agent (haiku) for parallel queries when main agent is busy
- /kill command to stop active agent
- Fix duplicate messages from edit/sendMessage race condition
- Fix verbose final message lost when edit fails silently
- Fix verbose fallback duplicate on short text-only responses

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@1872-svg 1872-svg force-pushed the feature/streaming branch from 3139412 to 30b4243 Compare March 11, 2026 12:41
Fenrur added a commit to Fenrur/claudeclaw that referenced this pull request Mar 13, 2026
… and /kill command

From upstream PR moazbuilds#21 by 1872-svg (streaming + verbose) and PR moazbuilds#20 (fork agent).
- Streaming output via editMessageText for real-time response display
- /verbose command to show tool calls in Telegram
- /fork command for parallel lightweight agent using Haiku
- /kill command to terminate active agent
- Auto-routing to fork when main agent is busy
- Merged with additionalDirs (moazbuilds#13) and session corruption fix (moazbuilds#26)

Co-Authored-By: 1872-svg <1872-svg@users.noreply.github.com>
justmaker added a commit to justmaker/claudeclaw that referenced this pull request Mar 31, 2026
- 重新組織為 Overview / Getting Started / Configuration / Features / Troubleshooting / Testing / Development
- 加入完整 settings.json schema 範例(含所有欄位與註解)
- 每個 feature 獨立章節:一句話說明 + 設定範例 + 行為說明
- 涵蓋所有已實作功能:Multi-Token Pool、OAuth、STT、Auto-Compact、Heartbeat、
  Thread Hire/Fire、Session Metrics、Concurrent Processing、Skill System、
  Graceful Shutdown、Structured Logging、Settings Hot-Reload
- 移除重複內容,統一格式
- 新增 Troubleshooting 常見問題表
- 新增 Development 專案結構說明
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