-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Terminal "middle-out": smart truncation for terminal output #1390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
| @@ -0,0 +1,154 @@ | |||
| interface OutputBuilderOptions { | |||
| maxSize?: number // Max size of the buffer (in bytes). | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider updating the documentation for maxSize. Although the comment states it's in bytes, this implementation uses string length (code units), which may not match actual byte counts for Unicode. Clarify this to avoid confusion.
| maxSize?: number // Max size of the buffer (in bytes). | |
| maxSize?: number // Max size of the buffer (in code units, not bytes). |
ae3738b to
8bfcd83
Compare
0deaf60 to
7eee3e0
Compare
This reverts commit 7eee3e0. 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
Context
If the terminal output from a command exceeds 100KB then remove the middle of the output and just return the first 50KB and last 50KB. The 100KB limit is configurable:
Before:
3-million-hello-worlds-before.mp4
After:
3-million-hello-worlds-after.mp4
Implementation
We now have an
OutputBuilderobject that you can append text to and it will maintain two buffers if themaxSizeis exceeded. It also supports cursor-based reads from the buffer so we can properly implementgetUnretrievedOutput.How to Test
Get in Touch
Important
Adds
OutputBuilderfor smart truncation of terminal output, updates settings for output limit, and includes comprehensive tests.OutputBuilderclass inOutputBuilder.tsfor smart truncation of terminal output, preserving start and end.truncateOutputwithOutputBuilderinCline.tsandTerminalManager.ts.TERMINAL_OUTPUT_LIMITconstant interminal.ts.terminalOutputLimitsetting inExtensionStateContext.tsx,AdvancedSettings.tsx, andSettingsView.tsx.WebviewMessage.tsandExtensionMessage.tsto handleterminalOutputLimit.OutputBuilderinOutputBuilder.test.ts.TerminalProcess.test.tsandmergePromise.test.tsto reflect new behavior.truncateOutputfromextract-text.tsand related tests.This description was created by
for 7eee3e0. It will automatically update as commits are pushed.