From 137edc7cfbf2e82b1f935028c3cb5d5534f1f094 Mon Sep 17 00:00:00 2001 From: Hampus Date: Sat, 22 Aug 2026 10:14:45 +0200 Subject: [PATCH] fix(app): share stream audio by default and reset the opt-out per stream (#1819) --- .../voice/engine/MediaEngineFacade.ts | 1 + ...EngineV2AppScreenShareExecutionAdapter.tsx | 10 ++++++++ .../src/features/voice/state/VoiceSettings.ts | 23 +++++++++++++++---- .../voice/utils/ScreenShareStartFlow.ts | 6 ++++- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/fluxer_app/src/features/voice/engine/MediaEngineFacade.ts b/fluxer_app/src/features/voice/engine/MediaEngineFacade.ts index 3ecd4226c..a499204ad 100644 --- a/fluxer_app/src/features/voice/engine/MediaEngineFacade.ts +++ b/fluxer_app/src/features/voice/engine/MediaEngineFacade.ts @@ -2326,6 +2326,7 @@ class MediaEngineFacade extends Store { sendUpdate?: boolean; playSound?: boolean; restartIfEnabled?: boolean; + preserveStreamAudioPreferences?: boolean; }, publishOptions?: TrackPublishOptions, ): Promise { diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppScreenShareExecutionAdapter.tsx b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppScreenShareExecutionAdapter.tsx index ddefb42bf..d4db550f7 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppScreenShareExecutionAdapter.tsx +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppScreenShareExecutionAdapter.tsx @@ -7,6 +7,7 @@ import {SoundType} from '@app/features/notification/utils/SoundUtils'; import * as ModalCommands from '@app/features/ui/commands/ModalCommands'; import * as SoundCommands from '@app/features/ui/commands/SoundCommands'; import {getElectronAPI} from '@app/features/ui/utils/NativeUtils'; +import * as VoiceSettingsCommands from '@app/features/voice/commands/VoiceSettingsCommands'; import {getStreamKey} from '@app/features/voice/components/StreamKeys'; import AdaptiveScreenShareEngine from '@app/features/voice/engine/AdaptiveScreenShareEngine'; import type {NegotiationReason} from '@app/features/voice/engine/ScreenShareCodecNegotiation'; @@ -691,11 +692,20 @@ class VoiceEngineV2AppScreenShareExecutionAdapter extends Store { playSound?: boolean; restartIfEnabled?: boolean; reason?: string; + preserveStreamAudioPreferences?: boolean; }, publishOptions?: TrackPublishOptions, ): Promise { assert.equal(typeof enabled, 'boolean'); await this.controllerRouting.setEnabled(room, enabled, options, publishOptions); + if (!enabled && options?.preserveStreamAudioPreferences !== true) { + VoiceSettingsCommands.update({ + shareAppAudio: true, + shareDesktopAudio: true, + shareDeviceAudio: true, + muteStreamAudio: false, + }); + } } async executeScreenShareSetEnabledDirect( diff --git a/fluxer_app/src/features/voice/state/VoiceSettings.ts b/fluxer_app/src/features/voice/state/VoiceSettings.ts index 59fe3649c..52ecdf5b8 100644 --- a/fluxer_app/src/features/voice/state/VoiceSettings.ts +++ b/fluxer_app/src/features/voice/state/VoiceSettings.ts @@ -216,6 +216,18 @@ function applyScreenShareAudioConsentMigrationV1(parsed: Record return true; } +function applyScreenShareAudioDefaultOnMigrationV1(parsed: Record): boolean { + if (parsed.screenShareAudioDefaultOnMigratedV1 === true) { + return false; + } + parsed.shareAppAudio = true; + parsed.shareDesktopAudio = true; + parsed.shareDeviceAudio = true; + parsed.muteStreamAudio = false; + parsed.screenShareAudioDefaultOnMigratedV1 = true; + return true; +} + function applyStreamingModeDefaultMigrationV1(parsed: Record): boolean { if (parsed.streamingModeDefaultMigratedV1 === true) { return false; @@ -284,12 +296,13 @@ class VoiceSettings { streamingMode: StreamingMode = 'screenshare'; streamingModeDefaultMigratedV1 = false; hideStreamPreview = false; - muteStreamAudio = true; - shareAppAudio = false; - shareDesktopAudio = false; - shareDeviceAudio = false; + muteStreamAudio = false; + shareAppAudio = true; + shareDesktopAudio = true; + shareDeviceAudio = true; screenShareAudioDeviceId = 'default'; screenShareAudioConsentMigratedV1 = false; + screenShareAudioDefaultOnMigratedV1 = false; outputVolumeRecalibratedV1 = false; backgroundImageId = NONE_BACKGROUND_ID; backgroundImages: Array = []; @@ -424,6 +437,7 @@ class VoiceSettings { changed = applyPiPPopoutDefaultsMigration(parsed) || changed; changed = applyAdaptiveScreenShareQualityMigrationV2(parsed) || changed; changed = applyScreenShareAudioConsentMigrationV1(parsed) || changed; + changed = applyScreenShareAudioDefaultOnMigrationV1(parsed) || changed; changed = applyStreamingModeDefaultMigrationV1(parsed) || changed; changed = applyOutputVolumeRecalibrationMigrationV1(parsed) || changed; if (changed) { @@ -463,6 +477,7 @@ class VoiceSettings { 'shareDeviceAudio', 'screenShareAudioDeviceId', 'screenShareAudioConsentMigratedV1', + 'screenShareAudioDefaultOnMigratedV1', 'outputVolumeRecalibratedV1', 'backgroundImageId', 'backgroundImages', diff --git a/fluxer_app/src/features/voice/utils/ScreenShareStartFlow.ts b/fluxer_app/src/features/voice/utils/ScreenShareStartFlow.ts index 899310704..0fe3b8ea5 100644 --- a/fluxer_app/src/features/voice/utils/ScreenShareStartFlow.ts +++ b/fluxer_app/src/features/voice/utils/ScreenShareStartFlow.ts @@ -357,7 +357,11 @@ async function runConfiguredDisplayScreenShare( logger.warn('No active screen share to restart for Wayland portal source switch'); return false; } - await MediaEngine.setScreenShareEnabled(false, {sendUpdate: false, playSound: false}); + await MediaEngine.setScreenShareEnabled(false, { + sendUpdate: false, + playSound: false, + preserveStreamAudioPreferences: true, + }); } let nativeAudioArmed = false; const isOwnWindowShare = options?.isOwnWindow === true && sourceId?.startsWith('window:');