Skip to content

feat: add Wizard component for multi-step wizard flows#127

Merged
jdx merged 4 commits intomainfrom
feat/wizard
Jan 31, 2026
Merged

feat: add Wizard component for multi-step wizard flows#127
jdx merged 4 commits intomainfrom
feat/wizard

Conversation

@jdx
Copy link
Copy Markdown
Owner

@jdx jdx commented Jan 31, 2026

Summary

  • Add new Wizard component for building multi-step wizard flows with breadcrumb navigation
  • Add Navigation enum (Next, Back, Jump(usize), Stay, Done) for controlling flow
  • Add Section struct with label and run closure for each wizard step
  • Add breadcrumb styling fields to Theme (breadcrumb_active, breadcrumb_clickable, breadcrumb_future, breadcrumb_separator)
  • Update all theme constructors with appropriate breadcrumb colors

Features

  • Breadcrumb rendering with numbered sections: [1:Name] > 2:Tools > 3:Done
  • Escape key handling for back navigation
  • Proper Ctrl+C cleanup
  • Builder pattern API matching other demand components

Example usage

Wizard::new("Setup")
    .section("Name", |state: &mut State, theme| {
        state.name = Input::new("Your name").theme(theme).run()?;
        Ok(Navigation::Next)
    })
    .section("Done", |_, _| Ok(Navigation::Done))
    .run(&mut State::default())?;

Test plan

  • Unit tests for Navigation enum, Section, Wizard builder
  • Unit tests for handle_navigation_key helper
  • Example at examples/wizard.rs
  • All existing tests pass

🤖 Generated with Claude Code


Note

Medium Risk
Introduces a new interactive terminal flow (Wizard) and extends Theme with new styling fields, which can affect rendering and navigation behavior across consumers. Also changes Escape-cancel behavior in several prompts by clearing terminal output before returning Interrupted.

Overview
Adds a new Wizard API (with Navigation actions and handle_navigation_key) to run multi-step terminal flows and support numbered breadcrumb navigation.

Extends Theme with breadcrumb styling fields and updates all theme constructors to provide defaults.

Improves cancellation UX by calling clear() on Escape before returning io::ErrorKind::Interrupted in Confirm, Input, Select, and MultiSelect, and adds an examples/wizard.rs demo.

Written by Cursor Bugbot for commit 304b6eb. This will update automatically on new commits. Configure here.

@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Add a new Wizard component that supports:
- Multi-step wizard with breadcrumb navigation
- Navigation enum (Next, Back, Jump, Stay, Done)
- Section struct with label and run closure
- Breadcrumb rendering with numbered sections [1:Name] > 2:Tools
- Escape key handling for back navigation
- Proper Ctrl+C cleanup

Also adds breadcrumb styling fields to Theme:
- breadcrumb_active, breadcrumb_clickable, breadcrumb_future
- breadcrumb_separator

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Comment thread src/wizard.rs
Comment thread src/wizard.rs
Comment thread src/wizard.rs
- Add cursor restoration on successful wizard completion (Navigation::Done)
- Mark target section as visited when navigating Back or on Escape
- Add documentation for handle_navigation_key explaining it's a utility
  for library consumers implementing custom widgets

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is ON, but a Cloud Agent failed to start.

Comment thread src/wizard.rs
}
}
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Breadcrumb navigation is never rendered during wizard execution

Medium Severity

The render_breadcrumb() method exists but is never called during wizard execution, and sections cannot call it because they only receive (&mut S, &Theme) parameters without access to the Wizard instance. The PR description advertises "Breadcrumb rendering with numbered sections" as a feature, but no breadcrumb will ever be displayed. The doc comment on render_breadcrumb incorrectly states "Sections can call this to include the breadcrumb in their output if desired."

Additional Locations (1)

Fix in Cursor Fix in Web

Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
jdx and others added 2 commits January 31, 2026 11:34
When Escape is pressed, widgets now clear their rendered output before
returning the Interrupted error. This prevents stale widget output from
accumulating when navigating between sections in wizard flows.

Affected widgets: Select, MultiSelect, Input, Confirm

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix render_breadcrumb doc comment to accurately describe limitations
- Remove Section and SectionFn from public exports (users interact via
  Wizard::section() builder method)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jdx jdx merged commit 963be9b into main Jan 31, 2026
6 checks passed
@jdx jdx deleted the feat/wizard branch January 31, 2026 19:16
@jdx jdx mentioned this pull request Jan 31, 2026
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