|
@@ -64,14 +64,8 @@ import { DebugBar } from "@/components/debug-bar"
|
|
|
import { Titlebar } from "@/components/titlebar"
|
|
import { Titlebar } from "@/components/titlebar"
|
|
|
import { useServer } from "@/context/server"
|
|
import { useServer } from "@/context/server"
|
|
|
import { useLanguage, type Locale } from "@/context/language"
|
|
import { useLanguage, type Locale } from "@/context/language"
|
|
|
-import {
|
|
|
|
|
- displayName,
|
|
|
|
|
- effectiveWorkspaceOrder,
|
|
|
|
|
- errorMessage,
|
|
|
|
|
- latestRootSession,
|
|
|
|
|
- sortedRootSessions,
|
|
|
|
|
- workspaceKey,
|
|
|
|
|
-} from "./layout/helpers"
|
|
|
|
|
|
|
+import { pathKey } from "@/utils/path-key"
|
|
|
|
|
+import { displayName, effectiveWorkspaceOrder, errorMessage, latestRootSession, sortedRootSessions } from "./layout/helpers"
|
|
|
import {
|
|
import {
|
|
|
collectNewSessionDeepLinks,
|
|
collectNewSessionDeepLinks,
|
|
|
collectOpenProjectDeepLinks,
|
|
collectOpenProjectDeepLinks,
|
|
@@ -164,7 +158,7 @@ export default function Layout(props: ParentProps) {
|
|
|
|
|
|
|
|
const editor = createInlineEditorController()
|
|
const editor = createInlineEditorController()
|
|
|
const setBusy = (directory: string, value: boolean) => {
|
|
const setBusy = (directory: string, value: boolean) => {
|
|
|
- const key = workspaceKey(directory)
|
|
|
|
|
|
|
+ const key = pathKey(directory)
|
|
|
if (value) {
|
|
if (value) {
|
|
|
setState("busyWorkspaces", key, true)
|
|
setState("busyWorkspaces", key, true)
|
|
|
return
|
|
return
|
|
@@ -176,7 +170,7 @@ export default function Layout(props: ParentProps) {
|
|
|
}),
|
|
}),
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
- const isBusy = (directory: string) => !!state.busyWorkspaces[workspaceKey(directory)]
|
|
|
|
|
|
|
+ const isBusy = (directory: string) => !!state.busyWorkspaces[pathKey(directory)]
|
|
|
const navLeave = { current: undefined as number | undefined }
|
|
const navLeave = { current: undefined as number | undefined }
|
|
|
const sortNow = () => state.sortNow
|
|
const sortNow = () => state.sortNow
|
|
|
let sizet: number | undefined
|
|
let sizet: number | undefined
|
|
@@ -497,8 +491,8 @@ export default function Layout(props: ParentProps) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const currentSession = params.id
|
|
const currentSession = params.id
|
|
|
- if (workspaceKey(directory) === workspaceKey(currentDir()) && props.sessionID === currentSession) return
|
|
|
|
|
- if (workspaceKey(directory) === workspaceKey(currentDir()) && session?.parentID === currentSession) return
|
|
|
|
|
|
|
+ if (pathKey(directory) === pathKey(currentDir()) && props.sessionID === currentSession) return
|
|
|
|
|
+ if (pathKey(directory) === pathKey(currentDir()) && session?.parentID === currentSession) return
|
|
|
|
|
|
|
|
dismissSessionAlert(sessionKey)
|
|
dismissSessionAlert(sessionKey)
|
|
|
|
|
|
|
@@ -556,14 +550,14 @@ export default function Layout(props: ParentProps) {
|
|
|
const currentProject = createMemo(() => {
|
|
const currentProject = createMemo(() => {
|
|
|
const directory = currentDir()
|
|
const directory = currentDir()
|
|
|
if (!directory) return
|
|
if (!directory) return
|
|
|
- const key = workspaceKey(directory)
|
|
|
|
|
|
|
+ const key = pathKey(directory)
|
|
|
|
|
|
|
|
const projects = layout.projects.list()
|
|
const projects = layout.projects.list()
|
|
|
|
|
|
|
|
- const sandbox = projects.find((p) => p.sandboxes?.some((item) => workspaceKey(item) === key))
|
|
|
|
|
|
|
+ const sandbox = projects.find((p) => p.sandboxes?.some((item) => pathKey(item) === key))
|
|
|
if (sandbox) return sandbox
|
|
if (sandbox) return sandbox
|
|
|
|
|
|
|
|
- const direct = projects.find((p) => workspaceKey(p.worktree) === key)
|
|
|
|
|
|
|
+ const direct = projects.find((p) => pathKey(p.worktree) === key)
|
|
|
if (direct) return direct
|
|
if (direct) return direct
|
|
|
|
|
|
|
|
const [child] = globalSync.child(directory, { bootstrap: false })
|
|
const [child] = globalSync.child(directory, { bootstrap: false })
|
|
@@ -596,7 +590,7 @@ export default function Layout(props: ParentProps) {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
const workspaceName = (directory: string, projectId?: string, branch?: string) => {
|
|
const workspaceName = (directory: string, projectId?: string, branch?: string) => {
|
|
|
- const key = workspaceKey(directory)
|
|
|
|
|
|
|
+ const key = pathKey(directory)
|
|
|
const direct = store.workspaceName[key] ?? store.workspaceName[directory]
|
|
const direct = store.workspaceName[key] ?? store.workspaceName[directory]
|
|
|
if (direct) return direct
|
|
if (direct) return direct
|
|
|
if (!projectId) return
|
|
if (!projectId) return
|
|
@@ -605,7 +599,7 @@ export default function Layout(props: ParentProps) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const setWorkspaceName = (directory: string, next: string, projectId?: string, branch?: string) => {
|
|
const setWorkspaceName = (directory: string, next: string, projectId?: string, branch?: string) => {
|
|
|
- const key = workspaceKey(directory)
|
|
|
|
|
|
|
+ const key = pathKey(directory)
|
|
|
setStore("workspaceName", key, next)
|
|
setStore("workspaceName", key, next)
|
|
|
if (!projectId) return
|
|
if (!projectId) return
|
|
|
if (!branch) return
|
|
if (!branch) return
|
|
@@ -633,7 +627,7 @@ export default function Layout(props: ParentProps) {
|
|
|
const activeDir = currentDir()
|
|
const activeDir = currentDir()
|
|
|
return workspaceIds(project).filter((directory) => {
|
|
return workspaceIds(project).filter((directory) => {
|
|
|
const expanded = store.workspaceExpanded[directory] ?? directory === project.worktree
|
|
const expanded = store.workspaceExpanded[directory] ?? directory === project.worktree
|
|
|
- const active = workspaceKey(directory) === workspaceKey(activeDir)
|
|
|
|
|
|
|
+ const active = pathKey(directory) === pathKey(activeDir)
|
|
|
return expanded || active
|
|
return expanded || active
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -644,10 +638,10 @@ export default function Layout(props: ParentProps) {
|
|
|
const projects = layout.projects.list()
|
|
const projects = layout.projects.list()
|
|
|
for (const [directory, expanded] of Object.entries(store.workspaceExpanded)) {
|
|
for (const [directory, expanded] of Object.entries(store.workspaceExpanded)) {
|
|
|
if (!expanded) continue
|
|
if (!expanded) continue
|
|
|
- const key = workspaceKey(directory)
|
|
|
|
|
|
|
+ const key = pathKey(directory)
|
|
|
const project = projects.find(
|
|
const project = projects.find(
|
|
|
(item) =>
|
|
(item) =>
|
|
|
- workspaceKey(item.worktree) === key || item.sandboxes?.some((sandbox) => workspaceKey(sandbox) === key),
|
|
|
|
|
|
|
+ pathKey(item.worktree) === key || item.sandboxes?.some((sandbox) => pathKey(sandbox) === key),
|
|
|
)
|
|
)
|
|
|
if (!project) continue
|
|
if (!project) continue
|
|
|
if (project.vcs === "git" && layout.sidebar.workspaces(project.worktree)()) continue
|
|
if (project.vcs === "git" && layout.sidebar.workspaces(project.worktree)()) continue
|
|
@@ -700,7 +694,7 @@ export default function Layout(props: ParentProps) {
|
|
|
seen: lru,
|
|
seen: lru,
|
|
|
keep: sessionID,
|
|
keep: sessionID,
|
|
|
limit: PREFETCH_MAX_SESSIONS_PER_DIR,
|
|
limit: PREFETCH_MAX_SESSIONS_PER_DIR,
|
|
|
- preserve: params.id && workspaceKey(directory) === workspaceKey(currentDir()) ? [params.id] : undefined,
|
|
|
|
|
|
|
+ preserve: params.id && pathKey(directory) === pathKey(currentDir()) ? [params.id] : undefined,
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1221,17 +1215,17 @@ export default function Layout(props: ParentProps) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function projectRoot(directory: string) {
|
|
function projectRoot(directory: string) {
|
|
|
- const key = workspaceKey(directory)
|
|
|
|
|
|
|
+ const key = pathKey(directory)
|
|
|
const project = layout.projects
|
|
const project = layout.projects
|
|
|
.list()
|
|
.list()
|
|
|
.find(
|
|
.find(
|
|
|
(item) =>
|
|
(item) =>
|
|
|
- workspaceKey(item.worktree) === key || item.sandboxes?.some((sandbox) => workspaceKey(sandbox) === key),
|
|
|
|
|
|
|
+ pathKey(item.worktree) === key || item.sandboxes?.some((sandbox) => pathKey(sandbox) === key),
|
|
|
)
|
|
)
|
|
|
if (project) return project.worktree
|
|
if (project) return project.worktree
|
|
|
|
|
|
|
|
const known = Object.entries(store.workspaceOrder).find(
|
|
const known = Object.entries(store.workspaceOrder).find(
|
|
|
- ([root, dirs]) => workspaceKey(root) === key || dirs.some((item) => workspaceKey(item) === key),
|
|
|
|
|
|
|
+ ([root, dirs]) => pathKey(root) === key || dirs.some((item) => pathKey(item) === key),
|
|
|
)
|
|
)
|
|
|
if (known) return known[0]
|
|
if (known) return known[0]
|
|
|
|
|
|
|
@@ -1283,7 +1277,7 @@ export default function Layout(props: ParentProps) {
|
|
|
: [root]
|
|
: [root]
|
|
|
const canOpen = (value: string | undefined) => {
|
|
const canOpen = (value: string | undefined) => {
|
|
|
if (!value) return false
|
|
if (!value) return false
|
|
|
- return dirs.some((item) => workspaceKey(item) === workspaceKey(value))
|
|
|
|
|
|
|
+ return dirs.some((item) => pathKey(item) === pathKey(value))
|
|
|
}
|
|
}
|
|
|
const refreshDirs = async (target?: string) => {
|
|
const refreshDirs = async (target?: string) => {
|
|
|
if (!target || target === root || canOpen(target)) return canOpen(target)
|
|
if (!target || target === root || canOpen(target)) return canOpen(target)
|
|
@@ -1409,9 +1403,9 @@ export default function Layout(props: ParentProps) {
|
|
|
|
|
|
|
|
function closeProject(directory: string) {
|
|
function closeProject(directory: string) {
|
|
|
const list = layout.projects.list()
|
|
const list = layout.projects.list()
|
|
|
- const key = workspaceKey(directory)
|
|
|
|
|
- const index = list.findIndex((x) => workspaceKey(x.worktree) === key)
|
|
|
|
|
- const active = workspaceKey(currentProject()?.worktree ?? "") === key
|
|
|
|
|
|
|
+ const key = pathKey(directory)
|
|
|
|
|
+ const index = list.findIndex((x) => pathKey(x.worktree) === key)
|
|
|
|
|
+ const active = pathKey(currentProject()?.worktree ?? "") === key
|
|
|
if (index === -1) return
|
|
if (index === -1) return
|
|
|
const next = list[index + 1]
|
|
const next = list[index + 1]
|
|
|
|
|
|
|
@@ -1485,8 +1479,8 @@ export default function Layout(props: ParentProps) {
|
|
|
if (directory === root) return
|
|
if (directory === root) return
|
|
|
|
|
|
|
|
const current = currentDir()
|
|
const current = currentDir()
|
|
|
- const currentKey = workspaceKey(current)
|
|
|
|
|
- const deletedKey = workspaceKey(directory)
|
|
|
|
|
|
|
+ const currentKey = pathKey(current)
|
|
|
|
|
+ const deletedKey = pathKey(directory)
|
|
|
const shouldLeave = leaveDeletedWorkspace || (!!params.dir && currentKey === deletedKey)
|
|
const shouldLeave = leaveDeletedWorkspace || (!!params.dir && currentKey === deletedKey)
|
|
|
if (!leaveDeletedWorkspace && shouldLeave) {
|
|
if (!leaveDeletedWorkspace && shouldLeave) {
|
|
|
navigateWithSidebarReset(`/${base64Encode(root)}/session`)
|
|
navigateWithSidebarReset(`/${base64Encode(root)}/session`)
|
|
@@ -1509,7 +1503,7 @@ export default function Layout(props: ParentProps) {
|
|
|
|
|
|
|
|
if (!result) return
|
|
if (!result) return
|
|
|
|
|
|
|
|
- if (workspaceKey(store.lastProjectSession[root]?.directory ?? "") === workspaceKey(directory)) {
|
|
|
|
|
|
|
+ if (pathKey(store.lastProjectSession[root]?.directory ?? "") === pathKey(directory)) {
|
|
|
clearLastProjectSession(root)
|
|
clearLastProjectSession(root)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1529,12 +1523,12 @@ export default function Layout(props: ParentProps) {
|
|
|
if (shouldLeave) return
|
|
if (shouldLeave) return
|
|
|
|
|
|
|
|
const nextCurrent = currentDir()
|
|
const nextCurrent = currentDir()
|
|
|
- const nextKey = workspaceKey(nextCurrent)
|
|
|
|
|
|
|
+ const nextKey = pathKey(nextCurrent)
|
|
|
const project = layout.projects.list().find((item) => item.worktree === root)
|
|
const project = layout.projects.list().find((item) => item.worktree === root)
|
|
|
const dirs = project
|
|
const dirs = project
|
|
|
? effectiveWorkspaceOrder(root, [root, ...(project.sandboxes ?? [])], store.workspaceOrder[root])
|
|
? effectiveWorkspaceOrder(root, [root, ...(project.sandboxes ?? [])], store.workspaceOrder[root])
|
|
|
: [root]
|
|
: [root]
|
|
|
- const valid = dirs.some((item) => workspaceKey(item) === nextKey)
|
|
|
|
|
|
|
+ const valid = dirs.some((item) => pathKey(item) === nextKey)
|
|
|
|
|
|
|
|
if (params.dir && projectRoot(nextCurrent) === root && !valid) {
|
|
if (params.dir && projectRoot(nextCurrent) === root && !valid) {
|
|
|
navigateWithSidebarReset(`/${base64Encode(root)}/session`)
|
|
navigateWithSidebarReset(`/${base64Encode(root)}/session`)
|
|
@@ -1640,7 +1634,7 @@ export default function Layout(props: ParentProps) {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
const handleDelete = () => {
|
|
const handleDelete = () => {
|
|
|
- const leaveDeletedWorkspace = !!params.dir && workspaceKey(currentDir()) === workspaceKey(props.directory)
|
|
|
|
|
|
|
+ const leaveDeletedWorkspace = !!params.dir && pathKey(currentDir()) === pathKey(props.directory)
|
|
|
if (leaveDeletedWorkspace) {
|
|
if (leaveDeletedWorkspace) {
|
|
|
navigateWithSidebarReset(`/${base64Encode(props.root)}/session`)
|
|
navigateWithSidebarReset(`/${base64Encode(props.root)}/session`)
|
|
|
}
|
|
}
|
|
@@ -1867,11 +1861,11 @@ export default function Layout(props: ParentProps) {
|
|
|
const local = project.worktree
|
|
const local = project.worktree
|
|
|
const dirs = [local, ...(project.sandboxes ?? [])]
|
|
const dirs = [local, ...(project.sandboxes ?? [])]
|
|
|
const active = currentProject()
|
|
const active = currentProject()
|
|
|
- const directory = workspaceKey(active?.worktree ?? "") === workspaceKey(project.worktree) ? currentDir() : undefined
|
|
|
|
|
|
|
+ const directory = pathKey(active?.worktree ?? "") === pathKey(project.worktree) ? currentDir() : undefined
|
|
|
const extra =
|
|
const extra =
|
|
|
directory &&
|
|
directory &&
|
|
|
- workspaceKey(directory) !== workspaceKey(local) &&
|
|
|
|
|
- !dirs.some((item) => workspaceKey(item) === workspaceKey(directory))
|
|
|
|
|
|
|
+ pathKey(directory) !== pathKey(local) &&
|
|
|
|
|
+ !dirs.some((item) => pathKey(item) === pathKey(directory))
|
|
|
? directory
|
|
? directory
|
|
|
: undefined
|
|
: undefined
|
|
|
const pending = extra ? WorktreeState.get(extra)?.status === "pending" : false
|
|
const pending = extra ? WorktreeState.get(extra)?.status === "pending" : false
|
|
@@ -1916,7 +1910,7 @@ export default function Layout(props: ParentProps) {
|
|
|
setStore(
|
|
setStore(
|
|
|
"workspaceOrder",
|
|
"workspaceOrder",
|
|
|
project.worktree,
|
|
project.worktree,
|
|
|
- result.filter((directory) => workspaceKey(directory) !== workspaceKey(project.worktree)),
|
|
|
|
|
|
|
+ result.filter((directory) => pathKey(directory) !== pathKey(project.worktree)),
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1942,8 +1936,8 @@ export default function Layout(props: ParentProps) {
|
|
|
setWorkspaceName(created.directory, created.branch, project.id, created.branch)
|
|
setWorkspaceName(created.directory, created.branch, project.id, created.branch)
|
|
|
|
|
|
|
|
const local = project.worktree
|
|
const local = project.worktree
|
|
|
- const key = workspaceKey(created.directory)
|
|
|
|
|
- const root = workspaceKey(local)
|
|
|
|
|
|
|
+ const key = pathKey(created.directory)
|
|
|
|
|
+ const root = pathKey(local)
|
|
|
|
|
|
|
|
setBusy(created.directory, true)
|
|
setBusy(created.directory, true)
|
|
|
WorktreeState.pending(created.directory)
|
|
WorktreeState.pending(created.directory)
|
|
@@ -1954,7 +1948,7 @@ export default function Layout(props: ParentProps) {
|
|
|
setStore("workspaceOrder", project.worktree, (prev) => {
|
|
setStore("workspaceOrder", project.worktree, (prev) => {
|
|
|
const existing = prev ?? []
|
|
const existing = prev ?? []
|
|
|
const next = existing.filter((item) => {
|
|
const next = existing.filter((item) => {
|
|
|
- const id = workspaceKey(item)
|
|
|
|
|
|
|
+ const id = pathKey(item)
|
|
|
return id !== root && id !== key
|
|
return id !== root && id !== key
|
|
|
})
|
|
})
|
|
|
return [created.directory, ...next]
|
|
return [created.directory, ...next]
|