@lethevimlet/sshift 1.9.9 → 2.0.1

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/README.md CHANGED
@@ -180,6 +180,18 @@ SSHIFT uses a priority-based configuration system. Config files are searched in
180
180
  3. `config.json` `bind` setting
181
181
  4. Default: `0.0.0.0`
182
182
 
183
+ ### Secrets from a secret manager
184
+
185
+ Bookmark passwords, private keys, passphrases and the speech/LLM keys can be
186
+ `"$NAME"` references instead of values: resolved on the server right before
187
+ connecting, never stored in `config.json` and never sent to the browser. Start
188
+ sshift with those variables, e.g. through the
189
+ [sm secret manager](https://github.com/lethevimlet/secret-manager)
190
+ (`sm -c 'exec node …/sshift'` with only the needed secrets), or list your own
191
+ variables in `SSHIFT_SECRET_VARS`. Without either, every value is used literally
192
+ as before. See
193
+ [Configuration → Secrets](docs/configuration.md#secrets-from-a-secret-manager-name-references).
194
+
183
195
  See [Configuration](docs/configuration.md) for details.
184
196
 
185
197
  ## 🔒 HTTPS on Local Network (PWA / "Not Secure" Warnings)
@@ -233,11 +245,13 @@ SSHIFT includes built-in plugins that detect when AI coding tools are waiting fo
233
245
 
234
246
  ### OpenCode Attention
235
247
 
236
- Detects when [OpenCode](https://opencode.ai) is waiting for input by tracking its spinner characters (⬝ ■ ▣) and prompt patterns. When the spinner stops or a prompt appears, the tab flashes.
248
+ Detects when [OpenCode](https://opencode.ai) finishes working (its spinner and "esc interrupt" hint disappear) and flashes the tab.
237
249
 
238
250
  ### Claude Attention
239
251
 
240
- Detects when [Claude Code](https://claude.ai) is waiting for input by tracking its spinner characters (⠋⠙⠹ braille patterns, ·✢✳✶✻✽) and prompt patterns like "❯", "Do you want", "Allow", and "Esc to cancel".
252
+ Detects when [Claude Code](https://claude.ai) finishes working or shows a permission dialog ("esc to interrupt" and the spinner disappear) and flashes the tab.
253
+
254
+ A flash stops as soon as you look at the tab and does not come back until you send the next prompt in that session. Turn each one on or off in **Settings → Sessions** (or **Settings → Plugins**).
241
255
 
242
256
  ### Enabling Plugins
243
257
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lethevimlet/sshift",
3
- "version": "1.9.9",
3
+ "version": "2.0.1",
4
4
  "description": "Web-based SSH + SFTP terminal client with tabs and bookmarks",
5
5
  "main": "src/server/index.js",
6
6
  "bin": {
@@ -209,6 +209,12 @@ class ClaudeAttentionPlugin {
209
209
  agentBytes: 0, // agent-driven bytes in the rolling window
210
210
  agentWindowStart: 0,
211
211
  cooldownUntil: 0,
212
+ // Flashing is allowed only after a prompt. Seeing a flash disarms
213
+ // it; the next real keystroke in the session re-arms it. Without
214
+ // this, a TUI repaint (resize, tab switch, status refresh) looked
215
+ // like a new working episode and the tab flashed again although
216
+ // nothing was asked.
217
+ armed: true,
212
218
  });
213
219
  }
214
220
  return this._sessionState.get(sessionId);
@@ -266,6 +272,11 @@ class ClaudeAttentionPlugin {
266
272
  _startFlash(sessionId, { force = false } = {}) {
267
273
  const s = this._getSessionState(sessionId);
268
274
  const now = Date.now();
275
+ // Already seen since the last prompt: nothing new to announce.
276
+ if (!s.armed) {
277
+ s.pendingAttention = false;
278
+ return;
279
+ }
269
280
  // Suppressed for now — pendingAttention keeps it queued for a retry
270
281
  // instead of dropping the event on the floor.
271
282
  if (now < s.cooldownUntil) return;
@@ -447,8 +458,22 @@ class ClaudeAttentionPlugin {
447
458
  this._scheduleEvaluate(sessionId);
448
459
  }
449
460
 
450
- onUserInput(sessionId /*, data */) {
461
+ // True for input the user actually typed. Terminal-generated reports
462
+ // (focus in/out when the tab gains or loses focus, mouse wheel/click
463
+ // reports) are not a prompt and must not re-arm the flash.
464
+ _isTypedInput(data) {
465
+ if (typeof data !== 'string') return !!data;
466
+ const rest = data
467
+ .replace(/\x1b\[[IO]/g, '')
468
+ .replace(/\x1b\[<\d+;\d+;\d+[Mm]/g, '')
469
+ .replace(/\x1b\[M[\s\S]{3}/g, '');
470
+ return rest.length > 0;
471
+ }
472
+
473
+ onUserInput(sessionId, data) {
451
474
  const s = this._getSessionState(sessionId);
475
+ if (data !== undefined && !this._isTypedInput(data)) return;
476
+ s.armed = true;
452
477
  s.lastUserInputAt = Date.now();
453
478
  // The user is here — stop flashing and hold off for a while. The
454
479
  // current episode is dropped as well: if the agent really is working,
@@ -461,7 +486,12 @@ class ClaudeAttentionPlugin {
461
486
  }
462
487
 
463
488
  // A client reported the user is looking at this tab.
489
+ // Once the result has been seen, stay quiet until the next prompt. A tab
490
+ // viewed while the agent is still working stays armed so the finish of
491
+ // that run is still announced.
464
492
  onSessionFocus(sessionId) {
493
+ const s = this._getSessionState(sessionId);
494
+ if (!s.workEpisode) s.armed = false;
465
495
  this._stopFlash(sessionId, { cooldown: true });
466
496
  }
467
497
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-attention",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Flashes SSH tabs when Claude Code finishes working and is waiting for you (state-transition detection, no brittle prompt patterns)",
5
5
  "type": "sshift-plugin"
6
6
  }
@@ -193,6 +193,12 @@ class OpenCodeAttentionPlugin {
193
193
  agentBytes: 0, // agent-driven bytes in the rolling window
194
194
  agentWindowStart: 0,
195
195
  cooldownUntil: 0,
196
+ // Flashing is allowed only after a prompt. Seeing a flash disarms
197
+ // it; the next real keystroke in the session re-arms it. Without
198
+ // this, a TUI repaint (resize, tab switch, status refresh) looked
199
+ // like a new working episode and the tab flashed again although
200
+ // nothing was asked.
201
+ armed: true,
196
202
  });
197
203
  }
198
204
  return this._sessionState.get(sessionId);
@@ -250,6 +256,11 @@ class OpenCodeAttentionPlugin {
250
256
  _startFlash(sessionId, { force = false } = {}) {
251
257
  const s = this._getSessionState(sessionId);
252
258
  const now = Date.now();
259
+ // Already seen since the last prompt: nothing new to announce.
260
+ if (!s.armed) {
261
+ s.pendingAttention = false;
262
+ return;
263
+ }
253
264
  // Suppressed for now — pendingAttention keeps it queued for a retry
254
265
  // instead of dropping the event on the floor.
255
266
  if (now < s.cooldownUntil) return;
@@ -431,8 +442,22 @@ class OpenCodeAttentionPlugin {
431
442
  this._scheduleEvaluate(sessionId);
432
443
  }
433
444
 
434
- onUserInput(sessionId /*, data */) {
445
+ // True for input the user actually typed. Terminal-generated reports
446
+ // (focus in/out when the tab gains or loses focus, mouse wheel/click
447
+ // reports) are not a prompt and must not re-arm the flash.
448
+ _isTypedInput(data) {
449
+ if (typeof data !== 'string') return !!data;
450
+ const rest = data
451
+ .replace(/\x1b\[[IO]/g, '')
452
+ .replace(/\x1b\[<\d+;\d+;\d+[Mm]/g, '')
453
+ .replace(/\x1b\[M[\s\S]{3}/g, '');
454
+ return rest.length > 0;
455
+ }
456
+
457
+ onUserInput(sessionId, data) {
435
458
  const s = this._getSessionState(sessionId);
459
+ if (data !== undefined && !this._isTypedInput(data)) return;
460
+ s.armed = true;
436
461
  s.lastUserInputAt = Date.now();
437
462
  // The user is here — stop flashing and hold off for a while. The
438
463
  // current episode is dropped as well: if the agent really is working,
@@ -445,7 +470,12 @@ class OpenCodeAttentionPlugin {
445
470
  }
446
471
 
447
472
  // A client reported the user is looking at this tab.
473
+ // Once the result has been seen, stay quiet until the next prompt. A tab
474
+ // viewed while the agent is still working stays armed so the finish of
475
+ // that run is still announced.
448
476
  onSessionFocus(sessionId) {
477
+ const s = this._getSessionState(sessionId);
478
+ if (!s.workEpisode) s.armed = false;
449
479
  this._stopFlash(sessionId, { cooldown: true });
450
480
  }
451
481
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-attention",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Flashes SSH tabs when OpenCode finishes working and is waiting for you (state-transition detection, no brittle prompt patterns)",
5
5
  "type": "sshift-plugin"
6
6
  }
@@ -28,6 +28,7 @@ const {
28
28
  loadSpeechAiProfile,
29
29
  deleteSpeechAiProfile
30
30
  } = require('../../utils/config');
31
+ const { resolveSecret } = require('../../utils/secrets');
31
32
 
32
33
  // Use the global fetch (Node 18+) for proxying. Fall back to undici/https for
33
34
  // ancient environments — but Node >=20 is the project floor, so global fetch
@@ -289,7 +290,7 @@ async function handleSttProxy(req, res) {
289
290
  const upstream = await fetch(url, {
290
291
  method: 'POST',
291
292
  headers: {
292
- 'Authorization': `Bearer ${cfg.sttAuthKey}`,
293
+ 'Authorization': `Bearer ${resolveSecret(cfg.sttAuthKey)}`,
293
294
  'Content-Type': `multipart/form-data; boundary=${boundary}`
294
295
  },
295
296
  body,
@@ -323,7 +324,7 @@ async function handleWandProxy(req, res) {
323
324
  const upstream = await fetch(cfg.llmEndpoint, {
324
325
  method: 'POST',
325
326
  headers: {
326
- 'Authorization': `Bearer ${cfg.llmAuthKey}`,
327
+ 'Authorization': `Bearer ${resolveSecret(cfg.llmAuthKey)}`,
327
328
  'Content-Type': 'application/json'
328
329
  },
329
330
  body: JSON.stringify({
@@ -12,6 +12,10 @@ if (typeof util.isDate !== 'function') {
12
12
  util.isDate = (d) => d instanceof Date;
13
13
  }
14
14
 
15
+ // Secrets injected by the sm secret manager: move them out of process.env into
16
+ // memory before anything else runs, so no child process inherits them.
17
+ require('./utils/secrets').captureSecretsFromEnv();
18
+
15
19
  // Load environment variables from .env files
16
20
  require('./utils/env-loader');
17
21
 
@@ -1,5 +1,6 @@
1
1
  const { Client } = require('ssh2');
2
2
  const { convertKeyIfNeeded } = require('../utils/key-converter');
3
+ const { resolveConnectionSecrets } = require('../utils/secrets');
3
4
  const { removeTab } = require('../utils/tab-manager');
4
5
 
5
6
  class SFTPManager {
@@ -10,6 +11,8 @@ class SFTPManager {
10
11
  }
11
12
 
12
13
  async connect(socket, options) {
14
+ // "$NAME" credentials (sm secret manager) are resolved here, server-side only.
15
+ options = resolveConnectionSecrets(options);
13
16
  // Pre-process private key (auto-convert PPK to OpenSSH format)
14
17
  if (options.privateKey && options.privateKey.length > 0) {
15
18
  try {
@@ -9,6 +9,7 @@ const SYNC_SCROLLBACK_TIERS = [2000, 500, 100, 0];
9
9
  const { Unicode11Addon } = require('@xterm/addon-unicode11');
10
10
  const pluginManager = require('../plugins/plugin-manager');
11
11
  const { convertKeyIfNeeded } = require('../utils/key-converter');
12
+ const { resolveConnectionSecrets } = require('../utils/secrets');
12
13
  const { removeTab } = require('../utils/tab-manager');
13
14
 
14
15
  class SSHManager {
@@ -27,6 +28,8 @@ class SSHManager {
27
28
  }
28
29
 
29
30
  async connect(socket, options) {
31
+ // "$NAME" credentials (sm secret manager) are resolved here, server-side only.
32
+ options = resolveConnectionSecrets(options);
30
33
  // Pre-process private key (auto-convert PPK to OpenSSH format)
31
34
  if (options.privateKey && options.privateKey.length > 0) {
32
35
  try {
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Secrets from the sm secret manager (https://github.com/lethevimlet/secret-manager).
3
+ *
4
+ * Bookmark credentials (password, privateKey, passphrase) and the speech/LLM
5
+ * auth keys may be references of the form "$NAME" instead of the value. They
6
+ * are resolved only on the server, right before an SSH/SFTP connection or an
7
+ * upstream request, so the value is never stored in config.json and never sent
8
+ * to the browser (which only ever sees "$NAME").
9
+ *
10
+ * Only names that were declared as secrets are references: the variables sm
11
+ * lists in __SM_SECRET_VARS, plus an optional space-separated SSHIFT_SECRET_VARS
12
+ * for setups without sm. Every other value, including a real password that
13
+ * happens to start with "$" (e.g. "$ecretPass1" or "$HOME"), is used literally,
14
+ * exactly as before. Without sm nothing changes.
15
+ *
16
+ * Run sshift through sm with only the needed secrets, e.g. in the systemd unit
17
+ * Environment=SM_AUTO_ENV=0
18
+ * Environment=LEVISTATION_PASSWORD={{secret:LEVISTATION_PASSWORD}}
19
+ * ExecStart=/usr/local/bin/sm -c 'exec node …/sshift'
20
+ * At startup captureSecretsFromEnv() moves them out of process.env into memory,
21
+ * so nothing sshift starts (key converter, updater, plugins) inherits them.
22
+ */
23
+
24
+ const SECRET_REF = /^\$([A-Za-z_][A-Za-z0-9_]*)$/;
25
+ const captured = new Map();
26
+
27
+ /**
28
+ * Move every variable sm reports in __SM_SECRET_VARS from the environment into
29
+ * memory, and drop sm's own markers. Returns the number of captured secrets.
30
+ */
31
+ function captureSecretsFromEnv(env = process.env) {
32
+ const names = `${env.__SM_SECRET_VARS || ''} ${env.SSHIFT_SECRET_VARS || ''}`.split(/\s+/).filter(Boolean);
33
+ for (const name of names) {
34
+ if (env[name] !== undefined) {
35
+ captured.set(name, env[name]);
36
+ delete env[name];
37
+ }
38
+ }
39
+ delete env.__SM_SECRET_VARS;
40
+ delete env.SSHIFT_SECRET_VARS;
41
+ delete env.SM_ACTIVE;
42
+ if (env.BASH_ENV && /sm-agents\.bash$/.test(env.BASH_ENV)) {
43
+ if (env.__SM_USER_BASH_ENV) env.BASH_ENV = env.__SM_USER_BASH_ENV;
44
+ else delete env.BASH_ENV;
45
+ }
46
+ delete env.__SM_USER_BASH_ENV;
47
+ return names.length;
48
+ }
49
+
50
+ /** True only for "$NAME" where NAME was declared as a secret at startup. */
51
+ function isSecretRef(value) {
52
+ const m = typeof value === 'string' && SECRET_REF.exec(value);
53
+ return Boolean(m) && captured.has(m[1]);
54
+ }
55
+
56
+ /**
57
+ * "$NAME" of a declared secret -> its value. Anything else, including "$WORD"
58
+ * values that aren't declared secrets, is returned unchanged.
59
+ */
60
+ function resolveSecret(value) {
61
+ return isSecretRef(value) ? captured.get(SECRET_REF.exec(value)[1]) : value;
62
+ }
63
+
64
+ /**
65
+ * Like resolveSecret, but a reference that can't be resolved is an error with
66
+ * a clear message instead of an empty credential.
67
+ */
68
+ function resolveSecretStrict(value, what = 'secret') {
69
+ const resolved = resolveSecret(value);
70
+ if (isSecretRef(value) && !resolved) {
71
+ throw new Error(`${what} ${value} is empty: check the secret ${value.slice(1)} in sm`);
72
+ }
73
+ return resolved;
74
+ }
75
+
76
+ /** Resolve the credential fields of SSH/SFTP connection options. */
77
+ function resolveConnectionSecrets(options) {
78
+ const out = { ...options };
79
+ for (const field of ['password', 'privateKey', 'passphrase']) {
80
+ if (isSecretRef(out[field])) out[field] = resolveSecretStrict(out[field], field);
81
+ }
82
+ return out;
83
+ }
84
+
85
+ module.exports = { SECRET_REF, captureSecretsFromEnv, isSecretRef, resolveSecret, resolveSecretStrict, resolveConnectionSecrets, _captured: captured };
@@ -893,6 +893,34 @@
893
893
  </label>
894
894
  </div>
895
895
  </div>
896
+ <div class="setting-item">
897
+ <label class="setting-label">
898
+ <i class="fas fa-bell"></i> Flash Tab When Claude Code Waits
899
+ </label>
900
+ <div class="setting-description">
901
+ Flash the tab when Claude Code finishes working and waits for your input. A flash stops when you look at the tab and does not come back until you send the next prompt.
902
+ </div>
903
+ <div class="setting-control">
904
+ <label class="toggle-switch">
905
+ <input type="checkbox" class="attention-plugin-toggle" id="claudeAttentionToggle" data-plugin="claude-attention">
906
+ <span class="toggle-slider"></span>
907
+ </label>
908
+ </div>
909
+ </div>
910
+ <div class="setting-item">
911
+ <label class="setting-label">
912
+ <i class="fas fa-bell"></i> Flash Tab When OpenCode Waits
913
+ </label>
914
+ <div class="setting-description">
915
+ Flash the tab when OpenCode finishes working and waits for your input. A flash stops when you look at the tab and does not come back until you send the next prompt.
916
+ </div>
917
+ <div class="setting-control">
918
+ <label class="toggle-switch">
919
+ <input type="checkbox" class="attention-plugin-toggle" id="opencodeAttentionToggle" data-plugin="opencode-attention">
920
+ <span class="toggle-slider"></span>
921
+ </label>
922
+ </div>
923
+ </div>
896
924
  </div>
897
925
 
898
926
  <div class="settings-category" id="settings-category-terminal" style="display:none;">
@@ -8048,12 +8048,40 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
8048
8048
  this.togglePlugin(pluginName, enabled, e.target);
8049
8049
  });
8050
8050
  });
8051
+ this._syncAttentionToggles(plugins);
8051
8052
  } catch (err) {
8052
8053
  console.error('[SSHIFT] Error loading plugins:', err);
8053
8054
  pluginsList.innerHTML = '<div class="plugins-loading">Failed to load plugins</div>';
8054
8055
  }
8055
8056
  }
8056
8057
 
8058
+ // Settings → Sessions has its own switches for the two tab-flash plugins
8059
+ // (the same setting as their cards in Settings → Plugins). They reflect
8060
+ // the plugin list and stay hidden for a plugin the server doesn't have.
8061
+ _syncAttentionToggles(plugins) {
8062
+ document.querySelectorAll('.attention-plugin-toggle').forEach(toggle => {
8063
+ const plugin = Array.isArray(plugins)
8064
+ ? plugins.find(p => p.name === toggle.dataset.plugin && !p.missing)
8065
+ : null;
8066
+ const item = toggle.closest('.setting-item');
8067
+ if (item) item.style.display = plugin ? '' : 'none';
8068
+ toggle.checked = !!(plugin && plugin.enabled);
8069
+ if (!toggle._attentionBound) {
8070
+ toggle._attentionBound = true;
8071
+ toggle.addEventListener('change', (e) => {
8072
+ this.togglePlugin(e.target.dataset.plugin, e.target.checked, e.target);
8073
+ });
8074
+ }
8075
+ });
8076
+ }
8077
+
8078
+ // Keep every switch for one plugin (Sessions + Plugins cards) in step.
8079
+ _setPluginToggleState(name, enabled) {
8080
+ document.querySelectorAll('.plugin-toggle, .attention-plugin-toggle').forEach(toggle => {
8081
+ if (toggle.dataset.plugin === name) toggle.checked = enabled;
8082
+ });
8083
+ }
8084
+
8057
8085
  async togglePlugin(name, enabled, toggleEl) {
8058
8086
  try {
8059
8087
  const headers = { 'Content-Type': 'application/json' };
@@ -8065,15 +8093,16 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
8065
8093
  });
8066
8094
 
8067
8095
  if (!response.ok) {
8068
- toggleEl.checked = !enabled;
8096
+ this._setPluginToggleState(name, !enabled);
8069
8097
  this.showToast('Failed to update plugin', 'error');
8070
8098
  return;
8071
8099
  }
8072
8100
 
8101
+ this._setPluginToggleState(name, enabled);
8073
8102
  this.showToast(`Plugin "${name}" ${enabled ? 'enabled' : 'disabled'}`, 'success');
8074
8103
  } catch (err) {
8075
8104
  console.error('[SSHIFT] Error toggling plugin:', err);
8076
- toggleEl.checked = !enabled;
8105
+ this._setPluginToggleState(name, !enabled);
8077
8106
  this.showToast('Failed to update plugin', 'error');
8078
8107
  }
8079
8108
  }
@@ -13787,24 +13816,53 @@ async syncTabsFromServer(...args) {
13787
13816
  this._armDisconnectToast();
13788
13817
  return;
13789
13818
  }
13819
+ const engine = socket.io && socket.io.engine;
13820
+ // "Connected" on top of a transport that is already closing or closed
13821
+ // is dead: nothing will ever arrive on it.
13822
+ if (engine && engine.readyState !== 'open') {
13823
+ this._forceReconnect(reason + ', transport ' + engine.readyState);
13824
+ return;
13825
+ }
13790
13826
  // Connected on paper: prove it. Throttled unless this is a real wake.
13791
13827
  const now = Date.now();
13792
13828
  if (this._probeInFlight) return;
13793
13829
  if (!force && this._lastProbeAt && now - this._lastProbeAt < 15000) return;
13794
13830
  this._lastProbeAt = now;
13795
13831
  this._probeInFlight = true;
13796
- const engine = socket.io && socket.io.engine;
13797
13832
  socket.timeout(this.PROBE_TIMEOUT_MS).emit('sshift-ping', (err) => {
13798
13833
  this._probeInFlight = false;
13799
13834
  if (!err) return;
13800
13835
  // Only tear down the transport the probe was sent on.
13801
13836
  if (socket.connected && socket.io && socket.io.engine === engine) {
13802
- console.warn('[SSHIFT] Connection probe timed out (' + reason + '), reconnecting');
13803
- try { engine.close(); } catch (_) {}
13837
+ this._forceReconnect('probe timed out, ' + reason);
13804
13838
  }
13805
13839
  });
13806
13840
  }
13807
13841
 
13842
+ /**
13843
+ * Drop the current connection and dial a new one, without relying on the
13844
+ * dead transport to cooperate. engine.close() alone is NOT enough: with
13845
+ * packets queued (the probe itself, keystrokes typed after waking) it
13846
+ * waits for a "drain" that a dead socket never emits, leaving the engine
13847
+ * stuck in "closing" — the socket then claims to be connected forever and
13848
+ * every later probe is silently dropped (v1.9.9 bug: wake was detected but
13849
+ * the page only recovered with F5). socket.disconnect() closes the
13850
+ * manager regardless of the engine, and connect() opens a new engine.
13851
+ */
13852
+ _forceReconnect(reason) {
13853
+ const socket = this.socket;
13854
+ if (!socket) return;
13855
+ console.warn('[SSHIFT] Forcing a new connection (' + reason + ')');
13856
+ const engine = socket.io && socket.io.engine;
13857
+ this._lastKickAt = Date.now();
13858
+ this._probeInFlight = false;
13859
+ try { socket.disconnect(); } catch (_) {}
13860
+ // Make sure the old transport is really gone (no stray events/timers).
13861
+ try { if (engine && engine.transport) engine.transport.close(); } catch (_) {}
13862
+ socket.connect();
13863
+ this._armDisconnectToast();
13864
+ }
13865
+
13808
13866
  _cancelDisconnectToast() {
13809
13867
  if (this._disconnectToastTimer) {
13810
13868
  clearTimeout(this._disconnectToastTimer);