Skip to content

feat: colorful demo defaults for the sample dataset - #78

Merged
dbolser merged 1 commit into
mainfrom
feat/colorful-default
Jul 24, 2026
Merged

dbolser merged 1 commit into
mainfrom
feat/colorful-default

Conversation

@dbolser

@dbolser dbolser commented Jul 24, 2026 •

Copy link
Copy Markdown
Owner

What

When the bundled iris sample loads — both the auto-load on first visit and the explicit Load Sample Data button — the app now starts with its colorful features on instead of monochrome gray dots:

  • Category coloring by species (colorMode: 'category', categoryColorColumn: 'species')
  • Cell border tinting by |r| (tintCellBorders: true) — the correlation badges stay off; ScatterPlotMatrix computes correlations whenever either flag is on (correlationActive = showCorrelation || tintCellBorders), so the tint works standalone
  • Regression lines (showRegressionLine: true)

Why

First-impression demo polish: the sample dataset is the first thing a new visitor sees, and it should show off what the tool can do rather than a wall of gray points.

How

  • New pure decision function computeSampleDefaults(context) in src/utils/sampleDefaults.ts — takes isSample / hasPendingViewState / detected string columns, returns the defaults to apply or null.
  • Applied in applyParseResult (App.tsx) via an isSample flag threaded from loadSampleData → handleDataLoaded. It runs after the standard per-load resets and before the #view= block.

Scope and safety

  • Only the sample: uploads, file-history loads, and URL loads pass isSample: false (the default) and keep the current neutral behavior.
  • Share links win: a pending #view= state makes computeSampleDefaults return null, so a shared link targeting the sample applies the sharer's settings, not the demo defaults. (A view without a data URL shows the upload screen; if the user then loads the sample, the pending view still wins.)
  • Not forced state: these are initial values only — each remains a normal user toggle.
  • No render-key work needed: all three flags are already part of buildRenderKey (src/utils/renderKeyUtils.ts), verified.

Guarantee (a): src/utils/sampleDefaults tests — src/test/sampleDefaults.test.ts covers the normal sample case, non-sample loads, pending view state (alone and combined), the sample-without-species edge case (tint + regression still apply, coloring stays 'none'), exact-name matching, and purity.

Testing

  • npm run typecheck green
  • npm run test:run — 372 tests, 32 files, all green
  • npm run build + npm run preview boot check green (index and data/sample.csv served)

🤖 Generated with Claude Code

https://claude.ai/code/session_0152hQSk9mV9zoZJBSRAJQWn

Summary by CodeRabbit

  • New Features

    • Improved the bundled sample dataset’s initial visualization settings.
    • Sample data now automatically enables cell border tinting and regression lines.
    • When available, the species column is selected for category-based coloring.
    • Sample data without a species column still receives applicable visual enhancements.
    • Shared view settings continue to take precedence over sample defaults.
  • Tests

    • Added coverage for sample defaults, edge cases, and shared view state behavior.

The iris sample is most users' first impression of the app, but it
rendered as monochrome gray dots. When the sample loads (auto-load on
first visit or the Load Sample Data button), default to:

- colorMode 'category' on the species column
- tintCellBorders (correlation badges stay off; the matrix computes
  correlations whenever either flag is on, so the tint works alone)
- showRegressionLine

Only the sample gets these: uploads, history loads, and URL loads keep
the neutral defaults, and a pending #view= share link always wins. The
decision is a pure function in src/utils/sampleDefaults.ts, applied in
applyParseResult via an isSample flag threaded from loadSampleData, and
unit-tested exhaustively (non-sample, pending view, missing-species
edge case). All three flags are ordinary toggles afterwards and are
already part of the render key, so no cache/render changes needed.

Guarantee (a): src/test/sampleDefaults.test.ts

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0152hQSk9mV9zoZJBSRAJQWn
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds sample-specific visualization defaults for the bundled iris dataset. The load pipeline propagates an isSample flag, computes initial coloring, border tinting, and regression settings, and tests behavior for sample, non-sample, pending-view, and edge-case contexts.

Changes

Sample Visualization Defaults

