fix(app): register new home projects (#41018)

This commit is contained in:
Brendan Allan
2026-08-07 15:34:32 +08:00
committed by GitHub
parent f9c770d8cf
commit 807cc48fd0
2 changed files with 29 additions and 1 deletions
+14 -1
View File
@@ -90,7 +90,20 @@ export function createHomeController() {
const directory = directories[0]
if (!directory) return
const ctx = global.ensureServerCtx(conn)
directories.forEach((item) => ctx.projects.open(item))
directories.forEach((item) => {
if (ctx.projects.list().some((project) => project.worktree === item)) return
const location = { directory: item }
void ctx.sdk.api.file
.list({ path: ".", location })
.then(async (files) => {
if (files.data.length > 0) return ctx.sdk.api.project.current({ location })
const result = await ctx.sdk.client.project.initGit({ directory: item })
return result.data ?? ctx.sdk.api.project.current({ location })
})
.then((project) => ctx.sync.child(item, { bootstrap: false })[1]("project", project.id))
.catch(() => undefined)
ctx.projects.open(item)
})
ctx.projects.touch(directory)
setSelection({ server: ServerConnection.key(conn), directory })
},