Skip to content

Hostname screen: rework into two-step selector + input flow#2

Merged
passcod merged 9 commits intomainfrom
hostname-screen-rework
Mar 5, 2026
Merged

Hostname screen: rework into two-step selector + input flow#2
passcod merged 9 commits intomainfrom
hostname-screen-rework

Conversation

@passcod
Copy link
Member

@passcod passcod commented Mar 5, 2026

Problem

The hostname screen had a confusing UX: a text input with a DHCP toggle checkbox below it for metal, and an optional text input for cloud. Users were presented with a required text input and a toggle that disables it at the same time, with no clear indication of which path to choose first.

Solution

Replace the single hostname screen with a two-step flow matching the variant selection pattern:

  1. Selector screen (Screen::Hostname): Up/Down selector choosing between "Static hostname" and "Network-assigned (DHCP)" (or "DHCP / cloud-init" for cloud).
  2. Input screen (Screen::HostnameInput): Text input shown only when Static is selected. Required (non-empty) for metal, optional for cloud.

If the user selects network-assigned, the flow skips the input screen and proceeds directly to Login.

Defaults by variant

  • Metal: Static hostname (selected by default)
  • Cloud: Network-assigned (selected by default)

Switching variant via the variant selection screen resets the default (unless a hostname has already been typed or was provided via template).

Config overrides

  • hostname-from-dhcp = true forces DHCP selected for any variant
  • A non-empty hostname or hostname-template forces Static selected

Changes

  • Added Screen::HostnameInput to the Screen enum
  • Updated advance() / go_back() navigation for the two-step flow
  • Rewrote Screen::Hostname key handler as Up/Down selector
  • Added Screen::HostnameInput key handler for text input
  • Rewrote render_hostname() as selector UI, added render_hostname_input()
  • Updated toggle_variant() to reset hostname default when switching variants
  • Bumped all tracey references from installer.tui.hostname+2 to +3
  • Updated all 8 affected files with test rewrites

Verification

  • cargo fmt -- clean
  • cargo clippy -- clean
  • tracey query stale -- no stale references
  • cargo test -- 252 unit tests + 68 integration tests pass (320 total)

passcod added 9 commits March 5, 2026 14:30
Replace the single-screen hostname text input with toggle approach with a
two-step flow: a selector screen (Static vs Network-assigned) followed by
an optional text input sub-screen.

The spec version is bumped from +2 to +3, marking all existing impl and
test references as stale.
The spec changes have already been committed. This rewrites the plan to
remove the spec change section and replace the implementation steps with a
detailed checklist that tracks every stale reference and what needs to
happen to each one.
Replace the single Hostname screen (text input with DHCP toggle) with a
two-step flow:

1. Screen::Hostname - an Up/Down selector choosing between 'Static hostname'
   and 'Network-assigned (DHCP)' (or 'DHCP / cloud-init' for cloud variant).
   Metal defaults to Static, Cloud defaults to Static (configurable via
   hostname-from-dhcp config).

2. Screen::HostnameInput - text input for the hostname, shown only when
   Static is selected. Required (non-empty) for metal, optional for cloud.

If the user selects network-assigned, the flow skips HostnameInput and
proceeds directly to Login.

Updates all tracey references from installer.tui.hostname+2 to +3.
Updates all unit tests and integration tests for the new flow.
Per the spec, cloud defaults to 'Network-assigned (DHCP / cloud-init)'
while metal defaults to 'Static hostname'. The default is set at
construction time based on the variant, and toggle_variant() resets it
when switching between variants (unless a hostname has been typed or
was provided via a hostname template).

Config overrides:
- hostname-from-dhcp = true forces DHCP selected for any variant
- A non-empty hostname or hostname-template forces Static selected

Also adds tests for the new defaulting behavior.
…iants

Choosing 'Static hostname' is an explicit decision to set a hostname, so
an empty value is never accepted — regardless of whether the variant is
metal or cloud. Previously cloud allowed empty static hostnames.

Also fixes the spec formatting: the hostname requirement now uses quoted
(> prefixed) lines so tracey correctly tracks the full multi-paragraph
requirement body. Bumps installer.tui.hostname from +3 to +4.
Add hostname format validation on Enter in the HostnameInput screen:
- Only ASCII letters, digits, and hyphens allowed
- Must not start or end with a hyphen
- Max 63 characters
- Cannot be empty (already enforced, now with same validator)

Extract validate_hostname() into config.rs as a shared function used by
both the config file validator and the TUI key handler. Validation errors
are shown inline in red and cleared when the user types or backspaces.

Also fixes the spec formatting for the hostname requirement to use
quoted (> prefixed) multi-paragraph blocks so tracey tracks the full
body. Bumps installer.tui.hostname from +4 to +5.
Validate hostname format live as the user types (Char/Backspace),
showing errors immediately instead of waiting for Enter. The empty
hostname check is still only enforced on Enter to avoid nagging
while the user is still typing.

Updated existing test and added a new test to verify the live
validation behavior.
@passcod passcod merged commit 1316044 into main Mar 5, 2026
12 checks passed
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.

1 participant