Skip to content

refactor(messaging): type the platform seam and scope the multi-platform claim#1180

Open
bennycode wants to merge 1 commit into
mainfrom
refactor/messaging-platform-seam
Open

refactor(messaging): type the platform seam and scope the multi-platform claim#1180
bennycode wants to merge 1 commit into
mainfrom
refactor/messaging-platform-seam

Conversation

@bennycode

Copy link
Copy Markdown
Owner

Summary

The MessagingPlatform abstraction claimed to be multi-platform, but it leaked its Telegram implementation: setReportScheduler?(scheduler: unknown), setWatchMonitor?(...), and setStrategyMonitor?(...) took unknown purely so TelegramPlatform could 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:

  • Typed ports instead of unknown: MessagingPlatform.ts now defines minimal port interfaces describing exactly what a platform may call on the report scheduler and the watch/strategy monitors (derived from what TelegramPlatform actually invokes). The down-casts in TelegramPlatform are gone; the wizards and restartAccountSessions accept the ports as well. All type-only imports — no runtime coupling added.
  • Scoped claim in the README: documents precisely what is platform-agnostic today (slash commands via registerCommand, notifications via PlatformDispatcher, 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 test in packages/messaging: 6 test files pass, typecheck clean, dependency-cruiser reports no violations
  • npm run lint in packages/messaging: eslint + prettier clean

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the MessagingPlatform optional setters instead of unknown.
  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants