diff options
Diffstat (limited to 'modules/core/terminal.js')
| -rw-r--r-- | modules/core/terminal.js | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/modules/core/terminal.js b/modules/core/terminal.js index 0a9538f..ee1afa4 100644 --- a/modules/core/terminal.js +++ b/modules/core/terminal.js @@ -20,6 +20,7 @@ this._pipeBufferSize = 5000; this._historyBuffer = []; this._historyMaxLines = 50; + this._historySavePending = false; this.MAX_OUTPUT_LINES = 200; this._aiBusy = false; this._dirty = false; @@ -325,12 +326,17 @@ } } _saveHistory() { - try { - const slice = this._historyBuffer.slice(-30); - localStorage.setItem('webx11_terminal_output', JSON.stringify(slice)); - } catch (e) { - // Silently ignore storage errors (e.g. quota exceeded) - } + if (this._historySavePending) return; + this._historySavePending = true; + setTimeout(() => { + this._historySavePending = false; + try { + const slice = this._historyBuffer.slice(-30); + localStorage.setItem('webx11_terminal_output', JSON.stringify(slice)); + } catch (e) { + // Silently ignore storage errors (e.g. quota exceeded) + } + }, 3000); } _saveCommandHistory() { try { @@ -369,10 +375,15 @@ _autoSaveSession() { try { this.fs.mkdirRecursive('_sessions'); + // Clone fsRoot and strip _sessions to prevent recursive nesting + var rootClone = JSON.parse(JSON.stringify(this.fs.root)); + if (rootClone && rootClone.content && rootClone.content['_sessions']) { + delete rootClone.content['_sessions']; + } const snapshot = { type: 'session', savedAt: new Date().toISOString(), - fsRoot: this.fs.root, + fsRoot: rootClone, currentPath: this.fs.currentPath, version: 1, terminalLines: this._historyBuffer.slice(-50) |