fix(watcher): fix TickCount wrap and resume retry on API failure

- Use 32-bit Environment.TickCount with unchecked uint arithmetic so
  GetIdleTime stays correct after the ~49.7 day uint wrap boundary
- Only clear _pausedTaskId after successful resume, not before the API call
- Add retry path: if resume failed, retry on next poll cycle while user
  is still active

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-27 00:18:22 -05:00
parent 74cd0f0018
commit 5db92d5127
2 changed files with 16 additions and 5 deletions

View File

@@ -29,6 +29,7 @@ internal static partial class NativeMethods
var info = new LASTINPUTINFO { cbSize = (uint)Marshal.SizeOf<LASTINPUTINFO>() };
if (!GetLastInputInfo(ref info))
return TimeSpan.Zero;
return TimeSpan.FromMilliseconds(Environment.TickCount64 - info.dwTime);
// Use 32-bit TickCount so both values wrap at the same boundary as dwTime (uint)
return TimeSpan.FromMilliseconds(unchecked((uint)Environment.TickCount - info.dwTime));
}
}