Layer / File(s) Summary
Sample defaults computation and validation
src/utils/sampleDefaults.ts, src/test/sampleDefaults.test.ts
Defines computeSampleDefaults and related exports, then tests sample detection, species matching, pending view precedence, fallback behavior, and input purity.
Sample load integration
App.tsx
Threads isSample through CSV loading and parsing, applies computed visualization defaults, and marks the bundled sample load accordingly.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant loadSampleData
  participant handleDataLoaded
  participant PapaParse
  participant applyParseResult
  loadSampleData->>handleDataLoaded: load CSV with isSample=true
  handleDataLoaded->>PapaParse: parse CSV
  PapaParse->>applyParseResult: parsed result and isSample
  applyParseResult->>applyParseResult: computeSampleDefaults
  applyParseResult-->>loadSampleData: update visualization state
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: colorful default visualization settings for the bundled sample dataset.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/colorful-default

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.

@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: 1

🤖 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 `@App.tsx`:
- Around line 244-249: Update the settings initialization around the
sampleDefaults handling in App so that when computeSampleDefaults returns null,
reset the sample-controlled color mode, category color column, tint cell
borders, and regression line to their neutral defaults. Preserve the existing
sample-default assignments when present, and apply any pending `#view`= state
after these resets so it can override them.
🪄 Autofix (Beta)

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: 2a478b58-d386-4c78-8b9c-7906f87a0e99

📥 Commits

Reviewing files that changed from the base of the PR and between 30da1a5 and f0ed477.

📒 Files selected for processing (3)
  • App.tsx
  • src/test/sampleDefaults.test.ts
  • src/utils/sampleDefaults.ts

Comment thread App.tsx
Comment on lines +244 to +249
if (sampleDefaults) {
setColorMode(sampleDefaults.colorMode);
setCategoryColorColumn(sampleDefaults.categoryColorColumn);
setTintCellBorders(sampleDefaults.tintCellBorders);
setShowRegressionLine(sampleDefaults.showRegressionLine);
}

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 | 🟠 Major | ⚡ Quick win

Reset sample-only settings on subsequent non-sample loads.

When computeSampleDefaults returns null for an upload/history/URL load, the prior sample's enabled tint and regression settings remain active; category mode also remains active if the next dataset contains species. Explicitly restore these sample-controlled settings to neutral for non-sample loads, then let pending #view= state override them.

Proposed fix
     if (sampleDefaults) {
       setColorMode(sampleDefaults.colorMode);
       setCategoryColorColumn(sampleDefaults.categoryColorColumn);
       setTintCellBorders(sampleDefaults.tintCellBorders);
       setShowRegressionLine(sampleDefaults.showRegressionLine);
+    } else if (!isSample) {
+      setColorMode('none');
+      setCategoryColorColumn(null);
+      setTintCellBorders(false);
+      setShowRegressionLine(false);
     }
📝 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
if (sampleDefaults) {
setColorMode(sampleDefaults.colorMode);
setCategoryColorColumn(sampleDefaults.categoryColorColumn);
setTintCellBorders(sampleDefaults.tintCellBorders);
setShowRegressionLine(sampleDefaults.showRegressionLine);
}
if (sampleDefaults) {
setColorMode(sampleDefaults.colorMode);
setCategoryColorColumn(sampleDefaults.categoryColorColumn);
setTintCellBorders(sampleDefaults.tintCellBorders);
setShowRegressionLine(sampleDefaults.showRegressionLine);
} else if (!isSample) {
setColorMode('none');
setCategoryColorColumn(null);
setTintCellBorders(false);
setShowRegressionLine(false);
}
🤖 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 `@App.tsx` around lines 244 - 249, Update the settings initialization around
the sampleDefaults handling in App so that when computeSampleDefaults returns
null, reset the sample-controlled color mode, category color column, tint cell
borders, and regression line to their neutral defaults. Preserve the existing
sample-default assignments when present, and apply any pending `#view`= state
after these resets so it can override them.

@dbolser
dbolser merged commit b12a125 into main Jul 24, 2026
3 checks passed
@dbolser
dbolser deleted the feat/colorful-default branch July 24, 2026 14:00
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