disable hidden video disconnect by default

This commit is contained in:
legop3
2026-07-26 21:08:24 -04:00
parent 0f9bed9c99
commit d000b8f4f8
9 changed files with 59 additions and 21 deletions
+14
View File
@@ -10,6 +10,7 @@ const EXTERNAL_SPECTATOR_ACCESS_MODES = new Set(['off', 'on', 'verifiedOnly', 'a
const DEFAULT_BANDWIDTH_SAVINGS = Object.freeze({
multiTabProtection: 'verifiedOnly',
pauseHiddenRoverVideo: false,
nonTurnVideo: Object.freeze({
mode: 'snapshots',
userThreshold: 0,
@@ -28,6 +29,15 @@ function normalizeEnum(value, allowed, fallback) {
return allowed.has(normalized) ? normalized : fallback;
}
function normalizeBoolean(value, fallback) {
/*
YAML booleans must stay real booleans. Treating strings such as "false" as
truthy would silently enable a bandwidth policy that the operator intended
to disable, so invalid values fall back to the documented server default.
*/
return typeof value === 'boolean' ? value : fallback;
}
function normalizeNonTurnVideo(value) {
const raw = value && typeof value === 'object' && !Array.isArray(value) ? value : {};
const threshold = Number(raw.userThreshold);
@@ -53,6 +63,10 @@ function buildBandwidthSavingsPolicy(config = loadConfig()) {
MULTI_TAB_MODES,
DEFAULT_BANDWIDTH_SAVINGS.multiTabProtection,
),
pauseHiddenRoverVideo: normalizeBoolean(
raw.pauseHiddenRoverVideo,
DEFAULT_BANDWIDTH_SAVINGS.pauseHiddenRoverVideo,
),
nonTurnVideo: normalizeNonTurnVideo(raw.nonTurnVideo),
externalSpectatorVideo: normalizeEnum(
raw.externalSpectatorVideo,