Skip to content

Commit 6afdd70

Browse files
LukasWodkaclaude
andcommitted
fix(resources): drop the double blank before the set confirm hint (Bugbot #375)
After removing the intro banner, flag-driven interactive `resources set` (no --yes/--dry-run) opened with TWO blank lines: a Newline() immediately before PromptHint, which already self-leads with a newline. The dry-run path dropped its redundant Newline() (Section supplies one) but the confirm path kept the stacked pair, so the command no longer opened with a single blank line. Remove the redundant Newline() — PromptHint's own leading newline gives the one blank the PR's spacing contract promises. Adds TestSet_ConfirmOpensWithSingleBlank (drives the flag confirm path via runSet) to pin it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 3b40fb6 commit 6afdd70

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

‎internal/cli/resources_set.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,10 @@ func applyResourcesSet(ctx context.Context, p *ui.Printer, pr prompter, target *
266266
return&exitError{code: exitFailure, err: fmt.Errorf(
267267
"refusing to change the ceiling without confirmation: pass --yes, or run on a terminal")}
268268
}
269-
p.Newline()
269+
// PromptHint self-leads with a blank line, so this opens with a single
270+
// blank — no preceding Newline() (that stacked two: the #375 banner-
271+
// removal regression Bugbot caught). Mirrors the dry-run path, which
272+
// leans on Section's own leading newline.
270273
p.PromptHint("tracebloc keeps about 1 core and 3 GiB for itself on top of this — it fits on this machine.")
271274
proceed, cerr:=pr.Confirm(fmt.Sprintf("Let each training run use up to %s?", perRunSize(desired)), true)
272275
ifcerr!=nil {

‎internal/cli/resources_set_test.go‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,3 +670,41 @@ func TestSet_UntouchedGPUIsKept(t *testing.T) {
670670
}
671671

672672
funcboolPtr(bbool) *bool { return&b }
673+
674+
// proceedingPrompter answers the final confirm "yes"; the wizard prompts are
675+
// unused on the flag-driven path.
676+
typeproceedingPrompterstruct{}
677+
678+
func (proceedingPrompter) Input(string, string, string, func(string) error) (string, error) {
679+
return"", errInteractiveCancelled
680+
}
681+
func (proceedingPrompter) Select(string, string, []string, string) (string, error) {
682+
return"", errInteractiveCancelled
683+
}
684+
func (proceedingPrompter) Confirm(string, bool) (bool, error) { returntrue, nil }
685+
686+
// TestSet_ConfirmOpensWithSingleBlank: after the banner removal (#375) the
687+
// flag-driven confirm path must still open with exactly ONE blank line.
688+
// PromptHint self-leads with a newline, so a preceding Newline() stacked two —
689+
// the command opened with a double blank (Bugbot #375). Pins the single-blank
690+
// opening so the redundant Newline() can't creep back.
691+
funcTestSet_ConfirmOpensWithSingleBlank(t*testing.T) {
692+
fakeHelm(t)
693+
cs:=csWith("8", "32Gi", map[string]string{"RESOURCE_LIMITS": "cpu=2,memory=8Gi"})
694+
out, err:=runSet(t, cs, proceedingPrompter{}, setReq{cores: "4", coresSet: true})
695+
iferr!=nil {
696+
t.Fatalf("flag-driven confirm + proceed should succeed: %v\n%s", err, out)
697+
}
698+
head:=out
699+
iflen(head) >48 {
700+
head=head[:48]
701+
}
702+
// PromptHint emits "\n <hint>\n": exactly one leading newline, then two
703+
// spaces. A double blank ("\n\n…") is the regression.
704+
if!strings.HasPrefix(out, "\n ") {
705+
t.Errorf("confirm path must open with a single blank line then the hint, got %q", head)
706+
}
707+
ifstrings.HasPrefix(out, "\n\n") {
708+
t.Errorf("confirm path opens with a DOUBLE blank line (banner-removal regression): %q", head)
709+
}
710+
}

0 commit comments

Comments
 (0)