Conversation
- Upgrade glob package to version 13.0.1. - Modify CourseCard component to use user ID for scoped localStorage keys for the bunk calculator setting. - Update useUserSettings hook to sync user settings to localStorage using user-specific keys. - Implement cleanup of legacy localStorage keys after migrating to user-scoped keys. - Ensure session validation checks are performed correctly to prevent race conditions during user logout.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Updates user settings persistence to be user-scoped in localStorage, reducing cross-user leakage and improving settings sync behavior across sessions/devices.
Changes:
- Scope bunk calculator + target percentage
localStoragekeys by authenticated user ID, and migrate/cleanup legacy unscoped keys. - Update
CourseCardto read the bunk calculator toggle from a user-scoped key. - Upgrade
globto^13.0.1and bump app version to1.4.8.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/providers/user-settings.ts | Writes/reads user-scoped settings keys, migrates legacy keys, adjusts session validation logic during async sync. |
| src/components/attendance/course-card.tsx | Loads bunk calculator visibility from a user-scoped localStorage key. |
| package.json | Bumps app version and upgrades glob. |
| package-lock.json | Lockfile updates reflecting dependency upgrades. |
| README.md | Updates checklist/security bullets. |
| Dockerfile | Attempts to copy generated service worker into runtime image. |
| .example.env | Bumps NEXT_PUBLIC_APP_VERSION to 1.4.8. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot open a new pull request to apply changes based on the comments in this thread |
* Initial plan * fix: address PR review comments for localStorage and session validation - Fix null userId in onMutate by getting session directly instead of using ref - Add userId validation in validateActiveSession to prevent cross-user leakage - Wrap getSession() calls in try/catch to handle transient errors gracefully - Add isMounted guard in CourseCard to prevent state updates after unmount - Replace dynamic import with static import for Supabase client - Use logger.dev instead of console.debug for consistency Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot open a new pull request to apply changes based on the comments in this thread |
…274) * Initial plan * Address review comments: add error handling, fix race conditions, remove dead code Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/components/attendance/course-card.tsx:115
- This effect reads a user-scoped key based on the auth session but has an empty dependency array. If the auth session changes without unmounting this component (e.g., user logs out/in in-place),
showBunkCalcwon’t be reloaded for the new user and may reflect the previous user’s preference.
Consider keying the effect off the current auth user id (or listening for auth state changes) and reloading/resetting showBunkCalc when it changes.
useEffect(() => {
// Track if component is still mounted to prevent state updates after unmount
let isMounted = true;
// Get user ID from auth to use scoped localStorage key
const fetchUserAndLoadSetting = async () => {
try {
const supabase = createClient();
const { data: { session } } = await supabase.auth.getSession();
if (session?.user?.id && isMounted) {
const localKey = `showBunkCalc_${session.user.id}`;
const stored = localStorage.getItem(localKey);
if (stored !== null) {
setShowBunkCalc(stored === "true");
}
}
} catch (error) {
// Fallback: if auth fails, don't block rendering
logger.dev("Failed to get session for localStorage key", error);
}
};
fetchUserAndLoadSetting();
const handleBunkCalcToggle = (event: CustomEvent) => {
setShowBunkCalc(event.detail);
};
window.addEventListener(
"bunkCalcToggle",
handleBunkCalcToggle as EventListener
);
return () => {
isMounted = false;
window.removeEventListener(
"bunkCalcToggle",
handleBunkCalcToggle as EventListener
);
};
}, []);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
feat: update localStorage handling for user-specific settings