Skip to content

feat(visualization): add variant track (Phase 6.4) - #30

Merged
dsk-dev-ai merged 4 commits into
mainfrom
feat/visualization-variant
Aug 13, 2026
Merged

feat(visualization): add variant track (Phase 6.4)#30
dsk-dev-ai merged 4 commits into
mainfrom
feat/visualization-variant

Conversation

@dsk-dev-ai

@dsk-dev-ai dsk-dev-ai commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Summary

Adds the Phase 6.4 Variant Visualization track to the Genome Browser. Variants render as point marks over the coordinate-search API, with row stacking, hover tooltips, keyboard-accessible selection, and a semantic detail panel.

Also adds the official External Data & API Master Plan (docs/external-data/) as the governing reference for external-source integration across Phases 4–9.

Changes

New

  • apps/web/src/lib/genome/variant.ts — variant model (toVariant, labels, detail lines)
  • apps/web/src/lib/genome/variantGeometry.ts — pure point-mark geometry + row stacking
  • apps/web/src/lib/genome/variantApi.tsfetchVariants adapter over the coordinate-search API
  • apps/web/src/components/genome/VariantTrack.tsx — point-mark track with selection + detail panel
  • Tests: variant.test.ts, variantGeometry.test.ts, variantApi.test.ts, VariantTrack.test.tsx
  • docs/visualization/variant.md, docs/external-data/MASTER_PLAN.md, docs/external-data/README.md

Enriched

  • lib/genome/types.ts + lib/genome/api.tsVariantFeature gains variantId, variantType, quality, filterStatus, geneId, description
  • GenomeBrowser.tsx delegates kind: 'variants' tracks to VariantTrack
  • GenomeBrowserDemo.tsx wires fetchVariants; page.tsx metadata updated to Phase 6.1–6.4

Validation

  • biome lint clean · tsc --noEmit clean · 186/186 web tests pass · make build succeeds

Known issue (pre-existing, not from this PR)

The backend search endpoints return raw SQLAlchemy ORM objects in items: list[Any], so any search returning rows fails JSON serialization with PydanticSerializationError (500), and /search/suggestions fails on a SELECT DISTINCT ... ORDER BY error. This blocks live-data gene/variant tracks end-to-end; the fixture-based gene/transcript viewer renders correctly. A separate backend fix is required.

Summary by Sourcery

Add a reusable, coordinate-accurate variant track to the Genome Browser and wire it to the coordinate-search API, enriching the variant data model and documentation.

New Features:

  • Introduce a VariantTrack component that renders point variants with keyboard-accessible selection and a detail panel within the Genome Browser.
  • Add a variant domain model, geometry utilities, and a variant-specific API adapter over the coordinate-search endpoint.
  • Expose the variant track in the visualization demo and update site metadata to include the Phase 6.4 variant milestone.

Enhancements:

  • Enrich VariantFeature with additional optional attributes such as accession, type, quality, filter status, gene linkage, and description.
  • Refactor GenomeBrowser to delegate variant tracks to the reusable VariantTrack component instead of inline rendering logic.
  • Clarify and expand visualization roadmap and README to document the delivered Phase 6.4 variant visualization and future milestones.

Documentation:

  • Add detailed documentation for Phase 6.4 Variant visualization, including architecture, a11y behavior, and test coverage.
  • Introduce an External Data & API master plan document and index it from the main README and external-data docs overview.

Tests:

  • Add unit tests for the variant domain model, geometry, API adapter, and VariantTrack component, and extend existing API tests to cover enriched variant attributes.

Summary by CodeRabbit

  • New Features

    • Added variant visualization to the Genome Browser and demo with viewport-based loading and stacked point markers.
    • Added keyboard- and pointer-accessible variant selection with detailed information panels.
    • Added richer variant details, including type, quality, filter status, linked genes, and descriptions.
    • Invalid or incomplete variant records are filtered automatically.
    • Added loading, empty, error, and retry states for variant tracks.
  • Documentation

    • Added External Data & API documentation and master planning materials.
    • Documented and marked Variant Visualization milestone 6.4 as complete.

@sourcery-ai

sourcery-ai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a dedicated, reusable variant track to the Genome Browser that fetches variants via the coordinate-search API, maps them into an enriched VariantFeature/Variant domain model, computes point-mark geometry with row stacking, and renders an accessible VariantTrack component with keyboard-selectable marks and a detail panel, alongside documentation for Phase 6.4 and an External Data & API master plan.

Sequence diagram for the new VariantTrack data flow

