Skip to content

Comments

Improve MCP gateway log output: refactor to helper module with file-tree display and extension filtering#13505

Merged
pelikhan merged 6 commits intomainfrom
copilot/improve-parse-gateway-logs
Feb 3, 2026
Merged

Improve MCP gateway log output: refactor to helper module with file-tree display and extension filtering#13505
pelikhan merged 6 commits intomainfrom
copilot/improve-parse-gateway-logs

Conversation

Copy link
Contributor

Copilot AI commented Feb 3, 2026

Gateway log debugging in printAllGatewayFiles() was indenting each line with 4 spaces and truncating files at 10KB, making logs harder to read and losing important context.

Changes

  • Remove log indentation: Output lines directly without prefix for cleaner console output
  • Increase truncation limit: 10KB → 64KB to capture more diagnostic information before truncation
  • Add collapsible groups: Wrap file content with core.startGroup() and core.endGroup() to create collapsible sections in GitHub Actions logs
  • File-tree appearance: Use filenames as group titles (e.g., gateway.log instead of Content of gateway.log) for natural file-tree navigation
  • Extension filtering: Only display content for .json, .jsonl, .log, .txt files to prevent displaying binary or non-text files
  • Refactor to helper module: Extract file display logic into display_file_helpers.cjs for better separation of concerns and reusability
  • Optimize GitHub Actions output: Use nested collapsible groups and appropriate macros (core.notice(), core.warning(), core.error()) for better visibility
  • Add comprehensive tests: 14 new tests in display_file_helpers.test.cjs covering all edge cases, plus updated existing tests

New Helper Module

Created display_file_helpers.cjs with three exported functions:

  • displayFileContent(filePath, fileName, maxBytes) - Displays a single file with collapsible group (filtered by extension)
  • displayDirectory(dirPath, maxBytes) - Displays all files in a directory
  • displayDirectories(directories, maxBytes) - Displays multiple directories

Example

// Before (in parse_mcp_gateway_log.cjs)
core.info("=== Listing All Gateway-Related Files ===");
core.info(`    --- Content of ${file} ---`);
core.info(`    ${line}`);  // Every line prefixed with 4 spaces
core.info(`    --- End of ${file} ---`);
const maxOutputBytes = 10 * 1024;  // 10KB

// After (using display_file_helpers.cjs)
displayDirectories(["/tmp/gh-aw/mcp-logs"], 64 * 1024);
// Creates nested groups with file-tree appearance:
// - Outer: "=== Listing All Gateway-Related Files ==="
//   - Middle: "📁 Directory: /path/to/dir"
//     - Inner: "gateway.log" (filename as title)
//     - Shows: "(content not displayed for .md files)" for unsupported types

Impact

File contents in gateway logs are now:

  • File-tree structure: Filenames are used as collapsible group titles, creating a natural file explorer appearance
  • Intelligent filtering: Only .json, .jsonl, .log, .txt files have content displayed; other files show a message explaining why content is not displayed
  • Better organized: Nested collapsible groups (outer for all files, per directory, per file)
  • More informative: Uses core.notice(), core.warning(), and core.error() for better visibility
  • Easier to maintain: Display logic separated from parsing logic with 85 lines reduced to 22 lines in main file
  • More complete: 64KB limit captures more diagnostic information
  • Safer: Prevents accidentally displaying binary files or large non-text content
  • Reusable: Helper functions can be used by other log parsers

Affects the debugging output in parse_mcp_gateway_log.cjs used during workflow runs.

Original prompt

Reference: https://github.com/github/gh-aw/actions/runs/21632510109/job/62348819729#step:41:1

Improve parse gateway agentic logs.cjs:

  • do not indent logs
  • trim files at 64kb instead of 10kb

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

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

Use actions code regions macros to create collapsible sections @copilot

Copilot AI changed the title [WIP] Improve parse gateway agentic logs formatting and size limit Improve MCP gateway log output: remove indentation and increase truncation to 64KB Feb 3, 2026
Copilot AI requested a review from pelikhan February 3, 2026 14:02
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 3, 2026

