Commit graph

3265 commits

Author SHA1 Message Date
Matt Rubens
c8b3095d93
Merge pull request #1566 from lightrabbit/feature/openai-compatible-deepseek-reasoning-support
feat: openai-compatible deepseek/qwq reasoning support
2025-03-12 11:39:49 -04:00
Matt Rubens
0d81c0d801
Merge pull request #1584 from RooVetGit/i18n
I18n
2025-03-12 11:38:00 -04:00
Matt Rubens
9b5ee27320
Merge pull request #1587 from dleen/cache
feat: Add prompt caching to OpenAI-compatible custom models
2025-03-12 11:35:42 -04:00
Matt Rubens
6fb61a2def
Merge pull request #1590 from ATempsch/add_deepseek_r1_to_bedrock
Add Deepseek R1 On-Demand to Bedrock
2025-03-12 11:30:32 -04:00
Matt Rubens
28e745124a PR cleanup 2025-03-12 11:23:06 -04:00
Matt Rubens
00bf91470b Add i18n 2025-03-12 11:23:06 -04:00
Matt Rubens
baa346dc46 Remove preferredLanguage and just rely on VSCode language 2025-03-12 11:23:04 -04:00
Chris Estreich
ae6903b26c
Merge pull request #1579 from RooVetGit/cte/context-proxy-fixes
ContextProxy fix - constructor should not be async
2025-03-12 08:16:30 -07:00
Andreas Tempsch
d3d1a27460 Add Deepseek R1 On-Demand to Bedrock 2025-03-12 09:16:22 +01:00
David Leen
10c1e7df2f Add cache control key to messages in OpenAI compatible provider 2025-03-11 22:43:33 -07:00
Matt Rubens
421e1972ad Add prompt caching to OpenAI-compatible custom model info 2025-03-11 22:43:33 -07:00
Chris Estreich
0fafe06e15
Merge pull request #1586 from RooVetGit/cte/fix-tests-macos
Fix terminal process unit tests on MacOS
2025-03-11 21:48:14 -07:00
Chris Estreich
13d54ad1c1
Merge pull request #1583 from cannuri/cannuri/fix-markdownblock-text-color
Fix MarkdownBlock text color for Dark High Contrast theme
2025-03-11 21:38:01 -07:00
Chris Estreich
30770ede77
Update src/integrations/terminal/__tests__/TerminalProcessExec.test.ts
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-03-11 21:35:18 -07:00
cte
0d55593fa8 Remove references to base64 from comments 2025-03-11 21:33:01 -07:00
cte
7806829ef0 Fix unit tests on MacOS 2025-03-11 21:29:22 -07:00
cannuri
49fca1074f Fix MarkdownBlock text color for Dark High Contrast theme 2025-03-12 02:32:59 +01:00
Chris Estreich
80d1fae033
Update src/shared/globalState.ts
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-03-11 14:27:18 -07:00
cte
4b6def5f31 ContextProxy fix - constructor should not be async 2025-03-11 14:24:21 -07:00
Chris Estreich
b73bc39c8d
Merge pull request #1365 from KJ7LNW/roo-fix-terminal-undefined-exit-code
refactor terminal architecture to address critical issues with the current design
2025-03-11 13:59:04 -07:00
Matt Rubens
3b2d6bce64
Merge pull request #1564 from cannuri/cannuri/fix_subtask_cancel_resume_bug
fix: Preserve parent-child relationship when cancelling subtasks
2025-03-11 14:47:17 -04:00
Matt Rubens
99258e4a9c
Merge pull request #1572 from RooVetGit/fix_openrouter_generation_check
Use baseURL in OpenRouter generation check
2025-03-11 12:00:37 -04:00
Matt Rubens
b5f6e37982
Merge pull request #1543 from shohei-ihaya/vertex
add gemini-2.0-pro-exp-02-05 model to vertex
2025-03-11 09:57:24 -04:00
Matt Rubens
76f91819c1 Use baseURL in OpenRouter generation check 2025-03-11 09:41:57 -04:00
lightrabbit
7114cef03e feat: openai-compatible deepseek/qwq reasoning support 2025-03-11 14:13:17 +08:00
Matt Rubens
ff54c63ffa
Merge pull request #1526 from qdaxb/fix_progress_status
Fix progress status
2025-03-11 01:23:45 -04:00
axb
8917ab7591 fix duplicate ask 2025-03-11 13:08:02 +08:00
axb
621fc0e867 Revert "Merge pull request #1518 from RooVetGit/revert_tool_progress_for_now"
This reverts commit dba9116d26, reversing
changes made to 85dd1a1977.
2025-03-11 13:07:55 +08:00
cannuri
6ce8e56db5 fix: Preserve parent-child relationship when cancelling subtasks
This commit fixes an issue where subtasks weren't properly reporting back to parent tasks when cancelled and resumed. Previously, when a subtask was cancelled and a new task was started with the same message, the parent task would incorrectly resume, causing unexpected behavior.