sequenceDiagram
  actor User
  participant GenomeBrowserDemo
  participant GenomeBrowser
  participant BrowserTrack
  participant VariantTrack
  participant useGenomeTrack
  participant fetchVariants
  participant requestCoordinateSearch
  participant BackendSearchAPI

  User ->> GenomeBrowserDemo: open /visualization
  GenomeBrowserDemo ->> GenomeBrowser: render with tracks (kind variants)
  GenomeBrowser ->> BrowserTrack: render track
  BrowserTrack ->> VariantTrack: track kind variants

  VariantTrack ->> useGenomeTrack: useGenomeTrack(track, debouncedViewport)
  useGenomeTrack ->> fetchVariants: loader(interval, signal)
  fetchVariants ->> requestCoordinateSearch: requestCoordinateSearch(variant, interval, signal, pageSize)
  requestCoordinateSearch ->> BackendSearchAPI: POST /search/variant/coordinate
  BackendSearchAPI -->> requestCoordinateSearch: items: RawSearchItem[]
  requestCoordinateSearch -->> fetchVariants: RawSearchItem[]
  fetchVariants -->> useGenomeTrack: Variant[]
  useGenomeTrack -->> VariantTrack: data (status, label, data)

  VariantTrack ->> VariantTrack: variantsInViewport / layoutVariantMarks
  VariantTrack ->> User: render SVG marks + VariantDetail

  User ->> VariantTrack: click / keypress on variant mark
  VariantTrack ->> VariantTrack: handleSelect(variant)
  VariantTrack ->> User: update selected mark + detail panel
Loading

File-Level Changes

Change Details Files
Route Genome Browser variant tracks through a new reusable VariantTrack component instead of inline SVG logic.
  • Remove the inline 'variants' branch from GenomeTrackSvg and restrict it to span features only.
  • Introduce BrowserTrack dispatch logic that renders VariantTrack when track.kind is 'variants'.
  • Ensure existing span tracks still use useGenomeTrack and GenomeTrackSvg with unchanged SVG/axis behavior.
apps/web/src/components/genome/GenomeBrowser.tsx
Define and use a typed Variant domain model and geometry utilities to normalize API records and compute stacked point-mark layout.
  • Introduce Variant model helpers for normalization (toVariant), validation (isValidVariant), and display/accessible labels and detail lines.
  • Add variantGeometry utilities for viewport filtering, scale-based x mapping, row-stacked layout with minimum pixel separation, and lane height/row y computation.
  • Enrich VariantFeature with optional variant metadata fields such as variantId, variantType, quality, filterStatus, geneId, and description, and map them in toVariantFeature.
apps/web/src/lib/genome/variant.ts
apps/web/src/lib/genome/variantGeometry.ts
apps/web/src/lib/genome/types.ts
apps/web/src/lib/genome/api.ts
Add a thin variant data adapter over the coordinate-search API and wire it into the visualization demo.
  • Implement fetchVariants as a typed adapter over requestCoordinateSearch('variant', ...) that normalizes RawSearchItem records into Variants and filters out invalid coordinates.
  • Switch GenomeBrowserDemo's variants track loader from fetchVariantFeatures to fetchVariants, preserving existing interval/AbortSignal behavior.
  • Cover the adapter with tests that assert endpoint URL, request body, signal wiring, and normalization/filtering semantics.
apps/web/src/lib/genome/variantApi.ts
apps/web/src/app/visualization/GenomeBrowserDemo.tsx
apps/web/src/lib/genome/variantApi.test.ts
Implement an accessible VariantTrack SVG component with keyboard-selectable point marks and a detail panel.
  • Render variants in viewport using shared Genome Browser scale and variantGeometry layout, drawing vertical marks with stacked rows and a labelled SVG group.
  • Add interactive, keyboard-focusable rect overlays per mark (role="button", aria-pressed, Enter/Space handling) that toggle selection state and color/stroke width.
  • Render a VariantDetail section under the SVG showing labelled fields derived from variantDetailLines for the selected variant, and cover behavior with a dedicated test suite.
apps/web/src/components/genome/VariantTrack.tsx
apps/web/src/components/genome/VariantTrack.test.tsx
apps/web/src/lib/genome/variantGeometry.test.ts
apps/web/src/lib/genome/variant.test.ts
Update docs and metadata to reflect Phase 6.4 Variant Visualization and add the External Data & API Master Plan docs section.
  • Adjust visualization docs/roadmap and README to set Phase 6.4 — Variant Visualization as implemented, document the new variant track scope, and link the variant.md doc.
  • Add docs/external-data/MASTER_PLAN.md plus README and root README link as the governing reference for external source integration across Phases 4–9.
  • Update visualization page metadata/description to mention the Phase 6.4 Variant track and refine roadmap notes for later visualization phases.