Use actions code regions macros to create collapsible sections @copilot

Implemented in commit a42df69. File contents are now wrapped with core.startGroup() and core.endGroup() to create collapsible sections in GitHub Actions logs.

Changes:

  • Each file's content is now in its own collapsible group titled "Content of {filename}"
  • When collapsed: Shows just the filename, making logs much cleaner
  • When expanded: Shows full file content (up to 64KB)

This makes the logs much easier to scan when debugging gateway files with large outputs.

Copilot AI changed the title Improve MCP gateway log output: remove indentation and increase truncation to 64KB Improve MCP gateway log output: remove indentation, increase truncation to 64KB, and add collapsible groups Feb 3, 2026
@pelikhan
Copy link
Contributor

pelikhan commented Feb 3, 2026

@copilot refactor helper to display file in separate JavaScript file, add tests

Make the output optimized for GitHub actions making best use of the macros

…b Actions output

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 3, 2026

@copilot refactor helper to display file in separate JavaScript file, add tests

Make the output optimized for GitHub actions making best use of the macros

Implemented in commit fe6a4b3. Created display_file_helpers.cjs with optimized GitHub Actions output:

New helper module:

  • displayFileContent() - Displays single files with collapsible groups
  • displayDirectory() - Displays all files in a directory
  • displayDirectories() - Displays multiple directories

Optimized GitHub Actions macros:

  • core.startGroup() / core.endGroup() - Nested collapsible sections (outer for all files, inner per directory, innermost per file)
  • core.notice() - Missing directory warnings
  • core.warning() - File read errors
  • core.error() - Directory read errors

Tests:

  • Added 11 comprehensive tests in display_file_helpers.test.cjs
  • Updated existing tests to work with new helper
  • All 31 tests passing

The refactoring reduces the main file from ~95 lines to ~22 lines for file display logic.

@pelikhan pelikhan added the smoke label Feb 3, 2026
Copilot AI changed the title Improve MCP gateway log output: remove indentation, increase truncation to 64KB, and add collapsible groups Improve MCP gateway log output: refactor to helper module with optimized GitHub Actions macros Feb 3, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

🎉 Yo ho ho! Changeset Generator found the treasure and completed successfully! ⚓💰

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

Agent Container Tool Check

Tool Status Version
bash 5.2.21
sh available
git 2.52.0
jq 1.7
yq 4.50.1
curl 8.5.0
gh 2.86.0
node 24.13.0
python3 3.13.11
go 1.24.12
java not found
dotnet not found

Result: 10/12 tools available ⚠️

Missing Tools:

  • java - command not found
  • dotnet - command not found

Status: PARTIAL - Core development tools (bash, git, node, python, go) are present, but Java and .NET runtimes are unavailable.

AI generated by Agent Container Smoke Test

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

GitHub MCP merged PRs ✅ (Fix smoke-claude: clarify safe-outputs auto-targeting for PR comments | Refactor MCP server status tool to call GetWorkflowStatuses directly)
Safeinputs GH PR list ✅ ([WIP] Fix crash issue during execution | [WIP] Refactor safe_outputs_config_generation.go into smaller modules)
Serena activate_project ✅
Playwright title check ❌
Tavily search ✅
File write + cat ✅
make build ✅
Discussion comment ✅
Overall: FAIL

AI generated by Smoke Codex

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

Smoke Test Results

PRs Tested:

Test Results:

  • ✅ GitHub MCP Testing
  • ✅ Safe Inputs GH CLI Testing
  • ✅ Serena MCP Testing
  • ❌ Playwright Testing (MCP unavailable)
  • ✅ File Writing Testing
  • ✅ Bash Tool Testing
  • ✅ Discussion Interaction Testing
  • ✅ Build gh-aw
  • ✅ Workflow Dispatch Testing

Overall Status: PARTIAL PASS ⚠️ (8/9 passed)

@pelikhan @Copilot

AI generated by Smoke Copilot

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

Smoke Test Results - Run 21633893537

PR Titles:

