Fix flicker showing message to press ctrl-O again to collapse. (#20414)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
Jacob Richman
2026-02-27 07:07:14 -08:00
committed by GitHub
parent 66b8922d66
commit 4d9cc36146
2 changed files with 25 additions and 72 deletions

View File

@@ -15,14 +15,16 @@ export function useTimedMessage<T>(durationMs: number) {
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
const showMessage = useCallback(
(msg: T) => {
(msg: T | null) => {
setMessage(msg);
if (timeoutRef.current) {
clearTimeout(timeoutRef.current);
}
timeoutRef.current = setTimeout(() => {
setMessage(null);
}, durationMs);
if (msg !== null) {
timeoutRef.current = setTimeout(() => {
setMessage(null);
}, durationMs);
}
},
[durationMs],
);