From 6a8e7349b151112dbd3a159b18d572d1cb39be56 Mon Sep 17 00:00:00 2001 From: Matt McClaskey Date: Thu, 14 Aug 2025 11:13:26 -0400 Subject: [PATCH] Bugfix/vnc 122 fix idle disconnect (#158) * VNC-122 log idle disconnect, add backup method if postMessage fails * VNC-122 fix bug with brave, fix location of disconnect.html --------- Co-authored-by: matt mcclaskey --- app/ui.js | 6 ++++ core/util/browser.js | 2 +- public/disconnected.html | 72 ++++++++++++++++++++++++++++++++++++++++ vite.config.js | 1 + 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 public/disconnected.html diff --git a/app/ui.js b/app/ui.js index 83def8d3..b08833e3 100644 --- a/app/ui.js +++ b/app/ui.js @@ -1566,7 +1566,13 @@ const UI = { } if (timeSinceLastActivityInS > idleDisconnectInS) { + Log.Warn("Idle Disconnect reached, disconnecting rfb session..."); parent.postMessage({ action: 'idle_session_timeout', value: 'Idle session timeout exceeded'}, '*' ); + + // in some cases the intra-frame message could be blocked, fall back to navigating to a disconnect page. + setTimeout(function() { + window.location.replace('disconnected.html'); + }, 10000); } else { //send keep-alive UI.rfb.sendKey(1, null, false); diff --git a/core/util/browser.js b/core/util/browser.js index 3296e108..429350d0 100644 --- a/core/util/browser.js +++ b/core/util/browser.js @@ -27,7 +27,7 @@ window.addEventListener('touchstart', function onFirstTouch() { // brings us a bit closer but is not optimal. export let dragThreshold = 10 * (window.devicePixelRatio || 1); -export const supportsKeyboardLock = ('keyboard' in navigator && 'lock' in navigator.keyboard && typeof(navigator.keyboard.lock) === 'function'); +export const supportsKeyboardLock = typeof navigator.keyboard?.lock === 'function'; let _supportsCursorURIs = false; diff --git a/public/disconnected.html b/public/disconnected.html new file mode 100644 index 00000000..a8965ae9 --- /dev/null +++ b/public/disconnected.html @@ -0,0 +1,72 @@ + + + + +Session Disconnected + + + + +
+
⚠️
+

Session Disconnected

+

Your remote session has ended due to inactivity or disconnection.

+ Return to Dashboard +
+ + diff --git a/vite.config.js b/vite.config.js index f09cadc0..21e39973 100644 --- a/vite.config.js +++ b/vite.config.js @@ -17,6 +17,7 @@ export default defineConfig({ ViteRestart({restart: ['core/**', 'app/**','kasmvnc-version.txt']}), ], build: { + sourcemap: false, rollupOptions: { input: { main: './index.html',