feat(approvals): gate push Approve/Deny buttons on the opt-in setting too

One switch now governs the whole feature: with approvalsInboxEnabled off
(the default), sendPushNotifications strips the actions and approvalId
from permission push payloads, so the buttons no longer render at all
(pre-inbox they rendered and did nothing). The page-side action relay is
gated the same way for stale notifications sent before the toggle
flipped. Only the store and answer endpoints keep running, so enabling
the toggle surfaces anything already pending immediately.

sendPushNotifications is async now (cached settings read); all call
sites were already fire-and-forget. Covered by three new payload tests
alongside the existing hostTitle suite.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer
2026-08-09 16:03:27 +02:00
parent 6c744f8677
commit 338f0e460d
6 changed files with 106 additions and 24 deletions
+4 -2
View File
@@ -126,10 +126,12 @@ Object.assign(CodemanApp.prototype, {
/**
* Push-notification action relay (sw.js → settings-ui notification-click →
* here). Falls back to opening the session when the item is unknown.
* here). Falls back to opening the session when the item is unknown, or
* when the inbox is disabled (a stale notification from before the toggle
* flipped can still carry an action).
*/
handleNotificationAction(action, approvalId, sessionId) {
if ((action === 'approve' || action === 'deny') && approvalId) {
if ((action === 'approve' || action === 'deny') && approvalId && this.approvalsInboxEnabled()) {
this.answerApproval(approvalId, action);
return;
}