-
Notifications
You must be signed in to change notification settings - Fork 15
feat: Add copy-from-current toggle to TUI profile creation #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: Add copy-from-current toggle to TUI profile creation #23
Conversation
There was a problem hiding this 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()orcreate_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
| render_create_profile_input_field(frame, app, chunks[0]); | ||
| render_create_profile_checkbox(frame, app, chunks[1]); | ||
|
|
||
| let mut current_idx = 3; |
There was a problem hiding this comment.
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
| let mut current_idx = 3; | |
| let mut current_idx = 2; // Start after input field and checkbox |

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:
create_profile_copy_currentandcreate_profile_focused_on_checkboxin the App structcreate_from_current_with_resources()orcreate_profile()based on the togglestart_create_profile()andexit_create_profile()helper methods for cleaner codeThe UI shows a clean checkbox with text that updates based on state:
[x] Copy from current config(when enabled)[ ] Copy from current config(when disabled)CLI Parity
This brings the TUI inline with the CLI, which already supported both creation modes:
bridle profile create <harness> <name>→ creates an empty profilebridle profile create <harness> <name> --from-current→ copies from current configNow 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.