close_preview_tool.py 724 B

123456789101112131415
  1. """Close the Hermes desktop GUI's preview pane, or one tab (``preview.close``).
  2. Registration lives in `desktop_preview`. The renderer drops the matching tab — or
  3. the whole pane when no url is given — only for the window that asked."""
  4. from tools import desktop_ui
  5. from tools.open_preview_tool import _normalize_target
  6. def close_preview_tool(url: str = "") -> str:
  7. """Ask the desktop GUI to close the preview pane, or the tab for ``url``."""
  8. target = _normalize_target(url or "")
  9. return desktop_ui.emit_or_error(
  10. "preview.close", {"url": target}, "Failed to close the preview pane: ",
  11. "The preview pane is only available in the Hermes desktop app.", {"success": True, "url": target},
  12. )