@@ -1466,10 +1466,10 @@ index 0000000000000000000000000000000000000000..6ce56bec114a6d8daf5dd3ded945ea78
14661466+ }
14671467diff --git a/src/vs/server/node/channel.ts b/src/vs/server/node/channel.ts
14681468new file mode 100644
1469- index 0000000000000000000000000000000000000000..40779e80aa56d6b802d39f7170c9c94a997393ef
1469+ index 0000000000000000000000000000000000000000..95d0d3c51e4a25a9d7d0cada90d031c79bd86380
14701470--- /dev/null
14711471+++ b/src/vs/server/node/channel.ts
1472- @@ -0,0 +1,848 @@
1472+ @@ -0,0 +1,860 @@
14731473+ import { field, logger } from '@coder/logger';
14741474+ import { Server } from '@coder/node-browser';
14751475+ import * as os from 'os';
@@ -1893,7 +1893,12 @@ index 0000000000000000000000000000000000000000..40779e80aa56d6b802d39f7170c9c94a
18931893+ private readonly maxReplayData = 10000;
18941894+ private totalReplayData = 0;
18951895+
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+ +
18971902+ private buffering = false;
18981903+ private readonly _onEvent = new Emitter<terminal.IRemoteTerminalProcessEvent>({
18991904+ // Don't bind to data until something is listening.
@@ -1907,11 +1912,15 @@ index 0000000000000000000000000000000000000000..40779e80aa56d6b802d39f7170c9c94a
19071912+
19081913+ // Replay stored events.
19091914+ 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") {
19111918+ return;
19121919+ }
19131920+
1914- + this.detached = false;
1921+ + clearTimeout(this.disposeTimeout);
1922+ + this.disposeTimeout = undefined;
1923+ +
19151924+ logger.debug('Terminal replaying', field('id', this.id));
19161925+ this._onEvent.fire({
19171926+ type: 'replay',
@@ -1924,10 +1933,13 @@ index 0000000000000000000000000000000000000000..40779e80aa56d6b802d39f7170c9c94a
19241933+ },
19251934+
19261935+ onLastListenerRemove: () => {
1927- + this.detached = true;
19281936+ logger.debug('Terminal unbound', field('id', this.id));
19291937+ if (!this.persist) { // Used by debug consoles.
19301938+ this.dispose();
1939+ + } else {
1940+ + this.disposeTimeout = setTimeout(() => {
1941+ + this.dispose();
1942+ + }, this.disposeDelay);
19311943+ }
19321944+ }
19331945+ });
0 commit comments