Skip to content

🏷️ fix: Preserve Conversation Tag Identity - #15748

Open
dustinhealy wants to merge 15 commits into
devfrom
fix/conversation-tag-identity
Open

dustinhealy wants to merge 15 commits into
devfrom
fix/conversation-tag-identity

Conversation

@dustinhealy

@dustinhealy dustinhealy commented Sep 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Conversation membership currently uses mutable bookmark names: an assignment racing with a rename can retain the old name and disconnect the conversation from its bookmark. Membership now references the existing ConversationTag._id, so renaming changes the catalog label while preserving membership and conversation timestamps.

How it works

The catalog owns labels; conversations store stable IDs. Browser mutations use IDs, existing name-based routes resolve labels once, and public reads project current labels from the owned catalog. Counts come from committed membership, and deleted or foreign identities cannot become valid membership.

packages/data-schemas/src/
├── tags/membership.ts              # Resolve labels, validate ownership, project current tags
├── methods/conversationTag.ts      # Catalog mutations and conversation membership
└── migrations/conversationTags.ts  # Validate and convert the legacy representation offline

Portable imports resolve names locally and ignore source IDs; local copies preserve identities, and exports carry names. Failed imports compensate their conversations and messages but retain shared catalog entries, including empty bookmarks. Failed create-and-attach requests return 404 for unavailable conversations and may also retain the catalog entry. Retries reuse those identities; users can explicitly delete unneeded bookmarks. Successful membership changes refresh parameterized conversation lists.

A separate Meilisearch catalog index preserves label search without rewriting every conversation on rename. MongoDB revalidates search results against ownership and current membership. Enabled startup index sync audits the tag index in paced background batches to recover interrupted deletions. This does not gate readiness, but total maintenance work grows with catalog size on every rollout.

Upgrade: back up MongoDB, stop every old writer, run the migration, then start only upgraded writers:

npm run migrate:conversation-tags -- --dry-run
npm run migrate:conversation-tags -- --apply
npm run migrate:conversation-tags -- --dry-run

Preflight rejects malformed records, including missing or invalid catalog positions, before writing. Catalog and membership writes use bounded batches; retries preserve committed identities and metadata. Startup checks a completion marker, and every existing unmarked database requires migration. Mixed-version writers are unsupported. Rollback requires restoring the complete pre-upgrade backup and rebuilding search indexes; subsequent writes are lost.

See the implementation and cutover guide and the companion documentation PR.

Change Type

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Testing

Focused validation includes real MongoDB race, tenant, migration/retry, HTTP error, and import-retention tests; real QueryClient membership/cache tests; and Meilisearch indexing, deletion, and recovery tests. Current focused suites passed: 48 migration/membership tests, 28 HTTP/import tests, 43 client tests, 93 indexing tests, and 154 shared-search/DocumentDB compatibility tests.

Schema and frontend typechecks/builds, scoped import sorting/checks, ESLint, and formatting passed. Tagged Lighthouse passed with median LCP 3.46 seconds, CLS 0.039, and TBT 119 ms. The full monorepo suite has not been run locally; CI results are attached to the PR.

Representative reproduction commands:

npm run build -w @librechat/data-schemas
(cd packages/data-schemas && npx jest src/migrations/conversationTags.spec.ts src/methods/conversationTag.methods.spec.ts src/models/plugins/mongoMeili --runInBand)
(cd api && npx jest server/routes/__tests__/tags.spec.js server/utils/import/importTags.spec.js --runInBand)
(cd client && npx jest src/data-provider/__tests__/tagMembership.spec.tsx src/data-provider/__tests__/pinnedConversations.test.tsx src/hooks/Conversations/__tests__/useBookmarkSuccess.spec.tsx --runInBand)
(cd packages/data-schemas && npx tsc --noEmit)
(cd client && npx tsc --noEmit)
npm run static-checks -- --against origin/dev
npm run lighthouse

Test Configuration:

  • Node.js 24.16.0 with locked dependencies.
  • MongoDB through mongodb-memory-server for database tests.
  • Isolated Meilisearch 1.35.1 for search experiments.
  • Chromium for Lighthouse, including the tagged-conversation fixture.

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
  • I have made pertinent documentation changes
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes
  • A pull request for updating the documentation has been submitted.

Copilot AI lite review requested due to automatic review settings September 8, 2026 17:49

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.

🟡 Changes recommended

There are correctness and tenant-isolation risks in the updated tag mutation paths (see stored PR comments) that should be addressed before merging.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR refactors conversation tag catalog handling to reduce rename-related inconsistencies by introducing rename-reservation metadata (renameTo / reservedNames), tenant-aware tag operations, and authoritative tag counts derived from committed conversation membership rather than cached deltas.

Changes:

  • Add schema support for in-progress renames and reserved tag-name claims with a supporting unique partial index.
  • Update tag methods to be tenant-aware, ensure required indexes exist even when auto-indexing is disabled, and derive public tag counts from conversations.
  • Update the legacy /api/tags routes to pass tenant context and to reject combined rename + reorder requests early with a 400.
File summaries
File Description
packages/data-schemas/src/schema/conversationTag.ts Adds renameTo/reservedNames fields and a unique partial index to reserve tag names across rename flows.
packages/data-schemas/src/methods/conversationTag.ts Implements tenant-scoped tag operations, derived counts, rename reservation, and index-provisioning with retry.
packages/data-schemas/src/methods/conversationTag.methods.spec.ts Expands coverage for derived counts, rename recovery, tenant boundaries, and index provisioning behavior.
api/server/routes/tags.js Passes tenantId through to tag methods and adds early 400 validation for rename+position requests.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-09T02:36:50.923028Z b69b0ca Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8404dc23e1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread client/src/data-provider/queries.ts Resolved

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 85d15eed4d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1927bd87fb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread client/src/data-provider/mutations.ts Resolved

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: bb83987789

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8168cbec31

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread api/server/routes/convos.js Resolved
Comment thread api/server/routes/tags.js Resolved

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 08ec4ffcb4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 08ec4ffcb4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread api/server/routes/tags.js Resolved

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 929ff88bfa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dustinhealy

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 929ff88bfa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dustinhealy

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e543f892ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread api/db/indexSync.js Resolved
Comment thread client/src/data-provider/mutations.ts Resolved
@dustinhealy

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 11165278e0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dustinhealy

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 11165278e0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dustinhealy

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: b69b0cabce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dustinhealy
dustinhealy marked this pull request as ready for review September 9, 2026 01:35
chatgpt-codex-connector[bot]

This comment was marked as duplicate.

@dustinhealy

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b69b0cabce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danny-avila

Copy link
Copy Markdown
Collaborator

@dustinhealy merge conflicts

@codegraph-librechat codegraph-librechat Bot added the 🗺️ DB Models & Ops codegraph: the taxonomy area this belongs to (classifier, confidence ≥ 0.9) label Oct 15, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🗺️ DB Models & Ops codegraph: the taxonomy area this belongs to (classifier, confidence ≥ 0.9) 🛡️ security review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants