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

View File

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