mirror of
https://gh-proxy.org/https://github.com/klinsmaya/multica.git
synced 2026-11-08 09:26:50 +08:00
`app/[workspaceSlug]/layout.tsx` writes the platform workspace singleton from render. The App Router can keep a previous workspace's layout mounted beside the incoming one, and both re-render on their own query activity, so the unguarded write let them alternate — every render flipping the singleton back to its own slug, indefinitely. Two things read that singleton and broke with it: - `packages/core/realtime/provider.tsx` binds the realtime socket to the slug, so each flip tore the socket down and rebuilt it against the other workspace. Seen on a self-host as a `close 1005` / reconnect pair every 20-35s alternating workspace, with realtime updates lost for whichever workspace the user was actually looking at. - `packages/views/editor/extensions/mention-suggestion.tsx` reads it synchronously when the user types `@`, then looks up the agent and member caches by that id. Pointed at the other workspace those caches are cold, so the mention list came back empty. Gate the write on the live pathname. The URL is the source of truth for workspace identity and `usePathname()` returns one value shared by every mounted instance, so exactly one layout — the routed one — can define it, with no ownership handshake. Desktop keeps its own protocol (`workspace-route-layout.tsx`) because it has no URL bar to appeal to. Co-authored-by: Claude Opus 5 <[email protected]>