Skip to content

Improve input prompt for AWS profile#98

Merged
gtsiolis merged 4 commits intomainfrom
george/improve-prompt-for-profile
Mar 11, 2026
Merged

Improve input prompt for AWS profile#98
gtsiolis merged 4 commits intomainfrom
george/improve-prompt-for-profile

Conversation

@gtsiolis
Copy link
Copy Markdown
Member

Some improvements on the input prompt for AWS profile for #92.

Open to rebasing and merging afterwards.

BEFORE AFTER
Screenshot 2026-03-10 at 21 42 20 Screenshot 2026-03-10 at 21 38 14

@gtsiolis gtsiolis self-assigned this Mar 10, 2026
Base automatically changed from carole/drg-565 to main March 11, 2026 11:10
@gtsiolis gtsiolis force-pushed the george/improve-prompt-for-profile branch 2 times, most recently from c0e7cc2 to 706b249 Compare March 11, 2026 13:22
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: b9466a98-217e-48a3-a9f1-3fc32ca6af02

📥 Commits

Reviewing files that changed from the base of the PR and between c763b2e and fa61ef1.

📒 Files selected for processing (6)
  • internal/awsconfig/awsconfig.go
  • internal/awsconfig/awsconfig_test.go
  • internal/output/plain_format.go
  • internal/ui/components/input_prompt.go
  • internal/ui/components/input_prompt_test.go
  • test/integration/awsconfig_test.go
💤 Files with no reviewable changes (1)
  • internal/awsconfig/awsconfig_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/integration/awsconfig_test.go
  • internal/ui/components/input_prompt_test.go

📝 Walkthrough

Walkthrough

Removed dynamic files-to-modify logic and its test; replaced AWS config prompt and success text with fixed strings; refactored prompt rendering to support multi-line prompts and move option-label formatting into a helper; added unit tests for InputPrompt and updated integration tests.

Changes

Cohort / File(s) Summary
AWS configuration
internal/awsconfig/awsconfig.go
Removed filesToModify() and dynamic assembly of files list; replaced prompt with static "Configure AWS profile in ~/.aws/?" and success message with "AWS profile successfully configured"; retained write flow and interactive confirmation.
Prompt rendering & formatting
internal/ui/components/input_prompt.go, internal/output/plain_format.go
Refactored InputPrompt.View() to render multi-line prompts with a styled "?" prefix and moved option-label formatting into new FormatPromptLabels(options []InputOption) helper; adjusted label rendering and imports accordingly.
Tests — integration & unit
test/integration/awsconfig_test.go, internal/awsconfig/awsconfig_test.go, internal/ui/components/input_prompt_test.go
Updated integration test expectations for the new static prompt and success message; removed TestFilesToModify; added table-driven InputPrompt unit tests covering hidden, single/multi-option, and multi-line prompts.
Imports / manifest
go.*, go.mod (manifest changes implied)
Removed unused import (strings) from awsconfig; added/modified imports where needed for new rendering/tests; manifest updated due to test additions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested reviewers

  • silv-io
  • anisaoshafi
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: improving the input prompt for AWS profile configuration.
Description check ✅ Passed The description is directly related to the changeset, referencing the related PR and showing before/after screenshots of the improved input prompt.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch george/improve-prompt-for-profile

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
internal/ui/components/input_prompt.go (1)

42-75: Add a focused InputPrompt.View() test matrix.

This branch now owns prompt formatting locally, but the updated coverage only exercises one integration path and a substring match. A small component test table for no options / one option / multiple options / multi-line prompts would catch rendering drift without coupling TUI output back to the plain formatter.

