Skip to content

feat: enhance console output handling and isolation in shell execution - #490

Merged
OutOfBedlam merged 1 commit into
mainfrom
fix-nfx-3636
Oct 7, 2026
Merged

OutOfBedlam merged 1 commit into
mainfrom
fix-nfx-3636

Conversation

@OutOfBedlam

Copy link
Copy Markdown
Contributor

This pull request improves the reliability and clarity of console output handling and error reporting in the shell environment. The main changes ensure that console output is properly isolated during agent code execution, error messages are consistently reported via the shell environment rather than standard logging, and the implementation of console functions in the JavaScript runtime is more robust and testable.

Console output isolation and reliability:

  • Refactored ExecAgentCode in ai.go to temporarily replace the VM's console object with a custom one during agent code execution, ensuring that console output is captured and restored correctly. This prevents output leakage and side effects on the global VM state.
  • Added a comprehensive test (TestExecAgentCodeConsoleIsolation) to verify that console output is properly isolated, captured, and restored, including handling startup failures.

Consistent and environment-aware error reporting:

  • Replaced direct log.Printf and log.Println calls with sh.printShellError throughout pipeline.go and shell.go, ensuring that error messages are written to the shell's configured output rather than standard output. This improves user-facing error reporting and testability. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]
  • Updated a pipeline test to expect the new error message format for unsupported stdout redirection.

Console and logging implementation improvements:

  • Refactored SetConsole and related functions in log.go to allow per-VM console output redirection, rather than relying on a global writer. Console methods (log, print, etc.) are now bound to the provided writer, improving modularity and preventing cross-test interference. [1] [2] [3] [4] [5]
  • Removed unused imports and clarified documentation regarding the distinction between global and VM-bound console output. [1] [2]

Test and code hygiene:

  • Added missing imports and synchronization primitives in log_test.go to support new and existing tests.

These changes collectively improve the shell's reliability, make console output behavior more predictable and testable, and enhance the clarity of error messages for end users.

@codecov

codecov Bot commented Oct 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.57377% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.74%. Comparing base (d580811) to head (9b64bc4).

Files with missing lines Patch % Lines
jsh/lib/shell/pipeline.go 33.33% 16 Missing ⚠️
jsh/lib/shell/shell.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #490      +/-   ##
==========================================
+ Coverage   70.64%   70.74%   +0.10%     
==========================================
  Files         359      359              
  Lines       73771    73774       +3     
==========================================
+ Hits        52112    52195      +83     
+ Misses      16113    16030      -83     
- Partials     5546     5549       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@OutOfBedlam
OutOfBedlam merged commit 93cf017 into main Oct 7, 2026
19 of 23 checks passed
@OutOfBedlam
OutOfBedlam deleted the fix-nfx-3636 branch October 7, 2026 01:46
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.

1 participant