Files
jackwener__opencli/extension/popup.js
jakevin bf5f327775 fix(extension): improve UX when daemon is not running (#424)
- Show helpful hint in popup when disconnected: "This is normal. The
  extension connects automatically when you run any opencli command."
- Stop eager reconnect after 6 attempts (reaching 60s backoff) to
  reduce ERR_CONNECTION_REFUSED noise in console; keepalive alarm
  still retries every ~24s at low frequency.
2026-03-25 16:19:02 +08:00

26 lines
939 B
JavaScript

// Query connection status from background service worker
chrome.runtime.sendMessage({ type: 'getStatus' }, (resp) => {
const dot = document.getElementById('dot');
const status = document.getElementById('status');
const hint = document.getElementById('hint');
if (chrome.runtime.lastError || !resp) {
dot.className = 'dot disconnected';
status.innerHTML = '<strong>No daemon connected</strong>';
hint.style.display = 'block';
return;
}
if (resp.connected) {
dot.className = 'dot connected';
status.innerHTML = '<strong>Connected to daemon</strong>';
hint.style.display = 'none';
} else if (resp.reconnecting) {
dot.className = 'dot connecting';
status.innerHTML = '<strong>Reconnecting...</strong>';
hint.style.display = 'none';
} else {
dot.className = 'dot disconnected';
status.innerHTML = '<strong>No daemon connected</strong>';
hint.style.display = 'block';
}
});