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.
TypeScript ai-agentsai-imageclaude-codeclaude-code-pluginclinecodexcodex-plugincomputer-usecontext-engineeringcontext-managementdeveloper-toolsgemini-cliimage-generationmcpmultimodalmultimodal-aiopencodeqwen-codetoken-optimizationvision-language-model
fix(panel): 适配 Codex 26.924 的面板高度;整轮勾选点一下立即保存
chipfighter417b2ff4eaab
diff --git a/plugin/src/panel.html b/plugin/src/panel.htmlindex f0ab3ae..a66b197 100644--- a/plugin/src/panel.html+++ b/plugin/src/panel.html@@ -21,7 +21,9 @@v0.1-17: with many images, the ones the model asked for ("需要 IMG-xxx") and the user has not checked are listed ina bar under the request size; clicking one scrolls the list to its row and flashes the row twice.v0.1-18: a checkbox at the end of a turn's line (when it has two or more images that can change) checks or- unchecks all of them at once, staged like single changes; it shows a dash while only some are checked.+ unchecks all of them at once; it shows a dash while only some are checked. v0.1-21: it saves at once, without 确定.+ v0.1-21: Codex 26.924 gives the page no fixed height, only the most it may take, and shows as much as the page asks+ for (MCP Apps size-changed); the page asks for all of it, and fits a smaller frame if that is what it gets.--><style>/* Fallbacks follow Codex's own widget palette; inside Codex its theme variables (MCP Apps host styles) win. */@@ -56,6 +58,8 @@}* { box-sizing: border-box; }html, body { height: 100%; margin: 0; }+ /* v0.1-21: the height this page asked Codex for (fitFrame), never less than the frame it was given. */+ html.asks-height, html.asks-height body { height: max(var(--frame-height), 100vh); }body {display: flex; flex-direction: column; overflow: hidden;background: var(--bg); color: var(--text); font: 13px/1.5 var(--font);@@ -521,14 +525,45 @@if (variables && typeof variables === "object") {for (const [name, value] of Object.entries(variables)) if (name.startsWith("--") && typeof value === "string") document.documentElement.style.setProperty(name, value);}+ if (context.containerDimensions) fitFrame(context.containerDimensions);}+ // ---- v0.1-21: the frame's height ----+ // Codex 26.924 gives the page no fixed height, only the most it may take (containerDimensions), and shows as much of+ // the page as it asks for (ui/notifications/size-changed). A page as tall as its frame asked for nothing, and the+ // panel was cut to 200 px (user 2026-09-27). So the page asks for all it may take; if the frame it then gets is+ // smaller (a host may cap it), it fits that frame, so the footer stays in view. A fixed height is simply filled.+ const frame = { asked: 0, timer: 0 };+ function fitFrame(dimensions) {+ const height = Math.floor(Number(dimensions.height) || Number(dimensions.maxHeight) || 0);+ if (height > 0) askFrame(height);+ }+ function askFrame(height) {+ document.documentElement.classList.add("asks-height");+ document.documentElement.style.setProperty("--frame-height", `${height}px`);+ if (height === frame.asked) return;+ frame.asked = height;+ reportFrame();+ settleLater();+ }+ const reportFrame = () => { if (frame.asked) post({ method: "ui/notifications/size-changed", params: { height: frame.asked } }); };+ // Judged once the frame has stopped changing: a host may resize it in steps.+ function settleLater() {+ clearTimeout(frame.timer);+ frame.timer = setTimeout(() => {+ const shown = window.innerHeight;+ if (shown > 0 && shown < frame.asked) askFrame(shown);+ }, 1500);+ }+ window.addEventListener("resize", () => { if (frame.asked) settleLater(); });+// ---- state ----const S = {data: null, threadId: null,error: null, // { key, message }: said in the current language when drawnflash: null, // a text keypending: new Map(), // id -> checked, changes not confirmed yet+ applying: new Map(), // id -> checked, a turn's change being saved (v0.1-21), shown as done meanwhilethumbs: new Map(), // id -> data URL or nullviewer: null, // { id, url, loading, failed }refreshing: false, saving: false,@@ -545,7 +580,7 @@let screenGap = true;const images = () => S.data?.images ?? [];const byId = (id) => images().find((image) => image.id === id);- const isChecked = (image) => (S.pending.has(image.id) ? S.pending.get(image.id) : image.checked);+ const isChecked = (image) => (S.pending.has(image.id) ? S.pending.get(image.id) : S.applying.has(image.id) ? S.applying.get(image.id) : image.checked);function ingest(state) {if (!state || !Array.isArray(state.images)) return;@@ -596,26 +631,30 @@render();}- async function confirm() {- if (!S.pending.size || S.saving) return;- const changes = [...S.pending];+ // Saves checks and unchecks (cam_set_selection); returns the thread's state after the change, or null on failure.+ async function save(check, uncheck) {S.saving = true; render();try {- const result = await callTool("cam_set_selection", {- uncheck: changes.filter(([, checked]) => !checked).map(([id]) => id),- check: changes.filter(([, checked]) => checked).map(([id]) => id),- });- S.pending.clear();+ const result = await callTool("cam_set_selection", { uncheck, check });S.flash = "footer.saved";setTimeout(() => { S.flash = null; renderFooter(); }, 4000);- ingest(result.structuredContent);+ return result.structuredContent;} catch (error) {S.error = { key: "error.save", message: error.message };+ return null;} finally {- S.saving = false; render();+ S.saving = false;}}+ async function confirm() {+ if (!S.pending.size || S.saving) return;+ const changes = [...S.pending];+ const state = await save(changes.filter(([, checked]) => checked).map(([id]) => id), changes.filter(([, checked]) => !checked).map(([id]) => id));+ if (state) { S.pending.clear(); ingest(state); }+ render();+ }+// ---- a panel opened on a new chat follows the thread its first message starts (v0.1-10) ----// The plugin offers only threads started while this page was on screen, so a panel left on another new chat does not// take a task started elsewhere. One: switch to it. Several (e.g. two windows side by side): the user picks one.@@ -778,14 +817,16 @@input.indeterminate = checked > 0 && checked < targets.length;input.disabled = S.saving;}- // Staged like single changes: blue dots, 撤销, and nothing saved before 确定.- function setTurn(turn, checked) {+ // Saved at once, without 确定 (v0.1-21, user 2026-09-27); it replaces changes staged for this turn's images, and+ // leaves those staged for other images alone.+ async function setTurn(turn, checked) {if (S.saving) return;- for (const image of images()) {- if (image.turn !== turn || !changeable(image)) continue;- if (image.checked === checked) S.pending.delete(image.id); else S.pending.set(image.id, checked);- }- S.flash = null;+ const ids = images().filter((image) => image.turn === turn && changeable(image)).map((image) => image.id);+ if (!ids.length) return;+ for (const id of ids) { S.pending.delete(id); S.applying.set(id, checked); }+ const state = await save(checked ? ids : [], checked ? [] : ids);+ S.applying.clear();+ if (state) ingest(state);render();}@@ -1096,7 +1137,7 @@if (window.matchMedia?.("(prefers-color-scheme: dark)").matches) document.documentElement.dataset.theme = "dark";applyLanguage();request("ui/initialize", { protocolVersion: "2026-01-26", appInfo: { name: "codex-attachment-manager", version: "0.1.0" }, appCapabilities: {} })- .then((init) => { applyHost(init?.hostContext); post({ method: "ui/notifications/initialized", params: {} }); })+ .then((init) => { applyHost(init?.hostContext); post({ method: "ui/notifications/initialized", params: {} }); reportFrame(); }).catch(() => {}).finally(() => setTimeout(() => { if (!S.data) refresh(); }, 1200));// Slower, not stopped, while the page reports itself hidden: a host frame may report that wrongly.diff --git a/spike/scripts/panel-dev.ts b/spike/scripts/panel-dev.tsindex 072e279..b1ce421 100644--- a/spike/scripts/panel-dev.ts+++ b/spike/scripts/panel-dev.ts@@ -159,6 +159,7 @@ const HOST = `<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><titiframe { flex: 1; border: 0; width: 100%; }.tools { position: fixed; left: 10px; top: 10px; display: flex; gap: 6px; } .tools button { font: inherit; }body.solo .chat, body.solo .tools, body.solo .tabs { display: none; } body.solo .panel { width: 100%; border: 0; }+ body.sized iframe { flex: none; height: 200px; }</style></head><body><div class="tools"><button id="theme">切换明暗</button><button id="grow">加一张图</button></div><div class="chat">(对话区)</div><div class="panel"><div class="tabs"><span class="tab">上下文素材</span></div><iframe id="app"></iframe></div><script>@@ -170,6 +171,13 @@ const HOST = `<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><titdocument.body.classList.toggle("solo", params.has("solo"));const frame = document.getElementById("app");const send = (message) => frame.contentWindow.postMessage({ jsonrpc: "2.0", ...message }, "*");+ // ?host=924: like Codex 26.924, which gives the page no fixed height, only the most it may take (containerDimensions),+ // and shows as much as the page asks for (size-changed): 200 px until it asks. &cap=N caps the frame, as a host may.+ const sized = params.get("host") === "924";+ const cap = Number(params.get("cap")) || Infinity;+ document.body.classList.toggle("sized", sized);+ const dimensions = () => ({ maxHeight: frame.parentElement.clientHeight - frame.offsetTop, maxWidth: frame.clientWidth });+ if (sized) window.addEventListener("resize", () => send({ method: "ui/notifications/host-context-changed", params: { containerDimensions: dimensions() } }));// ?thread=fresh: a thread that has no rollout, like a panel opened on a new chat whose prepared thread was replaced.// Each page load gets a thread of its own, so a switch made on an earlier load does not carry over.const fresh = params.get("thread") === "fresh" ? Math.random().toString(16).slice(2, 6).padEnd(4, "0") : null;@@ -178,7 +186,8 @@ const HOST = `<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><titwindow.addEventListener("message", async (event) => {const m = event.data;if (!m || event.source !== frame.contentWindow) return;- if (m.method === "ui/initialize") send({ id: m.id, result: { protocolVersion: "2026-01-26", hostInfo: { name: "panel-dev" }, hostCapabilities: { serverTools: {} }, hostContext: { theme, displayMode: "inline", locale: params.get("lang") === "en" ? "en-US" : "zh-CN" } } });+ if (m.method === "ui/initialize") send({ id: m.id, result: { protocolVersion: "2026-01-26", hostInfo: { name: "panel-dev" }, hostCapabilities: { serverTools: {} }, hostContext: { theme, displayMode: "inline", locale: params.get("lang") === "en" ? "en-US" : "zh-CN", ...(sized ? { containerDimensions: dimensions() } : {}) } } });+ else if (m.method === "ui/notifications/size-changed") { if (sized) frame.style.height = Math.min(m.params.height, dimensions().maxHeight, cap) + "px"; }else if (m.method === "ui/notifications/initialized") { send({ method: "ui/notifications/tool-result", params: await call("cam_panel", {}) }); demo(); }else if (m.method === "tools/call") { const delay = params.get("slow") ? 900 : 60; const result = await call(m.params.name, m.params.arguments); setTimeout(() => send({ id: m.id, result }), delay); }});