fix(core): always start worktrees as detached (#26931)

This commit is contained in:
James Long
2026-05-11 16:22:25 -04:00
committed by GitHub
parent 42a0453945
commit 9067218b74
7 changed files with 101 additions and 47 deletions

View File

@@ -22,11 +22,10 @@ export const WorktreeAdapter: WorkspaceAdapter = {
description: "Create a git worktree",
async configure(info) {
const { AppRuntime, Worktree } = await loadWorktree()
const next = await AppRuntime.runPromise(Worktree.Service.use((svc) => svc.makeWorktreeInfo()))
const next = await AppRuntime.runPromise(Worktree.Service.use((svc) => svc.makeWorktreeInfo({ detached: true })))
return {
...info,
name: next.name,
branch: next.branch,
directory: next.directory,
}
},
@@ -38,7 +37,7 @@ export const WorktreeAdapter: WorkspaceAdapter = {
svc.createFromInfo({
name: config.name,
directory: config.directory,
branch: config.branch ?? config.name,
...(config.branch ? { branch: config.branch } : {}),
}),
),
)
@@ -48,9 +47,8 @@ export const WorktreeAdapter: WorkspaceAdapter = {
return (await AppRuntime.runPromise(Worktree.Service.use((svc) => svc.list()))).map((info) => ({
type: "worktree",
name: info.name,
branch: info.branch ?? null,
branch: info.branch,
directory: info.directory,
extra: null,
projectID: Instance.project.id,
}))
},

View File

@@ -7,9 +7,9 @@ export const WorkspaceInfo = Schema.Struct({
id: WorkspaceID,
type: Schema.String,
name: Schema.String,
branch: Schema.NullOr(Schema.String),
directory: Schema.NullOr(Schema.String),
extra: Schema.NullOr(Schema.Unknown),
branch: Schema.optional(Schema.NullOr(Schema.String)),
directory: Schema.optional(Schema.NullOr(Schema.String)),
extra: Schema.optional(Schema.NullOr(Schema.Unknown)),
projectID: ProjectID,
}).annotate({ identifier: "Workspace" })
export type WorkspaceInfo = DeepMutable<Schema.Schema.Type<typeof WorkspaceInfo>>