-
-
Notifications
You must be signed in to change notification settings - Fork 77
feat: Use external editor for command editing instead of inline editor #77
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
- Replaces readline inline editor with external editor (Git-like approach) - Uses $EDITOR or $VISUAL environment variables - Falls back to common editors (vim, vi, nano, emacs) if env vars not set - Creates temporary file for editing with command pre-filled - Properly handles stdin/stdout/stderr for terminal editor support Fixes #76 Co-authored-by: Alvin <alvinunreal@users.noreply.github.com>
|
@claude fix ci |
|
Claude finished @alvinunreal's task —— View job ✅ CI Fixed!Todo List:
Summary:Fixed the golangci-lint errcheck issues in
The changes have been pushed to the branch and CI should now pass. --- | |
Code Review for PR #77: Use external editor for command editingSummaryThis PR successfully replaces the inline readline editor with an external editor approach (similar to Git), addressing issue #76. The implementation is clean and follows good practices overall. ✅ Strengths
🔍 Code Quality & Best Practices1. Temporary file permissions (Security)The temporary file is created with default permissions. Consider setting more restrictive permissions: tmpFile, err := os.CreateTemp("", "tmuxai-edit-*.sh")
if err != nil {
// ...
}
// Set restrictive permissions immediately after creation
os.Chmod(tmpFile.Name(), 0600)2. Resource leak preventionIn internal/confirm.go:94, consider using defer tmpFile.Close() immediately after successful creation to ensure the file handle is always closed: tmpFile, err := os.CreateTemp("", "tmuxai-edit-*.sh")
if err != nil {
// ...
}
defer tmpFile.Close()🐛 Potential Issues1. Windows compatibilityThe fallback editors list (vim, vi, nano, emacs) is Unix-centric. Consider adding Windows editors: editors := []string{"vim", "vi", "nano", "emacs"}
if runtime.GOOS == "windows" {
editors = []string{"notepad", "notepad++"}
}2. Empty editor scenarioGood error handling when no editor is found, providing clear user guidance. ⚡ Performance Considerations
🔒 Security Considerations
🧪 Test CoverageMissing tests: The confirm.go file lacks a corresponding test file. Consider adding tests for:
Example test structure: func TestConfirmedToExecFn_EditCommand(t *testing.T) {
// Test EDITOR env var
// Test VISUAL env var
// Test fallback to common editors
// Test no editor found scenario
// Test file operations
}📝 Additional Suggestions
✅ Overall AssessmentThe implementation is solid and addresses the issue well. With the security improvement for file permissions and addition of tests, this would be production-ready. The code is clean, readable, and follows Go idioms properly. Great work on this feature! The Git-like approach is much more user-friendly than inline editing. |
- Properly handle os.Remove error in defer statement - Check error returns for tmpFile.Close() calls - Fixes CI linting failures Co-authored-by: Alvin <alvinunreal@users.noreply.github.com>
Code Review for PR #77: External Editor for Command EditingThanks for this contribution! I've reviewed the changes and here's my feedback: ✅ Strengths
🔍 Code Quality & Best Practices
🐛 Potential Issues
⚡ Performance Considerations
🔒 Security Concerns
🧪 Test CoverageMissing Tests: The confirm.go file lacks a corresponding test file (confirm_test.go). Consider adding:
💡 Suggestions for Improvement
✨ Overall AssessmentThis is a solid implementation that improves the user experience by leveraging familiar external editors. The code is clean and follows Go best practices. With the security enhancements and test coverage additions suggested above, this would be an excellent addition to the project. The change successfully addresses issue #76 and provides a more robust editing experience than the inline readline approach. The Git-like approach is intuitive for developers and the fallback mechanism ensures it works out of the box for most users. |
Fixes #76