@exagone313/dsh-podman 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/README.zh.md +1 -0
- package/dist/approval-reasons.d.ts +12 -0
- package/dist/approval-reasons.js +15 -0
- package/dist/approval.js +21 -0
- package/dist/card-route.js +83 -1
- package/dist/client/ContainerCard.js +14 -2
- package/dist/client/card-protocol.d.ts +16 -1
- package/dist/client/container-card-controller.d.ts +8 -2
- package/dist/client/container-card-controller.js +21 -0
- package/dist/client/container-card-ports.d.ts +13 -0
- package/dist/client/container-card-ports.js +74 -0
- package/dist/client/container-card-row.d.ts +3 -0
- package/dist/client/container-card-row.js +12 -2
- package/dist/client/container-card-workspace.d.ts +3 -0
- package/dist/client/container-card-workspace.js +2 -2
- package/dist/client/index.js +653 -386
- package/dist/client/locales.d.ts +1 -1
- package/dist/client/locales.js +30 -0
- package/dist/client/tool-presentations.d.ts +167 -0
- package/dist/client/tool-presentations.js +167 -0
- package/dist/client/tool-views.d.ts +1 -2
- package/dist/client/tool-views.js +54 -190
- package/dist/generated/version.d.ts +2 -2
- package/dist/generated/version.js +2 -2
- package/dist/grpc/proto/dshctl/v1/control.proto +47 -1
- package/dist/grpc/proto/dshgateway/v1/gateway.proto +89 -0
- package/dist/grpc/proto/dshguest/v1/guest.proto +17 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/public.d.ts +1 -0
- package/dist/public.js +14 -0
- package/dist/publish-port.d.ts +6 -0
- package/dist/publish-port.js +37 -0
- package/dist/tool-defs.js +15 -1
- package/dist/tool-handlers.js +31 -1
- package/dist/tool-params.d.ts +48 -0
- package/dist/tool-params.js +42 -0
- package/docs/architecture.md +44 -7
- package/docs/architecture.zh.md +38 -6
- package/docs/configuration.md +25 -0
- package/docs/configuration.zh.md +23 -0
- package/docs/development.md +17 -6
- package/docs/development.zh.md +16 -6
- package/docs/install-dsh-and-dsh-podman.md +10 -4
- package/docs/install-dsh-and-dsh-podman.zh.md +9 -3
- package/docs/uninstall.md +4 -3
- package/docs/uninstall.zh.md +3 -2
- package/docs/update.md +23 -6
- package/docs/update.zh.md +23 -6
- package/docs/usage.md +48 -13
- package/docs/usage.zh.md +31 -2
- package/package.json +3 -1
- package/quadlet/dsh-podman-gateway.container +23 -0
- package/quadlet/dsh-podman-orchestrator.container +1 -1
- package/quadlet/dsh.container +1 -1
- package/dist/approval-reasons.test.d.ts +0 -1
- package/dist/approval-reasons.test.js +0 -143
- package/dist/approval.test.d.ts +0 -1
- package/dist/approval.test.js +0 -593
- package/dist/card-route.test.d.ts +0 -1
- package/dist/card-route.test.js +0 -223
- package/dist/card-test-support.d.ts +0 -15
- package/dist/card-test-support.js +0 -133
- package/dist/container-env.test.d.ts +0 -1
- package/dist/container-env.test.js +0 -93
- package/dist/containers.test.d.ts +0 -1
- package/dist/containers.test.js +0 -621
- package/dist/daemons.test.d.ts +0 -1
- package/dist/daemons.test.js +0 -167
- package/dist/dsh-version.test.d.ts +0 -1
- package/dist/dsh-version.test.js +0 -25
- package/dist/env-rows.test.d.ts +0 -1
- package/dist/env-rows.test.js +0 -43
- package/dist/fs-provider.test.d.ts +0 -1
- package/dist/fs-provider.test.js +0 -301
- package/dist/guest-rpc.test.d.ts +0 -1
- package/dist/guest-rpc.test.js +0 -241
- package/dist/images.test.d.ts +0 -1
- package/dist/images.test.js +0 -86
- package/dist/locales.test.d.ts +0 -1
- package/dist/locales.test.js +0 -34
- package/dist/misc.test.d.ts +0 -1
- package/dist/misc.test.js +0 -169
- package/dist/mounts.test.d.ts +0 -1
- package/dist/mounts.test.js +0 -478
- package/dist/naming.test.d.ts +0 -1
- package/dist/naming.test.js +0 -28
- package/dist/package-deps.test.d.ts +0 -1
- package/dist/package-deps.test.js +0 -49
- package/dist/paths.test.d.ts +0 -1
- package/dist/paths.test.js +0 -76
- package/dist/plugin-meta.test.d.ts +0 -1
- package/dist/plugin-meta.test.js +0 -29
- package/dist/project-path.test.d.ts +0 -1
- package/dist/project-path.test.js +0 -66
- package/dist/read-only-shell.test.d.ts +0 -1
- package/dist/read-only-shell.test.js +0 -182
- package/dist/runtime-client.test.d.ts +0 -1
- package/dist/runtime-client.test.js +0 -53
- package/dist/secrets.test.d.ts +0 -1
- package/dist/secrets.test.js +0 -196
- package/dist/settings-commands.test.d.ts +0 -1
- package/dist/settings-commands.test.js +0 -596
- package/dist/settings-create.test.d.ts +0 -1
- package/dist/settings-create.test.js +0 -416
- package/dist/settings-default-env.test.d.ts +0 -1
- package/dist/settings-default-env.test.js +0 -175
- package/dist/settings-mounts.test.d.ts +0 -1
- package/dist/settings-mounts.test.js +0 -506
- package/dist/settings-paths.test.d.ts +0 -1
- package/dist/settings-paths.test.js +0 -65
- package/dist/settings-schema.test.d.ts +0 -1
- package/dist/settings-schema.test.js +0 -35
- package/dist/settings-workspaces.test.d.ts +0 -1
- package/dist/settings-workspaces.test.js +0 -240
- package/dist/spill-store.test.d.ts +0 -1
- package/dist/spill-store.test.js +0 -82
- package/dist/subprocess.test.d.ts +0 -1
- package/dist/subprocess.test.js +0 -344
- package/dist/terminal-preference.test.d.ts +0 -1
- package/dist/terminal-preference.test.js +0 -62
- package/dist/terminal-route.test.d.ts +0 -1
- package/dist/terminal-route.test.js +0 -265
- package/dist/terminal-tab.test.d.ts +0 -1
- package/dist/terminal-tab.test.js +0 -58
- package/dist/terminal-targets.test.d.ts +0 -1
- package/dist/terminal-targets.test.js +0 -43
- package/dist/terminal-titles.test.d.ts +0 -1
- package/dist/terminal-titles.test.js +0 -36
- package/dist/test-support.d.ts +0 -358
- package/dist/test-support.js +0 -499
- package/dist/version-compat.test.d.ts +0 -1
- package/dist/version-compat.test.js +0 -27
- package/dist/views.test.d.ts +0 -1
- package/dist/views.test.js +0 -23
- package/dist/volumes.test.d.ts +0 -1
- package/dist/volumes.test.js +0 -40
- package/dist/workspace-binding.test.d.ts +0 -1
- package/dist/workspace-binding.test.js +0 -523
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: MIT
|
|
4
|
-
import test from "node:test";
|
|
5
|
-
import assert from "node:assert/strict";
|
|
6
|
-
import { readTerminalTarget, TERMINAL_TARGET_KEY, writeTerminalTarget, } from "./client/terminal-preference.js";
|
|
7
|
-
function fakeStorage(initial) {
|
|
8
|
-
const values = new Map();
|
|
9
|
-
if (initial !== undefined)
|
|
10
|
-
values.set(TERMINAL_TARGET_KEY, initial);
|
|
11
|
-
return {
|
|
12
|
-
values,
|
|
13
|
-
getItem: (key) => values.get(key) ?? null,
|
|
14
|
-
setItem: (key, value) => {
|
|
15
|
-
values.set(key, value);
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
test("the terminal card remembers the target it started", () => {
|
|
20
|
-
const storage = fakeStorage();
|
|
21
|
-
assert.equal(readTerminalTarget(storage), undefined);
|
|
22
|
-
writeTerminalTarget({ container: "dev", shell: "/usr/bin/bash" }, storage);
|
|
23
|
-
assert.deepEqual(readTerminalTarget(storage), {
|
|
24
|
-
container: "dev",
|
|
25
|
-
shell: "/usr/bin/bash",
|
|
26
|
-
});
|
|
27
|
-
// The default container is a real choice and must survive the round trip.
|
|
28
|
-
writeTerminalTarget({ container: "", shell: "/bin/sh" }, storage);
|
|
29
|
-
assert.deepEqual(readTerminalTarget(storage), {
|
|
30
|
-
container: "",
|
|
31
|
-
shell: "/bin/sh",
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
test("unusable stored values leave the card without a preference", () => {
|
|
35
|
-
for (const raw of [
|
|
36
|
-
"",
|
|
37
|
-
"{",
|
|
38
|
-
"null",
|
|
39
|
-
"[]",
|
|
40
|
-
'"text"',
|
|
41
|
-
"{}",
|
|
42
|
-
'{"container":1}',
|
|
43
|
-
'{"shell":2}',
|
|
44
|
-
'{"container":null,"shell":false}',
|
|
45
|
-
]) {
|
|
46
|
-
assert.equal(readTerminalTarget(fakeStorage(raw)), undefined, raw);
|
|
47
|
-
}
|
|
48
|
-
// A partial record keeps the half that is usable.
|
|
49
|
-
assert.deepEqual(readTerminalTarget(fakeStorage('{"shell":"/bin/sh","extra":true}')), { shell: "/bin/sh" });
|
|
50
|
-
});
|
|
51
|
-
test("a storage that refuses to answer never breaks the card", () => {
|
|
52
|
-
const failing = {
|
|
53
|
-
getItem() {
|
|
54
|
-
throw new Error("denied");
|
|
55
|
-
},
|
|
56
|
-
setItem() {
|
|
57
|
-
throw new Error("denied");
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
assert.equal(readTerminalTarget(failing), undefined);
|
|
61
|
-
assert.doesNotThrow(() => writeTerminalTarget({ container: "", shell: "/bin/sh" }, failing));
|
|
62
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: MIT
|
|
4
|
-
import test from "node:test";
|
|
5
|
-
import assert from "node:assert/strict";
|
|
6
|
-
import { FakeExecStream, FakeTerminalCall, WORKSPACE_ID, } from "./test-support.js";
|
|
7
|
-
import { TERMINAL_PATH, TERMINAL_RETAINED_PATH, TERMINAL_SHELLS_PATH, TERMINAL_TARGET_PATH, } from "./client/terminal-protocol.js";
|
|
8
|
-
import { workspaceSlug } from "./workspace-binding.js";
|
|
9
|
-
import { discoverShells, requireShell } from "./terminal-shells.js";
|
|
10
|
-
import { TerminalSessions } from "./terminal-sessions.js";
|
|
11
|
-
import { registerTerminalRoutes } from "./terminal-route.js";
|
|
12
|
-
const ROOT = "/projects/team";
|
|
13
|
-
function fakeGuest(options = {}) {
|
|
14
|
-
const terminal = new FakeTerminalCall();
|
|
15
|
-
const starts = [];
|
|
16
|
-
return {
|
|
17
|
-
terminal,
|
|
18
|
-
starts,
|
|
19
|
-
binding: {
|
|
20
|
-
guest: {
|
|
21
|
-
exec: () => new FakeExecStream(starts, { stdout: options.stdout ?? "" }),
|
|
22
|
-
terminal: () => terminal,
|
|
23
|
-
},
|
|
24
|
-
token: "t",
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function fakeResolver(binding) {
|
|
29
|
-
const calls = [];
|
|
30
|
-
return {
|
|
31
|
-
calls,
|
|
32
|
-
resolveForPath: async () => {
|
|
33
|
-
calls.push("default");
|
|
34
|
-
return binding;
|
|
35
|
-
},
|
|
36
|
-
containerBinding: async (_cwd, container) => {
|
|
37
|
-
calls.push(container);
|
|
38
|
-
return binding;
|
|
39
|
-
},
|
|
40
|
-
getConfig: () => ({ projectsRoot: "/projects" }),
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
function fakeRegistry() {
|
|
44
|
-
return { list: () => [{ id: WORKSPACE_ID, path: ROOT }] };
|
|
45
|
-
}
|
|
46
|
-
function routeHarness(sessions, resolver, sessionStore) {
|
|
47
|
-
const routes = new Map();
|
|
48
|
-
const ctx = {
|
|
49
|
-
inject: (_names, fn) => {
|
|
50
|
-
fn({
|
|
51
|
-
connection: {
|
|
52
|
-
fetch: {
|
|
53
|
-
register: (route) => {
|
|
54
|
-
routes.set(route.path, route);
|
|
55
|
-
return async () => { };
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
},
|
|
61
|
-
get: (name) => name === "sessions" ? sessionStore : undefined,
|
|
62
|
-
};
|
|
63
|
-
registerTerminalRoutes(ctx, resolver, sessions, fakeRegistry());
|
|
64
|
-
return routes;
|
|
65
|
-
}
|
|
66
|
-
test("shell discovery parses the probe, dedups and prefers the most capable shell", async () => {
|
|
67
|
-
const { binding } = fakeGuest({
|
|
68
|
-
stdout: "sh\t/usr/bin/sh\nbash\t/usr/bin/bash\nzsh\t/opt/tools/bin/zsh\nnot a path\nbash\t/bin/bash\ndash\t/usr/bin/dash\nfish\t/usr/bin/fish\n",
|
|
69
|
-
});
|
|
70
|
-
const shells = await discoverShells(binding, ROOT);
|
|
71
|
-
assert.deepEqual(shells.map((shell) => `${shell.name}=${shell.path}`), [
|
|
72
|
-
"zsh=/opt/tools/bin/zsh",
|
|
73
|
-
"bash=/usr/bin/bash",
|
|
74
|
-
"fish=/usr/bin/fish",
|
|
75
|
-
"dash=/usr/bin/dash",
|
|
76
|
-
"sh=/usr/bin/sh",
|
|
77
|
-
]);
|
|
78
|
-
});
|
|
79
|
-
test("shell discovery ignores names outside the candidate list", async () => {
|
|
80
|
-
const { binding } = fakeGuest({
|
|
81
|
-
stdout: "rbash\t/usr/bin/rbash\ngit-shell\t/usr/bin/git-shell\n",
|
|
82
|
-
});
|
|
83
|
-
assert.deepEqual(await discoverShells(binding, ROOT), []);
|
|
84
|
-
});
|
|
85
|
-
test("the host resolves a session's workspace from its own directory", async () => {
|
|
86
|
-
const { binding } = fakeGuest();
|
|
87
|
-
const resolver = fakeResolver(binding);
|
|
88
|
-
const sessions = new TerminalSessions({ resolver, retentionMs: 60_000 });
|
|
89
|
-
try {
|
|
90
|
-
const routes = routeHarness(sessions, resolver, {
|
|
91
|
-
get: (id) => id === "s1" ? { header: { cwd: `${ROOT}/src` } } : undefined,
|
|
92
|
-
});
|
|
93
|
-
const target = routes.get(TERMINAL_TARGET_PATH);
|
|
94
|
-
assert.ok(target);
|
|
95
|
-
const found = await target.fetch(new Request(`http://dsh.internal${TERMINAL_TARGET_PATH}?sessionId=s1`));
|
|
96
|
-
assert.equal(found.status, 200);
|
|
97
|
-
assert.deepEqual(await found.json(), {
|
|
98
|
-
workspace: "team",
|
|
99
|
-
workspaceSlug: workspaceSlug(WORKSPACE_ID),
|
|
100
|
-
});
|
|
101
|
-
// A missing id, an unknown session, an empty directory and a directory
|
|
102
|
-
// outside every workspace all refuse rather than guessing.
|
|
103
|
-
const missingId = await target.fetch(new Request(`http://dsh.internal${TERMINAL_TARGET_PATH}`));
|
|
104
|
-
assert.equal(missingId.status, 400);
|
|
105
|
-
assert.deepEqual(await missingId.json(), {
|
|
106
|
-
error: "sessionId is required",
|
|
107
|
-
});
|
|
108
|
-
for (const store of [
|
|
109
|
-
{ get: () => undefined },
|
|
110
|
-
{ get: () => ({ header: { cwd: "" } }) },
|
|
111
|
-
{ get: () => ({ header: { cwd: "/elsewhere" } }) },
|
|
112
|
-
]) {
|
|
113
|
-
const other = routeHarness(sessions, resolver, store).get(TERMINAL_TARGET_PATH);
|
|
114
|
-
const refused = await other.fetch(new Request(`http://dsh.internal${TERMINAL_TARGET_PATH}?sessionId=s1`));
|
|
115
|
-
assert.equal(refused.status, 400);
|
|
116
|
-
assert.deepEqual(await refused.json(), {
|
|
117
|
-
error: "Cannot determine this session's workspace",
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
finally {
|
|
122
|
-
sessions.dispose();
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
test("a shell missing from the probe is refused", async () => {
|
|
126
|
-
const { binding } = fakeGuest({ stdout: "bash\t/usr/bin/bash\n" });
|
|
127
|
-
await assert.rejects(() => requireShell(binding, ROOT, "/bin/zsh"), /not available in this container/);
|
|
128
|
-
});
|
|
129
|
-
test("terminal sessions stream frames, retain the shell and control it", async () => {
|
|
130
|
-
const { binding, terminal } = fakeGuest({ stdout: "bash\t/usr/bin/bash\n" });
|
|
131
|
-
const resolver = fakeResolver(binding);
|
|
132
|
-
const sessions = new TerminalSessions({ resolver, retentionMs: 60_000 });
|
|
133
|
-
try {
|
|
134
|
-
const prepared = await sessions.prepare({
|
|
135
|
-
sessionId: "s1",
|
|
136
|
-
tabId: "t1",
|
|
137
|
-
workspace: "team",
|
|
138
|
-
cwd: ROOT,
|
|
139
|
-
container: "",
|
|
140
|
-
shell: "/usr/bin/bash",
|
|
141
|
-
cols: 80,
|
|
142
|
-
rows: 24,
|
|
143
|
-
});
|
|
144
|
-
assert.equal(prepared.attached, false);
|
|
145
|
-
assert.deepEqual(resolver.calls, ["default"]);
|
|
146
|
-
const frames = [];
|
|
147
|
-
const detach = sessions.listen(prepared.terminalId, (frame) => frames.push(frame), new AbortController().signal);
|
|
148
|
-
assert.equal(frames[0]?.type, "ready");
|
|
149
|
-
terminal.emitStdout(Buffer.from("hi"));
|
|
150
|
-
assert.deepEqual(frames.at(-1), {
|
|
151
|
-
type: "data",
|
|
152
|
-
data: Buffer.from("hi").toString("base64"),
|
|
153
|
-
});
|
|
154
|
-
assert.equal(sessions.control({
|
|
155
|
-
terminalId: prepared.terminalId,
|
|
156
|
-
kind: "input",
|
|
157
|
-
data: Buffer.from("x").toString("base64"),
|
|
158
|
-
}), true);
|
|
159
|
-
assert.deepEqual(terminal.stdinChunks, [Buffer.from("x")]);
|
|
160
|
-
assert.equal(sessions.control({
|
|
161
|
-
terminalId: prepared.terminalId,
|
|
162
|
-
kind: "resize",
|
|
163
|
-
cols: 100,
|
|
164
|
-
rows: 30,
|
|
165
|
-
}), true);
|
|
166
|
-
assert.deepEqual(terminal.resizes, [{ cols: 100, rows: 30 }]);
|
|
167
|
-
assert.equal(sessions.control({
|
|
168
|
-
terminalId: prepared.terminalId,
|
|
169
|
-
kind: "rename",
|
|
170
|
-
title: "dev",
|
|
171
|
-
}), true);
|
|
172
|
-
assert.deepEqual(frames.at(-1), { type: "title", title: "dev" });
|
|
173
|
-
terminal.emitExit(0);
|
|
174
|
-
// The exit frame is written from the guest's done promise.
|
|
175
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
176
|
-
assert.equal(frames.at(-1)?.type, "exit");
|
|
177
|
-
// Reattaching replays the serialized screen and the exit state.
|
|
178
|
-
const again = await sessions.prepare({
|
|
179
|
-
sessionId: "s1",
|
|
180
|
-
tabId: "t1",
|
|
181
|
-
workspace: "team",
|
|
182
|
-
cwd: ROOT,
|
|
183
|
-
container: "",
|
|
184
|
-
shell: "/usr/bin/bash",
|
|
185
|
-
cols: 80,
|
|
186
|
-
rows: 24,
|
|
187
|
-
});
|
|
188
|
-
assert.equal(again.attached, true);
|
|
189
|
-
assert.equal(again.terminalId, prepared.terminalId);
|
|
190
|
-
const reattached = [];
|
|
191
|
-
sessions.listen(again.terminalId, (frame) => reattached.push(frame), new AbortController().signal, again.snapshot);
|
|
192
|
-
assert.equal(reattached[0]?.type, "ready");
|
|
193
|
-
assert.equal(reattached[1]?.type, "snapshot");
|
|
194
|
-
assert.equal(reattached.at(-1)?.type, "exit");
|
|
195
|
-
// A named container resolves through containerBinding.
|
|
196
|
-
const other = await sessions.prepare({
|
|
197
|
-
sessionId: "s1",
|
|
198
|
-
tabId: "t2",
|
|
199
|
-
workspace: "team",
|
|
200
|
-
cwd: ROOT,
|
|
201
|
-
container: "dev",
|
|
202
|
-
shell: "/usr/bin/bash",
|
|
203
|
-
cols: 80,
|
|
204
|
-
rows: 24,
|
|
205
|
-
});
|
|
206
|
-
assert.deepEqual(resolver.calls, ["default", "dev"]);
|
|
207
|
-
assert.equal(sessions.retained("s1").length, 2);
|
|
208
|
-
assert.equal(sessions.control({ terminalId: other.terminalId, kind: "close" }), true);
|
|
209
|
-
assert.equal(sessions.retained("s1").length, 1);
|
|
210
|
-
detach();
|
|
211
|
-
}
|
|
212
|
-
finally {
|
|
213
|
-
sessions.dispose();
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
test("terminal routes open, control, list and validate", async () => {
|
|
217
|
-
const { binding, terminal } = fakeGuest({ stdout: "bash\t/usr/bin/bash\n" });
|
|
218
|
-
const resolver = fakeResolver(binding);
|
|
219
|
-
const sessions = new TerminalSessions({ resolver, retentionMs: 60_000 });
|
|
220
|
-
try {
|
|
221
|
-
const routes = routeHarness(sessions, resolver);
|
|
222
|
-
const open = routes.get(TERMINAL_PATH);
|
|
223
|
-
assert.ok(open);
|
|
224
|
-
const missingShell = await open.fetch(new Request(`http://dsh.internal${TERMINAL_PATH}?sessionId=s1&tabId=t1&workspace=team&cols=80&rows=24`));
|
|
225
|
-
assert.equal(missingShell.status, 400);
|
|
226
|
-
const unknownWorkspace = await open.fetch(new Request(`http://dsh.internal${TERMINAL_PATH}?sessionId=s1&tabId=t1&workspace=nope&shell=/usr/bin/bash&cols=80&rows=24`));
|
|
227
|
-
assert.equal(unknownWorkspace.status, 400);
|
|
228
|
-
const response = await open.fetch(new Request(`http://dsh.internal${TERMINAL_PATH}?sessionId=s1&tabId=t1&workspace=team&shell=/usr/bin/bash&cols=80&rows=24`));
|
|
229
|
-
assert.equal(response.status, 200);
|
|
230
|
-
assert.equal(response.headers.get("content-type"), "application/x-ndjson");
|
|
231
|
-
const reader = response.body.getReader();
|
|
232
|
-
const first = new TextDecoder().decode((await reader.read()).value);
|
|
233
|
-
assert.match(first, /"type":"ready"/);
|
|
234
|
-
const ready = JSON.parse(first.trim().split("\n")[0]);
|
|
235
|
-
const control = await open.fetch(new Request(`http://dsh.internal${TERMINAL_PATH}`, {
|
|
236
|
-
method: "POST",
|
|
237
|
-
body: JSON.stringify({
|
|
238
|
-
terminalId: ready.terminalId,
|
|
239
|
-
kind: "resize",
|
|
240
|
-
cols: 90,
|
|
241
|
-
rows: 30,
|
|
242
|
-
}),
|
|
243
|
-
}));
|
|
244
|
-
assert.equal(control.status, 200);
|
|
245
|
-
assert.deepEqual(terminal.resizes, [{ cols: 90, rows: 30 }]);
|
|
246
|
-
const unknownTerminal = await open.fetch(new Request(`http://dsh.internal${TERMINAL_PATH}`, {
|
|
247
|
-
method: "POST",
|
|
248
|
-
body: JSON.stringify({ terminalId: "nope", kind: "close" }),
|
|
249
|
-
}));
|
|
250
|
-
assert.equal(unknownTerminal.status, 404);
|
|
251
|
-
const shellsResponse = await routes.get(TERMINAL_SHELLS_PATH).fetch(new Request(`http://dsh.internal${TERMINAL_SHELLS_PATH}?workspace=team&sessionId=s1`));
|
|
252
|
-
const shellsBody = (await shellsResponse.json());
|
|
253
|
-
assert.deepEqual(shellsBody.shells.map((shell) => shell.path), [
|
|
254
|
-
"/usr/bin/bash",
|
|
255
|
-
]);
|
|
256
|
-
const retainedResponse = await routes.get(TERMINAL_RETAINED_PATH).fetch(new Request(`http://dsh.internal${TERMINAL_RETAINED_PATH}?sessionId=s1`));
|
|
257
|
-
const retainedBody = (await retainedResponse.json());
|
|
258
|
-
assert.equal(retainedBody.terminals.length, 1);
|
|
259
|
-
assert.equal(retainedBody.terminals[0]?.tabId, "t1");
|
|
260
|
-
await reader.cancel();
|
|
261
|
-
}
|
|
262
|
-
finally {
|
|
263
|
-
sessions.dispose();
|
|
264
|
-
}
|
|
265
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: MIT
|
|
4
|
-
import test from "node:test";
|
|
5
|
-
import assert from "node:assert/strict";
|
|
6
|
-
// Importing the client module here also typechecks it under the host program,
|
|
7
|
-
// which has no DOM lib: it must stay environment-free data.
|
|
8
|
-
import { PODMAN_TERMINAL_SHORTCUT_DEFAULTS, PODMAN_TERMINAL_SHORTCUT_FALLBACK_DEFAULTS, } from "./client/terminal-tab.js";
|
|
9
|
-
// The harness's shortcuts registry rejects a declared default it does not admit
|
|
10
|
-
// by THROWING from register(), which runs inside apply(): one bad profile fails
|
|
11
|
-
// the client entry and the whole web boot. These assertions pin the profiles
|
|
12
|
-
// that rule allows, so such a break is caught by pnpm test instead of in the UI.
|
|
13
|
-
test("the Podman terminal shortcut prefers the built-in terminal's binding", () => {
|
|
14
|
-
const defaults = PODMAN_TERMINAL_SHORTCUT_DEFAULTS;
|
|
15
|
-
assert.deepEqual(Object.keys(defaults).sort(), [
|
|
16
|
-
"desktop:linux",
|
|
17
|
-
"desktop:macos",
|
|
18
|
-
"desktop:windows",
|
|
19
|
-
"web:macos",
|
|
20
|
-
"web:windows",
|
|
21
|
-
]);
|
|
22
|
-
for (const value of Object.values(PODMAN_TERMINAL_SHORTCUT_DEFAULTS)) {
|
|
23
|
-
assert.deepEqual(value, { code: "Backquote", modifiers: ["control"] });
|
|
24
|
-
}
|
|
25
|
-
// Linux Web admits only Ctrl+/, Ctrl+Shift+, and Ctrl+Shift+.
|
|
26
|
-
assert.equal(defaults["web:linux"], undefined);
|
|
27
|
-
});
|
|
28
|
-
test("the fallback binding is distinct and equally admitted", () => {
|
|
29
|
-
const fallback = PODMAN_TERMINAL_SHORTCUT_FALLBACK_DEFAULTS;
|
|
30
|
-
assert.deepEqual(Object.keys(fallback).sort(), [
|
|
31
|
-
"desktop:linux",
|
|
32
|
-
"desktop:macos",
|
|
33
|
-
"desktop:windows",
|
|
34
|
-
"web:macos",
|
|
35
|
-
"web:windows",
|
|
36
|
-
]);
|
|
37
|
-
// macOS Web admits Ctrl+` and Meta+Shift+`, never Ctrl+Shift+`.
|
|
38
|
-
assert.deepEqual(PODMAN_TERMINAL_SHORTCUT_FALLBACK_DEFAULTS["web:macos"], {
|
|
39
|
-
code: "Backquote",
|
|
40
|
-
modifiers: ["meta", "shift"],
|
|
41
|
-
});
|
|
42
|
-
for (const profile of [
|
|
43
|
-
"desktop:macos",
|
|
44
|
-
"desktop:windows",
|
|
45
|
-
"desktop:linux",
|
|
46
|
-
"web:windows",
|
|
47
|
-
]) {
|
|
48
|
-
assert.deepEqual(PODMAN_TERMINAL_SHORTCUT_FALLBACK_DEFAULTS[profile], {
|
|
49
|
-
code: "Backquote",
|
|
50
|
-
modifiers: ["control", "shift"],
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
// The two bindings can never overlap, so the fallback cannot be the reason a
|
|
54
|
-
// re-enabled built-in terminal breaks the boot.
|
|
55
|
-
for (const profile of Object.keys(fallback)) {
|
|
56
|
-
assert.notDeepEqual(fallback[profile], PODMAN_TERMINAL_SHORTCUT_DEFAULTS[profile]);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: MIT
|
|
4
|
-
import test from "node:test";
|
|
5
|
-
import assert from "node:assert/strict";
|
|
6
|
-
import { containerOptions, shellName, validContainer, validShell, } from "./client/terminal-targets.js";
|
|
7
|
-
function row(containerName, workspaceSlug) {
|
|
8
|
-
return { containerName, workspaceSlug };
|
|
9
|
-
}
|
|
10
|
-
test("terminal container options are logical names only", () => {
|
|
11
|
-
const containers = [
|
|
12
|
-
row("default", "alpha"),
|
|
13
|
-
row("dev", "alpha"),
|
|
14
|
-
row("db", "beta"),
|
|
15
|
-
// A podman name is never a valid target: the API rejects it.
|
|
16
|
-
row("dsh-podman-alpha-default", "alpha"),
|
|
17
|
-
];
|
|
18
|
-
assert.deepEqual(containerOptions(containers, "alpha"), ["dev"]);
|
|
19
|
-
assert.deepEqual(containerOptions(containers, "beta"), ["db"]);
|
|
20
|
-
assert.deepEqual(containerOptions(containers, "missing"), []);
|
|
21
|
-
assert.deepEqual(containerOptions(containers, undefined), []);
|
|
22
|
-
});
|
|
23
|
-
test("remembered targets are reused only while they are still offered", () => {
|
|
24
|
-
// Containers: the default answer is the workspace's own default.
|
|
25
|
-
assert.equal(validContainer(undefined, ["dev"]), "");
|
|
26
|
-
assert.equal(validContainer("", ["dev"]), "");
|
|
27
|
-
assert.equal(validContainer("dev", ["dev"]), "dev");
|
|
28
|
-
assert.equal(validContainer("gone", ["dev"]), "");
|
|
29
|
-
// Shells: a recreated container may no longer offer the remembered path.
|
|
30
|
-
const shells = [{ name: "bash", path: "/usr/bin/bash" }];
|
|
31
|
-
assert.equal(validShell(undefined, shells), undefined);
|
|
32
|
-
assert.equal(validShell("", shells), undefined);
|
|
33
|
-
assert.equal(validShell("/usr/bin/bash", shells), "/usr/bin/bash");
|
|
34
|
-
assert.equal(validShell("/bin/zsh", shells), undefined);
|
|
35
|
-
});
|
|
36
|
-
test("a shell path is named by its basename", () => {
|
|
37
|
-
assert.equal(shellName("/usr/bin/bash"), "bash");
|
|
38
|
-
assert.equal(shellName("/bin/sh"), "sh");
|
|
39
|
-
assert.equal(shellName("pwsh"), "pwsh");
|
|
40
|
-
assert.equal(shellName("/opt/tools/bin/"), undefined);
|
|
41
|
-
assert.equal(shellName(""), undefined);
|
|
42
|
-
assert.equal(shellName(undefined), undefined);
|
|
43
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: MIT
|
|
4
|
-
import test from "node:test";
|
|
5
|
-
import assert from "node:assert/strict";
|
|
6
|
-
import { forgetTerminalTitle, publishTerminalTitle, subscribeTerminalTitles, terminalTitle, } from "./client/terminal-titles.js";
|
|
7
|
-
test("published terminal titles are readable, notifying and forgettable", () => {
|
|
8
|
-
let notifications = 0;
|
|
9
|
-
const unsubscribe = subscribeTerminalTitles(() => {
|
|
10
|
-
notifications += 1;
|
|
11
|
-
});
|
|
12
|
-
assert.equal(terminalTitle("s1:t1"), undefined);
|
|
13
|
-
publishTerminalTitle("s1:t1", "bash");
|
|
14
|
-
assert.equal(terminalTitle("s1:t1"), "bash");
|
|
15
|
-
assert.equal(notifications, 1);
|
|
16
|
-
// Re-publishing the same name is a no-op; another terminal is independent.
|
|
17
|
-
publishTerminalTitle("s1:t1", "bash");
|
|
18
|
-
publishTerminalTitle("s1:t1", "");
|
|
19
|
-
assert.equal(notifications, 1);
|
|
20
|
-
publishTerminalTitle("s1:t2", "sh");
|
|
21
|
-
assert.equal(terminalTitle("s1:t2"), "sh");
|
|
22
|
-
assert.equal(notifications, 2);
|
|
23
|
-
// The same tab id in another session never bleeds through.
|
|
24
|
-
publishTerminalTitle("s2:t1", "zsh");
|
|
25
|
-
assert.equal(terminalTitle("s1:t1"), "bash");
|
|
26
|
-
assert.equal(terminalTitle("s2:t1"), "zsh");
|
|
27
|
-
forgetTerminalTitle("s1:t1");
|
|
28
|
-
assert.equal(terminalTitle("s1:t1"), undefined);
|
|
29
|
-
assert.equal(notifications, 4);
|
|
30
|
-
// Forgetting an unknown key changes nothing.
|
|
31
|
-
forgetTerminalTitle("s1:t1");
|
|
32
|
-
assert.equal(notifications, 4);
|
|
33
|
-
unsubscribe();
|
|
34
|
-
publishTerminalTitle("s1:t2", "fish");
|
|
35
|
-
assert.equal(notifications, 4);
|
|
36
|
-
});
|