Compare commits

...

1 Commits

Author SHA1 Message Date
James Long
c7dd54e608 Force worktrees to inherit project 2026-03-06 17:41:57 -05:00
2 changed files with 25 additions and 8 deletions

View File

@@ -19,16 +19,31 @@ const disposal = {
}
export const Instance = {
async provide<R>(input: { directory: string; init?: () => Promise<any>; fn: () => R }): Promise<R> {
async provide<R>(input: {
directory: string
project?: Project.Info
init?: () => Promise<any>
fn: () => R
}): Promise<R> {
let existing = cache.get(input.directory)
if (!existing) {
Log.Default.info("creating instance", { directory: input.directory })
debugger;
Log.Default.info("creating instance", { directory: input.directory, project: input.project })
existing = iife(async () => {
const { project, sandbox } = await Project.fromDirectory(input.directory)
const ctx = {
directory: input.directory,
worktree: sandbox,
project,
let ctx
if (input.project) {
ctx = {
directory: input.directory,
worktree: input.directory,
project: input.project,
}
} else {
const { project, sandbox } = await Project.fromDirectory(input.directory)
ctx = {
directory: input.directory,
worktree: sandbox,
project,
}
}
await context.provide(ctx, async () => {
await input.init?.()

View File

@@ -377,6 +377,8 @@ export namespace Worktree {
const booted = await Instance.provide({
directory: info.directory,
// worktrees should inherit the same project as the local project
project: Instance.project,
init: InstanceBootstrap,
fn: () => undefined,
})
@@ -411,7 +413,7 @@ export namespace Worktree {
await runStartScripts(info.directory, { projectID, extra })
}
void start().catch((error) => {
return start().catch((error) => {
log.error("worktree start task failed", { directory: info.directory, error })
})
}