feat: copy resource ID/ARN to clipboard (y/Y keys)#93
Conversation
- Add clipboard package with OSC52 + tmux/screen passthrough - y: copy resource ID, Y: copy ARN - Works in list view and detail view - Flash message shows copy confirmation
- Add y/Y keybindings to help_view.go and README.md - Add NoARNMsg for user feedback when ARN unavailable - Add inline comment for CopiedMsg.Value field
- Add cursor >= 0 check to prevent potential panic on negative cursor - Unify all handlers to Pattern A (positive check) - Affected: handleMark, handleEnter, handleAction, handleCopyID, handleCopyARN
This comment was marked as resolved.
This comment was marked as resolved.
- Add debug logging for OSC52 write failures - Verify command execution returns correct CopiedMsg - Test Label and Value fields in all copy functions
This comment was marked as resolved.
This comment was marked as resolved.
- Add package and function documentation to clipboard package - Add debug logging for native clipboard write failures - Extract flashDuration constant (2s) in app.go
This comment was marked as resolved.
This comment was marked as resolved.
- Add TestResourceBrowserCopyID/ARN/ARNNoARN/EmptyList - Add TestDetailViewCopyID/ARN/ARNNoARN - Add arn field to mockResource for testing
Code Review for PR #93: Copy Resource ID/ARN to ClipboardSummaryThis PR adds clipboard functionality ( ✅ Strengths
🔍 Code Quality & Best PracticesPositive
Minor Observations
🐛 Potential Bugs / IssuesNone identified. The code properly handles edge cases:
⚡ Performance Considerations
Verdict: No performance concerns. Operations are lightweight and appropriately scoped. 🔒 Security Concerns
Verdict: No security concerns identified. 🧪 Test CoverageClipboard Package
View Tests
Suggestions
📋 Suggestions for Improvement1. Message Type Assertion Safety (Low Priority)In tests like msg := cmd()
copiedMsg, ok := msg.(clipboard.CopiedMsg)
if !ok {
t.Fatalf("Expected CopiedMsg, got %T", msg)
}
if copiedMsg.Label != "ID" {
t.Errorf("Expected Label 'ID', got %q", copiedMsg.Label)
}
if copiedMsg.Value != "i-1234567890abcdef0" {
t.Errorf("Expected Value 'i-1234567890abcdef0', got %q", copiedMsg.Value)
}This would catch regressions where the wrong message type is returned. 2. Error Handling Documentation (Very Low Priority)The // Copy copies the given value to the clipboard and returns a tea.Cmd that sends a CopiedMsg.
// It writes to both OSC52 (terminal clipboard) and native system clipboard for maximum compatibility.
// Always returns CopiedMsg even if writes fail - clipboard operations are best-effort.
func Copy(label, value string) tea.Cmd {3. Potential Future EnhancementConsider adding the copied value to the debug log on success (not just failures): func Copy(label, value string) tea.Cmd {
return func() tea.Msg {
writeOSC52(value)
if err := clipboard.WriteAll(value); err != nil {
log.Debug("native clipboard write failed", "error", err)
} else {
log.Debug("copied to clipboard", "label", label) // Don't log value for privacy
}
return CopiedMsg{Label: label, Value: value}
}
}This would help with debugging clipboard issues without exposing sensitive data. 📖 Documentation✅ README.md updated with keybindings Suggestion: Consider adding a note in docs/architecture.md about the clipboard package under the "Directory Structure" section, since this is a new internal package. 🎯 Final Verdict✅ APPROVE - This is a high-quality implementation that I recommend merging. Checklist
Optional Follow-ups (Non-blocking)
Great work! This feature will be very useful for users working with AWS resources. 🎉 |
Summary
ykey to copy resource ID to clipboardYkey to copy resource ARN to clipboard (shows warning if no ARN)Implementation
internal/clipboardpackage with OSC52 + native clipboard supportdao.UnwrapResource())Changes
internal/clipboard/clipboard.go- OSC52 + atotto/clipboard dual-writeinternal/app/app.go- Flash message handlinginternal/view/resource_browser_input.go- y/Y handlersinternal/view/detail_view.go- y/Y handlersCloses #59