Skip to content

fix(channels): close stray thread when the channel feed mounts - #4016

Merged
trunk-io[bot] merged 4 commits into
mainfrom
posthog-code/fix-feed-thread-sidebar-stale
Jul 30, 2026
Merged

fix(channels): close stray thread when the channel feed mounts#4016
trunk-io[bot] merged 4 commits into
mainfrom
posthog-code/fix-feed-thread-sidebar-stale

Conversation

@adboio

@adboio adboio commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Problem

Users could end up looking at a channel's feed with a specific task's sidebar still docked on the right — two mutually exclusive views rendered at once.

Changes

The thread panel's open state (threadPanelStore.openByChannel) is route-independent: it only changes via openThread/closeThread, and nothing cleared it when the feed remounted. So feed → open full task → back to feed left the stale entry in place, and WebsiteChannelHome re-mounted the ThreadSidebar beside the feed.

Fix: when a channel's feed mounts, clear any open-thread entry for that channel (closeThread). Feed and thread panel are mutually exclusive, and the feed rendering is the only reliable signal that no thread is active — the task page's own sidebar is route-driven and unaffected.

How did you test this?

  • Added WebsiteChannelHome.test.tsx: mounts the feed with a thread open and asserts the sidebar doesn't render and the store entry is cleared. Fails against pre-fix code, passes with the fix.
  • packages/ui canvas suite: 290/290 pass.
  • biome check and tsc --noEmit clean on the changed files.

Automatic notifications

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

Created with PostHog Code

The thread panel's open state (threadPanelStore.openByChannel) is
route-independent, and nothing cleared it when the feed remounted — so
feed → task → back to feed could repaint a task sidebar beside the feed.
Feed and thread panel are mutually exclusive, so clear the channel's
open-thread entry on feed mount.

Generated-By: PostHog Code
Task-Id: cdb544dd-fce7-4877-9c38-e91299400585
@trunk-io

trunk-io Bot commented Jul 30, 2026

Copy link
Copy Markdown

😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details.

Generated-By: PostHog Code
Task-Id: cdb544dd-fce7-4877-9c38-e91299400585
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown

React Doctor found 2 issues in 1 file · 2 warnings.

2 warnings

src/features/canvas/components/WebsiteChannelHome.tsx

Reviewed by React Doctor for commit 61fb7c1.

@adboio adboio added the Stamphog This will request an autostamp by stamphog on small changes label Jul 30, 2026
@adboio
adboio marked this pull request as ready for review July 30, 2026 18:58
Comment on lines +140 to +143
useEffect(() => {
const open = useThreadPanelStore.getState().openByChannel[channelId];
if (open) useThreadPanelStore.getState().closeThread(channelId);
}, [channelId]);

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.

P1 Stale sidebar renders before cleanup

When the feed mounts with a stale thread ID, the initial render commits ThreadSidebar before this passive effect clears the store entry, causing the overlapping task panel to flash before disappearing.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/ui/src/features/canvas/components/WebsiteChannelHome.tsx
Line: 140-143

Comment:
**Stale sidebar renders before cleanup**

When the feed mounts with a stale thread ID, the initial render commits `ThreadSidebar` before this passive effect clears the store entry, causing the overlapping task panel to flash before disappearing.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@greptile-apps

greptile-apps Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
### Issue 1
packages/ui/src/features/canvas/components/WebsiteChannelHome.tsx:140-143
**Stale sidebar renders before cleanup**

When the feed mounts with a stale thread ID, the initial render commits `ThreadSidebar` before this passive effect clears the store entry, causing the overlapping task panel to flash before disappearing.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "chore: drop restated comment from channe..." | Re-trigger Greptile

@stamphog

stamphog Bot commented Jul 30, 2026

Copy link
Copy Markdown

Note

🤖 stamphog reviewed df67e26009ad9daa32d738449066cdf860df6234 — verdict: REFUSED

Greptile's unresolved P1 comment on WebsiteChannelHome.tsx (lines 140-143) is a valid, unaddressed technical concern: the cleanup runs in a passive effect after the first commit, so the stale sidebar still renders briefly before disappearing — the exact overlap bug this PR claims to fix isn't fully eliminated, and the added test can't catch it since RTL flushes effects synchronously.

  • Author wrote 0% of the modified lines and has 12 merged PRs in these paths (familiarity MODERATE).
  • greptile-apps[bot] reviewed the current head.
  • Unresolved Greptile P1 comment: stale ThreadSidebar can render before the cleanup effect fires, causing a flash of the mutually-exclusive view the PR is meant to remove.
  • No reviewer approval yet — only a COMMENTED review from the bot with an open concern.
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 9L, 1F substantive, 110L/2F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1c-medium (110L, 2F, single-area, fix)
stamphog 2.0.0b3 .stamphog/policy.yml @ 5ac5892 · reviewed head df67e26

@stamphog stamphog Bot removed the Stamphog This will request an autostamp by stamphog on small changes label Jul 30, 2026
adboio added 2 commits July 30, 2026 15:07
Greptile P1: clearing the open-thread entry in a passive effect still
committed ThreadSidebar for one frame, flashing the overlapping view.
Snapshot the inherited entry during the first render, exclude it from
the sidebar render, and clear the store in the effect for hygiene.
Threads opened from this feed instance are unaffected.

Generated-By: PostHog Code
Task-Id: cdb544dd-fce7-4877-9c38-e91299400585
The ref-based version split the same fact across render, a mutable ref,
and an effect. A lazy useState initialiser captures the inherited entry
once; the render excludes it and one effect clears the store. Same
behavior, one less moving part.

Generated-By: PostHog Code
Task-Id: cdb544dd-fce7-4877-9c38-e91299400585
@adboio adboio added the Stamphog This will request an autostamp by stamphog on small changes label Jul 30, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Contained UI fix to a stale thread-sidebar rendering bug, with tests; the prior reviewer's stale-render flash concern is directly addressed by the diff's render-time suppression logic (hence marked outdated), and this isn't risky territory.

  • Author wrote 0% of the modified lines and has 12 merged PRs in these paths (familiarity MODERATE).
  • 👍 on the PR from greptile-apps[bot].
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 17L, 1F substantive, 133L/2F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1c-medium (133L, 2F, single-area, fix)
stamphog 2.0.0b3 .stamphog/policy.yml @ 5ac5892 · reviewed head 61fb7c1

@trunk-io
trunk-io Bot merged commit 56d86a5 into main Jul 30, 2026
38 checks passed
@trunk-io
trunk-io Bot deleted the posthog-code/fix-feed-thread-sidebar-stale branch July 30, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant