From 1335c5a35ac3e92ea97beeaf3de164478318dd7b Mon Sep 17 00:00:00 2001 From: Philip Zeyliger Date: Wed, 14 Jan 2026 17:14:36 +0000 Subject: [PATCH] fix: keyboard shortcut toast disappears after 6 seconds Prompt: [user showed screenshot of stuck toast] I was expecting the toast for shelley's keyboard shortcuts to disappear after a while. Split the keyboard hint logic into two effects: 1. One to show the hint on first open (when fileDiff is ready) 2. One to auto-hide after 6 seconds (triggered by showKeyboardHint changing) This ensures the timer runs reliably regardless of how the dependencies of the first effect change. Co-authored-by: Shelley --- ui/src/components/DiffViewer.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/src/components/DiffViewer.tsx b/ui/src/components/DiffViewer.tsx index 83bf2250910d53913c9e062c911065ce97c5533e..043488b9d1f2ae612e67398d10823ad14c792958 100644 --- a/ui/src/components/DiffViewer.tsx +++ b/ui/src/components/DiffViewer.tsx @@ -164,10 +164,16 @@ function DiffViewer({ cwd, isOpen, onClose, onCommentTextChange, initialCommit } if (isOpen && !isMobile && !hasShownKeyboardHint.current && fileDiff) { hasShownKeyboardHint.current = true; setShowKeyboardHint(true); + } + }, [isOpen, isMobile, fileDiff]); + + // Auto-hide keyboard hint after 6 seconds + useEffect(() => { + if (showKeyboardHint) { const timer = setTimeout(() => setShowKeyboardHint(false), 6000); return () => clearTimeout(timer); } - }, [isOpen, isMobile, fileDiff]); + }, [showKeyboardHint]); // Load diffs when viewer opens, reset state when it closes useEffect(() => {