Speculative fixes to try to fix react error. (#19508)

This commit is contained in:
Jacob Richman
2026-02-18 22:39:32 -08:00
committed by GitHub
parent c43500c50b
commit a804f99fe0
3 changed files with 35 additions and 18 deletions

View File

@@ -80,20 +80,24 @@ export function useFocusHint(
isThisShellFocused: boolean,
resultDisplay: ToolResultDisplay | undefined,
) {
const [lastUpdateTime, setLastUpdateTime] = useState<Date | null>(null);
const [userHasFocused, setUserHasFocused] = useState(false);
// Derive a stable reset key for the inactivity timer. For strings and arrays
// (shell output), we use the length to capture updates without referential
// identity issues or expensive deep comparisons.
const resetKey =
typeof resultDisplay === 'string'
? resultDisplay.length
: Array.isArray(resultDisplay)
? resultDisplay.length
: !!resultDisplay;
const showFocusHint = useInactivityTimer(
isThisShellFocusable,
lastUpdateTime ? lastUpdateTime.getTime() : 0,
resetKey,
SHELL_FOCUS_HINT_DELAY_MS,
);
useEffect(() => {
if (resultDisplay) {
setLastUpdateTime(new Date());
}
}, [resultDisplay]);
useEffect(() => {
if (isThisShellFocused) {
setUserHasFocused(true);