Skip to content

Conversation

@Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Apr 30, 2025

No description provided.

@Skn0tt Skn0tt requested review from Copilot and pavelfeldman April 30, 2025 14:28
@Skn0tt Skn0tt self-assigned this Apr 30, 2025
Copy link

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 updates the file handling for downloads and screenshots by ensuring that file paths are derived from the provided output directory and that filenames are safely formatted in certain tools. Key changes include:

  • Adding a new test to verify that download links emit the correct download output.
  • Updating screenshot and PDF tools to sanitize timestamps in filenames.
  • Implementing download event handling and reporting in the browser context, along with adjustments in output file generation.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/files.spec.ts Added tests for verifying download link behavior and output directory usage.
src/tools/snapshot.ts Updated screenshot filename generation using sanitizeForFilePath.
src/tools/pdf.ts Updated PDF filename generation by incorporating sanitizeForFilePath.
src/tab.ts Introduced a download event listener to trigger downloadStarted.
src/context.ts Added logic to track downloads and display download status in snapshot output.
src/config.ts Modified outputFile to use the provided name directly, shifting filename sanitization responsibility to the callers.
const entry = {
download,
finished: false,
outputFile: await outputFile(this.config, download.suggestedFilename())
Copy link

Copilot AI Apr 30, 2025

Choose a reason for hiding this comment

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

Consider wrapping download.suggestedFilename() with sanitizeForFilePath in downloadStarted for consistent file naming and to avoid potential issues with unsafe characters.

Copilot uses AI. Check for mistakes.
@Skn0tt Skn0tt marked this pull request as ready for review April 30, 2025 15:03
src/config.ts Outdated
await fs.promises.mkdir(result, { recursive: true });
const fileName = sanitizeForFilePath(name);
return path.join(result, fileName);
return path.join(result, name);
Copy link
Member

Choose a reason for hiding this comment

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

Copilot has a point, this should always be here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I reverted it for now. The reason I remove it is that it leads to test.txt being saves as test-txt, breaking the file extension. that makes it impossible for non-computer-savvy users to open it. Let's think of a solution in a separate PR.

Copy link
Member

@pavelfeldman pavelfeldman left a comment

Choose a reason for hiding this comment

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

Approved, provided sanitization is restored and test is fixed.

@Skn0tt Skn0tt merged commit a15f0f3 into microsoft:main May 2, 2025
5 checks passed
sariwa15 pushed a commit to sariwa15/adjusted-playwright-mcp that referenced this pull request Jun 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants