@lethevimlet/sshift 0.6.0 β 0.9.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 +104 -9
- package/example.config.json +20 -0
- package/package.json +2 -1
- package/plugins/claude-attention/index.js +296 -0
- package/plugins/claude-attention/package.json +6 -0
- package/plugins/opencode-attention/index.js +248 -0
- package/plugins/opencode-attention/package.json +6 -0
- package/src/server/index.js +39 -1
- package/src/server/plugins/plugin-manager.js +256 -0
- package/src/server/services/ssh-manager.js +14 -0
- package/src/server/utils/config.js +23 -0
- package/src/webapp/css/style.css +138 -0
- package/src/webapp/js/app.js +255 -72
package/README.md
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
# SSHIFT - Web-based SSH
|
|
1
|
+
# SSHIFT - Web-based SSH/SFTP Terminal Client for the AI Stack
|
|
2
2
|
|
|
3
3
|
[](https://lethevimlet.github.io/sshift/)
|
|
4
4
|
[](https://www.npmjs.com/package/@lethevimlet/sshift)
|
|
5
5
|
[](https://github.com/lethevimlet/sshift/pkgs/container/sshift)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
|
-
A modern, responsive web-based SSH and SFTP terminal client built with Node.js, Express, and xterm.js.
|
|
8
|
+
A modern, responsive web-based SSH and SFTP terminal client built with Node.js, Express, and xterm.js. Designed for the AI coding workflow β featuring tab flash notifications that alert you when AI tools like OpenCode or Claude are waiting for your input, so you never miss a prompt while multitasking. Also features excellent TUI support, tabbed sessions, bookmarks, and mobile-friendly design.
|
|
9
9
|
|
|
10
10
|

|
|
11
11
|
|
|
12
12
|
## πΈ Screenshots
|
|
13
13
|
|
|
14
14
|
<div align="center">
|
|
15
|
-
<img src="media/
|
|
16
|
-
<img src="media/
|
|
15
|
+
<img src="media/desktop_light.png" alt="SSHIFT Desktop (Light)" width="45%">
|
|
16
|
+
<img src="media/desktop_dark.png" alt="SSHIFT Desktop (Dark)" width="45%">
|
|
17
|
+
</div>
|
|
18
|
+
<br>
|
|
19
|
+
<div align="center">
|
|
20
|
+
<img src="media/mobile.png" alt="SSHIFT Mobile" width="30%">
|
|
17
21
|
</div>
|
|
18
22
|
|
|
19
23
|
## β¨ Features
|
|
20
24
|
|
|
21
25
|
- π **SSH Terminal** - Full xterm.js emulation with TUI support (vim, nano, htop, tmux)
|
|
22
26
|
- π **SFTP Browser** - File manager interface with upload/download
|
|
27
|
+
- π€ **AI Attention Alerts** - Tab flash notifications when AI tools (OpenCode, Claude) need your input
|
|
23
28
|
- ποΈ **Tabbed Interface** - Multiple concurrent sessions
|
|
24
29
|
- π **Bookmarks** - Save connection details for quick access
|
|
25
30
|
- π **Password Protection** - Optional password lock for app access
|
|
@@ -45,6 +50,7 @@ Full documentation is available at [GitHub Pages](https://lethevimlet.github.io/
|
|
|
45
50
|
- **[Installation](docs/installation.md)** - Detailed installation options
|
|
46
51
|
- **[Docker](docs/docker.md)** - Docker deployment and usage
|
|
47
52
|
- **[Configuration](docs/configuration.md)** - Configuration files and options
|
|
53
|
+
- **[Plugins](docs/configuration.md#plugins)** - AI attention alerts and plugin system
|
|
48
54
|
- **[API Reference](docs/api-reference.md)** - Socket.IO events and API
|
|
49
55
|
- **[Testing](docs/testing.md)** - Running and writing tests
|
|
50
56
|
- **[Contributing](docs/contributing.md)** - How to contribute
|
|
@@ -107,15 +113,104 @@ npm start
|
|
|
107
113
|
|
|
108
114
|
## βοΈ Configuration
|
|
109
115
|
|
|
110
|
-
SSHIFT uses a priority-based configuration system
|
|
116
|
+
SSHIFT uses a priority-based configuration system. Config files are searched in order; the first match wins.
|
|
117
|
+
|
|
118
|
+
### Config File Search (first match wins)
|
|
119
|
+
|
|
120
|
+
| Priority | Path | Notes |
|
|
121
|
+
|----------|------|-------|
|
|
122
|
+
| 1 | `~/.local/share/sshift/.env/config.json` | Primary user install location |
|
|
123
|
+
| 2 | `~/.local/share/bin/.env/config.json` | Alternative install location |
|
|
124
|
+
| 3 | `~/.local/share/sshift/config.json` | User install (no `.env` subdir) |
|
|
125
|
+
| 4 | `~/.local/share/bin/config.json` | Alternative location (no `.env` subdir) |
|
|
126
|
+
| 5 | `<PACKAGE_DIR>/.env/config.json` | NPM package directory |
|
|
127
|
+
| 6 | `<PACKAGE_DIR>/config.json` | NPM package root (fallback) |
|
|
128
|
+
|
|
129
|
+
### Port Priority
|
|
130
|
+
|
|
131
|
+
1. `--port` CLI argument (highest priority)
|
|
132
|
+
2. `PORT` environment variable
|
|
133
|
+
3. `config.json` `devPort` (when `NODE_ENV=development` or `--dev`)
|
|
134
|
+
4. `config.json` `port` (production)
|
|
135
|
+
5. Default: 8022 (production), 3000 (development)
|
|
136
|
+
|
|
137
|
+
### Bind Address Priority
|
|
111
138
|
|
|
112
|
-
1.
|
|
113
|
-
2.
|
|
114
|
-
3.
|
|
115
|
-
4. `
|
|
139
|
+
1. `--bind` CLI argument
|
|
140
|
+
2. `BIND` environment variable
|
|
141
|
+
3. `config.json` `bind` setting
|
|
142
|
+
4. Default: `0.0.0.0`
|
|
116
143
|
|
|
117
144
|
See [Configuration](docs/configuration.md) for details.
|
|
118
145
|
|
|
146
|
+
## π HTTPS on Local Network (PWA / "Not Secure" Warnings)
|
|
147
|
+
|
|
148
|
+
When accessing sshift from a LAN IP (e.g., `https://192.168.1.50:8022`), browsers show "Not Secure" warnings because the self-signed certificate is untrusted. This also blocks PWA installation.
|
|
149
|
+
|
|
150
|
+
### Quick Fix: Chrome Flag
|
|
151
|
+
|
|
152
|
+
1. Go to `chrome://flags/#unsafely-treat-insecure-origin-as-secure`
|
|
153
|
+
2. Enter your LAN URL: `https://192.168.1.50:8022`
|
|
154
|
+
3. Set to **Enabled** β **Relaunch**
|
|
155
|
+
|
|
156
|
+
### Permanent: Custom Trusted Certificate
|
|
157
|
+
|
|
158
|
+
Generate a cert for your LAN IP and configure sshift to use it:
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
{
|
|
162
|
+
"enableHttps": true,
|
|
163
|
+
"certPath": "/path/to/sshift-lan-cert.pem",
|
|
164
|
+
"keyPath": "/path/to/sshift-lan-key.pem"
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Then add the certificate to your device's trusted root store. See [Configuration > HTTPS on Local Network](docs/configuration.md) for full instructions including nginx reverse proxy and mDNS options.
|
|
169
|
+
|
|
170
|
+
## π€ AI Attention Plugins
|
|
171
|
+
|
|
172
|
+
SSHIFT includes built-in plugins that detect when AI coding tools are waiting for user input and flash the browser tab to get your attention β perfect for when you're multitasking across tabs.
|
|
173
|
+
|
|
174
|
+
### OpenCode Attention
|
|
175
|
+
|
|
176
|
+
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.
|
|
177
|
+
|
|
178
|
+
### Claude Attention
|
|
179
|
+
|
|
180
|
+
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".
|
|
181
|
+
|
|
182
|
+
### Enabling Plugins
|
|
183
|
+
|
|
184
|
+
Add plugins to your `config.json`:
|
|
185
|
+
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"plugins": [
|
|
189
|
+
{
|
|
190
|
+
"name": "opencode-attention",
|
|
191
|
+
"enabled": true,
|
|
192
|
+
"config": {
|
|
193
|
+
"debounceMs": 300,
|
|
194
|
+
"flashDuration": 0,
|
|
195
|
+
"idleThreshold": 3000
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"name": "claude-attention",
|
|
200
|
+
"enabled": true,
|
|
201
|
+
"config": {
|
|
202
|
+
"debounceMs": 300,
|
|
203
|
+
"flashDuration": 0,
|
|
204
|
+
"idleThreshold": 3000,
|
|
205
|
+
"cooldownMs": 1000
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
See [Configuration > Plugins](docs/configuration.md#plugins) for full details.
|
|
213
|
+
|
|
119
214
|
## π οΈ Technology Stack
|
|
120
215
|
|
|
121
216
|
**Backend:** Node.js, Express, Socket.IO, ssh2
|
package/example.config.json
CHANGED
|
@@ -3,10 +3,30 @@
|
|
|
3
3
|
"devPort": 3000,
|
|
4
4
|
"bind": "0.0.0.0",
|
|
5
5
|
"enableHttps": true,
|
|
6
|
+
"certPath": null,
|
|
7
|
+
"keyPath": null,
|
|
6
8
|
"sticky": true,
|
|
7
9
|
"sshKeepaliveInterval": 15000,
|
|
8
10
|
"sshKeepaliveCountMax": 500,
|
|
9
11
|
"passwordHash": null,
|
|
12
|
+
"plugins": [
|
|
13
|
+
{
|
|
14
|
+
"name": "opencode-attention",
|
|
15
|
+
"enabled": true,
|
|
16
|
+
"config": {
|
|
17
|
+
"debounceMs": 300,
|
|
18
|
+
"flashDuration": 0
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "claude-attention",
|
|
23
|
+
"enabled": true,
|
|
24
|
+
"config": {
|
|
25
|
+
"debounceMs": 300,
|
|
26
|
+
"flashDuration": 0
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
],
|
|
10
30
|
"bookmarks": [
|
|
11
31
|
{
|
|
12
32
|
"id": "example1",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lethevimlet/sshift",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Web-based SSH + SFTP terminal client with tabs and bookmarks",
|
|
5
5
|
"main": "src/server/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"sshift",
|
|
62
62
|
"src/server/",
|
|
63
63
|
"src/webapp/",
|
|
64
|
+
"plugins/",
|
|
64
65
|
"example.config.json",
|
|
65
66
|
"README.md",
|
|
66
67
|
"LICENSE"
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* claude-attention Plugin
|
|
3
|
+
*
|
|
4
|
+
* Detects when Claude (https://claude.ai/claude-code) is waiting for user input
|
|
5
|
+
* in an SSH terminal and flashes the tab to alert the user.
|
|
6
|
+
*
|
|
7
|
+
* Detection strategy:
|
|
8
|
+
* - Detects Claude's TUI by looking for "Claude" in the terminal state (sticky: once detected, stays true)
|
|
9
|
+
* - Tracks Claude's processing state via spinner characters (β β β Ήβ Έβ Όβ ΄β ¦β §β β β ½β Β·β’β³βΆβ»β½)
|
|
10
|
+
* - While Claude is working (spinner seen within idleThreshold), ALL flashing is suppressed
|
|
11
|
+
* - When Claude 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 Claude-specific prompt patterns ("β―", "Do you want", "Allow", "Esc to cancel")
|
|
14
|
+
* - Prompt detection only activates in confirmed Claude sessions (isClaude gate)
|
|
15
|
+
* - Suppresses re-flash for a cooldown period after spinner stops a flash
|
|
16
|
+
*
|
|
17
|
+
* Configuration (in config.json under plugins[].config):
|
|
18
|
+
* - patterns: string[] - Additional regex patterns to detect attention
|
|
19
|
+
* - debounceMs: number - Milliseconds between full-state checks (default: 300)
|
|
20
|
+
* - flashDuration: number - Flash duration in ms, 0 = flash until focused (default: 0)
|
|
21
|
+
* - excludePatterns: string[] - Regex patterns to exclude from detection
|
|
22
|
+
* - checkInterval: number - Milliseconds between periodic terminal state checks (default: 2000)
|
|
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)
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
class ClaudeAttentionPlugin {
|
|
28
|
+
constructor(ctx, config = {}) {
|
|
29
|
+
this.ctx = ctx;
|
|
30
|
+
this.config = {
|
|
31
|
+
debounceMs: config.debounceMs || 300,
|
|
32
|
+
flashDuration: config.flashDuration || 0,
|
|
33
|
+
checkInterval: config.checkInterval || 2000,
|
|
34
|
+
idleThreshold: config.idleThreshold || 3000,
|
|
35
|
+
cooldownMs: config.cooldownMs || 1000,
|
|
36
|
+
...config,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
this.patterns = this._buildPatterns(config.patterns || [], config.excludePatterns || []);
|
|
40
|
+
|
|
41
|
+
this._dataTimers = new Map();
|
|
42
|
+
this._checkTimers = new Map();
|
|
43
|
+
this._flashing = new Map();
|
|
44
|
+
this._sessionState = new Map();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
_getSessionState(sessionId) {
|
|
48
|
+
if (!this._sessionState.has(sessionId)) {
|
|
49
|
+
this._sessionState.set(sessionId, {
|
|
50
|
+
isClaude: false,
|
|
51
|
+
lastSpinnerTime: 0,
|
|
52
|
+
wasWorking: false,
|
|
53
|
+
cooldownUntil: 0,
|
|
54
|
+
idleCheckScheduled: false,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return this._sessionState.get(sessionId);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
_isWorking(sessionId) {
|
|
61
|
+
const s = this._getSessionState(sessionId);
|
|
62
|
+
return s.wasWorking && (Date.now() - s.lastSpinnerTime) < this.config.idleThreshold;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
_buildPatterns(extraPatterns, excludePatterns) {
|
|
66
|
+
const defaultPatterns = [
|
|
67
|
+
/\> $/,
|
|
68
|
+
/\> \x1b/,
|
|
69
|
+
/β― /,
|
|
70
|
+
/waiting for input/i,
|
|
71
|
+
/press enter/i,
|
|
72
|
+
/press any key/i,
|
|
73
|
+
/confirm\s*\?/i,
|
|
74
|
+
/\(y\/n\)/i,
|
|
75
|
+
/\(yes\/no\)/i,
|
|
76
|
+
/\[Y\/n\]/i,
|
|
77
|
+
/\[y\/N\]/i,
|
|
78
|
+
/do you want/i,
|
|
79
|
+
/allow/i,
|
|
80
|
+
/Esc to cancel/i,
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
let patterns = [...defaultPatterns];
|
|
84
|
+
|
|
85
|
+
for (const p of extraPatterns) {
|
|
86
|
+
try { patterns.push(new RegExp(p)); } catch (e) {
|
|
87
|
+
console.error(`[claude-attention] Invalid pattern "${p}":`, e.message);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
for (const p of excludePatterns) {
|
|
92
|
+
try {
|
|
93
|
+
const regex = new RegExp(p);
|
|
94
|
+
patterns = patterns.filter(pat => pat.source !== regex.source);
|
|
95
|
+
} catch (e) {
|
|
96
|
+
console.error(`[claude-attention] Invalid exclude pattern "${p}":`, e.message);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return patterns;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
_matchesPattern(text) {
|
|
104
|
+
for (const pattern of this.patterns) {
|
|
105
|
+
if (pattern.test(text)) return true;
|
|
106
|
+
}
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
_stripAnsi(str) {
|
|
111
|
+
return str
|
|
112
|
+
.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, '')
|
|
113
|
+
.replace(/\x1b\][^\x07]*\x07/g, '')
|
|
114
|
+
.replace(/\x1b\[\?[0-9]+[hl]/g, '')
|
|
115
|
+
.replace(/\x1b[\(\)]B/g, '')
|
|
116
|
+
.replace(/\x1b[0-9;]*[a-zA-Z]/g, '')
|
|
117
|
+
.replace(/\x1b[^[\]()?P]/g, '')
|
|
118
|
+
.replace(/[\x00-\x08\x0b\x0c\x0d\x0e-\x1f\x7f]/g, '')
|
|
119
|
+
.trim();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
_startFlash(sessionId) {
|
|
123
|
+
const sessionState = this._getSessionState(sessionId);
|
|
124
|
+
if (Date.now() < sessionState.cooldownUntil) return;
|
|
125
|
+
if (this._isWorking(sessionId)) return;
|
|
126
|
+
if (this._flashing.get(sessionId)) return;
|
|
127
|
+
this._flashing.set(sessionId, true);
|
|
128
|
+
this.ctx.flashTab(sessionId, { duration: this.config.flashDuration || 0 });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
_stopFlash(sessionId) {
|
|
132
|
+
if (!this._flashing.get(sessionId)) return;
|
|
133
|
+
this._flashing.delete(sessionId);
|
|
134
|
+
this.ctx.stopFlashTab(sessionId);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
_scheduleCheck(sessionId) {
|
|
138
|
+
if (this._dataTimers.has(sessionId)) return;
|
|
139
|
+
|
|
140
|
+
const timer = setTimeout(() => {
|
|
141
|
+
this._dataTimers.delete(sessionId);
|
|
142
|
+
this._checkAttention(sessionId);
|
|
143
|
+
}, this.config.debounceMs);
|
|
144
|
+
|
|
145
|
+
this._dataTimers.set(sessionId, timer);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
_scheduleIdleCheck(sessionId) {
|
|
149
|
+
const sessionState = this._getSessionState(sessionId);
|
|
150
|
+
if (sessionState.idleCheckScheduled) return;
|
|
151
|
+
sessionState.idleCheckScheduled = true;
|
|
152
|
+
|
|
153
|
+
const delay = this.config.idleThreshold + 200;
|
|
154
|
+
|
|
155
|
+
setTimeout(() => {
|
|
156
|
+
sessionState.idleCheckScheduled = false;
|
|
157
|
+
if (!sessionState.wasWorking) return;
|
|
158
|
+
if (this._isWorking(sessionId)) return;
|
|
159
|
+
this._checkAttention(sessionId);
|
|
160
|
+
}, delay);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
_isSpinnerChar(text) {
|
|
164
|
+
return /[β β β Ήβ Έβ Όβ ΄β ¦β §β β β ½β Β·β’β³βΆβ»β½]/.test(text);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
_checkAttention(sessionId) {
|
|
168
|
+
if (this._isWorking(sessionId)) return;
|
|
169
|
+
|
|
170
|
+
const state = this.ctx.getTerminalState(sessionId);
|
|
171
|
+
if (!state || !state.state) return;
|
|
172
|
+
|
|
173
|
+
const lines = state.state.split('\n');
|
|
174
|
+
const recentLines = lines.slice(-30);
|
|
175
|
+
|
|
176
|
+
let foundClaude = false;
|
|
177
|
+
let matchedPrompt = false;
|
|
178
|
+
|
|
179
|
+
for (const line of recentLines) {
|
|
180
|
+
const stripped = this._stripAnsi(line);
|
|
181
|
+
if (!stripped) continue;
|
|
182
|
+
|
|
183
|
+
if (/Claude/i.test(stripped)) {
|
|
184
|
+
foundClaude = true;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (this._matchesPattern(stripped) || this._matchesPattern(line)) {
|
|
188
|
+
matchedPrompt = true;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const sessionState = this._getSessionState(sessionId);
|
|
193
|
+
if (foundClaude) {
|
|
194
|
+
sessionState.isClaude = true;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (!sessionState.isClaude) return;
|
|
198
|
+
|
|
199
|
+
if (matchedPrompt) {
|
|
200
|
+
this._startFlash(sessionId);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const now = Date.now();
|
|
205
|
+
const timeSinceSpinner = now - sessionState.lastSpinnerTime;
|
|
206
|
+
|
|
207
|
+
if (sessionState.wasWorking && timeSinceSpinner > this.config.idleThreshold) {
|
|
208
|
+
this._startFlash(sessionId);
|
|
209
|
+
sessionState.wasWorking = false;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
onData(sessionId, data) {
|
|
214
|
+
const stripped = this._stripAnsi(data);
|
|
215
|
+
const sessionState = this._getSessionState(sessionId);
|
|
216
|
+
|
|
217
|
+
if (/Claude/i.test(stripped) || /Claude/i.test(data)) {
|
|
218
|
+
sessionState.isClaude = true;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const isSpinner = this._isSpinnerChar(stripped) || this._isSpinnerChar(data);
|
|
222
|
+
|
|
223
|
+
if (isSpinner) {
|
|
224
|
+
sessionState.lastSpinnerTime = Date.now();
|
|
225
|
+
sessionState.wasWorking = true;
|
|
226
|
+
this._scheduleIdleCheck(sessionId);
|
|
227
|
+
if (this._flashing.get(sessionId)) {
|
|
228
|
+
this._stopFlash(sessionId);
|
|
229
|
+
sessionState.cooldownUntil = Date.now() + this.config.cooldownMs;
|
|
230
|
+
}
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (!sessionState.isClaude) return;
|
|
235
|
+
if (this._isWorking(sessionId)) return;
|
|
236
|
+
|
|
237
|
+
if (this._matchesPattern(stripped) || this._matchesPattern(data)) {
|
|
238
|
+
this._startFlash(sessionId);
|
|
239
|
+
} else {
|
|
240
|
+
this._scheduleCheck(sessionId);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
onTerminalLine(sessionId, strippedLine, rawLine) {
|
|
245
|
+
const sessionState = this._getSessionState(sessionId);
|
|
246
|
+
|
|
247
|
+
if (/Claude/i.test(strippedLine)) {
|
|
248
|
+
sessionState.isClaude = true;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (!sessionState.isClaude) return;
|
|
252
|
+
if (this._isWorking(sessionId)) return;
|
|
253
|
+
|
|
254
|
+
if (this._matchesPattern(strippedLine) || this._matchesPattern(rawLine)) {
|
|
255
|
+
this._startFlash(sessionId);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
onSessionConnect(sessionId) {
|
|
260
|
+
this._sessionState.delete(sessionId);
|
|
261
|
+
this._flashing.delete(sessionId);
|
|
262
|
+
|
|
263
|
+
const existingTimer = this._checkTimers.get(sessionId);
|
|
264
|
+
if (existingTimer) clearInterval(existingTimer);
|
|
265
|
+
|
|
266
|
+
const timer = setInterval(() => {
|
|
267
|
+
if (!this.ctx.getActiveSessions().includes(sessionId)) {
|
|
268
|
+
clearInterval(timer);
|
|
269
|
+
this._checkTimers.delete(sessionId);
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
this._checkAttention(sessionId);
|
|
273
|
+
}, this.config.checkInterval);
|
|
274
|
+
|
|
275
|
+
this._checkTimers.set(sessionId, timer);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
onSessionDisconnect(sessionId) {
|
|
279
|
+
this._stopFlash(sessionId);
|
|
280
|
+
this._sessionState.delete(sessionId);
|
|
281
|
+
|
|
282
|
+
const checkTimer = this._checkTimers.get(sessionId);
|
|
283
|
+
if (checkTimer) {
|
|
284
|
+
clearInterval(checkTimer);
|
|
285
|
+
this._checkTimers.delete(sessionId);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const dataTimer = this._dataTimers.get(sessionId);
|
|
289
|
+
if (dataTimer) {
|
|
290
|
+
clearTimeout(dataTimer);
|
|
291
|
+
this._dataTimers.delete(sessionId);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
module.exports = ClaudeAttentionPlugin;
|