Stop macOS capture helper when parent closes its input

This commit is contained in:
webadderall committed 2026-09-23 14:56:55 +10:00
1 parent 295bce2cb3
commit 0979839fee
4 files changed
+13 -1

No files matched your search

@@ -1086,10 +1086,12 @@ DispatchQueue.global(qos: .utility).async {
}
if input == "stop" {
service.stop()
break
}
}
// EOF means the Electron parent exited or restarted. Finalize and release
// capture devices just as we do for an explicit stop command.
service.stop()
}
if !service.waitUntilFinished() {
@@ -8,6 +8,16 @@ const recorderSource = readFileSync(
);
describe("ScreenCaptureKitRecorder finalization coordination", () => {
it("finalizes on parent pipe closure as well as an explicit stop, exactly once", () => {
const commandLoop = recorderSource.slice(
recorderSource.indexOf("while let input = readLine"),
);
expect(commandLoop).toMatch(
/if input == "stop"\s*\{\s*break\s*\}\s*\}\s*\/\/.*?service\.stop\(\)/s,
);
expect(commandLoop.match(/service\.stop\(\)/g)).toHaveLength(1);
});
it("marks manual stops as participants in the shared finalization", () => {
expect(recorderSource).toContain("finalizeCapture(interactive: true)");
expect(recorderSource).toContain("finalization.outputResult.get()");