refactor(bridge): split BridgeManager into focused modules#32
Merged
Conversation
Move all button callback handling (~180 lines) into a dedicated CallbackRouter class. Uses constructor DI with callback functions, matching existing CommandRouter pattern.
Move SDK conversation flow (~400 lines) into a dedicated SDKEngine class. Owns ConversationEngine, activeControls, SDK question state maps. Provider-agnostic — works with both Claude SDK and Codex via LLMProvider.
Move hook notification formatting and delivery (~80 lines) into a dedicated HookEngine class. Re-exports HookNotificationData for backward compatibility with existing consumers.
Move auth check, attachment buffering, permission text resolution, AskQuestion text replies, and hook reply routing (~250 lines) into a dedicated MessageRouter class. BridgeManager.handleInboundMessage is now a thin orchestrator delegating to MessageRouter, CallbackRouter, CommandRouter, and SDKEngine.
- callback-router.test.ts: 24 tests covering all 13+ callback types - message-router.test.ts: 22 tests for auth, buffering, permissions, hook routing - hook-engine.test.ts: 17 tests for notification formatting, context, URLs Total: 506 tests (up from 443)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Split the monolithic
BridgeManager(1138 lines) into 4 focused modules + thin orchestrator:CallbackRouterSDKEngineHookEngineMessageRouterBridgeManagerCommandRouterpatternLLMProviderinterfaceHookNotificationDatare-exported for backward compatibilityTests
callback-router.test.ts(24 tests) — all callback typesmessage-router.test.ts(22 tests) — auth, buffering, permissions, hook routinghook-engine.test.ts(17 tests) — notification formatting, context, URLssdk-engine.test.ts— SDK flow unit tests (complex mock setup, will follow up)Test plan
npm test— 506/506 passedtsc --noEmit— cleannpm run build— successtlivewith linked local build