Skip to content

Commit 74fe27f

Browse files
fix terminals and commands list
1 parent ffc629d commit 74fe27f

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codesandbox/sdk",
3-
"version": "1.0.0-rc.3",
3+
"version": "1.0.0-rc.4",
44
"description": "The CodeSandbox SDK",
55
"author": "CodeSandbox",
66
"license": "MIT",

src/sessions/WebSocketSession/commands.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ export class Commands {
3636
/**
3737
* Create and run command in a new shell. Allows you to listen to the output and kill the command.
3838
*/
39-
async runBackground(command: string | string[], opts?: ShellRunOpts) {
39+
async runBackground(
40+
command: string | string[],
41+
opts?: Omit<ShellRunOpts, "name">
42+
) {
4043
const disposableStore = new DisposableStore();
4144
const onOutput = new Emitter<string>();
4245
disposableStore.add(onOutput);
@@ -64,9 +67,11 @@ export class Commands {
6467
true
6568
);
6669

67-
if (opts?.name) {
68-
this.pitcherClient.clients.shell.rename(shell.shellId, opts.name);
69-
}
70+
// Only way for us to differentiate between a command and a terminal
71+
this.pitcherClient.clients.shell.rename(
72+
shell.shellId,
73+
`COMMAND-${shell.shellId}`
74+
);
7075

7176
const cmd = new Command(
7277
this.pitcherClient,
@@ -92,7 +97,10 @@ export class Commands {
9297
const shells = this.pitcherClient.clients.shell.getShells();
9398

9499
return shells
95-
.filter((shell) => shell.shellType === "COMMAND")
100+
.filter(
101+
(shell) =>
102+
shell.shellType === "TERMINAL" && shell.name.startsWith("COMMAND-")
103+
)
96104
.map((shell) => new Command(this.pitcherClient, shell));
97105
}
98106
}
@@ -120,21 +128,14 @@ export class Command {
120128

121129
private output: string[] = [];
122130

123-
/**
124-
* The command that was run.
125-
*/
126-
get command(): string {
127-
return this.shell.startCommand;
128-
}
129-
130131
/**
131132
* The status of the command.
132133
*/
133134
status: CommandStatus = "RUNNING";
134135

135136
constructor(
136137
private pitcherClient: IPitcherClient,
137-
private shell: protocol.shell.CommandShellDTO & { buffer?: string[] }
138+
private shell: protocol.shell.ShellDTO & { buffer?: string[] }
138139
) {
139140
this.disposable.addDisposable(
140141
pitcherClient.clients.shell.onShellExited(({ shellId, exitCode }) => {

src/sessions/WebSocketSession/terminals.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ export class Terminals {
7171
const shells = this.pitcherClient.clients.shell.getShells();
7272

7373
return shells
74-
.filter((shell) => shell.shellType === "TERMINAL")
74+
.filter(
75+
(shell) =>
76+
shell.shellType === "TERMINAL" && !shell.name.startsWith("COMMAND-")
77+
)
7578
.map((shell) => new Terminal(shell, this.pitcherClient));
7679
}
7780
}

0 commit comments

Comments
 (0)