* fix(editor): prevent file editing issues when git diff views are open
Add scheme checks to ensure only file:// URIs are matched when finding editors,
avoiding issues with git diffs and other schemes. Includes error logging for
failed editor lookups.
* Remove the warnings
* fix(editor): enforce file:// scheme in editor lookups to prevent git diff issues
---------
Co-authored-by: daniel-lxs <ricciodaniel98@gmail.com>
* feat: optimize memory usage for image handling in webview
- Replace base64 image data with webview URIs to reduce memory footprint
- Add proper resource roots to webview for workspace file access
- Implement convertToWebviewUri method for safe file-to-URI conversion
- Update ImageViewer to handle both webview URIs and file paths separately
- Add image message type for proper image rendering in chat
- Improve error handling and display for failed image loads
- Add comprehensive tests for ImageViewer component
- Format display paths as relative for better readability
This change significantly reduces memory usage by avoiding base64 encoding
of images and instead using VSCode's webview URI system for direct file
access. Images are now loaded on-demand from disk rather than being held
in memory as base64 strings.
* fix: address PR review comments
- Use safeJsonParse instead of JSON.parse in ChatRow.tsx
- Add type definition for parsed image info
- Add more specific error types in ClineProvider.ts
- Add comprehensive JSDoc comments to ImageBlock.tsx
- Improve error handling and type safety
* fix: address MrUbens' review comments
- Remove hardcoded 'rc1' pattern in formatDisplayPath, use generic workspace detection
- Internationalize 'No image data' text using i18n system
* chore: remove useless comment
* chore(i18n): add image.noData to all locales to fix translation check
* test: update ImageViewer.spec to align with i18n key and flexible path formatting
* fix: add character limit to prevent terminal output context explosion
- Enhanced truncateOutput function to accept character limits alongside line limits
- Character limits take priority over line limits to prevent context window explosion
- Added terminalOutputCharacterLimit setting (default: 100,000 characters)
- Updated all terminal output processing to use both limits
- Added comprehensive tests for character limit functionality
Fixes#5775
* feat: add terminal output character limit setting to UI
- Add character limit slider to Terminal Settings UI (default: 50,000)
- Update ExtensionStateContext to manage character limit state
- Add validation for positive character limit values
- Add English translation and translations for all 17 supported languages
- Connect UI to backend through proper message handling
- Character limit takes precedence over line limit to prevent memory issues
* fix: update test expectations for character limit edge cases
- Fix multi-byte character test to account for JavaScript's string length behavior
- Fix newline content test to match actual slice behavior
- Tests now correctly validate the truncateOutput function's character limit handling
---------
Co-authored-by: Roo Code <roomote@roocode.com>
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
* feat: add configurable delay for Go diagnostics to prevent premature error reporting
- Add diagnosticsDelayMs setting (default: 2000ms) to allow linters time to process
- Add diagnosticsEnabled setting to optionally disable diagnostic checking entirely
- Update DiffViewProvider.saveChanges() to use configurable delay before checking diagnostics
- Update all tool files (writeToFile, searchAndReplace, insertContent, applyDiff, multiApplyDiff) to pass diagnostic settings
- Add comprehensive tests for new diagnostic functionality
- Fixes issue where Go diagnostics errors were submitted to LLM before linter could clean up unused imports
Resolves#5859
* fix: add missing TypeScript type definitions for diagnostic settings
- Add diagnosticsDelayMs and diagnosticsEnabled to globalSettingsSchema
- Include properties in ExtensionState Pick type
- Add default values to EVALS_SETTINGS
- Fix VSCode mock to include DiagnosticSeverity for tests
- Resolves compilation errors in ClineProvider and webviewMessageHandler
* fix: update test mocks to support diagnostic settings in tool tests
- Add providerRef mock to insertContentTool and writeToFileTool tests
- Update mocks to include diagnosticsEnabled and diagnosticsDelayMs settings
- Fix test expectations to match new implementation with diagnostic configuration
- Resolves failing unit tests for insertContentTool.spec.ts and writeToFileTool.spec.ts
* fix: remove package-lock.json file (project uses pnpm)
* refactor: use existing writeDelayMs instead of diagnosticsDelayMs
- Remove diagnosticsDelayMs setting in favor of existing writeDelayMs
- Add min(0) validation for writeDelayMs in global settings schema
- Add error handling around delay function calls in DiffViewProvider
- Create DEFAULT_WRITE_DELAY_MS constant (1000ms) to replace repeated defaults
- Update all tool files to pass writeDelayMs instead of diagnosticsDelayMs
- Remove diagnosticsDelayMs from webview message handlers and types
- Update test files to use writeDelayMs instead of diagnosticsDelayMs
This refactoring consolidates diagnostic delay functionality to use the
existing writeDelayMs setting as requested in PR feedback.
* fix: resolve failing unit tests and TypeScript compilation errors
- Fix DiffViewProvider test to expect correct default delay (1000ms instead of 2000ms)
- Fix TypeScript type errors in ClineProvider test mock state object
- Correct terminalPowershellCounter and terminalZdotdir types to boolean
- Fix pinnedApiConfigs type from array to Record<string, boolean>
* fix: remove unrelated changes from ClineProvider.spec.ts
- Removed extensive unrelated property additions to mock state
- Kept only diagnosticsEnabled property which is related to Go diagnostics delay feature
- Removed unused DEFAULT_WRITE_DELAY_MS import
- Restored original structure and organization of mock state object
This addresses the feedback to remove unrelated changes while preserving
the necessary diagnostic functionality for the Go diagnostics delay feature.
* refactor: move DEFAULT_WRITE_DELAY_MS to packages/types/src/global-settings.ts
- Move DEFAULT_WRITE_DELAY_MS constant from src/shared/constants.ts to packages/types/src/global-settings.ts
- Update all import statements in affected files to use @roo-code/types
- Delete src/shared/constants.ts file as it is no longer needed
- Files updated:
- src/integrations/editor/DiffViewProvider.ts
- src/core/webview/ClineProvider.ts
- src/core/tools/multiApplyDiffTool.ts
- src/core/tools/applyDiffTool.ts
- src/core/tools/searchAndReplaceTool.ts
- src/core/tools/insertContentTool.ts
- src/core/tools/writeToFileTool.ts
---------
Co-authored-by: Roo Code <roomote@roocode.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Daniel <57051444+daniel-lxs@users.noreply.github.com>
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
* fix: use decodeURIComponent in openFile
* feat: add error handling for decodeURIComponent and tests
- Added try-catch block around decodeURIComponent to handle invalid escape sequences
- Falls back to original path if decoding fails
- Added comprehensive unit tests for the openFile function
- Tests cover invalid URI encoding, valid encoding, and various edge cases
* fix: update test to handle dynamic workspace paths in CI
* fix: handle Windows path separators in open-file tests
---------
Co-authored-by: Vivek Soni <vivex@Viveks-MacBook-Air-2.local>
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
* fix: prevent chatbox focus loss during automated file editing (#4574)
- Add preserveFocus: true to DiffViewProvider openDiffEditor method
- Implement comprehensive focus preservation during cursor positioning and scrolling
- Make scrollToFirstDiff async with focus restoration capabilities
- Update all tool files to use async scrollToFirstDiff
- Add comprehensive unit and E2E tests for focus preservation
Fixes#4574
* refactor: extract focus restoration logic and improve consistency
- Created restoreEditorFocus() helper method to eliminate code duplication
- Changed preserveFocus from false to true for consistent behavior
- Added error handling with silent logging for focus restoration failures
- Added null checks for undefined activeTextEditor cases
* Delete apps/vscode-e2e/src/suite/tools/focus-preservation.test.ts
It doesn't seem to be testing anything
* refactor: remove focus restoration logic to simplify diff editor interactions
* refactor: remove unnecessary await from scrollToFirstDiff calls
---------
Co-authored-by: Daniel <57051444+daniel-lxs@users.noreply.github.com>
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
* fix: resolve E2BIG error by passing large prompts via stdin to Claude CLI
- Pass messages via stdin instead of command line arguments to avoid Linux argument length limits
- Add --input-format text flag to claude CLI command
- Update execa configuration to use stdin pipe
- Fix corresponding unit tests with proper async iterator mocking
- Resolves spawn E2BIG errors when using very large conversation histories
* fix: address race condition and improve error handling
- Use setImmediate to ensure process is spawned before writing to stdin
- Add proper error handling for stdin write operations
- Add tests for error scenarios
- Update existing tests to handle async behavior properly
* fix: remove --input-format text flag to prevent CLI parsing errors
The --input-format text flag was causing the Claude CLI to misinterpret
the JSON content passed via stdin, leading to errors like 'unknown option -------'
when the system prompt contained dashes. Removing this flag allows the CLI
to properly handle the JSON input via stdin.
---------
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
* Fix: Allow write_to_file to handle newline-only and empty content
* fix: update writeToFileTool to return early without error on missing or empty parameters
* fix: preserve newlines in content parameters and update error handling in writeToFileTool tests
* fix: update parseAssistantMessage and parseAssistantMessageV2 to preserve newlines in content parameters while stripping leading and trailing newlines
---------
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Daniel <57051444+daniel-lxs@users.noreply.github.com>
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
* fix: resolve diff editor issues with markdown preview associations (#4946)
- Pre-open files as text documents before executing diff command to avoid preview mode
- Update closeAllDiffViews to identify diff tabs by label pattern
- Add comprehensive tests for the new behavior
This ensures that files with custom editor associations (like markdown preview)
can be properly edited using Roo Code's diff editor tools.
* refactor: extract diff view label separator as shared constant
- Add DIFF_VIEW_LABEL_SEPARATOR constant to prevent breaking logic if string changes
- Update all usages in DiffViewProvider.ts and test file
- Addresses PR review feedback for better maintainability
* refactor: improve diff view label constant to include full text
- Rename DIFF_VIEW_LABEL_SEPARATOR to DIFF_VIEW_LABEL_CHANGES
- Include full 'Original ↔ Roo's Changes' text in constant for better maintainability
- Update all usages in DiffViewProvider.ts and test file
- Addresses feedback to make constant changes less awkward