Network: confirm a change only after it has been fully applied, keep the session when the old connection times out, and retry reloading so changes show up without reopening the tab

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 23:22:16 +02:00
co-authored by Claude Opus 5.5
parent 1517764cca
commit 98d8cfa993
2 changed files with 21 additions and 13 deletions
+8 -3
View File
@@ -2185,8 +2185,13 @@ class NetworkSession {
this.draw();
}
async refresh() {
try { this.apply(await api.call('network:read', this.id)); } catch (e) { toast(e.message, 'error'); }
async refresh(tries = 1) {
for (let i = 1; ; i++) {
try { return this.apply(await api.call('network:read', this.id)); } catch (e) {
if (i >= tries) return toast(e.message, 'error');
await new Promise((r) => setTimeout(r, 3000));
}
}
}
cfg(name) { return this.data.config.find((c) => c.name === name); }
@@ -2258,7 +2263,7 @@ class NetworkSession {
try {
const r = await fn();
ov.remove();
if (r?.confirmed) { toast(r.direct ? T('Saved') : T('Network change applied and confirmed'), 'ok'); await this.refresh(); }
if (r?.confirmed) { toast(r.direct ? T('Saved') : T('Network change applied and confirmed'), 'ok'); await this.refresh(4); }
else {
setTabState(this, 'err');
this.body.innerHTML = `<div class="pane-empty"><div style="color:var(--orange);max-width:560px;text-align:center">${T('MrTerm could not reconnect after the change. The server restores the previous configuration automatically within 90 seconds.')}</div></div>`;