Skip to content

Commit e3dd78f

Browse files
refactoring
1 parent 7f26ebb commit e3dd78f

2 files changed

Lines changed: 25 additions & 12 deletions

File tree

src/views/SetupView.ts

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,16 @@ export class SetupViewProvider implements vscode.WebviewViewProvider {
143143
}
144144

145145
private async connectToCodacy() {
146-
await codacyAuth()
146+
try {
147+
await codacyAuth()
148+
this.updateLoginState()
149+
this.updateCLIStatus()
150+
} catch (error) {
151+
Logger.error(`Failed to connect to Codacy: ${error instanceof Error ? error.message : 'Unknown error'}`)
152+
vscode.window.showErrorMessage(
153+
`Failed to connect to Codacy: ${error instanceof Error ? error.message : 'Unknown error'}`
154+
)
155+
}
147156
}
148157

149158
private updateBadge() {
@@ -198,17 +207,21 @@ export class SetupViewProvider implements vscode.WebviewViewProvider {
198207
private updateMCPStatus() {
199208
if (this._view) {
200209
const isMCPInstalled = isMCPConfigured()
201-
checkRulesFile().then((hasInstructionFile) => {
202-
// MCP is complete when installed and has instructions file
203-
this._isMCPComplete = isMCPInstalled && hasInstructionFile
204-
this.updateBadge()
205-
206-
this._view?.webview.postMessage({
207-
type: 'mcpStatusChanged',
208-
isMCPInstalled,
209-
hasInstructionFile,
210+
checkRulesFile()
211+
.then((hasInstructionFile) => {
212+
// MCP is complete when installed and has instructions file
213+
this._isMCPComplete = isMCPInstalled && hasInstructionFile
214+
this.updateBadge()
215+
216+
this._view?.webview.postMessage({
217+
type: 'mcpStatusChanged',
218+
isMCPInstalled,
219+
hasInstructionFile,
220+
})
221+
})
222+
.catch((error) => {
223+
Logger.error(`Failed to check MCP status: ${error instanceof Error ? error.message : 'Unknown error'}`)
210224
})
211-
})
212225
}
213226
}
214227

src/views/scripts/setupScript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ts-check
22
/// <reference lib="dom" />
33

4-
/* global acquireVsCodeApi, document, window, console */
4+
/* global acquireVsCodeApi, document, window */
55

66
/**
77
* @typedef {Object} VsCodeApi

0 commit comments

Comments
 (0)