Skip to content

Commit 3e17542

Browse files
committed
chore(lint): add core/webview to no-floating-promises ratchet
1 parent 6e05ae9 commit 3e17542

7 files changed

Lines changed: 110 additions & 108 deletions

File tree

‎src/core/webview/ClineProvider.ts‎

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

143143
locks.set(parentTaskId, tail)
144144

145-
tail.finally(() => {
145+
void tail.finally(() => {
146146
if (locks.get(parentTaskId) === tail) {
147147
locks.delete(parentTaskId)
148148
}
@@ -234,7 +234,7 @@ export class ClineProvider
234234
ClineProvider.activeInstances.add(this)
235235

236236
this.mdmService = mdmService
237-
this.updateGlobalState("codebaseIndexModels", EMBEDDING_MODEL_PROFILES)
237+
void this.updateGlobalState("codebaseIndexModels", EMBEDDING_MODEL_PROFILES)
238238

239239
// Initialize the per-task file-based history store.
240240
// The globalState write-through is debounced separately (not on every mutation)
@@ -687,7 +687,7 @@ export class ClineProvider
687687
this.mcpHub = undefined
688688
await this.skillsManager?.dispose()
689689
this.skillsManager = undefined
690-
this.marketplaceManager?.cleanup()
690+
await this.marketplaceManager?.cleanup()
691691
this.customModesManager?.dispose()
692692
this.taskHistoryStore.dispose()
693693
this.flushGlobalStateWriteThrough()
@@ -822,9 +822,27 @@ export class ClineProvider
822822
setPanel(webviewView, "sidebar")
823823
}
824824

825+
// Set up webview options with proper resource roots
826+
const resourceRoots = [this.contextProxy.extensionUri]
827+
828+
// Add workspace folders to allow access to workspace files
829+
if (vscode.workspace.workspaceFolders) {
830+
resourceRoots.push(...vscode.workspace.workspaceFolders.map((folder) => folder.uri))
831+
}
832+
833+
webviewView.webview.options = {
834+
enableScripts: true,
835+
localResourceRoots: resourceRoots,
836+
}
837+
838+
webviewView.webview.html =
839+
this.contextProxy.extensionMode === vscode.ExtensionMode.Development
840+
? await this.getHMRHtmlContent(webviewView.webview)
841+
: await this.getHtmlContent(webviewView.webview)
842+
825843
// Initialize out-of-scope variables that need to receive persistent
826844
// global state values.
827-
this.getState().then(
845+
await this.getState().then(
828846
({
829847
terminalShellIntegrationTimeout = Terminal.defaultShellIntegrationTimeout,
830848
terminalShellIntegrationDisabled = false,
@@ -852,24 +870,6 @@ export class ClineProvider
852870
},
853871
)
854872

855-
// Set up webview options with proper resource roots
856-
const resourceRoots = [this.contextProxy.extensionUri]
857-
858-
// Add workspace folders to allow access to workspace files
859-
if (vscode.workspace.workspaceFolders) {
860-
resourceRoots.push(...vscode.workspace.workspaceFolders.map((folder) => folder.uri))
861-
}
862-
863-
webviewView.webview.options = {
864-
enableScripts: true,
865-
localResourceRoots: resourceRoots,
866-
}
867-
868-
webviewView.webview.html =
869-
this.contextProxy.extensionMode === vscode.ExtensionMode.Development
870-
? await this.getHMRHtmlContent(webviewView.webview)
871-
: await this.getHtmlContent(webviewView.webview)
872-
873873
// Sets up an event listener to listen for messages passed from the webview view context
874874
// and executes code based on the message that is received.
875875
this.setWebviewMessageListener(webviewView.webview)
@@ -892,7 +892,7 @@ export class ClineProvider
892892
// for this visibility listener panel.
893893
const viewStateDisposable = webviewView.onDidChangeViewState(() => {
894894
if (this.view?.visible) {
895-
this.postMessageToWebview({ type: "action", action: "didBecomeVisible" })
895+
void this.postMessageToWebview({ type: "action", action: "didBecomeVisible" })
896896
} else {
897897
this.logWebviewHiddenDiagnostics()
898898
}
@@ -903,7 +903,7 @@ export class ClineProvider
903903
// sidebar
904904
const visibilityDisposable = webviewView.onDidChangeVisibility(() => {
905905
if (this.view?.visible) {
906-
this.postMessageToWebview({ type: "action", action: "didBecomeVisible" })
906+
void this.postMessageToWebview({ type: "action", action: "didBecomeVisible" })
907907
} else {
908908
this.logWebviewHiddenDiagnostics()
909909
}
@@ -2107,7 +2107,7 @@ export class ClineProvider
21072107
const state = await this.getStateToPostToWebview()
21082108
this.clineMessagesSeq++
21092109
state.clineMessagesSeq = this.clineMessagesSeq
2110-
this.postMessageToWebview({ type: "state", state })
2110+
await this.postMessageToWebview({ type: "state", state })
21112111
}
21122112

21132113
/**
@@ -2123,7 +2123,7 @@ export class ClineProvider
21232123
this.clineMessagesSeq++
21242124
state.clineMessagesSeq = this.clineMessagesSeq
21252125
const { taskHistory: _omit, ...rest } = state
2126-
this.postMessageToWebview({ type: "state", state: rest })
2126+
await this.postMessageToWebview({ type: "state", state: rest })
21272127
}
21282128

21292129
/**
@@ -2140,7 +2140,7 @@ export class ClineProvider
21402140
async postStateToWebviewWithoutClineMessages(): Promise<void> {
21412141
const state = await this.getStateToPostToWebview()
21422142
const { clineMessages: _omitMessages, taskHistory: _omitHistory, ...rest } = state
2143-
this.postMessageToWebview({ type: "state", state: rest })
2143+
await this.postMessageToWebview({ type: "state", state: rest })
21442144
}
21452145

21462146
/**
@@ -2160,7 +2160,7 @@ export class ClineProvider
21602160
])
21612161

21622162
// Send marketplace data separately
2163-
this.postMessageToWebview({
2163+
await this.postMessageToWebview({
21642164
type: "marketplaceData",
21652165
organizationMcps: marketplaceResult.organizationMcps || [],
21662166
marketplaceItems: marketplaceResult.marketplaceItems || [],
@@ -2171,7 +2171,7 @@ export class ClineProvider
21712171
console.error("Failed to fetch marketplace data:", error)
21722172

21732173
// Send empty data on error to prevent UI from hanging
2174-
this.postMessageToWebview({
2174+
await this.postMessageToWebview({
21752175
type: "marketplaceData",
21762176
organizationMcps: [],
21772177
marketplaceItems: [],
@@ -2954,7 +2954,7 @@ export class ClineProvider
29542954
if (currentManager === this.getCurrentWorkspaceCodeIndexManager()) {
29552955
// Get the full status from the manager to ensure we have all fields correctly formatted
29562956
const fullStatus = currentManager.getCurrentStatus()
2957-
this.postMessageToWebview({
2957+
void this.postMessageToWebview({
29582958
type: "indexingStatusUpdate",
29592959
values: fullStatus,
29602960
})
@@ -2966,7 +2966,7 @@ export class ClineProvider
29662966
}
29672967

29682968
// Send initial status for the current workspace
2969-
this.postMessageToWebview({
2969+
void this.postMessageToWebview({
29702970
type: "indexingStatusUpdate",
29712971
values: currentManager.getCurrentStatus(),
29722972
})

‎src/core/webview/__tests__/ClineProvider.spec.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ describe("ClineProvider", () => {
11491149
setModeConfig: vi.fn(),
11501150
} as any
11511151

1152-
provider.setValue("currentApiConfigName", "current-config")
1152+
await provider.setValue("currentApiConfigName", "current-config")
11531153

11541154
// Switch to architect mode
11551155
await messageHandler({ type: "mode", text: "architect" })
@@ -1247,7 +1247,7 @@ describe("ClineProvider", () => {
12471247
},
12481248
}
12491249

1250-
provider.setValue("customModePrompts", existingPrompts)
1250+
await provider.setValue("customModePrompts", existingPrompts)
12511251

12521252
// Test updating a prompt
12531253
await messageHandler({

‎src/core/webview/checkpointRestoreHandler.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export async function handleCheckpointRestoreOperation(config: CheckpointRestore
3131
// This prevents "Current ask promise was ignored" errors
3232
// For edit operations, we don't abort because the checkpoint restore will handle it
3333
if (operation === "delete" && currentCline && !currentCline.abort) {
34-
currentCline.abortTask()
34+
await currentCline.abortTask()
3535
// Wait a bit for the abort to complete
3636
await pWaitFor(() => currentCline.abort === true, {
3737
timeout: 1000,

‎src/core/webview/rulesMessageHandler.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export async function handleCreateRule(
3838
try {
3939
const input = parseCreateRuleInput(message)
4040
const createdPath = await createRule(cwd, input)
41-
openFile(createdPath)
41+
await openFile(createdPath)
4242
} catch (error) {
4343
const errorMessage = getErrorMessage(error)
4444
provider.log(`Error creating rule: ${errorMessage}`)
@@ -89,7 +89,7 @@ export async function handleOpenRuleFile(provider: ClineProvider, cwd: string, m
8989
throw new Error("Rule file not found")
9090
}
9191

92-
openFile(filePath)
92+
await openFile(filePath)
9393
} catch (error) {
9494
const errorMessage = getErrorMessage(error)
9595
provider.log(`Error opening rule file: ${errorMessage}`)
@@ -109,7 +109,7 @@ export async function handleOpenRulesDirectory(
109109
kind: values.kind,
110110
modeSlug: values.modeSlug,
111111
} as CreateRuleInput)
112-
openFile(directoryPath)
112+
await openFile(directoryPath)
113113
} catch (error) {
114114
const errorMessage = getErrorMessage(error)
115115
provider.log(`Error opening rules directory: ${errorMessage}`)

‎src/core/webview/skillsMessageHandler.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export async function handleCreateSkill(
5555
const createdPath = await skillsManager.createSkill(skillName, source, skillDescription, modeSlugs)
5656

5757
// Open the created file in the editor
58-
openFile(createdPath)
58+
await openFile(createdPath)
5959

6060
// Send updated skills list
6161
const skills = skillsManager.getSkillsMetadata()
@@ -199,7 +199,7 @@ export async function handleOpenSkillFile(provider: ClineProvider, message: Webv
199199
throw new Error(t("skills:errors.skill_not_found", { name: skillName }))
200200
}
201201

202-
openFile(skill.path)
202+
await openFile(skill.path)
203203
} catch (error) {
204204
const errorMessage = error instanceof Error ? error.message : String(error)
205205
provider.log(`Error opening skill file: ${errorMessage}`)

0 commit comments

Comments
 (0)