Skip to content

refactor(web): migrate app detail sidebar storage#37052

Open
popsiclelmlm wants to merge 2 commits into
langgenius:mainfrom
popsiclelmlm:refactor/app-detail-sidebar-storage
Open

refactor(web): migrate app detail sidebar storage#37052
popsiclelmlm wants to merge 2 commits into
langgenius:mainfrom
popsiclelmlm:refactor/app-detail-sidebar-storage

Conversation

@popsiclelmlm
Copy link
Copy Markdown
Contributor

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Part of #36898.

Migrate the app-detail-collapse-or-expand preference away from direct localStorage access in the app detail sidebar flow.

Reproduction

web/AGENTS.md disallows direct localStorage, window.localStorage, or globalThis.localStorage access in app code. On main, this storage key still had direct app-code access in:

  • web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout-main.tsx
  • web/app/components/app-sidebar/index.tsx

Root 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-storage boundary for the same key.

Changes

  • Use useLocalStorage<string>('app-detail-collapse-or-expand', 'expand', { raw: true }) when initializing the app detail sidebar mode.
  • Use useSetLocalStorage<string>('app-detail-collapse-or-expand', { raw: true }) when persisting sidebar mode changes.
  • Update the existing sidebar persistence test to assert the storage hook setter path.
  • Prune the related no-restricted-globals suppression counts.

Tests

  • Passed: git diff --check
  • Passed: node -e "JSON.parse(require('fs').readFileSync('eslint-suppressions.json', 'utf8'))"
  • Passed: 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 || true returned no matches
  • Attempted: pnpm -C web test app/components/app-sidebar/__tests__/index.spec.tsx
    • Blocked locally by Corepack signature verification with the default Node 22.2.0 shim.
  • Attempted workaround: PATH="$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
    • Blocked before test execution by the workspace dependency policy using local registry metadata: @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

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

From Codex

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. refactor labels Jun 4, 2026
@github-actions github-actions Bot added the web This relates to changes on the web. label Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor size:S This PR changes 10-29 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant