From f4d934d341056142da1212c845eeeb170fd452c2 Mon Sep 17 00:00:00 2001 From: Agando Date: Tue, 26 May 2026 06:00:26 +0200 Subject: auto: 2026-05-26_06:00 changes --- modules/core/terminal.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'modules/core/terminal.js') 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) -- cgit v1.2.3