Skip to content

Stop paying the multimodal tax. Your AI agent keeps every image it has seen but only sends the ones it needs: lighter chats, no endless reconnecting, no starting over. Works with Codex, Claude Code, Cline, Gemini CLI, OpenCode, WorkBuddy and more. Install once, forget it.

fix(panel): support Ctrl+wheel image zoom

chipfighterd50683601218
diff --git a/plugin/src/panel.html b/plugin/src/panel.html
index dcdf96e..23bf171 100644
--- a/plugin/src/panel.html
+++ b/plugin/src/panel.html
@@ -201,7 +201,7 @@
.viewer-title { flex: 1; min-width: 0; display: flex; gap: 8px; align-items: baseline; font-size: 14px; }
.viewer-title .vid { flex: none; font-weight: 600; font-variant-numeric: tabular-nums; }
.viewer-title .vname { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: rgb(255 255 255 / 62%); }
- .viewer-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 14px; }
+ .viewer-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 14px; overflow: hidden; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.viewer-stage .none { color: rgb(255 255 255 / 55%); font-size: 12.5px; }
.viewer-stage.loading img { filter: blur(6px); opacity: .7; }
@@ -671,7 +671,7 @@
error: null, // { key, message }: said in the current language when drawn
unsaved: new Map(), // id -> on, switched and shown already, saved by the next call (v0.1-22)
thumbs: new Map(), // id -> data URL or null
- preview: null, // { id, url, loading }
+ preview: null, // { id, url, loading, zoom }
refreshing: false, saving: false,
switching: false, // a 启用插件 / 停用插件 call is under way
switchingTask: false, // a cam_bind call is under way
@@ -1336,6 +1336,7 @@
if (!img) { img = document.createElement("img"); stage.replaceChildren(img); }
img.alt = nameOf(image) ?? image.id;
if (img.src !== url) img.src = url;
+ img.style.transform = `scale(${S.preview.zoom})`;
} else stage.replaceChildren(Object.assign(document.createElement("span"), { className: "none", textContent: t(S.preview.loading ? "preview.loading" : "preview.none") }));
const control = $("viewerCheck");
const label = t(autoOn() ? "preview.pin" : "preview.send");
@@ -1349,13 +1350,13 @@
let returnTo = null;
function openPreview(id) {
returnTo = id;
- S.preview = { id, url: null, loading: true };
+ S.preview = { id, url: null, loading: true, zoom: 1 };
renderViewer();
$("viewerClose").focus({ focusVisible: false });
const side = Math.min(2048, Math.max(800, Math.round(Math.max(window.innerWidth, window.innerHeight) * (window.devicePixelRatio || 1))));
loadImage(id, side)
- .then((url) => { if (S.preview?.id === id) S.preview = { id, url, loading: false }; })
- .catch(() => { if (S.preview?.id === id) S.preview = { id, url: null, loading: false }; })
+ .then((url) => { if (S.preview?.id === id) S.preview = { ...S.preview, url, loading: false }; })
+ .catch(() => { if (S.preview?.id === id) S.preview = { ...S.preview, url: null, loading: false }; })
.finally(() => { if (S.preview?.id === id) renderViewer(); });
}
function closePreview() {
@@ -1368,6 +1369,15 @@
function previewControls() {
return [...$("viewer").querySelectorAll("button, input")].filter((el) => !el.disabled && !el.closest("[hidden]") && getComputedStyle(el).display !== "none" && getComputedStyle(el).visibility !== "hidden");
}
+ $("viewerStage").addEventListener("wheel", (event) => {
+ if (!event.ctrlKey || !S.preview) return;
+ const img = $("viewerStage").querySelector("img");
+ if (!img) return;
+ event.preventDefault();
+ const delta = event.deltaY * (event.deltaMode === 1 ? 16 : event.deltaMode === 2 ? $("viewerStage").clientHeight : 1);
+ S.preview.zoom = Math.min(10, Math.max(0.1, S.preview.zoom * Math.exp(-delta * 0.002)));
+ img.style.transform = `scale(${S.preview.zoom})`;
+ }, { passive: false });
// A click anywhere but on the image, a button or the checkbox closes the preview.
$("viewer").addEventListener("click", (event) => { if (!event.target.closest("img, button, .check")) closePreview(); });
$("viewerClose").addEventListener("click", closePreview);
diff --git a/spike/src/panel-state.test.ts b/spike/src/panel-state.test.ts
index 960f559..33c8c18 100644
--- a/spike/src/panel-state.test.ts
+++ b/spike/src/panel-state.test.ts
@@ -262,7 +262,7 @@ test("the task's panel lists its subagents and side chats with their last reques
]);
});
-test("the image preview dialog traps Tab and Shift+Tab across visible enabled controls and restores focus on close", () => {
+test("the image preview supports Ctrl+wheel zoom and preserves keyboard and backdrop behavior", async () => {
const html = readFileSync(join(import.meta.dirname, "..", "..", "plugin", "src", "panel.html"), "utf8");
const messagesJson = /<script type="application\/json" id="messages">([\s\S]*?)<\/script>/.exec(html)![1];
const scriptCode = /<script>\s*(\(\(\) => \{[\s\S]*?\}\)\(\);)\s*<\/script>/.exec(html)![1];
@@ -386,6 +386,15 @@ test("the image preview dialog traps Tab and Shift+Tab across visible enabled co
for (const fn of docListeners.get("keydown") ?? []) fn(event);
return event;
};
+ const wheel = (deltaY: number, ctrlKey = true) => {
+ const event = { type: "wheel", deltaY, deltaMode: 0, ctrlKey, defaultPrevented: false, preventDefault() { this.defaultPrevented = true; } };
+ viewerStage.dispatchEvent(event);
+ return event;
+ };
+ const scale = () => {
+ const img = viewerStage.querySelector("img");
+ return img ? Number(/^scale\((.+)\)$/.exec(img.style.transform ?? "")?.[1] ?? 1) : NaN;
+ };
const [tile1, tile2] = byId.get("main")!.querySelectorAll("button");
tile1.focus();
@@ -393,6 +402,18 @@ test("the image preview dialog traps Tab and Shift+Tab across visible enabled co
assert.equal(documentObj.activeElement, tile1);
tile1.click();
+ await new Promise((resolve) => setImmediate(resolve));
+ assert.equal(scale(), 1, "a preview starts fitted to its panel");
+ assert.equal(wheel(-100, false).defaultPrevented, false, "ordinary scrolling is not intercepted");
+ assert.equal(scale(), 1);
+ assert.equal(wheel(-100).defaultPrevented, true, "Ctrl+wheel prevents page zoom");
+ assert.ok(scale() > 1, "Ctrl+wheel up enlarges the image");
+ assert.equal(wheel(100).defaultPrevented, true);
+ assert.ok(Math.abs(scale() - 1) < 1e-10, "Ctrl+wheel down shrinks the image");
+ wheel(-1e6);
+ assert.ok(Number.isFinite(scale()) && scale() > 1 && scale() <= 10, "large wheel deltas have a bounded scale");
+ wheel(1e6);
+ assert.ok(scale() > 0 && scale() < 1, "zooming out never collapses or flips the image");
assert.deepEqual([viewer.hidden, viewerInput.disabled, documentObj.activeElement], [false, false, viewerClose]);
assert.equal(keydown("Tab").defaultPrevented, true);
assert.equal(documentObj.activeElement, viewerInput, "Tab moves from close button to checkbox");
@@ -409,8 +430,12 @@ test("the image preview dialog traps Tab and Shift+Tab across visible enabled co
keydown("Escape");
assert.deepEqual([viewer.hidden, documentObj.activeElement], [true, tile1], "Escape closes and restores focus to opening tile");
+ assert.equal(wheel(-100).defaultPrevented, false, "Ctrl+wheel is ignored when the preview is closed");
tile2.click();
+ await new Promise((resolve) => setImmediate(resolve));
+ assert.equal(scale(), 1, "opening another image resets the scale");
+ wheel(-100);
assert.deepEqual([viewer.hidden, viewerInput.disabled, documentObj.activeElement], [false, true, viewerClose]);
assert.equal(keydown("Tab").defaultPrevented, true);
assert.equal(documentObj.activeElement, viewerClose, "Tab skips disabled checkbox");