Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin/claude-code/scripts/post-compaction.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ PROJECT=$(detect_project "$CWD")

# Ensure session exists
if [ -n "$SESSION_ID" ] && [ -n "$PROJECT" ]; then
curl -sf "${ENGRAM_URL}/sessions" \
curl -sf --max-time 3 "${ENGRAM_URL}/sessions" \
-X POST \
-H "Content-Type: application/json" \
-d "$(jq -n --arg id "$SESSION_ID" --arg project "$PROJECT" --arg dir "$CWD" \
Expand Down
16 changes: 12 additions & 4 deletions plugin/claude-code/scripts/session-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,23 @@ CWD=$(echo "$INPUT" | jq -r '.cwd // empty')
OLD_PROJECT=$(basename "$CWD" | tr '[:upper:]' '[:lower:]')
PROJECT=$(detect_project "$CWD")

# Ensure engram server is running
# Ensure engram server is running.
# Detach the daemon from the parent shell's job control: start it in a new
# session with no controlling terminal so a Ctrl-Z (SIGTSTP) or SIGHUP on the
# terminal can't suspend it. A suspended daemon keeps the port bound but stops
# answering, which hangs every later hook curl and leaks processes over time.
if ! curl -sf "${ENGRAM_URL}/health" --max-time 1 > /dev/null 2>&1; then
engram serve &>/dev/null &
if command -v setsid > /dev/null 2>&1; then
setsid engram serve < /dev/null > /dev/null 2>&1 &
else
nohup engram serve < /dev/null > /dev/null 2>&1 &
fi
sleep 0.5
fi

# Migrate project name if it changed (one-time, idempotent)
if [ "$OLD_PROJECT" != "$PROJECT" ] && [ -n "$OLD_PROJECT" ] && [ -n "$PROJECT" ]; then
curl -sf "${ENGRAM_URL}/projects/migrate" \
curl -sf --max-time 3 "${ENGRAM_URL}/projects/migrate" \
-X POST \
-H "Content-Type: application/json" \
-d "$(jq -n --arg old "$OLD_PROJECT" --arg new "$PROJECT" \
Expand All @@ -41,7 +49,7 @@ fi

# Create session
if [ -n "$SESSION_ID" ] && [ -n "$PROJECT" ]; then
curl -sf "${ENGRAM_URL}/sessions" \
curl -sf --max-time 3 "${ENGRAM_URL}/sessions" \
-X POST \
-H "Content-Type: application/json" \
-d "$(jq -n --arg id "$SESSION_ID" --arg project "$PROJECT" --arg dir "$CWD" \
Expand Down
4 changes: 3 additions & 1 deletion plugin/claude-code/scripts/session-stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ if [ -z "$SESSION_ID" ]; then
exit 0
fi

curl -sf "${ENGRAM_URL}/sessions/${SESSION_ID}/end" \
# --max-time bounds the request: if the daemon is unreachable or unresponsive
# the curl fails fast instead of hanging forever and leaking a process per stop.
curl -sf --max-time 3 "${ENGRAM_URL}/sessions/${SESSION_ID}/end" \
-X POST \
-H "Content-Type: application/json" \
-d '{}' \
Expand Down