* fix(workspaces): show isolation without checkout delay * fix(workspaces): trust hydrated project capability * fix(workspaces): resolve branch before creation * fix(workspaces): honor invalidated checkout status * fix(workspaces): preserve isolation while projects load * fix(workspaces): keep provisional project routes usable Route-derived projects do not know their worktree capability. Represent that uncertainty at the placement boundary so remembered worktree intent survives hydration without disabling the New Workspace screen indefinitely.
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import type { CreatePaseoWorktreeInput } from "@getpaseo/client/internal/daemon-client";
|
|
import type { ForgeSearchItem } from "@getpaseo/protocol/messages";
|
|
import type { CheckoutStatusPayload } from "@/git/checkout-status-cache";
|
|
|
|
export type PickerItem =
|
|
| { kind: "branch"; name: string }
|
|
| {
|
|
kind: "github-pr";
|
|
item: ForgeSearchItem;
|
|
};
|
|
|
|
export type PickerCheckoutRequest = Pick<
|
|
CreatePaseoWorktreeInput,
|
|
"action" | "refName" | "checkoutSource" | "githubPrNumber"
|
|
>;
|
|
|
|
export function pickerItemToCheckoutRequest(
|
|
item: PickerItem | null,
|
|
): PickerCheckoutRequest | undefined {
|
|
if (!item) return undefined;
|
|
switch (item.kind) {
|
|
case "branch":
|
|
return { action: "branch-off", refName: item.name };
|
|
case "github-pr": {
|
|
const headRefName = item.item.headRefName?.trim();
|
|
const forge = item.item.forge ?? "github";
|
|
return {
|
|
action: "checkout",
|
|
...(headRefName ? { refName: headRefName } : {}),
|
|
checkoutSource: {
|
|
kind: "change_request",
|
|
forge,
|
|
number: item.item.number,
|
|
...(item.item.projectPath ? { projectPath: item.item.projectPath } : {}),
|
|
},
|
|
...(forge === "github"
|
|
? {
|
|
// COMPAT(githubPrNumber): added in v0.1.106, remove after 2026-12-28 once
|
|
// daemon floor parses checkoutSource.
|
|
githubPrNumber: item.item.number,
|
|
}
|
|
: {}),
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
export function resolveCheckoutRequest(
|
|
selectedItem: PickerItem | null,
|
|
checkoutStatus: CheckoutStatusPayload,
|
|
): PickerCheckoutRequest | undefined {
|
|
const selectedCheckoutRequest = pickerItemToCheckoutRequest(selectedItem);
|
|
if (selectedCheckoutRequest) return selectedCheckoutRequest;
|
|
if (!checkoutStatus.currentBranch) return undefined;
|
|
return {
|
|
action: "branch-off",
|
|
refName: checkoutStatus.currentBranch,
|
|
};
|
|
}
|