@lethevimlet/sshift 0.9.6 → 0.9.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lethevimlet/sshift",
3
- "version": "0.9.6",
3
+ "version": "0.9.7",
4
4
  "description": "Web-based SSH + SFTP terminal client with tabs and bookmarks",
5
5
  "main": "src/server/index.js",
6
6
  "bin": {
@@ -66,6 +66,8 @@
66
66
  },
67
67
  "files": [
68
68
  "sshift",
69
+ "sshift-install.sh",
70
+ "sshift-install.ps1",
69
71
  "src/server/",
70
72
  "src/webapp/",
71
73
  "plugins/",
@@ -5,12 +5,14 @@
5
5
  * in an SSH terminal and flashes the tab to alert the user.
6
6
  *
7
7
  * Detection strategy:
8
- * - Detects opencode's TUI by looking for "OpenCode" in the terminal state
8
+ * - Detects opencode's TUI by looking for "OpenCode" in the terminal state (sticky: once detected, stays true)
9
9
  * - Tracks opencode's processing state via spinner characters (⬝ ■ ▣)
10
- * - When opencode was working (spinner active) but goes idle for > idleThreshold ms,
11
- * flashes the tab to alert the user that opencode is waiting for input
12
- * - Also detects common prompt patterns like "> ", "❯ ", "(y/n)" etc.
13
- * - Stops flashing when spinner activity resumes (opencode is busy again)
10
+ * - While opencode is working (spinner seen within idleThreshold), ALL flashing is suppressed
11
+ * - When opencode goes idle (no spinner for > idleThreshold ms after working), flashes the tab
12
+ * - Schedules an immediate attention check when spinner stops (no delay waiting for timer)
13
+ * - Detects opencode-specific prompt patterns ("❯", "> ", "(y/n)", etc.)
14
+ * - Prompt detection only activates in confirmed OpenCode sessions (isOpencode gate)
15
+ * - Suppresses re-flash for a cooldown period after spinner stops a flash
14
16
  *
15
17
  * Configuration (in config.json under plugins[].config):
16
18
  * - patterns: string[] - Additional regex patterns to detect attention
@@ -19,6 +21,7 @@
19
21
  * - excludePatterns: string[] - Regex patterns to exclude from detection
20
22
  * - checkInterval: number - Milliseconds between periodic terminal state checks (default: 2000)
21
23
  * - idleThreshold: number - Milliseconds without spinner before considered idle (default: 3000)
24
+ * - cooldownMs: number - Milliseconds to suppress re-flash after spinner stops a flash (default: 1000)
22
25
  */
23
26
 
24
27
  class OpenCodeAttentionPlugin {
@@ -29,6 +32,7 @@ class OpenCodeAttentionPlugin {
29
32
  flashDuration: config.flashDuration || 0,
30
33
  checkInterval: config.checkInterval || 2000,
31
34
  idleThreshold: config.idleThreshold || 3000,
35
+ cooldownMs: config.cooldownMs || 1000,
32
36
  ...config,
33
37
  };
34
38
 
@@ -46,17 +50,23 @@ class OpenCodeAttentionPlugin {
46
50
  isOpencode: false,
47
51
  lastSpinnerTime: 0,
48
52
  wasWorking: false,
53
+ cooldownUntil: 0,
54
+ idleCheckScheduled: false,
49
55
  });
50
56
  }
51
57
  return this._sessionState.get(sessionId);
52
58
  }
53
59
 
