-
Notifications
You must be signed in to change notification settings - Fork 5
fix: sed portability, speech-to-speech reliability (t145, t141) #447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add sed_inplace() function to shared-constants.sh and each script that uses sed -i. macOS requires 'sed -i ""' while GNU/Linux requires 'sed -i'. The wrapper detects the platform and uses the correct syntax. Scripts fixed: agent-test-helper.sh, privacy-filter-helper.sh, quality-fix.sh, security-helper.sh, supervisor-helper.sh, version-manager.sh. Archived scripts left as-is (not actively used). ShellCheck: zero new violations.
…g (t141) cmd_stop: Replace fixed sleep 2 with polling loop (up to 5s) that checks process termination every 0.5s before force-killing. cmd_setup: Wrap nltk.download in error check so failures are visible instead of silently suppressed. Non-fatal warning since not all TTS engines require NLTK data.
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. WalkthroughThe PR resolves cross-platform sed portability issues by introducing a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
Summary of ChangesHello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on enhancing the robustness and cross-platform compatibility of the project's shell scripts. It standardizes Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Sat Feb 7 17:06:24 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a portable sed_inplace wrapper function to handle differences between macOS and Linux sed, and refactors several scripts to use it. It also improves the reliability of the speech-to-speech-helper.sh script. The review identifies a few areas for improvement related to the refactoring: code duplication of the new function, a case of redundant code, and an instance where the new abstraction is used inappropriately. The changes to speech-to-speech-helper.sh are solid improvements.
| if [[ "$(uname)" == "Darwin" ]]; then | ||
| sed -i '' "${line_num}a\\ | ||
| sed_inplace "${line_num}a\\ | ||
| ${notes_line}" "$todo_file" | ||
| else | ||
| sed -i "${line_num}a\\${notes_line}" "$todo_file" | ||
| sed_inplace "${line_num}a\\${notes_line}" "$todo_file" | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using sed_inplace here is not ideal because the arguments to sed for the append (a) command are themselves platform-dependent (BSD vs. GNU sed have different syntax for newlines). The sed_inplace function only abstracts the -i flag. This leads to a redundant outer uname check and makes the code more complex than necessary. It would be clearer to revert this specific change to use sed -i '' and sed -i directly within the if/else block as it was before, since the abstraction doesn't fully cover this use case.
| if [[ "$(uname)" == "Darwin" ]]; then | |
| sed -i '' "${line_num}a\\ | |
| sed_inplace "${line_num}a\\ | |
| ${notes_line}" "$todo_file" | |
| else | |
| sed -i "${line_num}a\\${notes_line}" "$todo_file" | |
| sed_inplace "${line_num}a\\${notes_line}" "$todo_file" | |
| fi | |
| if [[ "$(uname)" == "Darwin" ]]; then | |
| sed -i '' "${line_num}a\ | |
| ${notes_line}" "$todo_file" | |
| else | |
| sed -i "${line_num}a\\${notes_line}" "$todo_file" | |
| fi |
| log_header() { echo -e "${PURPLE}${BOLD}$*${NC}"; } | ||
|
|
||
| # Cross-platform sed in-place edit (macOS vs GNU/Linux) | ||
| sed_inplace() { if [[ "$(uname)" == "Darwin" ]]; then sed -i '' "$@"; else sed -i "$@"; fi; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sed_inplace function is duplicated across multiple scripts in this PR (agent-test-helper.sh, privacy-filter-helper.sh, quality-fix.sh, security-helper.sh, supervisor-helper.sh). To improve maintainability and adhere to the DRY (Don't Repeat Yourself) principle, consider having these scripts source shared-constants.sh to use the canonical function defined there. This would centralize the logic and make future updates easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acknowledged but intentionally deferred. These scripts are standalone (none source shared-constants.sh). Adding a source dependency to each would be a larger refactor with its own risks (path resolution, circular sourcing, etc.). The inline one-liner is self-contained and grep-able. A future refactor to consolidate via sourcing is tracked but not in scope for this bugfix PR.
| # Apply redaction | ||
| if [[ "$(uname)" == "Darwin" ]]; then | ||
| sed -i '' -E "s/$pattern/[REDACTED]/g" "$file" | ||
| sed_inplace -E "s/$pattern/[REDACTED]/g" "$file" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While using sed_inplace is a good step towards portability, the surrounding if [[ "$(uname)" == "Darwin" ]] is now redundant because sed_inplace performs the same OS check internally. To simplify the code and avoid this redundant check, the entire if/else block should be replaced with a single call: sed_inplace -E "s/$pattern/[REDACTED]/g" "$file".
- privacy-filter-helper.sh: remove redundant uname check around sed_inplace - supervisor-helper.sh: use direct sed -i for append command (syntax differs between BSD/GNU beyond just the -i flag, so sed_inplace can't abstract it)
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Sat Feb 7 17:14:22 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
- Fix CPU-only auto-detect falling back to cuda (crashes on CPU hosts) Now defaults to --server mode with warning - Add docker guard to cmd_stop (consistent with cmd_docker_start/cmd_status) - Replace || exit with || return 1 in docker functions (proper set -e handling) - Replace hardcoded 192.168.1.100 with <server-ip> placeholder in help - Fix PyTorch version typo: 2.10+ -> 2.4+ (matches upstream torch>=2.4.0) - Add API key storage guidance for OpenAI API usage Already fixed in prior PRs (replied with evidence): - nltk stderr suppression (PR #447) - cmd_stop fixed sleep 2 -> polling loop (PR #447) - transcribe command docs removed (commit fd2aa84) - detect_gpu stderr no longer suppressed - shift pattern refactored to explicit if/shift - README Voice section already condensed ShellCheck: zero violations.
- Fix CPU-only auto-detect falling back to cuda (crashes on CPU hosts) Now defaults to --server mode with warning - Add docker guard to cmd_stop (consistent with cmd_docker_start/cmd_status) - Replace || exit with || return 1 in docker functions (proper set -e handling) - Replace hardcoded 192.168.1.100 with <server-ip> placeholder in help - Fix PyTorch version typo: 2.10+ -> 2.4+ (matches upstream torch>=2.4.0) - Add API key storage guidance for OpenAI API usage Already fixed in prior PRs (replied with evidence): - nltk stderr suppression (PR #447) - cmd_stop fixed sleep 2 -> polling loop (PR #447) - transcribe command docs removed (commit fd2aa84) - detect_gpu stderr no longer suppressed - shift pattern refactored to explicit if/shift - README Voice section already condensed ShellCheck: zero violations.



Summary
sed -iportable across macOS and Linux. Addedsed_inplace()wrapper function toshared-constants.shand 6 active scripts. macOS requiressed -i ''while GNU/Linux requiressed -i(no argument).speech-to-speech-helper.shstop reliability (polling loop instead of fixed sleep) and NLTK download error handling (visible warnings instead of silent suppression).Changes
34c7899sed_inplace()in 7 scripts, replace allsed -i ''calls5b4eaefScripts Modified (t145)
shared-constants.sh- canonicalsed_inplace()definitionagent-test-helper.sh- replaced fallback patternprivacy-filter-helper.sh- replaced direct callquality-fix.sh- replaced 2 direct callssecurity-helper.sh- replaced 3 direct callssupervisor-helper.sh- replaced 3 platform-specific blocksversion-manager.sh- replaced 2 direct calls (function already existed)Quality
_archive/) left as-isCloses #440, closes #445
Summary by CodeRabbit
Bug Fixes
Chores