feat: add --service and --resource-id flags for startup navigation (#97)#100
feat: add --service and --resource-id flags for startup navigation (#97)#100
Conversation
- Add CLI flags: -s/--service, -i/--resource-id - Add DefaultResource() for sensible service defaults (ec2→instances, etc) - Add SetDefaultResource() for future config support - Show startup resource errors in StatusLine with flash message - Extract ReadOnlyBadgeStyle() to ui package - Refactor command_input.go to use DefaultResource()
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
Review Response (4th round)✅ #2 Leading slash validation
✅ #3 Error message UX
Race condition について前回説明の通り、 Commit: |
Pull Request Review: feat: add --service and --resource-id flags for startup navigation (#97)Overall, this is a well-implemented feature with excellent test coverage and thoughtful design. The code quality is high, and the implementation follows good practices. Below are my detailed findings: ✅ Strengths1. Code Quality & Best Practices
2. Test Coverage
3. User Experience
🔍 Areas for Improvement1. Potential Race Condition (Minor) Location: if a.startupPath != nil && a.startupPath.ResourceID != "" {
cmds = append(cmds, a.fetchStartupResource)
}Issue: The Recommendation: Consider chaining the resource fetch after AWS init completes, or add defensive error handling in 2. DAO Error Handling Could Be Clearer Location: d, err := a.registry.GetDAO(a.ctx, a.startupPath.Service, a.startupPath.ResourceType)
if err != nil {
log.Warn("failed to get DAO for startup resource", "error", err)
}Issue: The code logs a warning but continues to pass a potentially
Recommendation: Add a comment explaining why DAO failure is non-fatal, or verify that 3. Validation Gap: Resource ID Without Valid DAO Location: if opts.service != "" {
service, resourceType, err := resolveStartupService(strings.TrimSpace(opts.service))
// ...
startupPath = &app.StartupPath{
Service: service,
ResourceType: resourceType,
ResourceID: strings.TrimSpace(opts.resourceID),
}
}Issue: Recommendation: Add early validation in if opts.resourceID != "" {
if _, err := registry.Global.GetDAO(ctx, service, resourceType); err != nil {
fmt.Fprintf(os.Stderr, "Error: resource %s/%s does not support --resource-id\n", service, resourceType)
os.Exit(1)
}
}4. Input Validation Edge Case Location: parts := strings.SplitN(input, "/", 2)
service := parts[0]
if len(parts) > 1 {
resourceType = parts[1]
}
if strings.Contains(resourceType, "/") {
return "", "", fmt.Errorf("invalid resource type: %s", resourceType)
}Issue: The validation on line 248-250 is redundant because Minor note: This is working correctly but could be simplified. The current implementation is defensive and clear, so this is optional. 5. Concurrency Safety in DefaultResource (Addressed, but worth noting) Location: func (r *Registry) DefaultResource(service string) string {
r.mu.RLock()
userDefault := r.userDefaults[service]
r.mu.RUnlock()
// ...
}Good: The implementation correctly uses Potential issue: The Recommendation: Add a comment above 🔒 Security ConsiderationsNo significant security issues found. The implementation:
⚡ Performance ConsiderationsGenerally good, with one observation: Parallel Command Execution: The Recommendation: Monitor startup time with 🧪 Test Coverage AssessmentExcellent coverage overall:
Missing tests:
Recommendation: Add an integration test in
📝 Summary & RecommendationsPriority Fixes:
Optional Improvements:
✅ Approval StatusThis PR is ready to merge with the above considerations noted. The implementation is solid, well-tested, and follows the repository's conventions. The identified issues are minor and can be addressed in follow-up PRs if needed. Great work on this feature! 🎉 Reviewed by: Claude Code (Automated Review) |
Summary
-s/--serviceflag to start directly on a service/resource (e.g.,claws -s ec2,claws -s rds/snapshots)-i/--resource-idflag to open detail view for specific resource (requires--service)registry.DefaultResource()across codebaseReadOnlyBadgeStyle()toui/theme.gofollowing style helper patternChanges
cmd/claws/main.goresolveStartupService()with alias supportcmd/claws/startup_test.gointernal/app/app.goStartupPathstruct, startup navigation handlinginternal/registry/registry.goDefaultResource(),defaultResourcesmap (31 services)internal/view/command_input.goDefaultResource()instead ofListResources()[0]internal/view/resource_browser.goDefaultResource()instead ofListResources()[0]internal/ui/theme.goReadOnlyBadgeStyle()Usage
Closes #97