(updates: {
model?: string | null;
reasoningEffort?: string | null;
})
| 1079 | } |
| 1080 | |
| 1081 | async function applyModelUpdate(updates: { |
| 1082 | model?: string | null; |
| 1083 | reasoningEffort?: string | null; |
| 1084 | }) { |
| 1085 | if (updatingModelSettings) { |
| 1086 | return; |
| 1087 | } |
| 1088 | setUpdatingModelSettings(true); |
| 1089 | setReplyError(null); |
| 1090 | try { |
| 1091 | const response = await fetch(`/api/codex-threads/${encodeURIComponent(threadId)}/settings`, { |
| 1092 | method: 'POST', |
| 1093 | headers: { 'Content-Type': 'application/json' }, |
| 1094 | body: JSON.stringify(updates), |
| 1095 | }); |
| 1096 | const payload = await response.json().catch(() => null) as (ThreadModelOptions & { |
| 1097 | ok?: boolean; |
| 1098 | error?: string; |
| 1099 | permissionsMode?: PermissionsMode; |
| 1100 | }) | null; |
| 1101 | if (!response.ok || !payload?.ok) { |
| 1102 | throw new Error((payload?.error && String(payload.error).trim()) || '模型设置更新失败'); |
| 1103 | } |
| 1104 | applyModelOptionsSnapshot(payload); |
| 1105 | if (payload.permissionsMode) { |
| 1106 | setPermissionsMode(payload.permissionsMode); |
| 1107 | } |
| 1108 | setModelMenuOpen(false); |
| 1109 | } catch (error) { |
| 1110 | setReplyError(error instanceof Error ? error.message : '模型设置更新失败'); |
| 1111 | } finally { |
| 1112 | setUpdatingModelSettings(false); |
| 1113 | } |
| 1114 | } |
| 1115 | |
| 1116 | const effectiveModelOption = modelOptions?.availableModels.find((entry) => ( |
| 1117 | entry.model === modelOptions.effectiveModelId || entry.id === modelOptions.effectiveModelId |
no test coverage detected