summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorAdam <[email protected]>2026-01-16 13:21:07 -0600
committerAdam <[email protected]>2026-01-16 13:24:47 -0600
commite92d5b592c7f4079074bb32a2b183a833e90085a (patch)
treec7db9293eebc0e0037fd0902a4e6bc2746f25f44 /packages
parent00ec29dae6dbacf750ddd766182b93366161286a (diff)
downloadopencode-e92d5b592c7f4079074bb32a2b183a833e90085a.tar.gz
opencode-e92d5b592c7f4079074bb32a2b183a833e90085a.zip
fix(app): can't expand workspaces
Diffstat (limited to 'packages')
-rw-r--r--packages/app/src/pages/layout.tsx50
1 files 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<string | undefined>(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()