From 3885802d79ddaabe75f3b1d97d6f423997ec7cf9 Mon Sep 17 00:00:00 2001 From: Dave Date: Fri, 20 Mar 2026 08:07:59 +0000 Subject: [PATCH] story-kit: create 330_refactor_consolidate_chat_transports_into_a_chat_module_with_transport_submodules --- ...a_chat_module_with_transport_submodules.md | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/.story_kit/work/1_backlog/330_refactor_consolidate_chat_transports_into_a_chat_module_with_transport_submodules.md b/.story_kit/work/1_backlog/330_refactor_consolidate_chat_transports_into_a_chat_module_with_transport_submodules.md index 04313aa..fb5bc7f 100644 --- a/.story_kit/work/1_backlog/330_refactor_consolidate_chat_transports_into_a_chat_module_with_transport_submodules.md +++ b/.story_kit/work/1_backlog/330_refactor_consolidate_chat_transports_into_a_chat_module_with_transport_submodules.md @@ -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