дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-28 05:22:23 +02:00
A project can pin a GitHub CLI account in vcs.github.account (.openidea/settings.toml, a login, never a token), chosen in Settings > Version Control > GitHub or from the Pull Requests tool window header. With an account chosen, its token is resolved through gh and set as GH_TOKEN in the project environment for the project root and its agent worktrees; a .envrc GH_TOKEN still wins, and the token is cleared when the project closes or loses trust. Copilot keeps billing to its own account through COPILOT_GITHUB_TOKEN.
Automatic (the default) sets no GH_TOKEN and makes no GitHub calls on project open. When the settings page or the Pull Requests window asks for the status with several gh accounts signed in, the project's GitHub remote is probed to suggest a non-active account with access ("Use <login> for this project").
New commands: gh_project_account_status, gh_set_project_account. The gh account listing is shared with the Copilot account selector.
Co-authored-by: dengliu <[email protected]>
53 рядки
2.1 KiB
TypeScript
53 рядки
2.1 KiB
TypeScript
import type { Page } from "@playwright/test";
|
||
import type { GhProjectAccountStatus } from "../src/bindings";
|
||
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
|
||
|
||
async function openGithubSettings(page: Page) {
|
||
const settings = "/src/features/settings/model/staging.ts";
|
||
await page.evaluate(async (path) => (await import(/* @vite-ignore */ path)).openSettings("vcs.github"), settings);
|
||
return page.getByRole("dialog", { name: "Settings", exact: true });
|
||
}
|
||
|
||
test("suggests and configures a project-scoped GitHub account in Settings › Version Control › GitHub", async ({
|
||
workbench: page,
|
||
}) => {
|
||
await stubDesktop(page);
|
||
await page.evaluate(() => {
|
||
let configuredAccount = "";
|
||
const makeStatus = (): GhProjectAccountStatus => ({
|
||
ghInstalled: true,
|
||
accounts: [
|
||
{ login: "alice", active: true },
|
||
{ login: "alice-work", active: false },
|
||
],
|
||
configuredAccount,
|
||
effectiveAccount: configuredAccount || "alice",
|
||
suggestedAccount: configuredAccount ? null : "alice-work",
|
||
});
|
||
Object.assign(window.__ipc.handlers, {
|
||
settings_get_global: () => ({}),
|
||
gh_project_account_status: () => makeStatus(),
|
||
gh_set_project_account: ({ account }: { account: string }) => {
|
||
configuredAccount = account;
|
||
return makeStatus();
|
||
},
|
||
});
|
||
});
|
||
|
||
const dialog = await openGithubSettings(page);
|
||
const select = dialog.getByRole("button", { name: "GitHub account" });
|
||
await expect(select).toContainText("Automatic (alice)");
|
||
await expect(
|
||
dialog.getByText("Uses GitHub CLI's active account without setting GH_TOKEN in the project environment."),
|
||
).toBeVisible();
|
||
|
||
await dialog.getByRole("button", { name: "Use alice-work for this project" }).click();
|
||
await expect(select).toContainText("alice-work");
|
||
await expect(
|
||
dialog.getByText(
|
||
"Passes this account's GH_TOKEN to processes started in this project (terminals, agents, Git, and run configurations).",
|
||
),
|
||
).toBeVisible();
|
||
expect(await ipcCalls(page, "gh_set_project_account")).toEqual([{ account: "alice-work" }]);
|
||
});
|