Skip to content

chore: enable maintenance on all pages #1233

Merged
Hugo0 merged 12 commits intopeanut-walletfrom
chore/enable-maintainance
Sep 18, 2025
Merged

chore: enable maintenance on all pages #1233
Hugo0 merged 12 commits intopeanut-walletfrom
chore/enable-maintainance

Conversation

@kushagrasarathe
Copy link
Contributor

@kushagrasarathe kushagrasarathe commented Sep 18, 2025

Screenshot 2025-09-19 at 12 16 56 AM

@vercel
Copy link

vercel bot commented Sep 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
peanut-wallet Building Building Preview Comment Sep 18, 2025 6:43pm

@kushagrasarathe kushagrasarathe marked this pull request as ready for review September 18, 2025 18:43
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 18, 2025

Walkthrough

Converted the maintenance page into a client component with updated UI and navigation. Layout switched from Banner to GenericBanner and added a footer visibility observer. Middleware introduced a maintenance-mode redirect gate and expanded route matcher coverage.

Changes

Cohort / File(s) Summary of changes
Maintenance page client component and UI update
src/app/maintenance/page.tsx
Marked as client component; replaced Layout wrapper with local layout; added Next.js Image and Button; updated copy; added router-based navigation to /support; changed default export to const arrow function.
Layout banner swap and footer visibility tracking
src/components/Global/Layout/index.tsx
Replaced Banner with GenericBanner; commented old banner usage; removed Footer import usage; added FooterVisibilityObserver using IntersectionObserver and useFooterVisibility; kept existing ThemeProvider and modal structure.
Middleware maintenance gate and matcher expansion
src/middleware.ts
Added maintenance mode redirect to /maintenance with allowlist and asset exclusions; kept existing auth/promo logic order after gate; expanded config.matcher to include many app routes and wildcards.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • Hugo0
  • jjramirezn
  • Zishan-7

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description Check ❓ Inconclusive There is no author-provided pull request description (the PR body is empty), so under the guidelines this is inconclusive because a missing description does not provide meaningful context about intent, rollout, or testing steps even though the raw changes are present. Please ask the author to add a short description that states the purpose (why maintenance is being enabled), the key behavioral changes (middleware matcher updates and redirect behavior), instructions to toggle/verify maintenanceMode, and any rollout or testing notes so reviewers can assess impact and risks.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Chore/enable maintainance" clearly references enabling maintenance mode and matches the PR changes (middleware gate, maintenance page, banner), so it conveys the main intent; however it contains a spelling error ("maintainance" → "maintenance") and uses a slash-style format instead of a concise sentence.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/enable-maintainance

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.

@kushagrasarathe kushagrasarathe changed the title Chore/enable maintainance chore: enable maintenance on all pages Sep 18, 2025
@coderabbitai coderabbitai bot added the enhancement New feature or request label Sep 18, 2025
@Hugo0 Hugo0 merged commit f81ae60 into peanut-wallet Sep 18, 2025
5 of 8 checks passed
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (5)
src/components/Global/Layout/index.tsx (2)

41-44: Guard the maintenance banner behind a flag

Hard-coding the banner will show “Under maintenance” in all environments. Gate it behind an env flag so it can’t slip to prod unintentionally.

Apply this diff:

-                            {/* <Banner /> */}
-                            {/* @dev note: temp, remove banner later */}
-                            <GenericBanner message="Under maintenance" icon="⚠️" />
+                            {/* <Banner /> */}
+                            {/* @dev note: temp, remove banner later */}
+                            {process.env.NEXT_PUBLIC_MAINTENANCE_MODE === 'true' && (
+                                <GenericBanner message="Under maintenance" icon="⚠️" />
+                            )}

84-109: IntersectionObserver: sentinel likely never intersects; cleanup may leak

  • Zero-height sentinel with threshold 0.1 may never reach the threshold.
  • Prefer disconnect() in cleanup to avoid stale observations.

Apply this diff:

