From 91cdf8fea129537c9be65969f6ca8e8e68cea91a Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Mon, 27 Jul 2026 17:12:28 -0700 Subject: [PATCH] fix(macos): start the TCC watcher from app bootstrap, not the window wiring attachMainWindowServices is called directly by its own unit test, so wiring initTccPromptNotice there made `vitest src/main/window/` spawn real `log stream` children that outlived the run - two orphaned watchers were left behind by a single test session. Only the IPC handler registration stays there; the spawn moves to the real app bootstrap in index.ts, which tests never execute. Verified: running the suite that leaked now leaves the watcher count unchanged. --- src/main/index.ts | 5 ++++- src/main/window/attach-main-window-services.ts | 7 +++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/index.ts b/src/main/index.ts index 62d0f7646e2..0cac6f47316 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -3,7 +3,7 @@ import { existsSync, statSync } from 'node:fs' import { isAbsolute, join } from 'node:path' import os from 'node:os' import { app, BrowserWindow, dialog, ipcMain, nativeTheme, type Tray } from 'electron' -import { stopTccPromptNotice } from './macos-tcc-prompt-notice' +import { initTccPromptNotice, stopTccPromptNotice } from './macos-tcc-prompt-notice' import { electronApp, is } from '@electron-toolkit/utils' import { Store, @@ -1220,6 +1220,9 @@ function openMainWindow(): BrowserWindow { ) automations.setWebContents(window.webContents) automations.start() + // Why: spawns a `log stream` child, so it starts from real app bootstrap rather + // than attachMainWindowServices, which unit tests invoke directly (#9756). + initTccPromptNotice(window) attachMainWindowServices( window, store, diff --git a/src/main/window/attach-main-window-services.ts b/src/main/window/attach-main-window-services.ts index b323f52defe..7a0e12f96cf 100644 --- a/src/main/window/attach-main-window-services.ts +++ b/src/main/window/attach-main-window-services.ts @@ -9,7 +9,7 @@ import type { UpdateCheckOptions, WorktreeStartupLaunch } from '../../shared/types' -import { dismissTccPromptNotice, initTccPromptNotice } from '../macos-tcc-prompt-notice' +import { dismissTccPromptNotice } from '../macos-tcc-prompt-notice' import { registerRepoHandlers } from '../ipc/repos' import { registerWorktreeHandlers } from '../ipc/worktrees' import { registerWorkspaceCleanupHandlers } from '../ipc/workspace-cleanup' @@ -133,9 +133,8 @@ export function attachMainWindowServices( registerSshHandlers(store, () => mainWindow, runtime) registerRemoteWorkspaceHandlers(store, () => mainWindow) registerFileDropRelay(mainWindow) - // Why: macOS-only inside; counts TCC dialogs raised in Orca's name so the FDA - // hint reaches only users macOS is actually prompting (#9756). - initTccPromptNotice(mainWindow) + // Why: handler only — initTccPromptNotice spawns a `log stream` child, so it is + // started from the app bootstrap instead of here, which unit tests call directly. ipcMain.handle('macosTccPrompts:dismiss', () => { dismissTccPromptNotice() })