fix: stop stale checkout diff subscriptions (#2317)

* Fix pending checkout diff subscriptions

* Reduce checkout status Git spawns

* fix(checkout): own pending diff cancellation

Checkout sessions could invalidate a subscription before its shared watch had finished opening. Register targets synchronously and let the diff manager honor cancellation so pending and concurrent subscriptions share one teardown path.

---------

Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
This commit is contained in:
nikuscs
2026-07-22 16:49:44 +02:00
committed by GitHub
co-authored by Mohamed Boudra
parent bd937850b3
commit 9952615c33
7 changed files with 356 additions and 133 deletions
+14 -6
View File
@@ -155,6 +155,10 @@ export interface PaseoWorktreeOwnership {
worktreePath?: string;
}
export interface PaseoWorktreeOwnershipOptions extends WorktreeRootOptions {
knownGitCommonDir?: string | null;
}
export interface WorktreeRootOptions {
paseoHome?: string;
worktreesRoot?: string;
@@ -913,7 +917,7 @@ function resolveRepoRootFromGitCommonDir(commonDir: string): string {
export async function isPaseoOwnedWorktreeCwd(
cwd: string,
options?: WorktreeRootOptions,
options?: PaseoWorktreeOwnershipOptions,
): Promise<PaseoWorktreeOwnership> {
const resolvedCwd = normalizePathForOwnership(cwd);
@@ -921,11 +925,15 @@ export async function isPaseoOwnedWorktreeCwd(
// previous archive attempt removed the admin dir before the working tree
// could be fully cleaned up). We still want to allow archiving in that case.
let repoRoot: string | undefined;
try {
const gitCommonDir = await getGitCommonDir(cwd);
repoRoot = resolveRepoRootFromGitCommonDir(gitCommonDir);
} catch {
// ignore
if (options?.knownGitCommonDir) {
repoRoot = resolveRepoRootFromGitCommonDir(options.knownGitCommonDir);
} else if (options?.knownGitCommonDir === undefined) {
try {
const gitCommonDir = await getGitCommonDir(cwd);
repoRoot = resolveRepoRootFromGitCommonDir(gitCommonDir);
} catch {
// ignore
}
}
const worktreesBaseRoot = resolvePaseoWorktreesBaseRoot(options);