Remove seamless-immutable from cache classes#5562
Draft
alisman wants to merge 1 commit into
Draft
Conversation
The 3 cache classes (LazyMobXCache, SimpleCache, SampleGeneCache) used
seamless-immutable purely as a forcing function for `@observable.ref`,
not for any structural-sharing benefit. The deep `merge({deep: true})`
on every cache write was scaling with total cache size and showing up
as a perf hotspot.
Replace with plain object spread — top-level reassignment still triggers
observable.ref reactivity. SampleGeneCache needs a small custom 2-level
merge because it writes partial geneData updates that must preserve
existing entries for the same sampleId.
Also drop dead `seamless-immutable` deps from react-mutation-mapper and
react-variant-view (declared but never imported), the unused
`redux-seamless-immutable` typings stub, and a couple of stale comments.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
✅ Deploy Preview for cbioportalfrontend ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes seamless-immutable from the project’s MobX cache implementations and related package dependencies to reduce cache-write overhead (previous deep merge + freeze on every write) while preserving MobX @observable.ref reactivity via top-level reassignment.
Changes:
- Replaced
seamless-immutableusage inLazyMobXCache,SimpleCache, andSampleGeneCachewith plain object updates (and a targeted 2-level merge forSampleGeneCache.geneData). - Removed unused
seamless-immutable/ typings references from packages, root deps, andtypings/missing.d.ts. - Cleaned up stale comments referencing immutable behavior.
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| typings/missing.d.ts | Removes unused redux-seamless-immutable module stub. |
| src/shared/lib/LazyMobXCache.ts | Drops seamless-immutable and replaces deep merge with shallow object spread on cache updates. |
| src/shared/components/lazyMobXTable/LazyMobXTable.tsx | Removes outdated comment about immutable .map() behavior. |
| src/pages/patientView/clinicalInformation/SampleGeneCache.ts | Removes seamless-immutable; implements explicit merge to preserve existing geneData entries on partial updates. |
| packages/cbioportal-frontend-commons/src/lib/SimpleCache.ts | Drops seamless-immutable; replaces deep merge with shallow object spread. |
| packages/cbioportal-frontend-commons/src/api/remoteData.ts | Removes outdated comment referencing seamlessImmutable.from(). |
| packages/react-variant-view/package.json | Removes unused seamless-immutable dependency. |
| packages/react-mutation-mapper/package.json | Removes unused seamless-immutable dependency. |
| packages/cbioportal-frontend-commons/package.json | Removes seamless-immutable dependency. |
| package.json | Removes seamless-immutable and @types/seamless-immutable from root deps. |
| pnpm-lock.yaml | Removes seamless-immutable entries; also changes some peer resolution details (see comment). |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
| react-collapse: | ||
| specifier: ^4.0.3 | ||
| version: 4.0.3(react-motion@0.4.8(react@16.14.0))(react@16.14.0) | ||
| version: 4.0.3(react-motion@0.5.2(react@16.14.0))(react@16.14.0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LazyMobXCache,SimpleCache,SampleGeneCache) usedseamless-immutablepurely as a forcing function for@observable.ref— not for structural sharing. The recursive deep merge + freeze on every cache write was scaling with total cache size.observable.refreactivity.SampleGeneCachekeeps a small custom 2-level merge because it writes partialgeneDataupdates that must preserve existing entries.seamless-immutabledeps fromreact-mutation-mapperandreact-variant-view(declared but never imported), the unusedredux-seamless-immutabletypings stub, and a couple of stale comments.Test plan
pnpm typecheck— passesLazyMobXCache.spec.ts— all 18 tests pass (including the mobx-reactivity test)CohortColumnFormatterspecs (exerciseMrnaExprRankCache/SampleGeneCache) — passNotes for reviewers
LazyMobXCache; none of them importedseamless-immutabledirectly — the type change on the inheritedcachegetter (drops theImmutable.ImmutableObject<...>intersection) is the only ripple, and the typecheck confirms nothing relied on it.seamless-immutablewould throw at runtime on accidental mutation of_cache. After this change, that protection is gone. I grepped for direct_cache[...]writes outside the three files and found none, but worth a careful pass during review.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmithwith what you need.