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

@@ -17,7 +17,7 @@ from pathlib import Path
from typing import Any, Dict, List, Optional, Sequence, Tuple
from urllib.parse import urlsplit, quote, urljoin, unquote
from SYS.logger import log, debug
from SYS.logger import log, debug, is_debug_enabled
from API.HTTP import HTTPClient
from SYS.pipeline_progress import PipelineProgress
from SYS.utils import ensure_directory, unique_path, unique_preserve_order
@@ -27,6 +27,7 @@ Cmdlet = sh.Cmdlet
CmdletArg = sh.CmdletArg
SharedArgs = sh.SharedArgs
create_pipe_object_result = sh.create_pipe_object_result
coerce_to_pipe_object = sh.coerce_to_pipe_object
normalize_result_input = sh.normalize_result_input
should_show_help = sh.should_show_help
get_field = sh.get_field
@@ -592,13 +593,33 @@ def _capture(
}
})
tool.debug_dump()
if is_debug_enabled():
try:
from rich.table import Table
from rich import box
t = Table(title="Screenshot Config", show_header=True, header_style="bold magenta", box=box.ROUNDED)
t.add_column("Property", style="cyan")
t.add_column("Value", style="green")
t.add_row("URL", options.url)
t.add_row("Format", _normalize_format(options.output_format))
# Browser details
defaults = getattr(tool, "defaults", None)
if defaults:
t.add_row("Browser", getattr(defaults, "browser", "unknown"))
t.add_row("Headless", str(getattr(defaults, "headless", "unknown")))
t.add_row("Viewport", f"{getattr(defaults, 'viewport_width', '?')}x{getattr(defaults, 'viewport_height', '?')}")
t.add_row("Timeout", f"{getattr(defaults, 'navigation_timeout_ms', '?')}ms")
t.add_row("Full Page", str(options.full_page))
t.add_row("Destination", str(destination))
debug(t)
except Exception:
pass
debug("Launching browser...")
format_name = _normalize_format(options.output_format)
headless = options.headless or format_name == "pdf"
debug(f"[_capture] Format: {format_name}, Headless: {headless}")
if format_name == "pdf" and not options.headless:
warnings.append(
"pdf output requires headless Chromium; overriding headless mode"
@@ -1129,6 +1150,8 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
is_temp=True,
parent_hash=hashlib.sha256(url.encode()).hexdigest(),
tag=merged_tags,
url=url, # Explicitly map url to top-level PipeObject field
source_url=url, # Map source_url as well
extra={
"source_url": url,
"archive_url": screenshot_result.archive_url,
@@ -1141,6 +1164,24 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
pipeline_context.emit(pipe_obj)
all_emitted.append(pipe_obj)
# Debug: show PipeObject preview if enabled
if is_debug_enabled():
try:
debug("[screen-shot] Output PipeObject preview")
po = coerce_to_pipe_object(pipe_obj)
from SYS.logger import _sanitize_pipe_object_for_debug as _sanitize # Or use helper if avail
# Add simple sanitize helper if not available
def _safe_table(obj):
try:
# Try calling debug_table on the object
if hasattr(obj, "debug_table"):
obj.debug_table()
except Exception:
pass
_safe_table(po)
except Exception:
pass
# If we created a local progress UI, advance it per completed item.
progress.on_emit(pipe_obj)