Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

VoiceGate hook only supports Kitty terminal, breaks voice notifications for iTerm2 and other terminals

Open DolphusCY opened this issue 9 months ago • 1 comments

Problem

The VoiceGate.hook.ts hook currently only detects main terminal sessions by checking for Kitty-specific session files:

function isMainSession(sessionId: string): boolean {
  const paiDir = process.env.PAI_DIR || join(homedir(), '.claude');
  return existsSync(join(paiDir, 'MEMORY', 'STATE', 'kitty-sessions', `${sessionId}.json`));
}

This causes voice notifications to be blocked for users of other terminals (iTerm2, Alacritty, Warp, etc.), as the hook treats all sessions as "subagents" and suppresses voice curls.

Impact

  • Voice notifications completely broken for non-Kitty users
  • No audio feedback from PAI Algorithm phase transitions
  • Silent failures with no indication why voice isn't working

Root Cause

The session detection logic assumes Kitty terminal usage. When kitty-sessions/ directory is empty (for iTerm2 users), every session is classified as a subagent.

Proposed Solution

Check for terminal environment variables before falling back to Kitty-specific files:

function isMainSession(sessionId: string): boolean {
  // iTerm2 detection - main sessions have iTerm environment variables
  if (process.env.ITERM_SESSION_ID || process.env.TERM_PROGRAM === 'iTerm.app') {
    return true;
  }

  // Kitty detection - backward compatibility
  const paiDir = process.env.PAI_DIR || join(homedir(), '.claude');
  return existsSync(join(paiDir, 'MEMORY', 'STATE', 'kitty-sessions', `${sessionId}.json`));
}

This approach:

  • ✅ Works for iTerm2 (checks ITERM_SESSION_ID and TERM_PROGRAM)
  • ✅ Maintains backward compatibility with Kitty
  • ✅ Could be extended for other terminals (Alacritty, Warp, etc.)
  • ✅ Subagent blocking still works (spawned agents lack terminal env vars)

Testing

Verified with iTerm2:

  • ✅ Voice notification curl succeeds: {"status":"success","message":"Notification queued"}
  • ✅ Health check endpoint accessible
  • ✅ Audio plays through MLX-Audio/Kokoro TTS
  • ✅ Subagent blocking logic preserved

Additional Context

This affects the PAI Algorithm's phase announcements, which rely on voice curls being executable in the main session. Without this fix, users on non-Kitty terminals get a degraded experience with no audio feedback.

DolphusCY avatar Feb 16 '26 06:02 DolphusCY

Fixed in commit 95d65cc. VoiceGate now detects the main session via TERM_PROGRAM environment variable, supporting iTerm2, Warp, Alacritty, and Apple Terminal in addition to Kitty. Subagents don't inherit terminal env vars, so voice blocking for subagents still works correctly. Thanks for the report and the suggested fix approach! 🙏

kaimagnus avatar Feb 17 '26 09:02 kaimagnus