fix(app): ui flashing when switching tabs (#13978)

This commit is contained in:
Filip
2026-02-17 16:49:20 +01:00
committed by GitHub
parent d055c1cad6
commit 46739ca7cd
2 changed files with 5 additions and 1 deletions

View File

@@ -102,8 +102,10 @@ export const { use: useGlobalSDK, provider: GlobalSDKProvider } = createSimpleCo
let attempt: AbortController | undefined let attempt: AbortController | undefined
const HEARTBEAT_TIMEOUT_MS = 15_000 const HEARTBEAT_TIMEOUT_MS = 15_000
let lastEventAt = Date.now()
let heartbeat: ReturnType<typeof setTimeout> | undefined let heartbeat: ReturnType<typeof setTimeout> | undefined
const resetHeartbeat = () => { const resetHeartbeat = () => {
lastEventAt = Date.now()
if (heartbeat) clearTimeout(heartbeat) if (heartbeat) clearTimeout(heartbeat)
heartbeat = setTimeout(() => { heartbeat = setTimeout(() => {
attempt?.abort() attempt?.abort()
@@ -118,6 +120,7 @@ export const { use: useGlobalSDK, provider: GlobalSDKProvider } = createSimpleCo
void (async () => { void (async () => {
while (!abort.signal.aborted) { while (!abort.signal.aborted) {
attempt = new AbortController() attempt = new AbortController()
lastEventAt = Date.now()
const onAbort = () => { const onAbort = () => {
attempt?.abort() attempt?.abort()
} }
@@ -182,6 +185,7 @@ export const { use: useGlobalSDK, provider: GlobalSDKProvider } = createSimpleCo
const onVisibility = () => { const onVisibility = () => {
if (typeof document === "undefined") return if (typeof document === "undefined") return
if (document.visibilityState !== "visible") return if (document.visibilityState !== "visible") return
if (Date.now() - lastEventAt < HEARTBEAT_TIMEOUT_MS) return
attempt?.abort() attempt?.abort()
} }
if (typeof document !== "undefined") { if (typeof document !== "undefined") {

View File

@@ -116,7 +116,7 @@ export async function bootstrapDirectory(input: {
vcsCache: VcsCache vcsCache: VcsCache
loadSessions: (directory: string) => Promise<void> | void loadSessions: (directory: string) => Promise<void> | void
}) { }) {
input.setStore("status", "loading") if (input.store.status !== "complete") input.setStore("status", "loading")
const blockingRequests = { const blockingRequests = {
project: () => input.sdk.project.current().then((x) => input.setStore("project", x.data!.id)), project: () => input.sdk.project.current().then((x) => input.setStore("project", x.data!.id)),