🏷️ 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:
Danny Avila 2026-03-17 02:12:34 -04:00 committed by GitHub
parent 9a64791e3e
commit 0c378811f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 195 additions and 19 deletions

View file

@ -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 !== '',