@gapi/gcli 1.8.270 → 1.8.271
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.
|
@@ -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
|
@@ -324642,7 +324642,10 @@ var init_terminals = __esm({
|
|
|
324642
324642
|
this.env = env;
|
|
324643
324643
|
this.notIgnored = notIgnored;
|
|
324644
324644
|
this.events$ = new import_rxjs70.Subject();
|
|
324645
|
+
/** shells (`terminal/*`) */
|
|
324645
324646
|
this.sessions = /* @__PURE__ */ new Map();
|
|
324647
|
+
/** file watches (`watch/*`) - the open editor, terminal or not */
|
|
324648
|
+
this.watches = /* @__PURE__ */ new Map();
|
|
324646
324649
|
}
|
|
324647
324650
|
open(size) {
|
|
324648
324651
|
if (this.sessions.size >= MAX_SESSIONS) {
|
|
@@ -324679,46 +324682,66 @@ var init_terminals = __esm({
|
|
|
324679
324682
|
${e2.message}\r
|
|
324680
324683
|
` })
|
|
324681
324684
|
);
|
|
324685
|
+
this.sessions.set(sessionId, child);
|
|
324686
|
+
return { sessionId, pty: command === "script" };
|
|
324687
|
+
}
|
|
324688
|
+
input(sessionId, data) {
|
|
324689
|
+
const child = this.sessions.get(sessionId);
|
|
324690
|
+
if (!child) {
|
|
324691
|
+
throw new WorkspaceError("This terminal is closed.", 404);
|
|
324692
|
+
}
|
|
324693
|
+
child.stdin?.write(data);
|
|
324694
|
+
return { written: data.length };
|
|
324695
|
+
}
|
|
324696
|
+
close(sessionId) {
|
|
324697
|
+
const child = this.sessions.get(sessionId);
|
|
324698
|
+
if (child) {
|
|
324699
|
+
kill(child);
|
|
324700
|
+
this.forget(sessionId);
|
|
324701
|
+
}
|
|
324702
|
+
return { closed: !!child };
|
|
324703
|
+
}
|
|
324704
|
+
/**
|
|
324705
|
+
* Watch the root for the browser editor (no shell, no --allow-terminal:
|
|
324706
|
+
* only the names of changed files, which `list` shows anyway). Changes
|
|
324707
|
+
* are batched, de-duplicated and `.gitignore`d ones dropped, then sent as
|
|
324708
|
+
* `changed` events of this watch.
|
|
324709
|
+
*/
|
|
324710
|
+
watch() {
|
|
324711
|
+
if (this.watches.size >= MAX_SESSIONS) {
|
|
324712
|
+
throw new WorkspaceError(
|
|
324713
|
+
`At most ${MAX_SESSIONS} editors watching at a time.`,
|
|
324714
|
+
429
|
|
324715
|
+
);
|
|
324716
|
+
}
|
|
324717
|
+
const sessionId = (0, import_crypto3.randomUUID)();
|
|
324682
324718
|
const changed$ = new import_rxjs70.Subject();
|
|
324683
324719
|
const changes = changed$.pipe(
|
|
324684
324720
|
(0, import_operators59.bufferTime)(WATCH_BATCH_MS),
|
|
324685
324721
|
(0, import_operators59.filter)((paths) => paths.length > 0),
|
|
324686
324722
|
(0, import_operators59.concatMap)((paths) => (0, import_rxjs70.from)(this.notIgnored([...new Set(paths)]))),
|
|
324687
324723
|
(0, import_operators59.mergeMap)((paths) => (0, import_rxjs70.from)(paths))
|
|
324688
|
-
).subscribe(
|
|
324689
|
-
|
|
324690
|
-
|
|
324724
|
+
).subscribe(
|
|
324725
|
+
(path2) => this.events$.next({ sessionId, kind: "changed", data: path2 })
|
|
324726
|
+
);
|
|
324727
|
+
this.watches.set(sessionId, {
|
|
324691
324728
|
watcher: this.watchRoot((path2) => changed$.next(path2)),
|
|
324692
324729
|
changes
|
|
324693
324730
|
});
|
|
324694
|
-
return { sessionId
|
|
324731
|
+
return { sessionId };
|
|
324695
324732
|
}
|
|
324696
|
-
|
|
324697
|
-
this.
|
|
324698
|
-
|
|
324699
|
-
|
|
324700
|
-
|
|
324701
|
-
|
|
324702
|
-
if (session) {
|
|
324703
|
-
kill(session.child);
|
|
324704
|
-
this.forget(sessionId);
|
|
324705
|
-
}
|
|
324706
|
-
return { closed: !!session };
|
|
324733
|
+
unwatch(sessionId) {
|
|
324734
|
+
const watch3 = this.watches.get(sessionId);
|
|
324735
|
+
watch3?.watcher?.close();
|
|
324736
|
+
watch3?.changes.unsubscribe();
|
|
324737
|
+
this.watches.delete(sessionId);
|
|
324738
|
+
return { closed: !!watch3 };
|
|
324707
324739
|
}
|
|
324708
324740
|
closeAll() {
|
|
324709
324741
|
[...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;
|
|
324742
|
+
[...this.watches.keys()].forEach((id) => this.unwatch(id));
|
|
324717
324743
|
}
|
|
324718
324744
|
forget(sessionId) {
|
|
324719
|
-
const session = this.sessions.get(sessionId);
|
|
324720
|
-
session?.watcher?.close();
|
|
324721
|
-
session?.changes.unsubscribe();
|
|
324722
324745
|
this.sessions.delete(sessionId);
|
|
324723
324746
|
}
|
|
324724
324747
|
/** Recursive watch of the root (Node >= 20 on Linux, macOS, Windows). */
|
|
@@ -324767,7 +324790,10 @@ var init_connection2 = __esm({
|
|
|
324767
324790
|
// browser terminals (--allow-terminal, plan 36)
|
|
324768
324791
|
"terminal/open",
|
|
324769
324792
|
"terminal/input",
|
|
324770
|
-
"terminal/close"
|
|
324793
|
+
"terminal/close",
|
|
324794
|
+
// the browser editor's file watch (no --allow-terminal needed)
|
|
324795
|
+
"watch/open",
|
|
324796
|
+
"watch/close"
|
|
324771
324797
|
];
|
|
324772
324798
|
HEARTBEAT_MUTATION2 = `mutation localWorkspaceHeartbeat($info: LocalWorkspaceHeartbeatInput) {
|
|
324773
324799
|
localWorkspaceHeartbeat(info: $info) { id name }
|
|
@@ -325000,6 +325026,11 @@ var init_connection2 = __esm({
|
|
|
325000
325026
|
str(args.sessionId) ?? "",
|
|
325001
325027
|
str(args.data) ?? ""
|
|
325002
325028
|
);
|
|
325029
|
+
case "watch/open":
|
|
325030
|
+
log2("\u25C9 the browser editor watches the files");
|
|
325031
|
+
return this.terminals.watch();
|
|
325032
|
+
case "watch/close":
|
|
325033
|
+
return this.terminals.unwatch(str(args.sessionId) ?? "");
|
|
325003
325034
|
case "terminal/close":
|
|
325004
325035
|
log2("\u25A3 terminal closed");
|
|
325005
325036
|
return this.terminals.close(str(args.sessionId) ?? "");
|
|
@@ -326141,7 +326172,7 @@ if (!isWebContainer) {
|
|
|
326141
326172
|
} else {
|
|
326142
326173
|
}
|
|
326143
326174
|
}
|
|
326144
|
-
var version2 = true ? "1.8.
|
|
326175
|
+
var version2 = true ? "1.8.270" : "development";
|
|
326145
326176
|
var main = (argv) => {
|
|
326146
326177
|
import_commander.program.name("gcli").version(version2);
|
|
326147
326178
|
commands.map((command) => command(import_commander.program));
|