refactor(web): migrate app detail sidebar storage#37052
Open
popsiclelmlm wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
Fixes #<issue number>.Summary
Part of #36898.
Migrate the
app-detail-collapse-or-expandpreference away from directlocalStorageaccess in the app detail sidebar flow.Reproduction
web/AGENTS.mddisallows directlocalStorage,window.localStorage, orglobalThis.localStorageaccess in app code. Onmain, this storage key still had direct app-code access in:web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout-main.tsxweb/app/components/app-sidebar/index.tsxRoot cause
The app detail layout and sidebar still read/wrote the raw sidebar mode preference directly, while the dataset detail layout already uses the
@/hooks/use-local-storageboundary for the same key.Changes
useLocalStorage<string>('app-detail-collapse-or-expand', 'expand', { raw: true })when initializing the app detail sidebar mode.useSetLocalStorage<string>('app-detail-collapse-or-expand', { raw: true })when persisting sidebar mode changes.no-restricted-globalssuppression counts.Tests
git diff --checknode -e "JSON.parse(require('fs').readFileSync('eslint-suppressions.json', 'utf8'))"git grep -n -E "localStorage\\.(getItem|setItem|removeItem)\\('app-detail-collapse-or-expand'|window\\.localStorage.*app-detail-collapse-or-expand|globalThis\\.localStorage.*app-detail-collapse-or-expand" -- web/app web/context web/service || truereturned no matchespnpm -C web test app/components/app-sidebar/__tests__/index.spec.tsxPATH="$HOME/.nvm/versions/node/v22.13.0/bin:$PATH" npx -y pnpm@11.5.0 -C /Users/liumin/Documents/OpenSourceContributions/dify/web test app/components/app-sidebar/__tests__/index.spec.tsx@vitejs/plugin-rsc@0.5.27 Missing time for version 0.5.27 of @vitejs/plugin-rsc in metadata.Screenshots/Logs
Not applicable; behavior and UI are unchanged.
Checklist
make lint && make type-check(backend) andcd web && pnpm exec vp staged(frontend) to appease the lint godsFrom Codex