Commit e3492a165c45
Changed files (2)
home
common
dev
pkgs
my
scripts
bin
home/common/dev/gh-news.nix
@@ -40,8 +40,8 @@
}
{
name = "Review with Claude";
- command = "gh-news-review {url}";
- interactive = true;
+ command = "gh-news-review -d {url}";
+ interactive = false;
}
];
};
pkgs/my/scripts/bin/gh-news-review
@@ -1,10 +1,21 @@
#!/usr/bin/env bash
# Review a GitHub PR/issue with Claude on a remote machine via shpool
-# Usage: gh-news-review <url>
+# Usage: gh-news-review [-d|--detach] <url>
+# -d, --detach Start session in background and return immediately
set -euo pipefail
-URL="$1"
+DETACH=false
+if [[ "${1:-}" == "-d" || "${1:-}" == "--detach" ]]; then
+ DETACH=true
+ shift
+fi
+
+URL="${1:-}"
+if [[ -z "$URL" ]]; then
+ echo "Usage: gh-news-review [-d|--detach] <url>" >&2
+ exit 1
+fi
# Extract session name from URL (e.g., pull-123 or issues-456)
SESSION_NAME="review-$(echo "$URL" | grep -oE '(pull|issues)/[0-9]+' | tr '/' '-')"
@@ -16,6 +27,19 @@ fi
PROMPT="Review $URL, and load the proper skill as needed (e.g. nixpkgs skills and workflows if it is a pr from NixOS/nixpkgs)"
-# SSH to aomi and run cr in a shpool session
-# Use bash -lc to ensure PATH includes Nix profile paths where cr is located
-exec ssh -t aomi.sbr.pm "shpool attach -f -c 'bash -lc \"cr \\\"$PROMPT\\\"\"' $SESSION_NAME"
+# Command to run in shpool session
+# Use absolute path to bash since shpool's default PATH doesn't include NixOS paths
+# bash -lc sources login profile to get Nix paths where cr is located
+# cd to src/nixpkgs so Claude has access to the codebase for reviews
+SHPOOL_CMD="shpool attach -f -c '/run/current-system/sw/bin/bash -lc \"cd ~/src/nixpkgs && cr \\\"$PROMPT\\\"\"' $SESSION_NAME"
+
+if [[ "$DETACH" == "true" ]]; then
+ # Start in background and return immediately
+ # shellcheck disable=SC2029 # Intentional client-side expansion
+ ssh aomi.sbr.pm "nohup $SHPOOL_CMD > /dev/null 2>&1 &"
+ echo "Started review session: $SESSION_NAME"
+ echo "Attach with: ssh -t aomi.sbr.pm 'shpool attach $SESSION_NAME'"
+else
+ # Interactive mode - attach to session
+ exec ssh -t aomi.sbr.pm "$SHPOOL_CMD"
+fi