mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-09-22 19:22:25 +01:00
Sync CloudShell backend PTY size on terminal resize (#2553)
* Sync CloudShell backend PTY size on terminal resize
Resizing the browser window only re-fit the local xterm; the remote shell kept its original column count, so typed input wrapped/broke at the wrong column. Add resizeTerminal() client call to the CloudShell terminals/{id}/size endpoint and register a debounced terminal.onResize handler that pushes new dimensions to the backend.
* Add unit tests for registerTerminalResizeHandler (debounce, no-op skip, error handling)
* Fix resizeTerminal success test: stub a successful fetch response
This commit is contained in:
@@ -125,3 +125,27 @@ export const connectTerminal = async (
|
||||
|
||||
return resp.json();
|
||||
};
|
||||
|
||||
export const resizeTerminal = async (
|
||||
consoleUri: string,
|
||||
terminalId: string,
|
||||
size: { rows: number; cols: number },
|
||||
): Promise<void> => {
|
||||
const targetUri = consoleUri + `/terminals/${terminalId}/size?cols=${size.cols}&rows=${size.rows}&version=2019-01-01`;
|
||||
const resp = await fetch(targetUri, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
"Content-Length": "2",
|
||||
Authorization: userContext.authorizationToken,
|
||||
"x-ms-client-request-id": uuidv4(),
|
||||
"Accept-Language": getLocale(),
|
||||
},
|
||||
body: "{}", // empty body is necessary
|
||||
});
|
||||
|
||||
if (!resp.ok) {
|
||||
throw new Error(`Failed to resize terminal: ${resp.status} ${resp.statusText}`);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user