Skip to content

fix(desktop): keep channel-sections scoped to the active community - #7241

Open
changsheng1224 wants to merge 1 commit into
block:mainfrom
changsheng1224:fix/7207-channel-sections-community-scope
Open

fix(desktop): keep channel-sections scoped to the active community#7241
changsheng1224 wants to merge 1 commit into
block:mainfrom
changsheng1224:fix/7207-channel-sections-community-scope

Conversation

@changsheng1224

Copy link
Copy Markdown

Problem

Desktop persists and publishes the channel-sections layout of the
previously active community into the newly active community after a
workspace switch. Community A's kind:30078 d=channel-sections event (and
the matching localStorage key) can end up with channel UUIDs and section
objects that exist only on community B.

This is a persistence/publish bug, not only a render bug: the wrong assignment
map is written to the other community's relay, so it survives restarts and
follows the user to a new machine.

Cause

Section state is keyed …:<pubkey>:<relayUrl>, but in-memory writers and
first-sync seed-publish were not reliably fenced to the active community
before channels were ready. A stale store (or a polluted local blob) could be
persisted/published under the new relay URL, including while the channel
allowlist was still empty and filtering was a no-op.

Fix

  • Fence persist/publish by community scope generation so prior-community
    writers cannot land under the new relayUrl.
  • Scope assignments to known channel ids of the active community before
    localStorage write and kind:30078 publish; drop section folders that only
    held foreign-channel assignments.
  • Defer bootstrap seed-publish until the channel list is ready
    (channelsReady), then heal already-polluted local state and republish the
    cleaned blob.
  • Filter the rendered sections/assignments the same way so a stale payload
    cannot resurrect the symptom.

Related

Testing

  • pnpm exec node --import ./test-loader.mjs --experimental-strip-types --test
    on:
    • desktop/src/features/sidebar/lib/channelSectionsHelpers.test.mjs
    • desktop/src/features/sidebar/lib/useChannelSections.test.mjs
    • desktop/src/features/sidebar/lib/channelSectionsSync.test.mjs
    • desktop/src/features/sidebar/lib/channelSectionsStorage.test.mjs
      (58 passed)
  • Falsifiability: the new Desktop: channel sections of one community are published into another community's relay after a workspace switch #7207 hook tests fail against origin/main
    useChannelSections.ts and pass with this change
  • pnpm exec playwright test --project=smoke tests/e2e/community-rail.spec.ts -g 7207
    (1 passed — organize on B, switch to A, assert A's store and post-switch
    sign_event payloads carry no B section layout)

Fence writers by community scope, filter foreign assignments before persist/publish, defer seed until channels are ready, and heal polluted local blobs so a workspace switch cannot write B's layout into A's kind:30078 channel-sections event.

Fixes block#7207

Signed-off-by: changsheng1224 <152450618+changsheng1224@users.noreply.github.com>
@changsheng1224
changsheng1224 requested a review from a team as a code owner September 2, 2026 16:15
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

🔐 Codex Security Review

Status: review required for the current range.

The current range is 1c8321cd08feb597f8bcff5195c21148fb3e98ed...33c24ab88b87ae8205363c1127a197084dc9965f.
A new review must complete for this exact range. When manual authorization
is required, a Block organization member must comment exactly
@buzz-security-review 33c24ab88b87ae8205363c1127a197084dc9965f to authorize a new review.
Any previous review applies only to its recorded range.

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.

Desktop: channel sections of one community are published into another community's relay after a workspace switch

1 participant