Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
perf: stop the Features read from spawning system_profiler for the facetime check (#9593)
[._.]/ Adam Eivy5256b4c99085
diff --git a/server/services/instanceFeatures.js b/server/services/instanceFeatures.jsindex 3043753c2d..6bc92327a9 100644--- a/server/services/instanceFeatures.js+++ b/server/services/instanceFeatures.js@@ -57,8 +57,8 @@ const DETECTORS = {},facetime: async () => {if (process.platform !== 'darwin') return false;- const { checkSetup } = await import('./voice/facetimeBridge.js');- const report = await checkSetup();+ const { checkLocalSetup } = await import('./voice/facetimeBridge.js');+ const report = await checkLocalSetup();return report.helper?.ok === 'ok' && report.identity?.ok === 'ok';},// Cheap and fail-closed: platform, app bundle and the EnableAPIServer pref —diff --git a/server/services/voice/facetimeBridge.js b/server/services/voice/facetimeBridge.jsindex ef24e453d6..ed7c01e426 100644--- a/server/services/voice/facetimeBridge.js+++ b/server/services/voice/facetimeBridge.js@@ -82,15 +82,24 @@ const identityReady = (config) => Boolean(config?.facetime?.targetHandle?.trim()const fact = (ok, message) => ({ ok: ok ? 'ok' : 'missing', message });+// The two setup facts that need no subprocess (a file check and a config read).+// Feature detection reads only these, so it must not pay for the audio probe.+export async function checkLocalSetup(config) {+ const voiceConfig = config || await getVoiceConfig();+ return {+ helper: fact(existsSync(facetimeHelperPath()), 'Run npm run setup:facetime to compile the FaceTime helper.'),+ identity: fact(identityReady(voiceConfig), 'Set a target name and E.164 phone number or email address.'),+ };+}+export async function checkSetup(config) {const voiceConfig = config || await getVoiceConfig();const facetime = voiceConfig.facetime || {};- const helper = facetimeHelperPath();- const devices = await listAudioDevices();+ const [{ helper, identity }, devices] = await Promise.all([checkLocalSetup(voiceConfig), listAudioDevices()]);return {platform: fact(process.platform === 'darwin', 'FaceTime Audio control requires macOS.'),- helper: fact(existsSync(helper), 'Run npm run setup:facetime to compile the FaceTime helper.'),- identity: fact(identityReady(voiceConfig), 'Set a target name and E.164 phone number or email address.'),+ helper,+ identity,accessibility: fact(false, 'Grant Accessibility access to facetime-ax in System Settings > Privacy & Security > Accessibility.'),blackHole2ch: checkAudioDevice(devices, facetime.blackHole2chLabel || 'BlackHole 2ch', 2),blackHole16ch: checkAudioDevice(devices, facetime.blackHole16chLabel || 'BlackHole 16ch', 16),diff --git a/server/services/voice/facetimeBridge.test.js b/server/services/voice/facetimeBridge.test.jsindex 3214f90310..c5dd857cd1 100644--- a/server/services/voice/facetimeBridge.test.js+++ b/server/services/voice/facetimeBridge.test.js@@ -42,7 +42,7 @@ vi.mock('../../lib/bufferedSpawn.js', async (importOriginal) => {};});-import { CALL_AUDIO_DEVICE_RATE, FACETIME_COMMANDS, blockingSetupFailure, checkAudioDevice, checkSetup, facetimeControlResultSchema, run } from './facetimeBridge.js';+import { CALL_AUDIO_DEVICE_RATE, FACETIME_COMMANDS, blockingSetupFailure, checkAudioDevice, checkLocalSetup, checkSetup, facetimeControlResultSchema, run } from './facetimeBridge.js';const device = (overrides = {}) => ({name: 'BlackHole 16ch',@@ -110,6 +110,32 @@ guard !matcher.matches(["Incoming call from +44 1555 123 4567"]) else { exit(4)expect(JSON.stringify(setup)).not.toContain('targetHandle');});+ it('feature detection never spawns the audio-device probe', async () => {+ const spawned = [];+ helperRun.spawnImpl = async (cmd) => {+ spawned.push(cmd);+ return { success: true, code: 0, signal: null, stdout: '{}', stderr: '', timedOut: false };+ };+ const restorePlatform = pinPlatform('darwin');+ try {+ const { detectFeatureConfiguration } = await import('../instanceFeatures.js');+ await detectFeatureConfiguration();+ expect(spawned).not.toContain('system_profiler');+ } finally {+ helperRun.spawnImpl = null;+ restorePlatform();+ }+ });++ it('checkLocalSetup returns the helper and identity facts that checkSetup composes', async () => {+ const config = { facetime: { targetHandle: '', targetName: '' } };+ const local = await checkLocalSetup(config);+ const full = await checkSetup(config);+ expect(Object.keys(local).sort()).toEqual(['helper', 'identity']);+ expect(full).toMatchObject(local);+ expect(Object.keys(full).sort()).toEqual(['accessibility', 'blackHole16ch', 'blackHole2ch', 'helper', 'identity', 'platform']);+ });+describe('BlackHole device check', () => {it('passes a device present at the right rate and channel count', () => {expect(checkAudioDevice([device()], 'BlackHole 16ch', 16).ok).toBe('ok');