PR review changes

This commit is contained in:
ColemanRoo 2025-01-14 22:10:31 -06:00
parent c2883cdab9
commit ee2588d153
4 changed files with 22 additions and 58 deletions

View file

@ -86,6 +86,7 @@ export class Cline {
didFinishAborting = false
abandoned = false
private diffViewProvider: DiffViewProvider
private slackConfig?: { enabled: boolean; webhookUrl: string }
// streaming
private currentStreamingContentIndex = 0
@ -152,6 +153,7 @@ export class Cline {
console.error('Failed to send initialization notification:', error);
});
}
this.slackConfig = slackConfig
this.diffViewProvider = new DiffViewProvider(cwd)
this.customInstructions = customInstructions
this.diffEnabled = enableDiff ?? false
@ -2070,13 +2072,14 @@ export class Cline {
commandResult = execCommandResult
} else {
await this.say("completion_result", result, undefined, false)
if(this.slackConfig?.enabled && this.slackConfig?.webhookUrl) {
await (async () => {
try {
if (!result) {
console.warn("No result provided for completion notification", {
taskId: this.taskId,
timestamp: new Date().toISOString()
});
})
}
const completionMessage = result
? `✅ Task completed successfully!\n\nResult:\n${result}`
@ -2088,10 +2091,11 @@ export class Cline {
errorMessage: error instanceof Error ? error.message : 'Unknown error',
errorStack: error instanceof Error ? error.stack : 'No stack trace',
taskId: this.taskId
});
})
vscode.window.showErrorMessage(`Failed to send Slack completion notification: ${error instanceof Error ? error.message : 'Unknown error'}`);
}
})();
})()
}
}
// we already sent completion_result says, an empty string asks relinquishes control over button and field
const { response, text, images } = await this.ask("completion_result", "", false);
@ -2261,6 +2265,7 @@ export class Cline {
// lastMessage.ts = Date.now() DO NOT update ts since it is used as a key for virtuoso list
lastMessage.partial = false
// instead of streaming partialMessage events, we do a save and post like normal to persist to disk
console.log("updating artial message", lastMessage)
// await this.saveClineMessages()
}
@ -2327,6 +2332,7 @@ export class Cline {
}
if (this.abort) {
console.log("aborting stream...")
if (!this.abandoned) {
// only need to gracefully abort if this instance isn't abandoned (sometimes openrouter stream hangs, in which case this would affect future instances of cline)
await abortStream("user_cancelled")

View file

@ -1071,19 +1071,11 @@ export class ClineProvider implements vscode.WebviewViewProvider {
}
async updateCustomInstructions(instructions?: string): Promise<void> {
try {
// User may be clearing the field
const normalizedInstructions = instructions || undefined;
await this.updateGlobalState("customInstructions", normalizedInstructions);
if (this.cline) {
this.cline.customInstructions = normalizedInstructions;
}
await this.postStateToWebview();
} catch (error) {
throw new Error(`Failed to update custom instructions: ${error instanceof Error ? error.message : 'Unknown error'}`);
await this.updateGlobalState("customInstructions", instructions || undefined)
if (this.cline) {
this.cline.customInstructions = instructions || undefined
}
await this.postStateToWebview()
}
// MCP
@ -1430,11 +1422,11 @@ export class ClineProvider implements vscode.WebviewViewProvider {
if (fileExists) {
const apiConversationHistory = JSON.parse(await fs.readFile(apiConversationHistoryFilePath, "utf8"))
return {
historyItem,
taskDirPath,
apiConversationHistoryFilePath,
uiMessagesFilePath,
apiConversationHistory,
historyItem,
taskDirPath,
apiConversationHistoryFilePath,
uiMessagesFilePath,
apiConversationHistory,
}
}
}
@ -1459,9 +1451,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
}
async deleteTaskWithId(id: string) {
if (id === this.cline?.taskId) {
if (id === this.cline?.taskId) {
await this.clearTask()
}
}
const { taskDirPath, apiConversationHistoryFilePath, uiMessagesFilePath } = await this.getTaskWithId(id)
@ -1525,6 +1517,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
listApiConfigMeta,
slackWebhookUrl,
slackNotificationsEnabled,
slackConfig,
mode,
} = await this.getState()
@ -1564,10 +1557,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
listApiConfigMeta: listApiConfigMeta ?? [],
slackWebhookUrl: slackWebhookUrl ?? "",
slackNotificationsEnabled: slackNotificationsEnabled ?? false,
slackConfig: {
enabled: slackNotificationsEnabled ?? false,
webhookUrl: slackWebhookUrl ?? ""
},
slackConfig: slackConfig ?? {},
mode: mode ?? codeMode,
}
}

View file

@ -71,16 +71,12 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
const [commandInput, setCommandInput] = useState("")
const handleSubmit = () => {
console.log('handleSubmit called');
console.log('Validating configuration...');
const apiValidationResult = validateApiConfiguration(apiConfiguration)
const modelIdValidationResult = validateModelId(apiConfiguration, glamaModels, openRouterModels)
console.log('Validation results:', { apiValidationResult, modelIdValidationResult });
setApiErrorMessage(apiValidationResult)
setModelIdErrorMessage(modelIdValidationResult)
if (!apiValidationResult && !modelIdValidationResult) {
console.log('Validation passed, sending messages...');
vscode.postMessage({
type: "apiConfiguration",
apiConfiguration
@ -105,15 +101,6 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
vscode.postMessage({ type: "alwaysApproveResubmit", bool: alwaysApproveResubmit })
vscode.postMessage({ type: "requestDelaySeconds", value: requestDelaySeconds })
vscode.postMessage({ type: "currentApiConfigName", text: currentApiConfigName })
// Send settings to extension
console.log('Sending settings to extension...');
console.log('Sound enabled:', soundEnabled);
console.log('Sound volume:', soundVolume);
console.log('Slack notifications enabled:', slackNotificationsEnabled);
console.log('Slack webhook URL:', slackWebhookUrl);
vscode.postMessage({ type: "soundEnabled", bool: soundEnabled });
vscode.postMessage({ type: "soundVolume", value: soundVolume });
vscode.postMessage({ type: "slackNotificationsEnabled", bool: slackNotificationsEnabled });
vscode.postMessage({ type: "slackWebhookUrl", text: slackWebhookUrl });
vscode.postMessage({

View file

@ -183,25 +183,6 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
setListApiConfigMeta(message.listApiConfig ?? [])
break
}
case "soundEnabled": {
if (message.bool !== undefined) {
setState((prevState: ExtensionState) => ({ ...prevState, soundEnabled: message.bool }))
}
break
}
case "soundVolume": {
if (message.value !== undefined) {
setState((prevState: ExtensionState) => ({ ...prevState, soundVolume: message.value }))
}
break
}
case "slackWebhookUrl": {
if (message.text !== undefined) {
setState((prevState: ExtensionState) => ({ ...prevState, slackWebhookUrl: message.text }))
vscode.postMessage({ type: "slackWebhookUrl", text: message.text })
}
break
}
}
}, [setListApiConfigMeta])