Skip to content

Commit b08b28f

Browse files
committed
fix(ui): auto-switch branch when configured branch doesn't exist
When the branch list loads and the active branch (e.g. gh-pages) doesn't exist in the repo, automatically fall back to gh-pages > main > first available branch. This fixes the dropdown showing a mismatched branch name. Also improved back button visibility with a bordered style matching the branch selector. https://claude.ai/code/session_01UMaCWiW4jwY8gRyvKveWcE
1 parent 2bddfc8 commit b08b28f

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/app/SiteView.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ export function SiteView({ config, token, userLogin, onLogout, onBack }: SiteVie
8989

9090
fetchBranches(owner, repoName, token.accessToken).then((branchList) => {
9191
setBranches(branchList);
92+
// If the configured branch doesn't exist, fall back to a valid one
93+
if (branchList.length > 0 && !branchList.includes(matchedSite.branch)) {
94+
const fallback = branchList.includes('gh-pages')
95+
? 'gh-pages'
96+
: branchList.includes('main')
97+
? 'main'
98+
: branchList[0]!;
99+
setActiveBranch(fallback);
100+
}
92101
}).catch(() => { /* dropdown won't populate */ });
93102
// eslint-disable-next-line react-hooks/exhaustive-deps -- only re-run when repo/branch changes
94103
}, [matchedSite?.repo, matchedSite?.branch, token.accessToken]);

src/app/styles.css

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,18 @@ body {
103103

104104
.pp-status-back {
105105
background: none;
106-
border: none;
107-
color: #959da5;
106+
border: 1px solid #444d56;
107+
border-radius: 3px;
108+
color: #c9d1d9;
108109
cursor: pointer;
109-
font-size: 0.85rem;
110-
padding: 0 0.25rem;
110+
font-size: 0.75rem;
111+
padding: 0.1rem 0.4rem;
111112
line-height: 1;
112113
}
113114

114115
.pp-status-back:hover {
115-
color: #c9d1d9;
116+
background: #444d56;
117+
color: #fff;
116118
}
117119

118120
.pp-status-branch {

0 commit comments

Comments
 (0)