fix: move startup checks effect after promptTypingSuppressionActive declaration
Fixes temporal dead zone warning flagged by code-quality bot. promptTypingSuppressionActive is declared on line ~1340 but the useEffect was on line ~800, causing a reference-before-declaration. Also adds missing semicolons for style consistency.
This commit is contained in:
@@ -793,20 +793,8 @@ export function REPL({
|
|||||||
// accepts, and only then is the REPL component mounted and this effect runs.
|
// accepts, and only then is the REPL component mounted and this effect runs.
|
||||||
// This ensures that plugin installations from repository and user settings only
|
// This ensures that plugin installations from repository and user settings only
|
||||||
// happen after explicit user consent to trust the current working directory.
|
// happen after explicit user consent to trust the current working directory.
|
||||||
// We defer startup checks by STARTUP_CHECK_DELAY_MS and gate on
|
// Deferring startup checks is handled below (after promptTypingSuppressionActive
|
||||||
// promptTypingSuppressionActive so that plugin loading doesn't steal focus
|
// is declared) to avoid temporal dead zone issues.
|
||||||
// from the prompt during the vulnerable startup window (issue #363).
|
|
||||||
const startupChecksStartedRef = React.useRef(false)
|
|
||||||
useEffect(() => {
|
|
||||||
if (isRemoteSession) return
|
|
||||||
if (startupChecksStartedRef.current) return
|
|
||||||
const timer = setTimeout(() => {
|
|
||||||
if (!shouldRunStartupChecks(isRemoteSession, startupChecksStartedRef.current, promptTypingSuppressionActive)) return
|
|
||||||
startupChecksStartedRef.current = true
|
|
||||||
void performStartupChecks(setAppState)
|
|
||||||
}, STARTUP_CHECK_DELAY_MS)
|
|
||||||
return () => clearTimeout(timer)
|
|
||||||
}, [setAppState, isRemoteSession, promptTypingSuppressionActive])
|
|
||||||
|
|
||||||
// Allow Claude in Chrome MCP to send prompts through MCP notifications
|
// Allow Claude in Chrome MCP to send prompts through MCP notifications
|
||||||
// and sync permission mode changes to the Chrome extension
|
// and sync permission mode changes to the Chrome extension
|
||||||
@@ -1349,6 +1337,21 @@ export function REPL({
|
|||||||
const inputValueRef = useRef(inputValue);
|
const inputValueRef = useRef(inputValue);
|
||||||
inputValueRef.current = inputValue;
|
inputValueRef.current = inputValue;
|
||||||
const promptTypingSuppressionActive = isPromptTypingSuppressionActive(isPromptInputActive, inputValue);
|
const promptTypingSuppressionActive = isPromptTypingSuppressionActive(isPromptInputActive, inputValue);
|
||||||
|
|
||||||
|
// Defer startup checks by STARTUP_CHECK_DELAY_MS and gate on
|
||||||
|
// promptTypingSuppressionActive so that plugin loading doesn't steal focus
|
||||||
|
// from the prompt during the vulnerable startup window (issue #363).
|
||||||
|
const startupChecksStartedRef = React.useRef(false);
|
||||||
|
useEffect(() => {
|
||||||
|
if (isRemoteSession) return;
|
||||||
|
if (startupChecksStartedRef.current) return;
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
if (!shouldRunStartupChecks(isRemoteSession, startupChecksStartedRef.current, promptTypingSuppressionActive)) return;
|
||||||
|
startupChecksStartedRef.current = true;
|
||||||
|
void performStartupChecks(setAppState);
|
||||||
|
}, STARTUP_CHECK_DELAY_MS);
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}, [setAppState, isRemoteSession, promptTypingSuppressionActive]);
|
||||||
const insertTextRef = useRef<{
|
const insertTextRef = useRef<{
|
||||||
insert: (text: string) => void;
|
insert: (text: string) => void;
|
||||||
setInputWithCursor: (value: string, cursor: number) => void;
|
setInputWithCursor: (value: string, cursor: number) => void;
|
||||||
|
|||||||
Reference in New Issue
Block a user