Remove debug checkbox

This commit is contained in:
Matt Rubens
2024-12-16 22:58:04 -05:00
parent fb8a33e19b
commit 06202be46f
10 changed files with 13 additions and 72 deletions

View File

@@ -97,7 +97,6 @@ export class Cline {
apiConfiguration: ApiConfiguration, apiConfiguration: ApiConfiguration,
customInstructions?: string, customInstructions?: string,
diffEnabled?: boolean, diffEnabled?: boolean,
debugDiffEnabled?: boolean,
task?: string, task?: string,
images?: string[], images?: string[],
historyItem?: HistoryItem, historyItem?: HistoryItem,
@@ -110,7 +109,7 @@ export class Cline {
this.diffViewProvider = new DiffViewProvider(cwd) this.diffViewProvider = new DiffViewProvider(cwd)
this.customInstructions = customInstructions this.customInstructions = customInstructions
if (diffEnabled && this.api.getModel().id) { if (diffEnabled && this.api.getModel().id) {
this.diffStrategy = getDiffStrategy(this.api.getModel().id, debugDiffEnabled) this.diffStrategy = getDiffStrategy(this.api.getModel().id)
} }
if (historyItem) { if (historyItem) {
this.taskId = historyItem.id this.taskId = historyItem.id

View File

@@ -279,8 +279,9 @@ describe('Cline', () => {
mockApiConfig, mockApiConfig,
'custom instructions', 'custom instructions',
false, // diffEnabled false, // diffEnabled
false, // debugDiffEnabled 'test task', // task
'test task' undefined, // images
undefined // historyItem
); );
expect(cline.customInstructions).toBe('custom instructions'); expect(cline.customInstructions).toBe('custom instructions');

View File

@@ -6,10 +6,10 @@ import { SearchReplaceDiffStrategy } from './strategies/search-replace'
* @param model The name of the model being used (e.g., 'gpt-4', 'claude-3-opus') * @param model The name of the model being used (e.g., 'gpt-4', 'claude-3-opus')
* @returns The appropriate diff strategy for the model * @returns The appropriate diff strategy for the model
*/ */
export function getDiffStrategy(model: string, debugEnabled?: boolean): DiffStrategy { export function getDiffStrategy(model: string): DiffStrategy {
// For now, return SearchReplaceDiffStrategy for all models (with a fuzzy threshold of 0.9) // For now, return SearchReplaceDiffStrategy for all models (with a fuzzy threshold of 0.9)
// This architecture allows for future optimizations based on model capabilities // This architecture allows for future optimizations based on model capabilities
return new SearchReplaceDiffStrategy(0.9, debugEnabled) return new SearchReplaceDiffStrategy(0.9)
} }
export type { DiffStrategy } export type { DiffStrategy }

View File

@@ -55,12 +55,10 @@ function getSimilarity(original: string, search: string): number {
export class SearchReplaceDiffStrategy implements DiffStrategy { export class SearchReplaceDiffStrategy implements DiffStrategy {
private fuzzyThreshold: number; private fuzzyThreshold: number;
public debugEnabled: boolean;
constructor(fuzzyThreshold?: number, debugEnabled?: boolean) { constructor(fuzzyThreshold?: number) {
// Default to exact matching (1.0) unless fuzzy threshold specified // Default to exact matching (1.0) unless fuzzy threshold specified
this.fuzzyThreshold = fuzzyThreshold ?? 1.0; this.fuzzyThreshold = fuzzyThreshold ?? 1.0;
this.debugEnabled = debugEnabled ?? false;
} }
getToolDescription(cwd: string): string { getToolDescription(cwd: string): string {
@@ -177,11 +175,9 @@ Result:
// Extract the search and replace blocks // Extract the search and replace blocks
const match = diffContent.match(/<<<<<<< SEARCH\n([\s\S]*?)\n?=======\n([\s\S]*?)\n?>>>>>>> REPLACE/); const match = diffContent.match(/<<<<<<< SEARCH\n([\s\S]*?)\n?=======\n([\s\S]*?)\n?>>>>>>> REPLACE/);
if (!match) { if (!match) {
const debugInfo = this.debugEnabled ? `\n\nDebug Info:\n- Expected Format: <<<<<<< SEARCH\\n[search content]\\n=======\\n[replace content]\\n>>>>>>> REPLACE\n- Tip: Make sure to include both SEARCH and REPLACE sections with correct markers` : '';
return { return {
success: false, success: false,
error: `Invalid diff format - missing required SEARCH/REPLACE sections${debugInfo}` error: `Invalid diff format - missing required SEARCH/REPLACE sections\n\nDebug Info:\n- Expected Format: <<<<<<< SEARCH\\n[search content]\\n=======\\n[replace content]\\n>>>>>>> REPLACE\n- Tip: Make sure to include both SEARCH and REPLACE sections with correct markers`
}; };
} }
@@ -221,17 +217,9 @@ Result:
const exactEndIndex = endLine - 1; const exactEndIndex = endLine - 1;
if (exactStartIndex < 0 || exactEndIndex > originalLines.length || exactStartIndex > exactEndIndex) { if (exactStartIndex < 0 || exactEndIndex > originalLines.length || exactStartIndex > exactEndIndex) {
const debugInfo = this.debugEnabled ? `\n\nDebug Info:\n- Requested Range: lines ${startLine}-${endLine}\n- File Bounds: lines 1-${originalLines.length}` : '';
// Log detailed debug information
console.log('Invalid Line Range Debug:', {
requestedRange: { start: startLine, end: endLine },
fileBounds: { start: 1, end: originalLines.length }
});
return { return {
success: false, success: false,
error: `Line range ${startLine}-${endLine} is invalid (file has ${originalLines.length} lines)${debugInfo}`, error: `Line range ${startLine}-${endLine} is invalid (file has ${originalLines.length} lines)\n\nDebug Info:\n- Requested Range: lines ${startLine}-${endLine}\n- File Bounds: lines 1-${originalLines.length}`,
}; };
} }
@@ -294,13 +282,11 @@ Result:
? `\n\nBest Match Found:\n${addLineNumbers(bestMatchContent, matchIndex + 1)}` ? `\n\nBest Match Found:\n${addLineNumbers(bestMatchContent, matchIndex + 1)}`
: `\n\nBest Match Found:\n(no match)`; : `\n\nBest Match Found:\n(no match)`;
const debugInfo = this.debugEnabled ? `\n\nDebug Info:\n- Similarity Score: ${Math.floor(bestMatchScore * 100)}%\n- Required Threshold: ${Math.floor(this.fuzzyThreshold * 100)}%\n- Search Range: ${startLine && endLine ? `lines ${startLine}-${endLine}` : 'start to end'}\n\nSearch Content:\n${searchChunk}${bestMatchSection}${originalContentSection}` : '';
const lineRange = startLine || endLine ? const lineRange = startLine || endLine ?
` at ${startLine ? `start: ${startLine}` : 'start'} to ${endLine ? `end: ${endLine}` : 'end'}` : ''; ` at ${startLine ? `start: ${startLine}` : 'start'} to ${endLine ? `end: ${endLine}` : 'end'}` : '';
return { return {
success: false, success: false,
error: `No sufficiently similar match found${lineRange} (${Math.floor(bestMatchScore * 100)}% similar, needs ${Math.floor(this.fuzzyThreshold * 100)}%)${debugInfo}` error: `No sufficiently similar match found${lineRange} (${Math.floor(bestMatchScore * 100)}% similar, needs ${Math.floor(this.fuzzyThreshold * 100)}%)\n\nDebug Info:\n- Similarity Score: ${Math.floor(bestMatchScore * 100)}%\n- Required Threshold: ${Math.floor(this.fuzzyThreshold * 100)}%\n- Search Range: ${startLine && endLine ? `lines ${startLine}-${endLine}` : 'start to end'}\n\nSearch Content:\n${searchChunk}${bestMatchSection}${originalContentSection}`
}; };
} }

View File

@@ -13,11 +13,6 @@ export type DiffResult =
}}; }};
export interface DiffStrategy { export interface DiffStrategy {
/**
* Whether to enable detailed debug logging
*/
debugEnabled?: boolean;
/** /**
* Get the tool description for this diff strategy * Get the tool description for this diff strategy
* @param cwd The current working directory * @param cwd The current working directory

View File

@@ -68,7 +68,6 @@ type GlobalStateKey =
| "soundEnabled" | "soundEnabled"
| "soundVolume" | "soundVolume"
| "diffEnabled" | "diffEnabled"
| "debugDiffEnabled"
| "alwaysAllowMcp" | "alwaysAllowMcp"
export const GlobalFileNames = { export const GlobalFileNames = {
@@ -217,8 +216,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
const { const {
apiConfiguration, apiConfiguration,
customInstructions, customInstructions,
diffEnabled, diffEnabled
debugDiffEnabled,
} = await this.getState() } = await this.getState()
this.cline = new Cline( this.cline = new Cline(
@@ -226,7 +224,6 @@ export class ClineProvider implements vscode.WebviewViewProvider {
apiConfiguration, apiConfiguration,
customInstructions, customInstructions,
diffEnabled, diffEnabled,
debugDiffEnabled,
task, task,
images images
) )
@@ -237,8 +234,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
const { const {
apiConfiguration, apiConfiguration,
customInstructions, customInstructions,
diffEnabled, diffEnabled
debugDiffEnabled,
} = await this.getState() } = await this.getState()
this.cline = new Cline( this.cline = new Cline(
@@ -246,10 +242,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
apiConfiguration, apiConfiguration,
customInstructions, customInstructions,
diffEnabled, diffEnabled,
debugDiffEnabled,
undefined, undefined,
undefined, undefined,
historyItem, historyItem
) )
} }
@@ -614,11 +609,6 @@ export class ClineProvider implements vscode.WebviewViewProvider {
await this.updateGlobalState("diffEnabled", diffEnabled) await this.updateGlobalState("diffEnabled", diffEnabled)
await this.postStateToWebview() await this.postStateToWebview()
break break
case "debugDiffEnabled":
const debugDiffEnabled = message.bool ?? false
await this.updateGlobalState("debugDiffEnabled", debugDiffEnabled)
await this.postStateToWebview()
break
} }
}, },
null, null,
@@ -945,7 +935,6 @@ export class ClineProvider implements vscode.WebviewViewProvider {
alwaysAllowMcp, alwaysAllowMcp,
soundEnabled, soundEnabled,
diffEnabled, diffEnabled,
debugDiffEnabled,
taskHistory, taskHistory,
soundVolume, soundVolume,
} = await this.getState() } = await this.getState()
@@ -970,7 +959,6 @@ export class ClineProvider implements vscode.WebviewViewProvider {
.sort((a, b) => b.ts - a.ts), .sort((a, b) => b.ts - a.ts),
soundEnabled: soundEnabled ?? false, soundEnabled: soundEnabled ?? false,
diffEnabled: diffEnabled ?? false, diffEnabled: diffEnabled ?? false,
debugDiffEnabled: debugDiffEnabled ?? false,
shouldShowAnnouncement: lastShownAnnouncementId !== this.latestAnnouncementId, shouldShowAnnouncement: lastShownAnnouncementId !== this.latestAnnouncementId,
allowedCommands, allowedCommands,
soundVolume: soundVolume ?? 0.5, soundVolume: soundVolume ?? 0.5,
@@ -1066,7 +1054,6 @@ export class ClineProvider implements vscode.WebviewViewProvider {
allowedCommands, allowedCommands,
soundEnabled, soundEnabled,
diffEnabled, diffEnabled,
debugDiffEnabled,
soundVolume, soundVolume,
] = await Promise.all([ ] = await Promise.all([
this.getGlobalState("apiProvider") as Promise<ApiProvider | undefined>, this.getGlobalState("apiProvider") as Promise<ApiProvider | undefined>,
@@ -1105,7 +1092,6 @@ export class ClineProvider implements vscode.WebviewViewProvider {
this.getGlobalState("allowedCommands") as Promise<string[] | undefined>, this.getGlobalState("allowedCommands") as Promise<string[] | undefined>,
this.getGlobalState("soundEnabled") as Promise<boolean | undefined>, this.getGlobalState("soundEnabled") as Promise<boolean | undefined>,
this.getGlobalState("diffEnabled") as Promise<boolean | undefined>, this.getGlobalState("diffEnabled") as Promise<boolean | undefined>,
this.getGlobalState("debugDiffEnabled") as Promise<boolean | undefined>,
this.getGlobalState("soundVolume") as Promise<number | undefined>, this.getGlobalState("soundVolume") as Promise<number | undefined>,
]) ])
@@ -1162,7 +1148,6 @@ export class ClineProvider implements vscode.WebviewViewProvider {
allowedCommands, allowedCommands,
soundEnabled: soundEnabled ?? false, soundEnabled: soundEnabled ?? false,
diffEnabled: diffEnabled ?? false, diffEnabled: diffEnabled ?? false,
debugDiffEnabled: debugDiffEnabled ?? false,
soundVolume, soundVolume,
} }
} }

View File

@@ -53,7 +53,6 @@ export interface ExtensionState {
soundEnabled?: boolean soundEnabled?: boolean
soundVolume?: number soundVolume?: number
diffEnabled?: boolean diffEnabled?: boolean
debugDiffEnabled?: boolean
} }
export interface ClineMessage { export interface ClineMessage {

View File

@@ -34,7 +34,6 @@ export interface WebviewMessage {
| "soundEnabled" | "soundEnabled"
| "soundVolume" | "soundVolume"
| "diffEnabled" | "diffEnabled"
| "debugDiffEnabled"
| "openMcpSettings" | "openMcpSettings"
| "restartMcpServer" | "restartMcpServer"
| "toggleToolAlwaysAllow" | "toggleToolAlwaysAllow"

View File

@@ -33,8 +33,6 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
setSoundVolume, setSoundVolume,
diffEnabled, diffEnabled,
setDiffEnabled, setDiffEnabled,
debugDiffEnabled,
setDebugDiffEnabled,
openRouterModels, openRouterModels,
setAllowedCommands, setAllowedCommands,
allowedCommands, allowedCommands,
@@ -64,7 +62,6 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
vscode.postMessage({ type: "soundEnabled", bool: soundEnabled }) vscode.postMessage({ type: "soundEnabled", bool: soundEnabled })
vscode.postMessage({ type: "soundVolume", value: soundVolume }) vscode.postMessage({ type: "soundVolume", value: soundVolume })
vscode.postMessage({ type: "diffEnabled", bool: diffEnabled }) vscode.postMessage({ type: "diffEnabled", bool: diffEnabled })
vscode.postMessage({ type: "debugDiffEnabled", bool: debugDiffEnabled })
onDone() onDone()
} }
} }
@@ -358,20 +355,6 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
</div> </div>
)} )}
</div> </div>
<div style={{ marginBottom: 5 }}>
<VSCodeCheckbox checked={debugDiffEnabled} onChange={(e: any) => setDebugDiffEnabled(e.target.checked)}>
<span style={{ fontWeight: "500" }}>Debug diff operations</span>
</VSCodeCheckbox>
<p
style={{
fontSize: "12px",
marginTop: "5px",
color: "var(--vscode-descriptionForeground)",
}}>
When enabled, Cline will show detailed debug information when applying diffs fails.
</p>
</div>
</div> </div>
{IS_DEV && ( {IS_DEV && (

View File

@@ -31,7 +31,6 @@ export interface ExtensionStateContextType extends ExtensionState {
setSoundEnabled: (value: boolean) => void setSoundEnabled: (value: boolean) => void
setSoundVolume: (value: number) => void setSoundVolume: (value: number) => void
setDiffEnabled: (value: boolean) => void setDiffEnabled: (value: boolean) => void
setDebugDiffEnabled: (value: boolean) => void
} }
const ExtensionStateContext = createContext<ExtensionStateContextType | undefined>(undefined) const ExtensionStateContext = createContext<ExtensionStateContextType | undefined>(undefined)
@@ -46,7 +45,6 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
soundEnabled: false, soundEnabled: false,
soundVolume: 0.5, soundVolume: 0.5,
diffEnabled: false, diffEnabled: false,
debugDiffEnabled: false,
}) })
const [didHydrateState, setDidHydrateState] = useState(false) const [didHydrateState, setDidHydrateState] = useState(false)
const [showWelcome, setShowWelcome] = useState(false) const [showWelcome, setShowWelcome] = useState(false)
@@ -149,10 +147,6 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
setSoundEnabled: (value) => setState((prevState) => ({ ...prevState, soundEnabled: value })), setSoundEnabled: (value) => setState((prevState) => ({ ...prevState, soundEnabled: value })),
setSoundVolume: (value) => setState((prevState) => ({ ...prevState, soundVolume: value })), setSoundVolume: (value) => setState((prevState) => ({ ...prevState, soundVolume: value })),
setDiffEnabled: (value) => setState((prevState) => ({ ...prevState, diffEnabled: value })), setDiffEnabled: (value) => setState((prevState) => ({ ...prevState, diffEnabled: value })),
setDebugDiffEnabled: (value) => setState((prevState) => ({
...prevState,
debugDiffEnabled: value
})),
} }
return <ExtensionStateContext.Provider value={contextValue}>{children}</ExtensionStateContext.Provider> return <ExtensionStateContext.Provider value={contextValue}>{children}</ExtensionStateContext.Provider>