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:
diegosouzapw
2026-04-08 16:43:46 -03:00
parent f5cd841056
commit 02128618b0
8 changed files with 304 additions and 15 deletions

View File

@@ -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.
}
};

View File

@@ -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) {