fix(ui): harness setup terminal reports the real failure and can be reopened (#1755)
A websocket that never opened stays "failed" — onclose no longer overwrites it with "closed", so the terminal says "Could not open the setup terminal." instead of "The terminal session ended.". The terminal emits ended when its session closes, and HarnessPage resets terminalOpen on it (plus a Close terminal button), so reopening starts a fresh session instead of requiring a page reload. The harness load failure now has a Retry button.
This commit is contained in:
2 files changed
+11
-4
No files matched your search
@@ -112,7 +112,7 @@ function scopes(binding: HarnessBinding): string {
|
|||||||
|
|
||||||
<Alert v-if="failure" variant="destructive" class="mb-4">
|
<Alert v-if="failure" variant="destructive" class="mb-4">
|
||||||
<AlertTitle>Could not load the harness</AlertTitle>
|
<AlertTitle>Could not load the harness</AlertTitle>
|
||||||
<AlertDescription>{{ failure }}</AlertDescription>
|
<AlertDescription>{{ failure }} <Button variant="link" size="xs" class="px-0" @click="load">Retry</Button></AlertDescription>
|
||||||
</Alert>
|
</Alert>
|
||||||
|
|
||||||
<div v-if="loading" class="flex flex-col gap-2">
|
<div v-if="loading" class="flex flex-col gap-2">
|
||||||
@@ -153,8 +153,9 @@ function scopes(binding: HarnessBinding): string {
|
|||||||
</div>
|
</div>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
<Section v-if="terminalOpen && profile">
|
<Section v-if="terminalOpen && profile" title="Setup terminal">
|
||||||
<div class="h-96"><SetupTerminal :profile="profile" /></div>
|
<template #action><Button variant="outline" size="sm" @click="terminalOpen = false">Close terminal</Button></template>
|
||||||
|
<div class="h-96"><SetupTerminal :profile="profile" @ended="terminalOpen = false" /></div>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
<Section>
|
<Section>
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ import "@xterm/xterm/css/xterm.css";
|
|||||||
import { setupTerminalURL } from "./harness";
|
import { setupTerminalURL } from "./harness";
|
||||||
|
|
||||||
const props = defineProps<{ profile: string }>();
|
const props = defineProps<{ profile: string }>();
|
||||||
|
// The parent resets its open flag when the session ends, so reopening starts
|
||||||
|
// a new terminal rather than showing a dead one.
|
||||||
|
const emit = defineEmits<{ ended: [] }>();
|
||||||
|
|
||||||
const host = ref<HTMLDivElement | null>(null);
|
const host = ref<HTMLDivElement | null>(null);
|
||||||
const status = ref<"connecting" | "open" | "closed" | "failed">("connecting");
|
const status = ref<"connecting" | "open" | "closed" | "failed">("connecting");
|
||||||
@@ -78,7 +81,10 @@ onMounted(() => {
|
|||||||
status.value = "failed";
|
status.value = "failed";
|
||||||
};
|
};
|
||||||
ws.onclose = () => {
|
ws.onclose = () => {
|
||||||
status.value = "closed";
|
// A connection that never opened stays "failed": onclose must not
|
||||||
|
// overwrite the real reason with "ended".
|
||||||
|
if (status.value !== "failed") status.value = "closed";
|
||||||
|
emit("ended");
|
||||||
};
|
};
|
||||||
term.onData((data) => {
|
term.onData((data) => {
|
||||||
if (ws.readyState === WebSocket.OPEN) ws.send(data);
|
if (ws.readyState === WebSocket.OPEN) ws.send(data);
|
||||||
|
|||||||
Reference in new issue
Block a user