Test Results:

  • ✅ GitHub MCP Testing
  • ✅ Safe Inputs GH CLI Testing
  • ✅ Serena MCP Testing
  • ✅ Make Build Testing
  • ✅ Tavily Web Search Testing
  • ✅ File Writing Testing
  • ✅ Bash Tool Testing
  • ✅ Discussion Interaction Testing
  • ⚠️ Agentic Workflows MCP Testing (API access issue)
  • ❌ Playwright Testing (tools not available)

Overall Status: PARTIAL PASS (8/10 tests passed)

AI generated by Smoke Claude

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@pelikhan
Copy link
Contributor

pelikhan commented Feb 3, 2026

@copilot make the filename the title of the group so it looks like a file tree (instead of "Contents of ...")

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 3, 2026

@copilot make the filename the title of the group so it looks like a file tree (instead of "Contents of ...")

Implemented in commit 50ff236. Changed group title from "Content of ${fileName}" to just fileName for a file-tree appearance.

Before:

▶ Content of gateway.log
▶ Content of stderr.log

After:

▶ gateway.log
▶ stderr.log

This creates a cleaner, more natural file-tree structure in the logs.

@pelikhan pelikhan marked this pull request as ready for review February 3, 2026 14:31
Copilot AI review requested due to automatic review settings February 3, 2026 14:31
Copilot AI changed the title Improve MCP gateway log output: refactor to helper module with optimized GitHub Actions macros Improve MCP gateway log output: refactor to helper module with file-tree display Feb 3, 2026
return;
}

// Read and display file content
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot only show content of .json, .jsonl, .log, .txt files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Implemented in commit 3b01180. Content display is now filtered to only .json, .jsonl, .log, .txt files.

Behavior:

  • Supported extensions: File content is displayed in collapsible groups
  • Unsupported extensions: Shows (content not displayed for .ext files) message
  • All files: Still listed with filename and size information

Tests added:

  • Test for unsupported extension (.md file)
  • Test for .json file content display
  • Test for .log file content display

This prevents accidentally displaying binary files or large markdown/code files while keeping logs focused on debugging information.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the MCP gateway file-printing logic into a reusable helper module optimized for GitHub Actions, while increasing the file content truncation limit and improving log readability. The result is cleaner, non-indented log content presented as a collapsible file tree in Actions logs, with stronger unit test coverage around the new behavior.

Changes:

  • Replaced the inline printAllGatewayFiles implementation with a call to a new displayDirectories helper that uses GitHub Actions groups and raises the truncation limit from 10KB to 64KB.
  • Added display_file_helpers.cjs with displayFileContent, displayDirectory, and displayDirectories to encapsulate directory/file traversal, truncation logic, and group-based log presentation.
  • Expanded and adjusted tests in parse_mcp_gateway_log.test.cjs and added comprehensive tests in display_file_helpers.test.cjs to cover grouping behavior, truncation behavior, and error/edge cases (missing dirs, empty dirs, huge files).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
actions/setup/js/parse_mcp_gateway_log.cjs Refactors printAllGatewayFiles to delegate to displayDirectories with a 64KB per-file truncation limit, integrating the new helper into the existing gateway log parsing flow.
actions/setup/js/parse_mcp_gateway_log.test.cjs Updates gateway file-printing tests to assert on GitHub Actions group usage, 64KB truncation behavior, and the new notice-based missing-directory messaging.
actions/setup/js/display_file_helpers.cjs Introduces reusable helpers to display directories and files with collapsible groups, size-aware truncation, and tailored logging (info/notice/warning/error) for different scenarios.
actions/setup/js/display_file_helpers.test.cjs Adds unit tests for the new helpers, verifying normal files, empty files, directories, oversized files, read errors, multiple directories, and custom truncation limits.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title Improve MCP gateway log output: refactor to helper module with file-tree display Improve MCP gateway log output: refactor to helper module with file-tree display and extension filtering Feb 3, 2026
Copilot AI requested a review from pelikhan February 3, 2026 14:41
@pelikhan pelikhan merged commit efd601e into main Feb 3, 2026
@pelikhan pelikhan deleted the copilot/improve-parse-gateway-logs branch February 3, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants