Repository navigation
feat: colorful demo defaults for the sample dataset - #78
Conversation
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
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
📝 WalkthroughWalkthroughAdds sample-specific visualization defaults for the bundled iris dataset. The load pipeline propagates an ChangesSample Visualization Defaults
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
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
App.tsxsrc/test/sampleDefaults.test.tssrc/utils/sampleDefaults.ts
| if (sampleDefaults) { | ||
| setColorMode(sampleDefaults.colorMode); | ||
| setCategoryColorColumn(sampleDefaults.categoryColorColumn); | ||
| setTintCellBorders(sampleDefaults.tintCellBorders); | ||
| setShowRegressionLine(sampleDefaults.showRegressionLine); | ||
| } |
There was a problem hiding this comment.
🎯 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.
| 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.
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:
species(colorMode: 'category',categoryColorColumn: 'species')tintCellBorders: true) — the correlation badges stay off;ScatterPlotMatrixcomputes correlations whenever either flag is on (correlationActive = showCorrelation || tintCellBorders), so the tint works standaloneshowRegressionLine: 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
computeSampleDefaults(context)insrc/utils/sampleDefaults.ts— takesisSample/hasPendingViewState/ detected string columns, returns the defaults to apply ornull.applyParseResult(App.tsx) via anisSampleflag threaded fromloadSampleData→handleDataLoaded. It runs after the standard per-load resets and before the#view=block.Scope and safety
isSample: false(the default) and keep the current neutral behavior.#view=state makescomputeSampleDefaultsreturnnull, 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.)buildRenderKey(src/utils/renderKeyUtils.ts), verified.Guarantee (a): src/utils/sampleDefaults tests —
src/test/sampleDefaults.test.tscovers the normal sample case, non-sample loads, pending view state (alone and combined), the sample-without-speciesedge case (tint + regression still apply, coloring stays'none'), exact-name matching, and purity.Testing
npm run typecheckgreennpm run test:run— 372 tests, 32 files, all greennpm run build+npm run previewboot check green (index anddata/sample.csvserved)🤖 Generated with Claude Code
https://claude.ai/code/session_0152hQSk9mV9zoZJBSRAJQWn
Summary by CodeRabbit
New Features
speciescolumn is selected for category-based coloring.speciescolumn still receives applicable visual enhancements.Tests