Commit graph

123 commits

Author SHA1 Message Date
Eric Wheeler
304fcf2fbc fix: improve terminal execution with shell integration status
When shell integration is not available, the system now provides clear feedback
about command execution status and maintains consistent event flow.

- Removed waitForShellIntegration property to simplify code flow
- Consolidated event emission to ensure consistent behavior
- Updated tests to verify correct event sequence
- Simplified shell integration detection with pWaitFor
2025-03-10 20:55:05 -07:00
Eric Wheeler
0e41241faa fix: replace echo -e with printf in terminal tests
Replace echo -e with printf command in terminal tests for better portability.

- Replace echo -e with printf to ensure consistent behavior across different shell implementations
- Not all implementations of echo support the -e flag for interpreting backslash escapes
- Using printf provides a more reliable way to handle escape sequences

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
e24e5b24d4 refactor: move getTerminalContents to Terminal class
This commit partially addresses the issue of duplicate handler calls by
removing an unnecessary instantiation of TerminalManager in
registerTerminalActions.ts.

Move the getTerminalContents method from TerminalManager to Terminal
class as a static method and update all references to use the new
location.

Fixes: #1380

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
daf36f38ea refactor: move interpretExitCode from TerminalManager to TerminalProcess
This commit moves the interpretExitCode method from TerminalManager to
TerminalProcess class, as part of the terminal refactoring effort. The
method is responsible for translating exit codes into detailed results,
including signal information.

Changes include:
- Moved interpretExitCode method to TerminalProcess class
- Updated imports in TerminalManager and Cline to reference
  ExitCodeDetails from TerminalProcess
- Added findTerminalIdByVscodeTerminal helper method in TerminalManager
- Added comprehensive unit tests for interpretExitCode in
  TerminalProcess
- Tests cover undefined exit codes, normal exit codes (0-127), and
  signal exit codes (128+)

This change improves code organization by placing the exit code
interpretation logic closer to where it's primarily used, in the
TerminalProcess class.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
3a950bbc15 refactor: Rename TerminalInfo to Terminal and relocate to Terminal.ts
Transformed the TerminalInfo interface into a proper Terminal class and
moved it to its own file. This improves code organization and
encapsulation by centralizing terminal-related functionality.

The change establishes a clearer object model for terminal management,
setting the foundation for a more maintainable terminal architecture.
All references throughout the codebase have been updated to use the new
Terminal class while preserving existing functionality.

Tests have been updated and verified to ensure compatibility with the
new structure.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
60c14d8f5e test: add comprehensive terminal command execution testing
This commit combines three related improvements to terminal testing:

- Create a reusable function for testing terminal commands with real output
- Update tests to properly invoke terminal shell execution handlers
- Add microsecond timing to measure execution performance

Key improvements:
- Added testTerminalCommand function that takes command and expected output
- Use child_process.execSync to run real commands and feed output into mock terminal stream
- Properly trigger VSCode onDidStartTerminalShellExecution and onDidEndTerminalShellExecution events
- Add timeout mechanism to prevent hanging tests
- Measure execution time from terminal process creation to command completion
- Display both microseconds and milliseconds in test output
- Add test for base64 encoded zeros with configurable line count
- Increase buffer size for execSync to handle large outputs
- Limit output display to avoid cluttering the terminal

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
070a36baa2 Revert "Smart truncation for terminal output"
This reverts commit 7eee3e0878.

Middle-out truncation is a really great feature and it should still be
implemented, however it unnecessarily interferes with #1365 because it
hooked into the low-level chunk management that comes directly from VSCE
shell integration.

The best place to hook OutputBuilder is as follows depending on the
state of terminal interaction:

1. Foreground terminals:

