mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-04-07 00:15:23 +02:00
🏷️ fix: Clear ModelSpec Display Fields When Navigating via Agent Share Link (#12274)
- Extract `specDisplayFieldReset` constant and `mergeQuerySettingsWithSpec` utility to `client/src/utils/endpoints.ts` as a single source of truth for spec display fields that must be cleared on non-spec transitions. - Clear `spec`, `iconURL`, `modelLabel`, and `greeting` from the merged preset in `ChatRoute.getNewConvoPreset()` when URL query parameters override the conversation without explicitly setting a spec. - Also clear `greeting` in the parallel cleanup in `useQueryParams.newQueryConvo` using the shared `specDisplayFieldReset` constant. - Guard the field reset on `specPreset != null` so null values aren't injected when no spec is configured. - Add comprehensive test coverage for the merge-and-clear logic.
This commit is contained in:
parent
9a64791e3e
commit
0c378811f1
4 changed files with 195 additions and 19 deletions
|
|
@ -12,6 +12,7 @@ import type {
|
|||
import {
|
||||
clearModelForNonEphemeralAgent,
|
||||
removeUnavailableTools,
|
||||
specDisplayFieldReset,
|
||||
processValidSettings,
|
||||
getModelSpecIconURL,
|
||||
getConvoSwitchLogic,
|
||||
|
|
@ -128,13 +129,10 @@ export default function useQueryParams({
|
|||
endpointsConfig,
|
||||
});
|
||||
|
||||
let resetParams = {};
|
||||
const resetFields = newPreset.spec == null ? specDisplayFieldReset : {};
|
||||
if (newPreset.spec == null) {
|
||||
template.spec = null;
|
||||
template.iconURL = null;
|
||||
template.modelLabel = null;
|
||||
resetParams = { spec: null, iconURL: null, modelLabel: null };
|
||||
newPreset = { ...newPreset, ...resetParams };
|
||||
Object.assign(template, specDisplayFieldReset);
|
||||
newPreset = { ...newPreset, ...specDisplayFieldReset };
|
||||
}
|
||||
|
||||
// Sync agent_id from newPreset to template, then clear model if non-ephemeral agent
|
||||
|
|
@ -152,7 +150,7 @@ export default function useQueryParams({
|
|||
conversation: {
|
||||
...(conversation ?? {}),
|
||||
endpointType: template.endpointType,
|
||||
...resetParams,
|
||||
...resetFields,
|
||||
},
|
||||
preset: template,
|
||||
cleanOutput: newPreset.spec != null && newPreset.spec !== '',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue