Skip to content

✂️ refactor: Remove Dead Helpers, Classes and Dependencies From packages/api - #17118

Merged
berry-13 merged 6 commits into
devfrom
refactor/dead-code-packages-api
Oct 16, 2026
Merged

berry-13 merged 6 commits into
devfrom
refactor/dead-code-packages-api

Conversation

@berry-13

@berry-13 berry-13 commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A dead-code scan of the repository flagged functions, classes, constants and scripts in packages/api that nothing calls anymore. Each one was re-checked against current dev (whole-word grep across api/, client/ and packages/, including destructured require('@librechat/api') calls and jest.mock factories in /api), and only code that is still unreferenced is removed here. Specs that only tested a removed helper go with it; specs that drove live behavior through a removed wrapper now call the live function directly, so their cases stay.

This removes, among others: the superseded isTokenIssuedBeforeCredentialChange predicate (password-reset revocation runs through isTokenRetired, which every JWT strategy, the share and file gates and image authorization already use, and whose spec covers the same cases), an unused cache store class and its factory branch, legacy PII helpers beside the live fragment predicate, unused token, compaction, file filter, MCP, schedule, stream and tool approval helpers, unused constants, the root OIDC integration test that no Jest config ever ran, the MCP demo start:* scripts and their bootstrap loader, and four dependencies nothing imports (@google/genai, @azure/search-documents, @babel/preset-react, @types/react). Behavior is unchanged.

Skipped on purpose: exports whose JSDoc keeps them for external @librechat/api consumers or marks them deprecated rather than removed (manual skill primes, auth log formatting, the S3 and CloudFront URL wrappers, createHandleLLMNewToken, collectModelBoundHistoricalFileIds, the JSON schema to Zod converter, the deferDeliveryUntilSynchronized transport option), the paused LibreOffice preview, the generation job ready promise (threads through the streaming resume paths), helpers specs use as fixtures, and packages/chat host types (active refactor).

Type of change

  • Refactor

Testing

Tested environments/configuration: Jest with mongodb-memory-server, no Redis, no running app.

Automated tests:

  • tsc --noEmit in packages/api (specs included): no errors
  • npx jest --findRelatedTests in packages/api over the changed files: 14696 tests pass; the only failures were Redis-backed *_integration suites with no Redis available, and seven suites that timed out under load and pass when rerun alone
  • npm run build in packages/api, then utils/tokens.spec.js, responses.unit.spec.js and server/services/Files in api: pass
  • npm run static-checks -- --against origin/dev: pass
  • package-lock.json checked with npm install --package-lock-only (no further changes); bun.lock pruned of the same four entries

Screenshots / recordings

No user-facing change.

Checklist

  • I reviewed my own changes
  • Relevant tests have been added or updated
  • Existing relevant tests pass
  • The change does not introduce new warnings or errors

Copilot AI balanced review requested due to automatic review settings October 15, 2026 06:05

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@berry-13
berry-13 marked this pull request as ready for review October 15, 2026 06:05
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 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-10-16T13:42:46.867809Z 5d36d51 Manual request
🔒 Security Review ✅ Completed 2026-10-15T06:14:24.541637Z 9c35960 Draft marked ready
ℹ️ 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: 9c35960a1d

ℹ️ 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 on lines 419 to 420
/**
* Builds the security-sensitive provider source/file association in typed

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the documented compatibility export

Existing consumers that import collectModelBoundHistoricalFileIds from @librechat/api will fail after this removal: src/index.ts exports ./middleware, whose index exports this module, and the deleted comment explicitly identifies this function as the backward-compatible view. A repository-wide usage search only establishes that LibreChat itself no longer calls the helper; it does not make a published package export dead. Keep the delegating shim or defer its removal to a breaking release.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in ab85b27: the collectModelBoundHistoricalFileIds shim is restored, and so are the other published exports this diff removed despite a compatibility or deprecation contract (the JSON schema to Zod converter and the deferDeliveryUntilSynchronized transport option).

@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: ab85b27bcc

ℹ️ 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".

@@ -741,41 +634,6 @@ export function getModelMaxTokens(
return getModelTokenValue(modelName, maxTokensMap[endpoint as keyof typeof maxTokensMap]);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the published output-token lookup

When an installed consumer imports getModelMaxOutputTokens (or either exported output-token map) from @librechat/api, this removal makes the import undefined and breaks that consumer. These symbols were part of the published root entrypoint through src/utils/index.ts and src/index.ts, and the legacy API suite extensively exercised the helper before its tests were deleted here; repository-wide internal non-use does not make a published export safe to remove in a non-breaking refactor. Retain a compatibility export and its maps, or reserve their removal for a breaking release.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not changing this one: @librechat/api is not published (npm view @librechat/api returns 404 on registry.npmjs.org), so its only consumer is /api in this repo, and a grep across api/, client/ and packages/ finds no remaining caller of getModelMaxOutputTokens or the output-token maps. The earlier restore kept only exports with an explicit compatibility or deprecation contract in their JSDoc; plain unused helpers like this one are what the cleanup removes.

@codegraph-librechat codegraph-librechat Bot added 🗺️ Backend Infra codegraph: the taxonomy area this belongs to (classifier, confidence ≥ 0.9) 🛡️ security review labels Oct 15, 2026
@berry-13
berry-13 added this pull request to stack #17161 October 15, 2026 16:13
@berry-13
berry-13 force-pushed the refactor/dead-code-packages-api branch from ab85b27 to 5d36d51 Compare October 15, 2026 20:03
@berry-13

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: 5d36d51433

ℹ️ 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".

@berry-13
berry-13 merged commit ecd6943 into dev Oct 16, 2026
46 checks passed
@berry-13
berry-13 deleted the refactor/dead-code-packages-api branch October 16, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🗺️ Backend Infra 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.

2 participants