-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat: restore trimmed/whitespace search and replace fallbacks #7866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…github.com/continuedev/continue into dallin/search-replace-fallbacks-v2
AI Code ReviewAI review failed due to service initialization issues. Please check the Continue API key and configuration. No specific line comments generated. 💡 To request a new detailed review, comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9 issues found across 26 files
Prompt for AI agents (all 9 issues)
Understand the root cause of the following 9 issues and fix them.
<file name="gui/src/pages/gui/ToolCallDiv/FindAndReplace.test.tsx">
<violation number="1" location="gui/src/pages/gui/ToolCallDiv/FindAndReplace.test.tsx:46">
Import targets core module while tests still mock a different (now missing) path, so performFindAndReplace won’t be mocked and vi.importActual will fail.</violation>
</file>
<file name="core/edit/searchAndReplace/findSearchMatch.vitest.ts">
<violation number="1" location="core/edit/searchAndReplace/findSearchMatch.vitest.ts:204">
Test title contradicts assertion and implementation; rename to reflect emptySearch result instead of null.</violation>
</file>
<file name="gui/src/util/clientTools/callClientTool.ts">
<violation number="1" location="gui/src/util/clientTools/callClientTool.ts:64">
Unknown error case drops the original message, reducing debuggability; include String(e) when creating the ContinueError.</violation>
</file>
<file name="extensions/cli/src/telemetry/telemetryService.ts">
<violation number="1" location="extensions/cli/src/telemetry/telemetryService.ts:525">
PostHog events may be dropped on process exit; telemetryService.shutdown doesn’t call posthogService.shutdown to flush pending events.</violation>
<violation number="2" location="extensions/cli/src/telemetry/telemetryService.ts:525">
PostHog capture is gated by isEnabled() (OTLP metrics). Without OTLP config, this call never executes; if PostHog should send regardless, move it outside this gate.</violation>
<violation number="3" location="extensions/cli/src/telemetry/telemetryService.ts:525">
Async telemetry call is not awaited or explicitly marked fire-and-forget; prefix with void to make intent clear and avoid accidental unhandled promise usage.</violation>
</file>
<file name="gui/src/redux/thunks/callToolById.ts">
<violation number="1" location="gui/src/redux/thunks/callToolById.ts:142">
Telemetry schema change: replacing errorMessage with errorReason may break existing analytics consumers. Consider maintaining backward compatibility (e.g., include both fields or deprecate gradually).</violation>
</file>
<file name="core/edit/searchAndReplace/performReplace.ts">
<violation number="1" location="core/edit/searchAndReplace/performReplace.ts:31">
Comment says edits are applied in reverse order, but code applies them sequentially; update the comment for accuracy or implement reverse ordering.</violation>
</file>
<file name="core/util/errors.ts">
<violation number="1" location="core/util/errors.ts:19">
Set the error name in the constructor so logs and handlers see 'ContinueError' instead of the generic 'Error'.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai
to give feedback, ask questions, or re-run the review.
}); | ||
}); | ||
|
||
it("should return null for empty search content after whitespace removal", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test title contradicts assertion and implementation; rename to reflect emptySearch result instead of null.
Prompt for AI agents
Address the following comment on core/edit/searchAndReplace/findSearchMatch.vitest.ts at line 204:
<comment>Test title contradicts assertion and implementation; rename to reflect emptySearch result instead of null.</comment>
<file context>
@@ -0,0 +1,571 @@
+ });
+ });
+
+ it("should return null for empty search content after whitespace removal", () => {
+ const fileContent = "some content";
+ const searchContent = " \t\n ";
</file context>
? e | ||
: e instanceof Error | ||
? new ContinueError(ContinueErrorReason.Unspecified, e.message) | ||
: new ContinueError(ContinueErrorReason.Unknown), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unknown error case drops the original message, reducing debuggability; include String(e) when creating the ContinueError.
Prompt for AI agents
Address the following comment on gui/src/util/clientTools/callClientTool.ts at line 64:
<comment>Unknown error case drops the original message, reducing debuggability; include String(e) when creating the ContinueError.</comment>
<file context>
@@ -51,18 +52,16 @@ export async function callClientTool(
+ ? e
+ : e instanceof Error
+ ? new ContinueError(ContinueErrorReason.Unspecified, e.message)
+ : new ContinueError(ContinueErrorReason.Unknown),
output: undefined,
};
</file context>
: new ContinueError(ContinueErrorReason.Unknown), | |
: new ContinueError(ContinueErrorReason.Unknown, String(e)), |
// TODO: Implement OTLP logs export | ||
logger.debug("Tool result event", attributes); | ||
|
||
posthogService.capture("cli_tool_call_outcome", { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PostHog events may be dropped on process exit; telemetryService.shutdown doesn’t call posthogService.shutdown to flush pending events.
Prompt for AI agents
Address the following comment on extensions/cli/src/telemetry/telemetryService.ts at line 525:
<comment>PostHog events may be dropped on process exit; telemetryService.shutdown doesn’t call posthogService.shutdown to flush pending events.</comment>
<file context>
@@ -515,11 +518,17 @@ class TelemetryService {
// TODO: Implement OTLP logs export
logger.debug("Tool result event", attributes);
+
+ posthogService.capture("cli_tool_call_outcome", {
+ succeeded: options.success,
+ toolName: options.toolName,
</file context>
// TODO: Implement OTLP logs export | ||
logger.debug("Tool result event", attributes); | ||
|
||
posthogService.capture("cli_tool_call_outcome", { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PostHog capture is gated by isEnabled() (OTLP metrics). Without OTLP config, this call never executes; if PostHog should send regardless, move it outside this gate.
Prompt for AI agents
Address the following comment on extensions/cli/src/telemetry/telemetryService.ts at line 525:
<comment>PostHog capture is gated by isEnabled() (OTLP metrics). Without OTLP config, this call never executes; if PostHog should send regardless, move it outside this gate.</comment>
<file context>
@@ -515,11 +518,17 @@ class TelemetryService {
// TODO: Implement OTLP logs export
logger.debug("Tool result event", attributes);
+
+ posthogService.capture("cli_tool_call_outcome", {
+ succeeded: options.success,
+ toolName: options.toolName,
</file context>
✅ Addressed in c6858ad
succeeded: !error, | ||
toolName: toolCallState.toolCall.function.name, | ||
errorMessage: errorMessage, | ||
errorReason: error?.reason, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Telemetry schema change: replacing errorMessage with errorReason may break existing analytics consumers. Consider maintaining backward compatibility (e.g., include both fields or deprecate gradually).
Prompt for AI agents
Address the following comment on gui/src/redux/thunks/callToolById.ts at line 142:
<comment>Telemetry schema change: replacing errorMessage with errorReason may break existing analytics consumers. Consider maintaining backward compatibility (e.g., include both fields or deprecate gradually).</comment>
<file context>
@@ -131,14 +137,14 @@ export const callToolById = createAsyncThunk<
+ succeeded: !error,
toolName: toolCallState.toolCall.function.name,
- errorMessage: errorMessage,
+ errorReason: error?.reason,
duration_ms: duration_ms,
});
</file context>
…allin/search-replace-fallbacks-v2
…allin/search-replace-error-codes-con-3928
…github.com/continuedev/continue into dallin/search-replace-fallbacks-v2
…allin/search-replace-fallbacks-v2
Description
Jaro Winkler was removed here #7240
Other fallbacks were removed here #7267
This PR reintroduces whitespace and trimmed fallbacks
Other key changes
Summary by cubic
Restores trimmed and whitespace-ignored find/replace fallbacks and fixes match indexing to make edits more reliable. Adds structured ContinueError reasons surfaced in CLI/GUI and telemetry, and consolidates find/replace logic in core with extensive tests.
New Features
Refactors