Skip to content

WSI molecular tables and enrichment in the viewer package - #18

Closed
raylim wants to merge 76 commits into
masterfrom
codex/wsi-rd-molecular
Closed

raylim wants to merge 76 commits into
masterfrom
codex/wsi-rd-molecular

Conversation

@raylim

@raylim raylim commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

Fork follow-up stacked on codex/wsi-viewer-package (cBioPortal#5732). It adds the selected sample's molecular data, with optional OncoKB and CIViC annotations, to the viewer sidebar.

Behavior

  • After a patient's slides load, the viewer fetches the samples' clinical data, mutations, copy-number alterations, structural variants and mutation frequencies from the portal API in the background.
  • A sidebar MSK-IMPACT section shows, for the selected slide's sample:
    • tumor purity, TMB (linked to the sample page), MSI and metastatic site;
    • mutation, CNA and structural-variant tables, with a loading/error state for mutations.
  • Unmatched slides use the patient's reference sample.
  • The nav panel shows each sample's type badge, OncoTree code and cancer type.
  • Clinical attributes already shown in MSK-IMPACT (TMB, MSI, tumor purity, metastatic site) are left out of the generic clinical rows.
  • Enrichment updates samples in place and only for the current patient; a late response for a previous patient is dropped.

Host services

  • The package does not import app code. The app passes WsiViewerConfig.molecular (WsiMolecularServices), built by buildWsiMolecularServices() in src/shared/components/wsiViewer/wsiAppConfig.tsx:
    • showOncoKb / showCivic from the portal's show_oncokb / show_civic;
    • the OncoKB API URL and client, CIViC CNA lookup, and mutation-type simplification.
  • The OncoKB client is a dedicated instance (wsiOncoKbClientInstance.ts), so annotation failures stay out of the portal's global error handling.
  • Without these services the tables render unannotated.
  • Portal requests go through the runtime's buildApiUrl / fetchImpl.
  • New workspace:* peer dependencies: cbioportal-ts-api-client, cbioportal-utils, oncokb-frontend-commons, oncokb-ts-api-client, react-mutation-mapper.

Tests

Package Jest specs for fetching, merging and tables; mocked Playwright spec wsi-molecular-mocked.spec.ts.

🤖 Generated with Claude Code

@raylim
raylim force-pushed the codex/wsi-viewer-package branch from a5f3d4f to 59df2b2 Compare September 30, 2026 18:13
@raylim
raylim force-pushed the codex/wsi-rd-molecular branch from 77148e3 to 4ad4b92 Compare September 30, 2026 19:05
@raylim
raylim force-pushed the codex/wsi-rd-molecular branch 2 times, most recently from 4d098cc to fdd2e06 Compare September 30, 2026 20:22
raylim added a commit that referenced this pull request Oct 8, 2026
Rebuilt on codex/wsi-viewer-package (slide timing out, clinical section,
patient tab URL scoping) with the updated children: study #17, molecular
#18, agent #20 (with annotations #19) and study slides #23. #21 is closed:
its patient-tab URL scoping is now in the base and its slide timeline moved
to #28, so the timeline files, timing fields and mock routes it brought in
are left out. The previous head is kept as a parent so the update is a
fast-forward; this commit keeps the rebuilt tree.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
raylim added a commit that referenced this pull request Oct 12, 2026
raylim added a commit that referenced this pull request Oct 13, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
raylim added a commit that referenced this pull request Oct 13, 2026
Molecular (#18) and annotations/agent (#19/#20) both add to the viewer,
controller host, sidebar, runtime config and light entry; keep both, as
the previous integration did.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
raylim added a commit that referenced this pull request Oct 13, 2026
Merges the updated children: #17 b56bec1, #18 ff6ea53, #20 64712b9
(with #19 0b5a959) and #23 35c00aa (with #27 46d3dcb), all on
cBioPortal#5732 e90d380. The tree is the children merged onto each other (second
parent); the previous integration head stays the first parent so the
push fast-forwards.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Adds the cbioportal-wsi-viewer package (OpenSeadragon slide viewer with the slide list, details sidebar, panel chrome, scale bar and shareable view state) and the patient view Pathology Slides tab that serves whole-slide images from resource data. Slide resources and, when the viewer is configured, the legacy H&E resources are left out of Files & Links and the resource tabs (ResourcePolicy.isHiddenFromResourceViews, applied through ResourceTableStore's hideResource option).

Squashed onto master after resource table v2 (cBioPortal#5629); the previous history is on branch backup/codex-wsi-viewer-package-20261015.
@raylim
raylim force-pushed the codex/wsi-viewer-package branch from 7a9b5a1 to 22d3149 Compare October 15, 2026 20:07
raylim and others added 3 commits October 15, 2026 16:33
The tab count and the patient ResourcesTab table came from cBioPortal#5629's
server-driven code, which lists every resource; slides have their own
Pathology Slides tab.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… page links, study resource tabs

- Cancel a queued slide click when the hierarchy reloads, so a patient
  switch can't open the previous patient's slide.
- Request slide access with `credentials: 'include'`, like the hierarchy
  request, so an API on another origin gets its login cookie.
- Build the sidebar's patient/sample links through a new optional
  `buildPageUrl` runtime hook; the portal passes buildCBioPortalPageUrl so
  links keep the deployment context path (e.g. /beta).
- Study view: give the page's resource store the hiding policy and use its
  visibleTabs for the tabs, hasNewResourceTabs and the Files & Links
  redirect, so a hidden H&E resource is never the redirect target.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Squash of #18 onto the rebased cBioPortal#5732 after resource table v2 merged upstream.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@raylim
raylim force-pushed the codex/wsi-rd-molecular branch from 5b21891 to 643d044 Compare October 15, 2026 21:01
raylim added a commit that referenced this pull request Oct 15, 2026
…rge target)

Rebuilt from the rebased cBioPortal#5732 (44b68b8) by merging #17 (30456c9),
#18 (643d044), #20 (d81dab9, includes #19) and #23 (008ce69).

Squash of #22 onto the rebased cBioPortal#5732 after resource table v2 merged upstream.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
raylim and others added 4 commits October 15, 2026 17:34
Follows the backend rename of msk.wsi.tile_server.url to
wsi.tile_server.url: the setting isn't MSK-specific.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…server_url rename)

# Conflicts:
#	packages/cbioportal-wsi-viewer/src/wsiMetaUtils.spec.ts
#	src/shared/components/wsiViewer/wsiAppConfig.tsx
…ular

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
raylim added a commit that referenced this pull request Oct 15, 2026
…ration

#17 5304083, #18 704a81c, #20 be9a529 (with #19), #23 8f4a2bb.
The integration tree already matched them; this records the parents.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
raylim and others added 6 commits October 16, 2026 20:02
The opaque slide key is now the first 12 hex characters of the old
32-hex key. Update the slide-key doc comments, the mocked backend's
access validation, and the test fixtures to 12-hex keys.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ide keys)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Reuse hierarchySlides() for slide access registration and the empty-list
  message instead of re-walking the hierarchy.
- Share one revokeObjectUrl() helper for blob URLs.
- Derive the sidebar magnification from nativeObjectivePower().
- Drop the write-only viewerReady state, merge the filter handlers into
  applyFilters() and the selection resets into clearSelection().
- Skip cursor updates that land on the same image pixel; log tile failures
  once per terminal failure.
- Remove unused exports (buildPatientUrl, BLOCK_LABEL_TIP, WsiTheme) and
  redundant slide de-duplication; name the UNMATCHED sample id.
- Host: revert the ResourceTable and study openByDefault H&E filters (no
  live callers), reuse isNonEmptyString and isWsiTileServerConfigured, and
  type the slides-tab query from PathologySlideSettings.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
# Conflicts:
#	packages/cbioportal-wsi-viewer/src/wsiHierarchyFetchCache.ts
buildMain and build:size no longer chain the check, so heroku and local
builds don't depend on it; CI runs pnpm run checkWsiBundle after the build.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The controller read and wrote the component's fields through about thirty
one-line host getters and setters. The fields now live in a WsiViewerState
object that the component renders and the controller updates directly, with
the selection, cursor, scale and coordinate actions next to them. The host
interface keeps only what the component owns: props, filters, the container,
initial slide choice, performance reporting and the on* hooks, plus a new
onSelectionCleared hook for hosts that clear their own per-slide state.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
raylim and others added 24 commits October 27, 2026 17:44
Review follow-ups to the sample-chip and stale-hash fixes:

- The patient tab now trusts a #wsi:slide= hash only for the link it last
  showed (the opening link, or a remount after a tab switch). Going back to
  the sample the page opened with no longer reopens the slide another
  sample wrote to the hash.
- hostShowsSampleScope becomes hostOwnsSampleScope: the stain and match
  filters and "Show all slides" stay within the page's sample, so the
  list cannot widen past the sample the page filter still names. "Show
  all slides" shows only when a stain or match filter is set.
- A sample scope with no viewable slides says so instead of "No slides
  match these filters".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The viewer writes the selected slide to the #wsi:slide= hash, so after a
tab switch the remounted Pathology Slides tab read its own hash as a deep
link and dropped the page's sample scope. Only a link the page loads with
can now be a deep link; a remount at the same link keeps whatever it had
(the scope and the user's slide, or the deep link), and a changed link
still drops the stale hash.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The stain and Part/Block chip counts came from the whole patient, which
fit a link scope (a filter click widened it to the patient) but not the
page's sample scope, which now stays put: on P-0000012 / T06-IM7 the
chips read H&E 17, IHC 2 while the list showed 12 slides. With
hostOwnsSampleScope the counts are the scoped sample's. The nav panel's
showSampleScope prop becomes hostOwnsSampleScope to carry both.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…mple

Within the patient page's sample scope the button only resets the stain
and Part/Block filters; the sample stays, so "Show all slides" promised
more than it did. It now reads "Clear filters" there and keeps "Show all
slides" where resetting does show every slide (no scope, or a slide-link
scope it widens).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Review cleanup, no behaviour change: move hostOwnsScopedSample below
scopedSampleId so that getter keeps its doc comment, describe the reset as
"Clear filters" in the hostOwnsSampleScope doc, rewrap the tab's JSDoc,
rename resetOpeningWsiSlidesLink to resetLastWsiSlidesLink, and drop the
non-null assertions in the link-state check.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The filter reset showed whenever the page passed a sample or an initial
stain, even when clicking it did nothing: after a link scope had been
released (the preferred sample only picks the first slide), for a link
scope that hides no slide, or once the initial stain was cleared. It now
shows only while a stain or match filter is set, or while a link scope
the viewer may release hides some of the patient's viewable slides.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The sample chip's clear button had the same no-op case as the filter
reset: for a link sample scope that hides no viewable slide (all of the
patient's viewable slides are in that sample), clearing it changed
nothing. The list is narrowed to, and the chip names, a link's sample only
while the scope hides slides; a host-owned sample is unchanged. Tests also
cover unmatched slides hidden by a sample scope, a link that matches no
slide, a match-level link and slides the viewer cannot open.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Access control moves to the ingress: an nginx auth subrequest checks the
portal session cookie against GET /api/studies/{studyId}, and the tile
server no longer takes a JWT. The viewer therefore stops requesting
GET /api/resources/{studyId}/{resourceId}/access and sends no
Authorization header.

- Tiles: {tileServerUrl}/tiles/zxy/{z}/{x}/{y}?studyId=&key=&enc=
- Thumbnails: {tileServerUrl}/thumbnails?studyId=&key=&enc=&tw=&th=&width=&height=
  (key = serving.key, enc = serving.sealed_source, tw/th = the stored
  thumbnail size; all URL-encoded; same-origin, so the session cookie
  goes along)
- The slide registry (wsiAuth.ts) now keeps each published slide's
  serving key, sealed source, thumbnail size and tile metadata;
  getWsiSlideSource replaces the async access request. The Slide model
  carries sealed_source/thumbnail_width/thumbnail_height from the row;
  none of them is rendered.
- Removed token caching, refresh/expiry timers, OpenSeadragon ajax
  headers and the metadata prefetch that only warmed access requests.
  Tiles are still loaded with XHR so a refused tile's status is visible.
- A 401/403 from a tile or the thumbnail preview fails the slide at once
  with a "reload the page or sign in again" message in the existing
  error state.
- The hidden prop keeps pausing panel shortcuts and OpenSeadragon
  auto-resize; only the token refresh part is gone.
- Jest specs, the mocked Playwright WSI suite and the README portal
  contract follow the new contract (studyId/key/enc, tw/th, no
  Authorization header, no /access request, no image id).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…l#5732: tile requests by key and sealed source, no token)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The tile server sizes thumbnails itself and ignores tw/th, so thumbnail
URLs carry only studyId, key, enc, width and height. The viewer no longer
reads the stored thumbnail size from a slide's row; nothing laid out by it.

The Playwright mock now models the ingress (401/403 on session refusal)
separately from the tile server, which answers 404 for a key/enc mismatch
and never 401/403.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A preview error, 401/403 included, now just drops the preview. Tiles
decide whether the slide fails: a tile answered 401/403 still shows the
session-expired error at once. Before, a refused preview failed the mount
while tiles kept loading, so the error flashed and then cleared.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
fetchWsiPatientHierarchy registered a hierarchy's slides whenever the
shared cache promise resolved, even after the caller aborted or after
clearWsiSlideSources (e.g. for a change of user), bringing back slides the
clear had removed. The registry now has a generation that every
clearWsiSlideSources bumps; a call captures it before its request and
skips registration if it changed or if the caller aborted. Registering a
hierarchy does not bump it, so concurrent loads of other patients are
unaffected.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…erver

Tile and thumbnail URLs are now built the same way: the tile-server base is
normalized to exactly one trailing slash and the path and query are
appended, so `/wsi` and `/wsi/` give the same URLs and a relative base
stays relative.

The ingress authorizes tile and thumbnail requests with the portal session
cookie, so the tile server must be same-origin with the portal. The README
says so, and the viewer logs a console.error once per cross-origin tile
server it is configured with.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…l#5732: thumbnails without tw/th, ingress-only 401/403, registry generation)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ed as 8052359)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@raylim
raylim changed the base branch from codex/wsi-viewer-package to master November 5, 2026 16:55
raylim added a commit that referenced this pull request Nov 12, 2026
…n-20261112

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

# Conflicts:
#	packages/cbioportal-wsi-viewer/src/WSIViewer.tsx
#	packages/cbioportal-wsi-viewer/src/wsiViewerController.ts
raylim added a commit that referenced this pull request Nov 12, 2026
)

This merge takes its tree entirely from deploy/wsi-rd-children-20261112
(dd19c06), the second parent:
- codex/wsi-study-slide-facets-ui (#29, 7e493f7; stacked on #23 and #27)
- codex/wsi-rd-study (#17, 0c999a1)
- codex/wsi-rd-molecular (#18, ce690cf)
- codex/wsi-summary-timeline (#28, 406f52b)

The annotation (#19) and research assistant (#20) branches merged earlier
are not part of the result. The first parent keeps the branch's earlier
history, so the push is a fast-forward.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@raylim

raylim commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

Upstreamed in two parts:

@raylim

raylim commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

Superseded by cBioPortal#5822 and cBioPortal#5823.

@raylim raylim closed this Nov 13, 2026
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.

1 participant