control-channel: the Awake test moves into Session, where the beat is
Round-2 QA finding: the channel reset beatInputEventCount on its own clock, out of phase with every connection's heartbeat instant, so a session could send Heartbeat (20) where Windows sends Awake (21) — and Awake is what drives the peer's Common.HumanBeingDetected() (Receiver.cs:245-248), the default-on BlockScreenSaver mechanism. Windows's beat is the send: SendAwakeBeat() compares lastRealInputEventCount against Event.RealInputEventCount and re-records it in the same call (Common.cs:542-559). So the comparison belongs at the send. Session.tick(now:userActive:) becomes Session.tick(now:inputEventCount:), taking the raw process-wide counter (Event.cs:51-55, InputHook.cs:223, 345) and keeping its own beatInputEventCount — Common.lastRealInputEventCount, Common.cs:543 — recorded on both branches (:558). ControlChannel loses lastBeatAt and beatInputEventCount entirely; noteUserActivity() only increments the counter and tick() hands the same value to every connection. No userActive-shaped name is left in Sources. Sources/MWBCore/Session.swift is session-matrix's file, edited for this fix with the lead's authorisation, as is that lane's Handshakes section. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
1 parent
23eddb42b9
commit
c03b8cdbcf
5 files changed
+158
-40
No files matched your search
@@ -315,10 +315,11 @@ final class PeerConnection: @unchecked Sendable {
|
||||
// MARK: - Time
|
||||
|
||||
/// Heartbeats, and the C2 rule that a controlled peer which has gone quiet
|
||||
/// for 30 s while we are feeding it input is gone.
|
||||
func tick(now: TimeInterval, userActive: Bool) {
|
||||
/// for 30 s while we are feeding it input is gone. `inputEventCount` is the
|
||||
/// channel's raw real-input counter, passed straight through to the session.
|
||||
func tick(now: TimeInterval, inputEventCount: UInt64) {
|
||||
guard !finished, closing == nil else { return }
|
||||
session.tick(now: now, userActive: userActive)
|
||||
session.tick(now: now, inputEventCount: inputEventCount)
|
||||
pump()
|
||||
|
||||
guard status == .connected, isControlled, lastForward > lastReceive else { return }
|
||||
|
||||
Reference in new issue
Block a user