Skip to content

GH#2898: Fix quality-debt in session-count-helper.sh from PR #2883 review feedback#2962

Merged
marcusquinn merged 1 commit intomainfrom
bugfix/session-count-quality-debt
Mar 6, 2026
Merged

GH#2898: Fix quality-debt in session-count-helper.sh from PR #2883 review feedback#2962
marcusquinn merged 1 commit intomainfrom
bugfix/session-count-quality-debt

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Mar 6, 2026

Summary

Fixes quality-debt from PR #2883 Gemini review feedback (2 medium-severity findings).

Changes

  • Remove blanket 2>/dev/null from all pgrep calls (lines 84, 120, 143, 148, 153, 167, 204): || true is sufficient to handle the no-match exit code; 2>/dev/null was hiding potential system errors like "command not found"
  • Extend list_sessions() to include Cursor, Windsurf, and Aider sessions: Previously only OpenCode and Claude Code were listed with details, causing a mismatch between count and list output. Added _print_session_detail() helper to reduce duplication
  • Replace pgrep -c with pgrep | wc -l for Cursor/Windsurf/Aider counting: pgrep -c is Linux-only; the new pattern is cross-platform (macOS + Linux)

Verification

  • ShellCheck: clean (only SC1091 info for external source)
  • Syntax check: passes
  • Runtime test: count and list commands work correctly

Closes #2898

Summary by CodeRabbit

  • Bug Fixes

    • Improved error visibility: diagnostic messages from session checks are now displayed instead of being silently suppressed, providing better insight into system status.
  • Enhancements

    • Expanded session detection to include additional editors (Cursor, Windsurf, Aider) alongside existing tools.
    • Refined session listing output format for clearer information display.

@gemini-code-assist
Copy link

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 6, 2026

Warning

Rate limit exceeded

@marcusquinn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 22 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a3629c51-f8f1-4681-8978-9743fcf8f515

📥 Commits

Reviewing files that changed from the base of the PR and between 18d89e9 and 360ef96.

📒 Files selected for processing (1)
  • .agents/scripts/session-count-helper.sh

Walkthrough

The PR addresses quality feedback by removing stderr suppression (2>/dev/null) from pgrep calls across shell scripts, improving error visibility for debugging. The session-count-helper is refactored with a standardized output helper and extended to list Cursor, Windsurf, and Aider sessions alongside existing OpenCode and Claude Code sessions.

Changes

Cohort / File(s) Summary
Caller Scripts
.agents/scripts/aidevops-update-check.sh, .agents/scripts/pre-edit-check.sh
Removed stderr redirection (2>/dev/null) from session-count-helper invocations to allow error visibility while maintaining || true fallback handling.
Session Helper Refactor
.agents/scripts/session-count-helper.sh
Removed 2>/dev/null suppression from all pgrep calls; replaced pgrep -c with cross-platform wc -l counting; added _print_session_detail helper for standardized session output; extended list_sessions to include Cursor, Windsurf, and Aider sessions; improved filtering logic to exclude headless processes via command-line checks.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • #2855: Covers related session-count checks and session-reporting utilities that overlap with this PR's session counting and listing functionality.

Suggested labels

bug

Poem

🔍 No more silent errors hiding in the night,
Each stderr flows free, bringing clarity to light,
Session helpers now unified with pride,
Cursor, Windsurf, Aider—all counted side by side! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing quality-debt issues in session-count-helper.sh identified in PR #2883 review feedback, with reference to issue #2898.
Linked Issues check ✅ Passed All coding requirements from issue #2898 are met: removed 2>/dev/null from pgrep calls using || true instead, extended list_sessions to include Cursor/Windsurf/Aider sessions with _print_session_detail helper, and replaced pgrep -c with pgrep | wc -l for cross-platform compatibility.
Out of Scope Changes check ✅ Passed All changes are directly scoped to addressing the two medium findings from issue #2898; no unrelated modifications to other files or functionality were introduced.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/session-count-quality-debt

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
.agents/scripts/session-count-helper.sh (2)

160-167: Broad aider pattern may match unrelated processes.

The pattern 'aider' will match any process with "aider" anywhere in its command line, including unrelated matches like paths containing "aider" or processes like "raider". Consider a more specific pattern:

💡 Suggested refinement
 	# --- Aider sessions ---
 	local aider_pids=""
-	aider_pids=$(pgrep -f 'aider' || true)
+	aider_pids=$(pgrep -f '[/[:space:]]aider([[:space:]]|$)' || true)

Alternatively, if aider is typically invoked directly:

