Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions packages/app/src/pages/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ export default function LegacyLayout(props: ParentProps) {
const key = pathKey(directory)

const projects = layout.projects.list()
const knownRoots = new Set(projects.map((p) => pathKey(p.worktree)))

const sandbox = projects.find((p) => p.sandboxes?.some((item) => pathKey(item) === key))
if (sandbox) return sandbox
Expand All @@ -532,8 +533,9 @@ export default function LegacyLayout(props: ParentProps) {
const meta = serverSync().data.project.find((p) => p.id === id)
const root = meta?.worktree
if (!root) return

return projects.find((p) => p.worktree === root)
if (pathKey(root) === key) return
if (!knownRoots.has(pathKey(root))) return
return projects.find((p) => pathKey(p.worktree) === pathKey(root))
})

const [autoselecting] = createResource(async () => {
Expand Down Expand Up @@ -1134,6 +1136,7 @@ export default function LegacyLayout(props: ParentProps) {

function projectRoot(directory: string) {
const key = pathKey(directory)
const knownRoots = new Set(layout.projects.list().map((item) => pathKey(item.worktree)))
const project = layout.projects
.list()
.find((item) => pathKey(item.worktree) === key || item.sandboxes?.some((sandbox) => pathKey(sandbox) === key))
Expand All @@ -1149,7 +1152,11 @@ export default function LegacyLayout(props: ParentProps) {
if (!id) return directory

const meta = serverSync().data.project.find((item) => item.id === id)
return meta?.worktree ?? directory
const root = meta?.worktree
if (!root) return directory
if (pathKey(root) === key) return directory
if (knownRoots.has(pathKey(root))) return root
return directory
}

function activeProjectRoot(directory: string) {
Expand Down
Loading