diff --git a/README.md b/README.md index cb844a5b..6c683fb8 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ brew tap Jay1/jcode https://github.com/Jay1/jcode brew install --cask jcode ``` -#### Download the latest macOS +#### Download the latest macOS `JCode--arm64.dmg` or `JCode--x64.dmg`, or the latest Linux `JCode--x64.AppImage`, from @@ -33,7 +33,7 @@ brew install --cask jcode ### Windows -#### Scoop +#### Scoop If you do not have Scoop yet, follow the [official Scoop installation guide](https://scoop.sh/): @@ -42,7 +42,7 @@ scoop bucket add jcode https://github.com/Jay1/scoop-jcode scoop install jcode ``` -#### Winget +#### Winget ```powershell winget install Jay1.JCode diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index 5db7082b..a83bb428 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -270,6 +270,7 @@ const SIDEBAR_LIST_ANIMATION_OPTIONS = { easing: "ease-out", } as const; const EMPTY_THREAD_JUMP_LABELS = new Map(); +const EMPTY_PROJECT_EXPANDED_MAP = new Map(); const EMPTY_SHORTCUT_PARTS: readonly string[] = []; const ADD_PROJECT_SNAPSHOT_CATCH_UP_MAX_ATTEMPTS = 6; const ADD_PROJECT_SNAPSHOT_CATCH_UP_DELAY_MS = 50; @@ -3572,7 +3573,26 @@ export default function Sidebar() { ); // Reset per-project preview expansion when a folder closes so reopening starts at five rows again. + const previousProjectExpandedRef = useRef>( + EMPTY_PROJECT_EXPANDED_MAP, + ); useEffect(() => { + const nextExpanded = new Map( + standardProjects.map((project) => [project.cwd, project.expanded] as const), + ); + const prev = previousProjectExpandedRef.current; + let expandedChanged = nextExpanded.size !== prev.size; + if (!expandedChanged) { + for (const [cwd, expanded] of nextExpanded) { + if (prev.get(cwd) !== expanded) { + expandedChanged = true; + break; + } + } + } + previousProjectExpandedRef.current = nextExpanded; + if (!expandedChanged) return; + setExpandedThreadListsByProject((current) => pruneExpandedProjectThreadListsForCollapsedProjects({ expandedProjectThreadListCwds: current,