storkit: accept 330_refactor_consolidate_chat_transports_into_a_chat_module_with_transport_submodules

This commit is contained in:
Dave
2026-03-20 12:29:12 +00:00
parent c4e45b2841
commit 24ca585fd0

View File

@@ -0,0 +1,52 @@
---
name: "Consolidate chat transports into a chat module with transport submodules"
---
# Refactor 330: Consolidate chat transports into a chat module with transport submodules
## Current State
- TBD
## Desired State
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.
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
```
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/ — 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
## Out of Scope
- TBD