feat(harness): create the setup PTY at the browser's size
The setup terminal created its PTY at a fixed 24x80 while the browser measured its own box and threw the measurement away, so a full-screen CLI login drew into a corner of a much larger xterm. OpenRequest now carries a ConsoleSize with the target frame; the route reads cols/rows from the WebSocket URL, falling back to 24x80 when they are absent or out of range, and the daemon creates the PTY at that geometry. The component sends the size it measured before connecting. Live resize is the follow-on: it needs a control channel on the WebSocket, which today is a raw byte copy.
This commit is contained in:
1 parent
6110693aa8
commit
97afa76685
10 files changed
+204
-50
No files matched your search
@@ -6,10 +6,9 @@
|
||||
* set headers on a WebSocket, so the shared-token gate reads the same
|
||||
* HttpOnly cookie the SSE stream uses.
|
||||
*
|
||||
* The transport is raw bytes in both directions. Sizing the remote PTY is a
|
||||
* contract detail the daemon side will own with the session, so this
|
||||
* component fits the local surface but does not claim to resize the
|
||||
* container.
|
||||
* The transport is raw bytes in both directions. The component measures its
|
||||
* own box before connecting and sends that size so the remote PTY is created
|
||||
* at the right geometry; live resize is not wired yet.
|
||||
*/
|
||||
import { onBeforeUnmount, onMounted, ref } from "vue";
|
||||
import { Terminal } from "@xterm/xterm";
|
||||
@@ -59,7 +58,9 @@ onMounted(() => {
|
||||
fitLocal();
|
||||
term.focus();
|
||||
|
||||
const ws = new WebSocket(setupTerminalURL(props.profile, window.location));
|
||||
const ws = new WebSocket(
|
||||
setupTerminalURL(props.profile, window.location, term?.cols ?? 80, term?.rows ?? 24),
|
||||
);
|
||||
socket = ws;
|
||||
ws.binaryType = "arraybuffer";
|
||||
ws.onopen = () => {
|
||||
|
||||
@@ -53,15 +53,22 @@ export function bindingStatus(
|
||||
}
|
||||
|
||||
/**
|
||||
* setupTerminalURL builds the WebSocket URL for one Kit profile. The location
|
||||
* is a parameter rather than window so the module stays runnable outside a
|
||||
* browser.
|
||||
* setupTerminalURL builds the WebSocket URL for one Kit profile, carrying the
|
||||
* terminal size the browser measured so the remote PTY is created with it.
|
||||
* The location is a parameter rather than window so the module stays runnable
|
||||
* outside a browser.
|
||||
*/
|
||||
export function setupTerminalURL(
|
||||
profile: string,
|
||||
location: Pick<Location, "protocol" | "host">,
|
||||
cols = 80,
|
||||
rows = 24,
|
||||
): string {
|
||||
const scheme = location.protocol === "https:" ? "wss:" : "ws:";
|
||||
const query = new URLSearchParams({ profile }).toString();
|
||||
const query = new URLSearchParams({
|
||||
profile,
|
||||
cols: String(cols),
|
||||
rows: String(rows),
|
||||
}).toString();
|
||||
return `${scheme}//${location.host}/api/harness/terminal?${query}`;
|
||||
}
|
||||
Reference in new issue
Block a user