Merged
Conversation
- Fix duplicate figures by using only latest execution per group - Add KaTeX for rendering LaTeX math in figure captions (e.g. degree symbols) - Fix season ordering to include Annual alongside DJF/MAM/JJA/SON - Show rotated x-axis labels instead of hiding them for charts with many categories - Filter out placeholder cards from explorer view - Fix figure gallery whitespace by using useLayoutEffect for scroll margin
- Tests for renderLatexToHtml and containsLatex (LaTeX to HTML conversion) - Tests for sortCategories with season auto-detection, Annual variants, explicit ordering, and edge cases - Export sortCategories and KNOWN_CATEGORY_ORDERS for testability
Add pageSize prop to FigureGallery that switches from infinite scroll (window virtualizer) to paginated mode with previous/next controls and a page counter. Explorer galleries use pageSize=12 by default so users can see there are more figures without scrolling through hundreds. Diagnostics page still uses infinite scroll. Also extracts FigureCard as a reusable component.
✅ Deploy Preview for climate-ref ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Updates the Explorer/Diagnostics frontend to address review feedback around figure duplication, LaTeX caption rendering, season ordering, axis label visibility, placeholder content filtering, and (optionally) paginated figure galleries.
Changes:
- Add KaTeX-based inline LaTeX rendering for figure captions and split KaTeX into its own Rollup chunk.
- Fix figure gallery duplication by only using each execution group’s
latest_execution, add optional pagination, and filter out placeholder cards/content items in Explorer. - Extend season ordering (Annual variants) and rotate X-axis labels to keep them visible for many categories.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/vite.config.ts | Adds manual chunking to bundle KaTeX separately. |
| frontend/src/lib/latex.ts | Introduces KaTeX-based $...$ inline LaTeX rendering helper. |
| frontend/src/lib/latex.test.ts | Adds unit tests for LaTeX detection/rendering and HTML escaping. |
| frontend/src/components/explorer/thematicContent.tsx | Filters out placeholder cards and placeholder content items. |
| frontend/src/components/explorer/content/figureGalleryContent.tsx | Enables paginated gallery mode in Explorer via pageSize={12}. |
| frontend/src/components/diagnostics/figureGallery.tsx | Uses latest_execution to avoid duplicates; adds optional pagination and shared card rendering. |
| frontend/src/components/diagnostics/figure.tsx | Renders LaTeX in figure captions via dangerouslySetInnerHTML when detected. |
| frontend/src/components/diagnostics/ensembleChart.tsx | Extends known season ordering (Annual variants) and rotates X-axis labels instead of hiding them. |
| frontend/src/components/diagnostics/ensembleChart.test.ts | Adds tests for season ordering/sorting behavior. |
| frontend/package.json | Adds KaTeX dependency. |
| frontend/package-lock.json | Locks KaTeX and its transitive dependency versions. |
Files not reviewed (1)
- frontend/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Memoize KaTeX rendering in Figure component with useMemo - Hoist LaTeX regex patterns to module scope to avoid re-creation - Remove dead try/catch (KaTeX throwOnError:false handles errors) - Remove redundant placeholder field from filtered cards - Cap XAxis interval at ~20 labels for very large datasets - Remove unnecessary comment
- Re-add try/catch in renderLatexToHtml with escaped fallback to prevent XSS if KaTeX throws an unexpected internal error - Stop event propagation on FigureDropDown trigger button to prevent card onClick from firing when interacting with the dropdown menu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses multiple feedback items from the explorer review email:
latest_executionper group instead of iterating all executions, preventing repeated/outdated figures$^\circ$renders as degree symbol). KaTeX is bundled as a separate chunk to minimize main bundle impactplaceholderfrom the explorer viewpageSizeprop toFigureGallery. Explorer galleries usepageSize=12with previous/next controls so users can discover more figures without infinite scrolling. Diagnostics page retains infinite scrollNot addressed (require diagnostic reruns)
Not addressed (needs investigation with live data)
Test plan
apiEndpoint.test.tsunrelated)