storkit: create 400_bug_whatsapp_and_slack_missing_reset_command_handler

This commit is contained in:
dave
2026-03-26 20:06:13 +00:00
parent de54265c35
commit 26d34245f9
@@ -10,7 +10,21 @@ The reset command has a fallback handler in chat/commands/mod.rs that returns No
## Implementation Note
The fix must be in the shared command dispatch layer (chat/commands/mod.rs), NOT by adding transport-specific handlers. Study how commands like "rebuild" and "status" already work through the shared dispatch — the reset handler should return a concrete result from try_handle_command so all transports get it for free. We do not want separate mechanisms per transport per command.
Follow the **rebuild pattern** established in story 402, with one complication: `handle_reset` in `server/src/chat/transport/matrix/reset.rs` takes a Matrix-specific `ConversationHistory` (`Arc<TokioMutex<HashMap<OwnedRoomId, RoomConversation>>>`), so it cannot be called directly from WhatsApp or Slack.
**WhatsApp session storage** (`server/src/chat/transport/whatsapp.rs`):
- Type: `WhatsAppConversationHistory = Arc<TokioMutex<HashMap<String, RoomConversation>>>` (key = sender phone number)
- Persisted to `.storkit/whatsapp_history.json` via `save_whatsapp_history`
**Slack session storage** (`server/src/chat/transport/slack.rs`):
- Type: `SlackConversationHistory = Arc<TokioMutex<HashMap<String, RoomConversation>>>` (key = channel ID)
- Persisted to `.storkit/slack_history.json` via `save_slack_history`
**Approach:**
- Use `extract_reset_command` from `server/src/chat/transport/matrix/reset.rs` to detect the command (it works transport-agnostically)
- Implement the reset inline in each transport's async message handler: clear `session_id` and `entries` for the sender/channel key, call the transport's own `save_*_history`, reply with confirmation
- Add async intercepts in `whatsapp.rs` (~line 1107, after the rebuild intercept) and `slack.rs` (~line 845, after the rebuild intercept)
- The fallback handler in `chat/commands/mod.rs` (`handle_reset_fallback`) stays as-is
## How to Reproduce