Cline.ts:
	 executeCommandTool(...) {
	     process.on("line", (line) => {
		    lines.push(line)
		    ...
	    }
	 }

2. For background terminals: hook in at the point that getUnretrievedOutput is consumed for active or
   inactive terminals in Cline.ts:getEnvironmentDetails()

Please note:

The Terminal classes are very sensitive to change, partially because of
the complicated way that shell integration works with VSCE, and
partially because of the way that Cline interacts with the Terminal*
class abstractions that make VSCE shell integration easier to work with.

At the point that PR#1365 is merged, it is unlikely that any Terminal*
classes will need to be modified substantially.  Generally speaking, we
should think of this is a stable interface and minimize changes.

Reverts: #1390
2025-03-10 20:54:53 -07:00
Eric Wheeler
384b469bf1 Revert "Handle outputless commands"
This reverts commit 710284cc3d which has
been superseded by PR #1365.

Fixes: #1416
2025-03-10 20:50:10 -07:00
Eric Wheeler
7e0a4dd426 Revert "Try to prevent additional cases in which terminal commands lock the task UI"
This reverts commit eee7bbe104 which has
been superseded by PR #1365.

Fixes: #1435
2025-03-10 20:50:10 -07:00
Matt Rubens
e5ac33a146
Merge pull request #996 from qdaxb/optimize_diagnostics
Reduce the probability of errors when the model tries to fix the problems
2025-03-09 21:38:03 -04:00
Matt Rubens
585d5aba5a Strip all BOMs 2025-03-08 18:44:03 -05:00
Matt Rubens
4cf7754e65 Strip BOM when applying diffs 2025-03-08 17:50:49 -05:00
cte
eee7bbe104 Try to prevent additional cases in which terminal commands lock the task UI 2025-03-06 21:34:03 -08:00
cte
710284cc3d Handle outputless commands 2025-03-05 21:28:42 -08:00
cte
7eee3e0878 Smart truncation for terminal output 2025-03-05 19:36:52 -08:00
Chris Estreich
e49d886d63 Re-enable tests 2025-02-28 10:21:52 -08:00
Chris Estreich
4b66ce8255 Improve terminal command execution output parsing 2025-02-28 09:38:48 -08:00
Matt Rubens
dc83617b4d
Revert "Stop removing commas from terminal output" 2025-02-27 09:51:05 -05:00
Matt Rubens
5c5bf85020 Stop removing commas from terminal output 2025-02-26 21:36:19 -05:00
cte
22391e5011 Fix type errors 2025-02-24 15:55:04 -08:00
Matt Rubens
816847c5c0 Add Knip check for unused files 2025-02-23 01:01:51 -05:00
Saoud Rizwan
17157c46cb Add terminal context mention 2025-02-14 22:27:38 -05:00
axb
fbf65bfc6c Reduce the probability of errors when the model tries to fix the problem due to mismatched line numbers after applying diff 2025-02-15 00:04:17 +08:00
sam hoang
0ceb370008 feat: add terminal integration commands
- Add terminal context menu commands for:
  - Adding terminal content to context
  - Fixing failed commands
  - Explaining commands
- Implement terminal content selection and retrieval
- Add support prompts for terminal actions
- Register terminal action handlers
2025-02-06 10:27:12 +07:00
Matt Rubens
70ad037016 Fix tests 2025-02-01 12:21:13 -05:00
Matt Rubens
1e5a257e52 Removed active selection for now 2025-02-01 11:57:36 -05:00
loup
064dc4e52f feat: opened tabs and selection in the @ menu 2025-02-01 11:16:38 -05:00
Matt Rubens
2ffb009e6a Speed up diff edits 2025-01-27 02:52:05 -05:00
Evan
674216cc8a reuse existing non-busy terminals 2025-01-24 23:39:29 -05:00
Matt Rubens
b8e0aa0cde Custom modes 2025-01-21 09:39:54 -05:00
Matt Rubens
60a0a824b9 Prettier backfill 2025-01-17 14:11:28 -05:00
Frank
f759398b36 fix: correct VSCode URI 2025-01-15 08:24:21 +11:00
Matt Rubens
365f4acf63 Add mode-specific custom instructions 2025-01-14 14:54:30 -05:00
Matt Rubens
5fbfe9b775 Add test coverage 2025-01-07 16:20:11 -05:00
Matt Rubens
7e9ea7ac28 Add a Git section to the context mentions 2025-01-06 12:17:26 -05:00
Matt Rubens
667312e48c Set PAGER to cat 2024-12-30 21:57:18 -08:00
Matt Rubens
db9827efae More efficient workspace tracker 2024-12-27 17:17:38 -08:00
Matt Rubens
2b46a307b5 Update tests 2024-12-26 08:24:02 -08:00
Matt Rubens
912850c31c Updated workspace tracker from Cline 2024-12-26 08:05:07 -08:00
Matt Rubens
51b9418e31 Tests 2024-12-23 21:32:02 -08:00
Matt Rubens
752b0cf352 Use createFileSystemWatcher to more reliably watch for file system changes 2024-12-23 21:04:45 -08:00
Matt Rubens
5d930981a4 More flexibility for LLMs not being great at this 2024-12-19 09:50:34 -05:00
Matt Rubens
ef9c468f17 Use predicted length as input for detecting omissions 2024-12-19 00:54:06 -05:00
Matt Rubens
800db618bb Strip line numbers from write_to_file 2024-12-17 09:28:37 -05:00
Matt Rubens
c2b4b05459 Diff debugging 2024-12-16 12:19:44 -05:00
Matt Rubens
8159c51b03 Update omission format and keywords 2024-12-15 15:42:37 -05:00
Matt Rubens
413f10650f Stop appending newlines to files when applying diffs 2024-12-11 12:42:14 -05:00
Matt Rubens
c0b070e6f0
Improvements to apply_diff (#52) 2024-12-08 10:51:40 -05:00
John Stearns
bf0a5c82de Updating Roo-Cline with the latest cline/cline (11/22) 2024-11-22 15:28:46 -08:00
Mark Percival
93e70c62f1
Chore: Prettier for consistant formatting (#794)
* Chore: Pretier for consistant formatting

- TODO: This PR needs to be updated by Saoud after he runs `npm install` & `npm format:fix` and commits the results of the prettier changes.

* Revert prettier config

* Run npm install

* Fix prettier config and ignore package lock

* Run format

---------

Co-authored-by: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com>
2024-11-21 13:13:54 -08:00