mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 04:12:10 +03:00
fix(types): resolve context-relay payload resolution and typing issues
- Fix `handoffProviders` and `nextBody` unknown property TS errors in contextHandoff - Correct fallback payload parsing from responses `input` array in combo service
This commit is contained in:
@@ -1210,9 +1210,34 @@ function TestResultsView({ results }) {
|
||||
// Combo Form Modal
|
||||
// ─────────────────────────────────────────────
|
||||
function ComboFormModal({ isOpen, combo, onClose, onSave, activeProviders }) {
|
||||
type CreateDraftSnapshot = {
|
||||
name: string;
|
||||
models: unknown[];
|
||||
strategy: string;
|
||||
config: Record<string, unknown>;
|
||||
showAdvanced: boolean;
|
||||
nameError: string;
|
||||
agentSystemMessage: string;
|
||||
agentToolFilter: string;
|
||||
agentContextCache: boolean;
|
||||
};
|
||||
|
||||
const getEmptyCreateDraftSnapshot = (): CreateDraftSnapshot => ({
|
||||
name: "",
|
||||
models: [],
|
||||
strategy: "priority",
|
||||
config: {},
|
||||
showAdvanced: false,
|
||||
nameError: "",
|
||||
agentSystemMessage: "",
|
||||
agentToolFilter: "",
|
||||
agentContextCache: false,
|
||||
});
|
||||
|
||||
const t = useTranslations("combos");
|
||||
const tc = useTranslations("common");
|
||||
const notify = useNotificationStore();
|
||||
const createDraftStateRef = useRef<CreateDraftSnapshot>(getEmptyCreateDraftSnapshot());
|
||||
const [name, setName] = useState(combo?.name || "");
|
||||
const [models, setModels] = useState(() => {
|
||||
return (combo?.models || []).map((m) => normalizeModelEntry(m));
|
||||
@@ -1260,6 +1285,30 @@ function ComboFormModal({ isOpen, combo, onClose, onSave, activeProviders }) {
|
||||
[setAgentContextCache]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
createDraftStateRef.current = {
|
||||
name,
|
||||
models,
|
||||
strategy,
|
||||
config,
|
||||
showAdvanced,
|
||||
nameError,
|
||||
agentSystemMessage,
|
||||
agentToolFilter,
|
||||
agentContextCache,
|
||||
};
|
||||
}, [
|
||||
name,
|
||||
models,
|
||||
strategy,
|
||||
config,
|
||||
showAdvanced,
|
||||
nameError,
|
||||
agentSystemMessage,
|
||||
agentToolFilter,
|
||||
agentContextCache,
|
||||
]);
|
||||
|
||||
// DnD state
|
||||
const hasPricingForModel = useCallback(
|
||||
(modelValue) => {
|
||||
@@ -1405,17 +1454,30 @@ function ComboFormModal({ isOpen, combo, onClose, onSave, activeProviders }) {
|
||||
};
|
||||
}
|
||||
|
||||
createDraftStateRef.current = getEmptyCreateDraftSnapshot();
|
||||
resetFormForCombo(null, null);
|
||||
|
||||
const loadDefaults = async () => {
|
||||
try {
|
||||
const response = await fetch("/api/settings/combo-defaults");
|
||||
const data = response.ok ? await response.json() : {};
|
||||
if (!cancelled) {
|
||||
const draft = createDraftStateRef.current;
|
||||
const isPristineDraft =
|
||||
draft.name.trim().length === 0 &&
|
||||
draft.models.length === 0 &&
|
||||
draft.strategy === "priority" &&
|
||||
Object.keys(draft.config || {}).length === 0 &&
|
||||
draft.showAdvanced === false &&
|
||||
draft.nameError.length === 0 &&
|
||||
draft.agentSystemMessage.length === 0 &&
|
||||
draft.agentToolFilter.length === 0 &&
|
||||
draft.agentContextCache === false;
|
||||
|
||||
if (!cancelled && isPristineDraft) {
|
||||
resetFormForCombo(null, data.comboDefaults || null);
|
||||
}
|
||||
} catch {
|
||||
if (!cancelled) {
|
||||
resetFormForCombo(null, null);
|
||||
}
|
||||
// Keep the blank create form if defaults fail to load.
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -509,8 +509,7 @@ async function handleSingleModelChat(
|
||||
comboStrategy === "context-relay" &&
|
||||
comboName &&
|
||||
runtimeOptions.sessionId &&
|
||||
body?._omnirouteSkipContextRelay !== true &&
|
||||
!excludeConnectionId
|
||||
body?._omnirouteSkipContextRelay !== true
|
||||
) {
|
||||
const handoff = getHandoff(runtimeOptions.sessionId, comboName);
|
||||
if (handoff && handoff.fromAccount !== credentials.connectionId) {
|
||||
|
||||
Reference in New Issue
Block a user