Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a7a5b44
fix(gallery): keep the previous preview through frame swaps
teamleaderleo Oct 7, 2026
246b05e
style(gallery): format frame swap stage
teamleaderleo Oct 7, 2026
3a6045a
fix(gallery): satisfy stage hook dependencies
teamleaderleo Oct 7, 2026
f537147
fix(gallery): retain the displayed frame until ready
teamleaderleo Oct 8, 2026
f5c4721
fix(gallery): keep frame refs stable during swaps
teamleaderleo Oct 8, 2026
d908e3d
Merge remote-tracking branch 'origin/feat-cmux-next' into fix/next-ga…
teamleaderleo Oct 8, 2026
b00bfde
style(gallery): wrap frame request check
teamleaderleo Oct 8, 2026
402a9fe
fix(gallery): ignore stale frame readiness
teamleaderleo Oct 8, 2026
404d830
Merge remote-tracking branch 'origin/feat-cmux-next' into fix/next-ga…
teamleaderleo Oct 8, 2026
69ebe29
fix gallery frame ref typing
teamleaderleo Oct 8, 2026
2b9172f
format gallery stage
teamleaderleo Oct 8, 2026
1e46b26
Merge feat-cmux-next and preserve gallery frame scroll intent
teamleaderleo Oct 8, 2026
b0d3270
Merge remote-tracking branch 'origin/feat-cmux-next' into fix/next-ga…
teamleaderleo Oct 8, 2026
1e0c0bb
ci: format staged files before commit (#18808)
teamleaderleo Oct 10, 2026
08cd108
ci: check rustfmt on the cmux-tui packages a PR touches (#18800)
teamleaderleo Oct 10, 2026
7a52911
ci: add mini-first Swift canary for cmux-next (#18781)
teamleaderleo Oct 10, 2026
c980cc5
cmux-next: repin app FFI to current base release (#18776)
teamleaderleo Oct 10, 2026
8da37f7
cmux-next: same-tree cmux-tui is a hard check only for PRs that chang…
teamleaderleo Oct 10, 2026
1beff16
fix(ci): keep cmux-next minis first through bot retries (#18615)
teamleaderleo Oct 10, 2026
5c0a0fc
docs(cmux-next): map UI parity reference sources (#18561)
teamleaderleo Oct 10, 2026
c08fa90
fix(nightly): bound the publish notes step at 10 minutes (#18404)
teamleaderleo Oct 10, 2026
0e4c30a
ci(cmux-next): retry bad R2 binary reads and let the tree gate pin it…
teamleaderleo Oct 10, 2026
d808aa1
ci(gallery): capture narrow responsive states (#18901)
teamleaderleo Oct 10, 2026
347d3de
Merge feat-cmux-next into fix/next-gallery-white-flash
teamleaderleo Oct 10, 2026
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
2 changes: 1 addition & 1 deletion webviews/src/gallery/shell/Shell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ function EntryView({ entry, address }: { entry: GalleryEntry; address: Address }
) : (
stages.map((stage) => (
<Stage
key={stage.key}
key={search.view === "variant" ? "stage" : stage.key}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Play report persists across variants

Low Severity

The variant-view Stage now keeps a stable key, but report is never cleared when query changes. The previous variant’s play metrics stay in the caption, and they remain indefinitely when the next variant has no play and never sends a replacement report.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1e46b26. Configure here.

entry={entry}
state={stage.variant}
env={stage.env}
Expand Down
120 changes: 88 additions & 32 deletions webviews/src/gallery/shell/Stage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// The gallery's stage and controls: a stage is an iframe of frame.html under the controls (in
// window mode the real-size window, scaled down by one transform); the controls edit the URL
// contract (env.ts). A developer tool: its own labels are English, like the native gallery's.
import { useCallback, useState } from "react";
import { useCallback, useEffect, useRef, useState } from "react";
import {
DEFAULT_ENV,
DENSITIES,
Expand Down Expand Up @@ -141,6 +141,51 @@ export function Stage({
const [run, setRun] = useState(0);
const [report, setReport] = useState<PlayReport | undefined>();
const hasPlay = Boolean(entry.variants[state]?.play);
const note = entry.variants[state]?.note;
// Component entries have their own natural bounds. Keep the window frame for page entries,
// but never make a component preview inherit the 16:9 window's scale.
const windowed = env.frame === "window" && entry.host !== "native" && entry.host !== "component";
let frame: { width: number; height: number };
let scale = 1;
if (windowed) {
// The surface lays out at the real size of its pane in that window; one transform scales the
// finished surface, so its aspect ratio, text and spacing stay as the user sees them.
frame = entryPaneSize(env.window, env.layout, env.density, metrics);
const thumbnailWidth = Math.min(THUMBNAIL_WIDTH, available.width);
scale = thumbnail ? thumbnailWidth / frame.width : env.zoom === "fit" ? fitScale(frame, available) : env.zoom;
} else {
// The pane's width; the interface scale zooms the page inside it, as pageZoom does.
frame = {
width: widthPx(env.width, entry.widths ?? (entry.host === "native" ? NATIVE_WIDTHS : WIDTHS)),
height: env.height || stageHeight(entry, state),
};
scale = env.zoom === "fit" ? fitScale(frame, available) : env.zoom;
}
const frameWidth = frame.width;
const frameHeight = frame.height;
type FrameState = { query: string; run: number; frame: { width: number; height: number }; scale: number };
const [display, setDisplay] = useState<FrameState>({ query, run, frame, scale });
const [pending, setPending] = useState<FrameState>();
const promotion = useRef(0);
const pendingRef = useRef<FrameState | undefined>(undefined);
pendingRef.current = pending;
useEffect(() => {
const requested = { query, run, frame: { width: frameWidth, height: frameHeight }, scale };
if (display.query === query && display.run === run) {
setDisplay((current) => ({ ...current, frame: requested.frame, scale }));
setPending(undefined);
return;
}
setPending((current) =>
current?.query === requested.query &&
current.run === requested.run &&
current.frame.width === frameWidth &&
current.frame.height === frameHeight &&
current.scale === scale
? current
: requested,
);
}, [display.query, display.run, frameHeight, frameWidth, query, run, scale]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale play report after swap

Low Severity

Variant view now reuses Stage across swaps, but report is never cleared when query or run change. After a new frame is promoted, the previous variant's play metrics can stay visible, especially when the incoming variant has no play and never posts a replacement.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 402a9fe. Configure here.

Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
const frameRef = useCallback((iframe: HTMLIFrameElement | null) => {
if (!iframe) return;
const scrollTarget = scrollTargetFor(iframe);
Expand Down Expand Up @@ -232,39 +277,53 @@ export function Stage({
removeIntentListeners();
};
const receive = (event: MessageEvent) => {
const data = event.data as { type?: string; status?: string; report?: PlayReport } | null;
if (event.source !== iframe.contentWindow) return;
const data = event.data as { type?: string; report?: PlayReport; status?: string } | null;
const query = iframe.dataset.galleryQuery;
const run = Number(iframe.dataset.galleryRun);
if (event.source !== iframe.contentWindow || !query || !Number.isFinite(run)) return;
if (data?.type === "cmux-gallery-play") setReport(data.report);
if (data?.type === "cmux-gallery-stage" && (data.status === "ready" || data.status === "error")) {
restore();
const pending = pendingRef.current;
if (!pending || pending.query !== query || pending.run !== run) return;
const token = ++promotion.current;
requestAnimationFrame(() => {
if (token !== promotion.current) return;
const current = pendingRef.current;
if (!current || current.query !== query || current.run !== run) return;
pendingRef.current = undefined;
setDisplay(current);
setPending(undefined);
});
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
}
};
addEventListener("message", receive);
return () => {
removeEventListener("message", receive);
removeIntentListeners();
promotion.current += 1;
};
}, []);
const note = entry.variants[state]?.note;
// Component entries have their own natural bounds. Keep the window frame for page entries,
// but never make a component preview inherit the 16:9 window's scale.
const windowed = env.frame === "window" && entry.host !== "native" && entry.host !== "component";
let frame: { width: number; height: number };
let scale = 1;
if (windowed) {
// The surface lays out at the real size of its pane in that window; one transform scales the
// finished surface, so its aspect ratio, text and spacing stay as the user sees them.
frame = entryPaneSize(env.window, env.layout, env.density, metrics);
const thumbnailWidth = Math.min(THUMBNAIL_WIDTH, available.width);
scale = thumbnail ? thumbnailWidth / frame.width : env.zoom === "fit" ? fitScale(frame, available) : env.zoom;
} else {
// The pane's width; the interface scale zooms the page inside it, as pageZoom does.
frame = {
width: widthPx(env.width, entry.widths ?? (entry.host === "native" ? NATIVE_WIDTHS : WIDTHS)),
height: env.height || stageHeight(entry, state),
};
scale = env.zoom === "fit" ? fitScale(frame, available) : env.zoom;
}
const shown = display;
const next = pending;
const iframe = (content: typeof shown, hidden: boolean) => (
<iframe
key={`${content.run}:${content.query}`}
ref={frameRef}
data-gallery-query={content.query}
data-gallery-run={content.run}
title={`${entry.id} ${state}`}
src={`frame.html?${content.query}`}
style={{
width: content.frame.width,
height: content.frame.height,
transform: `scale(${content.scale})`,
background: "var(--g-bg)",
...(hidden ? { position: "absolute", inset: 0, opacity: 0, pointerEvents: "none" } : {}),
}}
loading="lazy"
/>
);
return (
<figure className="gallery-stage">
<figcaption>
Expand Down Expand Up @@ -299,15 +358,12 @@ export function Stage({
</span>
)}
</figcaption>
<div className="gallery-window" style={{ width: frame.width * scale, height: frame.height * scale }}>
<iframe
key={run}
ref={frameRef}
title={`${entry.id} ${state}`}
src={`frame.html?${query}`}
style={{ width: frame.width, height: frame.height, transform: `scale(${scale})` }}
loading="lazy"
/>
<div
className="gallery-window"
style={{ width: shown.frame.width * shown.scale, height: shown.frame.height * shown.scale }}
>
{iframe(shown, false)}
{next && iframe(next, true)}
</div>
</figure>
);
Expand Down
2 changes: 2 additions & 0 deletions webviews/src/gallery/shell/shell.css
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,11 @@ body {
}
/* A plain neutral frame around the surface: no shape of the native window. */
.gallery-window {
position: relative;
overflow: hidden;
outline: 1px solid var(--g-line);
box-shadow: 0 2px 10px rgb(0 0 0 / 0.12);
background: var(--g-bg);
}
.gallery-window iframe {
transform-origin: 0 0;
Expand Down
Loading