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.
This commit is contained in:
Brennan Benson
2026-07-27 17:12:28 -07:00
parent 0a8488a6d1
commit 91cdf8fea1
2 changed files with 7 additions and 5 deletions
+4 -1
View File
@@ -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,
@@ -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()
})