Skip to content

fix: Telegram interrupts are blocked behind the streaming session mutex#888

Open
sam-saffron-jarvis wants to merge 1 commit into
SamSaffron:mainfrom
sam-saffron-jarvis:feat/codereview-fc25a948
Open

fix: Telegram interrupts are blocked behind the streaming session mutex#888
sam-saffron-jarvis wants to merge 1 commit into
SamSaffron:mainfrom
sam-saffron-jarvis:feat/codereview-fc25a948

Conversation

@sam-saffron-jarvis

Copy link
Copy Markdown
Contributor

What changed

  • Check for an active Telegram stream before taking the session mutex used by streamReply for long-running stream serialization.
  • Keep the interrupt path on cancelMu, so a second Telegram message can cancel or interject while the first response/tool run is still streaming.
  • Let handleMessage accept the existing Telegram bot interface so the end-to-end interrupt path can be tested with a fake bot.
  • Added a regression test that starts one blocking Telegram request, sends a second handleMessage, and asserts the first stream context is cancelled before the provider is otherwise released.

Why this is high-value

Sam uses the Telegram/Jarvis path daily, and a follow-up message during a long answer or tool run should be able to stop or steer the work immediately. Previously the second handler blocked on sess.mu in the idle-timeout check, but streamReply holds that mutex for the entire stream, so the cancel/interject logic could not run until the original work was already done.

Validation

  • go test ./internal/serve -run TestHandleMessage_CancelInterruptReachesActiveStreamBeforeSessionMutex -count=1 -v
  • go build ./...
  • go test ./...
  • git diff --check

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