Skip to content

fix(useLocal): depuración de localStorage — groupOrder y categoryAssignments (#78)#87

Merged
jansaldo merged 1 commit into
developfrom
fix/localstorage-group-order-cleanup
May 26, 2026
Merged

fix(useLocal): depuración de localStorage — groupOrder y categoryAssignments (#78)#87
jansaldo merged 1 commit into
developfrom
fix/localstorage-group-order-cleanup

Conversation

@jansaldo
Copy link
Copy Markdown
Contributor

@jansaldo jansaldo commented May 26, 2026

El store de Zustand persistía en localStorage dos campos que acumulaban datos indefinidamente entre sesiones:

  • groupOrder almacena el orden de drag-and-drop del label manager como Record<category, canonicalId[]>. Los canonicalId son UUIDs generados frescos cada vez que se procesan archivos, por lo que cualquier entrada de una sesión anterior es basura garantizada. Se excluye de la persistencia via partialize; sigue funcionando en RAM durante la sesión.
  • categoryAssignments era dead code: setCategoryAssignments nunca fue invocado en ningún call site. Se elimina completamente del store y sus hooks.

Cambios:

  • Se agrega partialize al config de persist para serializar solo serverHost, tutorialsSeen, excludedTags y excludedWords.
  • Se elimina categoryAssignments / setCategoryAssignments del tipo, la implementación y los hooks exportados.

Cierra #78.

Summary by Sourcery

Restrict persisted Zustand local storage state to stable configuration fields and remove unused category assignment state from the local store and related hooks.

Bug Fixes:

  • Stop persisting transient drag-and-drop group order data that becomes stale across sessions.

Enhancements:

  • Add a persist configuration partializer so only relevant configuration fields are stored in localStorage.
  • Remove dead categoryAssignments state and its setters from the local store and hooks.

@jansaldo jansaldo requested review from Copilot and llapenna May 26, 2026 17:50
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 26, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors the Zustand local storage store to stop persisting ephemeral drag-and-drop ordering data and to remove an unused category assignment field and its hooks, while explicitly whitelisting which fields are serialized to localStorage.

File-Level Changes

Change Details Files
Limit persisted Zustand state to non-ephemeral fields using partialize.
  • Add a partialize option to the persist middleware configuration for the local store
  • Whitelist serverHost, tutorialsSeen, excludedTags, and excludedWords as the only fields serialized to localStorage
  • Document via comments that groupOrder is excluded because it contains per-session UUIDs that become stale between sessions
src/renderer/src/store/useLocal.ts
Remove dead categoryAssignments state and its related API from the local store.
  • Remove categoryAssignments and setCategoryAssignments from the LocalStorageStore interface
  • Delete the corresponding initial state and setter implementation from the Zustand store initializer
  • Stop selecting categoryAssignments and setCategoryAssignments in useGroupOrder and useGroupOrderActions hooks
src/renderer/src/store/useLocal.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The partialize implementation is now the single source of truth for what gets persisted; consider using object destructuring (e.g., const { serverHost, tutorialsSeen, ... } = state) or a typed helper to reduce the risk of forgetting to include new fields when they should be persisted.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `partialize` implementation is now the single source of truth for what gets persisted; consider using object destructuring (e.g., `const { serverHost, tutorialsSeen, ... } = state`) or a typed helper to reduce the risk of forgetting to include new fields when they should be persisted.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown

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 updates the renderer’s local Zustand store persistence to avoid accumulating stale session-specific data in localStorage, and removes unused state that had no call sites.

Changes:

  • Add partialize to the persist config so only stable config fields are saved (serverHost, tutorialsSeen, excludedTags, excludedWords).
  • Remove categoryAssignments and its setter from the store and exported hooks.
  • Keep groupOrder in-memory only (no longer persisted) to prevent cross-session staleness.

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

Comment on lines 49 to +57
name: "local-storage",
// groupOrder holds canonical UUIDs regenerated each session, so
// persisting it would only accumulate stale data across sessions.
partialize: (state) => ({
serverHost: state.serverHost,
tutorialsSeen: state.tutorialsSeen,
excludedTags: state.excludedTags,
excludedWords: state.excludedWords,
}),
@jansaldo jansaldo merged commit a37adc2 into develop May 26, 2026
2 checks passed
@jansaldo jansaldo deleted the fix/localstorage-group-order-cleanup branch May 26, 2026 19:50
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