feat: add bell notifications #31
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/bell-notifications"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds tmux bell detection without attaching clients to every window, a bell icon in the session list, and Web Push notifications for the installed PWA.
Design: adr/notifications.md.
What changed
Window.bellis read from#{window_bell_flag}in the existinglist-windowscall. No control mode, nopipe-pane, no per-window PTY, no tmux hooks.false -> truetransition for the inventory. The first read is a baseline, so a restart does not replay old flags.pushblock. When the block is present and the key is missing or a placeholder, the first start generates a P-256 key pair, writes it back toconfig.jsonwith mode0600, and logs only that it did so.mux_portal vapid-keysremains for manual generation. The private key is redacted inDebugand never logged.push.subjectis required and must be a real contact URI. A missing or empty subject is a startup error. Apple rejects alocalhostsubject.push-subscriptions.jsonwith mode0600, in$STATE_DIRECTORY(StateDirectory=mux-portal) or next to the config without systemd. They survive a portal restart, so the client does not have to re-register. A state file for a different VAPID key is ignored; the authenticated page still re-registers idempotently as a safety net.web-pushis used with default features off; ECE still needs OpenSSL, so the HTTP client isreqwestwithnative-tlsand the build/host needlibssl.GET /api/treecarriesbell. New routes:GET /api/push,POST/DELETE /api/push/subscribe,POST /api/push/test.generateSWand importspush-handler.jsviaworkbox.importScripts; it handlespush,notificationclickandpushsubscriptionchange, with every URL resolved against the service worker scope.visibilitychange,pagehide,pageshow,freezeandresume, and refreshes it every five seconds while visible. A push is suppressed only when that record is fresh (under fifteen seconds) and the worker also sees a focused, visible client. A backgrounded or closed app still gets notifications when iOS reports a staleWindowClient.StateDirectory=mux-portalfor the state file andReadWritePaths=/etc/mux-portalfor the first-start config rewrite. No startup check formonitor-bell; the Settings card and docs state the requirement.Verification
cargo test --workspace— unit, API, tmux integration, terminal WebSocket, push, watcher, config generation, state persistence and BEL scan tests pass.cargo clippy --workspace --all-targets -- -D warnings— clean.npm run typecheckandnpm run build— clean;push-handler.jsis imported bysw.js.delivered=1); the active-window PTY path was confirmed on the chat window withbg3; a direct push returned201,POST /api/push/testreturned204; the subject change fixed the Apple401/403.c0308db; service active withpush=true; temporary debug logging removed; clean backup under/var/backups/mux-portal-20261104-114939-clean-final.WIP: feat: add bell notificationsto feat: add bell notificationsImplementation is complete and the branch is ready for review.
Checks run:
cargo test --workspace— pass (unit, API, tmux bell integration, terminal WebSocket, push and watcher tests)cargo clippy --workspace --all-targets -- -D warnings— cleannpm run typecheckandnpm run build— clean;push-handler.jsis copied todist/and imported bysw.jspush.enabledwith a public key,bell=trueafterprintf '\\a',bell=falseafterselect-window, and400for an invalid subscriptionStill worth a manual device pass: desktop Chrome, an Android PWA, and an installed iOS 16.4+ PWA (closed app, foreground switch, Send test).
Note:
fj pr status 31currently fails withunknown variant ''while parsing the Forgejo response, so CI status was not checked throughfj.Updated after review: subscriptions now persist in $STATE_DIRECTORY and the VAPID key is generated on the first start and written back to config.json. A portal restart no longer requires re-registration; the client re-registers idempotently only as a safety net. The systemd unit now sets StateDirectory=mux-portal and ReadWritePaths=/etc/mux-portal. All Rust/UI checks and the restart smoke test pass.
Deployment follow-up: Apple Web Push rejected the VAPID
subclaimmailto:mux-portal@localhost(HTTP 401/403), which is the "push service rejected the request" error. The host now usesmailto:a@kosyrev.name; a direct push to the stored Apple subscription returned201 Created, and the serverPOST /api/push/testpath returned204with the same config/state. The VAPID key and subscription were unchanged.Also fixed in
61bc389: a missing or emptypush.subjectis now a startup error instead of defaulting to alocalhostaddress. The host runs the new binary;push=true, subscription persisted, no re-registration.Background delivery fix is in
63bb9c1and deployed to the host. The page writes a foreground/visibility record with a 10 s heartbeat; the service worker suppresses only when that record says foreground and is younger than 30 s. A backgrounded or closed iOS PWA now gets notifications even when the oldWindowClientstate looked focused. Reload/update the PWA once so the new page and service worker are active.Deployed
e935b6awith diagnostics and a more conservative background rule. The host watcher sent two real debug bells and loggeddelivered=1for both, so delivery from the server to Apple works. The Settings card now shows the last push decision and worker version. Please reload the PWA, press Send test to confirm workerbg2, then background the app and ring a bell in a non-current window; report the "Last push" line and the UTC time. Debug logging is temporarily enabled asRUST_LOG=mux_portal=debug; it will be removed after diagnosis.Root cause of the chat case was the tmux active window: tmux does not set
window_bell_flagfor the window the portal client is viewing, and repeated bells in an unread non-viewed window wait for the flag to clear.c0308dbadds a BEL scan over the already-open terminal PTY, so the viewed chat reports every bell; the flag watcher remains the first-unread path for non-viewed windows. Confirmed on the host; debug logging removed.