import type { UseFileBrowserAppType } from '../useFileBrowserApp';
import { AgentRunnerModal } from './AgentRunnerModal';

type AgentRunnerDialogProps = {
  fileBrowserManager: UseFileBrowserAppType;
};

export const AgentRunnerDialog = ({ fileBrowserManager }: AgentRunnerDialogProps) => {
  const { runningAgent, setRunningAgent, refresh, getEntryAbsPath } = fileBrowserManager;

  if (!runningAgent) return null;

  return (
    <AgentRunnerModal
      open
      onOpenChange={(open) => {
        if (!open) {
          setRunningAgent(null);
          refresh();
        }
      }}
      agent={runningAgent.agent}
      entryName={runningAgent.entry.name}
      entryFullPath={getEntryAbsPath(runningAgent.entry.name)}
    />
  );
};
