Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function runDelegationTransition<T>(

locks.set(parentTaskId, tail)

tail.finally(() => {
void tail.finally(() => {
if (locks.get(parentTaskId) === tail) {
locks.delete(parentTaskId)
}
Expand Down Expand Up @@ -234,7 +234,7 @@ export class ClineProvider
ClineProvider.activeInstances.add(this)

this.mdmService = mdmService
this.updateGlobalState("codebaseIndexModels", EMBEDDING_MODEL_PROFILES)
void this.updateGlobalState("codebaseIndexModels", EMBEDDING_MODEL_PROFILES)

// Initialize the per-task file-based history store.
// The globalState write-through is debounced separately (not on every mutation)
Expand Down Expand Up @@ -687,7 +687,7 @@ export class ClineProvider
this.mcpHub = undefined
await this.skillsManager?.dispose()
this.skillsManager = undefined
this.marketplaceManager?.cleanup()
await this.marketplaceManager?.cleanup()
this.customModesManager?.dispose()
this.taskHistoryStore.dispose()
this.flushGlobalStateWriteThrough()
Expand Down Expand Up @@ -822,9 +822,27 @@ export class ClineProvider
setPanel(webviewView, "sidebar")
}

// Set up webview options with proper resource roots
const resourceRoots = [this.contextProxy.extensionUri]

// Add workspace folders to allow access to workspace files
if (vscode.workspace.workspaceFolders) {
resourceRoots.push(...vscode.workspace.workspaceFolders.map((folder) => folder.uri))
}

webviewView.webview.options = {
enableScripts: true,
localResourceRoots: resourceRoots,
}

webviewView.webview.html =
this.contextProxy.extensionMode === vscode.ExtensionMode.Development
? await this.getHMRHtmlContent(webviewView.webview)
: await this.getHtmlContent(webviewView.webview)

// Initialize out-of-scope variables that need to receive persistent
// global state values.
this.getState().then(
await this.getState().then(
({
terminalShellIntegrationTimeout = Terminal.defaultShellIntegrationTimeout,
terminalShellIntegrationDisabled = false,
Expand Down Expand Up @@ -852,24 +870,6 @@ export class ClineProvider
},
)

// Set up webview options with proper resource roots
const resourceRoots = [this.contextProxy.extensionUri]

// Add workspace folders to allow access to workspace files
if (vscode.workspace.workspaceFolders) {
resourceRoots.push(...vscode.workspace.workspaceFolders.map((folder) => folder.uri))
}

webviewView.webview.options = {
enableScripts: true,
localResourceRoots: resourceRoots,
}

webviewView.webview.html =
this.contextProxy.extensionMode === vscode.ExtensionMode.Development
? await this.getHMRHtmlContent(webviewView.webview)
: await this.getHtmlContent(webviewView.webview)

// Sets up an event listener to listen for messages passed from the webview view context
// and executes code based on the message that is received.
this.setWebviewMessageListener(webviewView.webview)
Expand All @@ -892,7 +892,7 @@ export class ClineProvider
// for this visibility listener panel.
const viewStateDisposable = webviewView.onDidChangeViewState(() => {
if (this.view?.visible) {
this.postMessageToWebview({ type: "action", action: "didBecomeVisible" })
void this.postMessageToWebview({ type: "action", action: "didBecomeVisible" })
} else {
this.logWebviewHiddenDiagnostics()
}
Expand All @@ -903,7 +903,7 @@ export class ClineProvider
// sidebar
const visibilityDisposable = webviewView.onDidChangeVisibility(() => {
if (this.view?.visible) {
this.postMessageToWebview({ type: "action", action: "didBecomeVisible" })
void this.postMessageToWebview({ type: "action", action: "didBecomeVisible" })
} else {
this.logWebviewHiddenDiagnostics()
}
Expand Down Expand Up @@ -2107,7 +2107,7 @@ export class ClineProvider
const state = await this.getStateToPostToWebview()
this.clineMessagesSeq++
state.clineMessagesSeq = this.clineMessagesSeq
this.postMessageToWebview({ type: "state", state })
await this.postMessageToWebview({ type: "state", state })
}

/**
Expand All @@ -2123,7 +2123,7 @@ export class ClineProvider
this.clineMessagesSeq++
state.clineMessagesSeq = this.clineMessagesSeq
const { taskHistory: _omit, ...rest } = state
this.postMessageToWebview({ type: "state", state: rest })
await this.postMessageToWebview({ type: "state", state: rest })
}

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

/**
Expand All @@ -2160,7 +2160,7 @@ export class ClineProvider
])

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

// Send empty data on error to prevent UI from hanging
this.postMessageToWebview({
await this.postMessageToWebview({
type: "marketplaceData",
organizationMcps: [],
marketplaceItems: [],
Expand Down Expand Up @@ -2954,7 +2954,7 @@ export class ClineProvider
if (currentManager === this.getCurrentWorkspaceCodeIndexManager()) {
// Get the full status from the manager to ensure we have all fields correctly formatted
const fullStatus = currentManager.getCurrentStatus()
this.postMessageToWebview({
void this.postMessageToWebview({
type: "indexingStatusUpdate",
values: fullStatus,
})
Expand All @@ -2966,7 +2966,7 @@ export class ClineProvider
}

// Send initial status for the current workspace
this.postMessageToWebview({
void this.postMessageToWebview({
type: "indexingStatusUpdate",
values: currentManager.getCurrentStatus(),
})
Expand Down
4 changes: 2 additions & 2 deletions src/core/webview/__tests__/ClineProvider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ describe("ClineProvider", () => {
setModeConfig: vi.fn(),
} as any

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

// Switch to architect mode
await messageHandler({ type: "mode", text: "architect" })
Expand Down Expand Up @@ -1247,7 +1247,7 @@ describe("ClineProvider", () => {
},
}

provider.setValue("customModePrompts", existingPrompts)
await provider.setValue("customModePrompts", existingPrompts)

// Test updating a prompt
await messageHandler({
Expand Down
2 changes: 1 addition & 1 deletion src/core/webview/checkpointRestoreHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function handleCheckpointRestoreOperation(config: CheckpointRestore
// This prevents "Current ask promise was ignored" errors
// For edit operations, we don't abort because the checkpoint restore will handle it
if (operation === "delete" && currentCline && !currentCline.abort) {
currentCline.abortTask()
await currentCline.abortTask()
// Wait a bit for the abort to complete
await pWaitFor(() => currentCline.abort === true, {
timeout: 1000,
Expand Down
6 changes: 3 additions & 3 deletions src/core/webview/rulesMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function handleCreateRule(
try {
const input = parseCreateRuleInput(message)
const createdPath = await createRule(cwd, input)
openFile(createdPath)
await openFile(createdPath)
} catch (error) {
const errorMessage = getErrorMessage(error)
provider.log(`Error creating rule: ${errorMessage}`)
Expand Down Expand Up @@ -89,7 +89,7 @@ export async function handleOpenRuleFile(provider: ClineProvider, cwd: string, m
throw new Error("Rule file not found")
}

openFile(filePath)
await openFile(filePath)
} catch (error) {
const errorMessage = getErrorMessage(error)
provider.log(`Error opening rule file: ${errorMessage}`)
Expand All @@ -109,7 +109,7 @@ export async function handleOpenRulesDirectory(
kind: values.kind,
modeSlug: values.modeSlug,
} as CreateRuleInput)
openFile(directoryPath)
await openFile(directoryPath)
} catch (error) {
const errorMessage = getErrorMessage(error)
provider.log(`Error opening rules directory: ${errorMessage}`)
Expand Down
4 changes: 2 additions & 2 deletions src/core/webview/skillsMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function handleCreateSkill(
const createdPath = await skillsManager.createSkill(skillName, source, skillDescription, modeSlugs)

// Open the created file in the editor
openFile(createdPath)
await openFile(createdPath)

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

openFile(skill.path)
await openFile(skill.path)
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error)
provider.log(`Error opening skill file: ${errorMessage}`)
Expand Down
Loading
Loading