Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions internal/cmd/credentialcmd/credentialcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -1574,8 +1574,8 @@ func editInteractiveInitSecretsManagement(_ *cobra.Command, opts *root.Options,
func (p huhInitMenuPrompter) ChooseAction(prompt initMenuPrompt) (initMenuAction, error) {
action := initMenuInitialAction(prompt)
options := []huh.Option[initMenuAction]{
huh.NewOption(fmt.Sprintf("Configure reviewer entities (%d)", prompt.ReviewerEntityCount), initMenuActionReviewerEntities),
huh.NewOption(fmt.Sprintf("Configure LLM runtimes (%d)", prompt.LLMRuntimeCount), initMenuActionLLMRuntimes),
huh.NewOption(fmt.Sprintf("Configure reviewer entities (%d)", prompt.ReviewerEntityCount), initMenuActionReviewerEntities),
huh.NewOption(fmt.Sprintf("Configure review profiles (%d)", prompt.ReviewProfileCount), initMenuActionReviewProfiles),
huh.NewOption("Configure global settings", initMenuActionGlobalSettings),
huh.NewOption("Configure secrets management", initMenuActionSecretsManagement),
Expand Down Expand Up @@ -1616,12 +1616,12 @@ func (p huhInitMenuPrompter) ChooseAction(prompt initMenuPrompt) (initMenuAction
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Low (harness-engineering:harness-knowledge-reviewer): The PR description references a 'documented UX contract' for menu ordering (LLM runtimes → reviewer entities → review profiles → global settings → secrets management → commit → discard) but does not cite where that contract lives in the repo. If the rationale exists only in issue #341 or PR descriptions, it should be captured in a versioned docs/ artifact so contributors can understand the ordering without mining git history.

Reply to this thread when addressed.


func initMenuInitialAction(prompt initMenuPrompt) initMenuAction {
if prompt.CanConfigureReviewer {
return initMenuActionReviewerEntities
}
if prompt.CanConfigureLLM {
return initMenuActionLLMRuntimes
}
if prompt.CanConfigureReviewer {
return initMenuActionReviewerEntities
}
return initMenuActionReviewProfiles
}

Expand Down
50 changes: 46 additions & 4 deletions internal/cmd/credentialcmd/credentialcmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11325,8 +11325,8 @@ func TestHuhInitMenuPrompterAccessibleShowsMenuEntries(t *testing.T) {
}
out := stderr.String()
for _, want := range []string{
"Configure reviewer entities (3)",
"Configure LLM runtimes (2)",
"Configure reviewer entities (3)",
"Configure review profiles (1)",
"Configure global settings",
"Configure secrets management",
Expand All @@ -11344,11 +11344,13 @@ func TestHuhInitMenuPrompterAccessibleShowsMenuEntries(t *testing.T) {
t.Fatalf("stderr = %q, want temporary v2 menu item removed", out)
}
assertContentOrder(t, out,
"Configure reviewer entities (3)",
"Configure LLM runtimes (2)",
"Configure reviewer entities (3)",
"Configure review profiles (1)",
"Configure global settings",
"Configure secrets management",
"Commit staged changes and exit",
"Discard staged changes and exit",
)
}

Expand Down Expand Up @@ -11396,8 +11398,25 @@ func TestHuhInitMenuPrompterDefaultStartsAtTopWhenProfileIsActive(t *testing.T)
if err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Low (harness-engineering:harness-self-documenting-code-reviewer): TestHuhInitMenuPrompterDefaultStartsAtTopWhenProfileIsActive uses 'top' abstractly, but this PR changed what 'top' maps to (LLM runtimes is now first, previously reviewer entities). A name like TestHuhInitMenuPrompterDefaultStartsAtLLMRuntimesWhenWorkspaceActive makes the contract explicit and would catch future ordering regressions at the name level.

Reply to this thread when addressed.

t.Fatalf("ChooseAction: %v", err)
}
if action != initMenuActionLLMRuntimes {
t.Fatalf("action = %q, want LLM runtimes as first active-workspace configuration item", action)
}
}

func TestInitMenuInitialActionFallsBackToReviewerWhenLLMDisabled(t *testing.T) {
action := initMenuInitialAction(initMenuPrompt{
HasWorkspace: true,
CanConfigureReviewer: true,
})
if action != initMenuActionReviewerEntities {
t.Fatalf("action = %q, want first main-menu configuration item", action)
t.Fatalf("action = %q, want reviewer entities when LLM runtimes are disabled", action)
}
}

func TestInitMenuInitialActionStartsAtReviewProfilesBeforeWorkspace(t *testing.T) {
action := initMenuInitialAction(initMenuPrompt{})
if action != initMenuActionReviewProfiles {
t.Fatalf("action = %q, want review profiles before workspace-dependent actions are enabled", action)
}
}

Expand Down Expand Up @@ -11447,7 +11466,7 @@ func TestHuhInitMenuPrompterAccessibleRejectsDisabledLLMUntilProfileExists(t *te
var stderr bytes.Buffer
prompter := huhInitMenuPrompter{
stdin: strings.NewReader(strings.Join([]string{
"2", // Configure LLM runtimes (disabled)
"1", // Configure LLM runtimes (disabled)
"7", // Discard staged changes and exit
"",
}, "\n")),
Expand All @@ -11465,6 +11484,29 @@ func TestHuhInitMenuPrompterAccessibleRejectsDisabledLLMUntilProfileExists(t *te
}
}

func TestHuhInitMenuPrompterAccessibleRejectsDisabledReviewerUntilProfileExists(t *testing.T) {
t.Setenv("TERM", "dumb")
var stderr bytes.Buffer
prompter := huhInitMenuPrompter{
stdin: strings.NewReader(strings.Join([]string{
"2", // Configure reviewer entities (disabled)
"7", // Discard staged changes and exit
"",
}, "\n")),
stderr: &stderr,
}
action, err := prompter.ChooseAction(initMenuPrompt{})
if err != nil {
t.Fatalf("ChooseAction: %v", err)
}
if action == initMenuActionReviewerEntities {
t.Fatalf("action = %q, want disabled reviewer selection to be rejected", action)
}
if !strings.Contains(stderr.String(), "configure a review profile before editing reviewer entities") {
t.Fatalf("stderr = %q, want disabled-reviewer validation message", stderr.String())
}
}

func TestHuhInitMenuPrompterAccessibleSelectsReviewProfiles(t *testing.T) {
t.Setenv("TERM", "dumb")
var stderr bytes.Buffer
Expand Down
Loading