Skip to content

Commit a028a49

Browse files
committed
feat(pr-notify): accept explicit session ID parameter
Session-scoped daemons know exactly which session to notify. Bypassing anvil discovery for explicit session targets reduces latency and ensures correct routing. Authored By: opencode (claude-sonnet-4-5) commit-id:4da15748
1 parent cab95a6 commit a028a49

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

tools/pr-notify

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,29 @@ if [[ "${1:-}" == "--dry-run" ]]; then
1313
shift
1414
fi
1515

16-
# Get PR number and custom message (optional)
1716
PR_NUMBER="${1:-}"
1817
CUSTOM_MESSAGE="${2:-}"
18+
EXPLICIT_SESSION="${3:-}"
19+
20+
if [[ -n "$EXPLICIT_SESSION" ]]; then
21+
echo "Using explicit session: $EXPLICIT_SESSION" >&2
22+
if [[ -z "$CUSTOM_MESSAGE" ]]; then
23+
echo "ERROR: Explicit session requires custom message" >&2
24+
exit 1
25+
fi
26+
bash "${SCRIPT_DIR}/anvil" --session "$EXPLICIT_SESSION" "$CUSTOM_MESSAGE"
27+
exit 0
28+
fi
1929

20-
# Get current repo directory and remote URL
2130
REPO_DIR=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
2231

23-
# Get git remote URL to filter sessions working on this specific repo
2432
GIT_REMOTE=$(git remote get-url origin 2>/dev/null || echo "")
2533
if [[ -n "$GIT_REMOTE" ]]; then
26-
# Extract repo path from URL (works for both SSH and HTTPS)
27-
# git@github.com:owner/repo.git -> github.com/owner/repo
28-
# https://github.com/owner/repo.git -> github.com/owner/repo
2934
REPO_PATH=$(echo "$GIT_REMOTE" | sed -E 's#^(https://|git@)##' | sed 's#:#/#' | sed 's#\.git$##')
3035
else
3136
REPO_PATH=""
3237
fi
3338

34-
# Find all sessions in this repo using anvil
3539
SESSIONS=$(bash "${SCRIPT_DIR}/anvil" --list --repo "$REPO_DIR" --json 2>/dev/null)
3640
if [[ -z "$SESSIONS" ]] || [[ "$SESSIONS" == "[]" ]]; then
3741
echo "No sessions found in $REPO_DIR" >&2

0 commit comments

Comments
 (0)