Feat: Replay saving functionality added and readme polished.#618
Feat: Replay saving functionality added and readme polished.#618Sameersribot wants to merge 3 commits intonottelabs:mainfrom
Conversation
WalkthroughThis pull request adds replay and execution highlighting features to the Notte browser automation library. The changes introduce three class-level constants and three new methods to Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–25 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/examples/Interaction-overlay.py (1)
7-7: Add space after # in comments.Python style guidelines recommend a space after
#in comments for better readability.Apply this diff:
-#There was a clash with the local session.py file and the virtual env file +# There was a clash with the local session.py file and the virtual env fileAnd:
- #Use save_replay_to in Session method to save the screenshots WebP file at the specified location. + # Use save_replay_to in Session method to save the screenshots WebP file at the specified location.Also applies to: 48-48
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
📒 Files selected for processing (4)
README.md(2 hunks)packages/notte-browser/src/notte_browser/session.py(7 hunks)tests/examples/Interaction-overlay.py(1 hunks)tests/integration/sdk/test_steps.py(1 hunks)
🧰 Additional context used
🪛 Ruff (0.14.3)
tests/examples/Interaction-overlay.py
51-51: Local variable response is assigned to but never used
Remove assignment to unused variable response
(F841)
packages/notte-browser/src/notte_browser/session.py
252-252: Do not catch blind exception: Exception
(BLE001)
402-402: Do not catch blind exception: Exception
(BLE001)
488-488: Do not catch blind exception: Exception
(BLE001)
🔇 Additional comments (11)
tests/integration/sdk/test_steps.py (1)
45-45: LGTM! Typo corrected.The comment typo has been fixed appropriately.
README.md (2)
58-59: LGTM! Helpful setup guidance added.The preface note about
.env.examplewill help users configure their environment correctly before running examples.
75-75: LGTM! SDK switch instruction clarified.The updated wording ("replace the
notteimport withnotte_sdk") is clearer and more accurate than the previous "import prefix" phrasing.tests/examples/Interaction-overlay.py (1)
9-41: LGTM! Bootstrap logic enables local development workflow.The bootstrap function correctly prioritizes local package sources over virtualenv installations by manipulating
sys.pathand clearing cached modules. This is a useful pattern for testing local changes.packages/notte-browser/src/notte_browser/session.py (7)
77-79: LGTM! Well-defined execution highlight constants.The class-level constants provide clear configuration for the visual highlight feature with reasonable default values.
92-92: LGTM! Replay save path parameter added correctly.The
save_replay_toparameter is properly typed, documented through the PR context, and safely converted to aPathobject when provided.Also applies to: 114-114
160-163: LGTM! Safer teardown pattern with replay persistence.Using a local variable for the window reference before closing is a defensive practice. The replay save happens after window closure, ensuring all trajectory data is captured.
227-242: LGTM! Well-implemented replay persistence.The method has a clear docstring, automatically creates parent directories, and returns the saved path for confirmation.
244-254: LGTM! Robust error handling for best-effort replay saving.The method appropriately catches specific
ValueErrorfor empty trajectories and uses a broad exception handler for unexpected failures during the optional replay save. The logging provides useful feedback without disrupting the session close flow.
392-504: LGTM! Comprehensive visual highlight implementation.The method is well-structured with:
- Early returns for non-applicable cases (lines 393-399)
- Robust error handling for element location and evaluation (lines 400-409, 488-495)
- Defensive sleep cap using
min()(line 498)- Clean JavaScript overlay with proper lifecycle management (scroll, render, fade, cleanup)
The broad exception handlers at lines 402 and 488 are appropriate for this non-critical visual feature, ensuring execution continues even if highlighting fails.
560-560: LGTM! Highlight integrated at the right execution point.Calling
_flash_execution_highlightimmediately after action resolution ensures the visual feedback appears before the action executes, which is the correct user experience.
| def main() -> None: | ||
| load_dotenv() | ||
| #Use save_replay_to in Session method to save the screenshots WebP file at the specified location. | ||
| with notte.Session(headless=False, save_replay_to=r".\replays\rp.webp") as session: | ||
| agent = notte.Agent(session=session, reasoning_model="gemini/gemini-2.5-flash", max_steps=30) | ||
| response = agent.run(task="go to google and search for plujss and select the second dropdown suggestion") | ||
|
|
||
| if __name__ == "__main__": | ||
| main() |
There was a problem hiding this comment.
Remove unused variable assignment.
The response variable is assigned but never used. Either utilize it or remove the assignment to clean up the code.
Apply this diff to remove the unused assignment:
- response = agent.run(task="go to google and search for plujss and select the second dropdown suggestion")
+ _ = agent.run(task="go to google and search for plujss and select the second dropdown suggestion")🧰 Tools
🪛 Ruff (0.14.3)
51-51: Local variable response is assigned to but never used
Remove assignment to unused variable response
(F841)
🤖 Prompt for AI Agents
In tests/examples/Interaction-overlay.py around lines 46 to 54, the local
variable `response` is assigned the result of `agent.run(...)` but never used;
remove the unused assignment or make use of the returned value. Fix by either
deleting the `response =` assignment and calling `agent.run(...)` directly, or
replace it with a short use (for example logging/printing or passing it to an
assertion) so the value is consumed.
🆕 Feature: Replay Saving Functionality Added
Summary
This merge adds support for saving session replays as WebP animations directly through the Session class.
A new argument save_replay_to has been introduced to automatically save the replay when a session ends.
The README has also been refined for clarity and developer guidance.
save_replay_to defines the output path (must end with .webp).
When the session finishes, its entire trajectory (screenshots + actions) is automatically saved to the given file.
If the directory doesn’t exist, it will be created automatically.
Impact
Simplifies recording and debugging of interactive sessions.
Allows developers to store visual replays for sharing, analysis, or QA workflows.
Summary by CodeRabbit
Documentation
New Features