Skip to content

armgit / kokon

Public Imported from GitHub
0

Edit photos by describing the change, on your own GPU. A free, open-source alternative to Nano Banana and ChatGPT image editing: photos stay on your computer, no daily limit. One installer for Windows, Mac and Linux sets up the best open model (Qwen-Image 2.1). MCP server for AI agents.

Desktop: a dropped image is added once in development too (StrictMode left two drop listeners)

Gabriele Lozuponeacb9490e4e6c
diff --git a/src/App.tsx b/src/App.tsx
index afe9d21..22d647e 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -211,7 +211,10 @@ export default function App() {
// Native file drops (paths) — efficient: the service reads the files itself.
useEffect(() => {
if (inBrowser) return;
+ // The listener arrives asynchronously: if the effect was already cleaned up (StrictMode's
+ // second mount in development), drop it at once instead of keeping two that add each image twice.
let un: (() => void) | undefined;
+ let gone = false;
getCurrentWebview()
.onDragDropEvent((ev) => {
const p = ev.payload;
@@ -224,9 +227,12 @@ export default function App() {
else if (p.paths.length) toastInfo("Only image files can be added.");
}
})
- .then((u) => (un = u))
+ .then((u) => (gone ? u() : (un = u)))
.catch(() => {});
- return () => un?.();
+ return () => {
+ gone = true;
+ un?.();
+ };
}, []);
// Clipboard paste: browser image data first, native clipboard as a fallback.