Skip to content

v1.4.8#272

Merged
devakesu merged 3 commits intomainfrom
1.4.8
Feb 6, 2026
Merged

v1.4.8#272
devakesu merged 3 commits intomainfrom
1.4.8

Conversation

@devakesu
Copy link
Owner

@devakesu devakesu commented Feb 6, 2026

feat: update localStorage handling for user-specific settings

  • 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.

- 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.
Copilot AI review requested due to automatic review settings February 6, 2026 18:24
@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

❌ Patch coverage is 0% with 80 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/providers/user-settings.ts 0.00% 67 Missing ⚠️
src/components/attendance/course-card.tsx 0.00% 13 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 localStorage keys by authenticated user ID, and migrate/cleanup legacy unscoped keys.
  • Update CourseCard to read the bunk calculator toggle from a user-scoped key.
  • Upgrade glob to ^13.0.1 and bump app version to 1.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.

@devakesu
Copy link
Owner Author

devakesu commented Feb 6, 2026

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI commented Feb 6, 2026

@devakesu I've opened a new pull request, #273, to work on those changes. Once the pull request is ready, I'll request review from you.

* 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>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@devakesu
Copy link
Owner Author

devakesu commented Feb 6, 2026

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI commented Feb 6, 2026

@devakesu I've opened a new pull request, #274, to work on those changes. Once the pull request is ready, I'll request review from you.

…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>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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), showBunkCalc won’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.

@devakesu devakesu merged commit 146608a into main Feb 6, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants