Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions hermes_cli/dashboard_auth/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
"/ds-assets/",
"/fonts/",
"/fonts-terminal/",
# PWA assets — must be fetchable without a cookie so the OS can load the
# home-screen icon / manifest during "Add to Home Screen" (that fetch
# carries no session cookie). Non-sensitive static files.
"/icons/",
"/manifest.webmanifest",
"/sw.js",
)


Expand Down
49 changes: 34 additions & 15 deletions tui_gateway/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -7058,8 +7058,14 @@ def _(rid, params: dict) -> dict:
if err:
return err

if shutil.which("pdftoppm") is None:
return _err(rid, 5028, "pdftoppm not installed (poppler-utils package required)")
_have_pdftoppm = shutil.which("pdftoppm") is not None
if not _have_pdftoppm:
# Fall back to PyMuPDF (pure-python wheel, no system deps) when
# poppler isn't installed — e.g. macOS without Homebrew.
try:
import fitz # noqa: F401 (PyMuPDF)
except Exception:
return _err(rid, 5028, "pdftoppm not installed and PyMuPDF unavailable (install poppler-utils or `pip install pymupdf`)")

raw_path = str(params.get("path", "") or "").strip()
raw_b64 = str(params.get("content_base64") or params.get("data") or "").strip()
Expand Down Expand Up @@ -7116,22 +7122,35 @@ def _(rid, params: dict) -> dict:
return _err(rid, 4019, f"page range exceeds cap of {_PDF_ATTACH_MAX_PAGES} pages per attach call")

out_prefix = td_path / "page"
argv = [
"pdftoppm", "-png", "-r", "150",
"-f", str(first_page), "-l", str(last_page),
str(pdf_path), str(out_prefix),
]
try:
res = subprocess.run(argv, capture_output=True, text=True, timeout=120, stdin=subprocess.DEVNULL)
except subprocess.TimeoutExpired:
return _err(rid, 5028, "pdftoppm timed out (>120s)")
if res.returncode != 0:
tail = (res.stderr or res.stdout or "").strip().splitlines()[-3:]
return _err(rid, 5028, "pdftoppm failed: " + " | ".join(tail))
if _have_pdftoppm:
argv = [
"pdftoppm", "-png", "-r", "150",
"-f", str(first_page), "-l", str(last_page),
str(pdf_path), str(out_prefix),
]
try:
res = subprocess.run(argv, capture_output=True, text=True, timeout=120, stdin=subprocess.DEVNULL)
except subprocess.TimeoutExpired:
return _err(rid, 5028, "pdftoppm timed out (>120s)")
if res.returncode != 0:
tail = (res.stderr or res.stdout or "").strip().splitlines()[-3:]
return _err(rid, 5028, "pdftoppm failed: " + " | ".join(tail))
else:
# PyMuPDF fallback: render the page range to PNGs using the same
# ``page-NNN.png`` naming the glob below expects.
try:
import fitz
doc = fitz.open(str(pdf_path))
hi = min(last_page, doc.page_count)
for pno in range(first_page, hi + 1):
doc[pno - 1].get_pixmap(dpi=150).save(str(td_path / f"page-{pno:03d}.png"))
doc.close()
except Exception as exc:
return _err(rid, 5028, f"PyMuPDF render failed: {exc}")

rendered = sorted(td_path.glob("page-*.png"))
if not rendered:
return _err(rid, 5028, "pdftoppm produced no pages (corrupt PDF?)")
return _err(rid, 5028, "no pages rendered (corrupt PDF?)")

attached_pages = []
for src in rendered:
Expand Down
9 changes: 8 additions & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, viewport-fit=cover"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"
/>
<link rel="manifest" href="/manifest.webmanifest" />

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This root-absolute manifest URL bypasses an X-Forwarded-Prefix deployment. Current _serve_index rewrites /assets, favicon, fonts, and ds-assets only (hermes_cli/web_server.py:15790-15798); make this URL prefix-aware or extend that rewrite with coverage.

<link rel="apple-touch-icon" href="/icons/apple-touch-icon.png" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="Hermes" />
<meta name="theme-color" content="#0b0f0d" />
<title>Hermes Agent - Dashboard</title>
</head>
<body>
Expand Down
Binary file added web/public/icons/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/icons/icon-192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/icons/icon-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions web/public/manifest.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Hermes Agent",
"short_name": "Hermes",
"description": "Your personal Hermes AI agent.",
"start_url": "/chat",
"scope": "/",
"display": "standalone",
"background_color": "#0b0f0d",
"theme_color": "#0b0f0d",
"orientation": "portrait-primary",
"icons": [
{ "src": "/icons/icon-192.png", "sizes": "192x192", "type": "image/png", "purpose": "any" },
{ "src": "/icons/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any" },
{ "src": "/icons/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" }
]
}
7 changes: 7 additions & 0 deletions web/public/sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Minimal service worker — makes Hermes installable as a PWA without caching
// application code, so dashboard updates (new build hashes after `hermes
// update`) are never served stale. Network requests pass straight through.
self.addEventListener("install", () => self.skipWaiting());
self.addEventListener("activate", (event) => event.waitUntil(self.clients.claim()));
// A fetch handler is required for installability; pass through to the network.
self.addEventListener("fetch", () => {});
14 changes: 10 additions & 4 deletions web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ export default function App() {
<ProfileProvider>
<div
data-layout-variant={layoutVariant}
className="flex h-dvh max-h-dvh min-h-0 flex-col overflow-hidden bg-black text-text-primary antialiased"
className="flex min-h-0 flex-col overflow-hidden bg-[var(--background-base)] text-text-primary antialiased app-shell-root"
>
<SelectionSwitcher />
<Backdrop />
Expand All @@ -492,7 +492,10 @@ export default function App() {
<header
className={cn(
"lg:hidden fixed top-0 left-0 right-0 z-40 min-h-14",
"flex items-center gap-2 px-4 py-2",
// Pad below the iOS status bar when running as an installed PWA
// (standalone mode has no browser chrome). No-op in browsers / on
// devices without a notch (env() resolves to 0).
"flex items-center gap-2 px-4 pb-2 pt-[calc(0.5rem+env(safe-area-inset-top))]",
"border-b border-current/20",
"bg-background-base/90 backdrop-blur-sm",
)}
Expand Down Expand Up @@ -537,7 +540,7 @@ export default function App() {
<PluginSlot name="header-banner" />
<ProfileScopeBanner />

<div className="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden pt-14 lg:pt-0">
<div className="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden pt-[calc(3.5rem+env(safe-area-inset-top))] lg:pt-0">
<div className="flex min-h-0 min-w-0 flex-1">
<aside
id="app-sidebar"
Expand Down Expand Up @@ -720,7 +723,10 @@ export default function App() {
<div
className={cn(
"relative z-2 flex min-w-0 min-h-0 flex-1 flex-col",
"px-3 sm:px-6",
// Chat goes full-bleed on phones (the mobile chat manages its
// own padding); other routes keep side gutters. Desktop keeps
// gutters everywhere.
isChatRoute ? "px-0 sm:px-6" : "px-3 sm:px-6",
isChatRoute
? "pb-0 pt-1 sm:pt-2 lg:pt-4"
: "pt-2 sm:pt-4 lg:pt-6",
Expand Down
Loading