Skip to content

Add Windows notification support via native toast fallback#50

Open
Chebaleomkar wants to merge 2 commits into
warpdotdev:mainfrom
Chebaleomkar:fix/windows-notification-support
Open

Add Windows notification support via native toast fallback#50
Chebaleomkar wants to merge 2 commits into
warpdotdev:mainfrom
Chebaleomkar:fix/windows-notification-support

Conversation

@Chebaleomkar
Copy link
Copy Markdown

Problem

On Windows, the Warp Claude Code plugin's notifications silently fail. The OSC 777 escape sequences written to /dev/tty never reach Warp's terminal emulator because Claude Code's hook runner captures all stdio pipes (stdout for structured JSON responses, stderr for error handling).

Hooks fire correctly — verified via debug logging — but the notification never appears on screen.

Fixes #48

Solution

Added a Windows-native fallback that sends toast notifications via PowerShell's [Windows.UI.Notifications] API when /dev/tty fails:

New files

  • win-toast.ps1 — Sends Windows toast notifications branded as Warp (registers dev.warp.Warp AppUserModelId with Warp's icon)
  • win-notify.sh — Deduplication via mkdir lock (8s window), event-type routing, project context extraction

Modified files

  • warp-notify.sh — Try /dev/tty first, exit on success; fall back to stderr otherwise
  • on-stop.sh — Call win-notify.sh after warp-notify.sh
  • on-notification.sh — Same
  • on-permission-request.sh — Same

Event-specific notifications

Event Title Body
Task completed ✅ Task Completed — {project} Response summary from transcript
Input needed ⏳ Input Needed — {project} Claude is waiting for your input
Permission required 🔐 Permission Required — {project} Claude wants to run: {tool}

Key design decisions

  • Zero dependencies — uses built-in Windows 10/11 APIs via PowerShell
  • No macOS/Linux impactwin-notify.sh exits immediately if $WINDIR is unset
  • Deduplication — multiple hooks fire per event; mkdir atomic lock ensures only one toast per 8 seconds
  • Branded as Warp — registers AppUserModelId dev.warp.Warp with Warp's icon in Windows registry (HKCU, no admin needed)
  • Guard clause[ -f "$SCRIPT_DIR/win-notify.sh" ] in hooks, so older plugin versions without the file are unaffected

Testing

Tested on:

  • Windows 11 Home (10.0.26200)
  • Warp v0.2026.05.06.15.42.stable_05
  • Claude Code 2.1.77
  • Git Bash (MSYS2)
  • jq 1.8.1

All three notification types confirmed working with Warp branding and single-notification deduplication.

Related

On Windows, /dev/tty fails inside Claude Code's hook runner because
stdio is captured. OSC 777 escape sequences never reach Warp's
terminal emulator, so notifications silently fail.

This adds a Windows-native fallback using PowerShell's
Windows.UI.Notifications API:

- win-toast.ps1: Sends native Windows toasts branded as Warp
  (registers dev.warp.Warp AppUserModelId with Warp's icon)
- win-notify.sh: Deduplication (mkdir lock, 8s window) + event-type
  routing with project context in notification title
- Patched on-stop.sh, on-notification.sh, on-permission-request.sh
  to call win-notify.sh after warp-notify.sh
- Patched warp-notify.sh to try /dev/tty first, fall back gracefully

Zero dependencies — uses built-in Windows 10/11 APIs.
macOS/Linux behavior is unchanged.

Fixes warpdotdev#48
16 tests covering:
- Non-Windows exit (no-op on macOS/Linux)
- Windows detection and PowerShell invocation
- Deduplication via mkdir lock (8s window)
- Event type routing (stop, idle_prompt, permission_request, session_start)
- Project name extraction from cwd
- Hook script patching verification
- warp-notify.sh fallback logic
- win-toast.ps1 structure and Warp AppUserModelId

Tests use a mock PowerShell to verify behavior without sending
actual notifications — safe to run in CI on any platform.
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.

Notifications not working on Windows — OSC 777 sequences captured by Claude Code hook runner

1 participant