This commit is contained in:
2026-02-10 23:00:30 -08:00
parent c2449d0ba7
commit 5323b7c76f
6 changed files with 192 additions and 104 deletions

View File

@@ -253,76 +253,6 @@ class PlaywrightTool:
)
def config_schema() -> List[Dict[str, Any]]:
"""Return a schema describing editable Playwright tool defaults for the config UI.
Notes:
- `user_agent` is a dropdown with a `custom` option; put the real UA in
`user_agent_custom` when choosing `custom`.
- Viewport dimensions are offered as convenient choices.
- `ffmpeg_path` intentionally defaults to empty; Playwright will consult
a global `FFMPEG_PATH` environment variable (or fallback to bundled/system).
"""
_defaults = PlaywrightDefaults()
browser_choices = ["chromium", "firefox", "webkit"]
viewport_width_choices = [1920, 1366, 1280, 1024, 800]
viewport_height_choices = [1080, 900, 768, 720, 600]
return [
{
"key": "browser",
"label": "Playwright browser",
"default": _defaults.browser,
"choices": browser_choices,
},
{
"key": "headless",
"label": "Headless",
"default": str(_defaults.headless),
"choices": ["true", "false"],
},
{
"key": "user_agent",
"label": "User Agent",
"default": "default",
"choices": ["default", "native", "custom"],
},
{
"key": "user_agent_custom",
"label": "Custom User Agent (used when User Agent = custom)",
"default": "",
},
{
"key": "viewport_width",
"label": "Viewport width",
"default": _defaults.viewport_width,
"choices": viewport_width_choices,
},
{
"key": "viewport_height",
"label": "Viewport height",
"default": _defaults.viewport_height,
"choices": viewport_height_choices,
},
{
"key": "navigation_timeout_ms",
"label": "Navigation timeout (ms)",
"default": _defaults.navigation_timeout_ms,
},
{
"key": "ignore_https_errors",
"label": "Ignore HTTPS errors",
"default": str(_defaults.ignore_https_errors),
"choices": ["true", "false"],
},
{
"key": "ffmpeg_path",
"label": "FFmpeg path (leave empty to use global/bundled)",
"default": "",
},
]
def require(self) -> None:
"""Ensure Playwright is present; raise a helpful RuntimeError if not."""
try:
@@ -635,3 +565,74 @@ def config_schema() -> List[Dict[str, Any]]:
except Exception:
pass
return None
def config_schema() -> List[Dict[str, Any]]:
"""Return a schema describing editable Playwright tool defaults for the config UI.
Notes:
- `user_agent` is a dropdown with a `custom` option; put the real UA in
`user_agent_custom` when choosing `custom`.
- Viewport dimensions are offered as convenient choices.
- `ffmpeg_path` intentionally defaults to empty; Playwright will consult
a global `FFMPEG_PATH` environment variable (or fallback to bundled/system).
"""
_defaults = PlaywrightDefaults()
browser_choices = ["chromium", "firefox", "webkit"]
viewport_width_choices = [1920, 1366, 1280, 1024, 800]
viewport_height_choices = [1080, 900, 768, 720, 600]
return [
{
"key": "browser",
"label": "Playwright browser",
"default": _defaults.browser,
"choices": browser_choices,
},
{
"key": "headless",
"label": "Headless",
"default": str(_defaults.headless),
"choices": ["true", "false"],
},
{
"key": "user_agent",
"label": "User Agent",
"default": "default",
"choices": ["default", "native", "custom"],
},
{
"key": "user_agent_custom",
"label": "Custom User Agent (used when User Agent = custom)",
"default": "",
},
{
"key": "viewport_width",
"label": "Viewport width",
"default": _defaults.viewport_width,
"choices": viewport_width_choices,
},
{
"key": "viewport_height",
"label": "Viewport height",
"default": _defaults.viewport_height,
"choices": viewport_height_choices,
},
{
"key": "navigation_timeout_ms",
"label": "Navigation timeout (ms)",
"default": _defaults.navigation_timeout_ms,
},
{
"key": "ignore_https_errors",
"label": "Ignore HTTPS errors",
"default": str(_defaults.ignore_https_errors),
"choices": ["true", "false"],
},
{
"key": "ffmpeg_path",
"label": "FFmpeg path (leave empty to use global/bundled)",
"default": "",
},
]