Skip to content

Add config drift comparison tool for YAML merge - #2

Open
npeham wants to merge 2 commits into
mainfrom
claude/kind-wozniak-rXYxB
Open

Add config drift comparison tool for YAML merge#2
npeham wants to merge 2 commits into
mainfrom
claude/kind-wozniak-rXYxB

Conversation

@npeham

@npeham npeham commented Jun 2, 2026

Copy link
Copy Markdown

Summary

Adds a new "Compare & merge" feature to the configuration panel that allows users to paste a librechat.yaml file and compare it against the values currently configured in LibreChat. The tool identifies:

  • Conflicts: Fields with differing values between the pasted YAML and LibreChat's current config (must be resolved before merging)
  • Drift: Configured values missing from the pasted YAML (automatically folded into the merge)
  • In-sync values: Fields that match between both sources

When no conflicts exist, users receive a single merged YAML ready to save, combining their pasted config with all currently configured values.

Change Type

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Implementation Details

New Components & Routes

  • ConfigDiffPage (src/components/configuration/ConfigDiffPage.tsx): Main UI component with two-column layout (input YAML on left, results on right)
    • Handles file upload and manual YAML pasting
    • Displays conflicts, additions, and merged result
    • Copy-to-clipboard for merged YAML
  • Route: /configuration/diff with permission checks matching the main configuration page

Core Logic

  • computeConfigDrift() (src/utils/drift.ts): Compares pasted config against configured values, identifies conflicts/additions, and produces merged result
  • buildConfiguredValues() (src/utils/drift.ts): Aggregates currently configured values from file config and database overrides
  • parseConfigYamlFn() (src/server/config.ts): Server function that parses and validates pasted YAML, returning literal parsed values (not AppService-expanded) for accurate comparison

Types

  • New src/types/drift.ts with interfaces for conflicts, additions, and drift results

UI Integration

  • Added "Compare & merge" link in the configuration page header
  • New localization strings for the drift comparison feature

Testing

  • Unit tests for computeConfigDrift() and buildConfiguredValues() covering:
    • Identifying additions (configured paths missing from pasted YAML)
    • Detecting conflicts (differing values)
    • Treating deeply equal objects/arrays as in-sync
    • Sorting results by path
    • Merging with proper precedence (DB overrides > file config)

Testing

Run unit tests:

bun test src/utils/drift.test.ts

Manual testing:

  1. Navigate to Configuration → Compare & merge
  2. Paste a valid librechat.yaml or upload a file
  3. Click "Compare" to see drift analysis
  4. Verify conflicts are displayed when values differ
  5. Verify merged YAML is generated when no conflicts exist
  6. Test copy-to-clipboard functionality

Checklist

  • Code adheres to project style guidelines (single-word naming, DRY, type safety)
  • Self-reviewed code for correctness and clarity
  • Complex logic documented with JSDoc
  • No new warnings or TypeScript errors
  • Unit tests added and passing
  • Follows import conventions (barrel imports, type namespace)
  • Proper permission checks aligned with configuration page

https://claude.ai/code/session_01NPqLTVpwriTqEc91NkjSsz

Add a dedicated /configuration/diff page where a librechat.yaml can be
pasted and compared against the values currently configured in LibreChat
(base-file overrides + admin-panel DB overrides).

Configured leaf paths missing from the pasted YAML are folded in as
"drift" additions and the page emits a single valid merged YAML with a
copy button, ready to save. When the pasted YAML and LibreChat disagree
on a field, the merge is blocked and every conflicting field is listed
with both values so it can be resolved in the source YAML.

- computeConfigDrift / buildConfiguredValues utilities (+ unit tests)
- parseConfigYamlFn server fn validating YAML against configSchema and
  returning the literal parsed values (no schema defaults injected)
- ConfigDiffPage UI and route, "Compare & merge" header action
@railway-app
railway-app Bot temporarily deployed to Proactive - AI Hub - Demo / test June 2, 2026 11:37 Inactive
Make the compare & merge tool actionable instead of read-only:

- Per-conflict resolution: each conflicting field offers a "Your YAML" vs
  "LibreChat" choice (plus keep-all shortcuts). The merged YAML is built
  live from the chosen sides and is only produced once every conflict is
  resolved.
- The merged result can be copied, downloaded as librechat.yaml, or
  applied directly to LibreChat via the admin panel (full base-config
  replace, gated by MANAGE_CONFIGS).

Splits the merge out of computeConfigDrift into buildMergedConfig(pasted,
additions, conflicts, resolutions) and updates the unit tests accordingly.
@railway-app
railway-app Bot temporarily deployed to Proactive - AI Hub - Demo / test June 2, 2026 12:33 Inactive
@railway-app
railway-app Bot temporarily deployed to Proactive - AI Hub - Demo / feature-dev June 2, 2026 13:13 Inactive
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.

2 participants