myrlin-workbook 0.9.18 → 0.9.20
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/logs/server.pid +1 -1
- package/package.json +1 -1
- package/src/gui.js +18 -6
- package/src/web/pty-manager.js +1 -1
- package/src/web/public/app.js +34 -8
package/logs/server.pid
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
45572
|
package/package.json
CHANGED
package/src/gui.js
CHANGED
|
@@ -191,10 +191,22 @@ if (!process.env.CWM_NO_OPEN) {
|
|
|
191
191
|
|
|
192
192
|
// ─── Memory Watchdog ──────────────────────────────────────
|
|
193
193
|
// Monitor RSS and kill idle PTY sessions when memory exceeds threshold.
|
|
194
|
-
//
|
|
195
|
-
|
|
196
|
-
const
|
|
197
|
-
const
|
|
194
|
+
// ConPTY on Windows allocates significant native memory (outside V8 heap)
|
|
195
|
+
// so RSS can spike well beyond --max-old-space-size.
|
|
196
|
+
const MEMORY_CHECK_INTERVAL = 15000; // Check every 15 seconds
|
|
197
|
+
const MEMORY_WARN_MB = 200; // Start killing idle (zero-client) PTYs
|
|
198
|
+
const MEMORY_CRITICAL_MB = 350; // Aggressively kill PTYs to survive
|
|
199
|
+
|
|
200
|
+
// Periodic RSS logging so we can trace memory trajectory in server.log
|
|
201
|
+
const _rssLogger = setInterval(() => {
|
|
202
|
+
const mem = process.memoryUsage();
|
|
203
|
+
const ptyManager = getPtyManager();
|
|
204
|
+
const ptySessions = ptyManager ? ptyManager.listSessions().length : 0;
|
|
205
|
+
try {
|
|
206
|
+
console.log(`[RSS] ${Math.round(mem.rss / 1024 / 1024)}MB heap=${Math.round(mem.heapUsed / 1024 / 1024)}/${Math.round(mem.heapTotal / 1024 / 1024)}MB pty=${ptySessions}`);
|
|
207
|
+
} catch (_) {}
|
|
208
|
+
}, 60000);
|
|
209
|
+
_rssLogger.unref();
|
|
198
210
|
|
|
199
211
|
const _memoryWatchdog = setInterval(() => {
|
|
200
212
|
const rssMB = Math.round(process.memoryUsage().rss / 1024 / 1024);
|
|
@@ -220,8 +232,8 @@ const _memoryWatchdog = setInterval(() => {
|
|
|
220
232
|
}
|
|
221
233
|
|
|
222
234
|
// In critical mode, also kill sessions that have been alive longest
|
|
223
|
-
if (isCritical && killed === 0 && sessions.length >
|
|
224
|
-
const oldest = sessions.sort((a, b) => (a.createdAt || 0) - (b.createdAt || 0));
|
|
235
|
+
if (isCritical && killed === 0 && sessions.length > 1) {
|
|
236
|
+
const oldest = [...sessions].sort((a, b) => (a.createdAt || 0) - (b.createdAt || 0));
|
|
225
237
|
ptyManager.killSession(oldest[0].sessionId);
|
|
226
238
|
killed++;
|
|
227
239
|
}
|
package/src/web/pty-manager.js
CHANGED
|
@@ -111,7 +111,7 @@ class PtySession {
|
|
|
111
111
|
// Maximum number of live PTY sessions. Each one is a ConPTY handle + a Claude
|
|
112
112
|
// process (100-200MB each). Beyond this limit, new spawns are rejected to
|
|
113
113
|
// prevent the OS from OOM-killing the server process tree.
|
|
114
|
-
const MAX_PTY_SESSIONS =
|
|
114
|
+
const MAX_PTY_SESSIONS = 5;
|
|
115
115
|
|
|
116
116
|
class PtySessionManager {
|
|
117
117
|
constructor() {
|
package/src/web/public/app.js
CHANGED
|
@@ -9110,11 +9110,33 @@ class CWMApp {
|
|
|
9110
9110
|
});
|
|
9111
9111
|
};
|
|
9112
9112
|
|
|
9113
|
-
//
|
|
9114
|
-
//
|
|
9115
|
-
|
|
9113
|
+
// On fatal connection error, show disconnected state but PRESERVE pane info.
|
|
9114
|
+
// The session ID, name, and spawnOpts stay in the layout so the user can
|
|
9115
|
+
// reconnect by clicking, and layout saves don't lose the session mapping.
|
|
9116
|
+
tp.onFatalError = (failedSessionId) => {
|
|
9116
9117
|
const idx = this.terminalPanes.indexOf(tp);
|
|
9117
|
-
if (idx
|
|
9118
|
+
if (idx === -1) return;
|
|
9119
|
+
// Stash session info before disposing so we can offer reconnect
|
|
9120
|
+
const sid = tp.sessionId;
|
|
9121
|
+
const sName = tp.sessionName;
|
|
9122
|
+
const opts = { ...(tp.spawnOpts || {}) };
|
|
9123
|
+
tp.dispose();
|
|
9124
|
+
// Replace the TerminalPane with a lightweight placeholder that preserves
|
|
9125
|
+
// the session mapping for layout saves (saveCurrentGroupPanes reads these).
|
|
9126
|
+
this.terminalPanes[idx] = { sessionId: sid, sessionName: sName, spawnOpts: opts, _disconnected: true };
|
|
9127
|
+
const paneEl = document.getElementById(`term-pane-${idx}`);
|
|
9128
|
+
if (!paneEl) return;
|
|
9129
|
+
const container = document.getElementById(`term-container-${idx}`);
|
|
9130
|
+
if (container) {
|
|
9131
|
+
container.innerHTML = `<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:8px;color:var(--overlay0);font-size:13px;cursor:pointer;" class="reconnect-prompt">
|
|
9132
|
+
<span style="font-size:20px;">⚠</span>
|
|
9133
|
+
<span>${this.escapeHtml(sName || sid)}</span>
|
|
9134
|
+
<span style="font-size:11px;opacity:0.7;">Disconnected. Click to reconnect.</span>
|
|
9135
|
+
</div>`;
|
|
9136
|
+
container.querySelector('.reconnect-prompt').addEventListener('click', () => {
|
|
9137
|
+
this.openTerminalInPane(idx, sid, sName, opts);
|
|
9138
|
+
});
|
|
9139
|
+
}
|
|
9118
9140
|
};
|
|
9119
9141
|
|
|
9120
9142
|
// Enable auto-trust if the setting is on
|
|
@@ -12083,12 +12105,16 @@ class CWMApp {
|
|
|
12083
12105
|
|
|
12084
12106
|
group.panes = [];
|
|
12085
12107
|
for (let i = 0; i < CWMApp.MAX_PANES; i++) {
|
|
12086
|
-
|
|
12108
|
+
const tp = this.terminalPanes[i];
|
|
12109
|
+
// Save both live TerminalPanes and disconnected placeholders.
|
|
12110
|
+
// Disconnected placeholders have { sessionId, sessionName, spawnOpts, _disconnected: true }
|
|
12111
|
+
// and MUST be preserved so layout restores don't lose session mappings.
|
|
12112
|
+
if (tp && tp.sessionId) {
|
|
12087
12113
|
group.panes.push({
|
|
12088
12114
|
slot: i,
|
|
12089
|
-
sessionId:
|
|
12090
|
-
sessionName:
|
|
12091
|
-
spawnOpts:
|
|
12115
|
+
sessionId: tp.sessionId,
|
|
12116
|
+
sessionName: tp.sessionName,
|
|
12117
|
+
spawnOpts: tp.spawnOpts || {},
|
|
12092
12118
|
});
|
|
12093
12119
|
}
|
|
12094
12120
|
}
|