Skip to content

Commit ecb2721

Browse files
committed
make sure the webview is refreshed with the latest state
1 parent 87cbd06 commit ecb2721

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/core/Cline.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ export class Cline {
143143
const newConfig = await provider.getState()
144144
if (newConfig?.apiConfiguration) {
145145
this.api = buildApiHandler(newConfig.apiConfiguration)
146+
// Force provider to update webview state
147+
await provider.postStateToWebview()
146148
}
147149
}
148150
}),

src/core/webview/ClineProvider.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
15251525
if (this.cline) {
15261526
this.cline.api = buildApiHandler(apiConfiguration)
15271527
}
1528+
1529+
// Force a state refresh after updating configuration
1530+
await this.postStateToWebview()
15281531
}
15291532

15301533
async updateCustomInstructions(instructions?: string) {
@@ -1986,8 +1989,12 @@ export class ClineProvider implements vscode.WebviewViewProvider {
19861989
}
19871990

19881991
async postStateToWebview() {
1989-
const state = await this.getStateToPostToWebview()
1990-
this.postMessageToWebview({ type: "state", state })
1992+
try {
1993+
const state = await this.getStateToPostToWebview()
1994+
await this.postMessageToWebview({ type: "state", state })
1995+
} catch (error) {
1996+
console.error("Error posting state to webview:", error)
1997+
}
19911998
}
19921999

19932000
async getStateToPostToWebview() {

0 commit comments

Comments
 (0)