mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
feat: introduce experimental diff strategy toggle and enhance diff handling
- Added support for an experimental diff strategy in the Cline class, allowing users to opt for a new unified diff approach. - Updated the getDiffStrategy function to accommodate the experimental strategy, adjusting the fuzzy match threshold accordingly. - Integrated experimentalDiffStrategy into the global state management, enabling persistence across sessions. - Enhanced the ClineProvider and related components to handle the new experimental strategy, including UI updates for user settings. - Improved task history management to include the experimentalDiffStrategy setting, ensuring consistency in task execution. - Updated relevant interfaces and types to reflect the new experimentalDiffStrategy property.
This commit is contained in:
@@ -51,6 +51,7 @@ import { detectCodeOmission } from "../integrations/editor/detect-omission"
|
||||
import { BrowserSession } from "../services/browser/BrowserSession"
|
||||
import { OpenRouterHandler } from "../api/providers/openrouter"
|
||||
import { McpHub } from "../services/mcp/McpHub"
|
||||
import crypto from "crypto"
|
||||
|
||||
const cwd =
|
||||
vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath).at(0) ?? path.join(os.homedir(), "Desktop") // may or may not exist but fs checking existence would immediately ask for permission which would be bad UX, need to come up with a better solution
|
||||
@@ -105,26 +106,30 @@ export class Cline {
|
||||
task?: string | undefined,
|
||||
images?: string[] | undefined,
|
||||
historyItem?: HistoryItem | undefined,
|
||||
experimentalDiffStrategy?: boolean,
|
||||
) {
|
||||
this.providerRef = new WeakRef(provider)
|
||||
this.taskId = crypto.randomUUID()
|
||||
this.api = buildApiHandler(apiConfiguration)
|
||||
this.terminalManager = new TerminalManager()
|
||||
this.urlContentFetcher = new UrlContentFetcher(provider.context)
|
||||
this.browserSession = new BrowserSession(provider.context)
|
||||
this.diffViewProvider = new DiffViewProvider(cwd)
|
||||
this.customInstructions = customInstructions
|
||||
this.diffEnabled = enableDiff ?? false
|
||||
if (this.diffEnabled && this.api.getModel().id) {
|
||||
this.diffStrategy = getDiffStrategy(this.api.getModel().id, fuzzyMatchThreshold ?? 1.0)
|
||||
}
|
||||
|
||||
// Prioritize experimentalDiffStrategy from history item if available
|
||||
const effectiveExperimentalDiffStrategy = historyItem?.experimentalDiffStrategy ?? experimentalDiffStrategy
|
||||
this.diffStrategy = getDiffStrategy(this.api.getModel().id, fuzzyMatchThreshold, effectiveExperimentalDiffStrategy)
|
||||
this.diffViewProvider = new DiffViewProvider(cwd)
|
||||
this.providerRef = new WeakRef(provider)
|
||||
|
||||
if (historyItem) {
|
||||
this.taskId = historyItem.id
|
||||
this.resumeTaskFromHistory()
|
||||
} else if (task || images) {
|
||||
this.taskId = Date.now().toString()
|
||||
}
|
||||
|
||||
if (task || images) {
|
||||
this.startTask(task, images)
|
||||
} else {
|
||||
throw new Error("Either historyItem or task/images must be provided")
|
||||
} else if (historyItem) {
|
||||
this.resumeTaskFromHistory()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user