Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

[Bug] StopOrchestrator.isMainSession() silences voice for Windows Terminal (WSL2) users

Open rikitikitavi2012-debug opened this issue 9 months ago • 1 comments

Summary

StopOrchestrator.hook.ts gates the 🗣️ voice summary on isMainSession(), which checks for a Kitty terminal session file. When the Kitty sessions directory exists but is empty (e.g., after testing Kitty), every session returns false and voice is permanently silenced — with no warning to the user.

Additionally, the function has no detection for Windows Terminal / WSL2 (the most common PAI deployment on Windows), so even without the empty-dir issue, WT users can't get voice.

Root Cause

// hooks/StopOrchestrator.hook.ts — current isMainSession()
function isMainSession(sessionId: string): boolean {
  const kittySessionsDir = join(paiDir, 'MEMORY', 'STATE', 'kitty-sessions');
  if (!existsSync(kittySessionsDir)) return true; // ← dir doesn't exist → allow all
  return existsSync(join(kittySessionsDir, `${sessionId}.json`)); // ← dir EXISTS but empty → false for ALL sessions
}

The failure mode: If a user ever ran PAI in Kitty (even briefly), the kitty-sessions/ directory gets created. If they later switch to another terminal, the dir exists but is empty → isMainSession() returns false for every session → voice summary is permanently blocked with no log or indication why.

Missing terminal detection: hooks/handlers/VoiceGate.ts already checks WT_SESSION for Windows Terminal, but StopOrchestrator.hook.ts has no such check, creating an inconsistency.

Impact

  • 🗣️ voice summaries silenced for all non-Kitty users with a pre-existing kitty-sessions/ dir
  • Windows Terminal users on WSL2 never get voice regardless of kitty-sessions state
  • Silent failure — user has no indication voice is blocked; hook still runs, just drops voice

Proposed Fix

Add terminal environment checks before the Kitty session file check:

function isMainSession(sessionId: string): boolean {
  // Windows Terminal (WSL2) or known macOS terminals → always main session
  if (process.env.WT_SESSION ||
      process.env.ITERM_SESSION_ID ||
      process.env.TERM_PROGRAM === 'iTerm.app' ||
      process.env.TERM_PROGRAM === 'WarpTerminal' ||
      process.env.TERM_PROGRAM === 'Alacritty' ||
      process.env.TERM_PROGRAM === 'Apple_Terminal') {
    return true;
  }
  // Kitty detection via session files (backward-compatible)
  const kittySessionsDir = join(paiDir, 'MEMORY', 'STATE', 'kitty-sessions');
  if (!existsSync(kittySessionsDir)) return true; // Non-Kitty terminal: allow all sessions
  return existsSync(join(kittySessionsDir, `${sessionId}.json`));
}

This is consistent with how VoiceGate.ts already handles WT_SESSION detection.

Environment

  • WSL2 Ubuntu on Windows 11 with Windows Terminal
  • WT_SESSION env var is set by Windows Terminal in WSL sessions
  • kitty-sessions/ directory existed (from prior Kitty testing) but was empty

Related

  • hooks/handlers/VoiceGate.ts already checks WT_SESSION — this fix brings StopOrchestrator into alignment

rikitikitavi2012-debug avatar Feb 22 '26 21:02 rikitikitavi2012-debug

Fixed in v4.0.1 — isMainSession() was rewritten to check !process.env.CLAUDE_CODE_AGENT_TASK_ID instead of the fragile Kitty session file check. The WSL2/Windows Terminal issue no longer applies.

👉 Releases page

kaimagnus avatar Mar 01 '26 01:03 kaimagnus