[PR #5971] feat: add option to clear local workspace data on logout #5438

Open
opened 2026-03-17 02:52:57 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5971
Author: @statxc
Created: 3/10/2026
Status: 🔄 Open

Base: mainHead: feat/clear-local-data-on-logout


📝 Commits (1)

  • 9a60e78 feat: add option to clear local workspace data on logout

📊 Changes

11 files changed (+266 additions, -43 deletions)

View changed files

📝 packages/hoppscotch-common/locales/en.json (+4 -0)
📝 packages/hoppscotch-common/src/components/profile/index.vue (+20 -0)
📝 packages/hoppscotch-common/src/newstore/settings.ts (+4 -0)
📝 packages/hoppscotch-common/src/services/persistence/__tests__/index.spec.ts (+77 -0)
📝 packages/hoppscotch-common/src/services/persistence/index.ts (+116 -0)
📝 packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts (+2 -0)
📝 packages/hoppscotch-common/src/services/tab/graphql.ts (+16 -0)
📝 packages/hoppscotch-common/src/services/tab/rest.ts (+16 -0)
📝 packages/hoppscotch-selfhost-web/src/platform/auth/desktop/index.ts (+6 -0)
📝 packages/hoppscotch-selfhost-web/src/platform/auth/web/index.ts (+5 -2)
📝 pnpm-lock.yaml (+0 -41)

📄 Description

Closes #5957

What's changed

This PR adds a new privacy setting that gives users the option to clear their local workspace data when they log out.

New setting: "Clear local workspace data on logout"

A toggle has been added under Settings → Privacy. When enabled, logging out will remove the following data from the browser's localStorage:

  • REST and GraphQL collections
  • REST and GraphQL history
  • Personal and global environments
  • Secret environment variables
  • Open tabs (REST and GraphQL)
  • Realtime session data (WebSocket, Socket.IO, SSE, MQTT)
  • Local state and sort preferences

Settings and schema version are intentionally preserved so user preferences (theme, language, etc.) remain intact across sessions.

Implementation details

  • Added CLEAR_LOCAL_DATA_ON_LOGOUT to the settings store with a default value of false
  • Added the toggle UI component in the profile settings under a new "Privacy" section
  • Implemented clearWorkspaceData() in PersistenceService to handle storage removal and in-memory state reset
  • Introduced a _isPersistencePaused flag in PersistenceService to prevent RxJS store subscribers from re-writing cleared data back to localStorage during logout
  • Integrated the clear logic into signOutUser() for both selfhost-web and desktop auth flows
  • Added i18n keys for the new UI strings
  • Added validation schema entry for the new setting
  • Added unit tests for clearWorkspaceData (success path and partial failure handling)

Notes to reviewers

  • The toggle defaults to off, so there is no change in behavior for existing users.
  • The _isPersistencePaused flag is necessary because resetting in-memory stores (e.g., setRESTCollections([])) triggers persistence subscribers that would immediately re-save empty state back to localStorage. Without this flag, the cleared keys get re-created within milliseconds of removal.
  • The flag remains true after logout - the PersistenceService reinitializes on the next login, so there is no need to unpause it.
  • This feature only controls what stays in the browser's localStorage between sessions. Server-synced data (collections, environments, settings) will restore normally on next login through the existing sync mechanism.

Summary by cubic

Adds a Privacy toggle to clear local workspace data on logout (Linear #5957). When enabled, logout wipes browser-stored workspace data while preserving user settings.

  • New Features
    • Toggle under Settings → Privacy (default off).
    • On logout, clears localStorage workspace data (collections, history, environments incl. secrets, tabs, realtime, local state/sort) while preserving preferences; cloud-synced data restores on next login.
    • Works for both web and desktop sign-out flows.
    • Added i18n, validation, and unit tests; persistence is paused during clearing to avoid re-saving, with a toast on partial failures.

Written for commit 9a60e78761. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/5971 **Author:** [@statxc](https://github.com/statxc) **Created:** 3/10/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/clear-local-data-on-logout` --- ### 📝 Commits (1) - [`9a60e78`](https://github.com/hoppscotch/hoppscotch/commit/9a60e78761e1d1da9f2d40958c8f0575e4327a39) feat: add option to clear local workspace data on logout ### 📊 Changes **11 files changed** (+266 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-common/locales/en.json` (+4 -0) 📝 `packages/hoppscotch-common/src/components/profile/index.vue` (+20 -0) 📝 `packages/hoppscotch-common/src/newstore/settings.ts` (+4 -0) 📝 `packages/hoppscotch-common/src/services/persistence/__tests__/index.spec.ts` (+77 -0) 📝 `packages/hoppscotch-common/src/services/persistence/index.ts` (+116 -0) 📝 `packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts` (+2 -0) 📝 `packages/hoppscotch-common/src/services/tab/graphql.ts` (+16 -0) 📝 `packages/hoppscotch-common/src/services/tab/rest.ts` (+16 -0) 📝 `packages/hoppscotch-selfhost-web/src/platform/auth/desktop/index.ts` (+6 -0) 📝 `packages/hoppscotch-selfhost-web/src/platform/auth/web/index.ts` (+5 -2) 📝 `pnpm-lock.yaml` (+0 -41) </details> ### 📄 Description Closes #5957 ### What's changed This PR adds a new privacy setting that gives users the option to clear their local workspace data when they log out. **New setting: "Clear local workspace data on logout"** A toggle has been added under **Settings → Privacy**. When enabled, logging out will remove the following data from the browser's localStorage: - REST and GraphQL collections - REST and GraphQL history - Personal and global environments - Secret environment variables - Open tabs (REST and GraphQL) - Realtime session data (WebSocket, Socket.IO, SSE, MQTT) - Local state and sort preferences Settings and schema version are intentionally preserved so user preferences (theme, language, etc.) remain intact across sessions. **Implementation details** - [x] Added `CLEAR_LOCAL_DATA_ON_LOGOUT` to the settings store with a default value of `false` - [x] Added the toggle UI component in the profile settings under a new "Privacy" section - [x] Implemented `clearWorkspaceData()` in `PersistenceService` to handle storage removal and in-memory state reset - [x] Introduced a `_isPersistencePaused` flag in `PersistenceService` to prevent RxJS store subscribers from re-writing cleared data back to localStorage during logout - [x] Integrated the clear logic into `signOutUser()` for both selfhost-web and desktop auth flows - [x] Added i18n keys for the new UI strings - [x] Added validation schema entry for the new setting - [x] Added unit tests for `clearWorkspaceData` (success path and partial failure handling) ### Notes to reviewers - The toggle defaults to **off**, so there is no change in behavior for existing users. - The `_isPersistencePaused` flag is necessary because resetting in-memory stores (e.g., `setRESTCollections([])`) triggers persistence subscribers that would immediately re-save empty state back to localStorage. Without this flag, the cleared keys get re-created within milliseconds of removal. - The flag remains `true` after logout - the `PersistenceService` reinitializes on the next login, so there is no need to unpause it. - This feature only controls what stays in the browser's localStorage between sessions. Server-synced data (collections, environments, settings) will restore normally on next login through the existing sync mechanism. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds a Privacy toggle to clear local workspace data on logout (Linear #5957). When enabled, logout wipes browser-stored workspace data while preserving user settings. - **New Features** - Toggle under Settings → Privacy (default off). - On logout, clears localStorage workspace data (collections, history, environments incl. secrets, tabs, realtime, local state/sort) while preserving preferences; cloud-synced data restores on next login. - Works for both web and desktop sign-out flows. - Added i18n, validation, and unit tests; persistence is paused during clearing to avoid re-saving, with a toast on partial failures. <sup>Written for commit 9a60e78761e1d1da9f2d40958c8f0575e4327a39. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#5438
No description provided.