feat(site): allow opening web terminal to container (#16797)

Co-authored-by: BrunoQuaresma <bruno_nonato_quaresma@hotmail.com>
This commit is contained in:
Cian Johnston
2025-03-04 13:22:03 +00:00
committed by GitHub
parent d8561a62fc
commit e9f882220e
2 changed files with 14 additions and 0 deletions
@@ -55,6 +55,8 @@ const TerminalPage: FC = () => {
// a round-trip, and must be a UUIDv4.
const reconnectionToken = searchParams.get("reconnect") ?? uuidv4();
const command = searchParams.get("command") || undefined;
const containerName = searchParams.get("container") || undefined;
const containerUser = searchParams.get("container_user") || undefined;
// The workspace name is in the format:
// <workspace name>[.<agent name>]
const workspaceNameParts = params.workspace?.split(".");
@@ -234,6 +236,8 @@ const TerminalPage: FC = () => {
command,
terminal.rows,
terminal.cols,
containerName,
containerUser,
)
.then((url) => {
if (disposed) {
@@ -302,6 +306,8 @@ const TerminalPage: FC = () => {
workspace.error,
workspace.isLoading,
workspaceAgent,
containerName,
containerUser,
]);
return (
+8
View File
@@ -7,6 +7,8 @@ export const terminalWebsocketUrl = async (
command: string | undefined,
height: number,
width: number,
containerName: string | undefined,
containerUser: string | undefined,
): Promise<string> => {
const query = new URLSearchParams({ reconnect });
if (command) {
@@ -14,6 +16,12 @@ export const terminalWebsocketUrl = async (
}
query.set("height", height.toString());
query.set("width", width.toString());
if (containerName) {
query.set("container", containerName);
}
if (containerName && containerUser) {
query.set("container_user", containerUser);
}
const url = new URL(baseUrl || `${location.protocol}//${location.host}`);
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";