Skip to content

🔧 fix: Apply Mongoose Plugin at Model Creation #7749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 5, 2025
Merged

Conversation

danny-avila
Copy link
Owner

@danny-avila danny-avila commented Jun 5, 2025

Summary

I fixed an issue where the mongoMeili plugin was being applied to schemas during schema definition instead of during model creation, which caused problems with the main runtime mongoose instance as is not accessible within the package.

  • Moved mongoMeili plugin application from schema definition to model creation in both conversation and message models
  • Updated the mongoMeili plugin to accept a mongoose parameter and use proper TypeScript imports instead of direct mongoose imports
  • Modified the plugin to use the passed mongoose instance for database operations instead of relying on a global mongoose instance
  • Removed the plugin application from the schema files to prevent early binding issues
  • Added proper TypeScript types for FilterQuery and Types to improve type safety

Other Changes

  • Closes [Bug]: Agent Max Context & Tokens form field cannot be reset #7747
    • Replace useCallback with useMemo for the debounced function to ensure proper stability and typing
    • Add fallback function to prevent undefined setter in debounced function creation
    • Improve numeric conversion logic to handle undefined and empty string values properly
    • Remove unused useDebounceCodeBlock hook from the Artifacts component directory

Change Type

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

Testing

The fix was tested by verifying that the mongoMeili plugin now properly uses the main runtime mongoose instance when models are created, preventing connection and schema conflicts.

Test Configuration:

  • MongoDB with MeiliSearch integration enabled
  • Environment variables MEILI_HOST and MEILI_MASTER_KEY configured
  • Multiple mongoose instances in the application

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have commented in any complex areas of my code
  • My changes do not introduce new warnings
  • Local unit tests pass with my changes

@danny-avila danny-avila changed the base branch from main to dev June 5, 2025 03:02
@danny-avila danny-avila merged commit dff4fca into dev Jun 5, 2025
6 checks passed
@danny-avila danny-avila deleted the fix/mongomeili branch June 5, 2025 03:11
kenshinsamue pushed a commit to intelequia/LibreChat that referenced this pull request Aug 4, 2025
* fix: apply mongoMeili when models are created to use main runtime mongoose

* chore: update @librechat/data-schemas version to 0.0.8

* refactor: remove unused useDebounceCodeBlock

* fix: ensure setter function is stable and handle numeric conversion in useDebouncedInput

* refactor: replace useCallback with useMemo for stable debounced function in useDebouncedInput
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]: Agent Max Context & Tokens form field cannot be reset
1 participant