Skip to content

Remove seamless-immutable from cache classes#5562

Draft
alisman wants to merge 1 commit into
masterfrom
remove-seamless-immutable
Draft

Remove seamless-immutable from cache classes#5562
alisman wants to merge 1 commit into
masterfrom
remove-seamless-immutable

Conversation

@alisman

@alisman alisman commented May 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • The 3 cache classes (LazyMobXCache, SimpleCache, SampleGeneCache) used seamless-immutable purely 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.
  • Replaced with plain object spread; top-level reassignment still triggers observable.ref reactivity. SampleGeneCache keeps a small custom 2-level merge because it writes partial geneData updates that must preserve existing entries.
  • Removed 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.

Test plan

  • pnpm typecheck — passes
  • LazyMobXCache.spec.ts — all 18 tests pass (including the mobx-reactivity test)
  • CohortColumnFormatter specs (exercise MrnaExprRankCache/SampleGeneCache) — pass
  • CI green
  • Manual smoke: patient view (mutations / mRNA percentile / discrete CNA columns), study view, results view — confirm caches still hydrate
  • Profile a heavy study before/after to confirm the perf regression we were chasing is gone

Notes for reviewers

  • 17+ subclasses extend LazyMobXCache; none of them imported seamless-immutable directly — the type change on the inherited cache getter (drops the Immutable.ImmutableObject<...> intersection) is the only ripple, and the typecheck confirms nothing relied on it.
  • seamless-immutable would 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


View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

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>
Copilot AI review requested due to automatic review settings May 7, 2026 18:21
@netlify

netlify Bot commented May 7, 2026

Copy link
Copy Markdown

Deploy Preview for cbioportalfrontend ready!

Name Link
🔨 Latest commit dfe2e62
🔍 Latest deploy log https://app.netlify.com/projects/cbioportalfrontend/deploys/69fcd8274a8dcf0008904789
😎 Deploy Preview https://deploy-preview-5562.preview.cbioportal.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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.

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-immutable usage in LazyMobXCache, SimpleCache, and SampleGeneCache with plain object updates (and a targeted 2-level merge for SampleGeneCache.geneData).
  • Removed unused seamless-immutable / typings references from packages, root deps, and typings/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

Comment thread pnpm-lock.yaml
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)
@alisman alisman marked this pull request as draft May 15, 2026 19:56
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