apps/webapp/src/hooks/useCheckUrlAndOpenHeadingChat.ts opens a heading's chat room when the URL carries a chat deep link. It waits 800ms before publishing the CHAT_OPEN event, and the code says so:
// TODO: we need better flag rather than using setTimeout
const timer = setTimeout(() => {
PubSub.publish(CHAT_OPEN, { ... })
}, 800)
The effect already gates on workspaceId, editorLoading, and providerSyncing. The timer covers whatever those three do not: the heading has to exist in the rendered document before the scroll target resolves.
What to do
Find the real signal that says the heading is mounted and scrollable. Replace the timer with it.
Why this is not labelled good first issue
An 800ms timer is not an arbitrary number. Anything shorter can publish before the heading exists, and the chat then opens with nothing to scroll to. Anything that resolves too late looks like a dead link.
The failure is also silent and machine-dependent. A fast machine can pass every manual check while a slow one breaks. So this needs a Cypress test that proves the ordering, not a hand check.
Done when
The timer is gone, a deep link opens the right heading chat reliably, and a Cypress spec pins the ordering.
Where to ask
Comment here first with the signal you plan to use. That saves you a rewrite.
apps/webapp/src/hooks/useCheckUrlAndOpenHeadingChat.tsopens a heading's chat room when the URL carries a chat deep link. It waits 800ms before publishing theCHAT_OPENevent, and the code says so:The effect already gates on
workspaceId,editorLoading, andproviderSyncing. The timer covers whatever those three do not: the heading has to exist in the rendered document before the scroll target resolves.What to do
Find the real signal that says the heading is mounted and scrollable. Replace the timer with it.
Why this is not labelled
good first issueAn 800ms timer is not an arbitrary number. Anything shorter can publish before the heading exists, and the chat then opens with nothing to scroll to. Anything that resolves too late looks like a dead link.
The failure is also silent and machine-dependent. A fast machine can pass every manual check while a slow one breaks. So this needs a Cypress test that proves the ordering, not a hand check.
Done when
The timer is gone, a deep link opens the right heading chat reliably, and a Cypress spec pins the ordering.
Where to ask
Comment here first with the signal you plan to use. That saves you a rewrite.