Skip to content

Open a yes/no prompt on its default, so Enter picks it - #802

Merged
robzolkos merged 4 commits into
mainfrom
fix-confirm-default
Sep 30, 2026
Merged

robzolkos merged 4 commits into
mainfrom
fix-confirm-default

Conversation

@robzolkos

@robzolkos robzolkos commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

When the CLI asks a yes/no question, pressing Enter picks No, even when the question means Yes. tui.Confirm(message, defaultValue) never used its default: the answer started as false, so every prompt opened on No.

Where it bites:

  • basecamp connect setup (Guided connect setup, and notices that speak to the person in the thread #794): "Work in all of your agent's projects?" defaults to Yes, but Enter answers No and setup ends with "No projects were chosen, so nothing was set up".
  • basecamp setup: "Set up Basecamp for your coding agents?" and "Set a default project?" both behave the same way. forms.go last changed in August, so this is probably in v0.11.0 too.

The prompt now opens on the default it's given. The skill-overwrite prompt defaults to No and behaves as before.

The exception is accessible mode (TERM=dumb). There huh answers end of input with the prompt's default and can't tell it from Enter (accessibility.go:147), so a Yes default would let Ctrl+D consent. In that mode the prompt opens on No ([y/N]), and a Yes has to be typed.

The tests run Confirm through a small runConfirmForm seam and answer it via the field's own input handling: Enter, and answers typed against the default. They also check that end of input in accessible mode never gives Yes. They fail with the old code and with a prompt that isn't bound to Confirm's result.

Card: https://app.basecamp.com/2914079/buckets/48699913/card_tables/cards/10356301063


Summary by cubic

Fixes tui.Confirm so a yes/no prompt opens on the default answer, letting Enter pick it.

Every prompt previously opened on No, so pressing Enter answered No in basecamp connect setup and basecamp setup even when the question meant Yes. The skill-overwrite prompt defaults to No and behaves as before. Tests answer the form through a runConfirmForm seam and drive the field key by key with the key map the runForm gives every form, checking Enter picks the default, typed answers override it, and answering moves on.

The exception is accessible mode (TERM=dumb): huh answers end of input with the prompt's default and can't tell it from Enter, so a Yes default would let Ctrl+D consent. There the prompt opens on No, and a Yes must be typed. A test covers this too.

bubbletea v1.3.10 is now a direct requirement; the test imports it.

Written for commit 37b6db3. Summary will update on new commits.

Review in cubic

tui.Confirm took a default but never used it: the answer started as
false, so every prompt opened on No, and pressing Enter answered No even
where the question meant Yes. `basecamp setup` asks "Set up Basecamp for
your coding agents?" and "Set a default project?" that way, and guided
`connect setup` asks "Work in all of your agent's projects?"; pressing
Enter there ended with no projects chosen.

The prompt now opens on the default it's given. Prompts that default to
No, like the skill overwrite, behave as before.
Copilot AI balanced review requested due to automatic review settings September 30, 2026 13:55
@github-actions github-actions Bot added tui Terminal UI tests Tests (unit and e2e) labels Sep 30, 2026
@robzolkos
robzolkos marked this pull request as ready for review September 30, 2026 14:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The test bypasses the prompt, so it does not verify what Enter selects.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

This PR updates the CLI’s shared yes/no prompt so Enter selects the supplied default, addressing setup prompts that unintentionally answered No.

Changes:

  • Initialize confirmation prompts from their default value.
  • Add a test for both Yes and No defaults.

[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

File Description
internal/​tui/​forms.go Initializes the prompt answer from its default.
internal/​tui/​forms_test.go Adds a test for both default values.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/tui/forms_test.go Outdated
With TERM=dumb, huh runs forms in accessible mode, which answers end of
input (Ctrl+D) with the prompt's default and can't tell it from Enter.
Now that a prompt opens on its default, a question that defaults to Yes,
like "Set up Basecamp for your coding agents?", would take Ctrl+D as
consent. In accessible mode the prompt opens on No and a Yes must be
typed.

The test now answers through the field's own input handling, typed
answers against the default included, so a prompt that isn't bound to
Confirm's result fails it.
Copilot AI balanced review requested due to automatic review settings September 30, 2026 14:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The tests do not exercise Enter in the normal interactive prompt, which is the behavior this PR aims to fix.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
Resolved since last review (1)

Comment thread internal/tui/forms_test.go
The earlier tests answer through huh's text-input path. This one drives
Confirm's field with the key map runForm gives every form, as the
interactive prompt does: Enter submits what the prompt opened on, y and
n answer, and the arrows toggle. It sets TERM itself, so it means the
same on a CI runner whose terminal is dumb.

bubbletea v1 was already in the module graph; the test's import makes
it a direct requirement.
Enter leaves a prompt's value as it opened, so a test asserting only the
value passed even with Enter unbound. The keyboard test now also checks
that the last key of each answer submits the field.
Copilot AI balanced review requested due to automatic review settings September 30, 2026 15:36
@github-actions github-actions Bot added the deps label Sep 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approved

The focused change has tests for both defaults and the accessible-mode exception, with no unresolved issues identified.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@robzolkos
robzolkos merged commit cbbed16 into main Sep 30, 2026
41 checks passed
@robzolkos
robzolkos deleted the fix-confirm-default branch September 30, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deps tests Tests (unit and e2e) tui Terminal UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants