@@ -1586,10 +1586,10 @@ index 0000000000000000000000000000000000000000..c8a613ac2db1ff154a49aa7b6da5f7d2
1586
1586
+ }
1587
1587
diff --git a/src/vs/server/node/channel.ts b/src/vs/server/node/channel.ts
1588
1588
new file mode 100644
1589
- index 0000000000000000000000000000000000000000..4827b2da780b66e6dfd65c2a2f1c938cb23f6c26
1589
+ index 0000000000000000000000000000000000000000..a6c1f9f848f441b761397ba78e2fef60329b56fa
1590
1590
--- /dev/null
1591
1591
+++ b/src/vs/server/node/channel.ts
1592
- @@ -0,0 +1,897 @@
1592
+ @@ -0,0 +1,906 @@
1593
1593
+ import { field, logger } from '@coder/logger';
1594
1594
+ import { Server } from '@coder/node-browser';
1595
1595
+ import * as os from 'os';
@@ -2028,6 +2028,9 @@ index 0000000000000000000000000000000000000000..4827b2da780b66e6dfd65c2a2f1c938c
2028
2028
+ private readonly _onDispose = new Emitter<void>();
2029
2029
+ public get onDispose(): Event<void> { return this._onDispose.event; }
2030
2030
+
2031
+ + private _isOrphan = true;
2032
+ + public get isOrphan(): boolean { return this._isOrphan; }
2033
+ +
2031
2034
+ // These are replayed when a client reconnects.
2032
2035
+ private cols: number;
2033
2036
+ private rows: number;
@@ -2047,6 +2050,7 @@ index 0000000000000000000000000000000000000000..4827b2da780b66e6dfd65c2a2f1c938c
2047
2050
+ // Don't bind to data until something is listening.
2048
2051
+ onFirstListenerAdd: () => {
2049
2052
+ logger.debug('Terminal bound', field('id', this.id));
2053
+ + this._isOrphan = false;
2050
2054
+ if (!this.buffering) {
2051
2055
+ this.buffering = true;
2052
2056
+ this.bufferer.startBuffering(this.id, this.process.onProcessData);
@@ -2077,6 +2081,7 @@ index 0000000000000000000000000000000000000000..4827b2da780b66e6dfd65c2a2f1c938c
2077
2081
+
2078
2082
+ onLastListenerRemove: () => {
2079
2083
+ logger.debug('Terminal unbound', field('id', this.id));
2084
+ + this._isOrphan = true;
2080
2085
+ if (!this.persist) { // Used by debug consoles.
2081
2086
+ this.dispose();
2082
2087
+ } else {
@@ -2469,7 +2474,7 @@ index 0000000000000000000000000000000000000000..4827b2da780b66e6dfd65c2a2f1c938c
2469
2474
+ // behavior when first listing terminals but I don't know what you'd want to
2470
2475
+ // do differently. Maybe it's to reset the terminal dispose timeouts or
2471
2476
+ // something like that, but why not do it each time you list?
2472
- + return Promise.all(Array.from(this.terminals).map(async ([id, terminal]) => {
2477
+ + const terminals = await Promise.all(Array.from(this.terminals).map(async ([id, terminal]) => {
2473
2478
+ const cwd = await terminal.getCwd();
2474
2479
+ return {
2475
2480
+ id,
@@ -2478,8 +2483,12 @@ index 0000000000000000000000000000000000000000..4827b2da780b66e6dfd65c2a2f1c938c
2478
2483
+ cwd,
2479
2484
+ workspaceId: terminal.workspaceId,
2480
2485
+ workspaceName: terminal.workspaceName,
2486
+ + isOrphan: terminal.isOrphan,
2481
2487
+ };
2482
2488
+ }));
2489
+ + // Only returned orphaned terminals so we don't end up attaching to
2490
+ + // terminals already attached elsewhere.
2491
+ + return terminals.filter((t) => t.isOrphan);
2483
2492
+ }
2484
2493
+ }
2485
2494
+
0 commit comments