The fix:
1. Stores parent-child relationship information before cancelling a task
2. Restores this relationship after task reinitialization
3. Ensures parent tasks only resume when explicitly instructed to do so

This approach maintains the correct task hierarchy throughout the cancellation and resumption process, preventing parent tasks from automatically resuming when unrelated tasks with similar messages are started.
2025-03-11 06:05:48 +01:00
Eric Wheeler
701b5a7d87 test: align terminal tests with shell integration safeguards
Update TerminalProcessExec tests to properly handle shell integration
event sequences:

- Set terminal.running=true before command execution
- Remove duplicate command execution that could trigger extra events
- Replace arbitrary timeout with event-based waiting for output
- Ensure proper event sequence (run -> start -> output -> end)

This aligns the tests with the safeguards added in 62ffa797 that
prevent spurious shell integration events from corrupting terminal
state.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 21:22:19 -07:00
Eric Wheeler
62ffa7973c fix: prevent spurious onDidEndTerminalShellExecution from breaking terminal output
Add explicit checks and error logging to handle problematic event sequence:

0. terminal.running=false
1. terminal.shellIntegration.executeCommand(command)
2. onDidEndTerminalShellExecution  // from unexpected 'OSC 633 D' sequence
3. onDidStartTerminalShellExecution
4. stream begins
5. onDidEndTerminalShellExecution

The first onDidEndTerminalShellExecution (from unexpected OSC 633 D) is
ignored because terminal.running is false, preventing process=undefined
from being set prematurely. After the stream begins and sets
terminal.running to true, the second onDidEndTerminalShellExecution
proceeds normally.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
e3adee4f15 fix: allow background terminals to broadcast output across tasks
Fix issue where background processes (like compilers) couldn't broadcast their
output to new tasks after the launching task was closed. Previously commit
851a4cd prevented terminals from responding to any task except the one that
started them.

The fix allows background terminals (taskId undefined) to act as broadcast
sources that can update any task through getEnvironmentDetails, while still
maintaining proper isolation for task-specific terminals. This enables common
workflows where:

1. A task launches a background compiler
2. That task is closed and a new task is started
3. The new task can still receive compiler errors when making changes

This gives us the best of both worlds:
- Task isolation: Active tasks only see their own terminal output
- Background broadcasting: Background processes can inform any task that needs
  their output

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
0b4fa0b1d6 feat: compress repeated terminal output lines
Add Terminal.compressTerminalOutput static method to apply run-length encoding
before truncating terminal output. This significantly reduces output size for
repeated lines while maintaining readability.

- Add compressTerminalOutput static method to Terminal class
- Replace all truncateOutput calls with Terminal.compressTerminalOutput
- Import required functions from extract-text

Test program demonstrating compression:
```python
def generate_repeats():
    patterns = [
        ("A\n", 10),          # 10 lines
        ("AA\n", 100),        # 100 lines
        ("AAA\n", 1000),      # 1K lines
        ("AAAA\n", 10000),    # 10K lines
        ("AAAAA\n", 100000),  # 100K lines
        ("AAAAAA\n", 1000000) # 1M lines
    ]

    for text, count in patterns:
        print(text * count, end="")
```

Sample output showing compression:
```
A
A
A
A
A
A
A
A
A
A
AA
<previous line repeated 99 additional times>
AAA
<previous line repeated 999 additional times>
AAAA
<previous line repeated 9999 additional times>
AAAAA
<previous line repeated 99999 additional times>
AAAAAA
<previous line repeated 999999 additional times>
```

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
131f9ad0d9 feat: add run-length encoding for repeated lines
Implement applyRunLengthEncoding function to compress repeated lines in text output:
- Add line repetition compression with count message
- Focus on single line repetitions
- Only compress when beneficial
- Add tests for empty input and single line repetitions

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
269ddf9a0e fix: avoid duplicate terminal output accumulation
Optimize terminal output handling to reduce memory pressure by:
- Remove continuous result accumulation during line processing
- Only store the same final output from the "completed" event that came from TerminalProcess

Also:
- Add clear error messages for undefined exit details

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
5be49e1d15 fix: apply terminal output line limits consistently
Apply terminalOutputLineLimit to command output lines as they are received,
rather than only at the end of command execution. Also apply the limit to
terminal output shown in environment details.

This ensures consistent output truncation behavior across all terminal
output paths, preventing potential memory issues from large outputs.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
c31a5e5bcd perf: optimize truncateOutput for large inputs
Use string indices to find line boundaries instead of splitting into array.
This avoids creating large arrays in memory when truncating big inputs.

- Replace split/join with indexOf/lastIndexOf for line counting
- Use slice to extract start/end sections directly from string
- Maintain same 20/80 ratio for before/after content

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
8b8c4fde50 fix: handle undefined exit codes in terminal output
When a terminal command completes with an undefined exit code:

