Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sestinj
Copy link
Contributor

@sestinj sestinj commented Mar 9, 2025

No description provided.

Copy link

netlify bot commented Mar 9, 2025

Deploy Preview for continuedev canceled.

Name Link
🔨 Latest commit 6296630
🔍 Latest deploy log https://app.netlify.com/sites/continuedev/deploys/67ce23e18b09850008be41d4

@chezsmithy
Copy link
Contributor

Resolves #4482

Copy link
Contributor

@chezsmithy chezsmithy left a 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
stderr += newOutput;
terminalOutput += newOutput;

Comment on lines +22 to +23
let stdout = "";
let stderr = "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
stdout += newOutput;
terminalOutput += newOutput;

{
name: "Terminal",
description: "Terminal command output",
content: stdout,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
content: stdout,
content: terminalOutput,

{
name: "Terminal",
description: "Terminal command output",
content: stderr,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
content: stderr,
content: terminalOutput,

{
name: "Terminal",
description: "Terminal command output",
content: stdout || "[Command completed with no output]",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
content: stdout || "[Command completed with no output]",
content: terminalOutput || "[Command completed with no output]",

Comment on lines +84 to +86
stderr ||
stdout ||
`[Command failed with exit code ${code}]`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
stderr ||
stdout ||
`[Command failed with exit code ${code}]`,
terminalOutput || `[Command failed with exit code ${code}]`,

@sestinj
Copy link
Contributor Author

sestinj commented Mar 13, 2025

this is a huge help @chezsmithy thank you

@sestinj sestinj requested a review from RomneyDa March 16, 2025 20:29
@chezsmithy
Copy link
Contributor

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants