Skip to content

Commit e9f8822

Browse files
feat(site): allow opening web terminal to container (#16797)
Co-authored-by: BrunoQuaresma <bruno_nonato_quaresma@hotmail.com>
1 parent d8561a6 commit e9f8822

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

site/src/pages/TerminalPage/TerminalPage.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ const TerminalPage: FC = () => {
5555
// a round-trip, and must be a UUIDv4.
5656
const reconnectionToken = searchParams.get("reconnect") ?? uuidv4();
5757
const command = searchParams.get("command") || undefined;
58+
const containerName = searchParams.get("container") || undefined;
59+
const containerUser = searchParams.get("container_user") || undefined;
5860
// The workspace name is in the format:
5961
// <workspace name>[.<agent name>]
6062
const workspaceNameParts = params.workspace?.split(".");
@@ -234,6 +236,8 @@ const TerminalPage: FC = () => {
234236
command,
235237
terminal.rows,
236238
terminal.cols,
239+
containerName,
240+
containerUser,
237241
)
238242
.then((url) => {
239243
if (disposed) {
@@ -302,6 +306,8 @@ const TerminalPage: FC = () => {
302306
workspace.error,
303307
workspace.isLoading,
304308
workspaceAgent,
309+
containerName,
310+
containerUser,
305311
]);
306312

307313
return (

site/src/utils/terminal.ts

+8
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,21 @@ export const terminalWebsocketUrl = async (
77
command: string | undefined,
88
height: number,
99
width: number,
10+
containerName: string | undefined,
11+
containerUser: string | undefined,
1012
): Promise<string> => {
1113
const query = new URLSearchParams({ reconnect });
1214
if (command) {
1315
query.set("command", command);
1416
}
1517
query.set("height", height.toString());
1618
query.set("width", width.toString());
19+
if (containerName) {
20+
query.set("container", containerName);
21+
}
22+
if (containerName && containerUser) {
23+
query.set("container_user", containerUser);
24+
}
1725

1826
const url = new URL(baseUrl || `${location.protocol}//${location.host}`);
1927
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";

0 commit comments

Comments
 (0)