Skip to content

Commit a604f94

Browse files
ctemehmetsunkur
authored andcommitted
Move presentAssistantMessage into its own module (RooCodeInc#3345)
1 parent b28f3b7 commit a604f94

21 files changed

+997
-1004
lines changed

jest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = {
1414
allowJs: true,
1515
},
1616
diagnostics: false,
17-
isolatedModules: true,
1817
},
1918
],
2019
},

src/core/CodeActionProvider.ts renamed to src/activate/CodeActionProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as vscode from "vscode"
22

3-
import { EditorUtils } from "./EditorUtils"
3+
import { EditorUtils } from "../integrations/editor/EditorUtils"
44

55
export type CodeActionName = "EXPLAIN" | "FIX" | "IMPROVE" | "ADD_TO_CONTEXT" | "NEW_TASK"
66

src/core/__tests__/CodeActionProvider.test.ts renamed to src/activate/__tests__/CodeActionProvider.test.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
// npx jest src/core/__tests__/CodeActionProvider.test.ts
1+
// npx jest src/activate/__tests__/CodeActionProvider.test.ts
22

33
import * as vscode from "vscode"
44

5-
import { EditorUtils } from "../EditorUtils"
5+
import { EditorUtils } from "../../integrations/editor/EditorUtils"
66

77
import { CodeActionProvider, ACTION_TITLES } from "../CodeActionProvider"
88

9-
// Mock VSCode API
109
jest.mock("vscode", () => ({
1110
CodeAction: jest.fn().mockImplementation((title, kind) => ({
1211
title,
@@ -29,8 +28,7 @@ jest.mock("vscode", () => ({
2928
},
3029
}))
3130

32-
// Mock EditorUtils
33-
jest.mock("../EditorUtils", () => ({
31+
jest.mock("../../integrations/editor/EditorUtils", () => ({
3432
EditorUtils: {
3533
getEffectiveRange: jest.fn(),
3634
getFilePath: jest.fn(),
@@ -48,23 +46,16 @@ describe("CodeActionProvider", () => {
4846
beforeEach(() => {
4947
provider = new CodeActionProvider()
5048

51-
// Mock document
5249
mockDocument = {
5350
getText: jest.fn(),
5451
lineAt: jest.fn(),
5552
lineCount: 10,
5653
uri: { fsPath: "/test/file.ts" },
5754
}
5855

59-
// Mock range
6056
mockRange = new vscode.Range(0, 0, 0, 10)
6157

62-
// Mock context
63-
mockContext = {
64-
diagnostics: [],
65-
}
66-
67-
// Setup default EditorUtils mocks
58+
mockContext = { diagnostics: [] }
6859
;(EditorUtils.getEffectiveRange as jest.Mock).mockReturnValue({
6960
range: mockRange,
7061
text: "test code",
@@ -106,6 +97,7 @@ describe("CodeActionProvider", () => {
10697

10798
it("should handle errors gracefully", () => {
10899
const consoleErrorSpy = jest.spyOn(console, "error").mockImplementation(() => {})
100+
109101
;(EditorUtils.getEffectiveRange as jest.Mock).mockImplementation(() => {
110102
throw new Error("Test error")
111103
})

src/activate/handleTask.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import * as vscode from "vscode"
22

3-
import { COMMAND_IDS } from "../core/CodeActionProvider"
43
import { ClineProvider } from "../core/webview/ClineProvider"
4+
55
import { t } from "../i18n"
66

7+
import { COMMAND_IDS } from "./CodeActionProvider"
8+
79
export const handleNewTask = async (params: { prompt?: string } | null | undefined) => {
810
let prompt = params?.prompt
911

src/activate/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export { handleUri } from "./handleUri"
22
export { registerCommands } from "./registerCommands"
33
export { registerCodeActions } from "./registerCodeActions"
44
export { registerTerminalActions } from "./registerTerminalActions"
5+
export { CodeActionProvider } from "./CodeActionProvider"

src/activate/registerCodeActions.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import * as vscode from "vscode"
22

3-
import { type CodeActionName, type CodeActionId, COMMAND_IDS } from "../core/CodeActionProvider"
4-
import { EditorUtils } from "../core/EditorUtils"
3+
import { EditorUtils } from "../integrations/editor/EditorUtils"
54
import { ClineProvider } from "../core/webview/ClineProvider"
65

6+
import { type CodeActionName, type CodeActionId, COMMAND_IDS } from "./CodeActionProvider"
7+
78
export const registerCodeActions = (context: vscode.ExtensionContext) => {
89
registerCodeAction(context, COMMAND_IDS.EXPLAIN, "EXPLAIN")
910
registerCodeAction(context, COMMAND_IDS.FIX, "FIX")

0 commit comments

Comments
 (0)