Skip to content

Conversation

@mrubens
Copy link
Collaborator

@mrubens mrubens commented Mar 30, 2025

Important

Refactor write_to_file logic from Cline.ts to writeToFileTool.ts, maintaining existing functionality and improving code organization.

  • Refactoring:
    • Extract write_to_file logic from Cline.ts to writeToFileTool.ts.
    • Replace inline write_to_file logic in Cline.ts with a call to writeToFileTool().
  • Functionality:
    • writeToFileTool.ts handles file writing, including path validation, content processing, and user approval.
    • Maintains existing behavior for handling partial content, file existence checks, and error handling.

This description was created by Ellipsis for 8eb0e94. It will automatically update as commits are pushed.

@changeset-bot
Copy link

changeset-bot bot commented Mar 30, 2025

⚠️ No Changeset found

Latest commit: 8eb0e94

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 30, 2025
@mrubens mrubens force-pushed the write_to_file_tool branch from 83092c3 to 8eb0e94 Compare March 30, 2025 04:48
@mrubens mrubens merged commit 26c3fe6 into main Mar 30, 2025
7 checks passed
@mrubens mrubens deleted the write_to_file_tool branch March 30, 2025 04:49
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Mar 30, 2025
) {
const relPath: string | undefined = block.params.path
let newContent: string | undefined = block.params.content
let predictedLineCount: number | undefined = parseInt(block.params.line_count ?? "0")
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider validating the result of parseInt for predictedLineCount. If block.params.line_count is not a numeric string, parseInt returns NaN, which is falsy. Use an explicit isNaN check and provide a descriptive error when the value is invalid.

Suggested change
let predictedLineCount: number | undefined = parseInt(block.params.line_count ?? "0")
let predictedLineCount: number | undefined = isNaN(parseInt(block.params.line_count ?? "0")) ? undefined : parseInt(block.params.line_count ?? "0")

)
pushToolResult(
`The user made the following updates to your content:\n\n${userEdits}\n\n` +
`The updated content, which includes both your original modifications and the user's edits, has been successfully saved to ${relPath.toPosix()}. Here is the full, updated content of the file, including line numbers:\n\n` +
Copy link
Contributor

Choose a reason for hiding this comment

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

The template literal calls relPath.toPosix(), yet relPath originates as a string. Ensure that relPath is a proper path object (or convert it consistently using getReadablePath) so that the toPosix() method is available at runtime.

Smartsheet-JB-Brown added a commit to Smartsheet-JB-Brown/Roo-Code that referenced this pull request Mar 30, 2025
* main: (29 commits)
  Link to provider docs from the API options (RooCodeInc#2112)
  Link to the settings page from the auto approve toolbar (RooCodeInc#2111)
  Remove the ask promise error (RooCodeInc#2107)
  i18n Add translations for task pinning and unpinning (RooCodeInc#2109)
  Clean up the way we compute the current diff strategy (RooCodeInc#2049)
  Do a little code cleanup now that tools are refactored out (RooCodeInc#2103)
  Move new_task, switch_mode, attempt_completion, and ask_followup_question to tool files (RooCodeInc#2102)
  Move use_mcp_tool and access_mcp_resource to tool files (RooCodeInc#2101)
  Move execute_command to a tool file (RooCodeInc#2100)
  Move browser_action to a tool file (RooCodeInc#2099)
  Move search_files to a tool file (RooCodeInc#2098)
  Move list_code_definition_names to a tool file (RooCodeInc#2097)
  Move search_and_replace to a tool file (RooCodeInc#2096)
  Move insert_content to a tool file (RooCodeInc#2095)
  Move apply_diff to a tool file (RooCodeInc#2094)
  Move write_to_file to a tool file (RooCodeInc#2093)
  Fix a type in the listFiles tool (RooCodeInc#2092)
  Remove switch from tools (RooCodeInc#2091)
  Refactor/cline.ts/list files (RooCodeInc#2067)
  Update contributors list (RooCodeInc#2089)
  ...
cte pushed a commit that referenced this pull request Mar 30, 2025
cte added a commit that referenced this pull request Mar 30, 2025
* Parallel tasks

* Handle null [x]ModelInfo types, recover from settings schema parse errors (#2064)

* Require exactly node v20.18.1 (#2065)

* Get rid of runner and all CJS stuff

* Add an activation command for other extensions (#2073)

Since VS Code provides no actionEvents that trigger when a specific
extension activates, extensions can't activate only once Roo is
activated and ready.

This commit introduces a new roo-cline.activationCompleted command
and fires it at the very end of extension activation. Other
extensions that use Roo's exported APIs can now activate when they
see this event.

Co-authored-by: Greg Taylor <[email protected]>

* Update bug_report.yml (#1994)

* Update bug_report.yml

* Update bug_report.yml

---------

Co-authored-by: Matt Rubens <[email protected]>

* Fix mention file name is not fully displayed (#2026)

Fixed path leading character handling to preserve language characters and remove specific punctuation marks

* In-Editor Browser Improvements (#1601)

* Browser Automation Improvements
* Added multi-tab remote Chrome support
* Added support for hover
* Properly caching remote browser host in global state
* Cleanup functions

* Updated for changes after merge

* Added www. exception for common tabs

* Update src/core/webview/ClineProvider.ts

* Revert README changes

---------

Co-authored-by: Matt Rubens <[email protected]>

* Add missing awaits on refactored tools (#2078)

* More progress

* Added Gemini 2.5 Pro model to GCP Vertex AI Provider (#2079)

* More progress

* Display info about partial reads in chat row (#2080)

* More progress

* Update contributors list (#2023)

docs: update contributors list [skip ci]

Co-authored-by: mrubens <[email protected]>

* More progress

* Handle multiple API pages worth of contributors (#2088)

* Update contributors list (#2089)

docs: update contributors list [skip ci]

Co-authored-by: mrubens <[email protected]>

* Refactor/cline.ts/list files (#2067)

* "Refactor list_files tool to separate module (#2057)"

* Await

---------

Co-authored-by: Matt Rubens <[email protected]>

* Remove switch from tools (#2091)

* HandleError returns a promise

* Remove unnecessary switch from tools

* Fix a type in the listFiles tool (#2092)

* Move write_to_file to a tool file (#2093)

* Move apply_diff to a tool file (#2094)

* Move insert_content to a tool file (#2095)

* Move search_and_replace to a tool file (#2096)

* Move list_code_definition_names to a tool file (#2097)

* Move search_files to a tool file (#2098)

* Move browser_action to a tool file (#2099)

* Move execute_command to a tool file (#2100)

* Move use_mcp_tool and access_mcp_resource to tool files (#2101)

* Move new_task, switch_mode, attempt_completion, and ask_followup_question to tool files (#2102)

* Do a little code cleanup now that tools are refactored out (#2103)

* Clean up the way we compute the current diff strategy (#2049)

* Clean up the way we compute the current diff strategy

* Add changeset

* i18n Add translations for task pinning and unpinning (#2109)

Signed-off-by: feifei <[email protected]>

* Remove the ask promise error (#2107)

* Remove the ask promise error

* Send start_time along with checkpoints and use it to position in the messages

* Link to the settings page from the auto approve toolbar (#2111)

* Link to provider docs from the API options (#2112)

* Revert "Remove the ask promise error" (#2117)

Revert "Remove the ask promise error (#2107)"

This reverts commit 712ca71.

* Parse the retry out of the gemini 429 response (#2118)

* Fix Gemini command escaping (#2120)

* Fix switching profiles to ensure only the selected profile is switche… (#2119)

Fix switching profiles to ensure only the selected profile is switched for all modes, and optimize certain i18n keys.

Signed-off-by: feifei <[email protected]>

* Tweaks to support prompt line number format (#2121)

* Remove the ask promise error (#2123)

* Stronger typing

* Added Gemini 2.5 Pro model to GCP Vertex AI Provider (#2079)

* Display info about partial reads in chat row (#2080)

* Update contributors list (#2023)

docs: update contributors list [skip ci]

Co-authored-by: mrubens <[email protected]>

* Handle multiple API pages worth of contributors (#2088)

* Update contributors list (#2089)

docs: update contributors list [skip ci]

Co-authored-by: mrubens <[email protected]>

* Refactor/cline.ts/list files (#2067)

* "Refactor list_files tool to separate module (#2057)"

* Await

---------

Co-authored-by: Matt Rubens <[email protected]>

* Remove switch from tools (#2091)

* HandleError returns a promise

* Remove unnecessary switch from tools

* Fix a type in the listFiles tool (#2092)

* Move write_to_file to a tool file (#2093)

* Move apply_diff to a tool file (#2094)

* Move insert_content to a tool file (#2095)

* Move search_and_replace to a tool file (#2096)

* Move list_code_definition_names to a tool file (#2097)

* Move search_files to a tool file (#2098)

* Move browser_action to a tool file (#2099)

* Move execute_command to a tool file (#2100)

* Move use_mcp_tool and access_mcp_resource to tool files (#2101)

* Move new_task, switch_mode, attempt_completion, and ask_followup_question to tool files (#2102)

* Do a little code cleanup now that tools are refactored out (#2103)

* Clean up the way we compute the current diff strategy (#2049)

* Clean up the way we compute the current diff strategy

* Add changeset

* i18n Add translations for task pinning and unpinning (#2109)

Signed-off-by: feifei <[email protected]>

* Remove the ask promise error (#2107)

* Remove the ask promise error

* Send start_time along with checkpoints and use it to position in the messages

* Link to the settings page from the auto approve toolbar (#2111)

* Link to provider docs from the API options (#2112)

* Revert "Remove the ask promise error" (#2117)

Revert "Remove the ask promise error (#2107)"

This reverts commit 712ca71.

* Parse the retry out of the gemini 429 response (#2118)

* Fix Gemini command escaping (#2120)

* Fix switching profiles to ensure only the selected profile is switche… (#2119)

Fix switching profiles to ensure only the selected profile is switched for all modes, and optimize certain i18n keys.

Signed-off-by: feifei <[email protected]>

* Tweaks to support prompt line number format (#2121)

* Remove the ask promise error (#2123)

* Pass along pid and ppid

* Revert "Remove the ask promise error" (#2126)

Revert "Remove the ask promise error (#2123)"

This reverts commit b788aa1.

---------

Signed-off-by: feifei <[email protected]>
Co-authored-by: Greg Taylor <[email protected]>
Co-authored-by: Greg Taylor <[email protected]>
Co-authored-by: Hannes Rudolph <[email protected]>
Co-authored-by: Matt Rubens <[email protected]>
Co-authored-by: aheizi <[email protected]>
Co-authored-by: Afshawn Lotfi <[email protected]>
Co-authored-by: Nico Bihan <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bhavesh Ramburn <[email protected]>
Co-authored-by: feifei <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants