refactor: split Slack bot worker into focused modules
Summary
- move Slack event, interaction, health, session, message, and pending-request responsibilities into focused modules
- add a small composition root while keeping
index.tsas the stable default app export - preserve Slack
waitUntilscheduling, control-plane payloads, KV keys and TTLs, and existing route behavior
Verification
npm test -w @open-inspect/slack-bot(227 tests passed)npm run typecheck -w @open-inspect/slack-botnpm run build -w @open-inspect/slack-botgit diff --check origin/main...HEAD
Created with Open-Inspect
Summary by CodeRabbit
- New Features
- Added Slack event handling for direct messages, channel messages, app mentions, and app-home interactions.
- Added target selection with clarification prompts and pending-request support.
- Added session creation, prompt submission, thread context, and “Working on…” status updates.
- Added request validation, duplicate-event protection, health reporting, and interaction suggestions.
- Bug Fixes
- Improved handling of invalid requests, missing targets, stale sessions, and failed session operations.
- Tests
- Added coverage for message context, pending requests, and thread-session persistence.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6d9831ac-2e58-4868-bb23-86a1cefe320d
📥 Commits
Reviewing files that changed from the base of the PR and between 94ebec78f8e0080d1ea9cdc362d168285aacee32 and 0c40f81deacfc2979c53941cf7ea253512d401e6.
📒 Files selected for processing (2)
packages/slack-bot/src/pending-requests/pending-request-store.tspackages/slack-bot/src/sessions/thread-session-store.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/slack-bot/src/sessions/thread-session-store.test.ts
- packages/slack-bot/src/pending-requests/pending-request-store.ts
📝 Walkthrough
Walkthrough
The Slack bot is split into a typed Hono app with dedicated health, event, and interaction routes. New dispatchers handle Slack events and block actions, while message handlers manage context, target clarification, KV-backed state, session creation, and prompt delivery.
Changes
Slack bot HTTP and event flow
| Layer / File(s) | Summary |
|---|---|
HTTP routes and app wiring packages/slack-bot/src/app.ts, packages/slack-bot/src/index.ts, packages/slack-bot/src/routes/* |
The Hono app mounts health, event, interaction, and callback routes. Slack signatures, payloads, event deduplication, and asynchronous dispatch are handled in dedicated routers. |
Event dispatch and message handling packages/slack-bot/src/events/*, packages/slack-bot/src/messages/* |
Slack event callbacks route to app-home, direct-message, mention, and channel handlers, which process context, existing sessions, clarification requests, and new session prompts. |
Interaction target selection and pending requests packages/slack-bot/src/interactions/*, packages/slack-bot/src/pending-requests/* |
Block actions resolve selected targets and use KV storage for pending clarification requests, including expiration, retrieval, and deletion behavior. |
Control-plane sessions and thread persistence packages/slack-bot/src/sessions/* |
Session creation and prompt delivery are orchestrated through the control plane, with thread sessions persisted in KV and covered by storage tests. |
Estimated code review effort: 4 (Complex) | ~45 minutes
Sequence Diagram(s)
sequenceDiagram
participant Slack
participant HonoRoutes
participant EventDispatcher
participant MessageHandler
participant SessionLauncher
participant ControlPlane
Slack->>HonoRoutes: Submit signed event
HonoRoutes->>EventDispatcher: Schedule validated event
EventDispatcher->>MessageHandler: Dispatch message event
MessageHandler->>SessionLauncher: Start session and send prompt
SessionLauncher->>ControlPlane: Create session and send prompt
ControlPlane-->>SessionLauncher: Return session response
Possibly related PRs
- ColeMurray/background-agents#646: Related Slack routing and “Starting…” thread-status behavior.
- ColeMurray/background-agents#647: Related working-message block construction and status scheduling consolidation.
- ColeMurray/background-agents#812: Related Slack interaction payload validation at the interactions boundary.
Suggested reviewers: open-inspect
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly summarizes the main refactor: splitting the Slack bot worker into focused modules. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✨ Finishing Touches
📝 Generate docstrings
- [ ] Create stacked PR
- [ ] Commit on current branch
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Commit unit tests in branch
refactor/slack-bot-modules
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Terraform Validation Results
| Step | Status |
|---|---|
| Format | ✅ |
| Init | ✅ |
| Validate | ✅ |
Note: Terraform plan was skipped because secrets are not configured. This is expected for external contributors. See docs/GETTING_STARTED.md for setup instructions.
Pushed by: @ColeMurray, Action: pull_request
Terraform Validation Results
| Step | Status |
|---|---|
| Format | ✅ |
| Init | ✅ |
| Validate | ✅ |
Note: Terraform plan was skipped because secrets are not configured. This is expected for external contributors. See docs/GETTING_STARTED.md for setup instructions.
Pushed by: @open-inspect[bot], Action: pull_request
Review summary follow-up:
- Applied: represented the newly introduced pending-request TTL constant in milliseconds and converted at the Cloudflare KV boundary; behavior remains one hour.
- Applied: added rejected KV write/delete coverage for the extracted thread-session store.
- Not changed: event dedupe TTL remains the pre-existing literal 3600; changing its representation is unrelated to the extraction.
- Not changed: the createSession positional signature is unchanged from the original function; an options-object redesign is outside this behavior-preserving refactor.
- Not changed: thread-session KV shape handling uses the same loose object validation as the original implementation; stricter persisted-data validation is a separate behavior change.
Commit: 0c40f81. Verification: 19 test files / 238 tests passed, typecheck passed, build passed.
Terraform Validation Results
| Step | Status |
|---|---|
| Format | ✅ |
| Init | ✅ |
| Validate | ✅ |
Note: Terraform plan was skipped because secrets are not configured. This is expected for external contributors. See docs/GETTING_STARTED.md for setup instructions.
Pushed by: @open-inspect[bot], Action: pull_request