Add simulation feature for missing Git/LFS tools in development mode. Introduced new state and ref for simulating tool absence, allowing developers to test error handling in the Git check process. Updated UI to toggle simulation state with appropriate button labels.

This commit is contained in:
이정수 2026-01-30 10:38:54 +09:00
parent dc13526360
commit 7c649b76c4
1 changed files with 35 additions and 0 deletions

View File

@ -43,6 +43,7 @@ const App = () => {
const [serverRecoveryActive, setServerRecoveryActive] = useState(false);
const [skipToolsCheck, setSkipToolsCheck] = useState(false);
const [devProceedReady, setDevProceedReady] = useState(false);
const [simulateToolsMissing, setSimulateToolsMissing] = useState(false);
const [gitCheckInProgress, setGitCheckInProgress] = useState(false);
const [gitCheckedAt, setGitCheckedAt] = useState<number | undefined>();
const [gitCheckResult, setGitCheckResult] = useState<GitToolsCheck | undefined>();
@ -69,6 +70,7 @@ const App = () => {
const gitCheckInFlightRef = useRef(false);
const gitCheckedRef = useRef(false);
const transitionTimeoutRef = useRef<number | undefined>();
const simulateToolsMissingRef = useRef(false);
const runGitCheck = useCallback(async (force = false) => {
if (force) {
@ -83,6 +85,18 @@ const App = () => {
setGitCheckInProgress(true);
try {
if (IS_DEV && simulateToolsMissingRef.current) {
const simulated = {
git: { ok: false, command: "git", error: "simulated_missing" },
lfs: { ok: false, command: "git lfs", error: "simulated_missing" },
checkedAt: Date.now()
};
setGitCheckResult(simulated);
setGitCheckedAt(simulated.checkedAt);
gitCheckedRef.current = true;
return simulated;
}
if (!window.sptLauncher?.checkGitTools) {
throw new Error("preload(preload) 미로딩: window.sptLauncher.checkGitTools가 없습니다.");
}
@ -275,6 +289,10 @@ const App = () => {
return () => window.clearInterval(interval);
}, [serverRecoveryActive, runHealthCheck]);
useEffect(() => {
simulateToolsMissingRef.current = simulateToolsMissing;
}, [simulateToolsMissing]);
useEffect(() => {
return () => clearTransitionTimeout();
}, [clearTransitionTimeout]);
@ -655,6 +673,23 @@ const App = () => {
</button>
)}
{IS_DEV && (
<button
type="button"
className="ghost"
onClick={() => {
setSimulateToolsMissing((prev) => {
const next = !prev;
simulateToolsMissingRef.current = next;
return next;
});
gitCheckedRef.current = false;
void runGitCheck(true);
}}
>
{simulateToolsMissing ? "Git/LFS 시뮬레이션 해제" : "Git/LFS 미설치 시뮬레이션"}
</button>
)}
</section>
)}