Introduce IProcessRunner and migrate actions to centralized process execution; refactor camera capture and face authorizer#13
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f3578b9def
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Services/CameraCaptureService.cs
Outdated
| private async Task CaptureLoop() | ||
| { | ||
| using var frame = new Mat(); | ||
| var token = _cts?.Token ?? CancellationToken.None; |
There was a problem hiding this comment.
Pass capture token explicitly to prevent uncancellable loop
Avoid falling back to CancellationToken.None here: if Stop() cancels, waits up to 1s, and then sets _cts = null before CaptureLoop actually begins, this line captures None and the while condition can run indefinitely, leaving a background task alive after shutdown/restart. This regression was introduced by switching from _cts?.IsCancellationRequested to a local token fallback; pass the token into CaptureLoop at task creation time so cancellation is always bound to the correct session.
Useful? React with 👍 / 👎.
Motivation
Process.Startcalls across actions.CODE_REVIEW_REPORT.mdto record higher-priority issues and recommendations.Description
IProcessRunnerinterface and concreteProcessRunnerimplementation (Services/IProcessRunner.cs,Services/ProcessRunner.cs) that run processes with timeouts, expected success exit codes and structured logging, returning aProcessRunResult.services.AddSingleton<IProcessRunner, ProcessRunner>();inPlugin.csand migrated multiple action classes to acceptIProcessRunnerand callRunAsyncinstead of invokingProcess.Startdirectly (examples:CopyAction,MoveAction,DeleteAction,DisableMouseAction,EnableMouseAction,SimulateMouseAction, and the display actions such asCloneDisplayAction,ExtendDisplayAction,ExternalDisplayAction,InternalDisplayAction).ProcessStartInfosettings (e.g.WindowStyle = ProcessWindowStyle.Hidden) and introduced explicit success exit code handling and longer timeouts for potentially long-running operations (robocopy, rmdir, batch files).CameraCaptureServiceto an asynchronous cancellable capture loop (async Task CaptureLoop), useTask.Delaywith cancellation, makeFrameCapturedinvocation safer by creating and passing a managedMatsnapshot and catching subscriber exceptions, and improve stop/dispose handling.FaceRecognitionAuthorizerto clone frames where appropriate, improve exception logging while extracting encodings and during verification cancellation handling, and ensure proper resource disposal around camera/face services.CODE_REVIEW_REPORT.mdcontaining review findings and recommendations.Testing
Codex Task