diff --git a/client/src/MediaControl.tsx b/client/src/MediaControl.tsx index 23d7925..90baa3c 100644 --- a/client/src/MediaControl.tsx +++ b/client/src/MediaControl.tsx @@ -782,36 +782,9 @@ const MediaAgent = (props: MediaAgentProps) => { id: t.id, }); - // Do NOT force-enable the original local tracks for bot peers. - // For privacy and principle of least surprise, respect the local user's - // muted/video state. If a bot is added and needs media, mark a pending - // consent on the local peer so the UI can prompt the user. - if (peer.peer_name.includes("-bot")) { - try { - const localPeerId = session.id; - if (updatedPeers[localPeerId]) { - const existingPending = - (updatedPeers[localPeerId].attributes && updatedPeers[localPeerId].attributes.pendingBotConsent) || []; - const botName = peer.peer_name; - if (!existingPending.includes(botName)) { - const newPending = [...existingPending, botName]; - updatedPeers[localPeerId] = { - ...updatedPeers[localPeerId], - attributes: { - ...updatedPeers[localPeerId].attributes, - pendingBotConsent: newPending, - }, - }; - console.log( - `media-agent - addPeer:${peer.peer_name} Marked pending bot consent for local user:`, - newPending - ); - } - } - } catch (e) { - console.warn(`media-agent - addPeer: failed to mark pending bot consent`, e); - } - } + // Respect the local user's muted/video state. Do not force-enable or + // mark pending consent for bots here. The local user's track.enabled + // state (set above) will be used when adding tracks to the connection. // Add the existing track to the connection and rely on the track.enabled // value which was set above based on the local peer's muted/video state. @@ -1021,17 +994,6 @@ const MediaAgent = (props: MediaAgentProps) => { updatedPeers[peer_id].connection = undefined; } - // Also clear any pending bot consent references for this peer name on the local peer - try { - const localPeer = updatedPeers[session.id]; - if (localPeer && localPeer.attributes && localPeer.attributes.pendingBotConsent) { - const pending = localPeer.attributes.pendingBotConsent.filter((b: string) => b !== peer_name); - localPeer.attributes.pendingBotConsent = pending; - } - } catch (e) { - // session may not be available in this closure; ignore safely - } - setPeers(updatedPeers); }, [peers, setPeers] @@ -1555,46 +1517,7 @@ const MediaControl: React.FC = ({ isSelf, peer, className }) ); // Handlers for bot consent prompts (local user only) - const handleAllowBot = useCallback( - (botName: string) => { - if (!peer || !peer.local) return; - - // Clear pending for this bot and unmute/share media - const pending = (peer.attributes && peer.attributes.pendingBotConsent) || []; - const remaining = pending.filter((b: string) => b !== botName); - - peer.attributes = { - ...(peer.attributes || {}), - pendingBotConsent: remaining, - }; - - // Share: unmute and enable video (you might want different behaviour) - setMuted(false); - setVideoOn(true); - peer.muted = false; - peer.video_on = true; - - console.log(`media-agent - User allowed ${botName} to receive media`); - // Note: MediaAgent.addPeer uses the current media.getTracks().enabled state when adding tracks; - // existing connections won't be retroactively changed here. For a nicer UX we could trigger - // renegotiation for that bot connection, but keep this minimal for now. - }, - [peer] - ); - - const handleDenyBot = useCallback( - (botName: string) => { - if (!peer || !peer.local) return; - const pending = (peer.attributes && peer.attributes.pendingBotConsent) || []; - const remaining = pending.filter((b: string) => b !== botName); - peer.attributes = { - ...(peer.attributes || {}), - pendingBotConsent: remaining, - }; - console.log(`media-agent - User denied ${botName} access to media`); - }, - [peer] - ); + // No bot consent handlers — policy: do not override local mute/video state. // Snap-back functionality const checkSnapBack = (x: number, y: number) => { @@ -1700,44 +1623,7 @@ const MediaControl: React.FC = ({ isSelf, peer, className }) muted={peer.local || muted} /> - {/* If this is the local user's UI and there are pending bot consent requests, show them */} - {peer.local && peer.attributes?.pendingBotConsent && peer.attributes.pendingBotConsent.length > 0 && ( -
-
Bots requesting media access:
- {peer.attributes.pendingBotConsent.map((bot: string) => ( -
-
{bot}
- - -
- ))} -
- )} + ) ) : (