Skip to content

fix(canvas): open channel-filed task notifications in /website#2784

Merged
raquelmsmith merged 2 commits into
mainfrom
posthog-code/route-channel-task-notifications
Jun 19, 2026
Merged

fix(canvas): open channel-filed task notifications in /website#2784
raquelmsmith merged 2 commits into
mainfrom
posthog-code/route-channel-task-notifications

Conversation

@raquelmsmith

Copy link
Copy Markdown
Member

Problem

When a task needs action, the user gets a desktop notification. Clicking it always opened the task at /code/tasks/$taskId — even when the task was filed to a Project Bluebird channel, where it should open in the channel-organized view at /website/$channelId/tasks/$taskId (keeping the channels chrome), exactly like the command palette already does.

The notification click and posthog-code://task/<id> deep links both funnel through useTaskDeepLink, which called openTask(task) and unconditionally navigated to /code. Nothing consulted channel membership.

Change

  • useOpenTask.tsopenTask now accepts an optional { channelId }. When present it navigates via navigateToChannelTask (→ /website); otherwise /code as before. Every other side effect (detail-cache seed, analytics, ensureWorkspaceForTask) is unchanged, so channel tasks still get workspace provisioning. Existing single-arg callers are unaffected.
  • useTaskDeepLink.ts — resolves channel membership (gated behind PROJECT_BLUEBIRD_FLAG) via useChannels + useTaskChannelMap, mirrored into a ref so the stable handleOpenTask callback reads the current map without tearing down the onOpenTask subscription on each 30s channel poll.
  • CommandMenu.tsx — collapsed its duplicated if/else branch onto the same parameterized openTask, so palette-opened channel tasks also get workspace binding.

This fixes both notification clicks and deep links, since they share the path.

Known limitation

Cold start (app launched by the click before the channel map has loaded) falls back to /code. Warm clicks — the dominant case for "needs action" notifications — route correctly.

Verification

  • pnpm --filter @posthog/ui test run …/useTaskDeepLink.test.tsx — 4/4 pass (added cases: filed task → channel route; flag-off → /code).
  • pnpm --filter @posthog/ui typecheck — clean.
  • biome lint on changed files — clean.

🤖 Generated with Claude Code

Clicking a "task needs action" notification (or a posthog-code://task deep
link) always navigated to /code/tasks/$taskId, even when the task was filed
to a Project Bluebird channel. It now routes filed tasks to their channel
view at /website/$channelId/tasks/$taskId, mirroring the command palette.

- openTask() takes an optional { channelId } and navigates to the channel
  route when present, keeping all other side effects (cache seed, analytics,
  workspace binding) identical.
- useTaskDeepLink resolves channel membership (gated by PROJECT_BLUEBIRD_FLAG)
  via useChannels + useTaskChannelMap, held in a ref so the open-task
  subscription isn't recreated on each channel poll.
- CommandMenu collapsed onto the same parameterized openTask helper.

Generated-By: PostHog Code
Task-Id: 81a5307a-63f0-4aae-8376-60ef3faa0f42
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit bb44140.

@greptile-apps

greptile-apps Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
packages/ui/src/features/deep-links/useTaskDeepLink.test.tsx:77-114
**Prefer parameterised tests for the routing dispatch cases**

The three cold-start routing assertions repeat the same setup (set `channelMapState.map`, mock `getPendingDeepLink`, `renderHook`, `waitFor`) and differ only in flag state, channel map contents, and the expected `routerOpenTask` args. Per the project rule, collapsing them into a single `it.each` would express the same ideas without duplication. A fourth row could cover the warm-start path (trigger via `onOpenTask`'s subscription callback rather than `getPendingDeepLink`) to close that coverage gap at the same time.

Reviews (1): Last reviewed commit: "fix(canvas): open channel-filed task not..." | Re-trigger Greptile

Comment thread packages/ui/src/features/deep-links/useTaskDeepLink.test.tsx Outdated
Collapse the repeated cold-start routing assertions into a single it.each
covering unfiled, channel-filed, and flag-off cases, and add a warm-start
row that drives the onOpenTask subscription callback — closing that coverage
gap. Follows the project's parameterised-test convention.

Generated-By: PostHog Code
Task-Id: 81a5307a-63f0-4aae-8376-60ef3faa0f42

@adamleithp adamleithp 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.

LGTM

@raquelmsmith raquelmsmith marked this pull request as ready for review June 19, 2026 20:01
@raquelmsmith

Copy link
Copy Markdown
Member Author

tested locally, works

@raquelmsmith raquelmsmith merged commit 408eabf into main Jun 19, 2026
27 checks passed
@raquelmsmith raquelmsmith deleted the posthog-code/route-channel-task-notifications branch June 19, 2026 20:01
@greptile-apps

greptile-apps Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Reviews (2): Last reviewed commit: "test(canvas): parameterise task deep-lin..." | Re-trigger Greptile

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