mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2026-02-04 06:50:31 -07:00
UI Adjustments for Remote Shell
This commit is contained in:
@@ -157,6 +157,7 @@ export default function ReverseTunnelPowershell({ device }) {
|
|||||||
setStatusMessage("Agent Onboarding Underway.");
|
setStatusMessage("Agent Onboarding Underway.");
|
||||||
setSessionState("idle");
|
setSessionState("idle");
|
||||||
setShellState("idle");
|
setShellState("idle");
|
||||||
|
setTunnel(null);
|
||||||
}, [notifyAgentOnboarding]);
|
}, [notifyAgentOnboarding]);
|
||||||
|
|
||||||
const appendOutput = useCallback((text) => {
|
const appendOutput = useCallback((text) => {
|
||||||
@@ -266,7 +267,7 @@ export default function ReverseTunnelPowershell({ device }) {
|
|||||||
`/api/tunnel/status?agent_id=${encodeURIComponent(agentId)}`
|
`/api/tunnel/status?agent_id=${encodeURIComponent(agentId)}`
|
||||||
);
|
);
|
||||||
const readinessData = await readinessResp.json().catch(() => ({}));
|
const readinessData = await readinessResp.json().catch(() => ({}));
|
||||||
if (readinessResp.ok && readinessData?.agent_socket === false) {
|
if (readinessResp.ok && readinessData?.agent_socket !== true) {
|
||||||
await handleAgentOnboarding();
|
await handleAgentOnboarding();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -286,6 +287,7 @@ export default function ReverseTunnelPowershell({ device }) {
|
|||||||
const detail = data?.detail ? `: ${data.detail}` : "";
|
const detail = data?.detail ? `: ${data.detail}` : "";
|
||||||
throw new Error(`${data?.error || `HTTP ${resp.status}`}${detail}`);
|
throw new Error(`${data?.error || `HTTP ${resp.status}`}${detail}`);
|
||||||
}
|
}
|
||||||
|
tunnelIdRef.current = data?.tunnel_id || "";
|
||||||
const waitForTunnelReady = async () => {
|
const waitForTunnelReady = async () => {
|
||||||
const deadline = Date.now() + 60000;
|
const deadline = Date.now() + 60000;
|
||||||
let lastError = "";
|
let lastError = "";
|
||||||
@@ -294,6 +296,11 @@ export default function ReverseTunnelPowershell({ device }) {
|
|||||||
`/api/tunnel/connect/status?agent_id=${encodeURIComponent(agentId)}&bump=1`
|
`/api/tunnel/connect/status?agent_id=${encodeURIComponent(agentId)}&bump=1`
|
||||||
);
|
);
|
||||||
const statusData = await statusResp.json().catch(() => ({}));
|
const statusData = await statusResp.json().catch(() => ({}));
|
||||||
|
if (statusData?.error === "agent_socket_missing" || (statusResp.ok && statusData?.agent_socket === false)) {
|
||||||
|
await handleAgentOnboarding();
|
||||||
|
await stopTunnel("agent_onboarding_pending");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (statusResp.ok && statusData?.status === "up") {
|
if (statusResp.ok && statusData?.status === "up") {
|
||||||
const agentSocket = statusData?.agent_socket;
|
const agentSocket = statusData?.agent_socket;
|
||||||
const agentReady = agentSocket === undefined ? true : Boolean(agentSocket);
|
const agentReady = agentSocket === undefined ? true : Boolean(agentSocket);
|
||||||
@@ -310,6 +317,9 @@ export default function ReverseTunnelPowershell({ device }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const statusData = await waitForTunnelReady();
|
const statusData = await waitForTunnelReady();
|
||||||
|
if (!statusData) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
setTunnel({ ...data, ...statusData });
|
setTunnel({ ...data, ...statusData });
|
||||||
|
|
||||||
const socket = ensureSocket();
|
const socket = ensureSocket();
|
||||||
@@ -325,6 +335,7 @@ export default function ReverseTunnelPowershell({ device }) {
|
|||||||
}
|
}
|
||||||
if (openResp.error === "agent_socket_missing") {
|
if (openResp.error === "agent_socket_missing") {
|
||||||
await handleAgentOnboarding();
|
await handleAgentOnboarding();
|
||||||
|
await stopTunnel("agent_onboarding_pending");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
lastError = openResp.error;
|
lastError = openResp.error;
|
||||||
@@ -348,7 +359,7 @@ export default function ReverseTunnelPowershell({ device }) {
|
|||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}, [agentId, ensureSocket, handleAgentOnboarding]);
|
}, [agentId, ensureSocket, handleAgentOnboarding, stopTunnel]);
|
||||||
|
|
||||||
const handleSend = useCallback(
|
const handleSend = useCallback(
|
||||||
async (text) => {
|
async (text) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user