fix: avoid repeated macOS privacy prompts (#1524)
* fix: avoid repeated macos privacy prompts * fix: reduce background worktree permission probes * chore: pin oxlint for ci * fix: preserve optional rpc params with zod 4.4 * fix: preserve optional inline rpc params with zod 4.4
This commit is contained in:
@@ -23,8 +23,8 @@ import {
|
||||
dismissNudge
|
||||
} from '../updater'
|
||||
import { scheduleHistoryGc } from '../terminal-history'
|
||||
import { listRepoWorktrees } from '../repo-worktrees'
|
||||
import type { ClaudeRuntimeAuthPreparation } from '../claude-accounts/runtime-auth-service'
|
||||
import { getKnownWorktreeIdsForHistoryGc } from './history-gc-worktree-ids'
|
||||
|
||||
export function attachMainWindowServices(
|
||||
mainWindow: BrowserWindow,
|
||||
@@ -50,19 +50,10 @@ export function attachMainWindowServices(
|
||||
// and ensures the handlers are re-installed on macOS app re-activation when
|
||||
// the main window is recreated.
|
||||
registerDaemonManagementHandlers()
|
||||
// Why: GC runs on a 10s delay so live worktree enumeration completes first.
|
||||
// Uses git worktree list (not store.getWorktreeMeta) because untouched
|
||||
// worktrees have no metadata entries — see design doc §7.6.
|
||||
// Why: do not enumerate repo paths from background GC. `git worktree list`
|
||||
// can re-touch protected folders on macOS and trigger folder-access prompts.
|
||||
scheduleHistoryGc(async () => {
|
||||
const repos = store.getRepos()
|
||||
const ids = new Set<string>()
|
||||
for (const repo of repos) {
|
||||
const worktrees = await listRepoWorktrees(repo)
|
||||
for (const wt of worktrees) {
|
||||
ids.add(`${repo.id}::${wt.path}`)
|
||||
}
|
||||
}
|
||||
return ids
|
||||
return getKnownWorktreeIdsForHistoryGc(store)
|
||||
})
|
||||
registerSshHandlers(store, () => mainWindow, runtime)
|
||||
registerFileDropRelay(mainWindow)
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { getKnownWorktreeIdsForHistoryGc } from './history-gc-worktree-ids'
|
||||
|
||||
describe('getKnownWorktreeIdsForHistoryGc', () => {
|
||||
it('uses persisted metadata keys without probing repo paths', () => {
|
||||
const store = {
|
||||
getAllWorktreeMeta: vi.fn(() => ({
|
||||
'repo-1::/worktree-a': {},
|
||||
'repo-2::/worktree-b': {}
|
||||
}))
|
||||
}
|
||||
|
||||
expect(getKnownWorktreeIdsForHistoryGc(store as never)).toEqual(
|
||||
new Set(['repo-1::/worktree-a', 'repo-2::/worktree-b'])
|
||||
)
|
||||
expect(store.getAllWorktreeMeta).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { Store } from '../persistence'
|
||||
|
||||
export function getKnownWorktreeIdsForHistoryGc(
|
||||
store: Pick<Store, 'getAllWorktreeMeta'>
|
||||
): Set<string> {
|
||||
return new Set(Object.keys(store.getAllWorktreeMeta()))
|
||||
}
|
||||
Reference in New Issue
Block a user