Skip to content

Commit 2e9c7cd

Browse files
authored
Merge pull request #49 from trypear/token-refresh
Added token refreshing and 5174 port
2 parents 1c7ee46 + 4391416 commit 2e9c7cd

5 files changed

Lines changed: 27 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@
327327
"check-types:benchmark": "cd benchmark && npm run check-types",
328328
"package": "npm-run-all -p build:webview build:esbuild check-types lint",
329329
"pretest": "npm run compile",
330-
"dev": "cd webview-ui && npm run dev",
330+
"dev": "cd webview-ui && npm run dev -- --port 5174",
331331
"test": "npm-run-all -p test:*",
332332
"test:extension": "jest",
333333
"test:webview": "cd webview-ui && npm run test",

src/api/providers/pearai.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export class PearAiHandler extends BaseProvider implements SingleCompletionHandl
3535
}
3636
})
3737
throw new Error("PearAI API key not found. Please login to PearAI.")
38+
} else {
39+
vscode.commands.executeCommand("pearai.checkPearAITokens", undefined)
3840
}
3941

4042
this.handler = new OpenRouterHandler({

src/core/webview/ClineProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
564564
}
565565

566566
private async getHMRHtmlContent(webview: vscode.Webview): Promise<string> {
567-
const localPort = "5173"
567+
const localPort = "5174"
568568
const localServerUrl = `localhost:${localPort}`
569569

570570
// Check if local dev server is running.

src/extension.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,28 @@ export function activate(context: vscode.ExtensionContext) {
112112
}),
113113
)
114114

115+
context.subscriptions.push(
116+
vscode.commands.registerCommand("pearai-roo-cline.updatePearAITokens", async (data) => {
117+
console.dir("Updated PearAI tokens:")
118+
console.dir(data)
119+
context.secrets.store("pearaiApiKey", data.accessToken)
120+
context.secrets.store("pearaiRefreshKey", data.refreshToken)
121+
const provider = await ClineProvider.getInstance()
122+
if (provider) {
123+
// Update the API configuration to clear the PearAI key
124+
await provider.setValues({
125+
pearaiApiKey: data.accessToken,
126+
})
127+
await provider.postStateToWebview()
128+
// Update MCP server with new token
129+
const mcpHub = provider.getMcpHub()
130+
if (mcpHub) {
131+
await mcpHub.updatePearAiApiKey(data.accessToken)
132+
}
133+
}
134+
}),
135+
)
136+
115137
context.subscriptions.push(
116138
vscode.commands.registerCommand("pearai-roo-cline.pearaiLogout", async () => {
117139
console.dir("Logged out of PearAI:")

src/services/mcp/McpHub.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ export class McpHub {
10431043

10441044
await fs.writeFile(settingsPath, JSON.stringify(config, null, 2))
10451045
await this.updateServerConnections(config.mcpServers)
1046-
vscode.window.showInformationMessage("PearAI API key updated successfully")
1046+
// vscode.window.showInformationMessage("PearAI API key updated successfully")
10471047
}
10481048
} catch (error) {
10491049
console.error("Failed to update PearAI API key:", error)

0 commit comments

Comments
 (0)