docs/visualization/roadmap.md
docs/visualization/README.md
docs/visualization/variant.md
docs/external-data/MASTER_PLAN.md
docs/external-data/README.md
README.md
apps/web/src/app/visualization/page.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@dsk-dev-ai, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 115 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 75093da0-4bb4-4083-85c3-c2917533fce1

📥 Commits

Reviewing files that changed from the base of the PR and between 4ddd0c0 and b434dd8.

📒 Files selected for processing (3)
  • docs/external-data/MASTER_PLAN.md
  • docs/external-data/README.md
  • docs/visualization/variant.md

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 322fcf12-4637-4eb0-b1da-01a36c4444df

📥 Commits

Reviewing files that changed from the base of the PR and between 13287af and 4ddd0c0.

📒 Files selected for processing (8)
  • apps/web/src/components/genome/GenomeBrowser.tsx
  • apps/web/src/components/genome/VariantTrack.test.tsx
  • apps/web/src/components/genome/VariantTrack.tsx
  • apps/web/src/lib/genome/api.ts
  • apps/web/src/lib/genome/useGenomeBrowser.ts
  • apps/web/src/lib/genome/variant.test.ts
  • apps/web/src/lib/genome/variant.ts
  • apps/web/src/lib/genome/variantApi.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • apps/web/src/lib/genome/variant.test.ts
  • apps/web/src/components/genome/VariantTrack.tsx
  • apps/web/src/components/genome/VariantTrack.test.tsx
  • apps/web/src/lib/genome/api.ts
  • apps/web/src/components/genome/GenomeBrowser.tsx

📝 Walkthrough

Walkthrough

Adds Phase 6.4 variant visualization. The change introduces typed variant normalization, a coordinate-search adapter, pixel geometry and row stacking, an interactive VariantTrack, Genome Browser integration, tests, and supporting documentation.

Changes

Variant Visualization

