Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks to the UI for ie test #239

Merged
merged 1 commit into from
Nov 5, 2024
Merged
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
28 changes: 25 additions & 3 deletions internal/engine/test/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,34 @@ func (model TestModeModel) Update(message tea.Msg) (tea.Model, tea.Cmd) {
model.resourceGroupName = tmpResourceGroup
}
}
model.CommandLines = append(model.CommandLines, codeBlockState.StdOut)
model.CommandLines = append(
model.CommandLines,
ui.VerboseStyle.Render(codeBlockState.StdOut),
)
viewportContentUpdated = true

// Increment the codeblock and update the viewport content.
model.currentCodeBlock++

if model.currentCodeBlock < len(model.codeBlockState) {
nextTitle := model.codeBlockState[model.currentCodeBlock].StepName
nextCommand := model.codeBlockState[model.currentCodeBlock].CodeBlock.Content
nextLanguage := model.codeBlockState[model.currentCodeBlock].CodeBlock.Language

model.CommandLines = append(model.CommandLines, ui.CommandPrompt(nextLanguage)+nextCommand)
// Only add the title if the next step title is different from the current step.
if codeBlockState.StepName != nextTitle {
model.CommandLines = append(
model.CommandLines,
ui.StepTitleStyle.Render(
fmt.Sprintf("Step %d: %s", model.currentCodeBlock+1, nextTitle),
)+"\n",
)
}

model.CommandLines = append(
model.CommandLines,
ui.CommandPrompt(nextLanguage)+nextCommand,
)
}

// Only increment the step for azure if the step name has changed.
Expand Down Expand Up @@ -178,7 +195,10 @@ func (model TestModeModel) Update(message tea.Msg) (tea.Model, tea.Cmd) {
codeBlockState.SimilarityScore = message.SimilarityScore

model.codeBlockState[step] = codeBlockState
model.CommandLines = append(model.CommandLines, codeBlockState.StdErr+message.Error.Error())
model.CommandLines = append(
model.CommandLines,
ui.ErrorStyle.Render(codeBlockState.StdErr+message.Error.Error()),
)
viewportContentUpdated = true

commands = append(commands, common.Exit(true))
Expand Down Expand Up @@ -287,6 +307,8 @@ func NewTestModeModel(

language := codeBlockState[0].CodeBlock.Language
commandLines := []string{
ui.ScenarioTitleStyle.Render(title) + "\n",
ui.StepTitleStyle.Render("Step 1: "+codeBlockState[0].StepName) + "\n",
ui.CommandPrompt(language) + codeBlockState[0].CodeBlock.Content,
}

Expand Down
Loading