From d6300f33caeb74c35d75f6f60db25c62b49ba28d Mon Sep 17 00:00:00 2001 From: Shirone Date: Mon, 19 Jan 2026 00:49:56 +0100 Subject: [PATCH] fix: skip PR assignment for main worktree and refine metadata fallback logic This update modifies the list handler to skip PR assignment for the main worktree, preventing confusion when displaying PRs on the main branch tab. Additionally, the fallback logic for assigning stored metadata is refined to only apply if the PR state is 'OPEN', ensuring more accurate representation of PRs. --- apps/server/src/routes/worktree/routes/list.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/server/src/routes/worktree/routes/list.ts b/apps/server/src/routes/worktree/routes/list.ts index e82e5c14..f0d9c030 100644 --- a/apps/server/src/routes/worktree/routes/list.ts +++ b/apps/server/src/routes/worktree/routes/list.ts @@ -368,6 +368,13 @@ export function createListHandler() { : new Map(); for (const worktree of worktrees) { + // Skip PR assignment for the main worktree - it's not meaningful to show + // PRs on the main branch tab, and can be confusing if someone created + // a PR from main to another branch + if (worktree.isMain) { + continue; + } + const metadata = allMetadata.get(worktree.branch); const githubPR = githubPRs.get(worktree.branch); @@ -387,8 +394,8 @@ export function createListHandler() { ); }); } - } else if (metadata?.pr) { - // Fall back to stored metadata (for PRs not in recent GitHub response) + } else if (metadata?.pr && metadata.pr.state === 'OPEN') { + // Fall back to stored metadata only if the PR is still OPEN worktree.pr = metadata.pr; } }