From e92d5b592c7f4079074bb32a2b183a833e90085a Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Fri, 16 Jan 2026 13:21:07 -0600 Subject: [PATCH] fix(app): can't expand workspaces --- packages/app/src/pages/layout.tsx | 50 +++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/packages/app/src/pages/layout.tsx b/packages/app/src/pages/layout.tsx index 3b66e55ed..833503068 100644 --- a/packages/app/src/pages/layout.tsx +++ b/packages/app/src/pages/layout.tsx @@ -5,6 +5,7 @@ import { createSignal, For, Match, + on, onCleanup, onMount, ParentProps, @@ -275,12 +276,21 @@ export default function Layout(props: ParentProps) { return bUpdated - aUpdated } - function scrollToSession(sessionId: string) { + const [scrollSessionKey, setScrollSessionKey] = createSignal(undefined) + + function scrollToSession(sessionId: string, sessionKey: string) { if (!scrollContainerRef) return + if (scrollSessionKey() === sessionKey) return const element = scrollContainerRef.querySelector(`[data-session-id="${sessionId}"]`) - if (element) { - element.scrollIntoView({ block: "nearest", behavior: "smooth" }) + if (!element) return + const containerRect = scrollContainerRef.getBoundingClientRect() + const elementRect = element.getBoundingClientRect() + if (elementRect.top >= containerRect.top && elementRect.bottom <= containerRect.bottom) { + setScrollSessionKey(sessionKey) + return } + setScrollSessionKey(sessionKey) + element.scrollIntoView({ block: "nearest", behavior: "smooth" }) } const currentProject = createMemo(() => { @@ -325,9 +335,12 @@ export default function Layout(props: ParentProps) { createEffect(() => { if (!pageReady()) return if (!layoutReady()) return + const projects = layout.projects.list() for (const [directory, expanded] of Object.entries(store.workspaceExpanded)) { - if (layout.sidebar.workspaces(directory)()) continue if (!expanded) continue + const project = projects.find((item) => item.worktree === directory || item.sandboxes?.includes(directory)) + if (!project) continue + if (layout.sidebar.workspaces(project.worktree)()) continue setStore("workspaceExpanded", directory, false) } }) @@ -533,7 +546,7 @@ export default function Layout(props: ParentProps) { }) } navigateToSession(session) - queueMicrotask(() => scrollToSession(session.id)) + queueMicrotask(() => scrollToSession(session.id, `${session.directory}:${session.id}`)) } async function archiveSession(session: Session) { @@ -721,16 +734,23 @@ export default function Layout(props: ParentProps) { } } - createEffect(() => { - if (!pageReady()) return - if (!params.dir || !params.id) return - const directory = base64Decode(params.dir) - const id = params.id - setStore("lastSession", directory, id) - notification.session.markViewed(id) - untrack(() => setStore("workspaceExpanded", directory, (value) => value ?? true)) - requestAnimationFrame(() => scrollToSession(id)) - }) + createEffect( + on( + () => ({ ready: pageReady(), dir: params.dir, id: params.id }), + (value) => { + if (!value.ready) return + const dir = value.dir + const id = value.id + if (!dir || !id) return + const directory = base64Decode(dir) + setStore("lastSession", directory, id) + notification.session.markViewed(id) + untrack(() => setStore("workspaceExpanded", directory, (current) => current ?? true)) + requestAnimationFrame(() => scrollToSession(id, `${directory}:${id}`)) + }, + { defer: true }, + ), + ) createEffect(() => { const project = currentProject()