v8: agent logos on idle, transparent backgrounds, fix PI settings persistence

This commit is contained in:
2026-06-18 14:45:42 +08:00
parent ae114159ff
commit c1f35df657
5 changed files with 34 additions and 11 deletions
@@ -1,4 +1,4 @@
const { Plugins, Actions, log } = require('./utils/plugin');
const { Plugins, Actions, log } = require('./utils/plugin');
const fs = require('fs');
const path = require('path');
const os = require('os');
@@ -8,7 +8,21 @@ const timers = {};
const sessionOffsets = {};
const DEBUG_LOG = path.join(__dirname, '..', 'debug.log');
function dlog(msg) { try { fs.appendFileSync(DEBUG_LOG, '[' + new Date().toISOString() + '] ' + msg + '\n'); } catch (_) {} }
dlog('=== AI Monitor v7 multi-agent ===');
dlog('=== AI Monitor v8 multi-agent ===');
// --- Load agent logos as data URIs ---
function loadSvg(filename) {
try {
var file = path.join(__dirname, '..', 'static', 'img', filename);
var raw = fs.readFileSync(file, 'utf-8');
return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(raw);
} catch (_) { return ''; }
}
var AGENT_LOGOS = {
codex: loadSvg('codex-icon.svg'),
claude: loadSvg('claude-icon.svg'),
opencode: loadSvg('opencode-icon.svg')
};
const HOME = os.homedir();
const DEFAULT_POLL = 1000;
@@ -107,7 +121,7 @@ function makeSvg(fill, label, blink, breathe) {
var anim = '';
if (blink) anim = '<animate attributeName="opacity" values="1;0.2;1" dur="0.8s" repeatCount="indefinite"/>';
else if (breathe) anim = '<animate attributeName="opacity" values="1;0.4;1" dur="2s" repeatCount="indefinite"/>';
return '<svg width="144" height="144" xmlns="http://www.w3.org/2000/svg"><rect width="144" height="144" rx="20" fill="#1a1a2e"/><circle cx="72" cy="58" r="32" fill="' + fill + '">' + anim + '</circle><text x="72" y="118" font-family="Arial" font-weight="bold" font-size="13" fill="white" text-anchor="middle">' + label + '</text></svg>';
return '<svg width="144" height="144" xmlns="http://www.w3.org/2000/svg"><rect width="144" height="144" rx="20" fill="none"/><circle cx="72" cy="58" r="32" fill="' + fill + '">' + anim + '</circle><text x="72" y="118" font-family="Arial" font-weight="bold" font-size="13" fill="white" text-anchor="middle">' + label + '</text></svg>';
}
function setDisplay(context, state) {
@@ -124,7 +138,7 @@ function animateTick() {
var alpha = d.blink ? (phase < 0.5 ? 1 : 0.2) : 0.4 + 0.6 * Math.sin(phase * Math.PI);
var _r = parseInt(d.fill.slice(1,3),16), _g = parseInt(d.fill.slice(3,5),16), _b = parseInt(d.fill.slice(5,7),16);
var color = 'rgb(' + Math.round(16+(_r-16)*alpha) + ',' + Math.round(16+(_g-16)*alpha) + ',' + Math.round(16+(_b-16)*alpha) + ')';
var svg = '<svg width="144" height="144" xmlns="http://www.w3.org/2000/svg"><rect width="144" height="144" rx="20" fill="#1a1a2e"/><circle cx="72" cy="58" r="32" fill="' + color + '"/><text x="72" y="118" font-family="Arial" font-weight="bold" font-size="13" fill="white" text-anchor="middle">' + d.title + '</text></svg>';
var svg = '<svg width="144" height="144" xmlns="http://www.w3.org/2000/svg"><rect width="144" height="144" rx="20" fill="none"/><circle cx="72" cy="58" r="32" fill="' + color + '"/><text x="72" y="118" font-family="Arial" font-weight="bold" font-size="13" fill="white" text-anchor="middle">' + d.title + '</text></svg>';
plugin.setImage(currentCtx, 'data:image/svg+xml;charset=utf-8,' + svg);
}
}