Skip to content

fix(cleanup channels): Reorganize channels feature into dedicated @posthog/core package#3332

Draft
adamleithp wants to merge 3 commits into
mainfrom
claude/channels-feature-seam-o6enl8
Draft

fix(cleanup channels): Reorganize channels feature into dedicated @posthog/core package#3332
adamleithp wants to merge 3 commits into
mainfrom
claude/channels-feature-seam-o6enl8

Conversation

@adamleithp

Copy link
Copy Markdown
Contributor

Problem

The channels feature (project-bluebird) was scattered across @posthog/core/canvas and @posthog/core/links, mixing it with unrelated canvas and link concerns. This made the feature harder to locate, understand, and evolve independently.

Changes

Reorganized the channels feature into a dedicated @posthog/core/channels package:

  • Moved files from canvas/ and links/ to new channels/ directory:

    • channelTaskSchemas.tschannels/schemas.ts
    • channelName.ts, channelName.test.tschannels/
    • channel-link.ts, channel-link.test.tschannels/
  • Created new channels module (channels/channels.module.ts):

    • Binds ChannelsService (renamed from ChannelTasksService) to CHANNELS_SERVICE token
    • Composes DesktopFsClient from canvas module with AuthService
    • Loaded by desktop app container alongside canvas module
  • Extracted DI tokens to channels/identifiers.ts:

    • CHANNELS_SERVICE (host-agnostic service)
    • CHANNEL_LINK_SERVICE (host-bound deep-link service)
    • Moved from scattered locations in canvas/ and links/
  • Defined service interface (IChannelsService):

    • Extracted from canvas/services.ts to channels/channels.ts
    • Single seam for channel operations; absorbs future channel-identity unification
  • Updated imports across the codebase:

    • host-router channel-tasks router now imports from @posthog/core/channels
    • UI components and hooks updated to reference new package paths
    • Desktop app container loads channelsCoreModule
  • Removed from canvas module:

    • ChannelTasksService binding and CHANNEL_TASKS_SERVICE token
    • IChannelTasksService interface (moved to channels)
    • Channel-related imports from canvas/identifiers.ts and canvas/services.ts
  • Removed from links module:

    • CHANNEL_LINK_SERVICE token (moved to channels/identifiers.ts)
    • ChannelLinkService import (now imported from channels/channel-link.ts)

This reorganization follows the architecture principle of feature cohesion: all channels-related code lives in one place, making the feature boundary clear and enabling independent evolution.

How did you test this?

  • Verified import paths are consistent across all references
  • Confirmed DI bindings are properly wired in desktop app container
  • Checked that service interface matches all call sites in host-router
  • Ensured no circular dependencies introduced

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

https://claude.ai/code/session_01AYbS2SjLS49DSrT7fJLy7T

…src/channels

Create a dedicated channels feature so future channel-identity unification is a
change to one service's internals rather than to every call site. Pure code
relocation with no behavior change; still gated by the existing project-bluebird
flag via the routes that mount these surfaces.

- Move ChannelTasksService -> ChannelsService (channels/channels.ts) with an
  IChannelsService interface; inject the shared DesktopFsClient from canvas.
- Move channel task schemas -> channels/schemas.ts.
- Move validateChannelName -> channels/channelName.ts.
- Move ChannelLinkService -> channels/channel-link.ts.
- Add channels/identifiers.ts (CHANNELS_SERVICE, CHANNEL_LINK_SERVICE) and
  channels/channels.module.ts (channelsCoreModule), loaded beside canvasCoreModule.
- Rewire host-router routers, apps/code DI, and UI imports; drop the old
  channel bindings/tokens from canvas and links.

No core channel store is introduced: channel data state currently lives in
React Query caches in the UI, so an empty domain store would be a dead
abstraction. The api-client-direct channel/task-channel queries are left on
their existing transport; routing them through ChannelsService is the deferred
client migration this seam is designed to absorb.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AYbS2SjLS49DSrT7fJLy7T
@trunk-io

trunk-io Bot commented Jul 10, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit fe51cca.

…vice test

Address architect-review feedback on the channels seam:

- Fix dependency direction: move desktopFsClient (+ DESKTOP_FS_CLIENT token and
  its binding) into channels and have canvas dashboards import it from there, so
  the arrow points canvas -> channels instead of channels -> canvas. channels is
  the foundational seam; canvas is a consumer. Load channelsCoreModule before
  canvasCoreModule since it now binds the shared FS client.
- Raise method altitude for the broader service name: ChannelsService
  list/file/unfile -> listTasks/fileTask/unfileTask (tRPC procedure names on the
  channelTasks router are unchanged, so the UI wire is untouched).
- Add channels.test.ts covering listTasks/fileTask/unfileTask against a faked
  DesktopFsClient (the seam service was previously untested).

Still a pure refactor with no behavior change, gated by the existing
project-bluebird flag.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AYbS2SjLS49DSrT7fJLy7T
@adamleithp adamleithp changed the title Reorganize channels feature into dedicated @posthog/core package fix(cleanup channels): Reorganize channels feature into dedicated @posthog/core package Jul 10, 2026
The channels/schemas import must sort after canvas/dashboardSchemas
(canvas < channels); biome's import-sort assist flagged both files in the
quality CI job. No behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AYbS2SjLS49DSrT7fJLy7T
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants