Skip to content

Commit 08cd911

Browse files
committed
fix(manager): hide unavailable image handling controls
1 parent 1f431ae commit 08cd911

5 files changed

Lines changed: 42 additions & 19 deletions

File tree

apps/codex-plus-manager/src/App.tsx

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ import {
9191
mergeModelWindowRows,
9292
modelWindowRowsFromProfile,
9393
serializeModelWindowRows,
94+
shouldShowModelImageHandling,
9495
type ImageHandling,
9596
type ModelWindowRow,
9697
} from "./model-windows";
@@ -6123,8 +6124,10 @@ function RelayProfileEditor({
61236124
setModelWindowRows: (value: ModelWindowRow[]) => void;
61246125
}) {
61256126
const [showAdvanced, setShowAdvanced] = useState(false);
6126-
// 纯 Responses 模式(非聚合)下 VLM/Strip 不生效,禁用下拉
6127-
const vlmUnsupportedProtocol = profile.protocol === "responses" && !isAggregateRelayProfile(profile);
6127+
const showModelImageHandling = shouldShowModelImageHandling(
6128+
profile.protocol,
6129+
isAggregateRelayProfile(profile),
6130+
);
61286131
if (isAggregateRelayProfile(profile)) {
61296132
return (
61306133
<AggregateRelayProfileEditor
@@ -6412,13 +6415,18 @@ function RelayProfileEditor({
64126415
</div>
64136416
</div>
64146417
<div className="relay-model-row-editor">
6415-
<div className="relay-model-row relay-model-row-head">
6418+
<div
6419+
className={`relay-model-row relay-model-row-head${showModelImageHandling ? "" : " relay-model-row--without-image-handling"}`}
6420+
>
64166421
<span>{t("模型名称")}</span>
64176422
<span>{t("上下文窗口")}</span>
6418-
<span>{t("图片处理方式")}</span>
6423+
{showModelImageHandling ? <span>{t("图片处理方式")}</span> : null}
64196424
</div>
64206425
{modelWindowRows.map((row, index) => (
6421-
<div className="relay-model-row" key={index}>
6426+
<div
6427+
className={`relay-model-row${showModelImageHandling ? "" : " relay-model-row--without-image-handling"}`}
6428+
key={index}
6429+
>
64226430
<Input
64236431
value={row.model}
64246432
onChange={(event) => updateModelWindowRow(index, { model: event.currentTarget.value })}
@@ -6429,19 +6437,20 @@ function RelayProfileEditor({
64296437
onChange={(event) => updateModelWindowRow(index, { window: event.currentTarget.value })}
64306438
placeholder="1M"
64316439
/>
6432-
<AppSelect
6433-
className="text-xs"
6434-
value={row.imageHandling}
6435-
disabled={vlmUnsupportedProtocol}
6436-
onChange={(value) => updateModelWindowRow(index, { imageHandling: value })}
6437-
options={[
6438-
{ value: "", label: t("纯文本模型请配置此项"), disabled: true },
6439-
{ value: "send-as-is", label: "send-as-is", title: t("原样发送图片") },
6440-
{ value: "strip", label: "strip images", title: t("为纯文本模型移除消息中的图片") },
6441-
{ value: "vlm", label: "VLM analysis", title: t("为纯文本模型配置图片分析路由") },
6442-
]}
6443-
title={vlmUnsupportedProtocol ? t("VLM 仅支持 Chat Completions 协议和聚合模式") : t("多模态模型(支持图片输入的模型)请保持 send-as-is。")}
6444-
/>
6440+
{showModelImageHandling ? (
6441+
<AppSelect
6442+
className="text-xs"
6443+
value={row.imageHandling}
6444+
onChange={(value) => updateModelWindowRow(index, { imageHandling: value })}
6445+
options={[
6446+
{ value: "", label: t("纯文本模型请配置此项"), disabled: true },
6447+
{ value: "send-as-is", label: "send-as-is", title: t("原样发送图片") },
6448+
{ value: "strip", label: "strip images", title: t("为纯文本模型移除消息中的图片") },
6449+
{ value: "vlm", label: "VLM analysis", title: t("为纯文本模型配置图片分析路由") },
6450+
]}
6451+
title={t("多模态模型(支持图片输入的模型)请保持 send-as-is。")}
6452+
/>
6453+
) : null}
64456454
<Button
64466455
aria-label={t("删除模型")}
64476456
onClick={() => removeModelWindowRow(index)}

apps/codex-plus-manager/src/i18n-en.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export const EN_PLAIN: Record<string, string> = {
3737
"VLM API Key": "VLM API Key",
3838
"VLM Base URL": "VLM Base URL",
3939
"VLM Model": "VLM Model",
40-
"VLM 仅支持 Chat Completions 协议和聚合模式": "VLM only supports Chat Completions protocol and aggregate mode",
4140
"Vision Analysis Provider": "Vision Analysis Provider",
4241
"插件与模型": "Plugins and models",
4342
"管理插件市场、模型列表和服务档位相关增强。": "Manage enhancements for the plugin marketplace, model list and service tier.",

apps/codex-plus-manager/src/model-windows.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
modelWindowsTextToMap,
99
serializeModelWindowRows,
1010
mergeModelWindowRows,
11+
shouldShowModelImageHandling,
1112
} from "./model-windows.ts";
1213

1314
// 类型检查:确保 RelayProfile 包含 modelWindows 和 modelVlm 字段
@@ -44,6 +45,12 @@ const _profileTypeCheck: RelayProfile = {
4445
void _profileTypeCheck;
4546

4647
describe("model-windows helpers", () => {
48+
it("纯 Responses 直连隐藏图片处理选项", () => {
49+
assert.strictEqual(shouldShowModelImageHandling("responses", false), false);
50+
assert.strictEqual(shouldShowModelImageHandling("responses", true), true);
51+
assert.strictEqual(shouldShowModelImageHandling("chat_completions", false), true);
52+
});
53+
4754
it("modelWindowsMapToText 按 modelList 行顺序输出窗口文本", () => {
4855
assert.strictEqual(
4956
modelWindowsMapToText("a\nb\nc", '{"a":"1M","c":"200K"}'),

apps/codex-plus-manager/src/model-windows.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ export function modelWindowsTextToMap(modelList: string, modelWindowsText: strin
2727
/// 图片处理模式。
2828
export type ImageHandling = "" | "send-as-is" | "strip" | "vlm";
2929

30+
export function shouldShowModelImageHandling(protocol: string, isAggregate: boolean): boolean {
31+
return protocol !== "responses" || isAggregate;
32+
}
33+
3034
export type ModelWindowRow = {
3135
model: string;
3236
window: string;

apps/codex-plus-manager/src/styles.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3923,6 +3923,10 @@ body {
39233923
min-height: var(--relay-control-height);
39243924
}
39253925

3926+
.relay-model-row--without-image-handling {
3927+
grid-template-columns: minmax(220px, 1.6fr) minmax(130px, 0.7fr) 40px;
3928+
}
3929+
39263930
.relay-model-row-head {
39273931
min-height: 24px;
39283932
padding-inline: 2px;

0 commit comments

Comments
 (0)