HQ can send push notifications to the web app on a phone or desktop, so they arrive even
when HQ is closed. HQ itself, and any agent that reaches HQ over MCP, sends one with the
notify_owner tool. Approvals waiting on you are pushed too.
Push is off until you turn it on.
Turning it on
-
In
~/.hq/config.yaml:web_push: enabled: true subject: "mailto:admin@example.com" # how push services can reach youRestart the server (
hq webor the daemon). On first start it creates a VAPID key at.vault/_data/web_push_vapid.p8, readable by the owner only. -
Open HQ in the browser you want notified, go to Notifications and press Turn on push. Allow notifications when the browser asks, then press Test.
Each browser or device turns push on for itself. Turning it off on one leaves the others on.
What it needs
- HTTPS. Browsers only offer push to a secure page. A tailnet name such as
https://hq.example.ts.networks, and so doeshttp://localhost. Plain HTTP on a LAN address does not. - iPhone and iPad. Push works only for HQ added to the Home Screen (Share, then Add to Home Screen) on iOS 16.4 or later. Open it from the Home Screen icon, then turn push on.
- Outbound HTTPS from the server to the push services:
fcm.googleapis.com(Chrome, Edge on Android, most Chromium browsers),web.push.apple.com(Safari),updates.push.services.mozilla.com(Firefox) and*.notify.windows.com(Edge on Windows). Underprofile: liteaddweb-pushtolite.allow_egress, or the server refuses to start.hq doctor --egresslists it.
Settings
| Key | Default | Meaning |
|---|---|---|
web_push.enabled |
false |
Turns push on. |
web_push.subject |
first https entry of web_allowed_origins, else mailto:hq@localhost |
VAPID contact, a mailto: or https: URL. Apple refuses pushes without a real one, so set it if you use Safari. |
web_push.push_all |
false |
Push every new inbox item. Off: only notify_owner items and items waiting on an answer (approvals). |
web_push.max_agent_per_hour |
20 |
notify_owner calls allowed per rolling hour, across all agents. |
web_push.extra_push_hosts |
[] |
Push services to accept besides the four above. |
Sending one
From HQ’s own chat, a /watch, or any MCP client (hq_call with notify_owner):
{
"title": "Deploy finished",
"body": "v1.4 is live on the VPS. Smoke tests passed.",
"link": "/tasks",
"dedup_key": "deploy-v1.4",
"channels": "web"
}
titleis required, at most 120 characters. The push shows the title only; the body stays in the inbox (see “What a push says” below).linkopens a page of the web app on tap: a path such as/tasks,/notificationsor/chat?thread=<id>. Full URLs are refused, and the service worker refuses any other origin too, so a notification can never send you off-site.dedup_keydrops a repeat while an item with the same key is still in the inbox, or after you dismissed it. Put the date or version in it for events that recur.- It never goes to a chat. Telegram and Discord carry chat only, never notifications.
The tool writes the inbox row and nothing else. Every HQ process shares the vault
database, so hq mcp (stdio), the /mcp endpoint and the daemon can all call it; the web
server picks the row up within a few seconds and pushes it.
How it works
crates/hq-tools/src/notify.rs: thenotify_ownertool. It writes avalue_itemsrow with sourceagent_notifyand the optionallink.crates/hq-web/src/web_push/: the server end.vapid.rsholds the P-256 key and signs a short-lived ES256 token per push (RFC 8292).encrypt.rsencrypts each payload for one browser (RFC 8291,aes128gcm), so the push service relays it without being able to read it.mod.rsis the dispatcher. Every 3 seconds it takes new inbox items (claiming each in the database, so two server processes never push it twice), and posts them to every subscription that receives that kind (needsorupdates). Items older than an hour are never pushed, so a server that was down does not replay a backlog. A subscription the push service reports gone (404 or 410) is deleted, and one that fails 5 times in a row is dropped.api.rsservesGET /api/notifications/push(on/off and the public key) andPOST .../subscribe,.../unsubscribeand.../test, behind the web token. A subscription must point at a known push service over https, so the server never posts to an address a client made up.
crates/hq-db/src/push_subscriptions.rsandsql/088_web_push.sql: the subscriptions table, and thelinkandpushed_atcolumns onvalue_items.sql/111_push_kinds.sqladdskinds(defaultneeds,updates) anddetails(default off).
What a push says
The server builds every push’s words, so no browser, old service worker or push service ever receives an item’s content. A push has no buttons: a browser cannot check a screen lock, so anyone holding the device could press one.
- Something that needs you: “{Helper} needs your OK” (or “HQ needs your OK”) and “Open HQ to see what it wants to do.” A task: “A task needs your OK”, never the task’s name. A helper stuck at a prompt: “A helper is stuck” and “Open HQ to see which one.”
- A new sign-in: “A new sign-in to your HQ” and “Open HQ to see it.”
- An update, such as
notify_owner: its title, with no body. - With
detailson for a subscription, the body is the item’s own first line, at most 120 characters, never a command.
Tapping opens the item’s page. Answer in HQ: the phone app and the web app answer through
POST /api/notifications/{id}/answer with the web token and the X-HQ-Client header.
The service worker folds a busy lock screen: past the newest five Needs you notifications, one reads “{N} more waiting for you”; a fourth update within an hour folds them into “{N} updates from HQ”. When a browser subscribes again, or turns a kind back on, each item of that kind still waiting is pushed to it once.
apps/hq-web/src/lib/webPush.ts,components/notifications/PushToggle.tsxandsw.ts: subscribing in the browser, the toggle, and the service worker’spushhandler. On every start the app re-sends its subscription, so the server keeps it after a browser rotates it.
Privacy
The payload (the fixed words above, the link and a tag) is encrypted end to end. Google, Apple, Mozilla or Microsoft see when a push is sent and roughly how big it is, not what it says.
Deleting .vault/_data/web_push_vapid.p8 makes a new key on the next start. Every
existing subscription then stops working; each device re-subscribes the next time HQ is
opened on it.
Troubleshooting
- Notifications page says push is off on the server:
web_push.enabledis not set, or the server could not load its key (see the startup log lineweb push not enabled). - Test says the push was not delivered: the error comes from the push service. A 403 usually means the key changed since the device subscribed: turn push off and on again. A connection error means the server cannot reach the push service.
- Nothing arrives on iPhone: HQ must be opened from the Home Screen, and
web_push.subjectmust be set to a realmailto:orhttps:address. - Chat replies: a finished chat reply still alerts only while the page is running
(
apps/hq-web/src/lib/replyAlerts.ts). Ask HQ tonotify_ownerwhen a long job is done if you want it on a closed phone.
Who a push is for
A push is sent only for items whose audience is the owner (hq_db::inbox_prefs::audience, see
docs/security/OWNER_APPROVAL.md). Helper and agent traffic is never pushed, including when
push_all is on.
Quiet hours and the daily budget
web_push:
quiet_hours_utc: "22:00-07:00" # nothing is pushed in this window (UTC, wraps midnight); unset: none
non_urgent_per_day: 5 # pushes a day for items that are not urgent
Urgent items are approvals, notify_owner messages and due reminders. They are not limited by the
budget; during quiet hours they wait and go out when the period ends. Everything else folds into at
most one push an hour and stops at non_urgent_per_day. What is folded or over budget stays in the
inbox and on the badge. Push is off by default (web_push.enabled).