-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
first pass at terminal tool output ui #4565
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for continuedev canceled.
|
Resolves #4482 |
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.
@sestinj I ran some testing and noted a few issues with commands that might stream both stdout and stderr. Also noted some formatting issues with ANSI terminal output. By aggregating the output from stdout and stderr into a single variable, the partial dynamically updates with stdout, then stderr is added.
The way I tested this was to ask continue to write cucumber tests for test.js in the same project. Then once cucumber was added to the package.json and a "npm test" command was added I think ask: Run "npm test" to validate.
Hope this helps. This is a nice change, and really improves the terminal tool.
|
||
childProc.stderr?.on("data", (data) => { | ||
const newOutput = data.toString(); | ||
stderr += newOutput; |
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.
stderr += newOutput; | |
terminalOutput += newOutput; |
let stdout = ""; | ||
let stderr = ""; |
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.
let stdout = ""; | |
let stderr = ""; | |
let terminalOutput = ""; |
We can use a single variable to aggreate results for both stdout, and stderr to handle commands that return both like cucumber.
You might want to also consider adding in a function to strip off ANSI terminal formatting to clean up what shows up in the partial, but retain the output into the actual tools output response. This seemed to work nicely for me.
// Function to strip ANSI escape sequences from terminal output
function stripAnsiCodes(str: string): string {
// This regex matches ANSI escape codes used for terminal formatting
return str.replace(/\x1B[[(?);]{0,2}(;?\d)*[@-~]/g, '');
}
|
||
childProc.stdout?.on("data", (data) => { | ||
const newOutput = data.toString(); | ||
stdout += newOutput; |
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.
stdout += newOutput; | |
terminalOutput += newOutput; |
{ | ||
name: "Terminal", | ||
description: "Terminal command output", | ||
content: stdout, |
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.
content: stdout, | |
content: terminalOutput, |
{ | ||
name: "Terminal", | ||
description: "Terminal command output", | ||
content: stderr, |
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.
content: stderr, | |
content: terminalOutput, |
{ | ||
name: "Terminal", | ||
description: "Terminal command output", | ||
content: stdout || "[Command completed with no output]", |
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.
content: stdout || "[Command completed with no output]", | |
content: terminalOutput || "[Command completed with no output]", |
stderr || | ||
stdout || | ||
`[Command failed with exit code ${code}]`, |
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.
stderr || | |
stdout || | |
`[Command failed with exit code ${code}]`, | |
terminalOutput || `[Command failed with exit code ${code}]`, |
this is a huge help @chezsmithy thank you |
@sestinj and @RomneyDa noting this PR + my suggested changes fixes further issues my change didn't solve for when there is staggered or delayed output from the terminal command. I'd recommend accelerating this PR to fix more issues with the terminal based tool. I'll continue to run tests using this branch locally to look for additional issues. |
No description provided.