fix: clarify GitHub token settings

This commit is contained in:
Bohdan Triapitsyn
2026-06-11 18:59:58 +03:00
parent 6ca99a3d5e
commit 465732858f
11 changed files with 56 additions and 14 deletions
+11 -1
View File
@@ -84,12 +84,22 @@ export function registerGitHubRoutes(app) {
const ghCliDisabled = isGhCliDisabled();
const ghToken = getGhCliToken();
const usingOwnToken = Boolean(auth?.accessToken);
let ghCliUser = null;
if (ghToken !== null && !ghCliDisabled && usingOwnToken) {
try {
const { Octokit } = await import('@octokit/rest');
ghCliUser = await getGitHubUserSummary(new Octokit({ auth: ghToken }));
} catch {
ghCliUser = null;
}
}
const buildGhCli = (activeUser = null) => ({
available: ghToken !== null,
disabled: ghCliDisabled,
active: !usingOwnToken && ghToken !== null && !ghCliDisabled,
...(activeUser ? { user: activeUser } : {}),
...(!ghCliDisabled && (activeUser || ghCliUser) ? { user: activeUser || ghCliUser } : {}),
});
const octokit = getOctokitOrNull();