Skip to content

Conversation

@ellispinsky
Copy link
Contributor

Description

Please provide an explanation of the changes you've made:

[Describe what this PR does and why]

Implementation Checklist

  • If updating our sample apps, update the info in our Quickstart
  • If updating our CLI, update the info in our CLI

Testing

  • mintlify dev works (see installation here)

Docs

  • Link to a PR in our docs repo documenting your change (if applicable)

Visual Proof

Please provide a screenshot or video demonstrating that your changes work locally:

[Drag and drop your screenshot/video here or use the following format:]
[Screenshot description]

Related Issue

Fixes [Github issue link]

[If this corresponds to a fix from another Kernel OSS repo, include this:]

Fixes [Link to other repo]

[Replace with actual issue link, e.g., Fixes https://github.com/username/repo/issues/123]

Additional Notes

[Any additional context, concerns, or notes for reviewers]

@mesa-dot-dev
Copy link
Contributor

mesa-dot-dev bot commented Dec 4, 2025

Mesa Description

Description

Please provide an explanation of the changes you've made:

This PR improves the documentation for file I/O operations in browsers/file-io.mdx. It updates and expands code examples for both file downloads and uploads. Specifically, it includes minor formatting adjustments to existing TypeScript/JavaScript download examples, adds a new Stagehand v3 example for file download handling, and completely revamps file upload examples for both TypeScript/JavaScript and Python to illustrate a full workflow using Kernel's file system APIs and Playwright's setInputFiles for simulated uploads.

Implementation Checklist

  • If updating our sample apps, update the info in our Quickstart
  • If updating our CLI, update the info in our CLI

Testing

  • mintlify dev works (see installation here)

Docs

  • Link to a PR in our docs repo documenting your change (if applicable)

Visual Proof

Please provide a screenshot or video demonstrating that your changes work locally:

[Drag and drop your screenshot/video here or use the following format:]
[Screenshot description]

Related Issue

Fixes [Github issue link]

[If this corresponds to a fix from another Kernel OSS repo, include this:]

Fixes [Link to other repo]

[Replace with actual issue link, e.g., Fixes https://github.com/username/repo/issues/123]

Additional Notes

[Any additional context, concerns, or notes for reviewers]

Description generated by Mesa. Update settings

Copy link
Contributor

@mesa-dot-dev mesa-dot-dev bot left a comment

Choose a reason for hiding this comment

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

Performed full review of 16ab9dc...07a6eed

Analysis

  1. Resource leaks - The upload examples contain commented-out cleanup code (browser deletion) that would cause resource leaks if users copy the code as-is without proper cleanup.

  2. Inconsistent standards - There are inconsistencies in markdown formatting (4 vs 3 backticks) and timeout configurations (6s vs 10s) across examples that may cause rendering issues or confusion.

  3. Missing error handling - The examples lack robust error handling mechanisms, particularly for network failures when fetching remote resources, which could lead to unreliable code in production.

  4. Cleanup code patterns - There's an opportunity to establish a consistent pattern for all examples where cleanup code is always included and active, with explanatory comments about its importance.

Tip

Help

Slash Commands:

  • /review - Request a full code review
  • /review latest - Review only changes since the last review
  • /describe - Generate PR description. This will update the PR body or issue comment depending on your configuration
  • /help - Get help with Mesa commands and configuration options

1 files reviewed | 0 comments | Edit Agent SettingsRead Docs

asyncio.run(main())
````
```typescript Stagehand v3
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move Stagehand v3 out of this section? My thought:
Outer section for Downloads
Sub-section for Playwright
Sub-section for Stagehand v3

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

For Stagehand v3 section I would def mention the two necessary added params you have to add to your Stagehand config:

  downloadsPath: DOWNLOAD_DIR,
  acceptDownloads: true,

Copy link
Contributor

@dprevoznik dprevoznik left a comment

Choose a reason for hiding this comment

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

Made some requested changes!

asyncio.run(main())
````
```typescript Stagehand v3
Copy link
Contributor

Choose a reason for hiding this comment

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

console.log("Download triggered");

// Wait a bit for the download to complete
await new Promise((r) => setTimeout(r, 6000));
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't believe you need this since we have the waitFor function

Comment on lines 297 to 305
// List files in the download directory to see what was downloaded
console.log("Checking download directory...");
const files = await kernel.browsers.fs.listFiles(kernelBrowser.session_id, {
path: DOWNLOAD_DIR,
});

if (files.length === 0) {
console.log("No files found in download directory");
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't believe we need to try listing the files first. Since we use waitFor, I believe this is redundant

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually up to line 307

# await browser.close()
# kernel.browsers.delete_by_id(kernel_browser.session_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

You can uncomment this browser deletion there.

asyncio.run(main())
````
```typescript Stagehand v3
Copy link
Contributor

Choose a reason for hiding this comment

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

For Stagehand v3 section I would def mention the two necessary added params you have to add to your Stagehand config:

  downloadsPath: DOWNLOAD_DIR,
  acceptDownloads: true,

Comment on lines 315 to 321
console.log("Download triggered");

const downloadedFile = files[0];
console.log(`File found: ${downloadedFile.name}`);

// Wait for the file to be fully available via Kernel's File I/O APIs
console.log(`Waiting for file: ${downloadedFile.name}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there may be some code missing here about the downloadedFile?

removed duplicate language from playwright section
Update formatting + remove config addition step in code snippet for stagehand v3
- Moved playwright specific callout to the end of the code snippets in Playwright section
-  Added formatting changes for typescript code snippets
Copy link
Contributor

@dprevoznik dprevoznik left a comment

Choose a reason for hiding this comment

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

LGTM!

@dprevoznik dprevoznik merged commit a0d741b into main Dec 7, 2025
1 check passed
@dprevoznik dprevoznik deleted the feat/improve-io-docs branch December 7, 2025 20:16
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.

3 participants