Skip to content

Improve types - #98

Merged
david-mears-2 merged 7 commits into
mainfrom
types
Jun 5, 2026
Merged

Improve types#98
david-mears-2 merged 7 commits into
mainfrom
types

Conversation

@david-mears-2

Copy link
Copy Markdown
Contributor

This avoids the need for lots of line.metadata?.[Axis.ROW], which can now be line.metadata[Axis.ROW

Removed type PointWithMetadata as it was only used in a single place

@david-mears-2
david-mears-2 requested a review from absternator June 3, 2026 13:53
@david-mears-2 david-mears-2 changed the title Types Improve types Jun 3, 2026
@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fe287407-1a3e-4fb1-b767-f61bbc795ae0

📥 Commits

Reviewing files that changed from the base of the PR and between 1be0be9 and ce406da.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • package.json

📝 Walkthrough

Walkthrough

Types now require line metadata (LineWithMetadata). Composables, stores, utils, RidgelinePlot.vue, and tests are updated to use the new type and to index metadata directly (removing optional chaining and non-null assertions).

Changes

Stricter Line Metadata Typing

Layer / File(s) Summary
Type definition: Point to Lines, PointWithMetadata to LineWithMetadata
src/types.ts
Import changed from Point to Lines from @reside-ic/skadi-chart; PointWithMetadata replaced with LineWithMetadata, making metadata required and derived from Lines<LineMetadata>[0].
Composable type updates: useHistogramLines and usePlotTooltips
src/composables/useHistogramLines.ts, src/composables/usePlotTooltips.ts
useHistogramLines now uses LineWithMetadata[] (initializeLine/constructLines types updated); usePlotTooltips imports Point and LineMetadata, and its tooltip callback accepts Point & { metadata?: LineMetadata } to match skadi-chart while keeping a runtime guard.
RidgelinePlot.vue: remove optional chaining for metadata access
src/components/RidgelinePlot.vue
Filtering logic for relevant ridge lines, row-mean computation and sorting, legend-based selection, category extraction, and trace colour calls now index line.metadata directly (no optional chaining).
Color store: accept LineWithMetadata and index metadata directly
src/stores/colorStore.ts
setColors signature changed to LineWithMetadata[]; unique category extraction reads line.metadata[colorAxis.value] without optional chaining.
Data store: summary-row matching uses direct metadata indexing
src/stores/dataStore.ts
getSummaryDataRow compares dimension values via metadata[axis] instead of metadata?.[axis].
Plot configuration helpers: use LineWithMetadata[]
src/utils/plotConfiguration.ts
numericalScales, normalizeLines, categoricalScales, and exported plotConfiguration updated to accept and return LineWithMetadata[].
Test updates: stricter typing and non-null assertion removal
tests/unit/composables/usePlotTooltips.spec.ts
Tests now import explicit types and pass metadata directly to tooltipCallback/renderTooltip; non-null assertions removed; assertions unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Possibly related PRs

    • vimc/vaxviz#90: touches plotConfiguration/normalization pathways that interact with LineWithMetadata and normalizedLines.
  • Suggested reviewers

    • M-Kusumgar
    • EmmaLRussell
  • Poem

🐰 A rabbit hops through types so strict,
From Point to Lines, the path well-picked,
No null assertions left behind,
Metadata required, metadata defined.
A tidy hop — the code feels light. 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Improve types' is vague and generic, using a non-descriptive term that does not convey meaningful information about the changeset. Use a more specific title that clearly describes the main change, such as 'Make line metadata non-optional in type definitions' or 'Refactor types to assume metadata presence'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly relates to the changeset, explaining that types are being adjusted so lines always have metadata and the PointWithMetadata type was removed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch types

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 and usage tips.

@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.32%. Comparing base (694cc58) to head (ce406da).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #98      +/-   ##
==========================================
- Coverage   98.43%   98.32%   -0.11%     
==========================================
  Files          38       39       +1     
  Lines         896      897       +1     
  Branches      256      256              
==========================================
  Hits          882      882              
- Misses          9       10       +1     
  Partials        5        5              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@david-mears-2
david-mears-2 force-pushed the types branch 2 times, most recently from 51c59c5 to f683e81 Compare June 3, 2026 14:26

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

nice cleanup lgtm!

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

Actionable comments posted: 3

🤖 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 `@src/components/RidgelinePlot.vue`:
- Around line 117-123: The mean calculation in getMeanOfMeansForPlotRow
currently uses a non-null assertion on dataStore.getSummaryDataRow which can be
undefined; update getMeanOfMeansForPlotRow to call
dataStore.getSummaryDataRow(metadata) defensively: map each relevantRidgeLines
entry to its summary row, filter out undefined results, and then compute the
mean from the remaining SummaryTableColumn.MEAN values; if all lookups are
undefined, return a safe sentinel (e.g. NaN) or throw/log a clear warning about
the inconsistency so sorting callers know the row had no matching summary data.
Ensure you reference getMeanOfMeansForPlotRow, relevantRidgeLines,
dataStore.getSummaryDataRow, and SummaryTableColumn.MEAN when locating and
changing the logic.

In `@src/stores/colorStore.ts`:
- Around line 86-90: setColors currently types its parameter as
LineWithMetadata[] but only reads the metadata property; change the signature to
accept the minimal shape (either Array<Pick<LineWithMetadata, "metadata">> or
LineMetadata[]) so callers that pass { metadata } wrappers (as in tests) match
the API. Update the setColors function signature and any related usage/type
imports (referencing setColors, LineWithMetadata, and LineMetadata) to use the
narrower type, and run/adjust affected tests to ensure typing and behavior
remain correct.

In `@tests/unit/composables/usePlotTooltips.spec.ts`:
- Around line 10-11: Change the runtime import of PointWithMetadata to a
type-only import so it doesn't emit a module import at runtime: replace the
current import of PointWithMetadata from "types" with an `import type {
PointWithMetadata } from "types";` (matching other `import type` usage and
avoiding issues with verbatimModuleSyntax: true) and ensure only type
annotations reference PointWithMetadata (no runtime usage).
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c5fae0f1-cd92-499b-a6ee-8b2ea916a910

📥 Commits

Reviewing files that changed from the base of the PR and between c2a0c9d and dd757bd.

📒 Files selected for processing (8)
  • src/components/RidgelinePlot.vue
  • src/composables/useHistogramLines.ts
  • src/composables/usePlotTooltips.ts
  • src/stores/colorStore.ts
  • src/stores/dataStore.ts
  • src/types.ts
  • src/utils/plotConfiguration.ts
  • tests/unit/composables/usePlotTooltips.spec.ts

Comment thread src/components/RidgelinePlot.vue
Comment thread src/stores/colorStore.ts
Comment thread tests/unit/composables/usePlotTooltips.spec.ts Outdated
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 2 file(s) based on 1 unresolved review comment.

Files modified:

  • package-lock.json
  • tests/unit/composables/usePlotTooltips.spec.ts

Commit: 1be0be9e459818d37ae554792968a4b5011edd09

The changes have been pushed to the types branch.

Time taken: 1m 59s

@david-mears-2
david-mears-2 merged commit c8d31a2 into main Jun 5, 2026
5 of 6 checks passed
@david-mears-2
david-mears-2 deleted the types branch June 5, 2026 11:11
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