Skip to content

Commit ce6db78

Browse files
committed
add warp terminal guard and start notificatoin
1 parent 0e9636f commit ce6db78

2 files changed

Lines changed: 27 additions & 6 deletions

File tree

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
11
#!/bin/bash
22
# Hook script for Claude Code SessionStart event
3-
# Shows welcome message and Warp detection status
3+
# Shows welcome message, Warp detection status, and emits plugin version
44

5-
# Check if running in Warp terminal
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
source "$SCRIPT_DIR/build-payload.sh"
7+
8+
# Read hook input from stdin
9+
INPUT=$(cat)
10+
11+
# Read plugin version from plugin.json
12+
PLUGIN_VERSION=$(jq -r '.version // "unknown"' "$SCRIPT_DIR/../.claude-plugin/plugin.json" 2>/dev/null)
13+
14+
# Emit structured notification with plugin version so Warp can track it
15+
BODY=$(build_payload "$INPUT" "session_start" \
16+
--arg plugin_version "$PLUGIN_VERSION")
17+
"$SCRIPT_DIR/warp-notify.sh" "warp://cli-agent" "$BODY"
18+
19+
# Output system message for the Claude Code UI
620
if [ "$TERM_PROGRAM" = "WarpTerminal" ]; then
721
# Running in Warp - notifications will work
8-
cat << 'EOF'
22+
cat << EOF
923
{
10-
"systemMessage": "🔔 Warp plugin active. You'll receive native Warp notifications when tasks complete or input is needed."
24+
"systemMessage": "🔔 Warp plugin v${PLUGIN_VERSION} active. You'll receive native Warp notifications when tasks complete or input is needed."
1125
}
1226
EOF
1327
else
1428
# Not running in Warp - suggest installing
15-
cat << 'EOF'
29+
cat << EOF
1630
{
17-
"systemMessage": "ℹ️ Warp plugin installed but you're not running in Warp terminal. Install Warp (https://warp.dev) to get native notifications when Claude completes tasks or needs input."
31+
"systemMessage": "ℹ️ Warp plugin v${PLUGIN_VERSION} installed but you're not running in Warp terminal. Install Warp (https://warp.dev) to get native notifications when Claude completes tasks or needs input."
1832
}
1933
EOF
2034
fi

plugins/warp/scripts/warp-notify.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
# For structured Warp notifications, title should be "warp://cli-agent"
66
# and body should be a JSON string matching the cli-agent notification schema.
77

8+
# Only emit notifications when running in Warp.
9+
# Otherwise, folks that use warp _and_ another terminal will get
10+
# garbled notifications whenever they run claude elsewhere.
11+
if [ "$TERM_PROGRAM" != "WarpTerminal" ]; then
12+
exit 0
13+
fi
14+
815
TITLE="${1:-Notification}"
916
BODY="${2:-}"
1017

0 commit comments

Comments
 (0)