Skip to content

Commit 859dd18

Browse files
committed
Bugfix: Enhanced Status Footer - Fix 3 critical issues
Fixed all 3 reported bugs in enhanced status footer: ## Issue #1: Session Duration Shows "0m" ⏱️ Root Cause: session-start-time file missing for old sessions Fix: Added fallback to context-loaded.flag timestamp Location: conversation-capture-user-prompt.sh:118-145 intelligent-status-notification.sh:144-172 Impact: Old sessions now show approximate duration Code Changes: - Check session-start-time first (v2.1+ sessions) - Fallback to context-loaded.flag (old sessions) - Cross-platform support (Linux stat -c, macOS stat -f) - Graceful degradation (default "0m" if neither exists) ## Issue #2: Last Sync Shows "0m ago" 🔄 Root Cause: UX wording issue ("0m ago" sounds wrong) Fix: Changed "0m ago" to "Just now" + added days support Location: conversation-capture-user-prompt.sh:180-199 intelligent-status-notification.sh:204-223 Impact: Better UX, handles multi-day gaps Code Changes: - 0 minutes → "Just now" - < 60 minutes → "Xm ago" - < 1440 minutes (24h) → "Xh ago" - >= 1440 minutes → "Xd ago" ## Issue #3: No Notifications Despite 174 ops 💡 Root Cause: Slash commands didn't update last-memory-sync timestamp Fix: Created helper library + integrated with all sync operations Files: - NEW: .claude/hooks/lib/update-sync-timestamp.sh (helper) - MODIFIED: pre-compact-umb-sync.sh (integration) - MODIFIED: memory-sync.sh (integration) Impact: Notifications now work correctly Helper Features: - Updates timestamp to current time - Clears notification flags (prevent duplicates) - Safe (exits 0 on errors, non-blocking) - Reusable (DRY principle) ## Documentation - NEW: docs/BUGFIX-ANALYSIS.md (350+ lines comprehensive analysis) ## Testing Strategy Phase 1: ✅ Safe (display-only fixes #1 & #2) Phase 2: ✅ Low risk (timestamp integration #3) Risk Level: LOW (all changes additive, no breaking changes) Testing Required: Restart Claude Code to verify Next: User will restart and test all 3 fixes
1 parent 7888ea3 commit 859dd18

File tree

7 files changed

+499
-7
lines changed

7 files changed

+499
-7
lines changed

.claude/cache/.gitkeep

Whitespace-only changes.

.claude/hooks/conversation-capture-user-prompt.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,24 @@ fi
117117
# Get session duration
118118
session_start_file="$CLAUDE_TMP/session-start-time"
119119
session_duration="0m"
120+
start_time=0
121+
120122
if [ -f "$session_start_file" ]; then
123+
# Use explicit session start time (v2.1+)
121124
start_time=$(cat "$session_start_file" 2>/dev/null || echo "0")
125+
else
126+
# Fallback: Use context-loaded.flag timestamp (for old sessions)
127+
context_flag="$CLAUDE_TMP/context-loaded.flag"
128+
if [ -f "$context_flag" ]; then
129+
start_time=$(stat -c %Y "$context_flag" 2>/dev/null || stat -f %m "$context_flag" 2>/dev/null || echo "0")
130+
fi
131+
fi
132+
133+
if [ "$start_time" -gt 0 ]; then
122134
current_time=$(date +%s)
123135
duration_seconds=$((current_time - start_time))
124136
duration_minutes=$((duration_seconds / 60))
137+
125138
if [ "$duration_minutes" -lt 60 ]; then
126139
session_duration="${duration_minutes}m"
127140
else
@@ -171,11 +184,17 @@ if [ -f "$last_sync_file" ]; then
171184
last_sync_time=$(cat "$last_sync_file" 2>/dev/null || echo "0")
172185
current_time=$(date +%s)
173186
minutes_ago=$(( (current_time - last_sync_time) / 60 ))
174-
if [ "$minutes_ago" -lt 60 ]; then
187+
188+
if [ "$minutes_ago" -eq 0 ]; then
189+
last_sync="Just now"
190+
elif [ "$minutes_ago" -lt 60 ]; then
175191
last_sync="${minutes_ago}m ago"
176-
else
192+
elif [ "$minutes_ago" -lt 1440 ]; then
177193
hours_ago=$((minutes_ago / 60))
178194
last_sync="${hours_ago}h ago"
195+
else
196+
days_ago=$((minutes_ago / 1440))
197+
last_sync="${days_ago}d ago"
179198
fi
180199
fi
181200

