Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdds Sentry event filtering for known non-error messages, extends AuthContext to accept AbortSignal and include company_name, removes client-side SWR profile fetch in favor of AuthContext user data on the home page, and updates global SWR defaults (disable focus revalidate, increase dedupe window). Changes
Sequence Diagram(s)sequenceDiagram
participant Browser as Browser
participant AuthCtx as AuthContext (client)
participant API as /api/auth/me
participant Sentry as Sentry SDK
Browser->>AuthCtx: mount / login trigger
AuthCtx->>AuthCtx: create AbortController (signal)
AuthCtx->>API: fetch /api/auth/me (with signal)
API-->>AuthCtx: 200 OK + user data (includes company_name)
AuthCtx->>AuthCtx: map user, set state
Browser->>Sentry: capture error event
Sentry-->>Sentry: beforeSend checks exception value against IGNORED_VALUES
alt matches IGNORED_VALUES
Sentry-->>Browser: drop event (return null)
else
Sentry-->>Browser: send event to server
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 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
🧹 Nitpick comments (1)
src/app/(dashboard)/home/page.tsx (1)
196-198: Minor: "Loading..." fallback is misleading when user exists withoutfirst_name.If the user object is present but
first_nameis empty/undefined, this displays "Loading..." which is inaccurate. Consider aligning with the greeting fallback pattern:💡 Suggested fix
<p className="text-sm font-bold text-slate-900 truncate"> - {user?.first_name - ? `${user.first_name} ${user.last_name ?? ""}`.trim() + {user + ? (user.first_name ? `${user.first_name} ${user.last_name ?? ""}`.trim() : user.email) : "Loading..."} </p>🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/app/`(dashboard)/home/page.tsx around lines 196 - 198, The current JSX ternary checks user?.first_name and shows "Loading..." when first_name is missing even though a user exists; change the condition to check for user (not first_name), construct the display name from both user.first_name and user.last_name (trim the concatenation), and only fall back to the existing greeting fallback (e.g., "Loading..." or the same greeting used elsewhere) if the trimmed name is empty; update the JSX expression that references user, user.first_name, and user.last_name accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/lib/swr.ts`:
- Around line 6-10: Add a concise explanatory comment next to the SWR_CONFIG
export documenting the API-load vs. data-staleness trade-off introduced by
revalidateOnFocus: false and dedupingInterval: 60_000 (and refreshInterval:
5*60*1000), and list the affected hooks (useBookingsListQuery,
useUpcomingBookingsQuery, useResolvedProjectSelection, useProjectSubcontractors)
plus the fact that useBookingMutations invalidates caches on mutation and the
calendar view overrides refreshInterval to 30s; also add or update a short entry
in the repo docs/README linking to this comment so future devs understand why
manual refreshes or tab-focus updates might be required for these features.
---
Nitpick comments:
In `@src/app/`(dashboard)/home/page.tsx:
- Around line 196-198: The current JSX ternary checks user?.first_name and shows
"Loading..." when first_name is missing even though a user exists; change the
condition to check for user (not first_name), construct the display name from
both user.first_name and user.last_name (trim the concatenation), and only fall
back to the existing greeting fallback (e.g., "Loading..." or the same greeting
used elsewhere) if the trimmed name is empty; update the JSX expression that
references user, user.first_name, and user.last_name accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d3fd06ea-aa34-4b9f-9074-6b33333cda52
📒 Files selected for processing (5)
sentry.client.config.tssrc/app/(dashboard)/home/page.tsxsrc/app/context/AuthContext.tsxsrc/lib/swr.tssrc/types/auth.ts
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/app/(dashboard)/home/page.tsx (1)
172-201:⚠️ Potential issue | 🟡 MinorAvoid rendering a fake identity while auth is still loading.
When
authLoadingis true anduseris still null, this header briefly shows"User 👋","Member", and"U"before the real account data arrives. It would be better to gate these fallbacks behindauthLoadingor show a consistent skeleton/loading placeholder so the UI doesn’t momentarily present the wrong user identity.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/app/`(dashboard)/home/page.tsx around lines 172 - 201, The header is rendering placeholder identity strings when user is null, causing a brief fake identity flash; update the JSX around the top greeting, role/company block, avatar initial, and name/email lines (where {user?.first_name ? `${user.first_name} 👋` : "User 👋"}, {user?.role || "Member"}, the avatar initial expression, and the name/email rendering) to instead check authLoading and, if true, render a consistent loading state (e.g., a skeleton or "Loading..." placeholders) — only fall back to the static defaults when authLoading is false and user is null; ensure all occurrences (greeting, role/company, avatar initial, and name/email) use the same authLoading-gated logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@README.md`:
- Around line 269-275: Update the earlier "State Management" bullet that
currently claims SWR handles `profile` to reflect the new auth flow: remove or
replace the `profile` mention with a note that user/profile data is provided via
`AuthContext` (or the new auth provider), and add a brief pointer to the auth
source (e.g., `AuthContext`/auth flow) so the README is consistent with the SWR
trade-off description and `src/lib/swr.ts` rationale.
---
Outside diff comments:
In `@src/app/`(dashboard)/home/page.tsx:
- Around line 172-201: The header is rendering placeholder identity strings when
user is null, causing a brief fake identity flash; update the JSX around the top
greeting, role/company block, avatar initial, and name/email lines (where
{user?.first_name ? `${user.first_name} 👋` : "User 👋"}, {user?.role ||
"Member"}, the avatar initial expression, and the name/email rendering) to
instead check authLoading and, if true, render a consistent loading state (e.g.,
a skeleton or "Loading..." placeholders) — only fall back to the static defaults
when authLoading is false and user is null; ensure all occurrences (greeting,
role/company, avatar initial, and name/email) use the same authLoading-gated
logic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a3188dfc-5bdc-49d5-a4bd-980c7ac2e5f7
📒 Files selected for processing (3)
README.mdsrc/app/(dashboard)/home/page.tsxsrc/lib/swr.ts
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/app/(dashboard)/home/page.tsx (1)
202-202: Avatar initial may render empty during loading.When
authLoadingis true, the avatar shows an empty string. Consider showing a skeleton or placeholder character for visual consistency.💡 Optional: Add skeleton for avatar during loading
<div className="h-10 w-10 rounded-full bg-slate-100 flex items-center justify-center text-slate-700 font-bold border border-slate-200 shadow-sm text-sm"> - {authLoading ? "" : user?.first_name?.charAt(0) || user?.email?.charAt(0) || "U"} + {authLoading ? ( + <Skeleton className="h-5 w-5 rounded-full" /> + ) : ( + user?.first_name?.charAt(0) || user?.email?.charAt(0) || "U" + )} </div>🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/app/`(dashboard)/home/page.tsx at line 202, The avatar currently renders an empty string when authLoading is true; update the JSX that renders {authLoading ? "" : user?.first_name?.charAt(0) || user?.email?.charAt(0) || "U"} to show a consistent placeholder during loading (e.g., a skeleton component or a fallback character like "U") instead of an empty string; locate the expression using authLoading, user, first_name, and email in page.tsx and replace the ternary to render either a Skeleton/Placeholder element or the computed initial so the avatar never appears blank while loading.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/app/`(dashboard)/home/page.tsx:
- Line 202: The avatar currently renders an empty string when authLoading is
true; update the JSX that renders {authLoading ? "" :
user?.first_name?.charAt(0) || user?.email?.charAt(0) || "U"} to show a
consistent placeholder during loading (e.g., a skeleton component or a fallback
character like "U") instead of an empty string; locate the expression using
authLoading, user, first_name, and email in page.tsx and replace the ternary to
render either a Skeleton/Placeholder element or the computed initial so the
avatar never appears blank while loading.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4091a0e1-d77a-409e-8324-4de97e0a98ee
📒 Files selected for processing (2)
README.mdsrc/app/(dashboard)/home/page.tsx
Summary by CodeRabbit
New Features
Bug Fixes
Chores
Documentation