Repository navigation
feat: add custom 404 not found page - #47
Conversation
|
CodeAnt AI is reviewing your PR. |
📝 WalkthroughWalkthroughAdds a custom, space-themed ChangesCustom 404 experience
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
CodeAnt AI finished reviewing your PR. |
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 `@frontend/src/pages/NotFound.tsx`:
- Around line 75-82: Initialize prefersReducedMotion in the NotFound component’s
useState call from window.matchMedia("(prefers-reduced-motion: reduce)").matches
instead of false, so the initial render respects the user’s preference before
effects run. Keep the existing useEffect listener and cleanup for preference
changes.
🪄 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: bb752e0e-e28b-4418-903f-be98d8a999c6
📒 Files selected for processing (2)
frontend/src/App.tsxfrontend/src/pages/NotFound.tsx
| const [prefersReducedMotion, setPrefersReducedMotion] = useState(false); | ||
|
|
||
| useEffect(() => { | ||
| const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)"); | ||
| setPrefersReducedMotion(mediaQuery.matches); | ||
| const listener = (e: MediaQueryListEvent) => setPrefersReducedMotion(e.matches); | ||
| mediaQuery.addEventListener("change", listener); | ||
| return () => mediaQuery.removeEventListener("change", listener); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Initialize the motion preference before the first paint.
false initially mounts the SVG animations for users who prefer reduced motion; useEffect corrects it only after commit. Initialize from matchMedia so those animations never mount for those users.
Proposed fix
- const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);
+ const [prefersReducedMotion, setPrefersReducedMotion] = useState(
+ () =>
+ typeof window !== "undefined" &&
+ window.matchMedia("(prefers-reduced-motion: reduce)").matches,
+ );📝 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.
| const [prefersReducedMotion, setPrefersReducedMotion] = useState(false); | |
| useEffect(() => { | |
| const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)"); | |
| setPrefersReducedMotion(mediaQuery.matches); | |
| const listener = (e: MediaQueryListEvent) => setPrefersReducedMotion(e.matches); | |
| mediaQuery.addEventListener("change", listener); | |
| return () => mediaQuery.removeEventListener("change", listener); | |
| const [prefersReducedMotion, setPrefersReducedMotion] = useState( | |
| () => | |
| typeof window !== "undefined" && | |
| window.matchMedia("(prefers-reduced-motion: reduce)").matches, | |
| ); | |
| useEffect(() => { | |
| const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)"); | |
| setPrefersReducedMotion(mediaQuery.matches); | |
| const listener = (e: MediaQueryListEvent) => setPrefersReducedMotion(e.matches); | |
| mediaQuery.addEventListener("change", listener); | |
| return () => mediaQuery.removeEventListener("change", listener); |
🤖 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 `@frontend/src/pages/NotFound.tsx` around lines 75 - 82, Initialize
prefersReducedMotion in the NotFound component’s useState call from
window.matchMedia("(prefers-reduced-motion: reduce)").matches instead of false,
so the initial render respects the user’s preference before effects run. Keep
the existing useEffect listener and cleanup for preference changes.
| <g> | ||
| {!prefersReducedMotion && ( | ||
| <animateTransform | ||
| attributeName="transform" | ||
| type="rotate" | ||
| from="0 0 0" | ||
| to="360 0 0" | ||
| dur={`${o.dur}s`} | ||
| repeatCount="indefinite" | ||
| /> | ||
| )} | ||
| <circle cx={o.rx} cy="0" r="3" fill={o.dot} /> | ||
| <text | ||
| x={o.rx + 8} | ||
| y="4" | ||
| fontFamily="IBM Plex Sans, monospace" | ||
| fontSize="9" | ||
| fill={o.dot} | ||
| opacity="0.85" | ||
| > | ||
| {o.label} | ||
| </text> | ||
| </g> |
There was a problem hiding this comment.
Animated dot traces a circle, not the ellipse orbital path
The animateTransform rotates the inner <g> around (0, 0), so the dot at cx={o.rx} cy=0 traces a perfect circle of radius rx. The ellipse it's supposed to follow has semi-axes rx and ry (e.g., 220 × 80 for the first orbit). After a 90° rotation the dot sits at (0, 220) in the tilted coordinate space, far outside the ry=80 ellipse path. If this divergence is intentional as an approximate visual effect, a brief comment would clarify intent for future maintainers.
Prompt To Fix With AI
This is a comment left during a code review.
Path: frontend/src/pages/NotFound.tsx
Line: 43-65
Comment:
**Animated dot traces a circle, not the ellipse orbital path**
The `animateTransform` rotates the inner `<g>` around `(0, 0)`, so the dot at `cx={o.rx} cy=0` traces a perfect circle of radius `rx`. The ellipse it's supposed to follow has semi-axes `rx` and `ry` (e.g., 220 × 80 for the first orbit). After a 90° rotation the dot sits at `(0, 220)` in the tilted coordinate space, far outside the `ry=80` ellipse path. If this divergence is intentional as an approximate visual effect, a brief comment would clarify intent for future maintainers.
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
krishkhinchi
left a comment
There was a problem hiding this comment.
@SankeerthNara, Please attach screenshots of the 404 Page along with your PR.
|
Hey @krishkhinchi , I've attached the screenshots as requested , please go through them |
User description
Closes #44
Description
Adds a custom 404 Not Found page matching Kepler's existing dashboard design system, replacing the default framework 404 page.
frontend/src/pages/NotFound.tsx— deep-space background with technical grid, glass panel, animated orbital debris field SVG, Space Grotesk/IBM Plex Sans typography, and cyan glow accents consistent with the rest of the app/dashboard<Route path="*" element={<NotFound />} />inApp.tsxso any invalid route renders this pageprefers-reduced-motionfor the animated orbit pathsRelated Issue
Closes #44
Checklist
Screenshots / Screen Recordings
Breaking Changes
None. This only adds a new route for previously-unmatched paths; no existing routes or components are modified.
CodeAnt-AI Description
Add a custom 404 page for unknown routes
What Changed
Impact
✅ Clearer error pages✅ Easier recovery from bad links✅ Fewer confusing dead-end routes💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.
Summary by CodeRabbit
Greptile Summary
This PR adds a custom 404 page (
NotFound.tsx) styled to match Kepler's dashboard design system, and wires it into the router as a top-level catch-all route. The page includes an animated SVG debris field,prefers-reduced-motionsupport, and a "Return to Dashboard" button.<Route path=\"*\">only catches paths that have no matching parent route. Paths nested under/dashboard(e.g.,/dashboard/nonexistent) silently match the/dashboardparent and renderMainLayoutwith an empty outlet instead of the 404 page — a nested wildcard child is needed to cover this case.animateTransformrotates the debris dot in a circle of radiusrxrather than following the underlying ellipse (semi-axesrx/ry); the dot diverges visibly from the orbital path at all angles except 0° and 180°.Confidence Score: 3/5
The new 404 page itself is safe, but the routing gap means an entire class of invalid URLs displays a broken-looking empty dashboard shell instead of the intended error page.
The catch-all route does not cover invalid paths nested under /dashboard/. Any URL like /dashboard/anything-invalid matches the parent route, and MainLayout renders with a blank content area — the sidebar, header, and all their side-effects run normally, but users see no content and receive no error feedback. This is an observable, reproducible gap in the feature as described by the PR.
frontend/src/App.tsx needs a <Route path="*" element={} /> added as a child of the /dashboard route to close the gap.
Important Files Changed
Sequence Diagram
%%{init: {'theme': 'neutral'}}%% sequenceDiagram participant User participant BrowserRouter participant Routes participant MainLayout participant NotFound User->>BrowserRouter: Navigate to /unknown-path BrowserRouter->>Routes: Match /unknown-path Routes->>NotFound: "path="*" matches" NotFound-->>User: Renders 404 page User->>BrowserRouter: Navigate to /dashboard/nonexistent BrowserRouter->>Routes: Match /dashboard/nonexistent Routes->>MainLayout: "path="/dashboard" matches (parent)" MainLayout->>MainLayout: No child route matches nonexistent MainLayout-->>User: Renders shell with empty Outlet (NotFound not shown)%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% sequenceDiagram participant User participant BrowserRouter participant Routes participant MainLayout participant NotFound User->>BrowserRouter: Navigate to /unknown-path BrowserRouter->>Routes: Match /unknown-path Routes->>NotFound: "path="*" matches" NotFound-->>User: Renders 404 page User->>BrowserRouter: Navigate to /dashboard/nonexistent BrowserRouter->>Routes: Match /dashboard/nonexistent Routes->>MainLayout: "path="/dashboard" matches (parent)" MainLayout->>MainLayout: No child route matches nonexistent MainLayout-->>User: Renders shell with empty Outlet (NotFound not shown)Comments Outside Diff (1)
frontend/src/App.tsx, line 19-28 (link)The top-level
<Route path="*">only catches paths with no parent match. Because/dashboardalready matches as a parent route, any URL like/dashboard/nonexistentcausesMainLayoutto render with<Outlet>returningnull— the sidebar and header appear, but the content area is empty. TheNotFoundpage is never shown for these cases. A nested wildcard is needed as the last child of the/dashboardroute to cover this gap.Prompt To Fix With AI
Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "feat: add custom 404 not found page" | Re-trigger Greptile
ScreenShots
Desktop View
Mobile View
Tablet View