Remove hardcoded values and implement environment-based configuration#2
Merged
JessyTsui merged 5 commits intoJessyTsui:masterfrom Jul 28, 2025
Merged
Conversation
- Replace hardcoded email addresses with SMTP_USER environment variable - Add session files to gitignore to prevent runtime data commits - Make email filtering use existing SMTP_USER instead of adding new EMAIL_FROM This simple fix makes the tool more portable without adding unnecessary complexity or new configuration variables.
## 🔧 Core Configuration Improvements - **Environment Variable Integration**: Updated ConfigManager to automatically load all SMTP/IMAP settings from environment variables - **Dynamic Configuration**: Replaced hardcoded email configurations with dynamic environment-based loading - **Simplified Configuration**: Removed redundant hardcoded values from config/channels.json ## 🛠️ Hardcoded Values Removal - **User Path Fix**: Replaced hardcoded user-specific Claude CLI path with configurable CLAUDE_CLI_PATH environment variable - **Dynamic Test Tokens**: Made test tokens dynamic instead of hardcoded values - **Configurable Timeouts**: All timeout values now use environment variables (SMTP_TIMEOUT, NOTIFICATION_TIMEOUT, etc.) - **SMTP Settings**: All SMTP connection timeouts now configurable via environment variables ## 📧 Email System Enhancements - **Automatic Provider Detection**: Email configuration automatically enables when SMTP_USER is provided - **Better Error Handling**: Improved SMTP connection reliability with configurable timeouts - **Test Suite**: Added comprehensive SMTP testing script with dynamic configuration ## 🔒 Security & Portability - **No Hardcoded Credentials**: All email addresses, hosts, and ports now come from environment variables - **Cross-Platform**: Removed user-specific paths and made system calls configurable - **Environment-First**: All configuration now follows environment variable best practices ## 📝 Files Modified - src/core/config.js: Enhanced to load all settings from environment variables - claude-control.js: Removed hardcoded user path, now uses CLAUDE_CLI_PATH - src/channels/email/smtp.js: Configurable SMTP timeouts - src/channels/local/desktop.js: Configurable notification timeouts - send-test-reply.js: Dynamic token generation and proper authentication - config/channels.json: Removed hardcoded email settings - test-smtp.js: Added comprehensive SMTP testing utility ## ✅ Testing - All notification systems tested and working - SMTP connection verified with new timeout settings - Dynamic token generation confirmed - Environment variable loading verified - Cross-platform compatibility maintained
- Document all new environment variables for timeouts and configuration - Include examples for multiple email providers (Gmail, QQ, 163, Outlook) - Provide clear setup instructions and best practices - Cover all timeout settings, paths, and optional configurations
- Update token extraction pattern to match [Claude-Code-Remote #TOKEN] format - Remove legacy TaskPing patterns to avoid confusion - This fixes the "No token found in email" error when replying to notifications
Add regex pattern to handle email replies with "Re: " prefix. When users reply to Claude-Code-Remote emails, email clients add "Re: " which was preventing token extraction.
Owner
|
LGTM! This PR nicely addresses the hardcoded values I left in the code when I rushed the initial upload. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR removes all hardcoded values throughout the codebase and implements a comprehensive environment-variable-based configuration system, making the application fully configurable for production deployment and open-source distribution.
Key Changes
Configuration System Overhaul
/Users/jessytsui/.nvm/...) with configurableCLAUDE_CLI_PATHEmail System Improvements
Re: [Claude-Code-Remote #TOKEN] ...[Claude-Code-Remote #TOKEN]format (resolves "No token found in email" errors)SMTP_TIMEOUTenvironment variable for connection reliabilitySecurity & Reliability
Environment Variables Added
Core Email Configuration
System & Timeout Configuration
Files Modified
Core Configuration
src/core/config.js- Environment-first configuration loadingclaude-remote.js- Added dotenv integration.env.example- Complete configuration documentationEmail & Communication
src/channels/email/smtp.js- Configurable SMTP timeoutssrc/relay/relay-pty.js- Fixed token extraction for Claude-Code-Remote format + email reply supportsrc/channels/local/desktop.js- Configurable notification timeoutsconfig/channels.json- Removed hardcoded email settingsSystem Integration
claude-control.js- Configurable Claude CLI pathsend-test-reply.js- Dynamic token generationtest-smtp.js- New comprehensive testing utilityRecent Updates
Email Reply Fix (Latest Commit)
[Claude-Code-Remote #TOKEN]andRe: [Claude-Code-Remote #TOKEN]formatsTesting Results
Migration Guide
Existing users: Copy
.env.exampleto.envand configure your settings. All functionality preserved.New users: Follow the setup guide in
.env.examplefor complete configuration.Important: After updating, restart the relay process to load the new email reply fix:
node src/relay/relay-pty.jsType of Change