story-kit: create 330_refactor_consolidate_chat_transports_into_a_chat_module_with_transport_submodules
This commit is contained in:
@@ -10,22 +10,39 @@ name: "Consolidate chat transports into a chat module with transport submodules"
|
||||
|
||||
## Desired State
|
||||
|
||||
The chat/transport code is scattered across the codebase: transport.rs at the top level, matrix/ as a module, whatsapp.rs and slack.rs as top-level files. Consolidate into a unified chat/ module:
|
||||
The chat/transport code is scattered across the codebase: transport.rs at the top level, matrix/ as a module with transport-agnostic command logic baked in, whatsapp.rs and slack.rs as top-level files. Consolidate into a unified chat/ module where common code lives at the top level and only transport-specific details live in submodules.
|
||||
|
||||
- chat/mod.rs — ChatTransport trait, shared types, command dispatch registry
|
||||
- chat/matrix/ — existing matrix/ module (bot.rs, commands/, htop.rs, transport_impl.rs, etc.)
|
||||
- chat/whatsapp.rs — WhatsApp transport (moved from src/whatsapp.rs)
|
||||
- chat/slack.rs — Slack transport (moved from src/slack.rs)
|
||||
Target structure:
|
||||
```
|
||||
server/src/chat/
|
||||
├── mod.rs — ChatTransport trait, shared types, re-exports
|
||||
├── commands/ — command registry and handlers (moved OUT of matrix/)
|
||||
│ ├── mod.rs — BotCommand, CommandContext, CommandDispatch, try_handle_command
|
||||
│ ├── status.rs — handle_status, build_pipeline_status
|
||||
│ ├── cost.rs — handle_cost
|
||||
│ ├── help.rs — handle_help
|
||||
│ ├── git.rs — handle_git
|
||||
│ ├── show.rs — handle_show
|
||||
│ ├── overview.rs — handle_overview
|
||||
│ ├── ambient.rs — handle_ambient
|
||||
│ └── delete.rs — handle_delete
|
||||
├── htop.rs — htop dashboard logic (moved OUT of matrix/ — works on any transport)
|
||||
├── matrix/ — Matrix-specific: bot.rs, transport_impl.rs, config, notifications
|
||||
├── whatsapp.rs — WhatsApp-specific: webhook, transport impl, 24h window
|
||||
└── slack.rs — Slack-specific: webhook, transport impl, slash commands
|
||||
```
|
||||
|
||||
This groups all chat-related code under one module with transport-specific implementations as submodules. The common code (trait, types, command registry) lives at the chat/ level and the platform-specific code lives in submodules.
|
||||
The key insight: commands/, htop, and the ChatTransport trait are transport-agnostic. They currently live inside matrix/ but have nothing to do with Matrix. Only the actual Matrix SDK calls (sending messages, typing indicators, message editing, E2E encryption) are Matrix-specific.
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- [ ] transport.rs moved into chat/mod.rs (ChatTransport trait and shared types)
|
||||
- [ ] commands/ moved from matrix/commands/ to chat/commands/ — no Matrix imports in command handlers
|
||||
- [ ] htop.rs moved from matrix/htop.rs to chat/htop.rs — uses ChatTransport trait, not Matrix types
|
||||
- [ ] whatsapp.rs moved to chat/whatsapp.rs
|
||||
- [ ] slack.rs moved to chat/slack.rs
|
||||
- [ ] matrix/ moved to chat/matrix/
|
||||
- [ ] Command registry (commands/) accessible from chat/ level, not matrix-specific
|
||||
- [ ] matrix/ moved to chat/matrix/ — only contains Matrix-specific code (bot message handler, SDK calls, transport_impl, config)
|
||||
- [ ] matrix/bot.rs no longer contains command dispatch logic — delegates to chat/commands/
|
||||
- [ ] All imports updated throughout the codebase
|
||||
- [ ] All existing tests pass
|
||||
- [ ] No public API changes from the perspective of main.rs and other modules
|
||||
|
||||
Reference in New Issue
Block a user