.claude/hooks/intelligent-status-notification.sh

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,24 @@ build_status_footer() {
144144
# Get session duration
145145
local session_duration="0m"
146146
local session_start_file="$CLAUDE_TMP/session-start-time"
147+
local start_time=0
148+
147149
if [ -f "$session_start_file" ]; then
148-
local start_time=$(cat "$session_start_file" 2>/dev/null || echo "0")
150+
# Use explicit session start time (v2.1+)
151+
start_time=$(cat "$session_start_file" 2>/dev/null || echo "0")
152+
else
153+
# Fallback: Use context-loaded.flag timestamp (for old sessions)
154+
local context_flag="$CLAUDE_TMP/context-loaded.flag"
155+
if [ -f "$context_flag" ]; then
156+
start_time=$(stat -c %Y "$context_flag" 2>/dev/null || stat -f %m "$context_flag" 2>/dev/null || echo "0")
157+
fi
158+
fi
159+
160+
if [ "$start_time" -gt 0 ]; then
149161
local current_time=$(date +%s)
150162
local duration_seconds=$((current_time - start_time))
151163
local duration_minutes=$((duration_seconds / 60))
164+
152165
if [ "$duration_minutes" -lt 60 ]; then
153166
session_duration="${duration_minutes}m"
154167
else
@@ -195,11 +208,17 @@ build_status_footer() {
195208
local last_sync_time=$(cat "$last_sync_file" 2>/dev/null || echo "0")
196209
local current_time=$(date +%s)
197210
local minutes_ago=$(( (current_time - last_sync_time) / 60 ))
198-
if [ "$minutes_ago" -lt 60 ]; then
211+
212+
if [ "$minutes_ago" -eq 0 ]; then
213+
last_sync="Just now"
214+
elif [ "$minutes_ago" -lt 60 ]; then
199215
last_sync="${minutes_ago}m ago"
200-
else
216+
elif [ "$minutes_ago" -lt 1440 ]; then
201217
local hours_ago=$((minutes_ago / 60))
202218
last_sync="${hours_ago}h ago"
219+
else
220+
local days_ago=$((minutes_ago / 1440))
221+
last_sync="${days_ago}d ago"
203222
fi
204223
fi
205224

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
# Helper: Update last-memory-sync timestamp
3+
# Call this from any command that updates memory bank
4+
#
5+
# Usage:
6+
# bash .claude/hooks/lib/update-sync-timestamp.sh
7+
#
8+
# Purpose:
9+
# - Updates last-memory-sync timestamp to current time
10+
# - Clears notification flags (user acted on notification)
11+
# - Ensures status footer shows accurate "Last sync" time
12+
13+
set -euo pipefail
14+
15+
ROOT="${CLAUDE_PROJECT_DIR:-.}"
16+
CLAUDE_TMP="$ROOT/.claude/tmp"
17+
18+
# Update timestamp to current time
19+
echo "$(date +%s)" > "$CLAUDE_TMP/last-memory-sync"
20+
21+
# Clear notification flags (user has acted on notifications)
22+
rm -f "$CLAUDE_TMP/last-sync-notification" 2>/dev/null || true
23+
rm -f "$CLAUDE_TMP/update-notified-timestamp" 2>/dev/null || true
24+
rm -f "$CLAUDE_TMP/sync-notified-timestamp" 2>/dev/null || true
25+
26+
# Optional: Log the update (for debugging)
27+
# echo "[$(date --iso-8601=seconds)] Memory sync timestamp updated" >> "$CLAUDE_TMP/sync-updates.log"
28+
29+
exit 0

.claude/hooks/memory-sync.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ echo ""
170170
echo "🎯 Memory Bank synchronized successfully!"
171171
echo "📁 Context preserved in .claude/memory/"
172172

173-
# Record sync timestamp for notification system
174-
echo "$(date +%s)" > "$CLAUDE_TMP/last-memory-sync"
173+
# Update sync timestamp (Fix #3: Status footer integration)
174+
bash "$ROOT/.claude/hooks/lib/update-sync-timestamp.sh" 2>/dev/null || true
175175

176176
echo ""
177177
echo "Next session will load with complete context awareness."

.claude/hooks/pre-compact-umb-sync.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,7 @@ find "$MB/conversations/compact-summaries/" -name "precompact-*.md" -type f 2>/d
8686
echo " - Backup: .claude/tmp/precompact/$ts.md"
8787
} >> "$CLAUDE_TMP/hook-activity.log" 2>/dev/null || true
8888

89+
# Update sync timestamp (Fix #3: Status footer integration)
90+
bash "$ROOT/.claude/hooks/lib/update-sync-timestamp.sh" 2>/dev/null || true
91+
8992
exit 0

0 commit comments

Comments
 (0)