Skip to content

Conversation

@atharvadeosthale
Copy link
Member

@atharvadeosthale atharvadeosthale commented Jan 26, 2026

Summary by CodeRabbit

  • Documentation
    • Added a comprehensive blog post on screenshot best practices, covering how to stop real-time regeneration, persist screenshots to storage, map URLs to file identifiers, implement smart refresh strategies (time-based expiration and on-demand), choose optimal formats and sizes, handle dynamic content (including sleep strategies), and general recommendations for building robust screenshot workflows.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 26, 2026

Walkthrough

A new documentation page was added at src/routes/blog/post/screenshots-best-practices/+page.markdoc (~279 added lines). The file contains front-matter and a multipart article covering stopping realtime regeneration, persisting screenshots in storage, URL-to-file-id tracking, refresh strategies (time-based expiration and on-demand), format and size selection, handling dynamic content (sleep), and final guidelines. No executable code, tests, or public/exported API declarations were modified.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and directly describes the main change: adding a blog post about best practices for handling screenshots in applications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@atharvadeosthale
Copy link
Member Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 26, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Adds a new blog post documenting best practices for efficiently capturing, storing, and refreshing webpage screenshots in an app.

Changes:

  • Added a new Markdoc blog post: “Best practices for handling screenshots in your app”
  • Included code examples for persistence (Storage), lookup (TablesDB), refresh strategies, and screenshot parameter tuning

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

}

// Screenshot expired, regenerate and update the row
const newFileId = await captureAndStore(url);
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

This TTL refresh example calls captureAndStore(url), but that helper isn’t defined anywhere in the post. Define it (e.g., as the screenshot capture + Storage upload logic) or replace this call with an existing helper shown earlier.

Suggested change
const newFileId = await captureAndStore(url);
const newFileId = await createScreenshot(url);

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

@atharvadeosthale where is this function called from?

}

// No existing screenshot, create new one
return await createScreenshot(url);
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

This function returns createScreenshot(url), but createScreenshot isn’t defined anywhere in the post. Either define it or reuse the earlier screenshot creation logic so the snippet is complete.

Suggested change
return await createScreenshot(url);
const fileId = await captureAndStore(url);
return storage.getFileView('screenshots', fileId);

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

atharvadeosthale and others added 2 commits January 27, 2026 15:06
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@src/routes/blog/post/screenshots-best-practices/`+page.markdoc:
- Around line 74-79: The snippet uses client but never defines it; add a brief
initialization before using Client/Storage/TablesDB/Avatars (e.g., create and
configure a Client instance and assign it to the variable client) or add a
one-line note that client is assumed to be defined earlier; ensure the symbol
client is present and configured before the lines referencing new
Storage(client), new TablesDB(client), and new Avatars(client) so the snippet
can be copied and run independently.
- Around line 121-153: The example uses undefined helper functions
captureAndStore and createScreenshot in getScreenshot, making the snippet
non-runnable; add brief placeholder implementations or a clarifying note.
Specifically, either add short helper descriptions or minimal implementations
for captureAndStore(url) and createScreenshot(url) (and ensure they return a
fileId or call storage.getFileView as used), or prepend a comment to the
getScreenshot example stating these are stubs/placeholders that must be
implemented (referencing the function name getScreenshot so readers can locate
it). Ensure the helpers' return shapes match the rest of the snippet (fileId or
storage view) so the updateRow and storage.getFileView calls work.
🧹 Nitpick comments (1)
src/routes/blog/post/screenshots-best-practices/+page.markdoc (1)

255-264: Add a server-side safety note for auth headers.

The Authorization/Cookie headers example should explicitly state this must be executed server-side (to avoid exposing secrets, and because browsers block setting the Cookie header). A short caution line would prevent misuse.

💡 Suggested addition
+// Run this server-side; do not expose tokens or cookies in client-side code.
 const authenticatedScreenshot = avatars.getScreenshot({

}

// Screenshot expired, regenerate and update the row
const newFileId = await captureAndStore(url);
Copy link
Member

Choose a reason for hiding this comment

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

@atharvadeosthale where is this function called from?

}

// No existing screenshot, create new one
return await createScreenshot(url);
Copy link
Member

Choose a reason for hiding this comment

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

});
```

For pages with heavy JavaScript, 2-3 seconds is usually sufficient. For simple static pages, you can skip the delay entirely.
Copy link
Member

Choose a reason for hiding this comment

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

We should improve that first part and include a mention of loading

Also, pages with heavy JavaScript is a little too informal

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

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


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

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