refactor: encapsulate state management for spec and suggestions generation

- Made the generation status variables private and introduced getter functions for both spec and suggestions generation states.
- Updated relevant route handlers to utilize the new getter functions, improving encapsulation and reducing direct access to shared state.
- Enhanced code maintainability by centralizing state management logic.
This commit is contained in:
Cody Seibert
2025-12-14 18:18:11 -05:00
parent 01bae7d43e
commit 6733de9e0d
19 changed files with 321 additions and 33 deletions

View File

@@ -3,13 +3,22 @@
*/
import { createLogger } from "../../lib/logger.js";
import { getErrorMessage as getErrorMessageShared } from "../common.js";
const logger = createLogger("SpecRegeneration");
// Shared state for tracking generation status
export let isRunning = false;
export let currentAbortController: AbortController | null = null;
// Shared state for tracking generation status - private
let isRunning = false;
let currentAbortController: AbortController | null = null;
/**
* Get the current running state
*/
export function getSpecRegenerationStatus(): {
isRunning: boolean;
currentAbortController: AbortController | null;
} {
return { isRunning, currentAbortController };
}
/**
* Set the running state and abort controller