Skip to content

Commit 72ae470

Browse files
committed
Embedded HTML Div alert when connection is lost
1 parent 12dee8b commit 72ae470

File tree

2 files changed

+1187
-1117
lines changed

2 files changed

+1187
-1117
lines changed

bridge/webui.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,31 @@ class WebuiBridge {
170170
}
171171
}
172172
#freezeUi() {
173-
document.body.style.filter = 'contrast(1%)';
173+
if (document.getElementById('webui-error-connection-lost')) return;
174+
const div = document.createElement('div');
175+
div.id = 'webui-error-connection-lost';
176+
Object.assign(div.style, {
177+
position: 'relative',
178+
top: '0',
179+
left: '0',
180+
width: '100%',
181+
backgroundColor: '#ff4d4d',
182+
color: '#fff',
183+
textAlign: 'center',
184+
padding: '2px 0',
185+
fontFamily: 'Arial, sans-serif',
186+
fontSize: '14px',
187+
zIndex: '1000',
188+
lineHeight: '1'
189+
});
190+
div.innerText = 'WebUI Error: Connection with the backend is lost.';
191+
document.body.insertBefore(div, document.body.firstChild);
174192
}
175193
#unfreezeUI() {
176-
document.body.style.filter = 'contrast(100%)';
194+
const div = document.getElementById('webui-error-connection-lost');
195+
if (div) {
196+
div.remove();
197+
}
177198
}
178199
#isTextBasedCommand(cmd: number): Boolean {
179200
if (cmd !== this.#CMD_SEND_RAW) return true;

0 commit comments

Comments
 (0)