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.

Open the window with the logo already painted

Gabriele Lozupone8caa19b482de
diff --git a/index.html b/index.html
index cd08b09..e5d4759 100644
--- a/index.html
+++ b/index.html
@@ -22,6 +22,7 @@
<svg viewBox="0 0 1024 1024" aria-hidden="true"><path fill="currentColor" d="M0.00 242.81 C0.00 112.17 70.23 25.08 175.59 25.08 C280.94 25.08 351.17 112.17 351.17 242.81 L351.17 781.19 C351.17 911.83 280.94 998.92 175.59 998.92 C70.23 998.92 0.00 911.83 0.00 781.19 Z M389.53 548.95 C389.53 250.35 662.35 25.08 1024.00 25.08 C1024.00 323.68 751.18 548.95 389.53 548.95 Z M389.53 587.31 C389.53 821.93 618.71 998.92 922.49 998.92 C922.49 764.30 693.31 587.31 389.53 587.31 Z"/></svg>
</div>
</div>
+ <script src="/boot.js"></script>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
diff --git a/public/boot.js b/public/boot.js
new file mode 100644
index 0000000..048a960
--- /dev/null
+++ b/public/boot.js
@@ -0,0 +1,10 @@
+// The main window starts hidden (tauri.conf.json) so it never shows an empty page while the
+// web view and the app load. This runs right after the splash in index.html is in the DOM:
+// show the window once that splash has been painted. (A classic script file, not inline,
+// because the CSP only allows scripts from the app itself.)
+requestAnimationFrame(function () {
+ requestAnimationFrame(function () {
+ var t = window.__TAURI_INTERNALS__;
+ if (t) t.invoke("plugin:window|show", { label: "main" }).catch(function () {});
+ });
+});
diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json
index d1879c4..49a228c 100644
--- a/src-tauri/capabilities/default.json
+++ b/src-tauri/capabilities/default.json
@@ -5,6 +5,7 @@
"windows": ["main"],
"permissions": [
"core:default",
+ "core:window:allow-show",
"core:window:allow-set-fullscreen",
"core:window:allow-is-fullscreen",
"dialog:allow-open",
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index e4f4df6..401af26 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -244,6 +244,21 @@ pub fn run() {
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_clipboard_manager::init())
.manage(shared.clone())
+ .setup(|app| {
+ // The window starts hidden and the page shows it once its splash is painted
+ // (public/boot.js). If the page never loads (dev server down, broken web view),
+ // show it anyway so there is something to close or read.
+ let handle = app.handle().clone();
+ std::thread::spawn(move || {
+ std::thread::sleep(Duration::from_secs(4));
+ if let Some(w) = handle.get_webview_window("main")
+ && !w.is_visible().unwrap_or(true)
+ {
+ let _ = w.show();
+ }
+ });
+ Ok(())
+ })
.invoke_handler(tauri::generate_handler![connect, copy_image, read_clipboard_image, reveal, open_folder, open_link, data_folder])
.build(tauri::generate_context!())
.expect("error while building Kokon");
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index aa87a59..9e44956 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -21,6 +21,7 @@
"minWidth": 880,
"minHeight": 620,
"center": true,
+ "visible": false,
"dragDropEnabled": true
}
],
diff --git a/vite.config.ts b/vite.config.ts
index 48f25b1..ed445c3 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -5,7 +5,8 @@ import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [react()],
clearScreen: false,
- server: { port: 1420, strictPort: true, host: "127.0.0.1" },
+ // warmup: compile the app as soon as the dev server starts, not when the window asks for it.
+ server: { port: 1420, strictPort: true, host: "127.0.0.1", warmup: { clientFiles: ["./src/main.tsx"] } },
build: { target: "es2022", sourcemap: false, chunkSizeWarningLimit: 1500 },
test: { environment: "jsdom" },
});