refactor(messaging): type the platform seam and scope the multi-platform claim#1180
Open
bennycode wants to merge 1 commit into
Open
refactor(messaging): type the platform seam and scope the multi-platform claim#1180bennycode wants to merge 1 commit into
bennycode wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens the MessagingPlatform seam in packages/messaging by replacing unknown-typed service injection points with explicit “port” interfaces that match the exact methods Telegram wizards and flows call, and updates documentation to clarify what is actually platform-agnostic vs Telegram-only.
Changes:
- Introduces typed port interfaces (
ReportSchedulerPort,WatchMonitorPort,StrategyMonitorPort) and uses them in theMessagingPlatformoptional setters instead ofunknown. - Updates Telegram platform wiring and wizard dependencies to accept the new port types (removing the need for down-casts).
- Revises the messaging package README to scope the platform claim and document current limits and what’s required to add a new platform.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/messaging/src/service/restartAccountSessions.ts | Switches monitor parameters to port types to keep the restart helper compatible with the typed platform seam. |
| packages/messaging/src/platform/wizards/watchAddWizard.ts | Updates wizard dependency type to WatchMonitorPort (only the needed methods). |
| packages/messaging/src/platform/wizards/strategyAddWizard.ts | Updates wizard dependency type to StrategyMonitorPort (only the needed methods). |
| packages/messaging/src/platform/wizards/accountEditWizard.ts | Updates wizard dependencies to port types while keeping restartAccountSessions usage intact. |
| packages/messaging/src/platform/TelegramPlatform.ts | Replaces concrete service types with ports for injected scheduler/monitors and removes service-type down-cast coupling. |
| packages/messaging/src/platform/MessagingPlatform.ts | Defines the port interfaces and applies them to the optional setter injection points. |
| packages/messaging/README.md | Clarifies platform support and sets accurate expectations for adding new platforms. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
The
MessagingPlatformabstraction claimed to be multi-platform, but it leaked its Telegram implementation:setReportScheduler?(scheduler: unknown),setWatchMonitor?(...), andsetStrategyMonitor?(...)tookunknownpurely soTelegramPlatformcould down-cast to the concrete service classes. And the README implied a second platform (Discord/Slack) would get the full experience, when in reality every interactive flow (trade confirmation, wizards, inline keyboards, the reportAdd state machine) is grammY-specific.This PR makes the seam honest without building a conversation framework:
unknown:MessagingPlatform.tsnow defines minimal port interfaces describing exactly what a platform may call on the report scheduler and the watch/strategy monitors (derived from whatTelegramPlatformactually invokes). The down-casts inTelegramPlatformare gone; the wizards andrestartAccountSessionsaccept the ports as well. All type-only imports — no runtime coupling added.registerCommand, notifications viaPlatformDispatcher, platform-prefixed user ids) versus Telegram-only (interactive wizards, inline keyboards, multi-step flows), plus an "Adding a new platform" section describing the real surface to implement and its current limits.Behavior is unchanged — this is a typing + documentation fix.
Test plan
npm testinpackages/messaging: 6 test files pass, typecheck clean, dependency-cruiser reports no violationsnpm run lintinpackages/messaging: eslint + prettier clean