fix(ai): filter Copilot models by account availability

closes #5897
This commit is contained in:
Vegard Stikbakke
2026-06-19 13:16:51 +02:00
parent 226a316824
commit 6e6ce70caf
5 changed files with 169 additions and 8 deletions

View File

@@ -4,6 +4,7 @@
### Fixed
- Fixed `/model` to hide GitHub Copilot models that are unavailable to the authenticated account ([#5897](https://github.com/earendil-works/pi/issues/5897)).
- Fixed `/model` selector search to rank exact provider-prefixed matches before proxy-provider model ID matches ([#5892](https://github.com/earendil-works/pi/issues/5892)).
## [0.79.8] - 2026-06-19

View File

@@ -1669,6 +1669,25 @@ describe("ModelRegistry", () => {
expect(count).toBe(0);
});
test("getAvailable filters GitHub Copilot OAuth models to account picker availability", () => {
authStorage.set("github-copilot", {
type: "oauth",
refresh: "github-access-token",
access: "tid=test;exp=9999999999;proxy-ep=proxy.individual.githubcopilot.com;",
expires: Date.now() + 60_000,
availableModelIds: ["gpt-4.1"],
});
const registry = ModelRegistry.create(authStorage, modelsJsonPath);
expect(
registry
.getAvailable()
.filter((m) => m.provider === "github-copilot")
.map((m) => m.id),
).toEqual(["gpt-4.1"]);
});
test("getApiKeyAndHeaders resolves authHeader on every request", async () => {
const tokenFile = join(tempDir, "token");
writeFileSync(tokenFile, "token-1");