60
+ _isWorking(sessionId) {
61
+ const s = this._getSessionState(sessionId);
62
+ return s.wasWorking && (Date.now() - s.lastSpinnerTime) < this.config.idleThreshold;
63
+ }
64
+
54
65
  _buildPatterns(extraPatterns, excludePatterns) {
55
66
  const defaultPatterns = [
56
67
  /\> $/,
57
68
  /\> \x1b/,
58
- /❯ $/,
59
- /❯ \x1b/,
69
+ /❯ /,
60
70
  /waiting for input/i,
61
71
  /press enter/i,
62
72
  /press any key/i,
@@ -107,6 +117,9 @@ class OpenCodeAttentionPlugin {
107
117
  }
108
118
 
109
119
  _startFlash(sessionId) {
120
+ const sessionState = this._getSessionState(sessionId);
121
+ if (Date.now() < sessionState.cooldownUntil) return;
122
+ if (this._isWorking(sessionId)) return;
110
123
  if (this._flashing.get(sessionId)) return;
111
124
  this._flashing.set(sessionId, true);
112
125
  this.ctx.flashTab(sessionId, { duration: this.config.flashDuration || 0 });
@@ -129,12 +142,33 @@ class OpenCodeAttentionPlugin {
129
142
  this._dataTimers.set(sessionId, timer);
130
143
  }
131
144
 
145
+ _scheduleIdleCheck(sessionId) {
146
+ const sessionState = this._getSessionState(sessionId);
147
+ if (sessionState.idleCheckScheduled) return;
148
+ sessionState.idleCheckScheduled = true;
149
+
150
+ const delay = this.config.idleThreshold + 200;
151
+
152
+ setTimeout(() => {
153
+ sessionState.idleCheckScheduled = false;
154
+ if (!sessionState.wasWorking) return;
155
+ if (this._isWorking(sessionId)) return;
156
+ this._checkAttention(sessionId);
157
+ }, delay);
158
+ }
159
+
160
+ _isSpinnerChar(text) {
161
+ return /[⬝■▣]/.test(text);
162
+ }
163
+
132
164
  _checkAttention(sessionId) {
165
+ if (this._isWorking(sessionId)) return;
166
+
133
167
  const state = this.ctx.getTerminalState(sessionId);
134
168
  if (!state || !state.state) return;
135
169
 
136
170
  const lines = state.state.split('\n');
137
- const recentLines = lines.slice(-20);
171
+ const recentLines = lines.slice(-30);
138
172
 
139
173
  let isOpencode = false;
140
174
  let matchedPrompt = false;
@@ -149,25 +183,27 @@ class OpenCodeAttentionPlugin {
149
183
 
150
184
  if (this._matchesPattern(stripped) || this._matchesPattern(line)) {
151
185
  matchedPrompt = true;
152
- break;
153
186
  }
154
187
  }
155
188
 
156
189
  const sessionState = this._getSessionState(sessionId);
157
- sessionState.isOpencode = isOpencode;
190
+ if (isOpencode) {
191
+ sessionState.isOpencode = true;
192
+ }
193
+
194
+ if (!sessionState.isOpencode) return;
158
195
 
159
196
  if (matchedPrompt) {
160
197
  this._startFlash(sessionId);
198
+ return;
161
199
  }
162
200
 
163
- if (isOpencode && !matchedPrompt) {
164
- const now = Date.now();
165
- const timeSinceSpinner = now - sessionState.lastSpinnerTime;
201
+ const now = Date.now();
202
+ const timeSinceSpinner = now - sessionState.lastSpinnerTime;
166
203
 
167
- if (sessionState.wasWorking && timeSinceSpinner > this.config.idleThreshold) {
168
- this._startFlash(sessionId);
169
- sessionState.wasWorking = false;
170
- }
204
+ if (sessionState.wasWorking && timeSinceSpinner > this.config.idleThreshold) {
205
+ this._startFlash(sessionId);
206
+ sessionState.wasWorking = false;
171
207
  }
172
208
  }
173
209
 
@@ -175,19 +211,25 @@ class OpenCodeAttentionPlugin {
175
211
  const stripped = this._stripAnsi(data);
176
212
  const sessionState = this._getSessionState(sessionId);
177
213
 
178
- const isSpinner = /[⬝■▣]/.test(stripped) || /[⬝■▣]/.test(data);
214
+ if (/OpenCode/i.test(stripped) || /OpenCode/i.test(data)) {
215
+ sessionState.isOpencode = true;
216
+ }
217
+
218
+ const isSpinner = this._isSpinnerChar(stripped) || this._isSpinnerChar(data);
179
219
 
180
220
  if (isSpinner) {
181
221
  sessionState.lastSpinnerTime = Date.now();
182
222
  sessionState.wasWorking = true;
223
+ this._scheduleIdleCheck(sessionId);
183
224
  if (this._flashing.get(sessionId)) {
184
225
  this._stopFlash(sessionId);
226
+ sessionState.cooldownUntil = Date.now() + this.config.cooldownMs;
185
227
  }
228
+ return;
186
229
  }
187
230
 
188
- if (/OpenCode/i.test(stripped) || /OpenCode/i.test(data)) {
189
- sessionState.isOpencode = true;
190
- }
231
+ if (!sessionState.isOpencode) return;
232
+ if (this._isWorking(sessionId)) return;
191
233
 
192
234
  if (this._matchesPattern(stripped) || this._matchesPattern(data)) {
193
235
  this._startFlash(sessionId);
@@ -203,6 +245,9 @@ class OpenCodeAttentionPlugin {
203
245
  sessionState.isOpencode = true;
204
246
  }
205
247
 
248
+ if (!sessionState.isOpencode) return;
249
+ if (this._isWorking(sessionId)) return;
250
+
206
251
  if (this._matchesPattern(strippedLine) || this._matchesPattern(rawLine)) {
207
252
  this._startFlash(sessionId);
208
253
  }
@@ -232,7 +232,7 @@ async function initializeServer() {
232
232
 
233
233
  // Auth middleware - block API endpoints when password is set
234
234
  const { isValidAuthToken } = require('./endpoints/rest/auth');
235
- const AUTH_WHITELIST = ['/auth/status', '/auth/login'];
235
+ const AUTH_WHITELIST = ['/auth/status', '/auth/login', '/cert', '/security-info'];
236
236
 
237
237
  app.use('/api', (req, res, next) => {
238
238
  if (AUTH_WHITELIST.some(p => req.path === p)) return next();
@@ -1001,6 +1001,16 @@
1001
1001
  </div>
1002
1002
  <div class="modal-body">
1003
1003
  <div class="setting-group">
1004
+ <div class="setting-item" style="flex-direction: column; align-items: stretch;">
1005
+ <label class="setting-label"><i class="fas fa-info-circle"></i> Instructions</label>
1006
+ <div class="setting-description" style="font-size: 12px; line-height: 1.5;">
1007
+ <strong>Chrome/Edge (Desktop):</strong> Open <a href="chrome://settings/certificates" style="color: var(--accent-primary); word-break: break-all;">chrome://settings/certificates</a> (or <a href="edge://settings/certificates" style="color: var(--accent-primary);">edge://settings/certificates</a>) in the address bar, then import the downloaded .crt file to "Trusted Root Certification Authorities".<br><br>
1008
+ <strong>Chrome (Android):</strong> Settings > Security > Install from SD card > Select the downloaded file.<br><br>
1009
+ <strong>Firefox:</strong> Open <a href="about:preferences#privacy" style="color: var(--accent-primary);">about:preferences#privacy</a> > View Certificates > Import > Trust for identifying websites.<br><br>
1010
+ <strong>macOS/iOS:</strong> Double-click the .crt file > Add to Keychain > Set trust to "Always Trust". On iOS: Settings > General > VPN & Device Management > Install profile, then Settings > General > About > Certificate Trust Settings > Enable full trust.
1011
+ </div>
1012
+ </div>
1013
+
1004
1014
  <div id="swStatusContainer" class="setting-item" style="flex-direction: column; align-items: stretch;">
1005
1015
  <label class="setting-label"><i class="fas fa-hard-drive"></i> Service Worker</label>
1006
1016
  <div class="setting-description" id="swStatusText">
@@ -1017,16 +1027,6 @@
1017
1027
  <i class="fas fa-download"></i> Download Certificate
1018
1028
  </button>
1019
1029
  </div>
1020
-
1021
- <div class="setting-item" style="flex-direction: column; align-items: stretch;">
1022
- <label class="setting-label"><i class="fas fa-info-circle"></i> Instructions</label>
1023
- <div class="setting-description" style="font-size: 12px; line-height: 1.5;">
1024
- <strong>Chrome/Edge (Desktop):</strong> Open <a href="chrome://settings/certificates" style="color: var(--accent-primary); word-break: break-all;">chrome://settings/certificates</a> (or <a href="edge://settings/certificates" style="color: var(--accent-primary);">edge://settings/certificates</a>) in the address bar, then import the downloaded .crt file to "Trusted Root Certification Authorities".<br><br>
1025
- <strong>Chrome (Android):</strong> Settings > Security > Install from SD card > Select the downloaded file.<br><br>
1026
- <strong>Firefox:</strong> Open <a href="about:preferences#privacy" style="color: var(--accent-primary);">about:preferences#privacy</a> > View Certificates > Import > Trust for identifying websites.<br><br>
1027
- <strong>macOS/iOS:</strong> Double-click the .crt file > Add to Keychain > Set trust to "Always Trust". On iOS: Settings > General > VPN & Device Management > Install profile, then Settings > General > About > Certificate Trust Settings > Enable full trust.
1028
- </div>
1029
- </div>
1030
1030
  </div>
1031
1031
 
1032
1032
  <div class="setting-item" style="margin-top: 12px;">
@@ -4767,11 +4767,15 @@ const wheelHandler = (e) => {
4767
4767
  dontShowCheckbox.checked = stored === 'true';
4768
4768
  }
4769
4769
 
4770
- // Auto-show on startup if not dismissed
4770
+ // Auto-show on startup if not dismissed and cert not already installed
4771
4771
  const dontShow = localStorage.getItem('dontShowSecurityInfo');
4772
- if (dontShow !== 'true') {
4773
- setTimeout(() => this.openSecurityInfoDialog(), 1000);
4774
- }
4772
+ if (dontShow === 'true') return;
4773
+
4774
+ const isLocalhost = ['localhost', '127.0.0.1', '::1'].includes(window.location.hostname);
4775
+ const swActive = navigator.serviceWorker && navigator.serviceWorker.controller;
4776
+ if (isLocalhost || swActive) return;
4777
+
4778
+ setTimeout(() => this.openSecurityInfoDialog(), 1000);
4775
4779
  }
4776
4780
 
4777
4781
  openSecurityInfoDialog() {