Layer / File(s) Summary
Variant data contracts and loading
apps/web/src/lib/genome/types.ts, apps/web/src/lib/genome/variant.ts, apps/web/src/lib/genome/variantApi.ts, apps/web/src/lib/genome/api.ts, apps/web/src/lib/genome/*test.ts
Defines variant metadata, normalization, validation, labels, detail lines, coordinate-search loading, abort handling, and invalid-record filtering.
Variant mark geometry
apps/web/src/lib/genome/variantGeometry.ts, apps/web/src/lib/genome/variantGeometry.test.ts
Adds viewport filtering, shared-scale coordinate mapping, deterministic row stacking, lane sizing, and row positioning.
Interactive track and browser integration
apps/web/src/lib/genome/useGenomeBrowser.ts, apps/web/src/components/genome/VariantTrack.tsx, apps/web/src/components/genome/VariantTrack.test.tsx, apps/web/src/components/genome/GenomeBrowser.tsx, apps/web/src/app/visualization/GenomeBrowserDemo.tsx, apps/web/src/app/visualization/page.tsx
Adds typed track dispatch, interactive SVG variant marks, loading and retry states, keyboard selection, detail panels, browser delegation, demo loading, and Phase 6.4 page text.
External data and visualization documentation
README.md, docs/external-data/*, docs/visualization/*
Adds external-data architecture documentation and records Phase 6.4 variant visualization as implemented.

Estimated code review effort: 4 (Complex) | ~45 minutes

Mergeability Score: ⚪ Minimal · up to 4ddd0

The PR adds localized variant visualization behavior and documentation, with no actionable merge-blocking risk remaining beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant GenomeBrowserDemo
  participant BrowserTrack
  participant VariantTrack
  participant fetchVariants
  participant CoordinateSearchAPI
  participant VisualizationContainer

  GenomeBrowserDemo->>BrowserTrack: provide variant track and viewport
  BrowserTrack->>VariantTrack: render variant track
  VariantTrack->>fetchVariants: request viewport interval
  fetchVariants->>CoordinateSearchAPI: post coordinate-overlap search
  CoordinateSearchAPI-->>fetchVariants: return raw variant records
  fetchVariants-->>VariantTrack: return normalized valid variants
  VariantTrack->>VisualizationContainer: render marks and lifecycle state
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding the Phase 6.4 variant track to visualization.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/visualization-variant

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai sourcery-ai 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.

Hey - I've found 1 issue, and left some high level feedback:

  • The normalization logic in toVariant (variant.ts) and toVariantFeature (api.ts) is nearly identical; consider consolidating into a single shared helper to avoid drift if the variant schema changes.
  • In VariantTrack, data.data is coerced to VariantFeature[] with a cast; if possible, thread a more specific type through useGenomeTrack or the loader typing so you don’t need an unchecked cast at the adapter boundary.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The normalization logic in `toVariant` (variant.ts) and `toVariantFeature` (api.ts) is nearly identical; consider consolidating into a single shared helper to avoid drift if the variant schema changes.
- In `VariantTrack`, `data.data` is coerced to `VariantFeature[]` with a cast; if possible, thread a more specific type through `useGenomeTrack` or the `loader` typing so you don’t need an unchecked cast at the adapter boundary.

## Individual Comments

### Comment 1
<location path="apps/web/src/lib/genome/variant.ts" line_range="45-48" />
<code_context>
+/**
+ * Normalizes a raw variant record from the coordinate-search API.
+ *
+ * Mirrors `toVariantFeature` in `lib/genome/api.ts` so the model module is
+ * self-contained; the shared request pipeline remains in `api.ts`.
+ */
+export function toVariant(item: RawSearchItem): Variant {
+  const position = asNumber(item.position)
+  const chromosome = asString(item.chromosome)
</code_context>
<issue_to_address>
**suggestion:** Reduce duplication between `toVariant` and `toVariantFeature` to avoid divergent mapping logic.

This normalization closely duplicates `toVariantFeature` in `api.ts` (same coercions, name building, optional fields, etc.), which makes it easy for them to diverge (e.g., new or changed fields applied in one place but not the other). Please consider centralizing the mapping logic—either via a shared mapper that returns `VariantFeature` and is reused here, or by extracting the common helpers (`asString`, `asNumber`, `idOf`, object construction) into a shared module—so future API changes only need to be maintained in one location.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread apps/web/src/lib/genome/variant.ts Outdated

@coderabbitai coderabbitai 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.

Actionable comments posted: 5

🧹 Nitpick comments (1)
apps/web/src/components/genome/VariantTrack.test.tsx (1)

94-101: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Execute the keyboard-selection handlers.

This test checks ARIA attributes but does not execute the Enter or Space branches in VariantTrack.tsx lines 105-110. Add keydown assertions for both keys. Verify that each key changes aria-pressed and the detail panel state.

Proposed test extension
     expect(control).toHaveAttribute('tabindex', '0')
     expect(control).toHaveAttribute('aria-pressed', 'false')
+    fireEvent.keyDown(control, { key: 'Enter' })
+    expect(await screen.findByTestId('variant-detail-var-a')).toBeInTheDocument()
+    fireEvent.keyDown(control, { key: ' ' })
+    await waitFor(() =>
+      expect(screen.queryByTestId('variant-detail-var-a')).not.toBeInTheDocument(),
+    )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/src/components/genome/VariantTrack.test.tsx` around lines 94 - 101,
Extend the keyboard-accessibility test around the variant selection control
returned by renderTrack to dispatch keydown events for both Enter and Space.
After each key event, assert that aria-pressed changes and verify the detail
panel opens or updates accordingly, covering both keyboard branches in
VariantTrack.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/web/src/components/genome/GenomeBrowser.tsx`:
- Around line 229-231: Refactor BrowserTrack so the variants branch is rendered
by a separate child component, keeping useGenomeTrack called unconditionally
within the non-variant path. Add a rerender test that preserves the same track
id while changing track.kind between variant and non-variant values, and verify
rendering completes without a hook-order error.

In `@apps/web/src/lib/genome/variant.ts`:
- Around line 77-80: Update isValidVariant to require a non-empty variant
identity in addition to the existing chromosome and position checks, rejecting
records whose id is empty or missing. Ensure normalization provides a stable
unique identity when appropriate, and add a regression test covering API records
without id or variant_id so they cannot share selection or React-key identity.

In `@docs/external-data/MASTER_PLAN.md`:
- Around line 349-352: Update the Phase 6.4 Variant Viewer entry in the
governing plan to mark it implemented rather than “next,” and distinguish the
completed frontend work from the remaining live external-source integration
through the GenomeAI API. Preserve the existing external-source routing
requirement and leave Phase 6.5 unchanged.
- Around line 11-46: docs/external-data/MASTER_PLAN.md lines 11-46, 88-110,
133-144, 162-166, 175-185, 193-196, 204-213, 222-224, 232-236, 244-248, 262-275,
283-293, 301-313, 324-329, 415-430, and 442-456: add the text language tag to
each diagram or example fence; use python for the interface fence at lines
114-123. docs/external-data/README.md lines 9-11: add the text language tag to
the architecture fence. Ensure every listed fenced Markdown block has an
explicit appropriate language tag.

In `@docs/visualization/variant.md`:
- Around line 159-168: Update the Validation section in variant.md to visibly
document that live coordinate-search responses currently contain
non-serializable raw SQLAlchemy objects and therefore live variant data is
blocked. Add the relevant issue link if available, and explicitly state whether
the demo relies on fixtures or mocked responses.

---

Nitpick comments:
In `@apps/web/src/components/genome/VariantTrack.test.tsx`:
- Around line 94-101: Extend the keyboard-accessibility test around the variant
selection control returned by renderTrack to dispatch keydown events for both
Enter and Space. After each key event, assert that aria-pressed changes and
verify the detail panel opens or updates accordingly, covering both keyboard
branches in VariantTrack.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6e1b482c-a9af-4720-811d-ee6e450ef6c8

📥 Commits

Reviewing files that changed from the base of the PR and between b9bfcda and 13287af.

📒 Files selected for processing (20)
  • README.md
  • apps/web/src/app/visualization/GenomeBrowserDemo.tsx
  • apps/web/src/app/visualization/page.tsx
  • apps/web/src/components/genome/GenomeBrowser.tsx
  • apps/web/src/components/genome/VariantTrack.test.tsx
  • apps/web/src/components/genome/VariantTrack.tsx
  • apps/web/src/lib/genome/api.test.ts
  • apps/web/src/lib/genome/api.ts
  • apps/web/src/lib/genome/types.ts
  • apps/web/src/lib/genome/variant.test.ts
  • apps/web/src/lib/genome/variant.ts
  • apps/web/src/lib/genome/variantApi.test.ts
  • apps/web/src/lib/genome/variantApi.ts
  • apps/web/src/lib/genome/variantGeometry.test.ts
  • apps/web/src/lib/genome/variantGeometry.ts
  • docs/external-data/MASTER_PLAN.md
  • docs/external-data/README.md
  • docs/visualization/README.md
  • docs/visualization/roadmap.md
  • docs/visualization/variant.md

Comment thread apps/web/src/components/genome/GenomeBrowser.tsx Outdated
Comment on lines +77 to +80
export function isValidVariant(variant: Variant): boolean {
return (
variant.chromosome.length > 0 && Number.isSafeInteger(variant.position) && variant.position >= 1
)

@coderabbitai coderabbitai Bot Aug 10, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Require a non-empty variant identity.

Line 77 accepts variants with id === ''. VariantTrack uses id as both the React key and the selected-variant identity. If the API returns two records without id or variant_id, users cannot select them independently.

Reject records without an identity, or assign a stable unique identity during normalization. Add a regression test for this response shape.

Proposed fix
 export function isValidVariant(variant: Variant): boolean {
   return (
-    variant.chromosome.length > 0 && Number.isSafeInteger(variant.position) && variant.position >= 1
+    variant.id.length > 0 &&
+    variant.chromosome.length > 0 &&
+    Number.isSafeInteger(variant.position) &&
+    variant.position >= 1
   )
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function isValidVariant(variant: Variant): boolean {
return (
variant.chromosome.length > 0 && Number.isSafeInteger(variant.position) && variant.position >= 1
)
export function isValidVariant(variant: Variant): boolean {
return (
variant.id.length > 0 &&
variant.chromosome.length > 0 &&
Number.isSafeInteger(variant.position) &&
variant.position >= 1
)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/src/lib/genome/variant.ts` around lines 77 - 80, Update
isValidVariant to require a non-empty variant identity in addition to the
existing chromosome and position checks, rejecting records whose id is empty or
missing. Ensure normalization provides a stable unique identity when
appropriate, and add a regression test covering API records without id or
variant_id so they cannot share selection or React-key identity.

✅ Addressed in commit 4ddd0c0

Comment thread docs/external-data/MASTER_PLAN.md Outdated
Comment thread docs/external-data/MASTER_PLAN.md
Comment thread docs/visualization/variant.md
@dsk-dev-ai
dsk-dev-ai merged commit e064e6e into main Aug 13, 2026
4 of 5 checks passed
@dsk-dev-ai
dsk-dev-ai deleted the feat/visualization-variant branch August 13, 2026 02:48
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