feat(telegram): mid-stream message aborts in-flight turn and resends #47

Merged
weiwen merged 1 commit from sandcastle/issue-43 into main 2026-07-06 19:33:45 +08:00
Owner

Summary

  • When a plain text or attachment message arrives while a turn is streaming, evie aborts the in-flight turn, deletes its partial messages, then answers the new message below the new user message (last-writer-wins)
  • abort_inflight_turn() extracted from clear_session_with_abort() so the abort+delete logic is shared between /clear and mid-stream new messages
  • Session is NOT cleared on abort — aborted partial stays in pi's history so the new prompt runs with full prior context
  • HTTP interface is unaffected
  • Docs updated (CONTEXT.md, DESIGN.md, docs/adr/0001) to remove the claim that streamingBehavior: followUp delegates queueing to pi

Test plan

  • just check passes (90 tests, 0 failures)
  • New session tests: abort_in_flight_then_send_new_message_succeeds and last_writer_wins_second_message_supersedes_first
  • New pi test helper: fake_abortable_then_normal
  • Verify abort_inflight_turn is called at the top of deliver_streaming (before placeholder is sent)
  • Verify clear_session_with_abort is refactored to use abort_inflight_turn
  • Verify doc changes in CONTEXT.md, DESIGN.md, docs/adr/0001

Closes #43

🤖 Generated with Claude Code

## Summary - When a plain text or attachment message arrives while a turn is streaming, evie aborts the in-flight turn, deletes its partial messages, then answers the new message below the new user message (last-writer-wins) - `abort_inflight_turn()` extracted from `clear_session_with_abort()` so the abort+delete logic is shared between `/clear` and mid-stream new messages - Session is NOT cleared on abort — aborted partial stays in pi's history so the new prompt runs with full prior context - HTTP interface is unaffected - Docs updated (`CONTEXT.md`, `DESIGN.md`, `docs/adr/0001`) to remove the claim that `streamingBehavior: followUp` delegates queueing to pi ## Test plan - [ ] `just check` passes (90 tests, 0 failures) - [ ] New session tests: `abort_in_flight_then_send_new_message_succeeds` and `last_writer_wins_second_message_supersedes_first` - [ ] New pi test helper: `fake_abortable_then_normal` - [ ] Verify `abort_inflight_turn` is called at the top of `deliver_streaming` (before placeholder is sent) - [ ] Verify `clear_session_with_abort` is refactored to use `abort_inflight_turn` - [ ] Verify doc changes in CONTEXT.md, DESIGN.md, docs/adr/0001 Closes #43 🤖 Generated with [Claude Code](https://claude.com/claude-code)
weiwen force-pushed sandcastle/issue-43 from 74521bfd1d
Some checks failed
CI / check (pull_request) Failing after 7s
PR Triage — label changes-requested reviews / triage-review (pull_request) Successful in 1s
to 0132eacfdc
All checks were successful
CI / check (pull_request) Successful in 1m18s
PR Triage — label changes-requested reviews / triage-review (pull_request) Successful in 1s
2026-07-06 19:30:18 +08:00
Compare
weiwen merged commit 3ee6d6487b into main 2026-07-06 19:33:45 +08:00
weiwen deleted branch sandcastle/issue-43 2026-07-06 19:33:46 +08:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
weiwen/evie!47
No description provided.