Skip to content

Commit b01d813

Browse files
chore(lint): add core/webview to no-floating-promises ratchet (#950)
* chore(lint): add core/webview to no-floating-promises ratchet * fix(webview): catch indexing errors and cover changed handler paths * chore(lint): triage new core/webview call sites after merging main Also restore README.md to the upstream version, dropping an unintended formatter artifact picked up during the merge commit. --------- Co-authored-by: edelauna <54631123+edelauna@users.noreply.github.com>
1 parent 488732e commit b01d813

7 files changed

Lines changed: 568 additions & 112 deletions

File tree

src/core/webview/ClineProvider.ts

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ function runDelegationTransition<T>(
144144

145145
locks.set(parentTaskId, tail)
146146

147-
tail.finally(() => {
147+
void tail.finally(() => {
148148
if (locks.get(parentTaskId) === tail) {
149149
locks.delete(parentTaskId)
150150
}
@@ -228,7 +228,7 @@ export class ClineProvider
228228
ClineProvider.activeInstances.add(this)
229229

230230
this.mdmService = mdmService
231-
this.updateGlobalState("codebaseIndexModels", EMBEDDING_MODEL_PROFILES)
231+
void this.updateGlobalState("codebaseIndexModels", EMBEDDING_MODEL_PROFILES)
232232

233233
// Initialize the per-task file-based history store.
234234
// The globalState write-through is debounced separately (not on every mutation)
@@ -725,7 +725,7 @@ export class ClineProvider
725725
this.mcpHub = undefined
726726
await this.skillsManager?.dispose()
727727
this.skillsManager = undefined
728-
this.marketplaceManager?.cleanup()
728+
await this.marketplaceManager?.cleanup()
729729
this.customModesManager?.dispose()
730730
this.taskHistoryStore.dispose()
731731
this.flushGlobalStateWriteThrough()
@@ -860,9 +860,27 @@ export class ClineProvider
860860
setPanel(webviewView, "sidebar")
861861
}
862862

863+
// Set up webview options with proper resource roots
864+
const resourceRoots = [this.contextProxy.extensionUri]
865+
866+
// Add workspace folders to allow access to workspace files
867+
if (vscode.workspace.workspaceFolders) {
868+
resourceRoots.push(...vscode.workspace.workspaceFolders.map((folder) => folder.uri))
869+
}
870+
871+
webviewView.webview.options = {
872+
enableScripts: true,
873+
localResourceRoots: resourceRoots,
874+
}
875+
876+
webviewView.webview.html =
877+
this.contextProxy.extensionMode === vscode.ExtensionMode.Development
878+
? await this.getHMRHtmlContent(webviewView.webview)
879+
: await this.getHtmlContent(webviewView.webview)
880+
863881
// Initialize out-of-scope variables that need to receive persistent
864882
// global state values.
865-
this.getState().then(
883+
await this.getState().then(
866884
({
867885
terminalShellIntegrationTimeout = Terminal.defaultShellIntegrationTimeout,
868886
terminalShellIntegrationDisabled = false,
@@ -890,24 +908,6 @@ export class ClineProvider
890908
},
891909
)
892910

893-
// Set up webview options with proper resource roots
894-
const resourceRoots = [this.contextProxy.extensionUri]
895-
896-
// Add workspace folders to allow access to workspace files
897-
if (vscode.workspace.workspaceFolders) {
898-
resourceRoots.push(...vscode.workspace.workspaceFolders.map((folder) => folder.uri))
899-
}
900-
901-
webviewView.webview.options = {
902-
enableScripts: true,
903-
localResourceRoots: resourceRoots,
904-
}
905-
906-
webviewView.webview.html =
907-
this.contextProxy.extensionMode === vscode.ExtensionMode.Development
908-
? await this.getHMRHtmlContent(webviewView.webview)
909-
: await this.getHtmlContent(webviewView.webview)
910-
911911
// Sets up an event listener to listen for messages passed from the webview view context
912912
// and executes code based on the message that is received.
913913
this.setWebviewMessageListener(webviewView.webview)
@@ -930,7 +930,7 @@ export class ClineProvider
930930
// for this visibility listener panel.
931931
const viewStateDisposable = webviewView.onDidChangeViewState(() => {
932932
if (this.view?.visible) {
933-
this.postMessageToWebview({ type: "action", action: "didBecomeVisible" })
933+
void this.postMessageToWebview({ type: "action", action: "didBecomeVisible" })
934934
} else {
935935
this.logWebviewHiddenDiagnostics()
936936
}
@@ -941,7 +941,7 @@ export class ClineProvider
941941
// sidebar
942942
const visibilityDisposable = webviewView.onDidChangeVisibility(() => {
943943
if (this.view?.visible) {
944-
this.postMessageToWebview({ type: "action", action: "didBecomeVisible" })
944+
void this.postMessageToWebview({ type: "action", action: "didBecomeVisible" })
945945
} else {
946946
this.logWebviewHiddenDiagnostics()
947947
}
@@ -2139,7 +2139,7 @@ export class ClineProvider
21392139
const state = await this.getStateToPostToWebview()
21402140
this.clineMessagesSeq++
21412141
state.clineMessagesSeq = this.clineMessagesSeq
2142-
this.postMessageToWebview({ type: "state", state })
2142+
await this.postMessageToWebview({ type: "state", state })
21432143
}
21442144

21452145
/**
@@ -2155,7 +2155,7 @@ export class ClineProvider
21552155
this.clineMessagesSeq++
21562156
state.clineMessagesSeq = this.clineMessagesSeq
21572157
const { taskHistory: _omit, ...rest } = state
2158-
this.postMessageToWebview({ type: "state", state: rest })
2158+
await this.postMessageToWebview({ type: "state", state: rest })
21592159
}
21602160

21612161
/**
@@ -2172,7 +2172,7 @@ export class ClineProvider
21722172
async postStateToWebviewWithoutClineMessages(): Promise<void> {
21732173
const state = await this.getStateToPostToWebview()
21742174
const { clineMessages: _omitMessages, taskHistory: _omitHistory, ...rest } = state
2175-
this.postMessageToWebview({ type: "state", state: rest })
2175+
await this.postMessageToWebview({ type: "state", state: rest })
21762176
}
21772177

21782178
/**
@@ -2192,7 +2192,7 @@ export class ClineProvider
21922192
])
21932193

21942194
// Send marketplace data separately
2195-
this.postMessageToWebview({
2195+
await this.postMessageToWebview({
21962196
type: "marketplaceData",
21972197
organizationMcps: marketplaceResult.organizationMcps || [],
21982198
marketplaceItems: marketplaceResult.marketplaceItems || [],
@@ -2203,7 +2203,7 @@ export class ClineProvider
22032203
console.error("Failed to fetch marketplace data:", error)
22042204

22052205
// Send empty data on error to prevent UI from hanging
2206-
this.postMessageToWebview({
2206+
await this.postMessageToWebview({
22072207
type: "marketplaceData",
22082208
organizationMcps: [],
22092209
marketplaceItems: [],
@@ -3002,7 +3002,7 @@ export class ClineProvider
30023002
if (currentManager === this.getCurrentWorkspaceCodeIndexManager()) {
30033003
// Get the full status from the manager to ensure we have all fields correctly formatted
30043004
const fullStatus = currentManager.getCurrentStatus()
3005-
this.postMessageToWebview({
3005+
void this.postMessageToWebview({
30063006
type: "indexingStatusUpdate",
30073007
values: fullStatus,
30083008
})
@@ -3014,7 +3014,7 @@ export class ClineProvider
30143014
}
30153015

30163016
// Send initial status for the current workspace
3017-
this.postMessageToWebview({
3017+
void this.postMessageToWebview({
30183018
type: "indexingStatusUpdate",
30193019
values: currentManager.getCurrentStatus(),
30203020
})

0 commit comments

Comments
 (0)