(force = false)
| 740 | } |
| 741 | |
| 742 | async function loadModelOptions(force = false) { |
| 743 | if ((loadingModelOptions && !force) || updatingModelSettings) { |
| 744 | return; |
| 745 | } |
| 746 | if (modelOptions && !force) { |
| 747 | return; |
| 748 | } |
| 749 | setLoadingModelOptions(true); |
| 750 | try { |
| 751 | const response = await fetch(`/api/codex-threads/${encodeURIComponent(threadId)}/model-options`, { |
| 752 | cache: 'no-store', |
| 753 | }); |
| 754 | const payload = await response.json().catch(() => null) as ThreadModelOptions & { error?: string } | null; |
| 755 | if (!response.ok || payload?.error) { |
| 756 | throw new Error((payload?.error && String(payload.error).trim()) || '模型列表加载失败'); |
| 757 | } |
| 758 | applyModelOptionsSnapshot(payload); |
| 759 | } catch (error) { |
| 760 | setReplyError(error instanceof Error ? error.message : '模型列表加载失败'); |
| 761 | } finally { |
| 762 | setLoadingModelOptions(false); |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | function applyRunSnapshot(snapshot: ReplyRunSnapshot, draftId: string, draftTimestamp: string) { |
| 767 | replaceStreamAssistantMessages( |
no test coverage detected