Skip to content

🏷️ fix: Clear Model Spec Fields When Navigating with Non-spec Query Params#12274

Merged
danny-avila merged 1 commit into
devfrom
fix/agent-share-link-spec-contamination
Mar 17, 2026
Merged

🏷️ fix: Clear Model Spec Fields When Navigating with Non-spec Query Params#12274
danny-avila merged 1 commit into
devfrom
fix/agent-share-link-spec-contamination

Conversation

@danny-avila

Copy link
Copy Markdown
Owner

Closes #12272

Summary

I fixed a bug where navigating to an agent share link while a modelSpec was selected would leave stale modelSpec display data (icon, name, greeting) in the UI instead of showing the shared agent's information.

  • Clear spec, iconURL, and modelLabel from the merged preset in ChatRoute.getNewConvoPreset() when URL query parameters override the conversation without explicitly setting a spec.
  • Prevent spec field contamination when specPreset is spread as a base and query settings (e.g., agent_id) are overlaid on top — previously the spec's display fields persisted through the merge since areSettingsApplied() in useQueryParams skips checking those fields, so the safety-net newQueryConvo call never fired.

Change Type

  • Bug fix (non-breaking change which fixes an issue)

Testing

  1. Configure modelSpecs with prioritize: false and at least one spec (all default: false).
  2. Create an agent with sharing enabled and copy its share link.
  3. Select a modelSpec in the model selector.
  4. Paste the agent share link into the browser.
  5. Verify the agent's icon, name, and greeting display correctly (not the modelSpec's).
  6. Repeat starting from another agent instead of a modelSpec — confirm this still works as before.
  7. Navigate directly to a spec via ?spec=specName — confirm spec icon/name/greeting load correctly.

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • My changes do not introduce new warnings

Copilot AI review requested due to automatic review settings March 17, 2026 05:44
@danny-avila danny-avila linked an issue Mar 17, 2026 that may be closed by this pull request
1 task

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a UI state bug where navigating to an agent share link while a modelSpec is selected can leave modelSpec-derived display fields (e.g., icon/label/greeting) stuck in the conversation state instead of showing the shared agent’s identity.

Changes:

  • Updates ChatRoute.getNewConvoPreset() to merge query-derived settings over the default modelSpec preset.
  • When query params override the conversation without explicitly setting spec, clears select modelSpec display fields (spec, iconURL, modelLabel) from the merged preset to prevent stale UI carryover.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread client/src/routes/ChatRoute.tsx Outdated
Comment thread client/src/routes/ChatRoute.tsx Outdated
@danny-avila danny-avila force-pushed the fix/agent-share-link-spec-contamination branch 3 times, most recently from 4346e82 to 45f0779 Compare March 17, 2026 06:08
…e Link

- 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.
@danny-avila danny-avila force-pushed the fix/agent-share-link-spec-contamination branch from 45f0779 to b71fbbd Compare March 17, 2026 06:08
@danny-avila danny-avila changed the title 🏷️ fix: Clear ModelSpec Display Fields When Navigating via Agent Share Link 🏷️ fix: Clear Model Spec Fields When Navigating with Non-spec Query Params Mar 17, 2026
@danny-avila danny-avila merged commit 0c37881 into dev Mar 17, 2026
7 checks passed
@danny-avila danny-avila deleted the fix/agent-share-link-spec-contamination branch March 17, 2026 06:12
jcbartle pushed a commit to jcbartle/LibreChat that referenced this pull request May 11, 2026
…e Link (danny-avila#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Model selection not always updating when clicking an agent share link

2 participants