Skip to content

Commit b24db81

Browse files
committed
feat: Cache VSCode version on startup
1 parent c9f992e commit b24db81

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/lib/api-config.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
import type { State } from "./state"
22

3-
export const COPILOT_API_CONFIG = {
4-
baseURL: "https://api.individual.githubcopilot.com",
5-
headers: {
6-
"copilot-integration-id": "vscode-chat",
7-
"copilot-vision-request": "true",
8-
"editor-version": "vscode/1.98.0-insider",
9-
},
10-
} as const
11-
123
export const COPILOT_API_BASE_URL = "https://api.individual.githubcopilot.com"
134
export const copilotHeaders = (state: State) => ({
145
Authorization: `Bearer ${state.copilotToken}`,

src/lib/vscode-version.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import consola from "consola"
2+
3+
import { getVSCodeVersion } from "~/services/get-vscode-version"
4+
5+
import { state } from "./state"
6+
7+
export const cacheVSCodeVersion = async () => {
8+
const response = await getVSCodeVersion()
9+
state.vsCodeVersion = response
10+
11+
consola.info(`Using VSCode version: ${response}`)
12+
}

src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { serve, type ServerHandler } from "srvx"
77
import { cacheModels } from "./lib/models"
88
import { ensurePaths } from "./lib/paths"
99
import { setupCopilotToken, setupGitHubToken } from "./lib/token"
10+
import { cacheVSCodeVersion } from "./lib/vscode-version"
1011
import { server } from "./server"
1112

1213
interface RunServerOptions {
@@ -21,6 +22,7 @@ export async function runServer(options: RunServerOptions): Promise<void> {
2122
}
2223

2324
await ensurePaths()
25+
await cacheVSCodeVersion()
2426
await setupGitHubToken()
2527
await setupCopilotToken()
2628
await cacheModels()

0 commit comments

Comments
 (0)