- add server support to diff filesystem checkpoints, including root/HEAD fallbacks and lazy checkpoint initialization - wire new `providers.getCheckpointDiff` WebSocket route through provider manager and contracts - update web app to load per-turn diffs from checkpoints and improve diff panel behavior on narrow screens
28 lines
724 B
TypeScript
28 lines
724 B
TypeScript
import { useEffect, useState } from "react";
|
|
|
|
function getMediaQueryMatch(query: string): boolean {
|
|
if (typeof window === "undefined") {
|
|
return false;
|
|
}
|
|
return window.matchMedia(query).matches;
|
|
}
|
|
|
|
export function useMediaQuery(query: string): boolean {
|
|
const [matches, setMatches] = useState(() => getMediaQueryMatch(query));
|
|
|
|
useEffect(() => {
|
|
const mediaQueryList = window.matchMedia(query);
|
|
const handleChange = () => {
|
|
setMatches(mediaQueryList.matches);
|
|
};
|
|
|
|
setMatches(mediaQueryList.matches);
|
|
mediaQueryList.addEventListener("change", handleChange);
|
|
return () => {
|
|
mediaQueryList.removeEventListener("change", handleChange);
|
|
};
|
|
}, [query]);
|
|
|
|
return matches;
|
|
}
|