Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions apps/desktop/src/app/desktop-controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,33 @@ export function DesktopController() {
return onSessionsChanged(() => void refreshSessions().catch(() => undefined))
}, [refreshSessions])

// Cross-MACHINE session-list sync: BroadcastChannel only reaches windows on
// this machine, and the gateway routes session.info events to the session's
// owning transport only — so a pin/title/create on another desktop never
// reaches this one live (it only showed up after an app restart). Re-pull the
// list on window focus and on a slow poll while focused, mirroring the
// poll-based livesync pattern.
useEffect(() => {
if (isSecondaryWindow()) {
return
}

const refresh = () => void refreshSessions().catch(() => undefined)

window.addEventListener('focus', refresh)

const timer = window.setInterval(() => {
if (typeof document.hasFocus !== 'function' || document.hasFocus()) {
refresh()
}
}, 30_000)

return () => {
window.removeEventListener('focus', refresh)
window.clearInterval(timer)
}
}, [refreshSessions])

const toggleSelectedPin = useCallback(() => {
const sessionId = $selectedStoredSessionId.get()

Expand Down
Loading