Commit graph

1 commit

Author SHA1 Message Date
dj-oyu
d7a2e3cb1c feat: two-phase PDF follow-up message handling
Add two-phase message handling for PDF files sent without text (common
in Telegram reply-with-attachment flow):

Phase 1 (pre-OCR, 5s wait):
- Send hint message when bare PDF arrives
- Wait up to 5 seconds for follow-up message with OCR keywords
  (e.g. "figures"/"図版") to set OCR flags before processing starts

Phase 2 (during OCR):
- Run processMessage/OCR concurrently while draining the message queue
- Buffer same-chat messages as user instructions for post-OCR LLM turn
- Support cancel keywords ("cancel"/"中止"/"キャンセル") to abort OCR
- After OCR + initial LLM response, merge buffered messages into a
  follow-up LLM turn so user instructions are processed with context

Refactors llmWorker into llmWorkerNormal/llmWorkerPDF with shared
helpers (sendResponseIfNeeded, resetMessageTool).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 05:03:47 +09:00