From 4be18278e8616fd54cc6927e2a6c53dba543a8d4 Mon Sep 17 00:00:00 2001 From: OpeOginni Date: Tue, 7 Jul 2026 21:56:46 +0200 Subject: [PATCH 1/2] fix(desktop): skip stale remote session restore --- packages/desktop/src/renderer/index.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/desktop/src/renderer/index.tsx b/packages/desktop/src/renderer/index.tsx index 966fb0c0bf3a..3eab46d97745 100644 --- a/packages/desktop/src/renderer/index.tsx +++ b/packages/desktop/src/renderer/index.tsx @@ -90,11 +90,28 @@ function getLastActiveUrl(windowID: string) { if (typeof localStorage !== "object") return "/" try { const value = localStorage.getItem(windowLastActiveUrlKey(windowID)) - if (value?.startsWith("/") && !value.startsWith("//")) return value + if (value?.startsWith("/") && !value.startsWith("//") && !isStaleWindowsRemoteSessionUrl(value)) return value } catch {} return "/" } +function isStaleWindowsRemoteSessionUrl(value: string) { + if (!navigator.userAgent.includes("Windows")) return false + const match = value.match(/^\/([^/]+)\/session(?:\/|$)/) + if (!match) return false + const directory = decodeRouteSegment(match[1]) + return directory?.startsWith("/") ?? false +} + +function decodeRouteSegment(value: string) { + try { + const binary = atob(value.replace(/-/g, "+").replace(/_/g, "/")) + return new TextDecoder().decode(Uint8Array.from(binary, (char) => char.charCodeAt(0))) + } catch { + return undefined + } +} + function setLastActiveUrl(windowID: string, value: string) { if (typeof localStorage !== "object") return try { From 71a5a47733260aa7980cc7205fa0bc9aedbd6aef Mon Sep 17 00:00:00 2001 From: leecoder Date: Wed, 8 Jul 2026 09:13:56 +0900 Subject: [PATCH 2/2] fix(desktop): apply stale remote session fallback on all platforms PR #35790 only guards Windows. The same stale session restore bug affects macOS/Linux when switching between remote servers. Remove the Windows-only navigator.userAgent check so getLastActiveUrl falls back to home on every OS. --- packages/desktop/src/renderer/index.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/desktop/src/renderer/index.tsx b/packages/desktop/src/renderer/index.tsx index 3eab46d97745..fd3d70a89215 100644 --- a/packages/desktop/src/renderer/index.tsx +++ b/packages/desktop/src/renderer/index.tsx @@ -90,13 +90,12 @@ function getLastActiveUrl(windowID: string) { if (typeof localStorage !== "object") return "/" try { const value = localStorage.getItem(windowLastActiveUrlKey(windowID)) - if (value?.startsWith("/") && !value.startsWith("//") && !isStaleWindowsRemoteSessionUrl(value)) return value + if (value?.startsWith("/") && !value.startsWith("//") && !isStaleRemoteSessionUrl(value)) return value } catch {} return "/" } -function isStaleWindowsRemoteSessionUrl(value: string) { - if (!navigator.userAgent.includes("Windows")) return false +function isStaleRemoteSessionUrl(value: string) { const match = value.match(/^\/([^/]+)\/session(?:\/|$)/) if (!match) return false const directory = decodeRouteSegment(match[1])