@devries-cameron20 / t3code-1 / commits / c856e00ca8
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(desktop): stop the macOS Settings tracker when T3 exits (#22497)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>

Victor Vogel committed Oct 30, 2026 at 20:23 UTC c856e00ca819081e973191960dd011579d069153
2 files changed +29 -1
apps/desktop/src/permissions/MacSettingsWindow.test.ts
+27
@@ -1,4 +1,5 @@
1 import * as NodeEvents from "node:events";
2 +import * as NodeVM from "node:vm";
3 import { beforeEach, expect, it, vi } from "vite-plus/test";
4 import { watchMacSettingsWindow } from "./MacSettingsWindow.ts";
5
@@ -42,3 +43,29 @@ it("distinguishes unavailable tracking from a valid absent window", () => {
43 expect(unavailable).toHaveBeenCalledTimes(2);
44 stop();
45 });
46 +it("polls while its parent lives and stops after reparenting to launchd", () => {
47 + watchMacSettingsWindow(vi.fn(), vi.fn())();
48 + const script = mocks.spawn.mock.lastCall?.[1][3];
49 + const imports = new Set<string>();
50 + const writeData = vi.fn();
51 + const poll = vi.fn(() => ({ count: 0 }));
52 + const sleep = vi.fn(() => {
53 + if (sleep.mock.calls.length > 2) throw new Error("tracker kept polling after parent exit");
54 + });
55 + const bridge = Object.assign((line: string) => ({ dataUsingEncoding: () => line }), {
56 + getppid: () => {
57 + if (!imports.has("unistd")) throw new Error("unistd bridge unavailable");
58 + return sleep.mock.calls.length < 2 ? 42 : 1;
59 + },
60 + NSRunningApplication: { runningApplicationsWithBundleIdentifier: poll },
61 + NSFileHandle: { fileHandleWithStandardOutput: { writeData } },
62 + NSThread: { sleepForTimeInterval: sleep },
63 + NSUTF8StringEncoding: 4,
64 + });
65 + NodeVM.runInNewContext(script + "\nrun();", {
66 + ObjC: { import: (name: string) => imports.add(name) },
67 + $: bridge,
68 + });
69 + expect(poll).toHaveBeenCalledTimes(2);
70 + expect(writeData.mock.calls).toEqual([["null\n"]]);
71 +});
apps/desktop/src/permissions/MacSettingsWindow.ts
+2 -1
@@ -20,9 +20,10 @@ const decodeSettingsWindow = Schema.decodeUnknownSync(Schema.fromJsonString(Sett
20 const SETTINGS_WINDOW_SCRIPT = `
21 ObjC.import("CoreGraphics");
22 ObjC.import("AppKit");
23 +ObjC.import("unistd");
24 function run() {
25 let previous = "";
25 - while (true) {
26 + while ($.getppid() !== 1) {
27 const apps = $.NSRunningApplication.runningApplicationsWithBundleIdentifier("com.apple.systempreferences");
28 let result = null;
29 if (apps.count > 0) {