-	aider_pids=$(pgrep -f 'aider' || true)
+	aider_pids=$(pgrep -x aider || pgrep -f 'python.*aider' || true)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/scripts/session-count-helper.sh around lines 160 - 167, The pgrep
call using the broad pattern 'aider' can match unrelated commands; update the
helper to match the actual process name or full executable path instead. Replace
pgrep -f 'aider' with a stricter match (for example pgrep -x 'aider' || true) or
use the full path (pgrep -f '/path/to/aider' || true) so the variables
aider_pids and aider_count only include real aider processes; keep the existing
logic that computes aider_count and increments count.

141-149: Cross-platform note: Cursor detection is macOS-centric.

The pattern Cursor\.app targets macOS application bundles. On Linux, Cursor typically runs as cursor or similar. Consider adding a fallback pattern for Linux users:

💡 Optional enhancement for Linux support
 	# --- Cursor sessions ---
 	# Note: pgrep -c is Linux-only; use pgrep | wc -l for cross-platform
 	local cursor_pids=""
-	cursor_pids=$(pgrep -f 'Cursor\.app' || true)
+	cursor_pids=$(pgrep -f 'Cursor\.app' || pgrep -xf 'cursor' || true)
 	if [[ -n "$cursor_pids" ]]; then
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/scripts/session-count-helper.sh around lines 141 - 149, The cursor
detection currently only looks for the macOS bundle pattern 'Cursor\.app'
(variable cursor_pids / cursor_count); update the pgrep invocation to include a
cross-platform fallback so Linux processes named "cursor" are matched too (e.g.,
broaden the search pattern or try a second pgrep for "cursor" when the first
returns empty), and ensure the existing logic that counts lines into
cursor_count and adds to count remains unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.agents/scripts/session-count-helper.sh:
- Around line 160-167: The pgrep call using the broad pattern 'aider' can match
unrelated commands; update the helper to match the actual process name or full
executable path instead. Replace pgrep -f 'aider' with a stricter match (for
example pgrep -x 'aider' || true) or use the full path (pgrep -f
'/path/to/aider' || true) so the variables aider_pids and aider_count only
include real aider processes; keep the existing logic that computes aider_count
and increments count.
- Around line 141-149: The cursor detection currently only looks for the macOS
bundle pattern 'Cursor\.app' (variable cursor_pids / cursor_count); update the
pgrep invocation to include a cross-platform fallback so Linux processes named
"cursor" are matched too (e.g., broaden the search pattern or try a second pgrep
for "cursor" when the first returns empty), and ensure the existing logic that
counts lines into cursor_count and adds to count remains unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e6673766-57a5-427f-8fc9-94440defe286

📥 Commits

Reviewing files that changed from the base of the PR and between d79cc43 and 18d89e9.

📒 Files selected for processing (3)
  • .agents/scripts/aidevops-update-check.sh
  • .agents/scripts/pre-edit-check.sh
  • .agents/scripts/session-count-helper.sh

@marcusquinn
Copy link
Owner Author

Merge conflict detected — cannot auto-merge. Dispatching worker to rebase and resolve. PR has APPROVED review from coderabbitai and passing CI.

…ions() coverage

Address PR #2883 review feedback (GH#2898):
- Remove 2>/dev/null from all pgrep calls — || true already handles no-match
  exit codes, and stderr suppression hid real errors (e.g. pgrep -c unsupported
  on macOS)
- Replace Linux-only pgrep -c with pgrep | wc -l for cross-platform compat
- Extend list_sessions() to include Cursor, Windsurf, and Aider processes,
  matching the coverage of count_interactive_sessions()
- Extract _print_session_detail() helper to reduce duplication in list output
- Remove 2>/dev/null from session-count-helper.sh callers in
  aidevops-update-check.sh and pre-edit-check.sh

Closes #2898
@marcusquinn marcusquinn force-pushed the bugfix/session-count-quality-debt branch from 18d89e9 to 360ef96 Compare March 6, 2026 03:04
@github-actions
Copy link

github-actions bot commented Mar 6, 2026

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 108 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Fri Mar 6 03:04:52 UTC 2026: Code review monitoring started
Fri Mar 6 03:04:53 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 108

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 108
  • VULNERABILITIES: 0

Generated on: Fri Mar 6 03:04:55 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 6, 2026

@marcusquinn marcusquinn merged commit 4f4a7cc into main Mar 6, 2026
11 of 12 checks passed
@marcusquinn marcusquinn deleted the bugfix/session-count-quality-debt branch March 6, 2026 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

quality-debt: .agents/scripts/session-count-helper.sh — PR #2883 review feedback (medium)

1 participant