Skip to content

Conversation

continue[bot]
Copy link

@continue continue bot commented Sep 17, 2025

Summary

Improves the truncation logic for the Search tool to handle edge cases with extremely long lines (like base64 content) that can cause terminal display issues.

Changes

  • Extracted smart truncation logic into pure, testable functions in
  • Enhanced truncation handling with support for:
    • Line count limits (existing behavior)
    • Character count limits (prevents memory issues)
    • Individual line length limits (handles base64/minified content)
  • Added comprehensive test coverage for all truncation scenarios
  • Updated searchCode tool to use the new truncation system
  • Improved truncation messages that show both line and character metrics when relevant

Problem Solved

The previous truncation logic only considered line count, which caused problems when search results contained very long lines (e.g., base64 strings, minified code). This could lead to:

  • Terminal overflow and display issues
  • Poor user experience with extremely wide output
  • Memory usage concerns with large content

Solution

The new function handles multiple limits:

  • : 100 (same as before)
  • : 50KB total output
  • : 1000 characters per line

It truncates content intelligently, respecting whichever limit is hit first, and provides informative messages about what was truncated.

Testing

Added comprehensive unit tests covering:

  • Basic line truncation (existing behavior)
  • Character limit truncation
  • Long line truncation (new capability)
  • Combined limit scenarios
  • Edge cases (empty content, single long lines, etc.)

Manual testing confirms the integration works correctly with the Search tool.


Summary by cubic

Improves the Search tool’s truncation to handle extremely long lines and big outputs without breaking the terminal. Adds smart, configurable limits with clear messages to keep results readable and safe.

  • New Features
    • Extracted smartTruncate and formatTruncationMessage into pure, tested utilities.
    • Truncation limits: maxLines 100, maxChars 50KB, maxLineLength 1000; first limit wins.
    • Updated searchCode to use the new truncation and mark overly long lines with "... [line truncated]".
    • Added unit tests for line, char, long-line, combined, and edge cases.

- Extract smart truncation logic into pure functions (truncation.ts)
- Handle edge cases like very long lines (e.g., base64 content)
- Support both line count and character limits with configurable thresholds
- Add comprehensive test coverage for truncation scenarios
- Update searchCode tool to use new truncation system
- Prevent terminal overflow from extremely long individual lines

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <[email protected]>
@continue continue bot requested a review from a team as a code owner September 17, 2025 23:24
@continue continue bot requested review from RomneyDa and removed request for a team September 17, 2025 23:24
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Sep 17, 2025
@RomneyDa
Copy link
Collaborator

@continuedev this is failing tests and checks please fix

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
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants