mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-16 13:00:55 +00:00
* 🎨 chore: Enforce Design-System Rules With @shadcn/lint Registers @shadcn/lint for client/src and packages/client/src, resolving\n@librechat/client as the design system so a className that overrides what a\nprimitive owns is reported with the variants and sizes to use instead.\n\nFive rules run at error. no-unknown-classes stays off: it needs Tailwind v4.\nContracts record what callers legitimately own (text typography, skeleton\nsilhouette); eslint-suppressions.json records the 3,141 violations the tree\nalready carried, so the rules gate new code without a tree-wide migration.\n * 🩹 fix: Close the Gaps Review Found in the Design-Rule Gate Five findings against this pull request, and one that killed its CI: - The lockfile entries this change added resolved to a private mirror, so every job died in `npm ci`. They now resolve from registry.npmjs.org, with each integrity hash checked against the tarball npmjs.org serves. - The pre-commit hook ran ESLint twice and the first run had no `--pass-on-unpruned-suppressions`, so it exited 2 on the suppression the fix had just made unused and lint-staged never reached the command that tolerates it. One invocation now does both; ESLint applies suppressions after fixes, so it reports the post-fix state. - `scripts/static-checks.mts` omitted that same flag, so `npm run static-checks` failed locally on a diff the Static Checks lane passes. - `lint:design:suppress` recorded a moved file's new path and left the old one behind, because only `--prune-suppressions` removes it and ESLint refuses both flags in one run. The script now chains the prune, and CLAUDE.md documents the scoped recipe that does not re-baseline the whole surface. - The design rules matched only `.ts`/`.tsx`, so the client's `.jsx` entry points bypassed all five. Both globs now cover `.js`/`.jsx`; the one violation that exposed — an inline `display: none` on App.jsx's silent-audio iframe — is fixed at the source rather than recorded. - A suppressions-only diff started no workflow and nothing read the baseline. It is now a trigger path and its own filter group, and a new `suppressions` check rejects a shape ESLint cannot load, a count no run can reach, a rule the plugin does not define, and a path that no longer exists. The count-neutral swap two reviewers raised is not closed: ESLint's baseline format records a count, not violation identities, so replacing one suppressed violation with another of the same rule in the same file is invisible here. CLAUDE.md now says that instead of implying detection. Four `@scenario`-tagged specs cover the developer-facing behaviour: the report a caller gets on a primitive override, a `.jsx` file being checked, the fixing commit staying green (with the counter-proof that it exits 2 without the flag), the move recipe dropping the old path, and every locked tarball being fetchable from the public registry. * 🧪 fix: Close the Dormant-Entry and Gate-Trigger Gaps The suppressions gate did not run when the file that implements it changed, a count recorded against a path no design-rule lint reaches passed validation, the documented re-record chain could not run under cmd.exe, and the lockfile scenario failed a legitimate SheetJS upgrade. The trigger scenarios also ran four full-tree sweeps inside one test that declared a 180s deadline for work measured at 100-280s per sweep. - scripts/static-checks.mts: `scripts/static-checks.mts` joins the suppressions filter and the whole-record trigger, and a recorded path ESLint never reports on is rejected as dormant. - package.json/CLAUDE.md: `|| node -e ""` in place of `|| true`, which cmd.exe does not define. - e2e: the whole-record triggers are a matrix over a miniature repository (2-6s each instead of 100-280s), the oversized scenario is split into five behaviour-shaped ones, scratch baselines live in os.tmpdir(), and the lint gate runs in one project because it has no viewport. * 📏 chore: Re-Record the Counts Dev Moved Under the Backlog Rebasing onto dev brought #16067, which restyled three files the recorded backlog speaks for: MarketplaceSidebar.tsx gained one arbitrary value and two `no-restyle` violations, ToolsMarketplaceDialog.tsx gained one, and SkillsDialog lost one. Counts above the file fail the lint for whoever edits it next; the one below leaves capacity a later violation would spend. Scoped re-record and prune of those three paths, per the recipe in CLAUDE.md. * 🧭 test: Run the Copied Runner From the Tree It Is Testing The trigger matrix pointed the copied static-checks runner at a miniature repository but invoked it from the real one. The runner derives its repository from its own location and relativizes file arguments against the working directory, so `eslint.config.mjs` resolved to a path outside the miniature tree, the suppressions group read as "not affected by this diff", and the scenario passed a check that never ran (verify recorded it as a failure: exit 0 where a rejection was expected). `run` now takes a `cwd`, and both synthetic-root probes use it. * 🔇 fix: Reject a Disable Comment With Nothing Behind It Yet Comparing the two ESLint runs finds a directive only while it is silencing something. A `/* eslint-disable shadcn/no-raw-colors */` over a file with no raw colour left both runs agreeing, so it landed unseen and then silenced the first violation anyone added to that file. The configured run now also asks for unused directives, which is how ESLint names a disable with nothing behind it: a dormant design-rule disable and a dormant blanket disable are rejected, a dormant directive for another rule is not. Neither root carries one today (0 reports across 2,241 files), so what this rejects is new ones. The same pass also has to see the primitives' variants, so `validateSuppressions` builds `packages/client/dist` before the directive check rather than inside the capacity scan that follows it; without the metadata both runs report strictly fewer design diagnostics and a comment silencing a `no-restyle` violation is invisible to the comparison. * 🧱 fix: Count the Library's Build Inputs as Sources `designMetadataIsFresh` compared `packages/client/dist` with `packages/client/src` alone, so a commit that changed only the library's manifest or its tsdown config left every source older than the build and the runner skipped the rebuild. The design rules then classified against output emitted under the old contract — locally only, since CI always builds before validating, which is the shape of divergence nobody sees until the lane disagrees with the commit that passed. Both files already count as design metadata everywhere else (the suppressions filter, the whole-record trigger); they now count in the freshness comparison too. The scenario runs the miniature repository with an observable `build:client-package`: a current build is not rebuilt, and touching either input asks for one. * ⏱️ test: Set the Times the Freshness Rule Compares The rebuild scenario wrote the build output and then the manifest, and node wrote both inside the same millisecond, so the manifest was not newer than the build and the runner correctly declined to rebuild — the assertion failed on the filesystem clock rather than on the rule. The scenario now sets each mtime it depends on with `utimesSync`, which is what it meant to say. * 🩹 fix: Restore the Write the Import Edit Dropped Adding \ to the import list replaced \ instead of joining it, and nothing local caught it: no tsconfig covers e2e/, and the flat config leaves \ to TypeScript there. The mock harness did — every scenario in the file failed with ReferenceError — which is the point of running it. Typechecked the four scenario files directly this time. * 🚫 fix: Reject Every Inline Escape, Not Only the Ones in Use Codex found three more ways past the gate, one shape each. A blanket \ busy silencing an unrelated rule is used, so ESLint's unused-directive report never names it, and the configured-versus-ignored comparison sees no design delta — it waits for the file's first design violation and takes it. Inline \ over a clean file is invisible the same way. And a nested baseline that drops an entry for an unchanged source was checked against its remaining keys only, so the violation it used to speak for went unread. The directive check now has two halves: ESLint still answers what a comment is silencing today, and the comments themselves are read out of the parser — not the text, so a string that reads like a directive is not one — for a disable naming a design rule, a blanket disable, or inline configuration naming a design rule, whether or not anything is behind it yet. That supersedes \, which could only see the unused ones. Neither design root carries any of the three today. \ unions the entries a diff removes into a nested baseline's file list, and \ joins the design metadata: it carries the \ mapping, the entry emit and the include/exclude that decide what reaches the bundle the rules read, which is why the repository's own build caches key on \. * 🔐 fix: Make the Hook Select What the Lane Selects, and Distrust a Half-Built Bundle Two more shapes of the same mistake — trusting a proxy for the thing itself. The pre-commit group listed individual files while the Static Checks lane's filter also names both design roots, so staging a primitive ran ESLint locally and the whole-record sweep only in CI: the commit passed and the lane failed on callers nobody staged. The hook's group is now the lane's filter pattern for pattern, and the count-edit scenario reads both files and fails when the two lists differ, so the next path added to one has to reach the other. Freshness took the newest timestamp under \ as proof of a finished build. The build empties that directory before it writes, so a build that failed halfway leaves a recent directory over a bundle with no entry point, and every later run skipped rebuilding it. The check now also requires what \ promises inside \ — its entry fields and every string leaf of \ — to exist. * 🧾 fix: Give the CDN Exception to xlsx, Not to the Host The lockfile rule allowed \ for anything and then compared versions against the base branch, so regenerating the lockfile against that CDN could move any package off the public registry at the same version and pass. The exception now belongs to the package — \, at any version, nested or not — and every other entry has to come from the registry, which drops the version comparison and the shallow-clone caveat with it. The rule is a function the scenario applies to the repository's lockfile and to lockfiles written for the purpose: an xlsx upgrade on its CDN passes, lodash rewritten onto the same CDN at the same version fails, a new package from a private mirror fails, and a nested xlsx is still xlsx. * ↩️ fix: One Local Entry Point, Asked of the Runner The pre-commit group I added for the backlog and the design metadata was redundant and slower: \ already ends by running the runner over the staged diff with \, and that run selects its groups from the same filters — including both design roots, and including deletions, which lint-staged never hands to a task. The group made the whole-record sweep run twice for one commit. It is gone. The scenario now asserts the property instead of a copy of the list: the hook still runs the runner over the staged diff, and for every path the lane's suppressions paths-filter names, the runner reports that check as selected (\), while a path outside both roots is not affected. * 🗺️ fix: Assert Where the Rules Are Asked, Not Only What They Found A report cannot say where the rules were asked. Narrowing the design block over a subtree that happens to be clean today — \, say — produces no new diagnostic, no changed count, and no baseline entry to inspect, so every gate stays green while the styling written there next goes unread. The new scenario asks the resolved flat configuration instead: for one representative path of each source extension in every directory under both roots, all five design rules must be at error in the app and at the library's own profile inside \ (overriding a primitive is off there; colour and inline geometry still hold), and server code must carry none of them. 1,184 paths, answered through ESLint's API in one process in under a second — \ would have been eleven minutes of subprocesses. * 🎯 fix: Spend the Budget Once — Reject a Swap Inside the Allowance The recorded count is a budget per file and rule, and until now it could be respent: removing one raw colour while adding a different one keeps the total equal, so ESLint suppresses the new violation inside the old allowance and the count checks see nothing move. The backlog was documented as unable to tell that apart, and it was the one hole Codex kept finding its way back to. What the totals cannot distinguish the diagnostics can. For every design source a diff touches, the runner now lints that file's version at the base — through ESLint's API, one process for the whole diff — and reports a design-rule message the head has that the base did not, naming it. A violation that only moved keeps its message and is not reported; a file with no version at the base has no allowance to hide in and the count checks already answer for it. Measured on the checkout: swapping one `fill="#AFC1FF"` for `fill="#BEEF11"` in a file recording five raw colours is rejected in 4.9s naming the new one, and the unchanged file passes. The scenario proves all three states — recorded, moved, swapped — in a miniature repository with a history of its own, and CLAUDE.md no longer claims the swap is undetectable. * 🧰 fix: The Root Manifests Are Build Inputs Too \ is defined in the root manifest and runs with the toolchain the root lockfile pins, and both already select the suppressions check — but neither counted as an input to bundle freshness, so a commit that changed the build definition could validate locally against output made by the previous one while CI rebuilt. They count now, beside the library's own manifest, build config and compiler options, and the rebuild scenario drives the lockfile case through the miniature repository's observable build. * 🧭 fix: Read the Base From the Merge Base, and Give a New File No Allowance Two holes in the swap check, both about what "the base" means. It read each changed file's prior version from the base branch's tip, while the changed-file set comes from \. With \ moving under a branch, that calls a violation dev added since the branch diverged this change's doing, and forgives one this change added that dev happens to carry. It resolves the merge base once and reads from there. And a file with no version at the base was skipped, so adding a source with a violation and recording it in the same commit passed as "already recorded". A file the change adds has no allowance to inherit: every design violation in it is new. Renames are followed (\), so the documented re-record of a moved path stays green — its violations came with the file. The scenario now walks recorded, moved, swapped, added-with-its-own-entry and renamed through one miniature repository with a history of its own. * 🔗 fix: One Base Commit, Asked Once \ resolved the merge base; \ still read the baseline from the base branch's tip, so the two checks in the same run disagreed about what "before" meant — and an entry the base branch edited after the branch diverged entered \ as though this change had edited it. \ resolves it once and both ask it. * 🔤 fix: A Suppressed Message Carries Its Text \ omitted \, and the swap check reads it — the union of messages and suppressed messages is what a file's diagnostics are, and what the baseline silences is exactly what that check has to see. Nothing local caught it: node strips types without checking them and no tsconfig covers scripts/, so the runner is now typechecked directly ([41m [0m [41m[37m This is not the tsc command you are looking for [0m [41m [0m To get access to the TypeScript compiler, [34mtsc[0m, from the command line either: - Use [1mnpm install typescript[0m to first add TypeScript to your project [1mbefore[0m using npx - Use [1myarn[0m to avoid accidentally running code from un-installed packages, clean). * ⚖️ fix: Let the Record Grow, Out Loud The swap check reported every violation a change added, which also forbade the one path CLAUDE.md sanctions: add the violation and raise the count, so the debt arrives as a line in the diff a reviewer reads. What separates that from a swap is not the violation, it is whether the record said so — a swap keeps the count still. The check now charges each new diagnostic against how much that entry's count grew between the merge base and here, and reports only what the growth does not cover. Measured: a swap at an unchanged count fails, the same violation with the count raised passes, and raising nothing fails naming the class. CLAUDE.md says which of the three is which. * 🚧 fix: A File the Change Adds Brings No Allowance Letting the record grow to cover a new violation is right for a file that already existed — the raised count is the line a reviewer reads — but it also let a brand-new source arrive with its own entry, which is the backlog recording what the tree never owed. Growth applies only where there is something to grow: a file present at the merge base, renamed or not. A file the change adds owes everything in it, and the message says so. * ✏️ test: Assert the Wording the Added-File Rule Uses The scenario still expected "is new here" for a file the change adds, which now gets its own message — the backlog records what the tree owed, not what a new file brings. The harness caught it; the assertion follows the rule. * 🧮 fix: Ask Git What Existed, and Where Its Entry Lived Three faults in the new swap check, one cause: it inferred from content what only git can answer. A tracked empty file at the base reads as absent, so an existing file was treated as newly added and its recorded growth refused. A renamed file's growth was measured at the new key, where the base has no entry at all, so the move itself looked like room to spend. And a base commit missing from the clone made every changed file look new, silently. Existence is now \ succeeding, the allowance is read under the name the entry had (the rename map already resolved the source; it resolves the entry too), and a base commit that is not in the clone is reported rather than guessed at. Measured: a rename carrying a new violation with its count raised at the new key fails, a plain rename passes, a swap at an equal count fails. * 🗃️ fix: A Deleted Baseline Is a Deleted Baseline, Nested or Not The root baseline's deletion failed the check; a nested one was quietly dropped from the target list by the same \ filter that was meant to skip paths never present. What a nested baseline silences goes back to being reported — or stops being — and nothing else reads it, so its deletion is the same failure and now says which file is missing. * 📚 fix: A Baseline in the Diff Is Read in Full The comment said a baseline named in the diff is checked in full; the code checked only the entries the diff moved, because \ made \ non-empty and the full-record branch required it to be empty. So a count edit never revalidated the rest of the record — dormant paths and stale counts in unedited entries went unread. Editing the baseline now reads every path it records. And the rename map keyed on git's raw line, so a CRLF checkout left a \ on the new path and the rename never matched — the file read as added and its inherited allowance was refused. The lines are trimmed. * 🧷 fix: Lint the Base Under the Name It Had, and Compare a Commit With Its Parent Two last seams in the swap check. A renamed file's base contents were linted under the new path, so moving a component out of \ — where overriding a primitive is the library's own business — into \ made the destination's stricter rules apply to both sides: the diagnostics the move itself introduces looked inherited, and a matching entry would have hidden them. The base is linted as the path it had. And \, the documented single-commit mode, resolved its comparison to \ — the commit against itself, which forgives everything. It resolves to the commit's parent. * 🔖 fix: Quotes Do Not Hide an Inline Rule Configuration ESLint reads \ exactly as it reads the unquoted key, but the comment scan required the colon to follow the rule id directly, so the quoted form passed over a file that does not violate the rule yet — and then silences the first violation a primitive or config fan-out creates there. Over a violating file the two-run comparison always caught it; the dormant case is the one that slipped. The scan accepts either quoting, and the scenario carries the quoted spelling beside the rest. * 🧪 perf: A Spec Is Not Component Metadata Both roots the design rules police are full of specs — every primitive in `packages/client/src/components` has one — and editing any of them ran the two-root suppression sweep, because the metadata predicate asked only whether the path was a lintable source under a metadata root. A spec is neither: the flat config turns all five design rules off inside it and the library's tsconfig keeps it out of the bundle the caller rules resolve primitives through, so it carries no `cva` variant and can report no design diagnostic of its own. `packages/client/src/components/Button.spec.tsx` through the runner: 59.7s before, 0.0s after. The same `DESIGN_TEST_SOURCE` test is applied everywhere the invariant holds: the freshness input no longer treats a spec as something `dist` is built from (directory mtimes stay, so an added or deleted source still forces a rebuild), the directive gate no longer fails a commit over a comment in a file where the design rules are already off, and the base-vs-head lint no longer fetches a spec's base version to ask a question with one possible answer. * 🔎 fix: A Build That Reports Success Is Not a Build Two gates trusted a signal instead of the condition it stands for. `buildClientPackage` returned on the build's exit code. A build that exits 0 while leaving `packages/client/dist` incomplete or older than its sources left `designMetadataIsFresh()`'s answer exactly as it found it, and the suppression lint that follows then classified callers against a bundle describing something else — reporting fewer violations than CI, which is the failure the rebuild exists to prevent, reached through the branch meant to fix it. The freshness question is now asked again after a successful build, and a bundle still stale is an error naming `packages/client/dist`. The workflow's `on.pull_request.paths` named only the root `eslint-suppressions.json` while the inner `suppressions` filter names `**/eslint-suppressions.json`. A diff touching only a nested baseline outside `api|client|config|packages|scripts` — `e2e/fixtures`, say — started no workflow at all, so `validateSuppressions()` never ran over exactly the nested baselines it advertises. The trigger carries both spellings now. The miniature repository's `build:client-package` writes the bundle its manifest promises instead of only a marker, so the rebuild rows assert a finished build rather than a claim of one, and a build that writes nothing is its own row. * 🧭 fix: Ask the Tool, Don't Reconstruct Its Answer Four findings on the last head, and three of them were the next variant of a family this branch had already patched once. The shared cause is one habit: the gate re-derived a fact from a cheaper proxy instead of asking whatever owns it, and every round found another case the proxy got wrong. An inline `eslint` configuration comment was matched by the spelling of its rule key, so `shadcn/x`, `"shadcn/x"`, `"shadcn\/x"` and `"shadcn\u002fx"` — one key, four spellings, all of which ESLint honours — needed four regexes. The key is now decoded before it is compared, which ends the family rather than adding the fourth. Bundle freshness reduced a set of outputs to the newest file anywhere under `dist`. A resolver loads one entry, not a directory, so a build that rewrote the ESM bundle and left the CJS one or the type declarations behind passed while `@shadcn/lint` read the stale one. Every declared output is compared now, which is the same reason their existence was already checked one by one. Target discovery read `git diff --name-only` with rename detection, which names one side. `git mv eslint-suppressions.json backlog.json` therefore selected no group that owns the source, and the baseline's disappearance was reported by nothing. `--no-renames` at the single funnel makes a rename two paths; the one caller that wants the pairing asks for it separately. The fourth was the parity assertion added last round, sitting in the mock Playwright lane — whose own trigger excludes `.github/workflows` apart from its own file, so a workflow-only diff never ran the assertion guarding it. The claim moved into the runner, where the file that can break it already activates the group, and the scenario now exercises the runner both ways over a copy of the real workflow instead of reimplementing its parser. * 📝 docs: Say Which Swaps the Ratchet Misses The ratchet paragraph claimed a swap arrives as a failure, full stop. Two do not, and a reader deciding whether to trust the gate needs both. A swap whose diagnostic message equals the one it replaced is invisible, because the comparison keys on the message and some rules name the property without the value — `Inline style sets display.` is one message for `none` and for `flex`. And a swap the diff itself causes, by changing a primitive or the config, is invisible because both versions are linted under the head's design inputs. Tracked at berry-13/LibreChat#70 and berry-13/LibreChat#69. * 📏 chore: Re-Record the Count Dev Moved Under the Backlog `dev` fixed one `shadcn/no-restyle` violation in `client/src/components/SharePoint/SharePointPickerDialog.tsx`, so the rebased branch records 8 where the file now has 7. An entry with slack is exactly what this change added a check for: the unused 1 would silence the next violation anyone writes there, and the gate says so rather than letting it through. `npm run lint:design:prune` drops the one count; the trailing newline it strips is restored by prettier, the way the pre-commit hook's `*.json` group does. * 📝 docs: Drop a Recorded Count That Dev Keeps Moving The backlog total moves with every rebase that picks up new violations from `dev`, so a number written into CLAUDE.md is stale by the next re-record — it read 3,230 against a baseline holding 3,232. The recipe does not need the figure; `eslint-suppressions.json` is the record. * 📏 chore: Re-Record the Counts Canary Moved Under the Backlog Retargeting onto canary changes the tree the design rules read, so five files carry different violation counts than the recorded backlog claims: Wakeup and SubagentConversation shed no-restyle violations and picked up a require-static-classes one, and Ledger, UnifiedSidebar and ChatRoute each gained one. Re-recorded those entries and pruned; nothing else in the baseline moved. * 🧱 fix: Build the Primitives Before Recording What They Own `lint:design:record` was the one exposed design script that linted without building `packages/client/dist` first. The rules read each primitive's `cva` variants out of that bundle, so a fresh checkout or a primitive change left the recording run classifying against a library that does not exist yet and writing counts lower than the ones CI reports. Moved the build onto the record script, where the other three already have it, and dropped it from the `lint:design:suppress` wrapper so the wrapper still pays for exactly two builds. A build failure inside the wrapper is still loud: the record step cannot rewrite the baseline when the build it is chained to fails, and the prune that follows does not swallow its own. * 📏 chore: Re-Record the Counts Canary Moved Under the Backlog Rebasing onto canary picks up PR #15798, which rewrote the agent marketplace components, so eighteen recorded entries no longer describe the files they name: AgentDetail is gone, AgentCard traded its restyle and arbitrary-value violations for inline styles, AgentDetailContent grew to eighteen restyles, and CopyLink, GridSkeleton, Marketplace, MineFilterToggle, SortDropdown and LoadingDots arrived with violations nothing had recorded. Re-recorded and pruned; every entry that moved belongs to a file that commit touched, and nothing else in the baseline changed. * 🧪 test: Assert the Record Asks for a Build Before It Writes The build-freshness scenario covers the runner. Nothing covered the other entry point: `npm run lint:design:record`, which writes the budget every later change is measured against and, until now, linted whatever bundle happened to be on disk. The miniature repository's `build:client-package` appends to a log, so the scenario can ask whether the record built before it wrote, and whether a build that fails still stops the wrapper now that the wrapper no longer carries a build of its own. --------- Co-authored-by: berry-13 <berry-13@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| ISSUE_TEMPLATE | ||
| scripts | ||
| workflows | ||
| CODE_OF_CONDUCT.md | ||
| configuration-release.json | ||
| configuration-unreleased.json | ||
| CONTRIBUTING.md | ||
| FUNDING.yml | ||
| playwright.yml | ||
| pull_request_template.md | ||
| SECURITY.md | ||