import { useEffect, useState } from 'react';
import { terminalsRegistry, type TerminalRegistration } from '@/lib/events';

export function useTerminals(): TerminalRegistration[] {
  const [list, setList] = useState(() => terminalsRegistry.list());
  useEffect(() => terminalsRegistry.subscribe(() => setList(terminalsRegistry.list())), []);
  return list;
}
