Skip to content

Your lightweight open-source personal agent.

fix(webui): keep zoomed Mermaid images sharp

chengyongrue44ebb164d8f
diff --git a/webui/browser/diagrams.spec.ts b/webui/browser/diagrams.spec.ts
index ae0e89336..3d034c805 100644
--- a/webui/browser/diagrams.spec.ts
+++ b/webui/browser/diagrams.spec.ts
@@ -39,8 +39,10 @@ test("same-source completion loads a real Pele image only after generation, with
await page.keyboard.press("Enter");
const dialog = page.getByRole("dialog");
await expect(dialog).toBeVisible();
- await dialog.getByRole("button", { name: "Zoom in" }).click();
- await expect(dialog.getByRole("button", { name: "Fit image" })).toHaveText("150%");
+ for (let step = 0; step < 3; step++) await dialog.getByRole("button", { name: "Zoom in" }).click();
+ await expect(dialog.getByRole("button", { name: "Fit image" })).toHaveText("338%");
+ // CDP screenshots can hide fit-size raster caching, so check the compositor hint.
+ await expect(dialog.locator("img")).toHaveCSS("will-change", "auto");
const viewport = dialog.getByTestId("image-viewport");
await viewport.focus();
await page.keyboard.press("0");
diff --git a/webui/src/components/ui/image-viewport.tsx b/webui/src/components/ui/image-viewport.tsx
index c311a6822..e3afca759 100644
--- a/webui/src/components/ui/image-viewport.tsx
+++ b/webui/src/components/ui/image-viewport.tsx
@@ -140,7 +140,7 @@ export function ImageViewport({
event.stopPropagation();
}}>
<img ref={image} src={src} alt={alt} decoding="async" draggable={false} onLoad={() => apply(viewRef.current)}
- className={cn("max-h-full max-w-full select-none object-contain will-change-transform", imageClassName)}
+ className={cn("max-h-full max-w-full select-none object-contain", imageClassName)}
style={{ transform: `translate3d(${view.x}px, ${view.y}px, 0) scale(${view.scale})` }} />
</div>
<div className={cn("flex items-center justify-center gap-1 rounded-full p-1 text-muted-foreground", controlsClassName)}>