This commit is contained in:
Benjamin Toby 2026-03-10 15:04:44 +00:00
parent dcd7f022bd
commit c4c2caa6f0
2 changed files with 10 additions and 8 deletions

View File

@ -36,7 +36,10 @@ export default function ServiceClusterServerViews({
const viewRef = useRef<HTMLDivElement>(undefined);
const { data } = useWebSocketEventHandler<WebSocketDataType>();
const { isIntersecting } = useIntersectionObserver({ elementRef: viewRef });
const { isIntersecting } = useIntersectionObserver({
elementRef: viewRef,
options: { rootMargin: "-200px", threshold: 0 },
});
const [ttyd, setTtyd] = useState<TtydInfoObject>();
@ -56,7 +59,7 @@ export default function ServiceClusterServerViews({
}
useEffect(() => {
if (!ws?.socket || WsReqSentRef.current) {
if (!ws?.socket || WsReqSentRef.current || !isIntersecting) {
return;
}
@ -80,11 +83,9 @@ export default function ServiceClusterServerViews({
return function () {
sendKillPort();
};
}, [ws, refresh]);
}, [ws, refresh, isIntersecting]);
useEffect(() => {
console.log("log_cmd", log_cmd);
if (WsReqSentRef.current) {
sendKillPort();
@ -125,7 +126,10 @@ export default function ServiceClusterServerViews({
useEffect(() => {
if (!ttyd?.port) return;
if (!isIntersecting) {
if (isIntersecting) {
WsReqSentRef.current = false;
setTtyd(undefined);
} else {
sendKillPort();
}
}, [isIntersecting]);

View File

@ -13,8 +13,6 @@ export default async function socketClientServiceServerLogs({
const server = data?.server;
const cmd = data?.cmd;
console.log("cmd", cmd);
const ttyd = await grabTtydServerInfo({
server,
service,