fix(dashboard): clear input refs on tab deactivation (#106403)

(cherry picked from commit cb6fd96ef0521ed887bb136e12dadf2937053c3c)
This commit is contained in:
Konstantin Khlopkov
2026-09-09 09:52:49 +00:00
committed by Teknium
parent 070128f056
commit cbd1018ea6
+10
View File
@@ -205,6 +205,16 @@ export default function ChatPage({ isActive = true }: { isActive?: boolean }) {
useEffect(() => {
setHasActivated((prev) => latchChatActivation(prev, isActive));
}, [isActive]);
// Clear mobile-input tracking refs when the tab is hidden so stale state
// from a previous /chat visit doesn't cause the mobile-replacement logic
// to misfire on the next activation (#106403: repeated last character).
useEffect(() => {
if (!isActive) {
ptyInputLineRef.current = "";
mobileReplacementInputUntilRef.current = 0;
}
}, [isActive]);
const [searchParams, setSearchParams] = useSearchParams();
// Lazy-init: the missing-token check happens at construction so the effect
// body doesn't have to setState (React 19's set-state-in-effect rule).