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(lut): eight built-in looks shipped with the app
Gabriele Lozupone673850839106
diff --git a/crates/qls-core/src/lut.rs b/crates/qls-core/src/lut.rsindex 784079b..662f6a8 100644--- a/crates/qls-core/src/lut.rs+++ b/crates/qls-core/src/lut.rs@@ -1,6 +1,9 @@//! Colour LUTs in the `.cube` format (Adobe / DaVinci Resolve): parsing, applying one to an//! image at an intensity, and the folder of LUTs the user has opened (most recent first).//!+//! Kokon also ships a few looks of its own ([`PRESETS`]), built from simple colour math (no+//! third-party LUT files), listed with ids `kokon:<key>`.+//!//! 3D tables use tetrahedral interpolation (what Resolve and most graders use), 1D tables//! linear interpolation per channel. Values are display-referred: the image's 8-bit sRGB//! values go in as 0-1 (through `DOMAIN_MIN`/`DOMAIN_MAX`), like every grading tool does.@@ -45,6 +48,20 @@ fn floats<const N: usize>(rest: &str, line: usize) -> Result<[f32; N], String> {}impl Lut {+ /// A 3D table of `size` entries per axis computed from a colour function (components 0-1).+ pub fn from_fn(title: &str, size: usize, f: impl Fn([f32; 3]) -> [f32; 3]) -> Lut {+ let top = (size - 1) as f32;+ let mut table = Vec::with_capacity(size * size * size);+ for b in 0..size {+ for g in 0..size {+ for r in 0..size {+ table.push(f([r as f32 / top, g as f32 / top, b as f32 / top]).map(|v| v.clamp(0.0, 1.0)));+ }+ }+ }+ Lut { title: Some(title.into()), kind: LutKind::ThreeD, size, domain_min: [0.0; 3], domain_max: [1.0; 3], table }+ }+/// Parses a `.cube` file. Errors are short, user-facing reasons.pub fn parse(text: &str) -> Result<Lut, String> {let mut title = None;@@ -178,11 +195,80 @@ impl Lut {/// A LUT in the library, for the picker.#[derive(Debug, Clone, Serialize)]pub struct LutEntry {- /// File name without `.cube`; the LUT's id in the API.+ /// The LUT's id in the API: the file name without `.cube`, or `kokon:<key>` for a preset.pub name: String,+ /// The `.cube` file's TITLE; a preset's display name.pub title: Option<String>,pub kind: LutKind,pub size: usize,+ /// One of Kokon's presets (always listed, can't be removed).+ pub builtin: bool,+}++/// One of the looks Kokon ships.+pub struct Preset {+ pub key: &'static str,+ pub title: &'static str,+ look: fn([f32; 3]) -> [f32; 3],+}++const PRESET_PREFIX: &str = "kokon:";+const PRESET_SIZE: usize = 33;++fn luma([r, g, b]: [f32; 3]) -> f32 {+ 0.2126 * r + 0.7152 * g + 0.0722 * b+}++/// Per-channel gains, then the original luminance restored: a colour shift that keeps brightness.+fn tint(c: [f32; 3], gains: [f32; 3]) -> [f32; 3] {+ let t = [c[0] * gains[0], c[1] * gains[1], c[2] * gains[2]];+ let (l0, l1) = (luma(c), luma(t));+ if l1 <= 1e-6 { t } else { t.map(|v| v * l0 / l1) }+}++fn saturate(c: [f32; 3], s: f32) -> [f32; 3] {+ let l = luma(c);+ c.map(|v| l + (v - l) * s)+}++/// S-curve contrast around mid grey (`k` 0 = none, 1 = a full smoothstep).+fn contrast(c: [f32; 3], k: f32) -> [f32; 3] {+ c.map(|v| {+ let v = v.clamp(0.0, 1.0);+ v + k * (v * v * (3.0 - 2.0 * v) - v)+ })+}++/// Lifts the blacks to `lift` and lowers the whites to `1 - roll`.+fn fade(c: [f32; 3], lift: f32, roll: f32) -> [f32; 3] {+ c.map(|v| lift + v * (1.0 - lift - roll))+}++/// Kokon's presets, in the order the picker shows them.+pub const PRESETS: &[Preset] = &[+ // Qwen-Image tends to a warm, yellowish cast: pull it back towards neutral.+ Preset { key: "neutral", title: "Neutral (less yellow)", look: |c| tint(c, [0.97, 0.985, 1.08]) },+ Preset { key: "warm", title: "Warm", look: |c| tint(c, [1.06, 1.0, 0.9]) },+ Preset { key: "cool", title: "Cool", look: |c| tint(c, [0.93, 0.995, 1.09]) },+ Preset {+ key: "teal-orange",+ title: "Teal & Orange",+ look: |c| {+ let l = luma(c);+ let (sh, hi) = ((1.0 - l) * (1.0 - l), l * l);+ let t = [c[0] - 0.05 * sh + 0.05 * hi, c[1] + 0.01 * sh + 0.01 * hi, c[2] + 0.06 * sh - 0.06 * hi];+ contrast(saturate(t, 1.08), 0.12)+ },+ },+ Preset { key: "vivid", title: "Vivid", look: |c| contrast(saturate(c, 1.3), 0.2) },+ Preset { key: "soft-film", title: "Soft Film", look: |c| tint(fade(saturate(contrast(c, 0.15), 0.9), 0.04, 0.03), [1.02, 1.0, 0.97]) },+ Preset { key: "matte", title: "Matte", look: |c| fade(saturate(c, 0.85), 0.08, 0.04) },+ Preset { key: "black-white", title: "Black & White", look: |c| contrast([luma(c); 3], 0.2) },+];++fn preset(name: &str) -> Option<&'static Preset> {+ let key = name.strip_prefix(PRESET_PREFIX)?;+ PRESETS.iter().find(|p| p.key == key)}/// The LUTs the user has opened, copied into the app's data folder so they stay available@@ -234,16 +320,16 @@ impl LutLibrary {v}- /// The library, most recently used first (files that no longer parse are skipped).+ /// The user's LUTs, most recently used first (files that no longer parse are skipped),+ /// then Kokon's presets.pub fn list(&self) -> Vec<LutEntry> {- self.files()- .into_iter()- .filter_map(|(p, _)| {- let name = p.file_stem()?.to_string_lossy().into_owned();- let lut = Lut::parse(&std::fs::read_to_string(&p).ok()?).ok()?;- Some(LutEntry { name, title: lut.title, kind: lut.kind, size: lut.size })- })- .collect()+ let own = self.files().into_iter().filter_map(|(p, _)| {+ let name = p.file_stem()?.to_string_lossy().into_owned();+ let lut = Lut::parse(&std::fs::read_to_string(&p).ok()?).ok()?;+ Some(LutEntry { name, title: lut.title, kind: lut.kind, size: lut.size, builtin: false })+ });+ let presets = PRESETS.iter().map(|p| LutEntry { name: format!("{PRESET_PREFIX}{}", p.key), title: Some(p.title.into()), kind: LutKind::ThreeD, size: PRESET_SIZE, builtin: true });+ own.chain(presets).collect()}/// Copies a `.cube` file into the library (the same file opened again is not duplicated).@@ -272,10 +358,13 @@ impl LutLibrary {}self.touch(&name);self.prune();- Ok(LutEntry { name, title: lut.title, kind: lut.kind, size: lut.size })+ Ok(LutEntry { name, title: lut.title, kind: lut.kind, size: lut.size, builtin: false })}pub fn load(&self, name: &str) -> AppResult<Lut> {+ if let Some(p) = preset(name) {+ return Ok(Lut::from_fn(p.title, PRESET_SIZE, p.look));+ }let p = self.path(name)?;let text = std::fs::read_to_string(&p).map_err(|_| AppError::new(ErrorCode::NotFound, format!("The LUT \"{name}\" is no longer in Kokon's LUT list.")))?;Lut::parse(&text).map_err(|why| invalid(format!("This LUT can't be used: {why}.")))@@ -291,6 +380,9 @@ impl LutLibrary {}pub fn remove(&self, name: &str) -> AppResult<()> {+ if preset(name).is_some() {+ return Err(invalid("Kokon's own LUTs can't be removed."));+ }let p = self.path(name)?;match std::fs::remove_file(&p) {Ok(()) => Ok(()),@@ -385,6 +477,43 @@ mod tests {}}+ #[test]+ fn presets_are_listed_after_the_users_luts_and_behave() {+ let dir = tempfile::tempdir().unwrap();+ let lib = LutLibrary::new(dir.path().join("luts"));+ let list = lib.list();+ assert_eq!(list.len(), PRESETS.len(), "presets even with no LUT folder yet");+ assert!(list.iter().all(|e| e.builtin && e.name.starts_with("kokon:") && e.title.is_some()));+ let grey = [0.5, 0.5, 0.5];+ let get = |k: &str| lib.load(&format!("kokon:{k}")).unwrap();+ let n = get("neutral").map([0.8, 0.75, 0.55]);+ assert!(n[2] > 0.55 && n[0] < 0.8, "less yellow: {n:?}");+ let w = get("warm").map(grey);+ assert!(w[0] > w[2]);+ let c = get("cool").map(grey);+ assert!(c[2] > c[0]);+ let bw = get("black-white").map([0.9, 0.2, 0.4]);+ assert!((bw[0] - bw[1]).abs() < 1e-4 && (bw[1] - bw[2]).abs() < 1e-4);+ assert!(get("matte").map([0.0; 3])[0] > 0.05, "lifted blacks");+ for p in PRESETS {+ let lut = get(p.key);+ for v in [[0.0; 3], [1.0; 3], [0.2, 0.6, 0.9], grey] {+ assert!(lut.map(v).iter().all(|x| (0.0..=1.0).contains(x)), "{}", p.key);+ }+ // Mid grey stays roughly mid grey: looks, not exposure changes.+ assert!((luma(lut.map(grey)) - 0.5).abs() < 0.06, "{} {:?}", p.key, lut.map(grey));+ }+ assert!(lib.remove("kokon:warm").is_err());+ assert!(lib.load("kokon:nope").is_err());+ // A user's own file comes first.+ let src = dir.path().join("Mine.cube");+ std::fs::write(&src, cube3(2, |c| c)).unwrap();+ lib.import(&src).unwrap();+ let list = lib.list();+ assert_eq!((list[0].name.as_str(), list[0].builtin), ("Mine", false));+ assert_eq!(list.len(), PRESETS.len() + 1);+ }+#[test]fn library_imports_lists_recent_first_and_removes() {let dir = tempfile::tempdir().unwrap();@@ -402,11 +531,11 @@ mod tests {assert_eq!(b.name, "Warm Film-2");std::thread::sleep(std::time::Duration::from_millis(20));lib.touch("Warm Film");- let names: Vec<_> = lib.list().into_iter().map(|e| e.name).collect();+ let names: Vec<_> = lib.list().into_iter().filter(|e| !e.builtin).map(|e| e.name).collect();assert_eq!(names, ["Warm Film", "Warm Film-2"]);assert_eq!(lib.load("Warm Film-2").unwrap().size, 3);lib.remove("Warm Film").unwrap();- assert_eq!(lib.list().len(), 1);+ assert_eq!(lib.list().iter().filter(|e| !e.builtin).count(), 1);assert!(lib.load("../secret").is_err());assert_eq!(display_name(" a:b?.cube. "), "a-b-.cube");let bad = dir.path().join("bad.cube");diff --git a/src/components/Lut.tsx b/src/components/Lut.tsxindex 4130d65..962d665 100644--- a/src/components/Lut.tsx+++ b/src/components/Lut.tsx@@ -1,6 +1,7 @@import { Eye, FolderOpen, Loader2, Palette, X } from "lucide-react";import { useEffect, useState } from "react";import { api } from "../lib/api";+import { lutLabel } from "../lib/logic";import { native } from "../lib/native";import { toastError } from "../lib/store";import type { LutEntry } from "../lib/types";@@ -18,26 +19,31 @@ async function openCubeFile(): Promise<LutEntry | null> {}}-function LutList({ current, onPick, close }: { current?: string; onPick: (name: string) => void; close: () => void }) {+function LutList({ current, onPick, close }: { current?: string; onPick: (lut: LutEntry) => void; close: () => void }) {const [items, setItems] = useState<LutEntry[] | null>(null);useEffect(() => {api.luts().then((r) => setItems(r.items), toastError);}, []);- const pick = (name: string) => {+ const pick = (e: LutEntry) => {close();- onPick(name);+ onPick(e);};+ const own = items?.filter((e) => !e.builtin) ?? [];+ const presets = items?.filter((e) => e.builtin) ?? [];+ const row = (e: LutEntry) => (+ <button className="opt" onClick={() => pick(e)} title={!e.builtin && e.title && e.title !== e.name ? e.title : undefined}>+ <span className="check">{e.name === current ? <Palette size={15} /> : null}</span>+ <span className="lut-name">{lutLabel(e)}</span>+ {!e.builtin && <span className="sub">{e.kind === "3d" ? `${e.size}³` : "1D"}</span>}+ </button>+ );return (<div className="lut-list">- <span className="muted lut-list-title">Colour LUTs (.cube)</span>{items === null && <Loader2 className="spin" size={16} style={{ margin: 10 }} />}- {items?.map((e) => (+ {own.length > 0 && <span className="muted lut-list-title">Your LUTs</span>}+ {own.map((e) => (<div key={e.name} className="lut-row">- <button className="opt" onClick={() => pick(e.name)} title={e.title && e.title !== e.name ? e.title : undefined}>- <span className="check">{e.name === current ? <Palette size={15} /> : null}</span>- <span className="lut-name">{e.name}</span>- <span className="sub">{e.kind === "3d" ? `${e.size}³` : "1D"}</span>- </button>+ {row(e)}<buttonclassName="icon-btn sm"title="Remove from the list"@@ -48,12 +54,18 @@ function LutList({ current, onPick, close }: { current?: string; onPick: (name:</button></div>))}+ {presets.length > 0 && <span className="muted lut-list-title">Kokon presets</span>}+ {presets.map((e) => (+ <div key={e.name} className="lut-row">+ {row(e)}+ </div>+ ))}<buttonclassName="opt"onClick={async () => {close();const e = await openCubeFile();- if (e) onPick(e.name);+ if (e) onPick(e);}}><span className="check">@@ -65,9 +77,9 @@ function LutList({ current, onPick, close }: { current?: string; onPick: (name:);}-/** "LUT" under the image: the LUTs opened before, or a .cube file (straight to the file- * picker while the list is empty). `current` shows the LUT being previewed as its label. */-export function LutButton({ current, onPick }: { current?: string; onPick: (name: string) => void }) {+/** "LUT" under the image: Kokon's presets, the LUTs opened before, or a .cube file.+ * `current` (the LUT being previewed) is shown as its label. */+export function LutButton({ current, onPick }: { current?: LutEntry; onPick: (lut: LutEntry) => void }) {return (<Popoverplacement="top-end"@@ -76,20 +88,14 @@ export function LutButton({ current, onPick }: { current?: string; onPick: (nameclassName={`act ${open ? "active" : ""}`}title={current ? "Choose another LUT" : "LUT: apply a colour look from a .cube file (preview first, the original is kept)"}aria-label="LUT"- onClick={async () => {- if (open || current) return toggle();- const { items } = await api.luts().catch(() => ({ items: [] as LutEntry[] }));- if (items.length) return toggle();- const e = await openCubeFile();- if (e) onPick(e.name);- }}+ onClick={toggle}><Palette size={16} />- <span className={current ? "lut-current" : "act-label"}>{current ?? "LUT"}</span>+ <span className={current ? "lut-current" : "act-label"}>{current ? lutLabel(current) : "LUT"}</span></button>)}>- {(close) => <LutList current={current} onPick={onPick} close={close} />}+ {(close) => <LutList current={current?.name} onPick={onPick} close={close} />}</Popover>);}@@ -120,10 +126,10 @@ export function LutOverlay({ src, opacity }: { src: string; opacity: number }) {/** Replaces the actions while a LUT is previewed: which LUT, how strong, before/after, save. */export function LutBar(props: {- name: string;+ lut: LutEntry;intensity: number;saving: boolean;- onPick: (name: string) => void;+ onPick: (lut: LutEntry) => void;onIntensity: (v: number) => void;onBefore: (on: boolean) => void;onCancel: () => void;@@ -132,7 +138,7 @@ export function LutBar(props: {const pct = Math.round(props.intensity * 100);return (<div className="actions lut-bar">- <LutButton current={props.name} onPick={props.onPick} />+ <LutButton current={props.lut} onPick={props.onPick} /><label className="lut-intensity" title="Intensity"><input type="range" min={0} max={100} value={pct} aria-label="Intensity" onChange={(e) => props.onIntensity(Number(e.target.value) / 100)} /><span>{pct} %</span>diff --git a/src/components/Stage.tsx b/src/components/Stage.tsxindex 5c3cb57..28d583e 100644--- a/src/components/Stage.tsx+++ b/src/components/Stage.tsx@@ -4,14 +4,14 @@ import {import { Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";import { api, urls } from "../lib/api";import {- compareBase, composerFromRecord, formatDuration, jobFraction, jobLabel, lutInfo, MAX_UPSCALE_AREA, MAX_UPSCALE_SIDE, MODE_LABEL, pipelineSummary, remainingSeconds, sizeForWidth, upscaleRequest, arcLayout,+ compareBase, composerFromRecord, formatDuration, jobFraction, jobLabel, lutInfo, lutLabel, MAX_UPSCALE_AREA, MAX_UPSCALE_SIDE, MODE_LABEL, pipelineSummary, remainingSeconds, sizeForWidth, upscaleRequest, arcLayout,upscalerLabel, upscaleTargets, variationRequest, imageName, type LinkKind, type TimelineLink,} from "../lib/logic";import { native } from "../lib/native";import {addAsReference, addResult, cancelJob, focusPrompt, getState, itemSource, removeSessionItem, reusePrompt, selectedItem, selectItem, sessionLabels, sessionLinks, setState, submitRequest, toastError, toastInfo, useStore, type SessionItem,} from "../lib/store";-import type { GenerationRecord, JobView, Mode, Size } from "../lib/types";+import type { GenerationRecord, JobView, LutEntry, Mode, Size } from "../lib/types";import { CompareFrame, CompareFullscreen } from "./Compare";import { LutBar, LutButton, LutOverlay } from "./Lut";import { IconButton, Popover, useFit } from "./ui";@@ -138,7 +138,7 @@ function InfoPanel({ g }: { g: GenerationRecord }) {const rows: [string, string][] = lut ? [["Mode", MODE_LABEL[g.mode]],["Size", `${g.width}×${g.height}`],- ["LUT", lut.title && lut.title !== lut.name ? `${lut.name} (${lut.title})` : lut.name],+ ["LUT", !lut.name.startsWith("kokon:") && lut.title && lut.title !== lut.name ? `${lut.name} (${lut.title})` : lutLabel(lut)],["Intensity", `${Math.round(lut.intensity * 100)} %`],["Created", new Date(g.created_at).toLocaleString()],] : [@@ -287,7 +287,7 @@ function MoreMenu({ item, path }: { item: SessionItem; path: string | null }) {);}-function GenActions({ item, g, showOriginal, onLut }: { item: SessionItem; g: GenerationRecord; showOriginal: boolean; onLut: (name: string) => void }) {+function GenActions({ item, g, showOriginal, onLut }: { item: SessionItem; g: GenerationRecord; showOriginal: boolean; onLut: (lut: LutEntry) => void }) {// Save, copy and "show in folder" act on the image on screen: the result or its pre-upscale original.const shownPath = (showOriginal && g.pipeline?.original_path) || g.file_path;const original = g.references[0] && g.mode !== "generate" && g.mode !== "upscale" && g.mode !== "lut" ? { width: g.references[0].width, height: g.references[0].height } : null;@@ -374,7 +374,7 @@ function GenActions({ item, g, showOriginal, onLut }: { item: SessionItem; g: Ge);}-function InputActions({ item, onLut }: { item: SessionItem; onLut: (name: string) => void }) {+function InputActions({ item, onLut }: { item: SessionItem; onLut: (lut: LutEntry) => void }) {const input = item.input!;return (<div className="actions">@@ -404,7 +404,7 @@ function PlainFrame({ src, alt, w, h, maskSrc, overlay, onFullscreen }: { src: s}/** Under the image: which image this is and what made it, then what you can do with it. */-function StageBar(props: { item: SessionItem; label: string; showOriginal: boolean; setShowOriginal: (on: boolean) => void; lutBar: React.ReactNode; onLut: (name: string) => void }) {+function StageBar(props: { item: SessionItem; label: string; showOriginal: boolean; setShowOriginal: (on: boolean) => void; lutBar: React.ReactNode; onLut: (lut: LutEntry) => void }) {const { item, label, showOriginal, setShowOriginal } = props;const g = item.gen;const lut = g && lutInfo(g);@@ -418,7 +418,7 @@ function StageBar(props: { item: SessionItem; label: string; showOriginal: boole<span className="ver">{imageName(label)}</span>{g && <span className="mode">{MODE_LABEL[g.mode]}</span>}<span className="stage-prompt" title={g?.prompt ?? name}>- {g ? g.prompt || (g.mode === "upscale" ? `${g.references[0]?.width ?? "?"}×${g.references[0]?.height ?? "?"} → ${w}×${h}` : lut ? `${lut.name} · ${Math.round(lut.intensity * 100)} %` : "") : name}+ {g ? g.prompt || (g.mode === "upscale" ? `${g.references[0]?.width ?? "?"}×${g.references[0]?.height ?? "?"} → ${w}×${h}` : lut ? `${lutLabel(lut)} · ${Math.round(lut.intensity * 100)} %` : "") : name}</span>{from && !props.lutBar ? (<span className="seg dims-seg" role="radiogroup" aria-label="Which image to show">@@ -712,7 +712,7 @@ export function Stage() {const [full, setFull] = useState(false);const canFull = !!item && viewable(item);// A LUT being previewed on the selected version (intensity 0-1), before saving it as a new one.- const [lut, setLut] = useState<{ itemKey: string; source: string; name: string; intensity: number } | null>(null);+ const [lut, setLut] = useState<{ itemKey: string; source: string; lut: LutEntry; intensity: number } | null>(null);const [before, setBefore] = useState(false);const [saving, setSaving] = useState(false);const lutActive = lut && item && lut.itemKey === item.key ? lut : null;@@ -794,13 +794,13 @@ export function Stage() {const from = g?.pipeline?.original_path ? g.pipeline.enlarged_from : null;const showOriginal = !!(g && from && originalOf === g.id) && !lutActive;const source = g ? `gen:${g.id}` : `input:${item.input!.id}`;- const startLut = (name: string) => setLut((l) => ({ itemKey: item.key, source, name, intensity: l?.intensity ?? lastIntensity }));+ const startLut = (e: LutEntry) => setLut((l) => ({ itemKey: item.key, source, lut: e, intensity: l?.intensity ?? lastIntensity }));const saveLut = async () => {if (!lutActive) return;setSaving(true);try {lastIntensity = lutActive.intensity;- const rec = await api.applyLut(lutActive.name, lutActive.source, lutActive.intensity, getState().privateMode);+ const rec = await api.applyLut(lutActive.lut.name, lutActive.source, lutActive.intensity, getState().privateMode);setLut(null);addResult(rec);} catch (e) {@@ -813,7 +813,7 @@ export function Stage() {const previewMax = Math.min(Math.max(w, h), Math.round(1600 * Math.min(2, window.devicePixelRatio || 1)), 4096);const lutBar = lutActive && (<LutBar- name={lutActive.name}+ lut={lutActive.lut}intensity={lutActive.intensity}saving={saving}onPick={startLut}@@ -832,7 +832,7 @@ export function Stage() {alt={g?.prompt ?? item.input?.original_name ?? ""}w={w}h={h}- overlay={<LutOverlay src={urls.lutPreview(lutActive.name, lutActive.source, previewMax)} opacity={before ? 0 : lutActive.intensity} />}+ overlay={<LutOverlay src={urls.lutPreview(lutActive.lut.name, lutActive.source, previewMax)} opacity={before ? 0 : lutActive.intensity} />}onFullscreen={openFull}/>) : g && from && showOriginal ? (diff --git a/src/lib/logic.ts b/src/lib/logic.tsindex 467c1cf..5a418b6 100644--- a/src/lib/logic.ts+++ b/src/lib/logic.ts@@ -194,6 +194,11 @@ export const MODE_LABEL: Record<Mode | "lut", string> = {lut: "LUT",};+/** How a LUT is shown: a preset ("kokon:<key>") by its title, a user's LUT by its file name. */+export function lutLabel(l: { name: string; title?: string | null }): string {+ return l.name.startsWith("kokon:") ? l.title || l.name.slice(6) : l.name;+}+/** The LUT a "lut" result was made with. */export function lutInfo(g: GenerationRecord): LutInfo | null {return g.mode === "lut" ? ((g.request as unknown as { lut?: LutInfo } | null)?.lut ?? null) : null;diff --git a/src/lib/types.ts b/src/lib/types.tsindex 15a0ae7..98794ba 100644--- a/src/lib/types.ts+++ b/src/lib/types.ts@@ -143,8 +143,8 @@ export interface GenerationRecord {pipeline?: PipelineRecord | null;}-/** A .cube LUT in Kokon's list (most recently used first). */-export interface LutEntry { name: string; title: string | null; kind: "1d" | "3d"; size: number }+/** A .cube LUT in Kokon's list (the user's, most recently used first, then Kokon's presets). */+export interface LutEntry { name: string; title: string | null; kind: "1d" | "3d"; size: number; builtin: boolean }/** How a "lut" result was made (in its `request`). */export interface LutInfo { name: string; title?: string | null; intensity: number }