- Add explicit handling for undefined exit code case
- Include clear message in output that exit code is undefined
- Notify user to help diagnose potential terminal issues

This helps identify and debug cases where the terminal process
completes but the exit code is not properly captured.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
4e0f868261 fix: improve error handling when start sequence not received but stream started
When VSCE start sequence (]633;C or ]133;C) is not received, but the
stream has started:

- Emit no_shell_integration event with clear error message
- Include preOutput in completed event for bug reporting
- Call continue() to ensure proper cleanup
- Return early to prevent further processing

This helps diagnose potential upstream VSCE bugs by providing more context
in the error messages and ensuring proper cleanup of terminal state.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
8de202ba09 fix: prevent UI freeze when terminal stream is unavailable
Add timeout and error handling to terminal stream initialization to prevent
UI from freezing when a stream is unavailable or never starts. This ensures
that if the VSCE shell integration stream does not start within 3 seconds:

- The streamAvailable promise is rejected with a clear error
- Event listeners are cleaned up to prevent memory leaks
- Terminal state is properly reset
- Execution continues rather than hanging indefinitely

This fixes a potential deadlock where the UI could freeze waiting for a
stream that never becomes available.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
f2891d7bc6 test: update no_shell_integration event test
Update test to handle string message parameter in no_shell_integration event

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
a867595a6a doc: enhance shell integration error messages
Add descriptive messages to shell integration failures to help users
understand and resolve integration issues more effectively. This improves
the debugging experience by providing specific details about why shell
integration failed.

- Add message parameter to no_shell_integration event
- Update UI to display specific error messages
- Update troubleshooting documentation link

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
7dadf4cd1b refactor: remove redundant terminal ID from event handling
As pointed out by @cte, passing and checking terminal IDs in events is
unnecessary since a TerminalProcess instance can never be associated with a
different Terminal instance. The event handling is already properly scoped
to the specific TerminalProcess instance.

- Remove terminal ID parameter from shell_execution_complete event
- Remove terminal ID parameter from stream_available event
- Update all event handlers to remove ID checks
- Update all test cases to match new event signatures

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
1601401888 cleanup: remove unused stream property from Terminal
@cte reported that the stream property is not used anywhere in the codebase.
The stream is passed directly to the process via event emitter and does not need to be stored.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
5de0133929 docs: fix test file path in comment
Update the test file path in the comment to match the actual test file name,
making it easier to run the specific test file directly.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
e3b682f119 perf: use string instead of array for terminal output
Use a string instead of array for terminal output since it is faster
than splitting and joining. Also note that 'line' events may contain
multiple lines, so concatenating directly is more efficient.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
5c9f7722b6 docs: document TerminalProcess stability guidelines
The TerminalProcess class is a critical component for VSCode shell integration.
This documentation explains why changes must be minimal and carefully considered:

- Performance optimizations using index-based operations and zero-copy implementation
- Accuracy requirements for handling terminal output and escape sequences
- Complex integration with VSCode shell features and command execution
- Careful handling of stream data and escape sequence processing
- Backwards compatibility considerations for VSCode releases

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
2319f968e2 test: update Terminal constructor calls
Notice: this comment required updating system test snapshots with new
execute_command XML schema feature `cwd`

- Add required cwd parameter to Terminal constructor calls in tests
  - Use './' for TerminalProcess.test.ts
  - Use '/test/path' for TerminalProcessExec.test.ts to match shellIntegration.cwd

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
1a1432d1d1 fix: remove forced directory changes that break shell integration
Forcing terminals to `cd` back to the project directory was disrupting
shell state without providing feedback to the model. This caused issues
with capturing output from subsequent commands, particularly with custom
shell prompts.

Instead of forcing directory changes, we now track terminal state
through shell integration with a fallback mechanism, and provide
explicit working directory feedback to the model. This allows terminals
to maintain their natural state while ensuring accurate command output
capture.

Changes:
- Remove forced `cd` commands that were disrupting terminal state
- Add getCurrentWorkingDirectory() method with shell integration fallback
- Add customCwd parameter to executeCommandTool for flexible directory handling
- Add requiredCwd parameter to control terminal selection behavior
- Refactor terminal selection logic for more consistent state management
- Modify environment details to include terminal working directory feedback
- Update XML schema to include optional working directory parameter in execute_command

The environment details now provide explicit feedback about terminal state:
Command executed in terminal N from '/path/to/dir'. Exit code: 0

Fixes: #1388
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00
Eric Wheeler
e27c6aadc1 fix: terminal process isolation between parallel Cline tasks
These changes ensure proper isolation by preventing terminal process
output from one Cline task appearing in another task's context when
multiple Cline instances are running in parallel.

- Add taskId parameter to TerminalRegistry.getTerminals to filter terminals by Cline task ID
- Update Cline.ts to use taskId-filtered terminals

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-10 20:55:05 -07:00