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
feat: one-time star-on-GitHub card after 5 images made with the app
Gabriele Lozuponeb35410534567
diff --git a/src/App.tsx b/src/App.tsxindex f8f6ef0..352195d 100644--- a/src/App.tsx+++ b/src/App.tsx@@ -1,10 +1,10 @@import { getCurrentWebview } from "@tauri-apps/api/webview";-import { ArrowDownToLine, CircleHelp, EyeOff, PanelLeft, Redo2, Settings, SquarePen, Undo2, X } from "lucide-react";+import { ArrowDownToLine, CircleHelp, EyeOff, PanelLeft, Redo2, Settings, SquarePen, Star, Undo2, X } from "lucide-react";import { useEffect, useRef, useState } from "react";import { api, configure } from "./lib/api";import { native } from "./lib/native";import {- addExampleProjects, addInputs, dismissToast, getState, isMissingModel, newProject, openModelSetup, redoVersion, refreshStatus, selectItem, setPrivateMode, setState, startEvents, startTour, submitComposer, toastError, toastInfo, undoKey, undoVersion, useStore,+ addExampleProjects, addInputs, closeStarPrompt, dismissToast, getState, initStarPrompt, isMissingModel, newProject, openModelSetup, redoVersion, refreshStatus, selectItem, setPrivateMode, setState, startEvents, startTour, submitComposer, toastError, toastInfo, undoKey, undoVersion, useStore,} from "./lib/store";import { Composer, importPaths } from "./components/Composer";import { ExpandEditor } from "./components/ExpandEditor";@@ -25,6 +25,7 @@ import { KokonMark, Welcome } from "./components/Welcome";import { autoCheckForUpdate, installUpdate } from "./lib/updates";const IMAGE_EXT = /\.(png|jpe?g|webp|bmp|gif|tiff?|heic|heif)$/i;+const REPO_URL = "https://github.com/GabrieleLozupone/kokon";function StatusIndicator() {const connected = useStore((s) => s.connected);@@ -144,6 +145,7 @@ function Toasts() {const [open, setOpen] = useState<string | null>(null);return (<div className="toasts" role="status">+ <StarPrompt />{toasts.map((t) => (<div key={t.id} className="toast"><div className="body">@@ -165,6 +167,35 @@ function Toasts() {);}+/** Once, after a few images made with Kokon (store.ts): a star helps other people find it. */+function StarPrompt() {+ const on = useStore((s) => s.starPrompt);+ if (!on) return null;+ const star = () => {+ native.openLink(REPO_URL).catch(toastError);+ closeStarPrompt();+ };+ return (+ <div className="star-prompt">+ <div className="body">+ <strong>Enjoying Kokon?</strong>+ <div className="sugg">A star on GitHub helps other people find it. This is the only time we ask.</div>+ <div className="star-actions">+ <button className="btn primary" onClick={star}>+ <Star size={14} /> Star on GitHub+ </button>+ <button className="btn ghost" onClick={closeStarPrompt}>+ No thanks+ </button>+ </div>+ </div>+ <button onClick={closeStarPrompt} aria-label="Dismiss">+ <X size={14} />+ </button>+ </div>+ );+}+async function uploadBlobs(files: File[]) {const recs = [];for (const f of files) {@@ -208,6 +239,7 @@ export default function App() {// First launch: the welcome screen, once (Settings → General shows it again).const ui = (cfg.ui ?? {}) as Record<string, unknown>;const welcomeSeen = !!ui.welcomeSeen;+ initStarPrompt(ui);// ...with example projects to look at, and the tour through the first one.if (!welcomeSeen && !ui.tourSeen) {tourPending.current = true;diff --git a/src/lib/logic.test.ts b/src/lib/logic.test.tsindex 3c6aabf..249f710 100644--- a/src/lib/logic.test.ts+++ b/src/lib/logic.test.ts@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";import {activeOverrides, buildRequest, compareBase, diffPixels, emptyComposer, expansionPixels, expansionPreset, jobFraction, jobLabel, moveRef, needsPrompt, normalizeQuality, persistentAdvanced, pipelineSummary,planPipeline, remainingSeconds, sizeForWidth, timeAgo, upscaleRequest, upscaleTargets, versionLabels, type Ref,- neighbourAfterRemoval, previewIndex, formatBytes, formatDuration, installItemShort, installItemText, installProgress, installStep, installTimeLeft, timelineLinks, undoTarget, aspectLabel, parseRatio, sizeForRatio, expandToRatio, expandToSize, arcLayout,+ neighbourAfterRemoval, previewIndex, starPromptDue, STAR_PROMPT_AFTER, formatBytes, formatDuration, installItemShort, installItemText, installProgress, installStep, installTimeLeft, timelineLinks, undoTarget, aspectLabel, parseRatio, sizeForRatio, expandToRatio, expandToSize, arcLayout,} from "./logic";import type { GenerationRecord, InstallItem, JobView, Plan } from "./types";@@ -400,3 +400,12 @@ describe("formatDuration", () => {expect(formatDuration(3900)).toBe("65m");});});++describe("star prompt", () => {+ it("waits for enough images and a free screen", () => {+ expect(starPromptDue(STAR_PROMPT_AFTER - 1, false)).toBe(false);+ expect(starPromptDue(STAR_PROMPT_AFTER, true)).toBe(false);+ expect(starPromptDue(STAR_PROMPT_AFTER, false)).toBe(true);+ expect(starPromptDue(STAR_PROMPT_AFTER + 3, false)).toBe(true);+ });+});diff --git a/src/lib/logic.ts b/src/lib/logic.tsindex 6649419..fa56825 100644--- a/src/lib/logic.ts+++ b/src/lib/logic.ts@@ -682,3 +682,12 @@ export function neighbourAfterRemoval(ids: string[], id: string): string | nullif (i < 0) return null;return ids[i + 1] ?? ids[i - 1] ?? null;}++/** Images made with the app before the one-time "star on GitHub" card. */+export const STAR_PROMPT_AFTER = 5;++/** Whether to show the star card now: enough images made, and nothing else on screen (a dialog,+ * the tour or setup), else it waits for the next finished image. */+export function starPromptDue(made: number, busy: boolean): boolean {+ return made >= STAR_PROMPT_AFTER && !busy;+}diff --git a/src/lib/store.ts b/src/lib/store.tsindex 9a2a00c..080b46c 100644--- a/src/lib/store.ts+++ b/src/lib/store.ts@@ -7,7 +7,7 @@import { useSyncExternalStore } from "react";import { api, ApiError, setPrivateInputs, subscribe } from "./api";-import { buildRequest, emptyComposer, needsPrompt, newKey, persistentAdvanced, refFromGen, refFromInput, timelineLinks, undoTarget, versionLabels, type CompareMode, type Composer, type Ref } from "./logic";+import { buildRequest, emptyComposer, needsPrompt, newKey, persistentAdvanced, refFromGen, refFromInput, starPromptDue, timelineLinks, undoTarget, versionLabels, type CompareMode, type Composer, type Ref } from "./logic";import type { AppErrorBody, GenerationRecord, GenerationRequest, InputRecord, JobView, ServerState, StatusResponse } from "./types";export type Overlay = null | "gallery" | "settings" | "inpaint" | "expand" | "welcome" | "whats-new" | "prompt-tips" | "shortcuts";@@ -85,6 +85,8 @@ export interface State {redo: string[];/** Step of the first-run tour on screen (components/Tour.tsx), or null. */tour: number | null;+ /** The one-time "star on GitHub" card is on screen (App.tsx). */+ starPrompt: boolean;}const PREFS_KEY = "qls.prefs.v1";@@ -289,6 +291,7 @@ let state: State = {privateMode: false,redo: [],tour: null,+ starPrompt: false,};const listeners = new Set<() => void>();@@ -399,6 +402,8 @@ function onJob(job: JobView) {if (job.status === "failed" && prev?.status !== "failed" && isMissingModel(job.error) && job.finished_at && Date.now() - Date.parse(job.finished_at) < 60_000) {openModelSetup();}+ // Made with this app (it had a pending version), not by another client such as MCP.+ let made = false;setState((s) => {const jobs = { ...s.jobs, [job.id]: job };if (job.status !== "done") return { jobs };@@ -406,6 +411,7 @@ function onJob(job: JobView) {// Replace the pending version with one version per result.const idx = s.session.findIndex((i) => i.jobId === job.id && i.kind === "job");if (idx >= 0) {+ made = true;const pending = s.session[idx];const session = [...s.session.slice(0, idx), ...results, ...s.session.slice(idx + 1)];const wasSelected = s.selected === pending.key;@@ -421,6 +427,7 @@ function onJob(job: JobView) {for (const p of Object.values(projects)) {const k = p.items.findIndex((i) => i.jobId === job.id && i.kind === "job");if (k < 0) continue;+ made = true;const stored = results.map(toStored);for (const g of job.results) genCache.set(g.id, g);const wasSelected = p.selected === p.items[k].key;@@ -433,9 +440,47 @@ function onJob(job: JobView) {// A job from another client (e.g. MCP): track it but do not add it to a project.return { jobs };});+ if (made && job.results.length) countImageMade();if (job.status === "failed" && job.error) toastError(new ApiError(job.error, 500));}+// ---------------------------------------------------------------------------------------+// Star prompt: once, after a few images made with the app, never again whatever the answer.+// ---------------------------------------------------------------------------------------++const MADE_KEY = "kokon.imagesMade";+/** Config `ui.starPromptSeen`; true until read at start, so nothing shows before that. */+let starSeen = true;++export function initStarPrompt(ui: Record<string, unknown>) {+ starSeen = !!ui.starPromptSeen;+}++function countImageMade() {+ if (starSeen) return;+ let made: number;+ try {+ made = (Number(localStorage.getItem(MADE_KEY)) || 0) + 1;+ localStorage.setItem(MADE_KEY, String(made));+ } catch {+ return;+ }+ const s = getState();+ if (!starPromptDue(made, s.overlay !== null || s.tour !== null || s.needsSetup)) return;+ starSeen = true;+ setState({ starPrompt: true });+ api+ .config()+ .then((cfg) => api.saveConfig({ ...cfg, ui: { ...((cfg.ui ?? {}) as Record<string, unknown>), starPromptSeen: true } }))+ .catch(() => {+ /* only means it may show once more after a restart */+ });+}++export function closeStarPrompt() {+ setState({ starPrompt: false });+}+// ---------------------------------------------------------------------------------------// Projects// ---------------------------------------------------------------------------------------diff --git a/src/styles.css b/src/styles.cssindex 53c0c5b..048aa77 100644--- a/src/styles.css+++ b/src/styles.css@@ -338,6 +338,12 @@ pre.diag { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font.toast .sugg { opacity: 0.75; margin-top: 2px; }.toast pre { white-space: pre-wrap; word-break: break-all; font-size: 11px; max-height: 160px; overflow: auto; opacity: 0.8; margin: 8px 0 0; user-select: text; }.toast button { color: inherit; opacity: 0.7; font-size: 12px; }+.star-prompt { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 14px 14px 12px 16px; box-shadow: var(--shadow); font-size: 13px; display: flex; gap: 10px; align-items: flex-start; line-height: 1.45; }+.star-prompt .body { flex: 1; min-width: 0; }+.star-prompt .sugg { color: var(--text-2); margin-top: 2px; }+.star-prompt > button { color: var(--text-3); }+.star-actions { display: flex; gap: 6px; margin-top: 10px; }+.star-actions .btn { height: 30px; padding: 0 12px; }.drop-hint { position: absolute; inset: 12px; z-index: 35; border: 2px dashed var(--text-2); border-radius: 18px; display: grid; place-items: center; background: var(--scrim); pointer-events: none; font-size: 15px; color: var(--text); }.spin { animation: spin 0.9s linear infinite; }