@frebreco/canvas 0.3.0-next.2 → 0.3.0-next.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frebreco/canvas",
3
- "version": "0.3.0-next.2",
3
+ "version": "0.3.0-next.4",
4
4
  "description": "A multiplayer canvas for coding agents that run on your machine.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -6,6 +6,17 @@
6
6
 
7
7
  const SCROLLBACK = 200_000;
8
8
 
9
+ /**
10
+ * The shell must lead a session of its own, with the PTY as its controlling
11
+ * terminal, as in any terminal emulator. `Bun.spawn` leaves it in the session
12
+ * of `canvas serve` (Bun 1.4): Ctrl-C reaches nothing, and whatever opens
13
+ * `/dev/tty` — fzf's Ctrl-R, sudo, ssh prompts — gets the terminal `canvas
14
+ * serve` runs in, where it is stopped as a background job. util-linux
15
+ * `setsid -c` does both; where it is missing (macOS) the shell runs as before.
16
+ */
17
+ const SETSID = Bun.which("setsid");
18
+ const SESSION = SETSID ? [SETSID, "-c"] : [];
19
+
9
20
  interface Term {
10
21
  terminal: Bun.Terminal;
11
22
  scrollback: string;
@@ -19,6 +30,7 @@ export class Terminals {
19
30
  private readonly dir: string,
20
31
  private readonly onData: (id: string, data: string) => void,
21
32
  private readonly onExit: (id: string, code: number | null) => void,
33
+ private readonly shell = process.env.SHELL ?? "bash",
22
34
  ) {}
23
35
 
24
36
  /** Open (or re-attach to) a terminal; returns the scrollback to replay. */
@@ -42,8 +54,7 @@ export class Terminals {
42
54
  }),
43
55
  };
44
56
  this.terms.set(id, term);
45
- const shell = process.env.SHELL ?? "bash";
46
- const proc = Bun.spawn([shell, "-l"], {
57
+ const proc = Bun.spawn([...SESSION, this.shell, "-l"], {
47
58
  cwd: this.dir,
48
59
  terminal: term.terminal,
49
60
  env: { ...process.env, TERM: "xterm-256color" },