Skip to content

fix(tabbar): visitHistory field - #7543

Merged
jinmao88 merged 1 commit into
vbenjs:mainfrom
AxiosLeo:fix/vben-admin-packages
Feb 11, 2026
Merged

jinmao88 merged 1 commit into
vbenjs:mainfrom
AxiosLeo:fix/vben-admin-packages

Conversation

@AxiosLeo

@AxiosLeo AxiosLeo commented Feb 11, 2026 •

Copy link
Copy Markdown
Contributor

High Severity

The visitHistory field is a Stack class instance persisted to sessionStorage via pinia-plugin-persistedstate. There's no custom serializer or hydration hook. When the page reloads, JSON.parse(JSON.stringify(stack)) produces a plain object {dedup, items, maxSize} that lacks all Stack methods (push, pop, remove, retain, etc.) and the size getter. Pinia's $patch replaces the Stack instance with this plain object, so subsequent calls like this.visitHistory.push(...) will throw a TypeError.

Description

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Checklist

ℹ️ Check all checkboxes - this will indicate that you have done everything in accordance with the rules in CONTRIBUTING.

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs:dev command.
  • Run the tests with pnpm test.
  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

  • Bug Fixes
    • Fixed tab history not being properly restored upon returning to the application.

High Severity

The visitHistory field is a Stack<string> class instance persisted to sessionStorage via pinia-plugin-persistedstate. There's no custom serializer or hydration hook. When the page reloads, JSON.parse(JSON.stringify(stack)) produces a plain object {dedup, items, maxSize} that lacks all Stack methods (push, pop, remove, retain, etc.) and the size getter. Pinia's $patch replaces the Stack instance with this plain object, so subsequent calls like this.visitHistory.push(...) will throw a TypeError.
@changeset-bot

changeset-bot Bot commented Feb 11, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: fa08ca2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Feb 11, 2026 •

Copy link
Copy Markdown
Contributor
πŸ“ Walkthrough

Walkthrough

A persistence serializer was added to enable correct rehydration of the visitHistory Stack in the tabbar store after JSON-based persistence, alongside code formatting changes that collapse imports and simplify method bodies without altering control flow logic.

Changes

Cohort / File(s) Summary
Tabbar Store Persistence & Formatting
packages/stores/src/modules/tabbar.ts
Added persistence serializer for visitHistory Stack to ensure proper rehydration in both persist configuration and initial state hydration. Applied cosmetic formatting changes including collapsed multi-line imports and inlined arrow function bodies while preserving original logic for tab filtering, index finding, and route/tab key computations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • anncwb
  • mynetfan
  • jinmao88

Poem

🐰 A stack of tabs, preserved with care,
Through JSON's mist, they float through air,
With serializers wise and formatting neat,
The history persistsβ€”now that's quite sweet!
βœ¨πŸ“š

πŸš₯ Pre-merge checks | βœ… 3
βœ… Passed checks (3 passed)
Check name Status Explanation
Title check βœ… Passed The title 'fix(tabbar): visitHistory field' is clearly related to the main change: fixing the visitHistory Stack persistence bug by adding a custom serializer and hydration logic.
Description check βœ… Passed The PR description provides a detailed explanation of the high-severity bug, identifies the root cause (missing serializer/hydration), and marks the fix as tested with proper changeset prefix. However, several non-critical checklist items remain unchecked.
Docstring Coverage βœ… Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • πŸ“ Generate docstrings
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. πŸŽ‰

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jinmao88
jinmao88 merged commit aa74a25 into vbenjs:main Feb 11, 2026
10 checks passed
@doraemonxxx

doraemonxxx commented Feb 12, 2026 •

Copy link
Copy Markdown
Contributor

you reformatted the code (no stylelint). and the only changes start at deserialize (at line 567)

@github-actions github-actions Bot locked and limited conversation to collaborators Mar 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants