From 2aa5820deab6e429ad4ff41aa2b221169957b191 Mon Sep 17 00:00:00 2001
From: awsr <43862868+awsr@users.noreply.github.com>
Date: Fri, 30 Jan 2026 00:33:49 -0800
Subject: [PATCH 1/2] Fix model not updating + refactor
---
javascript/monitor.js | 75 +++++++++++++++++++++++++++++++------------
1 file changed, 54 insertions(+), 21 deletions(-)
diff --git a/javascript/monitor.js b/javascript/monitor.js
index ab3e714d4..f265fb8d4 100644
--- a/javascript/monitor.js
+++ b/javascript/monitor.js
@@ -1,31 +1,64 @@
-const getModel = () => {
- const cp = opts?.sd_model_checkpoint || '';
- if (!cp) return 'unknown model';
- const noBracket = cp.replace(/\s*\[.*\]\s*$/, ''); // remove trailing [hash]
- const parts = noBracket.split(/[\\/]/); // split on / or \
- return parts[parts.length - 1].trim() || 'unknown model';
-};
+class ConnectionMonitorState {
+ static element;
+ static version = '';
+ static commit = '';
+ static branch = '';
+ static online = false;
+
+ static getModel() {
+ const cp = opts?.sd_model_checkpoint || '';
+ return cp ? this.trimModelName(cp) : 'unknown model';
+ }
+
+ static trimModelName(name) {
+ const noBracket = name.replace(/\s*\[.*\]\s*$/, ''); // remove trailing [hash]
+ const parts = noBracket.split(/[\\/]/); // split on / or \
+ return parts[parts.length - 1].trim() || 'unknown model';
+ }
+
+ static setData({ online, updated, commit, branch }) {
+ this.online = online;
+ this.version = updated;
+ this.commit = commit;
+ this.branch = branch;
+ }
+
+ static setElement(el) {
+ this.element = el;
+ }
+
+ static toHTML(modelOverride) {
+ return `
+ Version: ${this.version}
+ Commit: ${this.commit}
+ Branch: ${this.branch}
+ Status: ${this.online ? 'online' : 'offline'}
+ Model: ${modelOverride ? this.trimModelName(modelOverride) : this.getModel()}
+ Since: ${new Date().toLocaleString()}
+ `;
+ }
+
+ static updateState(incomingModel) {
+ this.element.dataset.hint = this.toHTML(incomingModel);
+ this.element.style.backgroundColor = this.online ? 'var(--sd-main-accent-color)' : 'var(--color-error)';
+ }
+}
+
+let monitorAutoUpdating = false;
async function updateIndicator(online, data, msg) {
const el = document.getElementById('logo_nav');
if (!el || !data) return;
- const status = online ? 'online' : 'offline';
- const date = new Date();
- const template = `
- Version: ${data.updated}
- Commit: ${data.commit}
- Branch: ${data.branch}
- Status: ${status}
- Model: ${getModel()}
- Since: ${date.toLocaleString()}
- `;
+ ConnectionMonitorState.setElement(el);
+ if (!monitorAutoUpdating) {
+ monitorOption('sd_model_checkpoint', (newVal) => { ConnectionMonitorState.updateState(newVal); }); // Runs before opt actually changes
+ monitorAutoUpdating = true;
+ }
+ ConnectionMonitorState.setData({ online, ...data });
+ ConnectionMonitorState.updateState();
if (online) {
- el.dataset.hint = template;
- el.style.backgroundColor = 'var(--sd-main-accent-color)';
log('monitorConnection: online', data);
} else {
- el.dataset.hint = template;
- el.style.backgroundColor = 'var(--color-error)';
log('monitorConnection: offline', msg);
}
}
From 9dc536b25bc1f9c3fe3c98eb161dd608bcab1309 Mon Sep 17 00:00:00 2001
From: awsr <43862868+awsr@users.noreply.github.com>
Date: Fri, 30 Jan 2026 00:46:42 -0800
Subject: [PATCH 2/2] Minor consolidation
---
javascript/monitor.js | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/javascript/monitor.js b/javascript/monitor.js
index f265fb8d4..abc3c38ab 100644
--- a/javascript/monitor.js
+++ b/javascript/monitor.js
@@ -11,9 +11,8 @@ class ConnectionMonitorState {
}
static trimModelName(name) {
- const noBracket = name.replace(/\s*\[.*\]\s*$/, ''); // remove trailing [hash]
- const parts = noBracket.split(/[\\/]/); // split on / or \
- return parts[parts.length - 1].trim() || 'unknown model';
+ // remove trailing [hash], split on / or \, return last segment, trim
+ return name.replace(/\s*\[.*\]\s*$/, '').split(/[\\/]/).pop().trim() || 'unknown model';
}
static setData({ online, updated, commit, branch }) {