Files
wehub-resource-sync c48612c494
CI / E2E Tests (push) Has been cancelled
CI / Lint, Typecheck & Unit Tests (push) Has been cancelled
Docs Build / Build docs site (push) Has been cancelled
Publish @openmaic packages / Build, validate & publish (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:03:23 +08:00

28 lines
1001 B
TypeScript

import { PENDING_SCENE_ID } from '@/lib/store/stage';
/**
* Inputs the edit-mode auto-exit guard reads. Kept as primitives so callers
* can derive the values cheaply without holding full Scene / SceneOutline
* objects, and so the predicate is trivially testable without rendering Stage.
*/
export interface StageEditModeContext {
currentSceneId: string | null;
sceneCount: number;
generatingOutlineCount: number;
hasCurrentScene: boolean;
}
/**
* Whether edit mode should remain active for the given stage state.
* Returns false in cases that would otherwise strand the user in an empty
* edit shell — pending scene, no scenes, generation in flight, or no current
* scene resolved yet.
*/
export function isCurrentSceneEditable(ctx: StageEditModeContext): boolean {
if (ctx.currentSceneId === PENDING_SCENE_ID) return false;
if (ctx.sceneCount === 0) return false;
if (ctx.generatingOutlineCount > 0) return false;
if (!ctx.hasCurrentScene) return false;
return true;
}