Skip to content

Conversation

@kaiiiiiiiii
Copy link
Contributor

@kaiiiiiiiii kaiiiiiiiii commented Jan 7, 2026

G'day! 👋

This PR adds a handy checkbox to the TUI when creating new profiles, letting users choose whether to copy their current config or start fresh. Previously this was only available via the CLI commands, but now it's all there in the TUI for those who prefer a bit of point-and-click action.

What Changed

Added a toggle to the profile creation dialog in the TUI that lets users decide whether to copy their current harness configuration or create a completely empty profile. The implementation includes:

  • New state fields create_profile_copy_current and create_profile_focused_on_checkbox in the App struct
  • Tab key cycles focus between the profile name input and the checkbox
  • Space key toggles the checkbox when it's focused
  • Visual feedback showing which element has focus (yellow styling and bold text for the active element)
  • Conditionally calls either create_from_current_with_resources() or create_profile() based on the toggle
  • Refactored the profile creation state management into start_create_profile() and exit_create_profile() helper methods for cleaner code
  • Fixed input popup rendering to be properly layered and widened it slightly to accommodate the new UI

The UI shows a clean checkbox with text that updates based on state:

  • [x] Copy from current config (when enabled)
image
  • [ ] Copy from current config (when disabled)
image

CLI Parity

This brings the TUI inline with the CLI, which already supported both creation modes:

  • bridle profile create <harness> <name> → creates an empty profile
  • bridle profile create <harness> <name> --from-current → copies from current config

Now users can do the same thing directly in the TUI.

Backwards Compatibility

To keep things steady and not break existing workflows, the default is true (copy from current) — same behaviour as before, just with a new option to opt out when you want a completely fresh profile.

@kaiiiiiiiii kaiiiiiiiii marked this pull request as ready for review January 7, 2026 20:09
@kaiiiiiiiii
Copy link
Contributor Author

kaiiiiiiiii commented Jan 7, 2026

Did some more basic refactoring and shifted the error message from the main UI bottom into the dialog. Looks heaps better now I reckon ˆˆ

I guess it's ready for review now :)

image

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR successfully brings the --from-current CLI flag functionality to the TUI by adding an interactive checkbox to the profile creation popup. The implementation allows users to toggle between copying from the current config (default behavior, maintaining backwards compatibility) or creating an empty profile.

Key Changes:

  • Added three new state fields to track checkbox state, focus, and error messages
  • Implemented Tab key navigation between input field and checkbox
  • Space key toggles the checkbox when focused
  • Conditionally calls create_from_current_with_resources() or create_profile() based on toggle state
  • Refactored popup rendering into modular functions with proper layout management
  • Error messages now display inline within the popup instead of in the status bar
  • Enhanced visual feedback with yellow highlighting and bold text for focused elements

Code Quality:
The code is well-structured with proper separation of concerns. State management is clean, error handling is comprehensive, and the UI provides clear visual feedback. The implementation correctly handles focus states and keyboard input without conflicts (Space adds to input when focused on text field, toggles checkbox when focused on checkbox).

Confidence Score: 5/5

  • This PR is safe to merge - the changes are well-contained, properly tested through visual inspection, maintain backwards compatibility, and follow existing code patterns
  • Score reflects excellent implementation quality with clean state management, proper error handling, intuitive UX, and no identified bugs. The code correctly handles all edge cases including focus management, keyboard input routing, and dynamic layout rendering.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
src/tui/mod.rs 5/5 Added checkbox toggle for copy-from-current option in TUI profile creation popup with proper state management, error handling, and visual feedback

Sequence Diagram

sequenceDiagram
    participant User
    participant TUI
    participant App
    participant ProfileManager
    
    User->>TUI: Press 'n' (new profile)
    TUI->>App: reset_create_profile_state()
    App->>App: Set input_mode = CreatingProfile
    App->>App: Set create_profile_copy_current = true (default)
    App->>App: Set create_profile_focused_on_checkbox = false
    TUI->>User: Show popup with input field focused
    
    alt User types profile name
        User->>TUI: Type characters
        TUI->>App: handle_input_key(Char)
        App->>App: input_buffer.push(c)
        App->>App: clear_create_profile_error()
    end
    
    alt User switches focus to checkbox
        User->>TUI: Press Tab
        TUI->>App: handle_input_key(Tab)
        App->>App: Toggle create_profile_focused_on_checkbox
        TUI->>User: Visual feedback (yellow/bold checkbox)
        
        User->>TUI: Press Space
        TUI->>App: handle_input_key(Space)
        App->>App: Toggle create_profile_copy_current
        TUI->>User: Update checkbox: [x] or [ ]
    end
    
    User->>TUI: Press Enter
    TUI->>App: create_profile_from_input()
    App->>App: Validate name not empty
    App->>App: Validate harness selected
    App->>App: Create ProfileName
    
    alt Copy from current config
        App->>ProfileManager: create_from_current_with_resources()
        ProfileManager-->>App: Ok(path)
    else Create empty profile
        App->>ProfileManager: create_profile()
        ProfileManager-->>App: Ok(path)
    end
    
    App->>App: Set status_message
    App->>App: refresh_profiles()
    App->>App: cancel_create_profile()
    TUI->>User: Close popup, show success message
Loading

render_create_profile_input_field(frame, app, chunks[0]);
render_create_profile_checkbox(frame, app, chunks[1]);

let mut current_idx = 3;
Copy link

Choose a reason for hiding this comment

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

hardcoded index 3 assumes specific layout order (input at 0, checkbox at 1, spacer at 2). if layout changes, this will break

Suggested change
let mut current_idx = 3;
let mut current_idx = 2; // Start after input field and checkbox

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