import { notificationManager } from "./notificationManager";
import type { ConnectionStatus } from "$lib/types/messages";

// Track previous connection status to detect transitions
let previousConnectionStatus: ConnectionStatus | null = null;

export function handleConnectionStatusChange(newStatus: ConnectionStatus): void {
  // Only notify on successful connection after being disconnected
  if (
    newStatus === "connected" &&
    previousConnectionStatus &&
    previousConnectionStatus !== "connected"
  ) {
    notificationManager.notifyConnection();
  }

  previousConnectionStatus = newStatus;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function handleToolExecution(_toolName: string): void {
  // For now, we don't notify on every tool execution
  // But we could add specific rules here if needed
}

// No-op: sound tracking is now per-conversation in tauri.ts
export function handleNewUserMessage(): void {}

// No-op: all per-conversation sounds are driven by tauri.ts event listeners
export function initializeNotificationRules(): void {}

// Cleanup — reset connection tracking on teardown
export function cleanupNotificationRules(): void {
  previousConnectionStatus = null;
}
