Skip to content

Commit 3c35744

Browse files
rysweetUbuntuclaude
authored
fix: make power steering counter session-specific (#1605)
The power steering counter was showing total invocations across ALL sessions instead of just the current session's invocations. Changes: - stop.py: Update _increment_power_steering_counter() to accept session_id and store counter in session-specific path (power-steering/{session_id}/) - statusline.sh: Look for counter in session-specific path when session_id is available (matches lock counter pattern) This aligns with how the lock counter works - each session has its own invocation count, not a global total. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Ubuntu <azureuser@amplihack2.yb0a3bvkdghunmsjr4s3fnfhra.phxx.internal.cloudapp.net> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8026738 commit 3c35744

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

.claude/tools/amplihack/hooks/stop.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ def process(self, input_data: Dict[str, Any]) -> Dict[str, Any]:
124124
transcript_path, session_id, progress_callback=progress_tracker.emit
125125
)
126126

127-
# Increment counter for statusline display
128-
self._increment_power_steering_counter()
127+
# Increment counter for statusline display (session-specific)
128+
self._increment_power_steering_counter(session_id)
129129

130130
if ps_result.decision == "block":
131131
# Check if this is first stop (visibility feature)
@@ -459,14 +459,26 @@ def read_continuation_prompt(self) -> str:
459459
self.log(f"Error reading custom prompt: {e} - using default", "WARNING")
460460
return DEFAULT_CONTINUATION_PROMPT
461461

462-
def _increment_power_steering_counter(self) -> None:
462+
def _increment_power_steering_counter(self, session_id: str) -> int:
463463
"""Increment power-steering invocation counter for statusline display.
464464
465-
Writes counter to .claude/runtime/power-steering/session_count for statusline to read.
465+
Writes counter to .claude/runtime/power-steering/{session_id}/session_count
466+
for statusline to read. Session-specific like lock counter.
467+
468+
Args:
469+
session_id: Session identifier
470+
471+
Returns:
472+
New count value
466473
"""
467474
try:
468475
counter_file = (
469-
self.project_root / ".claude" / "runtime" / "power-steering" / "session_count"
476+
self.project_root
477+
/ ".claude"
478+
/ "runtime"
479+
/ "power-steering"
480+
/ session_id
481+
/ "session_count"
470482
)
471483
counter_file.parent.mkdir(parents=True, exist_ok=True)
472484

@@ -481,10 +493,12 @@ def _increment_power_steering_counter(self) -> None:
481493
# Increment and write
482494
new_count = current_count + 1
483495
counter_file.write_text(str(new_count))
496+
return new_count
484497

485498
except Exception as e:
486499
# Fail-safe: Don't break hook if counter write fails
487500
self.log(f"Failed to update power-steering counter: {e}", "DEBUG")
501+
return 0
488502

489503
def _increment_lock_counter(self, session_id: str) -> int:
490504
"""Increment lock mode invocation counter for session.

.claude/tools/statusline.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,18 @@ else
169169
fi
170170
fi
171171

172-
# Power-steering global counter (total invocations across all sessions)
173-
# Note: session_id is NOT required - counter should show regardless
172+
# Power-steering session counter (invocations for current session)
173+
# Uses session_id in path like lock counter
174174
power_steering_str=""
175175
# Use CLAUDE_PROJECT_DIR to find counter (works in worktrees)
176176
project_dir="${CLAUDE_PROJECT_DIR:-$current_dir}"
177-
ps_count_file="$project_dir/.claude/runtime/power-steering/session_count"
178-
if [ -f "$ps_count_file" ]; then
179-
ps_count=$(cat "$ps_count_file" 2>/dev/null || echo "0")
180-
if [ "$ps_count" -gt 0 ] 2>/dev/null; then
181-
power_steering_str=" \033[35m🚦×$ps_count\033[0m"
177+
if [ -n "$session_id" ]; then
178+
ps_count_file="$project_dir/.claude/runtime/power-steering/$session_id/session_count"
179+
if [ -f "$ps_count_file" ]; then
180+
ps_count=$(cat "$ps_count_file" 2>/dev/null || echo "0")
181+
if [ "$ps_count" -gt 0 ] 2>/dev/null; then
182+
power_steering_str=" \033[35m🚦×$ps_count\033[0m"
183+
fi
182184
fi
183185
fi
184186

0 commit comments

Comments
 (0)