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.
TypeScript ai-photo-editorcomfyui-alternativegenerative-fillimage-editingimage-generationinpaintinglinuxlocal-aimacosmcpmcp-servernano-banana-alternativeofflinephoto-editorprivacyqwen-imageqwen-image-2-1stable-diffusion-cppvulkanwindows
Phones: full-screen menu with private mode, simpler top bar, no zoom into text fields, What's new buttons stacked
Gabriele Lozupone02c42f232597
diff --git a/index.html b/index.htmlindex 3d7b8c1..a6c3abb 100644--- a/index.html+++ b/index.html@@ -2,7 +2,8 @@<html lang="en"><head><meta charset="UTF-8" />- <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />+ <!-- maximum-scale: iPhone no longer zooms the page into a text field (pinch zoom still works there) -->+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, 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. -->diff --git a/src/App.tsx b/src/App.tsxindex c174781..3326fa9 100644--- a/src/App.tsx+++ b/src/App.tsx@@ -3,7 +3,7 @@ import { Star, X } from "lucide-react";import { useEffect, useRef, useState } from "react";import { api, ApiError, configure, setSignedOutHandler } from "./lib/api";import { native } from "./lib/native";-import { inBrowser, isNarrow } from "./lib/platform";+import { inBrowser } from "./lib/platform";import {addExampleProjects, closeStarPrompt, loadProjects, dismissToast, getState, initStarPrompt, redoVersion, refreshLoras, refreshStatus, selectItem, setState, startEvents, startTour, submitComposer, toastError, toastInfo, undoVersion, useStore,} from "./lib/store";@@ -340,7 +340,6 @@ export default function App() {return (<div className="app">{sidebar && !needsSetup && <Sidebar />}- {sidebar && !needsSetup && isNarrow() && <div className="sidebar-scrim" onClick={() => setState({ sidebar: false })} />}<div className="workspace"><TopBar /><div className="main">diff --git a/src/components/Gallery.tsx b/src/components/Gallery.tsxindex 17d2c68..a565a37 100644--- a/src/components/Gallery.tsx+++ b/src/components/Gallery.tsx@@ -2,7 +2,7 @@ import { ArrowLeft, Check, FolderOpen, Heart, Loader2, Maximize2, Search, Trash2import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { api, urls } from "../lib/api";import { native } from "../lib/native";-import { inBrowser } from "../lib/platform";+import { inBrowser, isNarrow } from "../lib/platform";import { forgetGeneration, openGeneration, setState, toastError, useStore } from "../lib/store";import { MODE_LABEL, neighbourAfterRemoval, previewIndex } from "../lib/logic";import type { GenerationRecord } from "../lib/types";@@ -181,7 +181,7 @@ export function Gallery() {<div className="gallery-bar"><label className="search"><Search size={15} />- <input type="text" placeholder="Search prompts" value={q} onChange={(e) => setQ(e.target.value)} autoFocus />+ <input type="text" placeholder="Search prompts" value={q} onChange={(e) => setQ(e.target.value)} autoFocus={!isNarrow()} /></label><IconButton title={favorites ? "Show all" : "Favorites only"} active={favorites} onClick={() => setFavorites((f) => !f)}><Heart size={17} fill={favorites ? "currentColor" : "none"} />diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsxindex 3d883f9..511e598 100644--- a/src/components/Sidebar.tsx+++ b/src/components/Sidebar.tsx@@ -1,10 +1,11 @@-import { Check, Images, PanelLeftClose, Pencil, Settings, SquarePen, Trash2, X } from "lucide-react";+import { Check, EyeOff, Images, PanelLeftClose, Pencil, Settings, SquarePen, Trash2, X } from "lucide-react";import { useEffect, useState } from "react";import { urls } from "../lib/api";import { timeAgo } from "../lib/logic";import { native } from "../lib/native";-import { isNarrow } from "../lib/platform";+import { isNarrow, useNarrow } from "../lib/platform";import { deleteProject, deleteProjects, newProject, renameProject, setState, switchProject, useStore } from "../lib/store";+import { togglePrivateMode } from "./TopBar";import { IconButton, NameField } from "./ui";import { KokonMark } from "./Welcome";@@ -26,6 +27,9 @@ export function Sidebar() {const empty = useStore((s) => s.session.length === 0);const overlay = useStore((s) => s.overlay);const gallery = overlay === "gallery";+ const privateMode = useStore((s) => s.privateMode);+ // On a phone the menu covers the screen.+ const narrow = useNarrow();const [renaming, setRenaming] = useState<string | null>(null);// Selection: null = off; otherwise the picked project ids (and the last one clicked, for Shift).const [picked, setPicked] = useState<Set<string> | null>(null);@@ -81,8 +85,8 @@ export function Sidebar() {><div className="side-head" data-tauri-drag-region><Wordmark />- <IconButton title="Hide sidebar" onClick={() => setState({ sidebar: false })}>- <PanelLeftClose size={18} />+ <IconButton title={narrow ? "Close menu" : "Hide sidebar"} onClick={() => setState({ sidebar: false })}>+ {narrow ? <X size={22} /> : <PanelLeftClose size={18} />}</IconButton></div><nav className="side-nav">@@ -92,6 +96,12 @@ export function Sidebar() {<button className={`side-item ${gallery ? "on" : ""}`} onClick={() => setState({ overlay: gallery ? null : "gallery" })}><Images size={16} /> All images</button>+ {/* On a phone the top bar has no room for it. */}+ {narrow && (+ <button className="side-item" onClick={togglePrivateMode}>+ <EyeOff size={16} /> Private mode<span className="side-state">{privateMode ? "On" : "Off"}</span>+ </button>+ )}</nav>{projects.length > 0 && (<div className="side-label">diff --git a/src/components/TopBar.tsx b/src/components/TopBar.tsxindex 7513d06..3522286 100644--- a/src/components/TopBar.tsx+++ b/src/components/TopBar.tsx@@ -1,10 +1,10 @@// The top bar: the project's title, then undo/redo, the update pill, the status capsule,// private mode, shortcuts and (only while the sidebar is hidden) Settings, then the window's// buttons. Its own file so the launch video (marketing/video) shows the same bar.-import { ArrowDownToLine, CircleHelp, EyeOff, PanelLeft, Redo2, Settings, SquarePen, Undo2 } from "lucide-react";+import { ArrowDownToLine, CircleHelp, EyeOff, Menu, PanelLeft, Redo2, Settings, SquarePen, Undo2 } from "lucide-react";import { api } from "../lib/api";import { native } from "../lib/native";-import { shortcut } from "../lib/platform";+import { shortcut, useNarrow } from "../lib/platform";import { getState, isMissingModel, newProject, openModelSetup, redoVersion, refreshStatus, setPrivateMode, setState, toastError, undoKey, undoVersion, useStore } from "../lib/store";import { installUpdate } from "../lib/updates";import { SilkSpin } from "./Cocoon";@@ -12,7 +12,8 @@ import { ProjectTitle, Wordmark } from "./Sidebar";import { WindowControls } from "./TitleBar";import { IconButton } from "./ui";-function StatusIndicator() {+/** `quiet`: nothing while the model is loaded and idle (the phone bar has no room for "all is well"). */+function StatusIndicator({ quiet = false }: { quiet?: boolean }) {const connected = useStore((s) => s.connected);const server = useStore((s) => s.server);const busy = useStore((s) => Object.values(s.jobs).some((j) => !["done", "failed", "cancelled"].includes(j.status)));@@ -40,6 +41,7 @@ function StatusIndicator() {title = "Click to load the model now";}}+ if (quiet && cls === "dot ready" && !busy) return null;return (<buttonclassName="status"@@ -97,22 +99,55 @@ ${update.notes}` : msg, "Update Kokon")) installUpdate();function PrivateToggle() {const on = useStore((s) => s.privateMode);- const toggle = () => setPrivateMode(!on, () => native.confirm("Turn off private mode? The images made in private mode will be deleted.", "Private mode"));return on ? (- <button className="private-pill" onClick={toggle} title="Private mode is on: images are not saved and are deleted when you turn it off or close the app. Click to turn it off.">+ <button className="private-pill" onClick={togglePrivateMode} title="Private mode is on: images are not saved and are deleted when you turn it off or close the app. Click to turn it off."><EyeOff size={15} /> Private</button>) : (- <IconButton title="Private mode: nothing is saved to the gallery or your Pictures folder" onClick={toggle}>+ <IconButton title="Private mode: nothing is saved to the gallery or your Pictures folder" onClick={togglePrivateMode}><EyeOff size={18} /></IconButton>);}+/** Private mode from the phone menu: turning it off asks first (its images are deleted). */+export function togglePrivateMode() {+ setPrivateMode(!getState().privateMode, () => native.confirm("Turn off private mode? The images made in private mode will be deleted.", "Private mode"));+}++/** Phone: the menu, the project's title, and only what a thumb needs next to it. Private mode+ * and Settings are in the full-screen menu; the status shows only while it is not "Ready". */+function PhoneBar() {+ const overlay = useStore((s) => s.overlay);+ const privateMode = useStore((s) => s.privateMode);+ return (+ <div className="topbar phone">+ <IconButton title="Menu" onClick={() => setState({ sidebar: true })}>+ <Menu size={22} />+ </IconButton>+ <div className="brand">{overlay === "gallery" ? <span className="project-title">All images</span> : <ProjectTitle />}</div>+ <div className="toolbar">+ <StatusIndicator quiet />+ {privateMode && (+ <IconButton title="Private mode is on: tap to turn it off" onClick={togglePrivateMode} active>+ <EyeOff size={20} />+ </IconButton>+ )}+ <HistoryButtons />+ <IconButton title="New image" onClick={newProject}>+ <SquarePen size={20} />+ </IconButton>+ </div>+ </div>+ );+}+export function TopBar() {const overlay = useStore((s) => s.overlay);const needsSetup = useStore((s) => s.needsSetup);const sidebar = useStore((s) => s.sidebar);+ const narrow = useNarrow();+ if (narrow && !needsSetup) return <PhoneBar />;return (<div className="topbar" data-tauri-drag-region><div className="brand" data-tauri-drag-region>diff --git a/src/components/WhatsNew.tsx b/src/components/WhatsNew.tsxindex a7acbc1..c87aca3 100644--- a/src/components/WhatsNew.tsx+++ b/src/components/WhatsNew.tsx@@ -239,7 +239,7 @@ export function WhatsNew() {</button>) : (<div className="welcome-actions">- <div style={{ display: "flex", gap: 10 }}>+ <div className="welcome-buttons"><button className="btn primary big" disabled={running || !steps.length || (steps.includes("engine") && (!target || missing === null))} onClick={update}>{failed.length ? "Try again" : running ? "Updating…" : `Update now${size ? ` · ${formatBytes(size)}` : ""}`}</button>diff --git a/src/components/ui.tsx b/src/components/ui.tsxindex ff80a7f..20c7d78 100644--- a/src/components/ui.tsx+++ b/src/components/ui.tsx@@ -135,6 +135,8 @@ export function NameField(props: { value: string; onSave: (v: string) => void; oclassName={`name-field ${props.className ?? ""}`}value={v}autoFocus+ // No contact AutoFill bar over the keyboard on a phone.+ autoComplete="off"// Caret at the end, nothing selected: typing adds to the name instead of replacing it.onFocus={(e) => {const n = e.currentTarget.value.length;diff --git a/src/lib/platform.ts b/src/lib/platform.tsindex 960acc4..0b1be2c 100644--- a/src/lib/platform.ts+++ b/src/lib/platform.ts@@ -1,5 +1,7 @@// Platform-specific wording for labels (shortcut handlers accept Ctrl and ⌘ everywhere).+import { useSyncExternalStore } from "react";+export const isMac = typeof navigator !== "undefined" && /Mac/i.test(navigator.platform || navigator.userAgent);/** "Ctrl+Z" on Windows, "⌘Z" on macOS. */@@ -12,5 +14,17 @@ export const fileManager = isMac ? "Finder" : isLinux ? "the file manager" : "Ex/** A phone-sized screen (Kokon in a browser on another device): the sidebar becomes a drawer. Matches styles.css. */export const isNarrow = () => typeof window !== "undefined" && !!window.matchMedia?.("(max-width: 720px)").matches;+/** `isNarrow()` that re-renders when the screen crosses the width (a phone turned sideways). */+export function useNarrow(): boolean {+ return useSyncExternalStore(+ (onChange) => {+ const mq = window.matchMedia?.("(max-width: 720px)");+ mq?.addEventListener("change", onChange);+ return () => mq?.removeEventListener("change", onChange);+ },+ isNarrow,+ );+}+/** The UI runs in a browser, served by kokon-service to another device, not in the desktop app. */export const inBrowser = typeof window !== "undefined" && !("__TAURI_INTERNALS__" in window);diff --git a/src/styles.css b/src/styles.cssindex 2d35beb..78ffa21 100644--- a/src/styles.css+++ b/src/styles.css@@ -733,7 +733,13 @@ pre.diag { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font.welcome-foot { font-size: 12px; }/* The update buttons stay in view while the notes scroll (the dialog's bottom padding is 26px). */.welcome-actions { position: sticky; bottom: -26px; width: calc(100% + 72px); margin: 0 -36px -26px; padding: 14px 36px 22px; background: var(--bg); border-top: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 10px; }-@media (max-width: 560px) { .welcome-actions { width: calc(100% + 40px); margin: 0 -20px -20px; padding: 12px 20px 18px; bottom: -20px; } }+.welcome-buttons { display: flex; gap: 10px; }+/* A phone has no room for two 200 px buttons side by side: stacked, full width, Update first. */+@media (max-width: 560px) {+ .welcome-actions { width: calc(100% + 40px); margin: 0 -20px -20px; padding: 12px 20px 18px; bottom: -20px; }+ .welcome-buttons { flex-direction: column; align-self: stretch; }+ .welcome-buttons .btn.big { min-width: 0; width: 100%; }+}.update-offers { display: flex; flex-direction: column; gap: 8px; width: 100%; text-align: left; }.update-offer { display: flex; gap: 10px; align-items: flex-start; }.update-offer > input { margin-top: 3px; flex: none; }@@ -1000,17 +1006,42 @@ kbd { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px; display.modal-save { display: none; }/* ---------- phone-sized screens (Kokon in a browser on another device) ---------- */+@keyframes menu-in { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }+@media (prefers-reduced-motion: reduce) { .sidebar { animation: none !important; } }@media (max-width: 720px) {- .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 45; background: var(--ground); box-shadow: var(--shadow); padding-top: env(safe-area-inset-top); }- .sidebar-scrim { position: fixed; inset: 0; z-index: 44; background: rgba(13, 13, 12, 0.3); animation: fade 0.2s ease-out both; }- .side-select, .proj-rm { opacity: 1; }- .topbar { padding: env(safe-area-inset-top) 6px 0 8px; gap: 4px; }- /* the status capsule: only its dot or spinner (the words don't fit next to the project title) */- .toolbar .status { margin-right: 2px; padding: 0; width: 30px; justify-content: center; }- .status > span:not(.dot) { display: none; }- .brand .project-title { padding: 0 4px; }- /* the mark without the name, and no keyboard-shortcuts button: room for the project title */- .topbar .wordmark { flex: none; font-size: 0; gap: 0; }+ /* the menu covers the screen, with rows a thumb can hit */+ .sidebar { position: fixed; inset: 0; width: auto; z-index: 45; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); background: var(--ground); animation: menu-in 0.2s ease-out both; }+ .side-head { height: 56px; padding: 0 6px 0 20px; }+ .side-head .wordmark { font-size: 17px; }+ .side-head .icon-btn { width: 44px; height: 44px; }+ .side-nav { padding: 4px 12px 12px; gap: 4px; }+ .side-item { height: 50px; padding: 0 14px; gap: 14px; font-size: 16px; border-radius: 14px; }+ .side-item svg { width: 20px; height: 20px; }+ .side-state { margin-left: auto; font-size: 14px; color: var(--text-3); }+ .side-label { font-size: 13px; padding: 10px 14px 6px 26px; }+ .side-select { opacity: 1; height: 34px; padding: 0 12px; font-size: 14px; }+ .side-list { padding: 2px 12px 16px; gap: 4px; }+ .proj { padding: 9px; gap: 14px; }+ .proj .cover { width: 52px; height: 52px; border-radius: 12px; }+ .proj-title { font-size: 15.5px; }+ .proj-sub { font-size: 13px; margin-top: 2px; }+ .proj-rm, .proj:hover .proj-rm { display: grid; width: 40px; height: 40px; border-radius: 12px; color: var(--text-3); }+ .proj-rm svg { width: 17px; height: 17px; }+ .side-foot { padding: 8px 12px 12px; }+ .side-item.settings { height: 50px; font-size: 16px; }+ /* the top bar: menu, title, then undo/redo and New image; 40 px targets */+ .topbar.phone { height: 56px; box-sizing: content-box; padding: env(safe-area-inset-top) 6px 0 6px; gap: 2px; justify-content: flex-start; }+ .topbar.phone .icon-btn { width: 42px; height: 42px; border-radius: 13px; }+ .topbar.phone .brand { flex: 1; min-width: 0; justify-content: center; }+ .topbar.phone .project-title { font-size: 15px; height: 40px; padding: 0 10px; max-width: 100%; }+ .topbar.phone .title-pencil { display: none; }+ .topbar.phone .name-field.title-field { width: 100%; height: 40px; }+ .topbar.phone .toolbar { margin-left: 0; gap: 0; }+ /* the status capsule only while it says something (loading, working, an error): its dot or spinner */+ .topbar.phone .status { margin: 0 4px; padding: 0; width: 34px; height: 34px; justify-content: center; }+ .topbar.phone .status > span:not(.dot) { display: none; }+ /* during setup the usual bar stays (mark, status, Settings), without the shortcuts */+ .topbar:not(.phone) { padding: env(safe-area-inset-top) 6px 0 12px; }.topbar .icon-btn[title="Shortcuts (?)"] { display: none; }.stage { padding: 4px 10px 8px; }.empty h1 { font-size: 24px; }@@ -1019,7 +1050,7 @@ kbd { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px; display/* name, mode and upscaled/original wrap onto two centred lines instead of leaving the screen */.stage-meta { flex-wrap: wrap; row-gap: 6px; padding: 0 4px; }.stage-bar .actions { flex-wrap: wrap; justify-content: center; }- .composer-wrap { padding: 0 8px calc(8px + env(safe-area-inset-bottom)); }+ .composer-wrap { padding: 0 8px max(8px, calc(env(safe-area-inset-bottom) - 14px)); }.composer { border-radius: 22px; }/* the composer's buttons scroll sideways; the send button stays at the right edge */.controls { overflow-x: auto; scrollbar-width: none; margin-right: -2px; padding-right: 2px; }@@ -1031,7 +1062,14 @@ kbd { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px; display.controls .send:disabled { opacity: 1; background: var(--surface-3); color: var(--text-3); box-shadow: 0 0 0 4px var(--bg); }.controls .icon-btn[title="Prompt tips"] { display: none; }/* iOS zooms the page into any field under 16 px */- textarea, input[type="text"], input[type="password"], input[type="number"], .input, .select, .prompt { font-size: 16px; }+ textarea, input:not([type]), input[type="text"], input[type="password"], input[type="number"], input[type="search"], .input, .select, .prompt, .name-field, .name-field.title-field { font-size: 16px; }+ /* no double-tap zoom on buttons */+ body { touch-action: manipulation; }+ /* Added to the home screen, the bottom inset is the home bar (34 px on an iPhone): keep clear+ of it without the full gap Safari's own toolbar doesn't need. */+ .preview-bar { padding: 10px 12px max(14px, calc(env(safe-area-inset-bottom) - 6px)); }+ .preview-img { left: 0; width: 100%; }+ .toasts { left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); max-width: none; }.modal { width: 100vw; height: 100dvh; border-radius: 0; flex-direction: column; }.modal-nav { width: auto; flex: none; flex-direction: row; align-items: center; overflow-x: auto; gap: 4px; padding: calc(8px + env(safe-area-inset-top)) 8px 8px; scrollbar-width: none; }.modal-nav > button { flex: none; white-space: nowrap; }@@ -1049,5 +1087,5 @@ kbd { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px; display.modal-body { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }.path-row { flex-wrap: wrap; }.gallery-bar { padding: 0 10px 10px; flex-wrap: wrap; }- .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; padding: 4px 10px 20px; }+ .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; padding: 4px 10px calc(20px + env(safe-area-inset-bottom)); }}