Skip to content

Add open_viewer to NotteSession.__init__#790

Open
mendral-app[bot] wants to merge 2 commits into
mainfrom
mendral/fix-open-viewer-local-session
Open

Add open_viewer to NotteSession.__init__#790
mendral-app[bot] wants to merge 2 commits into
mainfrom
mendral/fix-open-viewer-local-session

Conversation

@mendral-app
Copy link
Copy Markdown

@mendral-app mendral-app Bot commented Apr 27, 2026

Summary

  • Fix: notte.Session(open_viewer=...) raises ValidationError: Extra inputs are not permitted for local sessions because open_viewer is not a field of SessionStartRequest. This adds open_viewer: bool = False as an explicit keyword parameter to NotteSession.__init__ (matching RemoteSession.__init__) so it is consumed before **data is passed to SessionStartRequest.model_validate().
  • Impact: Fixes test_root_level_scripts[cli_agent.py] and test_root_level_scripts[quickstart.py] which both call notte.Session(open_viewer=open_viewer).

Details

RemoteSession.__init__ already handles open_viewer as an explicit parameter. NotteSession.__init__ was missing it, so the kwarg leaked into **data and caused Pydantic to reject it. The fix is a single line addition to the function signature.


Insight: open_viewer breaks local Session in nightly examples


Note

Created by Mendral. Tag @mendral-app with feedback or questions.

NotteSession.__init__ passes all **data kwargs to
SessionStartRequest.model_validate(), but open_viewer is not a field of
SessionStartRequest. This causes a Pydantic ValidationError when
examples like cli_agent.py and quickstart.py call
notte.Session(open_viewer=...).

Add open_viewer as an explicit keyword parameter (matching
RemoteSession.__init__) so it is consumed before **data reaches
model_validate().
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 27, 2026

Greptile Summary

This PR fixes a ValidationError raised when open_viewer is passed to NotteSession (local session) by adding open_viewer: bool = False as an explicit keyword parameter to NotteSession.__init__, matching the pattern already used in RemoteSession. A parametrized regression test is also included. The parameter is intentionally unused in the local session body — it is silently dropped, since live-viewer functionality only applies to remote sessions.

Confidence Score: 5/5

Safe to merge — minimal, targeted fix with a regression test added.

Single-line fix to an explicit parameter shadowing issue, directly mirrors the existing RemoteSession pattern, and the new test covers both True and False cases. No logic changes, no security implications, no edge cases unaddressed.

No files require special attention.

Important Files Changed

Filename Overview
packages/notte-browser/src/notte_browser/session.py Adds open_viewer: bool = False to NotteSession.__init__ signature so it is consumed before **data reaches SessionStartRequest.model_validate(), matching the pattern already used in RemoteSession.
tests/test_session.py Adds a parametrized regression test (test_open_viewer_does_not_raise_validation_error) for both open_viewer=True and open_viewer=False, addressing the previously noted missing test coverage for this bug fix.

Reviews (2): Last reviewed commit: "test: add regression test for open_viewe..." | Re-trigger Greptile

persona: BasePersona | None = None,
window: BrowserWindow | None = None,
keep_alive: bool = False,
open_viewer: bool = False,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 No test added for this bug fix

This PR fixes a real bug (ValidationError when passing open_viewer to a local session) but adds no unit or integration test. Per the repository's test guidelines, at least one integration test is required for every bug fix. A minimal test that constructs NotteSession(open_viewer=True) or NotteSession(open_viewer=False) and verifies no ValidationError is raised would cover this path and prevent regression.

Context Used: # Test guidelines

  • Add a comment if the PR does n... (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/notte-browser/src/notte_browser/session.py
Line: 132

Comment:
**No test added for this bug fix**

This PR fixes a real bug (`ValidationError` when passing `open_viewer` to a local session) but adds no unit or integration test. Per the repository's test guidelines, at least one integration test is required for every bug fix. A minimal test that constructs `NotteSession(open_viewer=True)` or `NotteSession(open_viewer=False)` and verifies no `ValidationError` is raised would cover this path and prevent regression.

**Context Used:** # Test guidelines
- Add a comment if the PR does n... ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))

How can I resolve this? If you propose a fix, please make it concise.

Fix in Claude Code

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added a parametrized regression test (test_open_viewer_does_not_raise_validation_error) that constructs NotteSession(open_viewer=True) and NotteSession(open_viewer=False), verifying no ValidationError is raised. CI is green.

Verify that NotteSession(open_viewer=True/False) does not raise a
Pydantic ValidationError, covering the fix from the previous commit.
@mendral-app mendral-app Bot marked this pull request as ready for review April 27, 2026 07:17
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.

0 participants