Merge pull request #243 from btriapitsyn/fix-worktrees

feat: add kind metadata for worktrees and PR workflow support
This commit is contained in:
yulia-ivashko
2026-01-29 21:38:15 +02:00
committed by GitHub
5 changed files with 22 additions and 6 deletions
@@ -328,7 +328,9 @@ export function GitHubPullRequestPickerDialog({
throw new Error(`Local branch already exists: ${preferredBranch}`);
}
const session = await createWorktreeSessionForNewBranchExact(projectDirectory, preferredBranch, headCommitish);
const session = await createWorktreeSessionForNewBranchExact(projectDirectory, preferredBranch, headCommitish, {
kind: 'pr',
});
if (!session?.id) {
throw new Error('Failed to create PR worktree session');
}
@@ -341,12 +343,12 @@ export function GitHubPullRequestPickerDialog({
// Switch the new worktree to the PR branch and delete the SDK-created opencode/* branch immediately.
// This makes the worktree directly operate on the PR branch.
const originalBranch = (meta?.branch || session.branch || '').replace(/^refs\/heads\//, '').trim();
const commands: string[] = [
// Create local branch from the fetched PR head commit.
`git -C ${JSON.stringify(worktreeDir)} switch -c ${JSON.stringify(preferredBranch)} ${JSON.stringify(headCommitish)}`,
];
if (originalBranch && originalBranch.startsWith('opencode/')) {
const originalBranch = (meta?.branch || session.branch || '').replace(/^refs\/heads\//, '').trim();
if (meta?.kind === 'pr' && originalBranch && originalBranch.startsWith('opencode/')) {
commands.push(`git -C ${JSON.stringify(projectDirectory)} branch -D ${JSON.stringify(originalBranch)}`);
}
@@ -394,6 +396,7 @@ export function GitHubPullRequestPickerDialog({
branch: preferredBranch,
label: preferredBranch,
createdFromBranch: pr.base,
kind: 'pr' as const,
});
return { id: session.id };