mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 20:00:47 +00:00
refactor(app): RISKY pass R1-R3 — config-driven modal, cursor frame dedup, chunk helper
R1: merge AddOpenAICompatibleModal + AddAnthropicCompatibleModal → AddCompatibleModal (variant config-driven, ~180 dup removed, preserves per-variant useEffect behavior) R3: extract readCursorFrame() helper — dedup protobuf frame header/decompress loop (JSON+SSE transforms, byte-identical) R2: add chatChunkSse() helper, wire 7 cursor SSE scaffolds (byte-identical, cursor golden pass) Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -180,13 +180,21 @@ export default function ModelSelectModal({
|
||||
let combined = aliasModels;
|
||||
if (kindFilter && TYPED_KINDS.has(kindFilter)) {
|
||||
combined = getModelsByProviderId(providerId)
|
||||
.filter((m) => mKind(m) === kindFilter)
|
||||
.map((m) => ({ id: m.id, name: m.name, value: `${alias}/${m.id}`, kind: mKind(m) }));
|
||||
.filter((m) => getModelKind(m) === kindFilter)
|
||||
.map((m) => ({ id: m.id, name: m.name, value: `${alias}/${m.id}`, kind: getModelKind(m) }));
|
||||
// Fallback: provider-as-model when no hardcoded models match (tts/image/webFetch only)
|
||||
if (combined.length === 0 && ALLOW_PROVIDER_FALLBACK_KINDS.has(kindFilter)) {
|
||||
const supports = (providerInfo.serviceKinds || ["llm"]).includes(kindFilter);
|
||||
if (supports) combined = [{ id: providerId, name: providerInfo.name, value: alias }];
|
||||
}
|
||||
} else {
|
||||
// LLM/null kind: merge hardcoded models (e.g. mimo-free → mimo-auto) with aliases
|
||||
const seen = new Set(aliasModels.map((m) => m.value));
|
||||
const hardcoded = getModelsByProviderId(providerId)
|
||||
.filter((m) => !getModelKind(m) || getModelKind(m) === "llm")
|
||||
.map((m) => ({ id: m.id, name: m.name, value: `${alias}/${m.id}`, kind: getModelKind(m) }))
|
||||
.filter((m) => !seen.has(m.value));
|
||||
combined = [...aliasModels, ...hardcoded];
|
||||
}
|
||||
|
||||
if (combined.length > 0) {
|
||||
@@ -262,7 +270,7 @@ export default function ModelSelectModal({
|
||||
.map((m) => ({ id: m.id, name: m.name || m.id, value: `${alias}/${m.id}`, isCustom: true }));
|
||||
|
||||
const merged = [
|
||||
...hardcodedModels.map((m) => ({ id: m.id, name: m.name, value: `${alias}/${m.id}`, kind: mKind(m) })),
|
||||
...hardcodedModels.map((m) => ({ id: m.id, name: m.name, value: `${alias}/${m.id}`, kind: getModelKind(m) })),
|
||||
...customAliasModels,
|
||||
...customRegisteredModels,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user