From fa872a3718858dd7b9f430fe6cf2c2a237705f4a Mon Sep 17 00:00:00 2001 From: Natalie Date: Sun, 17 May 2026 06:35:35 -0700 Subject: [PATCH] =?UTF-8?q?feat(session):=20=E2=9C=A8=20enhance=20deep=20s?= =?UTF-8?q?earch=20to=20include=20session=20metadata?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- bin/rclaude | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/bin/rclaude b/bin/rclaude index e06dbe1..3f778c4 100755 --- a/bin/rclaude +++ b/bin/rclaude @@ -176,22 +176,47 @@ list_search_on() { list_sessions_on "$1" } -# Grep the full content of every Claude session JSONL on for and -# emit the matching rows in list_sessions_on() format. Used as a fallback when -# the cheap pattern path (first-message snippets + cwd) returns nothing. +# Grep the full content of every Claude session JSONL AND the per-session +# metadata index (~/.claude/sessions/*.json — which holds display names set +# via `claude -n `) on for , and emit matching rows in +# list_sessions_on() format. Used as a fallback when the cheap pattern path +# (first-message snippets + cwd) returns nothing. deep_search_on() { _host=$1; _pat=$2 _q=$(printf %s "$_pat" | sed "s/'/'\\\\''/g") + # Two passes: + # (a) grep every projects/*.jsonl for the pattern → recover uuid via filename + # (b) scan sessions/*.json (per-pid metadata: display name set via `claude -n`) + # via python, extract sessionId of any whose `name` contains the pattern + _py_script='import json, os, sys, glob +pat = os.environ.get("RCLAUDE_PAT", "").lower() +if not pat: sys.exit(0) +for f in glob.glob(os.path.expanduser("~/.claude/sessions/*.json")): + try: + d = json.load(open(f)) + except Exception: + continue + name = (d.get("name") or "").lower() + sid = d.get("sessionId") or "" + if pat in name and sid: + print(sid)' if is_local "$_host"; then - _files=$(grep -l -F -i -- "$_pat" "$HOME/.claude/projects/"*/*.jsonl 2>/dev/null || true) + _uuids_a=$(grep -l -F -i -- "$_pat" "$HOME/.claude/projects/"*/*.jsonl 2>/dev/null \ + | awk -F/ '{print $NF}' | sed 's/\.jsonl$//') + _uuids_b=$(RCLAUDE_PAT="$_pat" python3 -c "$_py_script" 2>/dev/null || true) else - _files=$(ssh -o BatchMode=yes -o ConnectTimeout=5 "$_host" \ - "grep -l -F -i -- '$_q' \$HOME/.claude/projects/*/*.jsonl 2>/dev/null" 2>/dev/null || true) + _uuids_a=$(ssh -o BatchMode=yes -o ConnectTimeout=5 "$_host" \ + "grep -l -F -i -- '$_q' \$HOME/.claude/projects/*/*.jsonl 2>/dev/null \ + | awk -F/ '{print \$NF}' | sed 's/\\.jsonl\$//'" 2>/dev/null || true) + _uuids_b=$(ssh -o BatchMode=yes -o ConnectTimeout=5 "$_host" \ + "RCLAUDE_PAT='$_q' python3 -" 2>/dev/null <