-    useEffect(() => {
+    useEffect(() => {
         const observerOptions = {
             root: null, // relative to viewport
             rootMargin: '0px',
-            threshold: 0.1, // 10% of the footer is visible
+            threshold: 0, // fire on any visibility to handle tiny sentinel
         }
@@
-        return () => {
-            if (footerRef.current) {
-                observer.unobserve(footerRef.current)
-            }
-        }
+        return () => {
+            observer.disconnect()
+        }
     }, [setIsFooterVisible])
 
-    return <div ref={footerRef}></div>
+    return <div ref={footerRef} className="h-px w-full" />
src/middleware.ts (2)

16-18: Broaden static asset allowlist and make regex cheaper

Add common modern formats and sourcemaps; current regex is fine but can be simplified.

Apply this diff:

-            !pathname.match(
-                /.*\.(jpg|jpeg|png|gif|svg|ico|ttf|woff|woff2|eot|css|js|json|xml|txt|mp3|mp4|webm|ogg|wav|flac|aac)$/
-            )
+            !/\.(?:jpg|jpeg|png|gif|svg|webp|avif|ico|ttf|woff|woff2|eot|css|js|map|json|xml|txt|mp3|mp4|webm|ogg|wav|flac|aac)$/i.test(
+                pathname
+            )

67-85: Matcher completeness and duplication

  • Consider adding '/maintenance' and '/support' to matcher for consistent handling (they’re allowed above anyway).
  • Remove redundant '/home' since '/home/:path*' covers it.

Apply this diff:

     matcher: [
-        '/',
-        '/home',
+        '/',
         '/claim/:path*',
         '/api/:path*',
         '/home/:path*',
+        '/maintenance',
+        '/support/:path*',
         '/profile/:path*',
         '/send/:path*',
         '/request/:path*',
         '/settings/:path*',
         '/setup/:path*',
         '/share/:path*',
         '/history/:path*',
         '/raffle/:path*',
         '/c/:path*',
         '/pay/:path*',
         '/p/:path*',
         '/link/:path*',
     ],
src/app/maintenance/page.tsx (1)

11-11: Use StaticImageData directly with next/image

Passing the imported image object (not .src) lets Next manage metadata optimally.

Apply this diff:

-            <Image src={chillPeanutAnim.src} alt="Maintenance" width={250} height={250} />
+            <Image src={chillPeanutAnim} alt="Maintenance" width={250} height={250} />
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 94e344d and 38c7c5c.

📒 Files selected for processing (3)
  • src/app/maintenance/page.tsx (1 hunks)
  • src/components/Global/Layout/index.tsx (2 hunks)
  • src/middleware.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/app/maintenance/page.tsx (1)
src/components/0_Bruddle/Button.tsx (1)
  • Button (76-267)
🪛 GitHub Check: CodeQL
src/middleware.ts

[failure] 16-18: Polynomial regular expression used on uncontrolled data
This regular expression that depends on a user-provided value may run slow on strings with many repetitions of 'a'.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Deploy-Preview
🔇 Additional comments (1)
src/app/maintenance/page.tsx (1)

20-23: /support currently bypasses middleware — add to allowedPaths if you add it to matcher

There is a support route at src/app/(mobile-ui)/support/page.tsx and multiple links/router.push to '/support'. src/middleware.ts’s matcher does not include '/support', so middleware does not run for that path (it remains reachable during maintenance). allowedPaths = ['/', '/maintenance', '/apple-app-site-association'] does NOT include '/support'; if you later add '/support' to middleware.config.matcher it will be redirected to /maintenance. Either keep the matcher excluding '/support' or add '/support' to allowedPaths in src/middleware.ts.

Likely an incorrect or invalid review comment.

Comment on lines +6 to +22
const { pathname } = request.nextUrl
const maintenanceMode = true

if (maintenanceMode) {
const allowedPaths = ['/', '/maintenance', '/apple-app-site-association']
if (
!allowedPaths.includes(pathname) &&
!pathname.startsWith('/api/') &&
!pathname.startsWith('/_next/') &&
!pathname.startsWith('/.well-known/') &&
!pathname.match(
/.*\.(jpg|jpeg|png|gif|svg|ico|ttf|woff|woff2|eot|css|js|json|xml|txt|mp3|mp4|webm|ogg|wav|flac|aac)$/
)
) {
return NextResponse.redirect(new URL('/maintenance', request.url))
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Hard-coded maintenance mode will lock users out

Shipping with maintenanceMode = true redirects nearly all traffic. Read from an env var and allow support access.

Apply this diff:

-    const { pathname } = request.nextUrl
-    const maintenanceMode = true
+    const { pathname } = request.nextUrl
+    const maintenanceMode =
+        (process.env.NEXT_PUBLIC_MAINTENANCE_MODE || process.env.MAINTENANCE_MODE) === 'true'
@@
-        const allowedPaths = ['/', '/maintenance', '/apple-app-site-association']
+        const allowedPaths = ['/', '/maintenance', '/support', '/apple-app-site-association']
📝 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
const { pathname } = request.nextUrl
const maintenanceMode = true
if (maintenanceMode) {
const allowedPaths = ['/', '/maintenance', '/apple-app-site-association']
if (
!allowedPaths.includes(pathname) &&
!pathname.startsWith('/api/') &&
!pathname.startsWith('/_next/') &&
!pathname.startsWith('/.well-known/') &&
!pathname.match(
/.*\.(jpg|jpeg|png|gif|svg|ico|ttf|woff|woff2|eot|css|js|json|xml|txt|mp3|mp4|webm|ogg|wav|flac|aac)$/
)
) {
return NextResponse.redirect(new URL('/maintenance', request.url))
}
}
const { pathname } = request.nextUrl
const maintenanceMode =
(process.env.NEXT_PUBLIC_MAINTENANCE_MODE || process.env.MAINTENANCE_MODE) === 'true'
if (maintenanceMode) {
const allowedPaths = ['/', '/maintenance', '/support', '/apple-app-site-association']
if (
!allowedPaths.includes(pathname) &&
!pathname.startsWith('/api/') &&
!pathname.startsWith('/_next/') &&
!pathname.startsWith('/.well-known/') &&
!pathname.match(
/.*\.(jpg|jpeg|png|gif|svg|ico|ttf|woff|woff2|eot|css|js|json|xml|txt|mp3|mp4|webm|ogg|wav|flac|aac)$/
)
) {
return NextResponse.redirect(new URL('/maintenance', request.url))
}
}
🧰 Tools
🪛 GitHub Check: CodeQL

[failure] 16-18: Polynomial regular expression used on uncontrolled data
This regular expression that depends on a user-provided value may run slow on strings with many repetitions of 'a'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants