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.

Other devices: QR code to open Kokon on a phone, home-screen icon and web manifest

Gabriele Lozupone02431c0fc44c
diff --git a/index.html b/index.html
index cc6f389..3d7b8c1 100644
--- a/index.html
+++ b/index.html
@@ -2,8 +2,15 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<title>Kokon</title>
+ <!-- In a browser on another device: the tab icon, and Kokon on the home screen like an app
+ (Settings → Other devices shows how). The desktop app ignores these. -->
+ <link rel="icon" type="image/png" href="/favicon.png" />
+ <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
+ <link rel="manifest" href="/manifest.webmanifest" />
+ <meta name="apple-mobile-web-app-capable" content="yes" />
+ <meta name="apple-mobile-web-app-title" content="Kokon" />
<!-- Painted before any JavaScript runs, so the window never shows an empty white page
(the dev server can take seconds to compile; the web view itself needs a moment).
React replaces #root's content when the app mounts. Colors match styles.css. -->
diff --git a/package-lock.json b/package-lock.json
index 18c7cad..ddbaac5 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -18,7 +18,8 @@
"@tauri-apps/plugin-updater": "^2.13.2",
"lucide-react": "^1.52.0",
"react": "^19.3.0",
- "react-dom": "^19.3.0"
+ "react-dom": "^19.3.0",
+ "uqr": "^0.1.3"
},
"devDependencies": {
"@tauri-apps/cli": "^2.12.1",
@@ -2147,6 +2148,12 @@
"node": ">=20.18.1"
}
},
+ "node_modules/uqr": {
+ "version": "0.1.3",
+ "resolved": "https://registry.npmjs.org/uqr/-/uqr-0.1.3.tgz",
+ "integrity": "sha512-0rjE8iEJe4YmT9TOhwsZtqCMRLc5DXZUI2UEYUUg63ikBkqqE5EYWaI0etFe/5KUcmcYwLih2RND1kq+hrUJXA==",
+ "license": "MIT"
+ },
"node_modules/vite": {
"version": "8.3.3",
"resolved": "https://registry.npmjs.org/vite/-/vite-8.3.3.tgz",
diff --git a/package.json b/package.json
index 82913bb..f38caa4 100644
--- a/package.json
+++ b/package.json
@@ -21,7 +21,8 @@
"@tauri-apps/plugin-updater": "^2.13.2",
"lucide-react": "^1.52.0",
"react": "^19.3.0",
- "react-dom": "^19.3.0"
+ "react-dom": "^19.3.0",
+ "uqr": "^0.1.3"
},
"devDependencies": {
"@tauri-apps/cli": "^2.12.1",
diff --git a/public/apple-touch-icon.png b/public/apple-touch-icon.png
new file mode 100644
index 0000000..d4dc131
Binary files /dev/null and b/public/apple-touch-icon.png differ
diff --git a/public/favicon.png b/public/favicon.png
new file mode 100644
index 0000000..0bd6a09
Binary files /dev/null and b/public/favicon.png differ
diff --git a/public/icon-192.png b/public/icon-192.png
new file mode 100644
index 0000000..b17eef2
Binary files /dev/null and b/public/icon-192.png differ
diff --git a/public/icon-512.png b/public/icon-512.png
new file mode 100644
index 0000000..b174503
Binary files /dev/null and b/public/icon-512.png differ
diff --git a/public/manifest.webmanifest b/public/manifest.webmanifest
new file mode 100644
index 0000000..1074cec
--- /dev/null
+++ b/public/manifest.webmanifest
@@ -0,0 +1,14 @@
+{
+ "name": "Kokon",
+ "short_name": "Kokon",
+ "description": "Edit photos by describing the change, on your own computer.",
+ "start_url": "/",
+ "scope": "/",
+ "display": "standalone",
+ "background_color": "#f4f4f4",
+ "theme_color": "#f4f4f4",
+ "icons": [
+ { "src": "/icon-192.png", "sizes": "192x192", "type": "image/png" },
+ { "src": "/icon-512.png", "sizes": "512x512", "type": "image/png" }
+ ]
+}
diff --git a/src/components/RemoteAccess.tsx b/src/components/RemoteAccess.tsx
index 3fd5e38..f31074e 100644
--- a/src/components/RemoteAccess.tsx
+++ b/src/components/RemoteAccess.tsx
@@ -3,8 +3,9 @@
// opens the network port only then (crates/qls-service/src/remote.rs).
import { Copy, ExternalLink } from "lucide-react";
-import { useEffect, useState } from "react";
+import { useEffect, useMemo, useState } from "react";
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
+import { encode } from "uqr";
import { api, type RemoteStatus } from "../lib/api";
import { native } from "../lib/native";
import { toastError, toastInfo } from "../lib/store";
@@ -12,6 +13,22 @@ import { Switch } from "./ui";
const GUIDE_URL = "https://github.com/GabrieleLozupone/kokon/blob/master/docs/remote-access.md";
+/** The address as a QR code for the phone's camera: black on white in both themes, so every scanner reads it. */
+function QrCode({ text }: { text: string }) {
+ const { path, size } = useMemo(() => {
+ const qr = encode(text, { border: 2 });
+ let d = "";
+ qr.data.forEach((row, y) => row.forEach((on, x) => on && (d += `M${x} ${y}h1v1h-1z`)));
+ return { path: d, size: qr.size };
+ }, [text]);
+ return (
+ <svg className="qr" viewBox={`0 0 ${size} ${size}`} role="img" aria-label={`QR code for ${text}`} shapeRendering="crispEdges">
+ <rect width={size} height={size} fill="#fff" />
+ <path d={path} fill="#000" />
+ </svg>
+ );
+}
+
function PasswordForm({ status, onSaved }: { status: RemoteStatus; onSaved: (s: RemoteStatus) => void }) {
const [password, setPassword] = useState("");
const [busy, setBusy] = useState(false);
@@ -98,14 +115,18 @@ export function RemoteAccess() {
</div>
{st.forced && <span className="muted">Turned on for this run by kokon-service --remote.</span>}
{st.listening && st.url && (
- <div className="setting-card">
+ <div className="setting-card remote-open">
+ <QrCode text={st.url} />
<div className="setting-card-text">
- <strong>Open this address on the other device</strong>
- <span className="remote-url">{st.url}</span>
+ <strong>Scan it with your phone's camera</strong>
+ <span className="muted">
+ Or open <span className="remote-url">{st.url}</span> on the other device. To keep Kokon on the home screen like an app: on iPhone, Share → Add to Home Screen; on
+ Android, the browser's menu → Add to Home screen.
+ </span>
+ <button className="btn" style={{ alignSelf: "flex-start", marginTop: 6 }} onClick={() => writeText(st.url!).then(() => toastInfo("Address copied"), toastError)}>
+ <Copy size={14} /> Copy address
+ </button>
</div>
- <button className="btn" onClick={() => writeText(st.url!).then(() => toastInfo("Address copied"), toastError)}>
- <Copy size={14} /> Copy
- </button>
</div>
)}
{st.listening && !st.url && <span className="muted">On, at port {st.port} of this computer's network address.</span>}
diff --git a/src/styles.css b/src/styles.css
index da2409a..3037727 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -292,7 +292,9 @@ svg { display: block; flex: none; }
.login .input { width: 100%; box-sizing: border-box; }
.login .btn { width: 100%; justify-content: center; }
.login-error { color: var(--text); font-weight: 500; }
-.remote-url { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; color: var(--text); user-select: all; }
+.remote-open { align-items: flex-start; gap: 16px; }
+.qr { width: 148px; height: 148px; flex: none; border-radius: 10px; }
+.remote-url { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; color: var(--text); user-select: all; }
/* version timeline: a line per image and the versions made from it; arcs join versions made
from earlier ones or from several */