Skip to content

A local plugin for image-heavy chats in Codex, Claude Code and other agents: earlier images stop going out with every message, and the model fetches the one it needs by its ID, also after compaction.

fix(needs): 每个 GPT-6 模型都按编号要图,面板也认更多要图的说法

chipfighterf7f97699bc3f
diff --git a/plugin/src/panel-state.ts b/plugin/src/panel-state.ts
index 3fe6d56..63fa215 100644
--- a/plugin/src/panel-state.ts
+++ b/plugin/src/panel-state.ts
@@ -74,12 +74,17 @@ export type PanelOptions = { sessionsDir: string; dataRoot?: string };
// the user to check them again in the note's own words ("请重新勾选 IMG-003 和 IMG-004", "please check IMG-004 back in",
// "please restore IMG-004"); "取消勾选" and a state ("已勾选", "没勾选", "was restored") are not asking.
const MARKS = "[“”\"'‘’「」*_`]*";
-const item = (separators: string) => `(?:\\s*${MARKS}\\s*IMG-\\d{3,}\\s*${MARKS}\\s*(?:${separators})?)`;
-const ZH_LIST = `(${item("[、,,/]|以及|和|与|及")}+)`;
-const EN_LIST = `(${item(",|and")}+)`;
+// v0.1-24: an id may carry a short note in brackets ("IMG-002 (v1 desktop)"), and several may be joined by "or".
+const NOTE = "(?:\\s*[((][^()()]{0,40}[))])?";
+const item = (separators: string) => `(?:\\s*${MARKS}\\s*IMG-\\d{3,}\\s*${MARKS}${NOTE}\\s*(?:${separators})?)`;
+const ZH_LIST = `(${item("[、,,/]|以及|和|与|及|或者|或")}+)`;
+const EN_LIST = `(${item(",|and|or")}+)`;
+// v0.1-24: models also ask the user to attach, send or share an image again (GPT-6 Luna: "Please reattach IMG-002").
+const ZH_ASK = "(?:重新)?(?:勾选|附上|附加|上传|发送|提供)";
+const EN_ASK = "needs?|restore|re-?enable|re-?check|re-?select|re-?attach|attach|re-?add|add back|re-?send|send|re-?share|share|re-?upload|upload|provide|re-?include|include";
const ASKED = [
- new RegExp(`(?:需要|(?<!取消|已|已经|没|没有|未)(?:重新)?勾选)${ZH_LIST}`, "g"),
- new RegExp(`\\b(?:needs?|restore|re-?enable|re-?check|re-?select)${EN_LIST}`, "gi"),
+ new RegExp(`(?:需要|(?<!取消|已|已经|没|没有|未)${ZH_ASK})${ZH_LIST}`, "g"),
+ new RegExp(`\\b(?:${EN_ASK})(?:\\s+(?:me|us))?${EN_LIST}`, "gi"),
new RegExp(`\\bcheck${EN_LIST}\\s*(?:back|again)\\b`, "gi"),
];
diff --git a/plugin/src/rewrite.ts b/plugin/src/rewrite.ts
index 3d2a25f..975f59d 100644
--- a/plugin/src/rewrite.ts
+++ b/plugin/src/rewrite.ts
@@ -4,6 +4,7 @@
// keeps trusting what it said about it (user report 2026-09-25).
// v0.1-14 — in the user's language (Codex's interface language, language.ts): the Chinese wording is the one tested on
// 2026-09-25; the English one says the same and is checked by the same self-test (v01-placeholder-selftest.ts --lang en).
+// v0.1-24 — how to ask for an image back is spelled out, for every GPT-6 model (self-tests with CAM_TEST_MODEL).
// Input: request items, a lookup into the thread index, the unchecked keys. Output: new items plus a metadata report.
import { findImages, type ImageKind, type ImageRef } from "./images.ts";
@@ -42,7 +43,7 @@ const WORDS: Record<Lang, Words> = {
note: [
"上下文管理说明(来自用户安装的上下文素材管理工具):为了节省上下文,用户取消勾选了这个任务里的部分图片。后面的对话里,这些图片原来的位置被换成了“[图片 IMG-xxx 已省略…]”这样的占位文字。",
"这些图片在它们出现的那一轮真实存在,你当时收到并看过;你之前对它们的描述,以及据此做出的判断,都是看着原图做出的,仍然有效。不要因为现在看不到,就认为之前的回答是猜测或错误,也不要收回或道歉。",
- "被问到现在能不能看到时,如实说明现在看不到(被用户省略了),并说明之前的描述仍然有效。现在看不到画面,就不要补充之前没说过的细节;需要重新看某张图时,在回复里写出“需要 IMG-xxx”,用户可以重新勾选;不要自己用工具去读取这些图片。",
+ "被问到现在能不能看到时,如实说明现在看不到(被用户省略了),并说明之前的描述仍然有效。现在看不到画面,就不要补充之前没说过的细节。需要重新看某张图时,在回复里原样写出“需要 IMG-xxx”(几张就写“需要 IMG-002、IMG-003”):工具靠这几个字认出你要的图,用户在工具里勾选后,下一条消息就会带上原图,所以不要让用户重新上传或附上图片。不要自己用工具去读取这些图片。",
].join("\n"),
},
en: {
@@ -60,12 +61,13 @@ const WORDS: Record<Lang, Words> = {
note: [
"Context management note (from the context asset manager the user installed): to save context, the user unchecked some images in this task. Further on in the conversation, where those images were, there is now placeholder text such as \"[Image IMG-xxx omitted…]\".",
"These images really existed in the turn where they appeared, and you received and looked at them then; what you said about them before, and the judgments you based on it, were made looking at the original images and remain valid. Do not treat your earlier answers as guesses or mistakes because you cannot see the images now, and do not take them back or apologize.",
- "If asked whether you can see them now, say truthfully that you cannot see them now (the user left them out), and that your earlier descriptions remain valid. Since you cannot see them now, do not add details you did not mention before; if you need to look at an image again, write \"need IMG-xxx\" in your reply, and the user can check it again; do not read these images yourself with tools.",
+ "If asked whether you can see them now, say truthfully that you cannot see them now (the user left them out), and that your earlier descriptions remain valid. Since you cannot see them now, do not add details you did not mention before. If you need to look at an image again, write exactly \"need IMG-xxx\" in your reply (for several: \"need IMG-002, IMG-003\"): the tool finds the images you want by these words, and once the user checks them, the next message brings back the originals, so do not ask the user to upload or attach them again. Do not read these images yourself with tools.",
].join("\n"),
},
};
-// Kept for the tests and the 2026-09-25 record: the Chinese note as tested then.
+// The Chinese note, tested on 2026-09-25; v0.1-24 (2026-09-28) spells out how to ask for an image back ("需要 IMG-xxx",
+// several at once, no re-uploading), after GPT-6 Luna asked the user to "reattach" images instead.
export const OMISSION_NOTE = WORDS.zh.note;
export const omissionNote = (lang: Lang) => WORDS[lang].note;
diff --git a/spike/src/panel-state.test.ts b/spike/src/panel-state.test.ts
index 7c5a29d..edfa979 100644
--- a/spike/src/panel-state.test.ts
+++ b/spike/src/panel-state.test.ts
@@ -38,6 +38,20 @@ test("an asked-for id may be in bold, or asked for as checking it again; uncheck
assert.deepEqual(asked("IMG-003 was restored earlier, and I will check IMG-004 carefully; I can't see IMG-002 now."), []);
});
+// v0.1-24 — GPT-6 Luna's reply in the user's recording of 2026-09-28 (all images unchecked): "reattach", two ids joined
+// by "or", each followed by a note in brackets. Nothing showed in the "model needs" bar.
+test("an asked-for id may be asked for as re-attaching or sending it, several joined by or, each with a note", () => {
+ const asked = (reply: string) => requestedIds(records(turn("t1") + assistant(reply, "t1")));
+ assert.deepEqual(asked("I can’t see the earlier images now; they were left out of the conversation. I didn’t mention v1’s chat button color in my earlier notes, so I can’t identify it from the context I have. Please reattach IMG-002 (v1 desktop) or IMG-003 (v1 mobile)."), ["IMG-002", "IMG-003"]);
+ assert.deepEqual(asked("Could you re-attach IMG-004 or send me IMG-005 again?"), ["IMG-004", "IMG-005"]);
+ assert.deepEqual(asked("Please share IMG-006, IMG-007 or IMG-008 so I can compare."), ["IMG-006", "IMG-007", "IMG-008"]);
+ assert.deepEqual(asked("请重新附上 IMG-002(v1 桌面版)或 IMG-003。"), ["IMG-002", "IMG-003"]);
+ assert.deepEqual(asked("请重新发送 IMG-009 或者 IMG-010。"), ["IMG-009", "IMG-010"]);
+ // Not asking: an image described as attached or sent before.
+ assert.deepEqual(asked("The attached IMG-001 shows the hero; you sent IMG-002 earlier, and IMG-003 was reattached before."), []);
+ assert.deepEqual(asked("你已经上传 IMG-004,之前也发送过 IMG-005 的截图。"), []);
+});
+
test("panel state lists every image with checked, same-content and requested flags", () => {
const options = sampleSessions();
const state = loadPanelState(THREAD, options);