feat: add support for saving screenshots to disk with reusable handles#145
Conversation
|
Warning Review limit reached
More reviews will be available in 34 minutes and 1 second. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThe PR adds a ChangesScreenshot save-to-disk flow
Sequence Diagram(s)sequenceDiagram
participant Agent as agent.ts
participant ScreenshotResult as screenshot result
participant DownloadStore as storeDownload
participant TestSuite as agent.spec.ts
Agent->>ScreenshotResult: extract base64 and mimeType
Agent->>DownloadStore: store screenshot bytes with sessionId
DownloadStore-->>Agent: saved handle or URL
TestSuite->>Agent: verify disk and URL formatting
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/tools/agent.spec.ts (1)
212-277: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd one batch-level regression test for
toDisk.These cases only hit
formatScreenshotToDisk()directly, so they won't catch formatter bugs in the fullbrowserless_agentflow. Please add a tool-level case for something like[screenshot { toDisk: true }, close]so the save-to-disk path stays covered end to end.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/tools/agent.spec.ts` around lines 212 - 277, Add a batch-level regression test in the browserless agent flow to cover the save-to-disk path end to end, since the current coverage only exercises formatScreenshotToDisk directly. Update the relevant batch/tool test around browserless_agent handling of screenshot with toDisk enabled, using a sequence like screenshot with toDisk: true followed by close, and assert the returned output includes the disk-save path behavior. Keep the existing formatScreenshotToDisk unit tests, but add this higher-level case so formatter regressions are caught through the full tool pipeline.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/tools/agent.ts`:
- Around line 723-748: The screenshot-to-disk branch in agent.ts is using a
different command source than the `last` result when a batch ends with `close`,
so the `toDisk` check can miss the final screenshot command. Update the logic
around `last`, `lastCmd`, and `formatScreenshotToDisk` to derive both the result
and command from the same pre-close filtered list, then add a regression test
for a batch like `screenshot { toDisk: true }` followed by `close` to verify the
saved-download handle is returned.
---
Nitpick comments:
In `@test/tools/agent.spec.ts`:
- Around line 212-277: Add a batch-level regression test in the browserless
agent flow to cover the save-to-disk path end to end, since the current coverage
only exercises formatScreenshotToDisk directly. Update the relevant batch/tool
test around browserless_agent handling of screenshot with toDisk enabled, using
a sequence like screenshot with toDisk: true followed by close, and assert the
returned output includes the disk-save path behavior. Keep the existing
formatScreenshotToDisk unit tests, but add this higher-level case so formatter
regressions are caught through the full tool pipeline.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 99f915f8-fd33-44b9-aaa5-937cc9f8ed18
📒 Files selected for processing (5)
src/skills/file-transfers.mdsrc/skills/screenshots.mdsrc/tools/agent.tssrc/tools/schemas.tstest/tools/agent.spec.ts
🤖 I have created a release *beep* *boop* --- ## [1.8.0](v1.7.2...v1.8.0) (2026-06-25) ### Features * add support for saving screenshots to disk with reusable handles ([#145](#145)) ([2ff2903](2ff2903)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: browserless-actions-bot[bot] <186328842+browserless-actions-bot[bot]@users.noreply.github.com>
Summary
Allows saving and reusing screenshots via the upload/download mechanism.
Related issues
Closes AUTO-185
Changes
Test plan
npm testpasses locallynpm run lintpasses locallynpm run coveragethresholds still metChecklist
Summary by CodeRabbit