Based on learnings: In reviews of code under internal/ui/components, allow TUI components to implement their own event rendering logic distinct from the plain-output rendering in internal/output/format.go. Ensure tests verify the separate rendering paths and avoid unintended coupling to the plain-output formatting.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/ui/components/input_prompt.go` around lines 42 - 75, Add a focused
table-driven unit test for InputPrompt.View() that exercises the component's own
rendering logic across the key cases: no options, one option, multiple options,
and multi-line prompts; for each case construct an InputPrompt with appropriate
prompt text and p.options (including labels), call View(), and assert the exact
rendered string includes the secondary "?" prefix, message styling output for
the first line, correctly formatted single "(label)" or multiple "[a/b]" option
label segments, and the secondary-styled trailing lines for multi-line
prompts—ensure the tests call InputPrompt.View() directly (not the plain
formatter in internal/output/format.go) so they validate the TUI component
rendering path independently.
internal/awsconfig/awsconfig.go (1)

224-246: Remove profileStatus.filesToModify() now that the copy is fixed.

Hardcoding the prompt and success text seems to have eliminated the last reason for profileStatus.filesToModify(). Dropping that helper would keep profileStatus focused on detection only and avoid stale message-formatting logic hanging around.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/awsconfig/awsconfig.go` around lines 224 - 246, Remove the
now-unused profileStatus.filesToModify() helper and any calls to it so
profileStatus is only responsible for detection; keep the current hardcoded
prompt and success messages in the interactive flow, and ensure the branch that
writes files still uses status.configNeeded and status.credsNeeded to call
writeConfigProfile and writeCredsProfile (and emits warnings on error) and then
emits the existing success string; delete the filesToModify() method and any
stale formatting logic tied to it from the profileStatus type and related code
paths.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/awsconfig/awsconfig.go`:
- Around line 224-246: Remove the now-unused profileStatus.filesToModify()
helper and any calls to it so profileStatus is only responsible for detection;
keep the current hardcoded prompt and success messages in the interactive flow,
and ensure the branch that writes files still uses status.configNeeded and
status.credsNeeded to call writeConfigProfile and writeCredsProfile (and emits
warnings on error) and then emits the existing success string; delete the
filesToModify() method and any stale formatting logic tied to it from the
profileStatus type and related code paths.

In `@internal/ui/components/input_prompt.go`:
- Around line 42-75: Add a focused table-driven unit test for InputPrompt.View()
that exercises the component's own rendering logic across the key cases: no
options, one option, multiple options, and multi-line prompts; for each case
construct an InputPrompt with appropriate prompt text and p.options (including
labels), call View(), and assert the exact rendered string includes the
secondary "?" prefix, message styling output for the first line, correctly
formatted single "(label)" or multiple "[a/b]" option label segments, and the
secondary-styled trailing lines for multi-line prompts—ensure the tests call
InputPrompt.View() directly (not the plain formatter in
internal/output/format.go) so they validate the TUI component rendering path
independently.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 1d22df7f-475d-4879-a7d9-952ccd4f4bc8

📥 Commits

Reviewing files that changed from the base of the PR and between 02fadd2 and c0e7cc2.

📒 Files selected for processing (3)
  • internal/awsconfig/awsconfig.go
  • internal/ui/components/input_prompt.go
  • test/integration/awsconfig_test.go

// "?" prefix in secondary color
sb.WriteString(styles.Secondary.Render("? "))

// Style trailing "?" with secondary color
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

issue: we never seem to be styling the "trailing ? with secondary color" like the comment says, so not sure what is the intent of this code

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oops, seems like a leftover as I was trying to have only the the prefix "?" use secondary color.

Nice catch! ⚾ Changed in 1790406.

sb.WriteString(styles.SecondaryMessage.Render(strings.Join(lines[1:], "\n")))
}

return sb.String()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: it looks like the logic to format the labels is duplicated in plain_format.go:62-89. Can we introduce a new helper FormatPromptLabels that's used in both places?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Made an attempt for this in fa61ef1.

@gtsiolis gtsiolis force-pushed the george/improve-prompt-for-profile branch from c763b2e to fa61ef1 Compare March 11, 2026 14:22
@gtsiolis gtsiolis merged commit 57f6c38 into main Mar 11, 2026
8 checks passed
@gtsiolis gtsiolis deleted the george/improve-prompt-for-profile branch March 11, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants