opencode-avatar 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/electron.js +4 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -194,6 +194,8 @@ The output shows:
|
|
|
194
194
|
- Subsequent loads are instant (cached)
|
|
195
195
|
- Reduce avatar size for faster generation
|
|
196
196
|
|
|
197
|
+
> **Warning:** If you have a lot of tools (like from an MCP), it will generate a lot of images per tool, which may impact performance.
|
|
198
|
+
|
|
197
199
|
## Development
|
|
198
200
|
|
|
199
201
|
### Building
|
package/dist/electron.js
CHANGED
|
@@ -405,11 +405,6 @@ import * as fs from "fs";
|
|
|
405
405
|
import * as os from "os";
|
|
406
406
|
import { fileURLToPath } from "url";
|
|
407
407
|
require_main().config();
|
|
408
|
-
var logFile = path.join(os.homedir(), "avatar.log");
|
|
409
|
-
function log(msg) {
|
|
410
|
-
fs.appendFileSync(logFile, new Date().toISOString() + ": " + msg + `
|
|
411
|
-
`);
|
|
412
|
-
}
|
|
413
408
|
function getConfig() {
|
|
414
409
|
try {
|
|
415
410
|
const configPath = path.join(os.homedir(), ".config", "opencode", "opencode-avatar.json");
|
|
@@ -517,11 +512,10 @@ var HTML_CONTENT = `<!DOCTYPE html>
|
|
|
517
512
|
img.src = canvas.toDataURL('image/png');
|
|
518
513
|
};
|
|
519
514
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
};
|
|
515
|
+
srcImg.onerror = function(e) {
|
|
516
|
+
console.error('Failed to load image:', e);
|
|
517
|
+
img.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==';
|
|
518
|
+
};
|
|
525
519
|
}
|
|
526
520
|
|
|
527
521
|
ipcRenderer.on('set-avatar', (event, avatarDataUrl) => {
|
|
@@ -690,7 +684,6 @@ function startAvatarServer() {
|
|
|
690
684
|
req.on("end", () => {
|
|
691
685
|
try {
|
|
692
686
|
const { avatarPath } = JSON.parse(body);
|
|
693
|
-
log("Set-avatar request with path: " + avatarPath);
|
|
694
687
|
if (mainWindow && avatarPath) {
|
|
695
688
|
const imageBuffer = fs.readFileSync(avatarPath);
|
|
696
689
|
const base64 = imageBuffer.toString("base64");
|
|
@@ -780,7 +773,6 @@ function createWindow() {
|
|
|
780
773
|
mainWindow.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(HTML_CONTENT)}`);
|
|
781
774
|
mainWindow.webContents.on("did-finish-load", () => {
|
|
782
775
|
if (mainWindow) {
|
|
783
|
-
log("Window finished loading");
|
|
784
776
|
const avatarPath = getAvatarPath();
|
|
785
777
|
try {
|
|
786
778
|
const imageBuffer = fs.readFileSync(avatarPath);
|
|
@@ -834,7 +826,6 @@ function createTray() {
|
|
|
834
826
|
tray.on("click", () => mainWindow?.isVisible() ? mainWindow.hide() : mainWindow?.show());
|
|
835
827
|
}
|
|
836
828
|
function processTrayIcon(pngPath) {
|
|
837
|
-
log("Processing tray icon from: " + pngPath);
|
|
838
829
|
let trayIcon = nativeImage.createFromPath(pngPath);
|
|
839
830
|
if (!trayIcon.isEmpty()) {
|
|
840
831
|
const size = trayIcon.getSize();
|
|
@@ -852,9 +843,7 @@ function processTrayIcon(pngPath) {
|
|
|
852
843
|
}
|
|
853
844
|
}
|
|
854
845
|
trayIcon = nativeImage.createFromBitmap(bitmap, size);
|
|
855
|
-
log("Tray icon processed successfully");
|
|
856
846
|
} else {
|
|
857
|
-
log("Tray icon is empty, using fallback");
|
|
858
847
|
trayIcon = nativeImage.createFromDataURL("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==");
|
|
859
848
|
}
|
|
860
849
|
return trayIcon;
|