Feature: Exclude human Web viewing from MCP remote control sessions

Complete the bidirectional mutual exclusion between MCP remote control
and human Web viewing (§8.2). Direction 1 (remote_open rejected while a
human session holds the screen sub-connection) already existed; this adds
direction 2: a human Web viewer is now rejected while an MCP session owns
the device.

Add a m_McpTriggeredDevices marker (mirroring m_MfcTriggeredDevices) that
is set when an MCP session is created (BeginScreenCtrlOpen) and cleared at
every session-erasure site (CloseScreenCtrlSession, SweepIdleScreenCtrl,
OnScreenControlClosed, EndScreenCtrlAction), so the marker cannot go stale
and permanently block humans. HandleConnect checks IsMcpTriggered before
mutating client state or starting the remote desktop.

Co-Authored-By: deepseek-v4-pro
This commit was merged in pull request #4.
This commit is contained in:
yuanyuanxiang
2026-08-25 14:14:26 +02:00
parent 25a6e2d07a
commit d55d40e7a2
3 changed files with 45 additions and 1 deletions

View File

@@ -299,6 +299,12 @@ public:
bool IsMfcTriggered(uint64_t device_id);
void ClearMfcTriggered(uint64_t device_id);
// MCP trigger management - an MCP remote control session owns the screen
// sub-connection and blocks human Web viewing (bidirectional mutex, §8.2).
void SetMcpTriggered(uint64_t device_id);
bool IsMcpTriggered(uint64_t device_id);
void ClearMcpTriggered(uint64_t device_id);
// Check if a remote desktop session already exists for device
bool HasActiveSession(uint64_t device_id);
@@ -344,6 +350,10 @@ private:
std::set<uint64_t> m_MfcTriggeredDevices;
std::mutex m_MfcTriggeredMutex;
// MCP triggered devices: screen sub-connection owned by an MCP remote control session
std::set<uint64_t> m_McpTriggeredDevices;
std::mutex m_McpTriggeredMutex;
// Web 终端会话状态
struct WebTermSession {
void* ws_ptr; // browser WebSocket