Task 004: Redis Stream FSM Integration
Priority: High Status: Planned Category: Infrastructure / Redis
🎯 Goal
Enable direct access to user FSM states within Redis Stream handlers. This allows background events to trigger state changes and UI updates seamlessly.
🛠 Problem Statement
Currently, Redis handlers only receive raw payload and container. To change a user's state, developers must manually interact with Redis storage.
🚀 Proposed Solution
- Context Building: Update
BotRedisDispatcherto look for auser_id(and optionalchat_id) in the incoming Redis message payload. - Async Director: If IDs are present, the dispatcher will automatically instantiate an
FSMContextand aDirectorobject. - Handler Injection: Allow Redis handlers to accept
director: Directoras an argument, providing the same API as regular Telegram handlers.
✅ Definition of Done
- Redis handlers can perform
await director.set_scene(). BaseStateManagerworks inside Redis handlers.- Documented convention for the
user_idkey in Redis payloads.