feat(machine): smart prompt defaults for machine config#106
feat(machine): smart prompt defaults for machine config#106nvandessel wants to merge 1 commit intomainfrom
Conversation
|
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. 📒 Files selected for processing (2)
✨ 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 |
Greptile SummaryAdds smart prompt defaults for machine config by auto-detecting git user info and GPG keys. The Key changes:
Previous threads raised valid points:
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| internal/machine/prompts.go | Adds resolveDefaults() to auto-populate git config and GPG keys. Copy semantics are mostly correct, format differs from existing FormatGPGKeyChoice() helper. |
| internal/machine/prompts_test.go | Adds comprehensive tests for resolveDefaults(). Previous thread correctly notes test should verify Options slice independence. |
Last reviewed commit: 20a069a
| func TestResolveDefaults_NoCopy(t *testing.T) { | ||
| // Verify original prompts are not mutated | ||
| original := config.MachinePrompt{ | ||
| ID: "test", | ||
| Prompts: []config.PromptField{ | ||
| {ID: "user_name", Default: ""}, | ||
| }, | ||
| } | ||
| _ = resolveDefaults(original) | ||
| if original.Prompts[0].Default != "" { | ||
| t.Error("original prompts were mutated") | ||
| } | ||
| } |
There was a problem hiding this comment.
Test should also verify Options slice independence to ensure complete copy semantics. Add check like:
| func TestResolveDefaults_NoCopy(t *testing.T) { | |
| // Verify original prompts are not mutated | |
| original := config.MachinePrompt{ | |
| ID: "test", | |
| Prompts: []config.PromptField{ | |
| {ID: "user_name", Default: ""}, | |
| }, | |
| } | |
| _ = resolveDefaults(original) | |
| if original.Prompts[0].Default != "" { | |
| t.Error("original prompts were mutated") | |
| } | |
| } | |
| func TestResolveDefaults_NoCopy(t *testing.T) { | |
| // Verify original prompts are not mutated | |
| original := config.MachinePrompt{ | |
| ID: "test", | |
| Prompts: []config.PromptField{ | |
| {ID: "user_name", Default: "", Options: []string{"a", "b"}}, | |
| }, | |
| } | |
| result := resolveDefaults(original) | |
| if original.Prompts[0].Default != "" { | |
| t.Error("original prompts were mutated") | |
| } | |
| // Verify Options slice is independent (if modified) | |
| if len(original.Prompts[0].Options) != 2 { | |
| t.Error("original Options slice was modified") | |
| } | |
| } |
| p.Type = "select" | ||
| p.Options = []string{"None"} | ||
| for _, k := range keys { | ||
| p.Options = append(p.Options, fmt.Sprintf("%s — %s", k.KeyID, k.Email)) |
There was a problem hiding this comment.
Format differs from FormatGPGKeyChoice() in git.go (line 291-293) which uses "%s <%s> (%s)". Consider using the existing formatter for consistency, or document why different formats are needed.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
🌴 Frond StackManaged by frond |
Add resolveDefaults() to enrich prompts with auto-detected values: - user_name defaults from git config --global user.name - user_email defaults from git config --global user.email - signing_key converts to select dropdown when GPG keys detected (with "None" and "Enter manually..." options) - Post-processing extracts key IDs from formatted select values - Returns a copy, never mutates input prompts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
c8ad870 to
20a069a
Compare
|
@greptileai review |
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (52.94%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #106 +/- ##
==========================================
+ Coverage 48.68% 48.70% +0.01%
==========================================
Files 108 108
Lines 12059 12092 +33
==========================================
+ Hits 5871 5889 +18
- Misses 6188 6203 +15
🚀 New features to boost your workflow:
|
Summary
resolveDefaults()to enrich machine config prompts with auto-detected valuesuser_nameanduser_emaildefault fromgit config --globalsigning_keyconverts to select dropdown when GPG keys are detected (with "None" and "Enter manually..." options)Depends on: #PR1 (feat/ssh-keygen-wizard)
Test plan
make build && make lint && make testpasses🤖 Generated with Claude Code