Elffuss BraidHub

kikocis/continue public

Merge pull request #6590 from continuedev/pe/req-headers

chore: add ideInfo headers to hub reqs
Changeset2341a2a49c81c53b0ea9b5e72b208ba72e9804f0b745590bc59c00691cdb09cb
AuthorDallin Romney <dallinromney@gmail.com> · 2025-07-17 18:46 +02:00
CommitterGitHub <noreply@github.com> · 2025-07-17 18:46 +02:00
Parentsc10bddf80ff0, 9e76bdcc19c2

Browse the files at this changeset

10 files changed

modified core/config/ConfigHandler.ts +3 −0
@@ -65,9 +65,11 @@
6565 ) {
6666 this.ide = ide;
6767 this.ideSettingsPromise = ideSettingsPromise;
68+
6869 this.controlPlaneClient = new ControlPlaneClient(
6970 sessionInfoPromise,
7071 ideSettingsPromise,
72+ this.ide.getIdeInfo(),
7173 );
7274
7375 // This profile manager will always be available
@@ -364,6 +366,7 @@
364366 this.controlPlaneClient = new ControlPlaneClient(
365367 Promise.resolve(sessionInfo),
366368 this.ideSettingsPromise,
369+ this.ide.getIdeInfo(),
367370 );
368371 this.abortCascade();
369372 await this.cascadeInit("Control plane session info update");
modified core/control-plane/client.ts +8 −1
@@ -10,7 +10,7 @@
1010 import fetch, { RequestInit, Response } from "node-fetch";
1111
1212 import { OrganizationDescription } from "../config/ProfileLifecycleManager.js";
13-import { IdeSettings, ModelDescription } from "../index.js";
13+import { IdeInfo, IdeSettings, ModelDescription } from "../index.js";
1414
1515 import { ControlPlaneSessionInfo, isOnPremSession } from "./AuthTypes.js";
1616 import { getControlPlaneEnv } from "./env.js";
@@ -40,6 +40,7 @@
4040 ControlPlaneSessionInfo | undefined
4141 >,
4242 private readonly ideSettingsPromise: Promise<IdeSettings>,
43+ private readonly ideInfoPromise: Promise<IdeInfo>,
4344 ) {}
4445
4546 async resolveFQSNs(
@@ -86,11 +87,17 @@
8687
8788 const env = await getControlPlaneEnv(this.ideSettingsPromise);
8889 const url = new URL(path, env.CONTROL_PLANE_URL).toString();
90+ const ideInfo = await this.ideInfoPromise;
91+
8992 const resp = await fetch(url, {
9093 ...init,
9194 headers: {
9295 ...init.headers,
9396 Authorization: `Bearer ${accessToken}`,
97+ ...{
98+ "x-extension-version": ideInfo.extensionVersion,
99+ "x-is-prerelease": String(ideInfo.isPrerelease),
100+ },
94101 },
95102 });
96103
modified core/index.d.ts +1 −0
@@ -711,6 +711,7 @@
711711 version: string;
712712 remoteName: string;
713713 extensionVersion: string;
714+ isPrerelease: boolean;
714715 }
715716
716717 export interface BranchAndDir {
modified core/test/fixtures.ts +1 −0
@@ -13,6 +13,7 @@
1313 export const testControlPlaneClient = new ControlPlaneClient(
1414 Promise.resolve(undefined),
1515 ideSettingsPromise,
16+ testIde.getIdeInfo(),
1617 );
1718
1819 export const testConfigHandler = new ConfigHandler(
modified core/util/filesystem.ts +1 −0
@@ -120,6 +120,7 @@
120120 version: "0.1",
121121 remoteName: "na",
122122 extensionVersion: "na",
123+ isPrerelease: false,
123124 });
124125 }
125126
modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +3 −2
@@ -1,3 +1,4 @@
1+
12 package com.github.continuedev.continueintellijextension.`continue`
23
34 import com.github.continuedev.continueintellijextension.*
@@ -86,7 +87,8 @@
8687 name = ideName,
8788 version = ideVersion,
8889 remoteName = remoteName,
89- extensionVersion = extensionVersion
90+ extensionVersion = extensionVersion,
91+ isPrerelease = false // TODO: Implement prerelease detection for JetBrains
9092 )
9193 }
9294
@@ -623,4 +625,3 @@
623625 }
624626
625627 }
626-
modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt +2 −1
@@ -30,7 +30,8 @@
3030 val name: String,
3131 val version: String,
3232 val remoteName: String,
33- val extensionVersion: String
33+ val extensionVersion: String,
34+ val isPrerelease: Boolean
3435 )
3536
3637 data class Problem(
modified extensions/vscode/src/VsCodeIde.ts +3 −3
@@ -27,6 +27,7 @@
2727 TerminalOptions,
2828 Thread,
2929 } from "core";
30+import { getExtensionVersion, isExtensionPrerelease } from "./util/util";
3031
3132 class VsCodeIde implements IDE {
3233 ideUtils: VsCodeIdeUtils;
@@ -153,9 +154,8 @@
153154 name: vscode.env.appName,
154155 version: vscode.version,
155156 remoteName: vscode.env.remoteName || "local",
156- extensionVersion:
157- vscode.extensions.getExtension("continue.continue")?.packageJSON
158- .version,
157+ extensionVersion: getExtensionVersion(),
158+ isPrerelease: isExtensionPrerelease(),
159159 });
160160 }
161161
modified extensions/vscode/src/util/util.ts +12 −0
@@ -126,3 +126,15 @@
126126 export function getvsCodeUriScheme(): string {
127127 return vscode.env.uriScheme;
128128 }
129+
130+export function isExtensionPrerelease(): boolean {
131+ const extensionVersion = getExtensionVersion();
132+ const versionParts = extensionVersion.split(".");
133+ if (versionParts.length >= 2) {
134+ const minorVersion = parseInt(versionParts[1], 10);
135+ if (!isNaN(minorVersion)) {
136+ return minorVersion % 2 !== 0;
137+ }
138+ }
139+ return false;
140+}
added extensions/vscode/src/util/util.vitest.ts +26 −0
@@ -0,0 +1,26 @@
1+import { expect, test, vi } from "vitest";
2+import * as vscode from "vscode";
3+
4+// Mock the vscode module
5+vi.mock("vscode", () => ({
6+ extensions: {
7+ getExtension: vi.fn(),
8+ },
9+}));
10+
11+// Import the function after mocking
12+import { isExtensionPrerelease } from "./util";
13+
14+test("isExtensionPrerelease detects prerelease versions correctly", () => {
15+ // 1.0.0 is not prerelease (even minor version)
16+ vi.mocked(vscode.extensions.getExtension).mockReturnValue({
17+ packageJSON: { version: "1.0.0" },
18+ } as any);
19+ expect(isExtensionPrerelease()).toBe(false);
20+
21+ // 1.1.0 is prerelease (odd minor version)
22+ vi.mocked(vscode.extensions.getExtension).mockReturnValue({
23+ packageJSON: { version: "1.1.0" },
24+ } as any);
25+ expect(isExtensionPrerelease()).toBe(true);
26+});