Skip to content

Commit 7594550

Browse files
committed
Added client side error
1 parent a1f8937 commit 7594550

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/api/providers/pearai.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
import { OpenAiHandler } from "./openai"
2+
import * as vscode from "vscode"
23
import { ApiHandlerOptions, PEARAI_URL } from "../../shared/api"
34
import { AnthropicHandler } from "./anthropic"
45

56
export class PearAiHandler extends AnthropicHandler {
67
constructor(options: ApiHandlerOptions) {
78
if (!options.pearaiApiKey) {
9+
vscode.window.showErrorMessage("PearAI API key not found.", "Login to PearAI").then(async (selection) => {
10+
if (selection === "Login to PearAI") {
11+
const extensionUrl = `${vscode.env.uriScheme}://pearai.pearai/auth`
12+
const callbackUri = await vscode.env.asExternalUri(vscode.Uri.parse(extensionUrl))
13+
14+
vscode.env.openExternal(
15+
await vscode.env.asExternalUri(
16+
vscode.Uri.parse(
17+
`https://trypear.ai/signin?callback=${callbackUri.toString()}`, // Change to localhost if running locally
18+
),
19+
),
20+
)
21+
}
22+
})
823
throw new Error("PearAI API key not found. Please login to PearAI.")
924
}
1025
super({

0 commit comments

Comments
 (0)