@@ -1466,10 +1466,10 @@ index 0000000000000000000000000000000000000000..6ce56bec114a6d8daf5dd3ded945ea78
1466
1466
+ }
1467
1467
diff --git a/src/vs/server/node/channel.ts b/src/vs/server/node/channel.ts
1468
1468
new file mode 100644
1469
- index 0000000000000000000000000000000000000000..40779e80aa56d6b802d39f7170c9c94a997393ef
1469
+ index 0000000000000000000000000000000000000000..95d0d3c51e4a25a9d7d0cada90d031c79bd86380
1470
1470
--- /dev/null
1471
1471
+++ b/src/vs/server/node/channel.ts
1472
- @@ -0,0 +1,848 @@
1472
+ @@ -0,0 +1,860 @@
1473
1473
+ import { field, logger } from '@coder/logger';
1474
1474
+ import { Server } from '@coder/node-browser';
1475
1475
+ import * as os from 'os';
@@ -1893,7 +1893,12 @@ index 0000000000000000000000000000000000000000..40779e80aa56d6b802d39f7170c9c94a
1893
1893
+ private readonly maxReplayData = 10000;
1894
1894
+ private totalReplayData = 0;
1895
1895
+
1896
- + private detached = false;
1896
+ + // According to the release notes the terminals are supposed to dispose after
1897
+ + // a short timeout; in our case we'll use 48 hours so you can get them back
1898
+ + // the next day or over the weekend.
1899
+ + private disposeTimeout: NodeJS.Timeout | undefined;
1900
+ + private disposeDelay = 48 * 60 * 60 * 1000;
1901
+ +
1897
1902
+ private buffering = false;
1898
1903
+ private readonly _onEvent = new Emitter<terminal.IRemoteTerminalProcessEvent>({
1899
1904
+ // Don't bind to data until something is listening.
@@ -1907,11 +1912,15 @@ index 0000000000000000000000000000000000000000..40779e80aa56d6b802d39f7170c9c94a
1907
1912
+
1908
1913
+ // Replay stored events.
1909
1914
+ onFirstListenerDidAdd: () => {
1910
- + if (!this.detached) {
1915
+ + // We only need to replay if the terminal is being reconnected which is
1916
+ + // true if there is a dispose timeout.
1917
+ + if (typeof this.disposeTimeout !== "undefined") {
1911
1918
+ return;
1912
1919
+ }
1913
1920
+
1914
- + this.detached = false;
1921
+ + clearTimeout(this.disposeTimeout);
1922
+ + this.disposeTimeout = undefined;
1923
+ +
1915
1924
+ logger.debug('Terminal replaying', field('id', this.id));
1916
1925
+ this._onEvent.fire({
1917
1926
+ type: 'replay',
@@ -1924,10 +1933,13 @@ index 0000000000000000000000000000000000000000..40779e80aa56d6b802d39f7170c9c94a
1924
1933
+ },
1925
1934
+
1926
1935
+ onLastListenerRemove: () => {
1927
- + this.detached = true;
1928
1936
+ logger.debug('Terminal unbound', field('id', this.id));
1929
1937
+ if (!this.persist) { // Used by debug consoles.
1930
1938
+ this.dispose();
1939
+ + } else {
1940
+ + this.disposeTimeout = setTimeout(() => {
1941
+ + this.dispose();
1942
+ + }, this.disposeDelay);
1931
1943
+ }
1932
1944
+ }
1933
1945
+ });
0 commit comments