The best way to control Claude Code, Codex and more from any computer or phone

main
ts 19 lines 685 Bytes
Raw
1 import { useEffect, useRef } from "react";
2
3 import type { WorkspaceSearchMode } from "./workspace-tabs-state";
4
5 export function useSearchScrollRestoration(
6 searchMode: WorkspaceSearchMode | undefined,
7 restore: () => void,
8 ) {
9 const previousSearchMode = useRef(searchMode);
10 // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- restores the native list's saved search position
11 useEffect(() => {
12 const cancelledSearch =
13 previousSearchMode.current !== undefined &&
14 previousSearchMode.current !== "resting" &&
15 searchMode === "resting";
16 previousSearchMode.current = searchMode;
17 if (cancelledSearch) restore();
18 }, [searchMode, restore]);
19 }