Skip to content

No Windows system notification when a session finishes or the agent needs user input #431

Description

@xiaoqinxing

Title: No Windows system notification when a session finishes or the agent needs user input

Describe the problem
When a pi-web session finishes, or when the agent is blocked waiting for user
input (extension dialogs such as confirm/select/input/editor, or a pending
prompt awaiting approval), no system notification is shown on Windows. The user
must keep watching the tab.

Steps to reproduce

  1. Run pi-web on Windows (Edge/Chrome), grant notification permission.
  2. Start a task, then switch to another window (e.g. VS Code) while keeping the
    pi-web tab visible (not minimized, not backgrounded as a tab).
  3. When the session completes → no Windows toast appears.

For input prompts:

  1. Trigger an extension dialog (confirm/select/input) or a prompt that requires
    approval.
  2. Switch to another window → only an in-page dialog + sound plays, no
    Windows toast.

Root cause

  • components/AppShell.tsx handleAgentEnd returns early when
    document.visibilityState === "visible". Being covered by another window
    (blurred but visible tab) never fires the notification.
  • There is no notification at all for pending user input: extension dialogs
    (setExtensionDialog in hooks/useAgentSession.ts) and agent prompts
    (isPromptRunning) are in-page only.

Expected behavior

  • Fire a Windows toast (Web Notification via the existing
    showCompletionNotification helper) whenever the window/tab is not focused
    (!document.hasFocus()), not just when hidden.
  • Fire a toast when the agent needs user input (extension dialog or pending
    prompt), e.g. title "Pi needs your attention", clicking it focuses the
    window and scrolls to the dialog.
  • If permission is denied, surface an in-app hint directing users to enable
    notifications for the site (or prompt to install the PWA).

Suggested implementation

  • Replace the visibility check with document.hasFocus() in handleAgentEnd.
  • Add an onAttentionNeeded callback (mirroring onAgentEnd /
    wrappedOnAgentEnd in components/ChatWindow.tsx) fired from
    handleExtensionUiRequest (confirm/select/input/editor) and when
    isPromptRunning transitions to true.
  • Optionally, a server-side native toast route (e.g. node-notifier or a
    PowerShell WinRT toast) for a fully native, browser-independent popup.

Environment: pi-web 0.8.6, Windows 10/11, Edge/Chrome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions