Skip to content
Closed
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
3d39f2c
feat(diffView): add autoFocus setting for diff view tab behavior
felixAnhalt Apr 25, 2025
53eb305
feat(diffViewWebUI): add diffViewAutoFocus setting and control
felixAnhalt Apr 25, 2025
a1831be
feat(diffView): add autoFocus labels and descriptions for multiple la…
felixAnhalt Apr 25, 2025
5ba577d
refactor(diffView): re-add autoFocus labels and descriptions from mul…
felixAnhalt Apr 25, 2025
742cc69
feat(diffView): implement diffViewAutoFocus setting and update relate…
felixAnhalt Apr 25, 2025
629fbad
feat(diffView): update diff editor behavior to use rightUri and enhan…
felixAnhalt Apr 25, 2025
4d0e9e0
feat(diffView): refactor diff editor opening logic and improve autoFo…
felixAnhalt Apr 25, 2025
dab08ab
feat(changeset): add changeset
felixAnhalt Apr 25, 2025
84dc391
test(diffView): add mock for createTextEditorDecorationType and verif…
felixAnhalt Apr 25, 2025
04889b7
test(diffView): add mock for createTextEditorDecorationType and verif…
felixAnhalt Apr 25, 2025
5f86d92
feat(diffView): enhance autoFocus handling for diff view and improve …
felixAnhalt Apr 26, 2025
8705104
feat(diffView): streamline editor fetching un open diff editor
felixAnhalt Apr 27, 2025
936fec1
feat(diffView): enhance diff editor opening to respect view column se…
felixAnhalt Apr 30, 2025
8644484
feat(diffView): update view column handling to default to Active for …
felixAnhalt May 1, 2025
151452a
feat(diffView): update default view column to Active for diff editor …
felixAnhalt May 1, 2025
6fb64b1
feat(diffView): implement focus handling for previous editor when aut…
felixAnhalt May 1, 2025
6be9b12
feat(diffView): refactor openDiffEditor to use default view column an…
felixAnhalt May 2, 2025
5fb1ec7
feat(diffView): finalize view col and re-focus behavior
felixAnhalt May 4, 2025
e19bbad
feat(diffView): restore functionality to open the finished edited fil…
felixAnhalt May 4, 2025
6b2e8a4
feat(diffView): add autoCloseRooTabs setting to manage automatic clos…
felixAnhalt May 4, 2025
aa87e05
fix(diffView): set default view column to -1 for proper initialization
felixAnhalt May 4, 2025
1d2c965
fix(diffView): remove unnecessary check for autoCloseRooTabs in close…
felixAnhalt May 4, 2025
fedddae
feat(diffView): add autoCloseTabs setting to manage tab closure behavior
felixAnhalt May 4, 2025
c0a5673
Merge remote-tracking branch 'origin/main' into feature/2122-editor-f…
felixAnhalt May 4, 2025
1426735
feat(diffView): enhance auto-focus behavior and manage user interactions
felixAnhalt May 6, 2025
d1d4eec
Merge branch 'RooVetGit:main' into feature/2122-editor-focus
felixAnhalt May 6, 2025
0e21dd4
Merge remote-tracking branch 'origin/main' into feature/2122-editor-f…
felixAnhalt May 9, 2025
ee10d10
feat(settings): streamline JSON structure and add auto-focus and auto…
felixAnhalt May 9, 2025
927760c
feat(diffView): refactor diff view reset methods to include listeners…
felixAnhalt May 9, 2025
945666b
feat(diffView): fix diffViewProvider config tests (ugly for now)
felixAnhalt May 9, 2025
185626c
Merge remote-tracking branch 'origin/main' into feature/2122-editor-f…
felixAnhalt May 11, 2025
7629191
feat(view): enhance view column handling for multiple windows and Web…
felixAnhalt May 11, 2025
61a8f55
Merge branch 'main' of https://github.com/RooVetGit/Roo-Code into edi…
seedlord May 13, 2025
f4ab14d
fix: comment out tab closing logic in DiffViewProvider
seedlord May 13, 2025
bff8aaf
Merge branch 'main' of https://github.com/RooVetGit/Roo-Code into edi…
seedlord May 13, 2025
05be241
Merge remote-tracking branch 'origin/main' into feature/2122-editor-f…
felixAnhalt May 13, 2025
f371001
Merge branch 'feature/2122-editor-focus' of https://github.com/felixa…
seedlord May 14, 2025
31d8a77
Merge branch 'main' of https://github.com/RooVetGit/Roo-Code into edi…
seedlord May 14, 2025
4560403
Merge remote-tracking branch 'origin/main' into feature/2122-editor-f…
felixAnhalt May 14, 2025
4799865
fix(exports): add exports/types.ts change leftovers from merge
felixAnhalt May 14, 2025
36ab8ad
Merge remote-tracking branch 'origin/main' into feature/2122-editor-f…
felixAnhalt May 15, 2025
f2627fe
fix(settings): update autoFocus description for clarity and consistency
felixAnhalt May 15, 2025
9316be6
Merge branch 'feature/2122-editor-focus' of https://github.com/felixa…
seedlord May 17, 2025
92647f7
Merge remote-tracking branch 'origin/main' into feature/2122-editor-f…
felixAnhalt May 17, 2025
a5ceddc
fix(diff-view): streamline tab closing logic in DiffViewProvider
felixAnhalt May 17, 2025
ef726e8
Merge branch 'feature/2122-editor-focus' of https://github.com/felixa…
seedlord May 17, 2025
92a623d
Merge branch 'main' of https://github.com/RooVetGit/Roo-Code into edi…
seedlord May 18, 2025
3d7e844
Add 'autoCloseAllRooTabs' setting to enhance tab management functiona…
seedlord May 19, 2025
f6b9efb
Refine diff editor behavior for new files and improve focus handling
seedlord May 19, 2025
86a721e
Refactor diff editor settings handling to dynamically read configurat…
seedlord May 19, 2025
2047067
Merge branch 'RooVetGit:main' into editorfocuspr/felixAnhalt/2955
seedlord May 20, 2025
c3e4794
Merge remote-tracking branch 'origin/main' into feature/2122-editor-f…
felixAnhalt May 20, 2025
ef84af7
refactor(diff): simplify scrolling behavior by removing autoFocus checks
seedlord May 20, 2025
31a0556
Merge branch 'main' of https://github.com/RooVetGit/Roo-Code into edi…
seedlord May 20, 2025
0e4e21a
Merge branch 'feature/2122-editor-focus' of https://github.com/felixa…
seedlord May 20, 2025
0fc0234
Merge branch 'main' into feature/2122-editor-focus
felixAnhalt May 21, 2025
542c7fb
Merge remote-tracking branch 'seedlord/editorfocuspr/felixAnhalt/2955…
felixAnhalt May 21, 2025
45249e1
refactor(diff): enhance tab closing logic and settings management in …
felixAnhalt May 21, 2025
e239ed0
feat(settings): add 'autoCloseAll' option to enhance tab management
felixAnhalt May 21, 2025
829cfe3
Merge remote-tracking branch 'origin/main' into feature/2122-editor-f…
felixAnhalt May 23, 2025
ff13aa2
feat(lockfile): add lockfile etc
felixAnhalt May 25, 2025
e189a0f
Merge remote-tracking branch 'origin/main' into feature/2122-editor-f…
felixAnhalt May 25, 2025
a834171
feat(diff): enhance focus behavior and tab management after diff oper…
felixAnhalt May 25, 2025
bf81452
feat(diff): implement focus behavior for the last tab in active group…
felixAnhalt May 25, 2025
e290d49
Merge remote-tracking branch 'origin/main' into feature/2122-editor-f…
felixAnhalt May 27, 2025
8c48cb8
feat(settings): add new options for diff view auto focus and tab mana…
felixAnhalt May 27, 2025
43dc92f
feat(settings): add options for diff view auto focus and tab management
felixAnhalt May 27, 2025
883f3e9
feat(settings): add options for diff view auto focus and tab management
felixAnhalt May 27, 2025
e5a75ee
Merge remote-tracking branch 'origin/main' into feature/2122-editor-f…
felixAnhalt May 31, 2025
e8b93c3
feat(writeToFileTool): update diff view provider to use view column a…
felixAnhalt May 31, 2025
b7a3220
Merge remote-tracking branch 'origin/main' into feature/2122-editor-f…
felixAnhalt Jun 7, 2025
2f9b748
Apply suggestions from code review
felixAnhalt Jun 7, 2025
0406afa
fix(ClineProvider): use tabPanelId to ref tab panels
felixAnhalt Jun 7, 2025
cdab9aa
refactor(SettingsView, ExtensionStateContext): streamline state updat…
felixAnhalt Jun 7, 2025
1a32c82
chore(cleanup): rem random linter changes etc
felixAnhalt Jun 7, 2025
5f05cce
feat(UserInteractionProvider): implement user interaction handling fo…
felixAnhalt Jun 7, 2025
0e03f5f
feat(PostDiffViewBehaviorUtils): add utility for managing post-diff b…
felixAnhalt Jun 7, 2025
f9b254f
Merge remote-tracking branch 'origin/main' into feature/2122-editor-f…
felixAnhalt Jun 9, 2025
8069fe9
chore(linting): rem out of scope linting
felixAnhalt Jun 9, 2025
08749da
chore(linting): rem out of scope linting
felixAnhalt Jun 9, 2025
f8455e3
chore(linting): rem out of scope linting
felixAnhalt Jun 9, 2025
6aa788a
Merge remote-tracking branch 'origin/main' into feature/2122-editor-f…
felixAnhalt Jun 9, 2025
af3b00d
chore(linting): rem out of scope linting
felixAnhalt Jun 9, 2025
f797f9d
Merge remote-tracking branch 'origin/main' into feature/2122-editor-f…
felixAnhalt Jun 10, 2025
0f7cad1
Merge remote-tracking branch 'origin/main' into feature/2122-editor-f…
felixAnhalt Jun 28, 2025
fae5f31
refactor(tests): update test mocks and improve diff view handling
felixAnhalt Jun 28, 2025
8c33c81
chore(linting): rem linter again
felixAnhalt Jun 28, 2025
ba19395
chore(linting): rem linter again
felixAnhalt Jun 28, 2025
7ecb74e
feat(file-editing): add file-based editing options and settings (#2)
felixAnhalt Jun 30, 2025
fd82dc5
Merge remote-tracking branch 'refs/remotes/origin/main' into feature/…
felixAnhalt Jun 30, 2025
9c94994
chore(mcphub): rem old jest test
felixAnhalt Jun 30, 2025
1379392
Merge remote-tracking branch 'refs/remotes/origin/main' into feature/…
felixAnhalt Jul 5, 2025
0569d7f
feat(settings): clean settings logic and use meaningful icons
felixAnhalt Jul 5, 2025
73f7239
feat(editor): update diff view auto focus settings and related options
felixAnhalt Jul 5, 2025
8481380
feat(editor): rename diffViewProvider to editingProvider for consistency
felixAnhalt Jul 5, 2025
2bac5e1
chore(linting): rem useless linter
felixAnhalt Jul 5, 2025
df54ea2
chore(linting): rem useless linter
felixAnhalt Jul 5, 2025
b4f213e
feat(editor): rename diffViewProvider to editingProvider in tests and…
felixAnhalt Jul 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/large-snakes-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"roo-cline": patch
---

Added an editable setting to allow users to preserve focus on the tab they are in while roo code is opening new tabs to do what it has to do.
3 changes: 3 additions & 0 deletions evals/packages/types/src/roo-code-defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export const rooCodeDefaults: RooCodeSettings = {
terminalShellIntegrationDisabled: false,

diffEnabled: true,
diffViewAutoFocus: false,
autoCloseRooTabs: true,
autoCloseAllRooTabs: true,
fuzzyMatchThreshold: 1,

enableCheckpoints: false,
Expand Down
14 changes: 13 additions & 1 deletion evals/packages/types/src/roo-code.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { z } from "zod"
import { undefined, z } from "zod"

import { Equals, Keys, AssertEqual } from "./utils.js"

Expand Down Expand Up @@ -335,6 +335,9 @@ export type ProviderSettingsEntry = z.infer<typeof providerSettingsEntrySchema>
const genericProviderSettingsSchema = z.object({
includeMaxTokens: z.boolean().optional(),
diffEnabled: z.boolean().optional(),
diffViewAutoFocus: z.boolean().optional(),
autoCloseRooTabs: z.boolean().optional(),
autoCloseAllRooTabs: z.boolean().optional(),
fuzzyMatchThreshold: z.number().optional(),
modelTemperature: z.number().nullish(),
rateLimitSeconds: z.number().optional(),
Expand Down Expand Up @@ -700,6 +703,9 @@ const providerSettingsRecord: ProviderSettingsRecord = {
includeMaxTokens: undefined,
reasoningEffort: undefined,
diffEnabled: undefined,
diffViewAutoFocus: undefined,
autoCloseRooTabs: undefined,
autoCloseAllRooTabs: undefined,
fuzzyMatchThreshold: undefined,
modelTemperature: undefined,
rateLimitSeconds: undefined,
Expand Down Expand Up @@ -779,6 +785,9 @@ export const globalSettingsSchema = z.object({

rateLimitSeconds: z.number().optional(),
diffEnabled: z.boolean().optional(),
diffViewAutoFocus: z.boolean().optional(),
autoCloseRooTabs: z.boolean().optional(),
autoCloseAllRooTabs: z.boolean().optional(),
fuzzyMatchThreshold: z.number().optional(),
experiments: experimentsSchema.optional(),

Expand Down Expand Up @@ -857,6 +866,9 @@ const globalSettingsRecord: GlobalSettingsRecord = {

rateLimitSeconds: undefined,
diffEnabled: undefined,
diffViewAutoFocus: undefined,
autoCloseRooTabs: undefined,
autoCloseAllRooTabs: undefined,
fuzzyMatchThreshold: undefined,
experiments: undefined,

Expand Down
62 changes: 32 additions & 30 deletions locales/ca/README.md

Large diffs are not rendered by default.

62 changes: 32 additions & 30 deletions locales/de/README.md

Large diffs are not rendered by default.

62 changes: 32 additions & 30 deletions locales/es/README.md

Large diffs are not rendered by default.

62 changes: 32 additions & 30 deletions locales/fr/README.md

Large diffs are not rendered by default.

62 changes: 32 additions & 30 deletions locales/hi/README.md

Large diffs are not rendered by default.

62 changes: 32 additions & 30 deletions locales/it/README.md

Large diffs are not rendered by default.

62 changes: 32 additions & 30 deletions locales/ja/README.md

Large diffs are not rendered by default.

62 changes: 32 additions & 30 deletions locales/ko/README.md

Large diffs are not rendered by default.

62 changes: 32 additions & 30 deletions locales/nl/README.md

Large diffs are not rendered by default.

62 changes: 32 additions & 30 deletions locales/pl/README.md

Large diffs are not rendered by default.

62 changes: 32 additions & 30 deletions locales/pt-BR/README.md

Large diffs are not rendered by default.

62 changes: 32 additions & 30 deletions locales/ru/README.md

Large diffs are not rendered by default.

62 changes: 32 additions & 30 deletions locales/tr/README.md

Large diffs are not rendered by default.

62 changes: 32 additions & 30 deletions locales/vi/README.md

Large diffs are not rendered by default.

62 changes: 32 additions & 30 deletions locales/zh-CN/README.md

Large diffs are not rendered by default.

62 changes: 32 additions & 30 deletions locales/zh-TW/README.md

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion packages/types/src/global-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const globalSettingsSchema = z.object({
allowedMaxRequests: z.number().nullish(),
autoCondenseContext: z.boolean().optional(),
autoCondenseContextPercent: z.number().optional(),
maxConcurrentFileReads: z.number().optional(),
maxConcurrentFileReads: z.number().optional(),

browserToolEnabled: z.boolean().optional(),
browserViewportSize: z.string().optional(),
Expand Down Expand Up @@ -82,6 +82,9 @@ export const globalSettingsSchema = z.object({

rateLimitSeconds: z.number().optional(),
diffEnabled: z.boolean().optional(),
diffViewAutoFocus: z.boolean().optional(),
autoCloseRooTabs: z.boolean().optional(),
autoCloseAllRooTabs: z.boolean().optional(),
fuzzyMatchThreshold: z.number().optional(),
experiments: experimentsSchema.optional(),

Expand Down Expand Up @@ -168,6 +171,9 @@ export const GLOBAL_SETTINGS_KEYS = keysOf<GlobalSettings>()([

"rateLimitSeconds",
"diffEnabled",
"diffViewAutoFocus",
"autoCloseRooTabs",
"autoCloseAllRooTabs",
"fuzzyMatchThreshold",
"experiments",

Expand Down
6 changes: 6 additions & 0 deletions packages/types/src/provider-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export type ProviderSettingsEntry = z.infer<typeof providerSettingsEntrySchema>
const baseProviderSettingsSchema = z.object({
includeMaxTokens: z.boolean().optional(),
diffEnabled: z.boolean().optional(),
diffViewAutoFocus: z.boolean().optional(),
autoCloseRooTabs: z.boolean().optional(),
autoCloseAllRooTabs: z.boolean().optional(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed these settings are were defined on the provider settings which are focused on AI provider integration.

Would these settings be tied to specific profiles? If these settings are global (for every profile) we probably want to move them out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felixAnhalt the following instructions got lost not too long ago, we are working on getting the merged back in:
#4130

instruct the model to use those instructions to create check box settings where they belong.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These settings are (or should be) global.
I initially added them here, because the setting for allowing editing through diffs are located here as well.

I'd be open to moving them into another settings tab, if you see one more fitting @daniel-lxs.

These docs are super helpful for collaborators, hope it'll get merged soon @KJ7LNW

fuzzyMatchThreshold: z.number().optional(),
modelTemperature: z.number().nullish(),
rateLimitSeconds: z.number().optional(),
Expand Down Expand Up @@ -342,6 +345,9 @@ export const PROVIDER_SETTINGS_KEYS = keysOf<ProviderSettings>()([
// Generic
"includeMaxTokens",
"diffEnabled",
"diffViewAutoFocus",
"autoCloseRooTabs",
"autoCloseAllRooTabs",
"fuzzyMatchThreshold",
"modelTemperature",
"rateLimitSeconds",
Expand Down
3 changes: 3 additions & 0 deletions src/core/task/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,9 @@ export class Task extends EventEmitter<ClineEvents> {
private async initiateTaskLoop(userContent: Anthropic.Messages.ContentBlockParam[]): Promise<void> {
// Kicks off the checkpoints initialization process in the background.
getCheckpointService(this)
// Lets track if the user is interacting with the editor after we start our task loop.
this.diffViewProvider.initialize()
this.diffViewProvider.disableAutoFocusAfterUserInteraction()

let nextUserContent = userContent
let includeFileDetails = true
Expand Down
106 changes: 57 additions & 49 deletions src/core/tools/__tests__/readFileTool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ jest.mock("../../../services/tree-sitter")

// Then create the mock functions
const addLineNumbersMock = jest.fn().mockImplementation((text, startLine = 1) => {
if (!text) return ""
const lines = typeof text === "string" ? text.split("\n") : [text]
return lines.map((line, i) => `${startLine + i} | ${line}`).join("\n")
if (!text) return ""
const lines = typeof text === "string" ? text.split("\n") : [text]
return lines.map((line, i) => `${startLine + i} | ${line}`).join("\n")
})

const extractTextFromFileMock = jest.fn().mockImplementation((_filePath) => {
// Call addLineNumbersMock to register the call
addLineNumbersMock(mockInputContent)
return Promise.resolve(addLineNumbersMock(mockInputContent))
// Call addLineNumbersMock to register the call
addLineNumbersMock(mockInputContent)
return Promise.resolve(addLineNumbersMock(mockInputContent))
})

// Now assign the mocks to the module
Expand Down Expand Up @@ -104,7 +104,7 @@ describe("read_file tool with maxReadFileLine setting", () => {
// Setup the extractTextFromFile mock implementation with the current mockInputContent
// Reset the spy before each test
addLineNumbersMock.mockClear()

// Setup the extractTextFromFile mock to call our spy
mockedExtractTextFromFile.mockImplementation((_filePath) => {
// Call the spy and return its result
Expand Down Expand Up @@ -170,7 +170,6 @@ describe("read_file tool with maxReadFileLine setting", () => {
}
argsContent += `</file>`


// Create a tool use object
const toolUse: ReadFileToolUse = {
type: "tool_use",
Expand All @@ -190,7 +189,6 @@ describe("read_file tool with maxReadFileLine setting", () => {
(_: ToolParamName, content?: string) => content ?? "",
)


return toolResult
}

Expand All @@ -208,7 +206,6 @@ describe("read_file tool with maxReadFileLine setting", () => {
// Don't check exact content or exact function calls
})


it("should not show line snippet in approval message when maxReadFileLine is -1", async () => {
// This test verifies the line snippet behavior for the approval message
// Setup - use default mockInputContent
Expand Down Expand Up @@ -341,7 +338,7 @@ describe("read_file tool with maxReadFileLine setting", () => {

// Make sure mockCline.ask returns approval
mockCline.ask = jest.fn().mockResolvedValue({ response: "yesButtonClicked" })

// Execute - skip addLineNumbers check
const result = await executeReadFileTool(
{},
Expand All @@ -367,10 +364,13 @@ describe("read_file tool with maxReadFileLine setting", () => {
mockedReadLines.mockResolvedValue("Line 2\nLine 3\nLine 4")

// Execute using executeReadFileTool with range parameters
const rangeResult = await executeReadFileTool({},{
start_line: "2",
end_line: "4",
})
const rangeResult = await executeReadFileTool(
{},
{
start_line: "2",
end_line: "4",
},
)

// Verify - just check that the result contains the expected elements
expect(rangeResult).toContain(`<file><path>${testFilePath}</path>`)
Expand Down Expand Up @@ -469,15 +469,12 @@ describe("read_file tool XML output structure", () => {
mockedIsBinaryFile.mockResolvedValue(isBinary)
mockCline.rooIgnoreController.validateAccess = jest.fn().mockReturnValue(validateAccess)



let argsContent = `<file><path>${options.path || testFilePath}</path>`
if (options.start_line && options.end_line) {
argsContent += `<line_range>${options.start_line}-${options.end_line}</line_range>`
}
argsContent += `</file>`


// Create a tool use object
const toolUse: ReadFileToolUse = {
type: "tool_use",
Expand All @@ -486,7 +483,6 @@ describe("read_file tool XML output structure", () => {
partial: false,
}


// Execute the tool
await readFileTool(
mockCline,
Expand All @@ -507,7 +503,7 @@ describe("read_file tool XML output structure", () => {
// Skip this test for now - it requires more complex mocking
// of the formatResponse module which is causing issues
expect(true).toBe(true)

mockedCountFileLines.mockResolvedValue(1)

// Execute
Expand All @@ -520,15 +516,15 @@ describe("read_file tool XML output structure", () => {
// Skip this test for now - it requires more complex mocking
// of the formatResponse module which is causing issues
expect(true).toBe(true)

// Mock the file content
mockInputContent = "Test content"

// Mock the extractTextFromFile to return numbered content
mockedExtractTextFromFile.mockImplementation(() => {
return Promise.resolve("1 | Test content")
})

mockedCountFileLines.mockResolvedValue(1)

// Execute
Expand Down Expand Up @@ -605,30 +601,33 @@ describe("read_file tool XML output structure", () => {
// Setup
const startLine = 2
const endLine = 5

// For line range tests, we need to mock both readLines and addLineNumbers
const content = "Line 2\nLine 3\nLine 4\nLine 5"
const numberedContent = "2 | Line 2\n3 | Line 3\n4 | Line 4\n5 | Line 5"

// Mock readLines to return the content
mockedReadLines.mockResolvedValue(content)

// Mock addLineNumbers to return the numbered content
addLineNumbersMock.mockImplementation((_text?: any, start?: any) => {
if (start === 2) {
return numberedContent
}
return _text || ""
})

mockedCountFileLines.mockResolvedValue(endLine)
mockProvider.getState.mockResolvedValue({ maxReadFileLine: endLine })

// Execute with line range parameters
const result = await executeReadFileTool({}, {
start_line: startLine.toString(),
end_line: endLine.toString()
})
const result = await executeReadFileTool(
{},
{
start_line: startLine.toString(),
end_line: endLine.toString(),
},
)

// Verify
expect(result).toBe(
Expand All @@ -641,27 +640,30 @@ describe("read_file tool XML output structure", () => {
const endLine = 3
const content = "Line 1\nLine 2\nLine 3"
const numberedContent = "1 | Line 1\n2 | Line 2\n3 | Line 3"

// Mock readLines to return the content
mockedReadLines.mockResolvedValue(content)

// Mock addLineNumbers to return the numbered content
addLineNumbersMock.mockImplementation((_text?: any, start?: any) => {
if (start === 1) {
return numberedContent
}
return _text || ""
})

mockedCountFileLines.mockResolvedValue(endLine)
mockProvider.getState.mockResolvedValue({ maxReadFileLine: 500 })

// Execute with line range parameters
const result = await executeReadFileTool({}, {
start_line: "1",
end_line: endLine.toString(),
totalLines: endLine
})
const result = await executeReadFileTool(
{},
{
start_line: "1",
end_line: endLine.toString(),
totalLines: endLine,
},
)

// Verify
expect(result).toBe(
Expand Down Expand Up @@ -727,27 +729,30 @@ describe("read_file tool XML output structure", () => {
const startLine = 3
const content = "Line 3\nLine 4\nLine 5"
const numberedContent = "3 | Line 3\n4 | Line 4\n5 | Line 5"

// Mock readLines to return the content
mockedReadLines.mockResolvedValue(content)

// Mock addLineNumbers to return the numbered content
addLineNumbersMock.mockImplementation((_text?: any, start?: any) => {
if (start === 3) {
return numberedContent
}
return _text || ""
})

mockedCountFileLines.mockResolvedValue(totalLines)
mockProvider.getState.mockResolvedValue({ maxReadFileLine: totalLines })

// Execute with line range parameters
const result = await executeReadFileTool({}, {
start_line: startLine.toString(),
end_line: totalLines.toString(),
totalLines
})
const result = await executeReadFileTool(
{},
{
start_line: startLine.toString(),
end_line: totalLines.toString(),
totalLines,
},
)

// Should adjust to actual file length
expect(result).toBe(
Expand Down Expand Up @@ -780,11 +785,14 @@ describe("read_file tool XML output structure", () => {
mockedReadLines.mockResolvedValue(rangeContent)

// Execute
const result = await executeReadFileTool({},
const result = await executeReadFileTool(
{},
{
start_line: startLine.toString(),
end_line: endLine.toString(),
maxReadFileLine, totalLines },
maxReadFileLine,
totalLines,
},
)

// Verify
Expand Down
Loading