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.

stage: the enhanced prompt scrolls when it is longer than the frame, and Stop stays visible

Gabriele Lozupone2d785754157a
diff --git a/src/components/Stage.tsx b/src/components/Stage.tsx
index aa229a3..6e94056 100644
--- a/src/components/Stage.tsx
+++ b/src/components/Stage.tsx
@@ -155,16 +155,26 @@ function PromptPhase(props: { title: string; text: string; streaming: boolean; w
visible.push(/^\s+$/.test(w) ? w : <span key={i} className="w" style={wordStyle(at, shown)}>{w}</span>);
at += w.length;
}
+ // Follow the new words only while the reader is at the bottom; scrolling up to reread stays put.
+ const follow = useRef(true);
useEffect(() => {
const el = ref.current;
- if (el && writing) el.scrollTop = el.scrollHeight;
+ if (el && writing && follow.current) el.scrollTop = el.scrollHeight;
}, [visible.length, writing]);
return (
<div className={`prompt-stage ${leave.leaving ? "leaving" : ""}`} style={{ transitionDuration: `${PROMPT_FADE_MS}ms`, ...leave.style }}>
<span className={`enhanced-label ${writing ? "shimmer" : ""}`}>
<WandSparkles size={13} /> {writing ? "Writing the prompt" : "The prompt"} · {props.title}
</span>
- <div className="prompt-text" ref={ref} aria-live="polite">
+ <div
+ className="prompt-text"
+ ref={ref}
+ aria-live="polite"
+ onScroll={(e) => {
+ const el = e.currentTarget;
+ follow.current = el.scrollHeight - el.scrollTop - el.clientHeight < 24;
+ }}
+ >
<div className="prompt-flow">
{text ? visible : <span className="enhanced-wait shimmer">{props.withImage ? "Looking at your image…" : "Reading your idea…"}</span>}
{writing && text && <i className="caret" />}
diff --git a/src/styles.css b/src/styles.css
index 72ff6c7..6787681 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -226,7 +226,7 @@ svg { display: block; flex: none; }
@keyframes indet { from { left: -30%; } to { left: 100%; } }
.notes { color: var(--text-3); font-size: 12px; max-width: 360px; }
/* prompt enhancer: its prompt fills the frame while it is written, then fades for the percentage */
-.prompt-stage { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 14px; width: 100%; height: 100%; padding: clamp(18px, 5%, 44px); transition-property: opacity, transform, filter; transition-timing-function: ease-in; }
+.prompt-stage { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; gap: 14px; padding: clamp(18px, 5%, 44px); transition-property: opacity, transform, filter; transition-timing-function: ease-in; }
.prompt-stage.leaving { opacity: 0; transform: scale(0.97); filter: blur(8px); }
.prompt-text { flex: 1; min-height: 0; overflow: auto; scrollbar-width: none; display: flex; flex-direction: column; white-space: pre-wrap; user-select: text; color: var(--text); font-size: clamp(15px, 2.1vw, 22px); line-height: 1.5; letter-spacing: -0.005em; text-shadow: 0 1px 18px color-mix(in srgb, var(--bg, #000) 70%, transparent); }
.prompt-flow { margin: auto 0; }