Skip to content

Clear onboarding storage upon completion#952

Open
slifty wants to merge 4 commits intomainfrom
951-archive-name-fix
Open

Clear onboarding storage upon completion#952
slifty wants to merge 4 commits intomainfrom
951-archive-name-fix

Conversation

@slifty
Copy link
Contributor

@slifty slifty commented Mar 3, 2026

This PR fixes an issue where onboarding data could carry over between onboarding sessions.

Specifically it refactors how the onboarding components interact with session storage, deferring to the OnboardingService as the "source of truth" for both read, write, and state management.

I also made a small improvement to logout to make sure we aren't leaking session data in browser storage after a user has logged out.

Resolves #951

Copilot AI review requested due to automatic review settings March 3, 2026 20:06
Copy link

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

This PR addresses onboarding state leaking across account-creation sessions by clearing persisted onboarding values from sessionStorage so subsequent signups/onboarding runs start clean (resolving #951).

Changes:

  • Clear onboarding-related sessionStorage keys during signup submission.
  • Clear onboarding-related sessionStorage keys after archive creation flow completes.
  • Add unit tests to verify the sessionStorage keys are cleared in both flows.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/app/onboarding/components/create-new-archive/create-new-archive.component.ts Clears onboarding session storage after onSubmit() and includes onboardingScreen in the cleared keys.
src/app/onboarding/components/create-new-archive/create-new-archive.component.spec.ts Adds a test ensuring onboarding sessionStorage keys are cleared after archive creation.
src/app/auth/components/signup/signup.component.ts Clears onboarding sessionStorage keys at the start of signup submission.
src/app/auth/components/signup/signup.component.spec.ts Adds a test ensuring onboarding sessionStorage keys are cleared when signup is submitted.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 80.95238% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.86%. Comparing base (20919e1) to head (b64de96).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...create-new-archive/create-new-archive.component.ts 50.00% 11 Missing ⚠️
src/app/shared/services/account/account.service.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #952      +/-   ##
==========================================
+ Coverage   48.79%   48.86%   +0.07%     
==========================================
  Files         351      351              
  Lines       11345    11365      +20     
  Branches     1899     1904       +5     
==========================================
+ Hits         5536     5554      +18     
- Misses       5619     5623       +4     
+ Partials      190      188       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@slifty slifty force-pushed the 951-archive-name-fix branch 2 times, most recently from 30d77c8 to ca0022b Compare March 3, 2026 20:43
Copilot AI review requested due to automatic review settings March 3, 2026 20:43
Copy link

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 4 out of 4 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@slifty slifty force-pushed the 951-archive-name-fix branch 2 times, most recently from 158cd85 to 1a5c89b Compare March 3, 2026 21:00
@slifty slifty added the QA This issue is ready for QA / user acceptance testing label Mar 3, 2026
@slifty slifty force-pushed the 951-archive-name-fix branch 3 times, most recently from 0b3dd0e to 3108334 Compare March 3, 2026 21:45
@slifty slifty removed the QA This issue is ready for QA / user acceptance testing label Mar 3, 2026
@slifty slifty force-pushed the 951-archive-name-fix branch from 53b4192 to f9443ac Compare March 9, 2026 15:18
@PermanentOrg PermanentOrg deleted a comment from github-actions bot Mar 9, 2026
@slifty
Copy link
Contributor Author

slifty commented Mar 9, 2026

This should finally be ready for review!

Copy link

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 17 out of 17 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 421 to 425
this.clearAccount();
this.clearArchive();
this.clearRootFolder();
sessionStorage.clear();
this.accountChange.emit(null);
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

sessionStorage.clear() in logOut() clears all sessionStorage keys (e.g. UI state like showArchiveOptions/showAppsSubfolders), not just onboarding state. This can cause unrelated session-scoped preferences/state to be lost on logout. Consider removing this, or clearing only the onboarding-related keys (e.g. via OnboardingService.clearSessionStorage() / targeted removeItem calls) instead of wiping sessionStorage globally.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was my intention but @cecilia-donnelly please note if that is shooting too far.

I do think that it is odd to have any state be carried over between login / logout (e.g. if a family computer is used by two people with different preferences in those settings... shouldn't those preferences be stored outside of a session?)

Copy link
Member

Choose a reason for hiding this comment

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

I think this is right. It's possible that it will change behavior people are used to, so we might have to address some of that in future support conversations. If options need to be carried over through logout, though, we should store them in the backend (e.g. for the checklist there's the "don't show this again" option, which is stored in the database, but we wouldn't keep the checklist minimized/maximized through a login/logout cycle).

We were not reliably clearing out onboarding metadata when it finished
or when users logged out, which meant that if the same browser was used
to create two accounts there could be some contamination of the
onboarding step for the second user.

This (1) fixes that, and (2) moves the state management to the
OnboardingService rather than an individual component.

Issue #951 Ensure web archive name is empty during account creation
slifty added 3 commits March 11, 2026 15:33
We had various components writing / reading session storage to look up
onboarding flow information.  This meant that the responsibility of
concerns was fragmented and components were doing "more" than they
really should have been responsible for.

This moves the mechanism of storage / storage management entirely into
the OnboardingService.  It's now much easier to ensure things are
behaving properly, and components have a much simpler API to interact
with onboarding data.

Issue #951 Ensure web archive name is empty during account creation
When a user logs out they might have some data in their session storage
which should also be wiped away.

Issue #951 Ensure web archive name is empty during account creation
The previous implementation of the onboarding flow interacted directly
with local storage; however, we have a StorageService which exists to
cover edge cases where local storage isn't actually available.

This fix should make onboarding more robust, and is in line with the
recent refactors to improve that storage.
@slifty slifty force-pushed the 951-archive-name-fix branch from 7dc5f94 to b64de96 Compare March 11, 2026 19:34
Copy link
Member

@cecilia-donnelly cecilia-donnelly left a comment

Choose a reason for hiding this comment

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

This is much clearer, thank you! And it works :)

I did make a ticket for a pre-existing bug that I saw while testing this: https://permanent.atlassian.net/browse/PER-10486

Comment on lines 421 to 425
this.clearAccount();
this.clearArchive();
this.clearRootFolder();
sessionStorage.clear();
this.accountChange.emit(null);
Copy link
Member

Choose a reason for hiding this comment

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

I think this is right. It's possible that it will change behavior people are used to, so we might have to address some of that in future support conversations. If options need to be carried over through logout, though, we should store them in the backend (e.g. for the checklist there's the "don't show this again" option, which is stored in the database, but we wouldn't keep the checklist minimized/maximized through a login/logout cycle).

Copy link
Member

@cecilia-donnelly cecilia-donnelly left a comment

Choose a reason for hiding this comment

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

Meant to approve.

@cecilia-donnelly cecilia-donnelly added the QA This issue is ready for QA / user acceptance testing label Mar 12, 2026
@github-actions
Copy link
Contributor

QA Instructions

Summary

This PR addresses issues with improper session storage handling for the onboarding process. It ensures onboarding session data is cleared:

  • Upon session completion.
  • When logging out.
    It centralizes session storage management in the OnboardingService for consistency and to avoid fragmented logic across components.

Test Scenarios

Onboarding Data Management

  1. Scenario: Reset onboarding data when completing onboarding (via SignupComponent).

    • Steps:
      1. Initiate a new signup process.
      2. Complete the signup and observe session storage behavior.
    • Expected Result: Session storage related to onboarding (e.g., steps, progress) is cleared after successful onboarding.
  2. Scenario: Maintain session integrity during onboarding failure.

    • Steps:
      1. Initiate the onboarding process (e.g., creating a new archive).
      2. Simulate an error in the middle of onboarding (e.g., API failure during archive creation).
    • Expected Result: No onboarding-related data in session storage is cleared upon failure.
  3. Scenario: Clear onboarding session storage after successful archive creation.

    • Steps:
      1. Initiate onboarding to create an archive.
      2. Successfully complete the archive creation step.
    • Expected Result: Onboarding session data is cleared immediately after successful archive creation.
  4. Scenario: Retain incomplete onboarding session storage on page refresh.

    • Steps:
      1. Begin the onboarding process but stop midway (e.g., fill out half of the steps and refresh the page).
    • Expected Result: Unfinished onboarding data persists until onboarding is completed.

Logout Behavior

  1. Scenario: Clear all session storage upon user logout.
    • Steps:
      1. Log into an account and begin the onboarding process.
      2. Log out before completing onboarding.
    • Expected Result: All session-related data is cleared, especially onboarding data.

Regression Risks

  1. Existing Onboarding Flows:
    Changes to the onboarding logic may inadvertently introduce issues with:

    • Proper progression through onboarding steps.
    • Correct restoration of state after page refresh.
    • Interaction between session storage and the OnboardingService.
  2. Logout Functionality:
    Ensure regular logout operations are not disrupted by the added session clearing logic.


Things to Watch For

  1. Misaligned API interactions: Verify that the onboarding API endpoints handle the updated state logic without returning unexpected errors.
  2. Delayed or incorrect onboarding data clearing: Confirm that the session storage is cleared precisely where and when expected in all workflows.

Generated by QA Instructions Action

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

Labels

QA This issue is ready for QA / user acceptance testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ensure web archive name is empty during account creation

4 participants