fix lightpanda (#1050)

* fix lightpanda

* fmt
This commit is contained in:
Chris Tate
2026-03-27 09:33:08 -07:00
committed by GitHub
parent a95bc0f75a
commit db215a1467
6 changed files with 110 additions and 44 deletions
@@ -194,14 +194,20 @@ export function Viewport() {
addressRef.current?.blur();
const target = normalizeUrl(addressValue);
const previousUrl = url;
setAddressValue(target);
setNavigating(true);
try {
await runCmd("navigate", target);
const result = await runCmd("navigate", target);
if (!result.success) {
setAddressValue(previousUrl || "about:blank");
}
} catch {
setAddressValue(previousUrl || "about:blank");
} finally {
setNavigating(false);
}
}, [addressValue, navigating, runCmd]);
}, [addressValue, navigating, runCmd, url]);
const drawFrame = useCallback((base64: string) => {
const canvas = canvasRef.current;
+25 -12
View File
@@ -8,12 +8,21 @@ export interface ExecResult {
}
export async function execCommand(args: string[]): Promise<ExecResult> {
const resp = await fetch(`http://localhost:${DASHBOARD_PORT}/api/exec`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ args }),
});
return resp.json();
try {
const resp = await fetch(`http://localhost:${DASHBOARD_PORT}/api/exec`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ args }),
});
return resp.json();
} catch {
return {
success: false,
exit_code: null,
stdout: "",
stderr: "Network error: dashboard server unreachable",
};
}
}
export function sessionArgs(session: string, ...args: string[]): string[] {
@@ -21,10 +30,14 @@ export function sessionArgs(session: string, ...args: string[]): string[] {
}
export async function killSession(session: string): Promise<{ success: boolean; killed_pid?: number }> {
const resp = await fetch(`http://localhost:${DASHBOARD_PORT}/api/kill`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ session }),
});
return resp.json();
try {
const resp = await fetch(`http://localhost:${DASHBOARD_PORT}/api/kill`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ session }),
});
return resp.json();
} catch {
return { success: false };
}
}