Skip to content

Created log-viewer.html to view logs #80

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ajay-sreeram
Copy link

It was difficult to understand the logs, so vibe coded this simple log viewer with workflow view, message flow view and raw logs view.

Screenshot 2025-03-28 at 2 45 40 PM

@saqadri
Copy link
Collaborator

saqadri commented Mar 28, 2025

@ajay-sreeram whoa, this is an awesome idea and thanks for the contribution! Can you please add usage instructions (both to PR and to the README). That'll help me review this better as well.

Would like to test out a few cases before merging it in, but overall quite supportive of having this.

processLogs();

// Re-initialize resizable columns after loading the logs
reinitializeResizableColumns();
Copy link

Choose a reason for hiding this comment

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

The function reinitializeResizableColumns() is referenced but not defined in the code, which will cause a JavaScript runtime error when executed. Either implement this function to handle column resizing functionality or remove this call to prevent errors. The column resizing UI elements (the .resizer class) are defined in CSS, suggesting this functionality was intended but not fully implemented.

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +526 to +528
<div>
<button id="toggleView">Switch to Workflow View</button>
</div>
Copy link

Choose a reason for hiding this comment

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

The toggleView button in the header appears to be unused - there's no event listener attached to it in the JavaScript code. This creates a confusing user experience since clicking the button won't perform any action. Consider either:

  1. Removing this button since the view switching functionality is already handled by the showRawLogs, showWorkflow, and showMessageFlow buttons below, or
  2. Adding an event listener to implement the toggle functionality, perhaps cycling through the three available views.

This would improve the UI consistency and prevent user confusion.

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +1335 to +1338
function formatResult(result) {
// Replace \\ with \ and handle newlines for display
return result.replace(/\\n/g, '<br>').replace(/\\\\/g, '\\').replace(/\\\(/g, '(').replace(/\\\)/g, ')');
}
Copy link

Choose a reason for hiding this comment

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

The formatResult function directly inserts potentially untrusted content into the DOM without sanitizing HTML, creating a cross-site scripting (XSS) vulnerability. An attacker could craft log content containing malicious script tags that would execute when displayed.

Consider implementing HTML sanitization before inserting content:

function formatResult(result) {
    // First escape HTML special characters
    const escaped = result
        .replace(/&/g, '&amp;')
        .replace(/</g, '&lt;')
        .replace(/>/g, '&gt;')
        .replace(/"/g, '&quot;')
        .replace(/'/g, '&#039;');
    
    // Then handle the special characters for display
    return escaped.replace(/\\n/g, '<br>').replace(/\\\\/g, '\\').replace(/\\\(/g, '(').replace(/\\\)/g, ')');
}

Alternatively, use a dedicated library like DOMPurify to handle sanitization more comprehensively.

Suggested change
function formatResult(result) {
// Replace \\ with \ and handle newlines for display
return result.replace(/\\n/g, '<br>').replace(/\\\\/g, '\\').replace(/\\\(/g, '(').replace(/\\\)/g, ')');
}
function formatResult(result) {
// First escape HTML special characters
const escaped = result
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;');
// Then handle the special characters for display
return escaped.replace(/\\n/g, '<br>').replace(/\\\\/g, '\\').replace(/\\\(/g, '(').replace(/\\\)/g, ')');
}

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

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