Conversation
…ed page's ancestors Fixes AppFlowy-IO#526. Expand state lived in one global localStorage key, so the validator pruned each workspace's saved ids against the other's outline after every switch, and the navigation-hydration effect returned early for an already-present selected page, leaving its space collapsed.
Reviewer's GuideThe PR fixes sidebar state leakage across workspaces by introducing workspace-scoped expansion storage with legacy fallback, and fixes navigation visibility by expanding the selected page’s ancestor chain when that page is already in the loaded outline. The implementation threads workspace context through all persistence and validation paths, gates automatic expansion per selected page, and adds regression coverage for isolation and non-invasive expansion behavior. Sequence diagram for workspace-scoped outline restorationsequenceDiagram
participant Workspace as Workspace switch
participant Outline
participant Storage as localStorage
participant Validator as Outline validator
Workspace->>Outline: load outline for currentWorkspaceId
Outline->>Storage: getOutlineExpands(currentWorkspaceId)
Storage-->>Outline: outline_expanded_workspaceId or legacy outline_expanded
Outline->>Validator: validate restored expanded ids against workspace outline
Validator->>Storage: setOutlineExpands(viewId, false, currentWorkspaceId)
Outline-->>Workspace: restore isolated expansion state
Sequence diagram for selected page ancestor expansionsequenceDiagram
participant Navigation
participant Outline
participant Storage as localStorage
participant Sidebar
Navigation->>Outline: selectedViewId changes
Outline->>Outline: findView(outline, selectedViewId)
alt selected page already in outline
Outline->>Outline: findViewAncestorIds(outline, selectedViewId)
Outline->>Storage: setOutlineExpands(ancestorId, true, currentWorkspaceId)
Outline->>Sidebar: expandHydratedPath(ancestorIds)
else selected page missing
Outline->>Outline: ensureViewVisibleInOutline(selectedViewId)
Outline->>Storage: setOutlineExpands(ancestorId, true, currentWorkspaceId)
Outline->>Sidebar: expandHydratedPath(ancestorIds)
end
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Fixes #526.
Confirmed both causes from the report against current main and put together a fix:
outline_expandedinsrc/components/_shared/outline/utils.ts). The validator effect inOutline.tsxprunes any restored id it can't find in the current workspace's outline - so after a switch, workspace A's leftover ids are validated against workspace B's tree and deleted, and each workspace's saved state keeps clobbering the other's.if (findView(outline, selectedViewId)) return;, so the ancestor-expansion path never runs and the space containing the selected page stays collapsed.Changes:
outline_expanded_<workspaceId>) with a legacy-key read fallback so existing state migrates on first write.Verification: the three touched jest suites (OutlineItem.databaseContainer, Outline.navigationContext, DatabaseView.databaseContainer) run green locally, 25/25 passed (pnpm 10.9.0,
--no-coverage --maxWorkers=1).Summary by Sourcery
Fix workspace outline state restoration and reveal the selected page’s containing hierarchy.
Bug Fixes:
Enhancements:
Tests: