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
feat(panel): 页头列出模型要了、还没勾上的图,点编号跳到那一行并闪两下(v0.1-17)
chipfighterf3f7a60cb8e4
diff --git a/plugin/src/panel.html b/plugin/src/panel.htmlindex f1a120c..6195018 100644--- a/plugin/src/panel.html+++ b/plugin/src/panel.html@@ -18,6 +18,8 @@was deleted); the images left are listed as usual.v0.1-14: Simplified Chinese or English, following Codex's interface language (the host context's locale; else thesystem's). Every call tells the plugin the language, so its answers match and the text for the model follows it.+ v0.1-17: with many images, the ones the model asked for ("需要 IMG-xxx") and the user has not checked are listed in+ a bar under the request size; clicking one scrolls the list to its row and flashes the row twice.--><style>/* Fallbacks follow Codex's own widget palette; inside Codex its theme variables (MCP Apps host styles) win. */@@ -92,6 +94,11 @@.bar i { display: block; height: 100%; border-radius: inherit; background: var(--info); transition: width .25s ease; }.last { margin-top: 8px; color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }.last:empty { display: none; }+ /* v0.1-17: stays in the header, so after jumping to one image the next one is still a click away. */+ .needs { margin-top: 10px; padding: 6px 8px 6px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 12.5px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }+ .needs button { height: 22px; padding: 0 9px; border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); border-radius: 999px; background: var(--bg); color: var(--warn); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer; transition: border-color .15s, transform .1s; }+ .needs button:hover { border-color: var(--warn); }+ .needs button:active { transform: scale(.96); }main { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 18px; border-top: 1px solid var(--border); scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }.turn { display: flex; align-items: center; gap: 10px; margin: 18px 8px 6px; color: var(--text-3); font-size: 12px; font-weight: 500; }@@ -101,6 +108,13 @@.row { position: relative; display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; transition: background .15s; }.row:hover { background: var(--bg-hover); }.row.pending { background: var(--info-bg); }+ /* Two flashes on the row picked in the bar above. */+ .row.flash { animation: flash 1.2s ease-in-out; }+ @keyframes flash {+ 0%, 50%, 100% { box-shadow: inset 0 0 0 0 transparent; }+ 20%, 30%, 70%, 80% { box-shadow: inset 0 0 0 2px var(--warn); background: var(--warn-bg); }+ }+ @media (prefers-reduced-motion: reduce) { .row.flash { animation: none; box-shadow: inset 0 0 0 2px var(--warn); } }.thumb {position: relative; flex: none; width: 64px; height: 64px; padding: 0; border: 1px solid var(--border);border-radius: 10px; background: var(--bg-soft); overflow: hidden; cursor: zoom-in;@@ -204,6 +218,7 @@<div class="bar"><i id="meterBar"></i></div></div><div class="last" id="last"></div>+ <div class="needs" id="needs" hidden></div></header><main id="main"></main><footer>@@ -260,6 +275,8 @@"tag.locked": "无法取消","tag.gone": "已不在上下文","tag.requested": "模型需要这张",+ "needs.title": "模型需要 {count} 张没发送的图:",+ "needs.jump": "在列表里定位到 {id}","tag.replacedBy": "由 {id} 代替","tag.notSent": "不发送","tag.sameAs": "与 {id} 相同",@@ -344,6 +361,9 @@"tag.locked": "Can't uncheck","tag.gone": "No longer in context","tag.requested": "The model needs this",+ "needs.title": "The model needs {count} unsent images:",+ "needs.title_one": "The model needs {count} unsent image:",+ "needs.jump": "Show {id} in the list","tag.replacedBy": "Replaced by {id}","tag.notSent": "Not sent","tag.sameAs": "Same as {id}",@@ -866,6 +886,52 @@for (const button of box.children) button.disabled = S.switching;}+ // ---- v0.1-17: the images the model asked for that are not checked (the same test as the row's tag) ----+ // Rebuilt only when that list changes, so hover and focus survive the polling.+ let needsKey = "";+ function renderNeeds() {+ const needed = images().filter((image) => image.requested && image.inNextRequest && image.replaceable && !isChecked(image));+ const box = $("needs");+ const key = needed.length ? `${lang}|${needed.map((image) => image.id).join(",")}` : "";+ box.hidden = !key;+ if (key === needsKey) return;+ needsKey = key;+ box.replaceChildren(...(key ? [+ Object.assign(document.createElement("span"), { textContent: t("needs.title", { count: needed.length }) }),+ ...needed.map((image) => {+ const button = Object.assign(document.createElement("button"), { type: "button", textContent: image.id, title: t("needs.jump", { id: image.id }) });+ button.addEventListener("click", () => jumpTo(image.id));+ return button;+ }),+ ] : []));+ }++ // Scrolls the row to the middle of the list, then flashes it; the keyboard focus goes to its checkbox (Space checks it).+ let flashAfterScroll = null;+ main.addEventListener("scrollend", () => flashAfterScroll?.());+ function jumpTo(id) {+ const row = rows.get(id);+ if (!row) return;+ row.querySelector("input").focus({ preventScroll: true });+ const box = row.getBoundingClientRect();+ const view = main.getBoundingClientRect();+ const top = Math.max(0, Math.min(main.scrollHeight - main.clientHeight, main.scrollTop + box.top + box.height / 2 - view.top - view.height / 2));+ if (Math.abs(top - main.scrollTop) < 2) { flash(row); return; }+ // Flash once the scrolling stops; a later jump replaces this one.+ const go = () => { if (flashAfterScroll !== go) return; flashAfterScroll = null; flash(row); };+ flashAfterScroll = go;+ setTimeout(go, 1000);+ main.scrollTo({ top, behavior: "smooth" });+ }+ const flashTimers = new Map();+ function flash(row) {+ clearTimeout(flashTimers.get(row));+ row.classList.remove("flash");+ void row.offsetWidth; // restarts the animation when the same row is picked again+ row.classList.add("flash");+ flashTimers.set(row, setTimeout(() => { row.classList.remove("flash"); flashTimers.delete(row); }, 1300));+ }+function renderRefresh() {const button = $("refresh");const stale = lastFresh > 0 && Date.now() - lastFresh > STALE_MS;@@ -950,7 +1016,7 @@}}- function render() { renderHeader(); renderPlugin(); renderRefresh(); renderList(); renderFooter(); renderViewer(); }+ function render() { renderHeader(); renderNeeds(); renderPlugin(); renderRefresh(); renderList(); renderFooter(); renderViewer(); }let focusBeforeViewer = null;function openViewer(id) {diff --git a/spike/scripts/panel-dev.ts b/spike/scripts/panel-dev.tsindex 4a94685..072e279 100644--- a/spike/scripts/panel-dev.ts+++ b/spike/scripts/panel-dev.ts@@ -6,7 +6,8 @@// ?stats=none|skipped|websocket for other engine statistics than a normal rewritten request, ?setup=off for a Codex that// does not go through the engine yet, ?demo=disabled for right after 停用插件, ?thread=fresh for a task with no rollout;// with &newtask=1 the user then starts one task — the panel switches to it — and with &newtask=2 two at once;-// ?thread=gap for a fork whose original task was deleted, v0.1-13; ?lang=en for Codex in English, v0.1-14).+// ?thread=gap for a fork whose original task was deleted, v0.1-13; ?lang=en for Codex in English, v0.1-14;+// ?thread=many for a task with 45 images whose last reply asks for two unchecked ones, v0.1-17).// The demo task has a name, as if the user had renamed it in Codex (v0.1-9).// Everything is written to a temporary folder, including a Codex home of its own: nothing in the user's Codex home is// read or changed, whatever is clicked.@@ -67,8 +68,33 @@ writeFileSync(join(day, `rollout-2026-09-24T11-00-00-${GAP}.jsonl`),line("session_meta", { id: GAP, forked_from_id: "01a0d301-0000-7000-8000-00000000dead", history_base: { thread_id: "01a0d301-0000-7000-8000-00000000dead", end_byte_offset: 4096 } }) +turn("g1") + upload("msg_g1", "g1", [["after-fork.png", sunset]]));-// Its name, as Codex keeps it next to the sessions folder (the panel's title).+// ?thread=many: 45 images over 11 turns; two large ones (about 3 MB each) are unchecked and the last reply asks for them.+const MANY = `${THREAD.slice(0, -4)}a045`;+const noiseOf = (seed: number) => {+ let state = seed;+ const next = () => { state ^= state << 13; state ^= state >>> 17; state ^= state << 5; return state & 0xff; };+ return png(1024, 1024, () => [next(), next(), next()]);+};+let shot = 0;+const photo = (): [string, Buffer] => {+ const n = ++shot;+ if (n === 17 || n === 32) return [`scan-${n}.png`, noiseOf(n * 0x9e3779b1)];+ const [r, g, b] = [(n * 53) % 200 + 40, (n * 97) % 200 + 40, (n * 151) % 200 + 40];+ return [`product-${String(n).padStart(2, "0")}.png`, png(480, 320, (x, y) => {+ const inside = [(x - 240) ** 2 + (y - 160) ** 2 < 90 ** 2, Math.abs(x - 240) < 90 && Math.abs(y - 160) < 90, (x + y) % 60 < 30, y > 60 && y < 260 && Math.abs(x - 240) < (y - 60) * 0.6][n % 4];+ return inside ? [255 - r, 255 - g, 255 - b] : [r, g, b];+ })];+};+let manyLog = line("session_meta", { id: MANY });+[5, 4, 4, 5, 3, 4, 5, 4, 4, 4, 3].forEach((count, index) => {+ const id = `m${index + 1}`;+ manyLog += turn(id) + upload(`msg_${id}`, id, Array.from({ length: count }, photo)) + say(index === 10 ? "需要 IMG-017 和 IMG-032 才能比较这两版。" : "收到。", id);+});+writeFileSync(join(day, `rollout-2026-09-24T12-00-00-${MANY}.jsonl`), manyLog);++// Their names, as Codex keeps them next to the sessions folder (the panel's title).writeFileSync(join(root, "session_index.jsonl"), `${JSON.stringify({ id: THREAD, thread_name: "海报配色调整", updated_at: "2026-09-24T10:00:00Z" })}+${JSON.stringify({ id: MANY, thread_name: "产品图批量修图", updated_at: "2026-09-24T12:00:00Z" })}`);// New tasks the user starts after opening the panel on a new chat (?newtask=): Codex files them in today's folder.@@ -100,6 +126,8 @@ const meta = { threadId: THREAD, thread_id: THREAD };// Start with the red square, the copy of the blue circle and the large noise image unchecked, so both placeholder// kinds and a visible saving show.callTool("cam_set_selection", { uncheck: ["IMG-001", "IMG-005", "IMG-006"] }, meta, sessionsDir);+const manyMeta = { threadId: MANY, thread_id: MANY };+callTool("cam_set_selection", { uncheck: ["IMG-005", "IMG-012", "IMG-017", "IMG-024", "IMG-032", "IMG-040"] }, manyMeta, sessionsDir);// What the engine would have recorded: the last full request came in turn 3 (turn 4's images are new since) and had// IMG-001, IMG-005 and IMG-006 replaced. ?stats=skipped|websocket|none shows the other cases.@@ -145,7 +173,7 @@ const HOST = `<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><tit// ?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;- const query = fresh ? "?fresh=" + fresh : params.get("thread") === "gap" ? "?gap=1" : "";+ const query = fresh ? "?fresh=" + fresh : params.get("thread") === "gap" ? "?gap=1" : params.get("thread") === "many" ? "?many=1" : "";const call = (name, args) => fetch("/call" + query, { method: "POST", body: JSON.stringify({ name, arguments: args }) }).then((r) => r.json());window.addEventListener("message", async (event) => {const m = event.data;@@ -208,7 +236,8 @@ createServer((request, response) => {const { name, arguments: args } = JSON.parse(body);const freshId = `${THREAD.slice(0, -4)}${fresh}`;const gap = new URL(request.url, "http://x").searchParams.has("gap");- const threadMeta = fresh && /^[0-9a-f]{4}$/.test(fresh) ? { threadId: freshId, thread_id: freshId } : gap ? { threadId: GAP, thread_id: GAP } : meta;+ const many = new URL(request.url, "http://x").searchParams.has("many");+ const threadMeta = fresh && /^[0-9a-f]{4}$/.test(fresh) ? { threadId: freshId, thread_id: freshId } : gap ? { threadId: GAP, thread_id: GAP } : many ? manyMeta : meta;try { reply(200, "application/json", JSON.stringify(callTool(name, args ?? {}, threadMeta, sessionsDir))); }catch (error) { reply(200, "application/json", JSON.stringify({ isError: true, content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }] })); }});