Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions src/components/ShisoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ export function ShisoModal({
const sessionIdentity = shiso.snapshot?.sessionIdentity ?? null;

const scrollRef = useRef<HTMLDivElement | null>(null);
const imagePanelRef = useRef<HTMLElement | null>(null);

useEffect(() => {
if (isOpen) {
Expand Down Expand Up @@ -561,6 +562,16 @@ export function ShisoModal({
};
}, [isOpen, network, previewToken]);

// R2-V1: when a confirmation or preview appears, bring the WHOLE approval
// panel into view so the fixed composer can never hide Save / Regenerate /
// Cancel. This only scrolls the conversation thread, never the page.
useEffect(() => {
if (!isOpen || imageState.phase === 'idle') return;
const panel = imagePanelRef.current;
if (!panel || typeof panel.scrollIntoView !== 'function') return;
panel.scrollIntoView({ block: 'end', inline: 'nearest' });
}, [isOpen, imageState.phase, securePreviewUrl]);

const recipeContext = useShisoRecipeContext(recipe);
const nutritionRowsMatchRecipe = recipeContext !== null &&
recipeContext.ingredients.length === nutritionRows.length &&
Expand Down Expand Up @@ -1872,20 +1883,21 @@ export function ShisoModal({

{(imageState.phase !== 'idle' || imageState.message !== undefined) && (
<section
ref={imagePanelRef}
data-testid="shiso-image-panel"
className="rounded-xl border border-amber-500/25 bg-[#121212] px-3 py-3 space-y-2.5"
className="w-full max-w-[900px] rounded-2xl border border-amber-500/20 bg-[#101010] px-4 py-3.5 space-y-3 shadow-[0_20px_50px_-32px_rgba(0,0,0,0.95)]"
>
<div className="flex items-center justify-between gap-2">
<p className="text-xs font-semibold text-amber-100">Recipe image</p>
<span className="text-[10px] uppercase tracking-wider text-gray-400">
<p className="text-[13px] font-semibold text-amber-100">Recipe image</p>
<span className="text-[10px] uppercase tracking-[0.14em] text-amber-200/60">
{imageState.phase === 'confirming' ? 'Awaiting confirmation'
: imageState.phase === 'saved' ? 'Saved'
: imageState.phase === 'preview' ? 'Preview — not saved'
: imageState.phase === 'saving' ? 'Saving'
: 'Generating'}
</span>
</div>
<p className="text-[11px] text-gray-400">
<p className="text-[11px] leading-relaxed text-gray-400">
{imageRecipe?.title ?? 'Current recipe'} · Nothing is saved until you press Save Image.
</p>

Expand All @@ -1902,7 +1914,13 @@ export function ShisoModal({
data-testid="shiso-image-preview"
src={securePreviewUrl}
alt={`Generated image preview for ${imageRecipe?.title ?? 'the current recipe'}`}
className="max-h-72 w-full rounded-lg object-cover border border-white/10"
className="mx-auto block h-auto w-auto max-w-full max-h-[clamp(280px,38vh,340px)] rounded-xl border border-white/10 bg-black/20 object-contain"
onLoad={(event) => {
if (typeof event.currentTarget.scrollIntoView !== 'function') return;
event.currentTarget
.closest('[data-testid="shiso-image-panel"]')
?.scrollIntoView({ block: 'end', inline: 'nearest' });
}}
/>
)}
{imageState.preview !== undefined && securePreviewUrl === null && imageState.phase !== 'saving' && (
Expand All @@ -1924,14 +1942,14 @@ export function ShisoModal({
</p>
)}

<div className="flex flex-wrap items-center gap-2">
<div className="flex flex-wrap items-center gap-2 pt-0.5">
{imageState.phase === 'confirming' && (
<button
type="button"
data-testid="shiso-image-confirm"
disabled={imageBusy}
onClick={confirmImageGeneration}
className="rounded-lg bg-amber-500/20 px-2.5 py-1 text-[11px] font-semibold text-amber-100 border border-amber-500/40 hover:bg-amber-500/30 disabled:opacity-40"
className="rounded-lg bg-amber-500/15 px-3 py-1.5 text-[11px] font-semibold text-amber-100 border border-amber-500/40 hover:bg-amber-500/25 disabled:opacity-40"
>
Confirm generation
</button>
Expand All @@ -1942,7 +1960,7 @@ export function ShisoModal({
data-testid="shiso-image-save"
disabled={imageBusy}
onClick={saveGeneratedImage}
className="rounded-lg bg-emerald-500/20 px-2.5 py-1 text-[11px] font-semibold text-emerald-100 border border-emerald-500/40 hover:bg-emerald-500/30 disabled:opacity-40"
className="rounded-lg bg-amber-500 px-3 py-1.5 text-[11px] font-semibold text-black hover:bg-amber-400 disabled:opacity-40"
>
Save Image
</button>
Expand All @@ -1953,7 +1971,7 @@ export function ShisoModal({
data-testid="shiso-image-regenerate"
disabled={imageBusy}
onClick={regenerateImage}
className="rounded-lg border border-white/15 px-2.5 py-1 text-[11px] text-gray-200 hover:bg-white/5 disabled:opacity-40"
className="rounded-lg border border-white/15 px-3 py-1.5 text-[11px] text-gray-200 hover:bg-white/5 disabled:opacity-40"
>
Regenerate
</button>
Expand All @@ -1964,7 +1982,7 @@ export function ShisoModal({
data-testid="shiso-image-cancel"
disabled={false}
onClick={cancelImage}
className="rounded-lg border border-white/15 px-2.5 py-1 text-[11px] text-gray-300 hover:bg-white/5"
className="rounded-lg border border-white/10 px-3 py-1.5 text-[11px] text-gray-400 hover:bg-white/5 hover:text-gray-200"
>
Cancel
</button>
Expand All @@ -1974,7 +1992,7 @@ export function ShisoModal({
type="button"
data-testid="shiso-image-done"
onClick={cancelImage}
className="rounded-lg border border-white/15 px-2.5 py-1 text-[11px] text-gray-300 hover:bg-white/5"
className="rounded-lg border border-white/10 px-3 py-1.5 text-[11px] text-gray-400 hover:bg-white/5 hover:text-gray-200"
>
Done
</button>
Expand Down
6 changes: 3 additions & 3 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -1903,7 +1903,7 @@ summary:focus-visible,

.kc-shiso-workspace-shell {
display: grid;
grid-template-columns: clamp(280px, 20.2vw, 300px) minmax(0, 1fr);
grid-template-columns: clamp(292px, 19.5vw, 320px) minmax(0, 1fr);
grid-template-rows: minmax(0, 1fr);
width: 100%;
height: 100%;
Expand Down Expand Up @@ -2255,9 +2255,9 @@ summary:focus-visible,
overscroll-behavior: contain;
scrollbar-gutter: stable;
gap: 12px;
scroll-padding-block: 18px;
scroll-padding-block: 18px 24px;
min-height: 0;
padding: 18px 36px 16px;
padding: 18px 36px 20px;
background:
radial-gradient(60% 72% at 54% 8%, color-mix(in srgb, var(--accent-text, #F59E0B) 7%, transparent), transparent 74%),
var(--bg-root, #0C0C0C);
Expand Down