@gapi/gcli 1.8.270 → 1.8.272
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/docs/changelog.d/2026-11-18-local-workspaces-browser-terminal-pty-starts-at-the-browser-s-size-stty-not-8.md +14 -0
- package/docs/changelog.d/2026-11-18-local-workspaces-watch-open-watch-close-the-browser-editor-watches-files-with.md +17 -0
- package/package.json +1 -1
- package/release/index.js +70 -32
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
## 2026-11-18 - local-workspaces: Browser terminal PTY starts at the browser's size (stty), not 80 columns
|
|
2
|
+
|
|
3
|
+
**Feature:** local-workspaces · **Type:** fix
|
|
4
|
+
|
|
5
|
+
- The shell under `script` asked its PTY for the size (80x24), not COLUMNS:
|
|
6
|
+
commands wrapped at 80 columns in a wide editor (seen in a cloud
|
|
7
|
+
workspace). `shellCommand(size)` now runs `stty cols C rows R; exec shell
|
|
8
|
+
-i` inside the PTY (linux `script -qfec`, macOS `script -q /dev/null
|
|
9
|
+
/bin/sh -c`). The size comes from the browser, so `dimension()` lets only
|
|
10
|
+
integers 10..1000 into the command line.
|
|
11
|
+
- Resize after start is still not passed (plan 36 follow-up).
|
|
12
|
+
- **Test:** `npx jest test/workspace-terminals.spec.ts --forceExit` (12).
|
|
13
|
+
- **Debug:** `stty size` in the terminal shows what the shell sees.
|
|
14
|
+
- **Verification:** 12/12, lint clean.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
## 2026-11-18 - local-workspaces: watch/open + watch/close: the browser editor watches files without a terminal
|
|
2
|
+
|
|
3
|
+
**Feature:** local-workspaces · **Type:** feat
|
|
4
|
+
|
|
5
|
+
- Found by the owner: a file edited in his own IDE did not update in the
|
|
6
|
+
Lambforge editor - changes were only watched while a browser terminal
|
|
7
|
+
was open.
|
|
8
|
+
- `TerminalManager.watch()` / `unwatch()`: a watch of its own (recursive
|
|
9
|
+
fs.watch, 150 ms batches, .gitignore'd paths dropped) pushing `changed`
|
|
10
|
+
events under its sessionId; terminals are shells only now. Ops
|
|
11
|
+
`watch/open`, `watch/close` - no `--allow-terminal` needed (names only,
|
|
12
|
+
what `list` shows anyway). Max 4 watches.
|
|
13
|
+
- **Test:** `npx jest test/workspace-terminals.spec.ts --coverage=false`
|
|
14
|
+
(a watch reports changes; watch/open works without the flag).
|
|
15
|
+
- **Debug:** no updates in the browser -> the gcli log shows "the browser
|
|
16
|
+
editor watches the files" when the editor opens; older gcli has no watch.
|
|
17
|
+
- **Verification:** tsc clean, `npm run lint`, jest workspace specs 50/50.
|
package/package.json
CHANGED
package/release/index.js
CHANGED
|
@@ -324599,15 +324599,22 @@ ${this.text}` : this.text;
|
|
|
324599
324599
|
});
|
|
324600
324600
|
|
|
324601
324601
|
// src/commands/workspace/terminals.ts
|
|
324602
|
-
function
|
|
324603
|
-
|
|
324602
|
+
function dimension(value, fallback) {
|
|
324603
|
+
const n = Math.trunc(Number(value));
|
|
324604
|
+
return Number.isFinite(n) && n >= 10 && n <= 1e3 ? n : fallback;
|
|
324605
|
+
}
|
|
324606
|
+
function shellCommand(size = {}, platform2 = process.platform, hasScript = () => !(0, import_child_process8.spawnSync)("script", ["--version"]).error) {
|
|
324607
|
+
if (platform2 === "win32") {
|
|
324604
324608
|
return [process.env.ComSpec || "cmd.exe", []];
|
|
324605
324609
|
}
|
|
324606
324610
|
const shell = process.env.SHELL || "/bin/sh";
|
|
324607
|
-
if ((
|
|
324611
|
+
if (!hasScript()) {
|
|
324608
324612
|
return [shell, ["-i"]];
|
|
324609
324613
|
}
|
|
324610
|
-
|
|
324614
|
+
const cols = dimension(size.cols, 80);
|
|
324615
|
+
const rows = dimension(size.rows, 24);
|
|
324616
|
+
const start3 = `stty cols ${cols} rows ${rows} 2>/dev/null; exec ${shell} -i`;
|
|
324617
|
+
return platform2 === "darwin" ? ["script", ["-q", "/dev/null", "/bin/sh", "-c", start3]] : ["script", ["-qfec", start3, "/dev/null"]];
|
|
324611
324618
|
}
|
|
324612
324619
|
function kill(child) {
|
|
324613
324620
|
try {
|
|
@@ -324642,7 +324649,10 @@ var init_terminals = __esm({
|
|
|
324642
324649
|
this.env = env;
|
|
324643
324650
|
this.notIgnored = notIgnored;
|
|
324644
324651
|
this.events$ = new import_rxjs70.Subject();
|
|
324652
|
+
/** shells (`terminal/*`) */
|
|
324645
324653
|
this.sessions = /* @__PURE__ */ new Map();
|
|
324654
|
+
/** file watches (`watch/*`) - the open editor, terminal or not */
|
|
324655
|
+
this.watches = /* @__PURE__ */ new Map();
|
|
324646
324656
|
}
|
|
324647
324657
|
open(size) {
|
|
324648
324658
|
if (this.sessions.size >= MAX_SESSIONS) {
|
|
@@ -324652,7 +324662,7 @@ var init_terminals = __esm({
|
|
|
324652
324662
|
);
|
|
324653
324663
|
}
|
|
324654
324664
|
const sessionId = (0, import_crypto3.randomUUID)();
|
|
324655
|
-
const [command, args] = shellCommand();
|
|
324665
|
+
const [command, args] = shellCommand(size);
|
|
324656
324666
|
const child = (0, import_child_process8.spawn)(command, args, {
|
|
324657
324667
|
cwd: this.root,
|
|
324658
324668
|
env: {
|
|
@@ -324679,46 +324689,66 @@ var init_terminals = __esm({
|
|
|
324679
324689
|
${e2.message}\r
|
|
324680
324690
|
` })
|
|
324681
324691
|
);
|
|
324692
|
+
this.sessions.set(sessionId, child);
|
|
324693
|
+
return { sessionId, pty: command === "script" };
|
|
324694
|
+
}
|
|
324695
|
+
input(sessionId, data) {
|
|
324696
|
+
const child = this.sessions.get(sessionId);
|
|
324697
|
+
if (!child) {
|
|
324698
|
+
throw new WorkspaceError("This terminal is closed.", 404);
|
|
324699
|
+
}
|
|
324700
|
+
child.stdin?.write(data);
|
|
324701
|
+
return { written: data.length };
|
|
324702
|
+
}
|
|
324703
|
+
close(sessionId) {
|
|
324704
|
+
const child = this.sessions.get(sessionId);
|
|
324705
|
+
if (child) {
|
|
324706
|
+
kill(child);
|
|
324707
|
+
this.forget(sessionId);
|
|
324708
|
+
}
|
|
324709
|
+
return { closed: !!child };
|
|
324710
|
+
}
|
|
324711
|
+
/**
|
|
324712
|
+
* Watch the root for the browser editor (no shell, no --allow-terminal:
|
|
324713
|
+
* only the names of changed files, which `list` shows anyway). Changes
|
|
324714
|
+
* are batched, de-duplicated and `.gitignore`d ones dropped, then sent as
|
|
324715
|
+
* `changed` events of this watch.
|
|
324716
|
+
*/
|
|
324717
|
+
watch() {
|
|
324718
|
+
if (this.watches.size >= MAX_SESSIONS) {
|
|
324719
|
+
throw new WorkspaceError(
|
|
324720
|
+
`At most ${MAX_SESSIONS} editors watching at a time.`,
|
|
324721
|
+
429
|
|
324722
|
+
);
|
|
324723
|
+
}
|
|
324724
|
+
const sessionId = (0, import_crypto3.randomUUID)();
|
|
324682
324725
|
const changed$ = new import_rxjs70.Subject();
|
|
324683
324726
|
const changes = changed$.pipe(
|
|
324684
324727
|
(0, import_operators59.bufferTime)(WATCH_BATCH_MS),
|
|
324685
324728
|
(0, import_operators59.filter)((paths) => paths.length > 0),
|
|
324686
324729
|
(0, import_operators59.concatMap)((paths) => (0, import_rxjs70.from)(this.notIgnored([...new Set(paths)]))),
|
|
324687
324730
|
(0, import_operators59.mergeMap)((paths) => (0, import_rxjs70.from)(paths))
|
|
324688
|
-
).subscribe(
|
|
324689
|
-
|
|
324690
|
-
|
|
324731
|
+
).subscribe(
|
|
324732
|
+
(path2) => this.events$.next({ sessionId, kind: "changed", data: path2 })
|
|
324733
|
+
);
|
|
324734
|
+
this.watches.set(sessionId, {
|
|
324691
324735
|
watcher: this.watchRoot((path2) => changed$.next(path2)),
|
|
324692
324736
|
changes
|
|
324693
324737
|
});
|
|
324694
|
-
return { sessionId
|
|
324738
|
+
return { sessionId };
|
|
324695
324739
|
}
|
|
324696
|
-
|
|
324697
|
-
this.
|
|
324698
|
-
|
|
324699
|
-
|
|
324700
|
-
|
|
324701
|
-
|
|
324702
|
-
if (session) {
|
|
324703
|
-
kill(session.child);
|
|
324704
|
-
this.forget(sessionId);
|
|
324705
|
-
}
|
|
324706
|
-
return { closed: !!session };
|
|
324740
|
+
unwatch(sessionId) {
|
|
324741
|
+
const watch3 = this.watches.get(sessionId);
|
|
324742
|
+
watch3?.watcher?.close();
|
|
324743
|
+
watch3?.changes.unsubscribe();
|
|
324744
|
+
this.watches.delete(sessionId);
|
|
324745
|
+
return { closed: !!watch3 };
|
|
324707
324746
|
}
|
|
324708
324747
|
closeAll() {
|
|
324709
324748
|
[...this.sessions.keys()].forEach((id) => this.close(id));
|
|
324710
|
-
|
|
324711
|
-
session(sessionId) {
|
|
324712
|
-
const session = this.sessions.get(sessionId);
|
|
324713
|
-
if (!session) {
|
|
324714
|
-
throw new WorkspaceError("This terminal is closed.", 404);
|
|
324715
|
-
}
|
|
324716
|
-
return session;
|
|
324749
|
+
[...this.watches.keys()].forEach((id) => this.unwatch(id));
|
|
324717
324750
|
}
|
|
324718
324751
|
forget(sessionId) {
|
|
324719
|
-
const session = this.sessions.get(sessionId);
|
|
324720
|
-
session?.watcher?.close();
|
|
324721
|
-
session?.changes.unsubscribe();
|
|
324722
324752
|
this.sessions.delete(sessionId);
|
|
324723
324753
|
}
|
|
324724
324754
|
/** Recursive watch of the root (Node >= 20 on Linux, macOS, Windows). */
|
|
@@ -324767,7 +324797,10 @@ var init_connection2 = __esm({
|
|
|
324767
324797
|
// browser terminals (--allow-terminal, plan 36)
|
|
324768
324798
|
"terminal/open",
|
|
324769
324799
|
"terminal/input",
|
|
324770
|
-
"terminal/close"
|
|
324800
|
+
"terminal/close",
|
|
324801
|
+
// the browser editor's file watch (no --allow-terminal needed)
|
|
324802
|
+
"watch/open",
|
|
324803
|
+
"watch/close"
|
|
324771
324804
|
];
|
|
324772
324805
|
HEARTBEAT_MUTATION2 = `mutation localWorkspaceHeartbeat($info: LocalWorkspaceHeartbeatInput) {
|
|
324773
324806
|
localWorkspaceHeartbeat(info: $info) { id name }
|
|
@@ -325000,6 +325033,11 @@ var init_connection2 = __esm({
|
|
|
325000
325033
|
str(args.sessionId) ?? "",
|
|
325001
325034
|
str(args.data) ?? ""
|
|
325002
325035
|
);
|
|
325036
|
+
case "watch/open":
|
|
325037
|
+
log2("\u25C9 the browser editor watches the files");
|
|
325038
|
+
return this.terminals.watch();
|
|
325039
|
+
case "watch/close":
|
|
325040
|
+
return this.terminals.unwatch(str(args.sessionId) ?? "");
|
|
325003
325041
|
case "terminal/close":
|
|
325004
325042
|
log2("\u25A3 terminal closed");
|
|
325005
325043
|
return this.terminals.close(str(args.sessionId) ?? "");
|
|
@@ -326141,7 +326179,7 @@ if (!isWebContainer) {
|
|
|
326141
326179
|
} else {
|
|
326142
326180
|
}
|
|
326143
326181
|
}
|
|
326144
|
-
var version2 = true ? "1.8.
|
|
326182
|
+
var version2 = true ? "1.8.271" : "development";
|
|
326145
326183
|
var main = (argv) => {
|
|
326146
326184
|
import_commander.program.name("gcli").version(version2);
|
|
326147
326185
|
commands.map((command) => command(import_commander.program));
|