// Analysis completion flag utility
export const analysisCompletionFlag = {
  isComplete: false,
  currentSession: null as string | null,
  
  setComplete: (value: boolean) => {
    analysisCompletionFlag.isComplete = value
  },
  
  getComplete: () => analysisCompletionFlag.isComplete,
  
  canCleanup: () => analysisCompletionFlag.isComplete,
  
  startAnalysisCycle: (sessionId: string) => {
    analysisCompletionFlag.currentSession = sessionId
    analysisCompletionFlag.isComplete = false
  },
  
  endAnalysisCycle: () => {
    analysisCompletionFlag.isComplete = true
    analysisCompletionFlag.currentSession = null
  },
  
  markAnalysisComplete: (sessionId: string) => {
    if (analysisCompletionFlag.currentSession === sessionId) {
      analysisCompletionFlag.isComplete = true
    }
  }
}

export default analysisCompletionFlag