Skip to content

fix: send push notifications for permission requests when user is not focused#1765

Open
thaning0 wants to merge 1 commit into
getpaseo:mainfrom
thaning0:fix/permission-push-notification
Open

fix: send push notifications for permission requests when user is not focused#1765
thaning0 wants to merge 1 commit into
getpaseo:mainfrom
thaning0:fix/permission-push-notification

Conversation

@thaning0

Copy link
Copy Markdown
Contributor

Closes #1764

Problem

When an agent asks the user a question (permission request), Paseo suppresses push notifications if any client was active within 180 seconds — even if the user is on a different page and won't see the in-app dialog.

Fix

Add a skipPresence parameter to computeNotificationPlan. For permission reason, skip the 180s presence window. The focus check (appVisible && focusedAgentId === agent.id) still applies: no push if the user is literally looking at the agent.

Changes

  • agent-attention-policy.ts: Add optional skipPresence flag. When true, all clients are treated as absent regardless of recent activity.
  • websocket-server.ts: Pass skipPresence: params.reason === "permission" to computeNotificationPlan.

@greptile-apps

greptile-apps Bot commented Jun 27, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a UX gap where push notifications for permission requests were suppressed whenever any client had been active within the last 180 seconds, even if the user was on a completely different page and wouldn't see the in-app dialog.

  • agent-attention-policy.ts: Adds an optional skipPresence flag to computeNotificationPlan. When true, the 180-second presence window is ignored and the function takes an early path that only checks whether any client has the target agent focused and visible — returning shouldPush: false only in that case, and shouldPush: pushEligible otherwise.
  • websocket-server.ts: Passes skipPresence: params.reason === \"permission\" at the single call site, wiring the new behavior exclusively for permission-reason notifications.

Confidence Score: 5/5

The change is safe to merge. The focus guard is correctly evaluated before the early return in the skipPresence branch, so a user who has the agent actively visible will still not receive a push notification.

The skipPresence early-return path correctly places the focus check first, matching the stated invariant in the PR description. The logic is minimal and self-contained, with no side effects on the existing presence-window path.

No files require special attention. The only follow-up is adding tests for the new skipPresence branch in agent-attention-policy.test.ts.

Important Files Changed

Filename Overview
packages/server/src/server/agent-attention-policy.ts Adds skipPresence optional param that bypasses the 180s presence window; the focus guard is correctly placed before the early return so a focused+visible client still suppresses push.
packages/server/src/server/websocket-server.ts Single-line integration: passes skipPresence: params.reason === 'permission' to computeNotificationPlan; clean and minimal.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[computeNotificationPlan called] --> B{skipPresence?}
    B -- Yes --> C[Loop through allStates]
    C --> D{appVisible AND focused on agent?}
    D -- Yes --> E[return shouldPush false]
    D -- No --> F[Continue to next state]
    F --> G{More states?}
    G -- Yes --> C
    G -- No --> H[return shouldPush = pushEligible]
    B -- No --> I{Client present within 180s?}
    I -- No --> J[Skip client]
    I -- Yes --> K{appVisible AND focused on agent?}
    K -- Yes --> E
    K -- No --> L[Track as most-recent present client]
    L --> M{Most-recent present exists?}
    M -- Yes --> N[return inAppRecipient = index, shouldPush false]
    M -- No --> O[return shouldPush = pushEligible]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[computeNotificationPlan called] --> B{skipPresence?}
    B -- Yes --> C[Loop through allStates]
    C --> D{appVisible AND focused on agent?}
    D -- Yes --> E[return shouldPush false]
    D -- No --> F[Continue to next state]
    F --> G{More states?}
    G -- Yes --> C
    G -- No --> H[return shouldPush = pushEligible]
    B -- No --> I{Client present within 180s?}
    I -- No --> J[Skip client]
    I -- Yes --> K{appVisible AND focused on agent?}
    K -- Yes --> E
    K -- No --> L[Track as most-recent present client]
    L --> M{Most-recent present exists?}
    M -- Yes --> N[return inAppRecipient = index, shouldPush false]
    M -- No --> O[return shouldPush = pushEligible]
Loading

Reviews (2): Last reviewed commit: "fix: send push notifications for permiss..." | Re-trigger Greptile

… focused

Skip the 180s presence window for permission reason. The focus check
(appVisible && focusedAgentId === agent.id) still applies — no push
if the user is literally looking at the agent.

Fixes getpaseo#1764
@thaning0 thaning0 force-pushed the fix/permission-push-notification branch from 81b4a6e to 4545bd2 Compare June 27, 2026 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Push notifications for agent permission requests (not just completion)

1 participant